]> git.vomp.tv Git - vompclient.git/blob - afeed.cc
Fix text corruption in channel number display on live tv
[vompclient.git] / afeed.cc
1 /*
2     Copyright 2004-2005 Chris Tallon
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
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #include "afeed.h"
22
23 #include "log.h"
24 #include "demuxer.h"
25 #include "callback.h"
26
27
28 AFeed::AFeed(Callback* tcb)
29 : cb(*tcb)
30 {
31   audioEnabled = 1;
32 }
33
34 int AFeed::init()
35 {
36   return 1;
37 }
38
39 int AFeed::shutdown()
40 {
41   // FIXME
42   return 1;
43 }
44
45 void AFeed::disable()
46 {
47   audioEnabled = 0;
48 }
49
50 void AFeed::enable()
51 {
52   audioEnabled = 1;
53 }
54
55 int AFeed::start()
56 {
57   audioEnabled = 1;
58   return threadStart();
59 }
60
61 void AFeed::stop()
62 {
63         Log::getInstance()->log("AFeed", Log::DEBUG, "Stop1");
64   threadCancel();
65         Log::getInstance()->log("AFeed", Log::DEBUG, "Stop2");
66 }
67
68 void AFeed::threadMethod()
69 {
70   bool alen;
71
72   while(1)
73   {
74     threadCheckExit();
75
76     if (audioEnabled)
77     {
78       bool newdata=false;
79       alen = Demuxer::getInstance()->writeAudio(&newdata);
80
81       if (newdata) cb.call(this);
82       if (alen)
83       {
84            //Log::getInstance()->log("Afeed", Log::DEBUG, "written");
85            cb.call(this);
86       }
87       else
88       {
89         //MILLISLEEP(100);
90         MILLISLEEP(5); //Performance Issue Marten
91       }
92     }
93     else
94     {
95       Demuxer::getInstance()->flushAudio();
96       //Log::getInstance()->log("AFeed", Log::DEBUG, "No data delay");
97       //MILLISLEEP(100);
98       MILLISLEEP(5); //Performance Issue
99     }
100   }
101 }
102