]> git.vomp.tv Git - vompclient.git/blob - tfeed.cc
Fix black background for 16:9 live TV on 4:3 screen
[vompclient.git] / tfeed.cc
1 /*
2     Copyright 2008 Marten Richter
3     
4     This file is part of VOMP.
5     
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10     VOMP is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14     
15     You should have received a copy of the GNU General Public License
16     along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
17 */
18
19 #include "log.h"
20 #include "demuxer.h"
21 #include "callback.h"
22
23 #include "tfeed.h"
24
25 TFeed::TFeed(Callback* tcb): cb(*tcb)
26 {
27   teletextEnabled = 1;
28 }
29   
30 void TFeed::disable()
31 {
32   teletextEnabled = 0;
33 }
34
35 void TFeed::enable()
36 {
37   teletextEnabled = 1;
38 }
39
40 void TFeed::start()
41 {
42   teletextEnabled = 1;
43
44   threadStartProtect.lock();
45   feedThread = std::thread( [this]
46   {
47     threadStartProtect.lock();
48     threadStartProtect.unlock();
49     threadMethod();
50   });
51   threadStartProtect.unlock();
52 }
53
54 void TFeed::stop()
55 {
56   if (!feedThread.joinable()) return;
57   stopThread = true;
58   feedThread.join();
59   stopThread = false;
60 }
61
62 void TFeed::threadMethod()
63 {
64   bool tlen;
65   
66   while(1)
67   {
68     if (stopThread) return;
69
70     tlen = Demuxer::getInstance()->writeTeletext();
71     
72     if (tlen)
73     {
74       cb.call(this);
75 //        Log::getInstance()->log("Tfeed", Log::DEBUG, "written");
76     }
77     else
78     {
79       //MILLISLEEP(100);
80         MILLISLEEP(20); //Performance Issue Marten
81     }
82   }
83 }