]> git.vomp.tv Git - vompclient.git/blob - afeed.cc
Initial import of patches for ARM/Android/Raspeberry pi
[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   threadCancel();\r
64 }\r
65 \r
66 void AFeed::threadMethod()\r
67 {\r
68   bool alen;\r
69 \r
70   while(1)\r
71   {\r
72     threadCheckExit();\r
73 \r
74     if (audioEnabled)\r
75     {\r
76       alen = Demuxer::getInstance()->writeAudio();\r
77 \r
78       if (alen)\r
79       {\r
80           cb.call(this);\r
81 //        Log::getInstance()->log("Afeed", Log::DEBUG, "written");\r
82       }\r
83       else\r
84       {\r
85         //MILLISLEEP(100);\r
86         MILLISLEEP(5); //Performance Issue Marten\r
87       }\r
88     }\r
89     else\r
90     {\r
91       Demuxer::getInstance()->flushAudio();\r
92       //Log::getInstance()->log("AFeed", Log::DEBUG, "No data delay");\r
93       //MILLISLEEP(100);\r
94       MILLISLEEP(5); //Performance Issue\r
95     }\r
96   }\r
97 }\r
98 \r