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