29 files changed, 1229 insertions, 893 deletions
diff --git a/core/multimedia/opieplayer/Makefile.in b/core/multimedia/opieplayer/Makefile.in index 1b0307a..8d33fb4 100644 --- a/core/multimedia/opieplayer/Makefile.in +++ b/core/multimedia/opieplayer/Makefile.in | |||
@@ -91,190 +91,203 @@ OBJMOC = moc_loopcontrol.o \ | |||
91 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< | 91 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< |
92 | 92 | ||
93 | ####### Build rules | 93 | ####### Build rules |
94 | 94 | ||
95 | 95 | ||
96 | all: $(DESTDIR)$(TARGET) | 96 | all: $(DESTDIR)$(TARGET) |
97 | 97 | ||
98 | $(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) | 98 | $(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) |
99 | $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) | 99 | $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) |
100 | 100 | ||
101 | moc: $(SRCMOC) | 101 | moc: $(SRCMOC) |
102 | 102 | ||
103 | tmake: | 103 | tmake: |
104 | tmake mpegplayer.pro | 104 | tmake mpegplayer.pro |
105 | 105 | ||
106 | clean: | 106 | clean: |
107 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) | 107 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) |
108 | -rm -f *~ core | 108 | -rm -f *~ core |
109 | -rm -f allmoc.cpp | 109 | -rm -f allmoc.cpp |
110 | 110 | ||
111 | ####### Extension Modules | 111 | ####### Extension Modules |
112 | 112 | ||
113 | listpromodules: | 113 | listpromodules: |
114 | @echo | 114 | @echo |
115 | 115 | ||
116 | listallmodules: | 116 | listallmodules: |
117 | @echo | 117 | @echo |
118 | 118 | ||
119 | listaddonpromodules: | 119 | listaddonpromodules: |
120 | @echo | 120 | @echo |
121 | 121 | ||
122 | listaddonentmodules: | 122 | listaddonentmodules: |
123 | @echo | 123 | @echo |
124 | 124 | ||
125 | 125 | ||
126 | REQUIRES= | 126 | REQUIRES= |
127 | 127 | ||
128 | ####### Sub-libraries | 128 | ####### Sub-libraries |
129 | 129 | ||
130 | 130 | ||
131 | ###### Combined headers | 131 | ###### Combined headers |
132 | 132 | ||
133 | 133 | ||
134 | 134 | ||
135 | ####### Compile | 135 | ####### Compile |
136 | 136 | ||
137 | main.o: main.cpp \ | 137 | main.o: main.cpp \ |
138 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 138 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
139 | $(OPIEDIR)/include/qpedecoration_qws.h \ | ||
140 | $(OPIEDIR)/include/timestring.h \ | ||
139 | mediaplayerstate.h \ | 141 | mediaplayerstate.h \ |
140 | playlistwidget.h \ | 142 | playlistwidget.h \ |
141 | $(OPIEDIR)/include/qpe/applnk.h \ | 143 | $(OPIEDIR)/include/qpe/applnk.h \ |
142 | audiowidget.h \ | 144 | audiowidget.h \ |
143 | videowidget.h \ | 145 | videowidget.h \ |
144 | loopcontrol.h \ | 146 | loopcontrol.h \ |
145 | mediaplayer.h \ | 147 | mediaplayer.h \ |
146 | $(OPIEDIR)/include/qpe/qlibrary.h \ | 148 | $(OPIEDIR)/include/qpe/qlibrary.h \ |
147 | $(OPIEDIR)/include/qpe/qcom.h \ | 149 | $(OPIEDIR)/include/qpe/qcom.h \ |
148 | $(OPIEDIR)/include/qpe/quuid.h \ | 150 | $(OPIEDIR)/include/qpe/quuid.h \ |
149 | $(OPIEDIR)/include/qpe/mediaplayerplugininterface.h | 151 | mediaplayerplugininterface.h |
150 | 152 | ||
151 | loopcontrol.o: loopcontrol.cpp \ | 153 | loopcontrol.o: loopcontrol.cpp \ |
152 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 154 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
153 | $(OPIEDIR)/include/qpe/qcopenvelope_qws.h \ | 155 | $(OPIEDIR)/include/qpedecoration_qws.h \ |
156 | $(OPIEDIR)/include/timestring.h \ | ||
154 | loopcontrol.h \ | 157 | loopcontrol.h \ |
155 | videowidget.h \ | 158 | videowidget.h \ |
156 | audiodevice.h \ | 159 | audiodevice.h \ |
157 | mediaplayerplugininterface.h \ | 160 | mediaplayerplugininterface.h \ |
158 | $(OPIEDIR)/include/qpe/qcom.h \ | 161 | $(OPIEDIR)/include/qpe/qcom.h \ |
159 | $(OPIEDIR)/include/qpe/quuid.h \ | 162 | $(OPIEDIR)/include/qpe/quuid.h \ |
160 | mediaplayerstate.h | 163 | mediaplayerstate.h |
161 | 164 | ||
162 | playlistselection.o: playlistselection.cpp \ | 165 | playlistselection.o: playlistselection.cpp \ |
163 | $(OPIEDIR)/include/qpe/applnk.h \ | 166 | $(OPIEDIR)/include/qpe/applnk.h \ |
164 | $(OPIEDIR)/include/qpe/resource.h \ | 167 | $(OPIEDIR)/include/qpe/resource.h \ |
165 | playlistselection.h | 168 | playlistselection.h |
166 | 169 | ||
167 | mediaplayerstate.o: mediaplayerstate.cpp \ | 170 | mediaplayerstate.o: mediaplayerstate.cpp \ |
168 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 171 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
172 | $(OPIEDIR)/include/qpedecoration_qws.h \ | ||
173 | $(OPIEDIR)/include/timestring.h \ | ||
169 | $(OPIEDIR)/include/qpe/qlibrary.h \ | 174 | $(OPIEDIR)/include/qpe/qlibrary.h \ |
170 | $(OPIEDIR)/include/qpe/qcom.h \ | 175 | $(OPIEDIR)/include/qpe/qcom.h \ |
171 | $(OPIEDIR)/include/qpe/quuid.h \ | 176 | $(OPIEDIR)/include/qpe/quuid.h \ |
172 | $(OPIEDIR)/include/qpe/mediaplayerplugininterface.h \ | ||
173 | $(OPIEDIR)/include/qpe/config.h \ | 177 | $(OPIEDIR)/include/qpe/config.h \ |
178 | mediaplayerplugininterface.h \ | ||
174 | mediaplayerstate.h \ | 179 | mediaplayerstate.h \ |
175 | libmad/libmadpluginimpl.h \ | 180 | libmad/libmadpluginimpl.h \ |
176 | libmpeg3/libmpeg3pluginimpl.h \ | 181 | libmpeg3/libmpeg3pluginimpl.h \ |
177 | wavplugin/wavpluginimpl.h | 182 | wavplugin/wavpluginimpl.h |
178 | 183 | ||
179 | videowidget.o: videowidget.cpp \ | 184 | videowidget.o: videowidget.cpp \ |
180 | $(OPIEDIR)/include/qpe/resource.h \ | 185 | $(OPIEDIR)/include/qpe/resource.h \ |
181 | $(OPIEDIR)/include/qpe/mediaplayerplugininterface.h \ | 186 | mediaplayerplugininterface.h \ |
182 | $(OPIEDIR)/include/qpe/qcom.h \ | 187 | $(OPIEDIR)/include/qpe/qcom.h \ |
183 | $(OPIEDIR)/include/qpe/quuid.h \ | 188 | $(OPIEDIR)/include/qpe/quuid.h \ |
184 | videowidget.h \ | 189 | videowidget.h \ |
185 | mediaplayerstate.h | 190 | mediaplayerstate.h |
186 | 191 | ||
187 | audiowidget.o: audiowidget.cpp \ | 192 | audiowidget.o: audiowidget.cpp \ |
188 | $(OPIEDIR)/include/qpe/resource.h \ | 193 | $(OPIEDIR)/include/qpe/resource.h \ |
189 | audiowidget.h \ | 194 | audiowidget.h \ |
190 | mediaplayerstate.h | 195 | mediaplayerstate.h |
191 | 196 | ||
192 | playlistwidget.o: playlistwidget.cpp \ | 197 | playlistwidget.o: playlistwidget.cpp \ |
193 | $(OPIEDIR)/include/qpe/qpemenubar.h \ | 198 | $(OPIEDIR)/include/qpe/qpemenubar.h \ |
194 | $(OPIEDIR)/include/qpe/qpetoolbar.h \ | 199 | $(OPIEDIR)/include/qpe/qpetoolbar.h \ |
195 | $(OPIEDIR)/include/qpe/fileselector.h \ | 200 | $(OPIEDIR)/include/qpe/fileselector.h \ |
201 | $(OPIEDIR)/include/filemanager.h \ | ||
202 | $(OPIEDIR)/include/applnk.h \ | ||
203 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | ||
204 | $(OPIEDIR)/include/qpedecoration_qws.h \ | ||
205 | $(OPIEDIR)/include/timestring.h \ | ||
196 | $(OPIEDIR)/include/qpe/applnk.h \ | 206 | $(OPIEDIR)/include/qpe/applnk.h \ |
197 | $(OPIEDIR)/include/qpe/config.h \ | 207 | $(OPIEDIR)/include/qpe/config.h \ |
198 | $(OPIEDIR)/include/qpe/global.h \ | 208 | $(OPIEDIR)/include/qpe/global.h \ |
199 | $(OPIEDIR)/include/qpe/resource.h \ | 209 | $(OPIEDIR)/include/qpe/resource.h \ |
200 | playlistselection.h \ | 210 | playlistselection.h \ |
201 | playlistwidget.h \ | 211 | playlistwidget.h \ |
202 | mediaplayerstate.h | 212 | mediaplayerstate.h |
203 | 213 | ||
204 | mediaplayer.o: mediaplayer.cpp \ | 214 | mediaplayer.o: mediaplayer.cpp \ |
205 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 215 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
216 | $(OPIEDIR)/include/qpedecoration_qws.h \ | ||
217 | $(OPIEDIR)/include/timestring.h \ | ||
206 | $(OPIEDIR)/include/qpe/qlibrary.h \ | 218 | $(OPIEDIR)/include/qpe/qlibrary.h \ |
207 | $(OPIEDIR)/include/qpe/qcom.h \ | 219 | $(OPIEDIR)/include/qpe/qcom.h \ |
208 | $(OPIEDIR)/include/qpe/quuid.h \ | 220 | $(OPIEDIR)/include/qpe/quuid.h \ |
209 | $(OPIEDIR)/include/qpe/resource.h \ | 221 | $(OPIEDIR)/include/qpe/resource.h \ |
210 | $(OPIEDIR)/include/qpe/config.h \ | 222 | $(OPIEDIR)/include/qpe/config.h \ |
211 | mediaplayer.h \ | 223 | mediaplayer.h \ |
212 | $(OPIEDIR)/include/qpe/mediaplayerplugininterface.h \ | 224 | mediaplayerplugininterface.h \ |
213 | playlistwidget.h \ | 225 | playlistwidget.h \ |
214 | $(OPIEDIR)/include/qpe/applnk.h \ | 226 | $(OPIEDIR)/include/qpe/applnk.h \ |
215 | audiowidget.h \ | 227 | audiowidget.h \ |
216 | loopcontrol.h \ | 228 | loopcontrol.h \ |
217 | audiodevice.h \ | 229 | audiodevice.h \ |
218 | mediaplayerstate.h | 230 | mediaplayerstate.h |
219 | 231 | ||
220 | audiodevice.o: audiodevice.cpp \ | 232 | audiodevice.o: audiodevice.cpp \ |
221 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 233 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
234 | $(OPIEDIR)/include/qpedecoration_qws.h \ | ||
235 | $(OPIEDIR)/include/timestring.h \ | ||
222 | $(OPIEDIR)/include/qpe/config.h \ | 236 | $(OPIEDIR)/include/qpe/config.h \ |
223 | audiodevice.h \ | 237 | audiodevice.h |
224 | $(OPIEDIR)/include/qpe/qcopenvelope_qws.h | ||
225 | 238 | ||
226 | moc_loopcontrol.o: moc_loopcontrol.cpp \ | 239 | moc_loopcontrol.o: moc_loopcontrol.cpp \ |
227 | loopcontrol.h | 240 | loopcontrol.h |
228 | 241 | ||
229 | moc_playlistselection.o: moc_playlistselection.cpp \ | 242 | moc_playlistselection.o: moc_playlistselection.cpp \ |
230 | playlistselection.h \ | 243 | playlistselection.h \ |
231 | $(OPIEDIR)/include/qpe/applnk.h | 244 | $(OPIEDIR)/include/qpe/applnk.h |
232 | 245 | ||
233 | moc_mediaplayerstate.o: moc_mediaplayerstate.cpp \ | 246 | moc_mediaplayerstate.o: moc_mediaplayerstate.cpp \ |
234 | mediaplayerstate.h | 247 | mediaplayerstate.h |
235 | 248 | ||
236 | moc_videowidget.o: moc_videowidget.cpp \ | 249 | moc_videowidget.o: moc_videowidget.cpp \ |
237 | videowidget.h | 250 | videowidget.h |
238 | 251 | ||
239 | moc_audiowidget.o: moc_audiowidget.cpp \ | 252 | moc_audiowidget.o: moc_audiowidget.cpp \ |
240 | audiowidget.h | 253 | audiowidget.h |
241 | 254 | ||
242 | moc_playlistwidget.o: moc_playlistwidget.cpp \ | 255 | moc_playlistwidget.o: moc_playlistwidget.cpp \ |
243 | playlistwidget.h \ | 256 | playlistwidget.h \ |
244 | $(OPIEDIR)/include/qpe/applnk.h | 257 | $(OPIEDIR)/include/qpe/applnk.h |
245 | 258 | ||
246 | moc_mediaplayer.o: moc_mediaplayer.cpp \ | 259 | moc_mediaplayer.o: moc_mediaplayer.cpp \ |
247 | mediaplayer.h \ | 260 | mediaplayer.h \ |
248 | $(OPIEDIR)/include/qpe/qlibrary.h \ | 261 | $(OPIEDIR)/include/qpe/qlibrary.h \ |
249 | $(OPIEDIR)/include/qpe/qcom.h \ | 262 | $(OPIEDIR)/include/qpe/qcom.h \ |
250 | $(OPIEDIR)/include/qpe/quuid.h \ | 263 | $(OPIEDIR)/include/qpe/quuid.h \ |
251 | $(OPIEDIR)/include/qpe/mediaplayerplugininterface.h | 264 | mediaplayerplugininterface.h |
252 | 265 | ||
253 | moc_audiodevice.o: moc_audiodevice.cpp \ | 266 | moc_audiodevice.o: moc_audiodevice.cpp \ |
254 | audiodevice.h | 267 | audiodevice.h |
255 | 268 | ||
256 | moc_loopcontrol.cpp: loopcontrol.h | 269 | moc_loopcontrol.cpp: loopcontrol.h |
257 | $(MOC) loopcontrol.h -o moc_loopcontrol.cpp | 270 | $(MOC) loopcontrol.h -o moc_loopcontrol.cpp |
258 | 271 | ||
259 | moc_playlistselection.cpp: playlistselection.h | 272 | moc_playlistselection.cpp: playlistselection.h |
260 | $(MOC) playlistselection.h -o moc_playlistselection.cpp | 273 | $(MOC) playlistselection.h -o moc_playlistselection.cpp |
261 | 274 | ||
262 | moc_mediaplayerstate.cpp: mediaplayerstate.h | 275 | moc_mediaplayerstate.cpp: mediaplayerstate.h |
263 | $(MOC) mediaplayerstate.h -o moc_mediaplayerstate.cpp | 276 | $(MOC) mediaplayerstate.h -o moc_mediaplayerstate.cpp |
264 | 277 | ||
265 | moc_videowidget.cpp: videowidget.h | 278 | moc_videowidget.cpp: videowidget.h |
266 | $(MOC) videowidget.h -o moc_videowidget.cpp | 279 | $(MOC) videowidget.h -o moc_videowidget.cpp |
267 | 280 | ||
268 | moc_audiowidget.cpp: audiowidget.h | 281 | moc_audiowidget.cpp: audiowidget.h |
269 | $(MOC) audiowidget.h -o moc_audiowidget.cpp | 282 | $(MOC) audiowidget.h -o moc_audiowidget.cpp |
270 | 283 | ||
271 | moc_playlistwidget.cpp: playlistwidget.h | 284 | moc_playlistwidget.cpp: playlistwidget.h |
272 | $(MOC) playlistwidget.h -o moc_playlistwidget.cpp | 285 | $(MOC) playlistwidget.h -o moc_playlistwidget.cpp |
273 | 286 | ||
274 | moc_mediaplayer.cpp: mediaplayer.h | 287 | moc_mediaplayer.cpp: mediaplayer.h |
275 | $(MOC) mediaplayer.h -o moc_mediaplayer.cpp | 288 | $(MOC) mediaplayer.h -o moc_mediaplayer.cpp |
276 | 289 | ||
277 | moc_audiodevice.cpp: audiodevice.h | 290 | moc_audiodevice.cpp: audiodevice.h |
278 | $(MOC) audiodevice.h -o moc_audiodevice.cpp | 291 | $(MOC) audiodevice.h -o moc_audiodevice.cpp |
279 | 292 | ||
280 | 293 | ||
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index 8861015..59136af 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp | |||
@@ -1,386 +1,371 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added better error code Fri 02-15-2002 14:37:47 | ||
21 | |||
22 | |||
20 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <stdio.h> | ||
21 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
23 | #include "audiodevice.h" | 27 | #include "audiodevice.h" |
24 | 28 | ||
25 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 29 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
26 | #include "qpe/qcopenvelope_qws.h" | 30 | #include "qpe/qcopenvelope_qws.h" |
27 | #endif | 31 | #endif |
28 | 32 | ||
29 | #ifdef Q_WS_WIN | 33 | #ifdef Q_WS_WIN |
30 | #include <windows.h> | 34 | #include <windows.h> |
31 | #include <mmsystem.h> | 35 | #include <mmsystem.h> |
32 | #include <mmreg.h> | 36 | #include <mmreg.h> |
33 | #endif | 37 | #endif |
34 | 38 | ||
35 | #if defined(Q_WS_X11) || defined(Q_WS_QWS) | 39 | #if defined(Q_WS_X11) || defined(Q_WS_QWS) |
36 | #include <fcntl.h> | 40 | #include <fcntl.h> |
37 | #include <sys/ioctl.h> | 41 | #include <sys/ioctl.h> |
38 | #include <sys/soundcard.h> | 42 | #include <sys/soundcard.h> |
39 | #include <sys/stat.h> | 43 | #include <sys/stat.h> |
40 | #include <sys/time.h> | 44 | #include <sys/time.h> |
41 | #include <sys/types.h> | 45 | #include <sys/types.h> |
42 | #include <unistd.h> | 46 | #include <unistd.h> |
43 | #endif | 47 | #endif |
44 | 48 | ||
45 | #if defined(Q_OS_WIN32) | 49 | #if defined(Q_OS_WIN32) |
46 | static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000; | 50 | static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000; |
47 | static const int timerResolutionMilliSeconds = 30; | 51 | static const int timerResolutionMilliSeconds = 30; |
48 | static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond; | 52 | static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond; |
49 | #else | 53 | #else |
50 | # if defined(QT_QWS_IPAQ) | 54 | # if defined(QT_QWS_IPAQ) |
51 | static const int sound_fragment_shift = 14; | 55 | static const int sound_fragment_shift = 14; |
52 | # else | 56 | # else |
53 | static const int sound_fragment_shift = 16; | 57 | static const int sound_fragment_shift = 16; |
54 | # endif | 58 | # endif |
55 | static const int sound_fragment_bytes = (1<<sound_fragment_shift); | 59 | static const int sound_fragment_bytes = (1<<sound_fragment_shift); |
56 | #endif | 60 | #endif |
57 | 61 | ||
58 | 62 | ||
59 | class AudioDevicePrivate { | 63 | class AudioDevicePrivate { |
60 | public: | 64 | public: |
61 | int handle; | 65 | int handle; |
62 | unsigned int frequency; | 66 | unsigned int frequency; |
63 | unsigned int channels; | 67 | unsigned int channels; |
64 | unsigned int bytesPerSample; | 68 | unsigned int bytesPerSample; |
65 | unsigned int bufferSize; | 69 | unsigned int bufferSize; |
66 | #ifndef Q_OS_WIN32 | 70 | #ifndef Q_OS_WIN32 |
67 | bool can_GETOSPACE; | 71 | bool can_GETOSPACE; |
68 | char* unwrittenBuffer; | 72 | char* unwrittenBuffer; |
69 | unsigned int unwritten; | 73 | unsigned int unwritten; |
70 | #endif | 74 | #endif |
71 | 75 | ||
72 | static int dspFd; | 76 | static int dspFd; |
73 | static bool muted; | 77 | static bool muted; |
74 | static unsigned int leftVolume; | 78 | static unsigned int leftVolume; |
75 | static unsigned int rightVolume; | 79 | static unsigned int rightVolume; |
76 | }; | 80 | }; |
77 | 81 | ||
78 | 82 | ||
79 | #ifdef Q_WS_QWS | 83 | #ifdef Q_WS_QWS |
80 | // This is for keeping the device open in-between playing files when | 84 | // This is for keeping the device open in-between playing files when |
81 | // the device makes clicks and it starts to drive you insane! :) | 85 | // the device makes clicks and it starts to drive you insane! :) |
82 | // Best to have the device not open when not using it though | 86 | // Best to have the device not open when not using it though |
83 | //#define KEEP_DEVICE_OPEN | 87 | //#define KEEP_DEVICE_OPEN |
84 | #endif | 88 | #endif |
85 | 89 | ||
86 | 90 | ||
87 | int AudioDevicePrivate::dspFd = 0; | 91 | int AudioDevicePrivate::dspFd = 0; |
88 | bool AudioDevicePrivate::muted = FALSE; | 92 | bool AudioDevicePrivate::muted = FALSE; |
89 | unsigned int AudioDevicePrivate::leftVolume = 0; | 93 | unsigned int AudioDevicePrivate::leftVolume = 0; |
90 | unsigned int AudioDevicePrivate::rightVolume = 0; | 94 | unsigned int AudioDevicePrivate::rightVolume = 0; |
91 | 95 | ||
92 | 96 | ||
93 | void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) { | 97 | void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) { |
94 | muted = AudioDevicePrivate::muted; | 98 | muted = AudioDevicePrivate::muted; |
95 | unsigned int volume; | 99 | unsigned int volume; |
96 | #ifdef Q_OS_WIN32 | 100 | #ifdef Q_OS_WIN32 |
97 | HWAVEOUT handle; | 101 | HWAVEOUT handle; |
98 | WAVEFORMATEX formatData; | 102 | WAVEFORMATEX formatData; |
99 | formatData.cbSize = sizeof(WAVEFORMATEX); | 103 | formatData.cbSize = sizeof(WAVEFORMATEX); |
100 | formatData.wFormatTag = WAVE_FORMAT_PCM; | 104 | formatData.wFormatTag = WAVE_FORMAT_PCM; |
101 | formatData.nAvgBytesPerSec = 4 * 44000; | 105 | formatData.nAvgBytesPerSec = 4 * 44000; |
102 | formatData.nBlockAlign = 4; | 106 | formatData.nBlockAlign = 4; |
103 | formatData.nChannels = 2; | 107 | formatData.nChannels = 2; |
104 | formatData.nSamplesPerSec = 44000; | 108 | formatData.nSamplesPerSec = 44000; |
105 | formatData.wBitsPerSample = 16; | 109 | formatData.wBitsPerSample = 16; |
106 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); | 110 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); |
107 | if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) | 111 | if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) |
108 | qDebug( "get volume of audio device failed" ); | 112 | qDebug( "get volume of audio device failed" ); |
109 | waveOutClose( handle ); | 113 | waveOutClose( handle ); |
110 | leftVolume = volume & 0xFFFF; | 114 | leftVolume = volume & 0xFFFF; |
111 | rightVolume = volume >> 16; | 115 | rightVolume = volume >> 16; |
112 | #else | 116 | #else |
113 | int mixerHandle = open( "/dev/mixer", O_RDWR ); | 117 | int mixerHandle = open( "/dev/mixer", O_RDWR ); |
114 | if ( mixerHandle >= 0 ) { | 118 | if ( mixerHandle >= 0 ) { |
115 | ioctl( mixerHandle, MIXER_READ(0), &volume ); | 119 | if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1) |
120 | perror("ioctl(\"MIXER_READ\")"); | ||
116 | close( mixerHandle ); | 121 | close( mixerHandle ); |
117 | } else | 122 | } else |
118 | qDebug( "get volume of audio device failed" ); | 123 | perror("open(\"/dev/mixer\")"); |
119 | leftVolume = ((volume & 0x00FF) << 16) / 101; | 124 | leftVolume = ((volume & 0x00FF) << 16) / 101; |
120 | rightVolume = ((volume & 0xFF00) << 8) / 101; | 125 | rightVolume = ((volume & 0xFF00) << 8) / 101; |
121 | #endif | 126 | #endif |
122 | } | 127 | } |
123 | 128 | ||
124 | 129 | ||
125 | void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { | 130 | void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { |
126 | AudioDevicePrivate::muted = muted; | 131 | AudioDevicePrivate::muted = muted; |
127 | if ( muted ) { | 132 | if ( muted ) { |
128 | AudioDevicePrivate::leftVolume = leftVolume; | 133 | AudioDevicePrivate::leftVolume = leftVolume; |
129 | AudioDevicePrivate::rightVolume = rightVolume; | 134 | AudioDevicePrivate::rightVolume = rightVolume; |
130 | leftVolume = 0; | 135 | leftVolume = 0; |
131 | rightVolume = 0; | 136 | rightVolume = 0; |
132 | } else { | 137 | } else { |
133 | leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); | 138 | leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); |
134 | rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); | 139 | rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); |
135 | } | 140 | } |
136 | #ifdef Q_OS_WIN32 | 141 | #ifdef Q_OS_WIN32 |
137 | HWAVEOUT handle; | 142 | HWAVEOUT handle; |
138 | WAVEFORMATEX formatData; | 143 | WAVEFORMATEX formatData; |
139 | formatData.cbSize = sizeof(WAVEFORMATEX); | 144 | formatData.cbSize = sizeof(WAVEFORMATEX); |
140 | formatData.wFormatTag = WAVE_FORMAT_PCM; | 145 | formatData.wFormatTag = WAVE_FORMAT_PCM; |
141 | formatData.nAvgBytesPerSec = 4 * 44000; | 146 | formatData.nAvgBytesPerSec = 4 * 44000; |
142 | formatData.nBlockAlign = 4; | 147 | formatData.nBlockAlign = 4; |
143 | formatData.nChannels = 2; | 148 | formatData.nChannels = 2; |
144 | formatData.nSamplesPerSec = 44000; | 149 | formatData.nSamplesPerSec = 44000; |
145 | formatData.wBitsPerSample = 16; | 150 | formatData.wBitsPerSample = 16; |
146 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); | 151 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); |
147 | unsigned int volume = (rightVolume << 16) | leftVolume; | 152 | unsigned int volume = (rightVolume << 16) | leftVolume; |
148 | if ( waveOutSetVolume( handle, volume ) ) | 153 | if ( waveOutSetVolume( handle, volume ) ) |
149 | qDebug( "set volume of audio device failed" ); | 154 | qDebug( "set volume of audio device failed" ); |
150 | waveOutClose( handle ); | 155 | waveOutClose( handle ); |
151 | #else | 156 | #else |
152 | // Volume can be from 0 to 100 which is 101 distinct values | 157 | // Volume can be from 0 to 100 which is 101 distinct values |
153 | unsigned int rV = (rightVolume * 101) >> 16; | 158 | unsigned int rV = (rightVolume * 101) >> 16; |
154 | 159 | ||
155 | # if 0 | 160 | # if 0 |
156 | unsigned int lV = (leftVolume * 101) >> 16; | 161 | unsigned int lV = (leftVolume * 101) >> 16; |
157 | unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); | 162 | unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); |
158 | int mixerHandle = 0; | 163 | int mixerHandle = 0; |
159 | if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 164 | if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
160 | ioctl( mixerHandle, MIXER_WRITE(0), &volume ); | 165 | if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) |
166 | perror("ioctl(\"MIXER_WRITE\")"); | ||
161 | close( mixerHandle ); | 167 | close( mixerHandle ); |
162 | } else | 168 | } else |
163 | qDebug( "set volume of audio device failed" ); | 169 | perror("open(\"/dev/mixer\")"); |
170 | |||
164 | # else | 171 | # else |
165 | // This is the way this has to be done now I guess, doesn't allow for | 172 | // This is the way this has to be done now I guess, doesn't allow for |
166 | // independant right and left channel setting, or setting for different outputs | 173 | // independant right and left channel setting, or setting for different outputs |
167 | Config cfg("Sound"); | 174 | Config cfg("Sound"); |
168 | cfg.setGroup("System"); | 175 | cfg.setGroup("System"); |
169 | cfg.writeEntry("Volume",(int)rV); | 176 | cfg.writeEntry("Volume",(int)rV); |
170 | # endif | 177 | # endif |
171 | 178 | ||
172 | #endif | 179 | #endif |
173 | // qDebug( "setting volume to: 0x%x", volume ); | 180 | // qDebug( "setting volume to: 0x%x", volume ); |
174 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 181 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
175 | // Send notification that the volume has changed | 182 | // Send notification that the volume has changed |
176 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; | 183 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; |
177 | #endif | 184 | #endif |
178 | } | 185 | } |
179 | 186 | ||
180 | 187 | ||
181 | 188 | ||
182 | 189 | ||
183 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { | 190 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { |
184 | d = new AudioDevicePrivate; | 191 | d = new AudioDevicePrivate; |
185 | d->frequency = f; | 192 | d->frequency = f; |
186 | d->channels = chs; | 193 | d->channels = chs; |
187 | d->bytesPerSample = bps; | 194 | d->bytesPerSample = bps; |
195 | qDebug("%d",bps); | ||
196 | int format=0; | ||
197 | if( bps == 8) format = AFMT_U8; | ||
198 | else if( bps <= 0) format = AFMT_S16_LE; | ||
199 | else format = AFMT_S16_LE; | ||
188 | 200 | ||
201 | qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); | ||
189 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); | 202 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); |
190 | 203 | ||
191 | #ifdef Q_OS_WIN32 | ||
192 | UINT result; | ||
193 | WAVEFORMATEX formatData; | ||
194 | formatData.cbSize = sizeof(WAVEFORMATEX); | ||
195 | /* | ||
196 | // Other possible formats windows supports | ||
197 | formatData.wFormatTag = WAVE_FORMAT_MPEG; | ||
198 | formatData.wFormatTag = WAVE_FORMAT_MPEGLAYER3; | ||
199 | formatData.wFormatTag = WAVE_FORMAT_ADPCM; | ||
200 | */ | ||
201 | formatData.wFormatTag = WAVE_FORMAT_PCM; | ||
202 | formatData.nAvgBytesPerSec = bps * chs * f; | ||
203 | formatData.nBlockAlign = bps * chs; | ||
204 | formatData.nChannels = chs; | ||
205 | formatData.nSamplesPerSec = f; | ||
206 | formatData.wBitsPerSample = bps * 8; | ||
207 | // Open a waveform device for output | ||
208 | if (result = waveOutOpen((LPHWAVEOUT)&d->handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL)) { | ||
209 | QString errorMsg = "error opening audio device.\nReason: %i - "; | ||
210 | switch (result) { | ||
211 | case MMSYSERR_ALLOCATED:errorMsg += "Specified resource is already allocated."; break; | ||
212 | case MMSYSERR_BADDEVICEID:errorMsg += "Specified device identifier is out of range."; break; | ||
213 | case MMSYSERR_NODRIVER:errorMsg += "No device driver is present."; break; | ||
214 | case MMSYSERR_NOMEM:errorMsg += "Unable to allocate or lock memory."; break; | ||
215 | case WAVERR_BADFORMAT:errorMsg += "Attempted to open with an unsupported waveform-audio format."; break; | ||
216 | case WAVERR_SYNC: errorMsg += "The device is synchronous but waveOutOpen was called without using the WAVE_ALLOWSYNC flag."; break; | ||
217 | default: errorMsg += "Undefined error"; break; | ||
218 | } | ||
219 | qDebug( errorMsg, result ); | ||
220 | } | ||
221 | |||
222 | d->bufferSize = sound_fragment_bytes; | ||
223 | #else | ||
224 | 204 | ||
225 | int fragments = 0x10000 * 8 + sound_fragment_shift; | 205 | int fragments = 0x10000 * 8 + sound_fragment_shift; |
226 | int format = AFMT_S16_LE; | ||
227 | int capabilities = 0; | 206 | int capabilities = 0; |
228 | 207 | ||
229 | #ifdef KEEP_DEVICE_OPEN | 208 | #ifdef KEEP_DEVICE_OPEN |
230 | if ( AudioDevicePrivate::dspFd == 0 ) { | 209 | if ( AudioDevicePrivate::dspFd == 0 ) { |
231 | #endif | 210 | #endif |
232 | if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { | 211 | if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { |
233 | qDebug( "error opening audio device /dev/dsp, sending data to /dev/null instead" ); | 212 | perror("open(\"/dev/dsp\") sending to /dev/null instead"); |
234 | d->handle = ::open( "/dev/null", O_WRONLY ); | 213 | d->handle = ::open( "/dev/null", O_WRONLY ); |
235 | } | 214 | } |
236 | #ifdef KEEP_DEVICE_OPEN | 215 | #ifdef KEEP_DEVICE_OPEN |
237 | AudioDevicePrivate::dspFd = d->handle; | 216 | AudioDevicePrivate::dspFd = d->handle; |
238 | } else { | 217 | } else { |
239 | d->handle = AudioDevicePrivate::dspFd; | 218 | d->handle = AudioDevicePrivate::dspFd; |
240 | } | 219 | } |
241 | #endif | 220 | #endif |
242 | 221 | ||
243 | ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities ); | 222 | if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) |
244 | ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments ); | 223 | perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); |
245 | ioctl( d->handle, SNDCTL_DSP_SETFMT, &format ); | 224 | if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) |
246 | ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency ); | 225 | perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); |
226 | if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) | ||
227 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | ||
228 | qDebug("freq %d", d->frequency); | ||
229 | if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) | ||
230 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | ||
231 | qDebug("channels %d",d->channels); | ||
247 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { | 232 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { |
248 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; | 233 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; |
249 | ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ); | 234 | if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) |
235 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | ||
250 | } | 236 | } |
251 | 237 | ||
252 | d->bufferSize = sound_fragment_bytes; | 238 | d->bufferSize = sound_fragment_bytes; |
253 | d->unwrittenBuffer = new char[d->bufferSize]; | 239 | d->unwrittenBuffer = new char[d->bufferSize]; |
254 | d->unwritten = 0; | 240 | d->unwritten = 0; |
255 | d->can_GETOSPACE = TRUE; // until we find otherwise | 241 | d->can_GETOSPACE = TRUE; // until we find otherwise |
256 | 242 | ||
257 | //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); | 243 | //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); |
258 | //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); | 244 | //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); |
259 | //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); | 245 | //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); |
260 | //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); | 246 | //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); |
261 | //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); | 247 | //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); |
262 | //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); | 248 | //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); |
263 | #endif | ||
264 | } | 249 | } |
265 | 250 | ||
266 | 251 | ||
267 | AudioDevice::~AudioDevice() { | 252 | AudioDevice::~AudioDevice() { |
268 | #ifdef Q_OS_WIN32 | 253 | #ifdef Q_OS_WIN32 |
269 | waveOutClose( (HWAVEOUT)d->handle ); | 254 | waveOutClose( (HWAVEOUT)d->handle ); |
270 | #else | 255 | #else |
271 | # ifndef KEEP_DEVICE_OPEN | 256 | # ifndef KEEP_DEVICE_OPEN |
272 | close( d->handle ); // Now it should be safe to shut the handle | 257 | close( d->handle ); // Now it should be safe to shut the handle |
273 | # endif | 258 | # endif |
274 | delete d->unwrittenBuffer; | 259 | delete d->unwrittenBuffer; |
275 | delete d; | 260 | delete d; |
276 | #endif | 261 | #endif |
277 | } | 262 | } |
278 | 263 | ||
279 | 264 | ||
280 | void AudioDevice::volumeChanged( bool muted ) | 265 | void AudioDevice::volumeChanged( bool muted ) |
281 | { | 266 | { |
282 | AudioDevicePrivate::muted = muted; | 267 | AudioDevicePrivate::muted = muted; |
283 | } | 268 | } |
284 | 269 | ||
285 | 270 | ||
286 | void AudioDevice::write( char *buffer, unsigned int length ) | 271 | void AudioDevice::write( char *buffer, unsigned int length ) |
287 | { | 272 | { |
288 | #ifdef Q_OS_WIN32 | 273 | #ifdef Q_OS_WIN32 |
289 | // returns immediately and (to be implemented) emits completedIO() when finished writing | 274 | // returns immediately and (to be implemented) emits completedIO() when finished writing |
290 | WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) ); | 275 | WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) ); |
291 | // maybe the buffer should be copied so that this fool proof, but its a performance hit | 276 | // maybe the buffer should be copied so that this fool proof, but its a performance hit |
292 | lpWaveHdr->lpData = buffer; | 277 | lpWaveHdr->lpData = buffer; |
293 | lpWaveHdr->dwBufferLength = length; | 278 | lpWaveHdr->dwBufferLength = length; |
294 | lpWaveHdr->dwFlags = 0L; | 279 | lpWaveHdr->dwFlags = 0L; |
295 | lpWaveHdr->dwLoops = 0L; | 280 | lpWaveHdr->dwLoops = 0L; |
296 | waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ); | 281 | waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ); |
297 | // waveOutWrite returns immediately. the data is sent in the background. | 282 | // waveOutWrite returns immediately. the data is sent in the background. |
298 | if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) ) | 283 | if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) ) |
299 | qDebug( "failed to write block to audio device" ); | 284 | qDebug( "failed to write block to audio device" ); |
300 | // emit completedIO(); | 285 | // emit completedIO(); |
301 | #else | 286 | #else |
302 | int t = ::write( d->handle, buffer, length ); | 287 | int t = ::write( d->handle, buffer, length ); |
303 | if ( t<0 ) t = 0; | 288 | if ( t<0 ) t = 0; |
304 | if ( t != (int)length) { | 289 | if ( t != (int)length) { |
305 | qDebug("Ahhh!! memcpys 1"); | 290 | qDebug("Ahhh!! memcpys 1"); |
306 | memcpy(d->unwrittenBuffer,buffer+t,length-t); | 291 | memcpy(d->unwrittenBuffer,buffer+t,length-t); |
307 | d->unwritten = length-t; | 292 | d->unwritten = length-t; |
308 | } | 293 | } |
309 | #endif | 294 | #endif |
310 | } | 295 | } |
311 | 296 | ||
312 | 297 | ||
313 | unsigned int AudioDevice::channels() const | 298 | unsigned int AudioDevice::channels() const |
314 | { | 299 | { |
315 | return d->channels; | 300 | return d->channels; |
316 | } | 301 | } |
317 | 302 | ||
318 | 303 | ||
319 | unsigned int AudioDevice::frequency() const | 304 | unsigned int AudioDevice::frequency() const |
320 | { | 305 | { |
321 | return d->frequency; | 306 | return d->frequency; |
322 | } | 307 | } |
323 | 308 | ||
324 | 309 | ||
325 | unsigned int AudioDevice::bytesPerSample() const | 310 | unsigned int AudioDevice::bytesPerSample() const |
326 | { | 311 | { |
327 | return d->bytesPerSample; | 312 | return d->bytesPerSample; |
328 | } | 313 | } |
329 | 314 | ||
330 | 315 | ||
331 | unsigned int AudioDevice::bufferSize() const | 316 | unsigned int AudioDevice::bufferSize() const |
332 | { | 317 | { |
333 | return d->bufferSize; | 318 | return d->bufferSize; |
334 | } | 319 | } |
335 | 320 | ||
336 | unsigned int AudioDevice::canWrite() const | 321 | unsigned int AudioDevice::canWrite() const |
337 | { | 322 | { |
338 | #ifdef Q_OS_WIN32 | 323 | #ifdef Q_OS_WIN32 |
339 | return bufferSize(); // Any better? | 324 | return bufferSize(); // Any better? |
340 | #else | 325 | #else |
341 | audio_buf_info info; | 326 | audio_buf_info info; |
342 | if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) { | 327 | if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) { |
343 | d->can_GETOSPACE = FALSE; | 328 | d->can_GETOSPACE = FALSE; |
344 | fcntl( d->handle, F_SETFL, O_NONBLOCK ); | 329 | fcntl( d->handle, F_SETFL, O_NONBLOCK ); |
345 | } | 330 | } |
346 | if ( d->can_GETOSPACE ) { | 331 | if ( d->can_GETOSPACE ) { |
347 | int t = info.fragments * sound_fragment_bytes; | 332 | int t = info.fragments * sound_fragment_bytes; |
348 | return QMIN(t,(int)bufferSize()); | 333 | return QMIN(t,(int)bufferSize()); |
349 | } else { | 334 | } else { |
350 | if ( d->unwritten ) { | 335 | if ( d->unwritten ) { |
351 | int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten ); | 336 | int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten ); |
352 | if ( t<0 ) t = 0; | 337 | if ( t<0 ) t = 0; |
353 | if ( (unsigned)t!=d->unwritten ) { | 338 | if ( (unsigned)t!=d->unwritten ) { |
354 | memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t); | 339 | memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t); |
355 | d->unwritten -= t; | 340 | d->unwritten -= t; |
356 | } else { | 341 | } else { |
357 | d->unwritten = 0; | 342 | d->unwritten = 0; |
358 | } | 343 | } |
359 | } | 344 | } |
360 | if ( d->unwritten ) | 345 | if ( d->unwritten ) |
361 | return 0; | 346 | return 0; |
362 | else | 347 | else |
363 | return d->bufferSize; | 348 | return d->bufferSize; |
364 | } | 349 | } |
365 | #endif | 350 | #endif |
366 | } | 351 | } |
367 | 352 | ||
368 | 353 | ||
369 | int AudioDevice::bytesWritten() { | 354 | int AudioDevice::bytesWritten() { |
370 | #ifdef Q_OS_WIN32 | 355 | #ifdef Q_OS_WIN32 |
371 | MMTIME pmmt = { TIME_BYTES, 0 }; | 356 | MMTIME pmmt = { TIME_BYTES, 0 }; |
372 | if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) { | 357 | if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) { |
373 | qDebug( "failed to get audio device position" ); | 358 | qDebug( "failed to get audio device position" ); |
374 | return -1; | 359 | return -1; |
375 | } | 360 | } |
376 | return pmmt.u.cb; | 361 | return pmmt.u.cb; |
377 | #else | 362 | #else |
378 | int buffered = 0; | 363 | int buffered = 0; |
379 | if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) { | 364 | if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) { |
380 | qDebug( "failed to get audio device position" ); | 365 | qDebug( "failed to get audio device position" ); |
381 | return -1; | 366 | return -1; |
382 | } | 367 | } |
383 | return buffered; | 368 | return buffered; |
384 | #endif | 369 | #endif |
385 | } | 370 | } |
386 | 371 | ||
diff --git a/core/multimedia/opieplayer/audiodevice.h b/core/multimedia/opieplayer/audiodevice.h index 928f134..dcd79fe 100644 --- a/core/multimedia/opieplayer/audiodevice.h +++ b/core/multimedia/opieplayer/audiodevice.h | |||
@@ -1,71 +1,75 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
22 | |||
20 | #ifndef AUDIODEVICE_H | 23 | #ifndef AUDIODEVICE_H |
21 | #define AUDIODEVICE_H | 24 | #define AUDIODEVICE_H |
22 | 25 | ||
23 | 26 | ||
24 | #include <qobject.h> | 27 | #include <qobject.h> |
28 | #include <sys/soundcard.h> | ||
25 | 29 | ||
26 | 30 | ||
27 | class AudioDevicePrivate; | 31 | class AudioDevicePrivate; |
28 | 32 | ||
29 | 33 | ||
30 | class AudioDevice : public QObject { | 34 | class AudioDevice : public QObject { |
31 | Q_OBJECT | 35 | Q_OBJECT |
32 | public: | 36 | public: |
33 | AudioDevice( unsigned int freq = 44000, unsigned int channels = 2, unsigned int bytesPerSample = 2 ); | 37 | AudioDevice( unsigned int freq = 44000, unsigned int channels = 2, unsigned int bytesPerSample = AFMT_S16_LE ); |
34 | ~AudioDevice(); | 38 | ~AudioDevice(); |
35 | 39 | ||
36 | unsigned int canWrite() const; | 40 | unsigned int canWrite() const; |
37 | void write( char *buffer, unsigned int length ); | 41 | void write( char *buffer, unsigned int length ); |
38 | int bytesWritten(); | 42 | int bytesWritten(); |
39 | 43 | ||
40 | unsigned int channels() const; | 44 | unsigned int channels() const; |
41 | unsigned int frequency() const; | 45 | unsigned int frequency() const; |
42 | unsigned int bytesPerSample() const; | 46 | unsigned int bytesPerSample() const; |
43 | unsigned int bufferSize() const; | 47 | unsigned int bufferSize() const; |
44 | 48 | ||
45 | // Each volume level is from 0 to 0xFFFF | 49 | // Each volume level is from 0 to 0xFFFF |
46 | static void getVolume( unsigned int& left, unsigned int& right, bool& muted ); | 50 | static void getVolume( unsigned int& left, unsigned int& right, bool& muted ); |
47 | static void setVolume( unsigned int left, unsigned int right, bool muted ); | 51 | static void setVolume( unsigned int left, unsigned int right, bool muted ); |
48 | 52 | ||
49 | static unsigned int leftVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return l; } | 53 | static unsigned int leftVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return l; } |
50 | static unsigned int rightVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return r; } | 54 | static unsigned int rightVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return r; } |
51 | static bool isMuted() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return muted; } | 55 | static bool isMuted() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return muted; } |
52 | 56 | ||
53 | static void increaseVolume() { setVolume( leftVolume() + 1968, rightVolume() + 1968, isMuted() ); } | 57 | static void increaseVolume() { setVolume( leftVolume() + 1968, rightVolume() + 1968, isMuted() ); } |
54 | static void decreaseVolume() { setVolume( leftVolume() - 1966, rightVolume() - 1966, isMuted() ); } | 58 | static void decreaseVolume() { setVolume( leftVolume() - 1966, rightVolume() - 1966, isMuted() ); } |
55 | 59 | ||
56 | public slots: | 60 | public slots: |
57 | // Convinence functions derived from above functions | 61 | // Convinence functions derived from above functions |
58 | void setVolume( unsigned int level ) { setVolume( level, level, isMuted() ); } | 62 | void setVolume( unsigned int level ) { setVolume( level, level, isMuted() ); } |
59 | void mute() { setVolume( leftVolume(), rightVolume(), TRUE ); } | 63 | void mute() { setVolume( leftVolume(), rightVolume(), TRUE ); } |
60 | void volumeChanged( bool muted ); | 64 | void volumeChanged( bool muted ); |
61 | 65 | ||
62 | signals: | 66 | signals: |
63 | void completedIO(); | 67 | void completedIO(); |
64 | 68 | ||
65 | private: | 69 | private: |
66 | AudioDevicePrivate *d; | 70 | AudioDevicePrivate *d; |
67 | }; | 71 | }; |
68 | 72 | ||
69 | 73 | ||
70 | #endif // AUDIODEVICE_H | 74 | #endif // AUDIODEVICE_H |
71 | 75 | ||
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index 243c58c..0d88591 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp | |||
@@ -16,262 +16,262 @@ | |||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qwidget.h> | 20 | #include <qwidget.h> |
21 | #include <qpixmap.h> | 21 | #include <qpixmap.h> |
22 | #include <qbutton.h> | 22 | #include <qbutton.h> |
23 | #include <qpainter.h> | 23 | #include <qpainter.h> |
24 | #include <qframe.h> | 24 | #include <qframe.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include "audiowidget.h" | 26 | #include "audiowidget.h" |
27 | #include "mediaplayerstate.h" | 27 | #include "mediaplayerstate.h" |
28 | 28 | ||
29 | 29 | ||
30 | extern MediaPlayerState *mediaPlayerState; | 30 | extern MediaPlayerState *mediaPlayerState; |
31 | 31 | ||
32 | 32 | ||
33 | static const int xo = -2; // movable x offset | 33 | static const int xo = -2; // movable x offset |
34 | static const int yo = 22; // movable y offset | 34 | static const int yo = 22; // movable y offset |
35 | 35 | ||
36 | 36 | ||
37 | struct MediaButton { | 37 | struct MediaButton { |
38 | int xPos, yPos; | 38 | int xPos, yPos; |
39 | int color; | 39 | int color; |
40 | bool isToggle, isBig, isHeld, isDown; | 40 | bool isToggle, isBig, isHeld, isDown; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | 43 | ||
44 | // Layout information for the audioButtons (and if it is a toggle button or not) | 44 | // Layout information for the audioButtons (and if it is a toggle button or not) |
45 | MediaButton audioButtons[] = { | 45 | MediaButton audioButtons[] = { |
46 | { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play | 46 | { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play |
47 | { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop | 47 | { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop |
48 | { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause | 48 | { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause |
49 | { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next | 49 | { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next |
50 | { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous | 50 | { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous |
51 | { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up | 51 | { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up |
52 | { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down | 52 | { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down |
53 | { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop | 53 | { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop |
54 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist | 54 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist |
55 | }; | 55 | }; |
56 | 56 | ||
57 | 57 | ||
58 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 58 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
59 | 59 | ||
60 | 60 | ||
61 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 61 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
62 | QWidget( parent, name, f ) | 62 | QWidget( parent, name, f ) |
63 | { | 63 | { |
64 | setCaption( tr("MediaPlayer") ); | 64 | setCaption( tr("OpiePlayer") ); |
65 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 65 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); |
66 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) ); | 66 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) ); |
67 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) ); | 67 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) ); |
68 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls" ) ); | 68 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls" ) ); |
69 | pixmaps[3] = new QPixmap( Resource::loadPixmap( "mpegplayer/animatedButton" ) ); | 69 | pixmaps[3] = new QPixmap( Resource::loadPixmap( "mpegplayer/animatedButton" ) ); |
70 | 70 | ||
71 | songInfo = new Ticker( this ); | 71 | songInfo = new Ticker( this ); |
72 | songInfo->setFocusPolicy( QWidget::NoFocus ); | 72 | songInfo->setFocusPolicy( QWidget::NoFocus ); |
73 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); | 73 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); |
74 | 74 | ||
75 | slider = new QSlider( Qt::Horizontal, this ); | 75 | slider = new QSlider( Qt::Horizontal, this ); |
76 | slider->setFixedWidth( 220 ); | 76 | slider->setFixedWidth( 220 ); |
77 | slider->setFixedHeight( 20 ); | 77 | slider->setFixedHeight( 20 ); |
78 | slider->setMinValue( 0 ); | 78 | slider->setMinValue( 0 ); |
79 | slider->setMaxValue( 1 ); | 79 | slider->setMaxValue( 1 ); |
80 | slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 80 | slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); |
81 | slider->setFocusPolicy( QWidget::NoFocus ); | 81 | slider->setFocusPolicy( QWidget::NoFocus ); |
82 | slider->setGeometry( QRect( 7, 262, 220, 20 ) ); | 82 | slider->setGeometry( QRect( 7, 262, 220, 20 ) ); |
83 | 83 | ||
84 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 84 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
85 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 85 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
86 | 86 | ||
87 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 87 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
88 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 88 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
89 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 89 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
90 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 90 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
91 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 91 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
92 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 92 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
93 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 93 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
94 | 94 | ||
95 | // Intialise state | 95 | // Intialise state |
96 | setLength( mediaPlayerState->length() ); | 96 | setLength( mediaPlayerState->length() ); |
97 | setPosition( mediaPlayerState->position() ); | 97 | setPosition( mediaPlayerState->position() ); |
98 | setLooping( mediaPlayerState->fullscreen() ); | 98 | setLooping( mediaPlayerState->fullscreen() ); |
99 | setPaused( mediaPlayerState->paused() ); | 99 | setPaused( mediaPlayerState->paused() ); |
100 | setPlaying( mediaPlayerState->playing() ); | 100 | setPlaying( mediaPlayerState->playing() ); |
101 | 101 | ||
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
105 | AudioWidget::~AudioWidget() { | 105 | AudioWidget::~AudioWidget() { |
106 | for ( int i = 0; i < 4; i++ ) | 106 | for ( int i = 0; i < 4; i++ ) |
107 | delete pixmaps[i]; | 107 | delete pixmaps[i]; |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | static bool audioSliderBeingMoved = FALSE; | 111 | static bool audioSliderBeingMoved = FALSE; |
112 | 112 | ||
113 | 113 | ||
114 | void AudioWidget::sliderPressed() { | 114 | void AudioWidget::sliderPressed() { |
115 | audioSliderBeingMoved = TRUE; | 115 | audioSliderBeingMoved = TRUE; |
116 | } | 116 | } |
117 | 117 | ||
118 | 118 | ||
119 | void AudioWidget::sliderReleased() { | 119 | void AudioWidget::sliderReleased() { |
120 | audioSliderBeingMoved = FALSE; | 120 | audioSliderBeingMoved = FALSE; |
121 | if ( slider->width() == 0 ) | 121 | if ( slider->width() == 0 ) |
122 | return; | 122 | return; |
123 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 123 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
124 | mediaPlayerState->setPosition( val ); | 124 | mediaPlayerState->setPosition( val ); |
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
128 | void AudioWidget::setPosition( long i ) { | 128 | void AudioWidget::setPosition( long i ) { |
129 | updateSlider( i, mediaPlayerState->length() ); | 129 | updateSlider( i, mediaPlayerState->length() ); |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | void AudioWidget::setLength( long max ) { | 133 | void AudioWidget::setLength( long max ) { |
134 | updateSlider( mediaPlayerState->position(), max ); | 134 | updateSlider( mediaPlayerState->position(), max ); |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | void AudioWidget::setView( char view ) { | 138 | void AudioWidget::setView( char view ) { |
139 | if ( view == 'a' ) { | 139 | if ( view == 'a' ) { |
140 | startTimer( 150 ); | 140 | startTimer( 150 ); |
141 | showMaximized(); | 141 | showMaximized(); |
142 | } else { | 142 | } else { |
143 | killTimers(); | 143 | killTimers(); |
144 | hide(); | 144 | hide(); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | 148 | ||
149 | void AudioWidget::updateSlider( long i, long max ) { | 149 | void AudioWidget::updateSlider( long i, long max ) { |
150 | if ( max == 0 ) | 150 | if ( max == 0 ) |
151 | return; | 151 | return; |
152 | // Will flicker too much if we don't do this | 152 | // Will flicker too much if we don't do this |
153 | // Scale to something reasonable | 153 | // Scale to something reasonable |
154 | int width = slider->width(); | 154 | int width = slider->width(); |
155 | int val = int((double)i * width / max); | 155 | int val = int((double)i * width / max); |
156 | if ( !audioSliderBeingMoved ) { | 156 | if ( !audioSliderBeingMoved ) { |
157 | if ( slider->value() != val ) | 157 | if ( slider->value() != val ) |
158 | slider->setValue( val ); | 158 | slider->setValue( val ); |
159 | if ( slider->maxValue() != width ) | 159 | if ( slider->maxValue() != width ) |
160 | slider->setMaxValue( width ); | 160 | slider->setMaxValue( width ); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | void AudioWidget::setToggleButton( int i, bool down ) { | 165 | void AudioWidget::setToggleButton( int i, bool down ) { |
166 | if ( down != audioButtons[i].isDown ) | 166 | if ( down != audioButtons[i].isDown ) |
167 | toggleButton( i ); | 167 | toggleButton( i ); |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | void AudioWidget::toggleButton( int i ) { | 171 | void AudioWidget::toggleButton( int i ) { |
172 | audioButtons[i].isDown = !audioButtons[i].isDown; | 172 | audioButtons[i].isDown = !audioButtons[i].isDown; |
173 | QPainter p(this); | 173 | QPainter p(this); |
174 | paintButton ( &p, i ); | 174 | paintButton ( &p, i ); |
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
178 | void AudioWidget::paintButton( QPainter *p, int i ) { | 178 | void AudioWidget::paintButton( QPainter *p, int i ) { |
179 | int x = audioButtons[i].xPos; | 179 | int x = audioButtons[i].xPos; |
180 | int y = audioButtons[i].yPos; | 180 | int y = audioButtons[i].yPos; |
181 | int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; | 181 | int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; |
182 | int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); | 182 | int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); |
183 | p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); | 183 | p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); |
184 | p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 ); | 184 | p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 ); |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | void AudioWidget::timerEvent( QTimerEvent * ) { | 188 | void AudioWidget::timerEvent( QTimerEvent * ) { |
189 | static int frame = 0; | 189 | static int frame = 0; |
190 | if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { | 190 | if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { |
191 | frame = frame >= 7 ? 0 : frame + 1; | 191 | frame = frame >= 7 ? 0 : frame + 1; |
192 | int x = audioButtons[AudioPlay].xPos; | 192 | int x = audioButtons[AudioPlay].xPos; |
193 | int y = audioButtons[AudioPlay].yPos; | 193 | int y = audioButtons[AudioPlay].yPos; |
194 | QPainter p( this ); | 194 | QPainter p( this ); |
195 | // Optimize to only draw the little bit of the changing images which is different | 195 | // Optimize to only draw the little bit of the changing images which is different |
196 | p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); | 196 | p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); |
197 | p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); | 197 | p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | 201 | ||
202 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 202 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
203 | for ( int i = 0; i < numButtons; i++ ) { | 203 | for ( int i = 0; i < numButtons; i++ ) { |
204 | int size = audioButtons[i].isBig; | 204 | int size = audioButtons[i].isBig; |
205 | int x = audioButtons[i].xPos; | 205 | int x = audioButtons[i].xPos; |
206 | int y = audioButtons[i].yPos; | 206 | int y = audioButtons[i].yPos; |
207 | if ( event->state() == QMouseEvent::LeftButton ) { | 207 | if ( event->state() == QMouseEvent::LeftButton ) { |
208 | // The test to see if the mouse click is inside the circular button or not | 208 | // The test to see if the mouse click is inside the circular button or not |
209 | // (compared with the radius squared to avoid a square-root of our distance) | 209 | // (compared with the radius squared to avoid a square-root of our distance) |
210 | int radius = 32 + 13 * size; | 210 | int radius = 32 + 13 * size; |
211 | QPoint center = QPoint( x + radius, y + radius ); | 211 | QPoint center = QPoint( x + radius, y + radius ); |
212 | QPoint dXY = center - event->pos(); | 212 | QPoint dXY = center - event->pos(); |
213 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 213 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); |
214 | bool isOnButton = dist <= (radius * radius); | 214 | bool isOnButton = dist <= (radius * radius); |
215 | // QRect r( x, y, 64 + 22*size, 64 + 22*size ); | 215 | // QRect r( x, y, 64 + 22*size, 64 + 22*size ); |
216 | // bool isOnButton = r.contains( event->pos() ); // Rectangular Button code | 216 | // bool isOnButton = r.contains( event->pos() ); // Rectangular Button code |
217 | if ( isOnButton && !audioButtons[i].isHeld ) { | 217 | if ( isOnButton && !audioButtons[i].isHeld ) { |
218 | audioButtons[i].isHeld = TRUE; | 218 | audioButtons[i].isHeld = TRUE; |
219 | toggleButton(i); | 219 | toggleButton(i); |
220 | switch (i) { | 220 | switch (i) { |
221 | case AudioVolumeUp: emit moreClicked(); return; | 221 | case AudioVolumeUp: emit moreClicked(); return; |
222 | case AudioVolumeDown: emit lessClicked(); return; | 222 | case AudioVolumeDown: emit lessClicked(); return; |
223 | } | 223 | } |
224 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 224 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
225 | audioButtons[i].isHeld = FALSE; | 225 | audioButtons[i].isHeld = FALSE; |
226 | toggleButton(i); | 226 | toggleButton(i); |
227 | } | 227 | } |
228 | } else { | 228 | } else { |
229 | if ( audioButtons[i].isHeld ) { | 229 | if ( audioButtons[i].isHeld ) { |
230 | audioButtons[i].isHeld = FALSE; | 230 | audioButtons[i].isHeld = FALSE; |
231 | if ( !audioButtons[i].isToggle ) | 231 | if ( !audioButtons[i].isToggle ) |
232 | setToggleButton( i, FALSE ); | 232 | setToggleButton( i, FALSE ); |
233 | switch (i) { | 233 | switch (i) { |
234 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; | 234 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; |
235 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 235 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
236 | case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; | 236 | case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; |
237 | case AudioNext: mediaPlayerState->setNext(); return; | 237 | case AudioNext: mediaPlayerState->setNext(); return; |
238 | case AudioPrevious: mediaPlayerState->setPrev(); return; | 238 | case AudioPrevious: mediaPlayerState->setPrev(); return; |
239 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 239 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
240 | case AudioVolumeUp: emit moreReleased(); return; | 240 | case AudioVolumeUp: emit moreReleased(); return; |
241 | case AudioVolumeDown: emit lessReleased(); return; | 241 | case AudioVolumeDown: emit lessReleased(); return; |
242 | case AudioPlayList: mediaPlayerState->setList(); return; | 242 | case AudioPlayList: mediaPlayerState->setList(); return; |
243 | } | 243 | } |
244 | } | 244 | } |
245 | } | 245 | } |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 250 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
251 | mouseMoveEvent( event ); | 251 | mouseMoveEvent( event ); |
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
255 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 255 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
256 | mouseMoveEvent( event ); | 256 | mouseMoveEvent( event ); |
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | void AudioWidget::showEvent( QShowEvent* ) { | 260 | void AudioWidget::showEvent( QShowEvent* ) { |
261 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 261 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
262 | mouseMoveEvent( &event ); | 262 | mouseMoveEvent( &event ); |
263 | } | 263 | } |
264 | 264 | ||
265 | 265 | ||
266 | void AudioWidget::closeEvent( QCloseEvent* ) { | 266 | void AudioWidget::closeEvent( QCloseEvent* ) { |
267 | mediaPlayerState->setList(); | 267 | mediaPlayerState->setList(); |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | void AudioWidget::paintEvent( QPaintEvent * ) { | 271 | void AudioWidget::paintEvent( QPaintEvent * ) { |
272 | QPainter p( this ); | 272 | QPainter p( this ); |
273 | for ( int i = 0; i < numButtons; i++ ) | 273 | for ( int i = 0; i < numButtons; i++ ) |
274 | paintButton( &p, i ); | 274 | paintButton( &p, i ); |
275 | } | 275 | } |
276 | 276 | ||
277 | 277 | ||
diff --git a/core/multimedia/opieplayer/libflash/libflashplugin.h b/core/multimedia/opieplayer/libflash/libflashplugin.h index 532bca2..a2f1c42 100644 --- a/core/multimedia/opieplayer/libflash/libflashplugin.h +++ b/core/multimedia/opieplayer/libflash/libflashplugin.h | |||
@@ -1,96 +1,98 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LIBFLASH_PLUGIN_H | 20 | #ifndef LIBFLASH_PLUGIN_H |
21 | #define LIBFLASH_PLUGIN_H | 21 | #define LIBFLASH_PLUGIN_H |
22 | 22 | ||
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qapplication.h> | 25 | #include <qapplication.h> |
26 | #include "flash.h" | 26 | #include "flash.h" |
27 | #include "mediaplayerplugininterface.h" | 27 | //#include <qpe/mediaplayerplugininterface.h> |
28 | #include "../mediaplayerplugininterface.h" | ||
28 | 29 | ||
29 | 30 | ||
30 | class LibFlashPlugin : public MediaPlayerDecoder { | 31 | class LibFlashPlugin : public MediaPlayerDecoder { |
31 | 32 | ||
32 | public: | 33 | public: |
33 | LibFlashPlugin(); | 34 | LibFlashPlugin(); |
34 | ~LibFlashPlugin() { close(); } | 35 | ~LibFlashPlugin() { close(); } |
35 | 36 | ||
36 | const char *pluginName() { return "LibFlashPlugin: " PLUGIN_NAME " " FLASH_VERSION_STRING; } | 37 | const char *pluginName() { return "LibFlashPlugin: " PLUGIN_NAME " " FLASH_VERSION_STRING; } |
37 | const char *pluginComment() { return "This is the libflash library: " PLUGIN_NAME " " FLASH_VERSION_STRING; } | 38 | const char *pluginComment() { return "This is the libflash library: " PLUGIN_NAME " " FLASH_VERSION_STRING; } |
38 | double pluginVersion() { return 1.0; } | 39 | double pluginVersion() { return 1.0; } |
39 | 40 | ||
40 | bool isFileSupported( const QString& fileName ) { return fileName.right(4) == ".swf"; } | 41 | bool isFileSupported( const QString& fileName ) { return fileName.right(4) == ".swf"; } |
41 | bool open( const QString& fileName ); | 42 | bool open( const QString& fileName ); |
42 | bool close() { FlashClose( file ); file = NULL; return TRUE; } | 43 | bool close() { FlashClose( file ); file = NULL; return TRUE; } |
43 | bool isOpen() { return file != NULL; } | 44 | bool isOpen() { return file != NULL; } |
44 | const QString &fileInfo() { return strInfo = qApp->translate( "MediaPlayer", "No Information Available", "media plugin text" ); } | 45 | const QString &fileInfo() { return strInfo = qApp->translate( "MediaPlayer", "No Information Available", "media plugin text" ); } |
45 | 46 | ||
46 | // If decoder doesn't support audio then return 0 here | 47 | // If decoder doesn't support audio then return 0 here |
47 | int audioStreams() { return 1; } | 48 | int audioStreams() { return 1; } |
48 | int audioChannels( int /*stream*/ ) { return 2; } | 49 | int audioChannels( int /*stream*/ ) { return 2; } |
49 | int audioFrequency( int /*stream*/ ) { return 44100; } | 50 | int audioFrequency( int /*stream*/ ) { return 44100; } |
50 | int audioSamples( int /*stream*/ ) { return 1000000; } | 51 | int audioSamples( int /*stream*/ ) { return 1000000; } |
52 | int audioBitsPerSample(int) { return 0;} | ||
51 | bool audioSetSample( long sample, int stream ); | 53 | bool audioSetSample( long sample, int stream ); |
52 | long audioGetSample( int stream ); | 54 | long audioGetSample( int stream ); |
53 | //bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 55 | //bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
54 | //bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 56 | //bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); |
55 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); | 57 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); |
56 | //bool audioReadSamples( short *output, int channel, long samples, int stream ); | 58 | //bool audioReadSamples( short *output, int channel, long samples, int stream ); |
57 | //bool audioReReadSamples( short *output, int channel, long samples, int stream ); | 59 | //bool audioReReadSamples( short *output, int channel, long samples, int stream ); |
58 | 60 | ||
59 | // If decoder doesn't support video then return 0 here | 61 | // If decoder doesn't support video then return 0 here |
60 | int videoStreams(); | 62 | int videoStreams(); |
61 | int videoWidth( int stream ); | 63 | int videoWidth( int stream ); |
62 | int videoHeight( int stream ); | 64 | int videoHeight( int stream ); |
63 | double videoFrameRate( int stream ); | 65 | double videoFrameRate( int stream ); |
64 | int videoFrames( int stream ); | 66 | int videoFrames( int stream ); |
65 | bool videoSetFrame( long frame, int stream ); | 67 | bool videoSetFrame( long frame, int stream ); |
66 | long videoGetFrame( int stream ); | 68 | long videoGetFrame( int stream ); |
67 | bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ); | 69 | bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ); |
68 | bool videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ); | 70 | bool videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ); |
69 | bool videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ); | 71 | bool videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ); |
70 | 72 | ||
71 | // Profiling | 73 | // Profiling |
72 | double getTime(); | 74 | double getTime(); |
73 | 75 | ||
74 | // Ignore if these aren't supported | 76 | // Ignore if these aren't supported |
75 | bool setSMP( int cpus ); | 77 | bool setSMP( int cpus ); |
76 | bool setMMX( bool useMMX ); | 78 | bool setMMX( bool useMMX ); |
77 | 79 | ||
78 | // Capabilities | 80 | // Capabilities |
79 | bool supportsAudio() { return TRUE; } | 81 | bool supportsAudio() { return TRUE; } |
80 | bool supportsVideo() { return TRUE; } | 82 | bool supportsVideo() { return TRUE; } |
81 | bool supportsYUV() { return TRUE; } | 83 | bool supportsYUV() { return TRUE; } |
82 | bool supportsMMX() { return TRUE; } | 84 | bool supportsMMX() { return TRUE; } |
83 | bool supportsSMP() { return TRUE; } | 85 | bool supportsSMP() { return TRUE; } |
84 | bool supportsStereo() { return TRUE; } | 86 | bool supportsStereo() { return TRUE; } |
85 | bool supportsScaling() { return TRUE; } | 87 | bool supportsScaling() { return TRUE; } |
86 | 88 | ||
87 | private: | 89 | private: |
88 | FlashHandle file; | 90 | FlashHandle file; |
89 | FlashDisplay *fd; | 91 | FlashDisplay *fd; |
90 | QString strInfo; | 92 | QString strInfo; |
91 | 93 | ||
92 | }; | 94 | }; |
93 | 95 | ||
94 | 96 | ||
95 | #endif | 97 | #endif |
96 | 98 | ||
diff --git a/core/multimedia/opieplayer/libflash/libflashpluginimpl.h b/core/multimedia/opieplayer/libflash/libflashpluginimpl.h index b5cc869..cb8d959 100644 --- a/core/multimedia/opieplayer/libflash/libflashpluginimpl.h +++ b/core/multimedia/opieplayer/libflash/libflashpluginimpl.h | |||
@@ -1,53 +1,54 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LIBFLASH_PLUGIN_IMPL_H | 20 | #ifndef LIBFLASH_PLUGIN_IMPL_H |
21 | #define LIBFLASH_PLUGIN_IMPL_H | 21 | #define LIBFLASH_PLUGIN_IMPL_H |
22 | 22 | ||
23 | 23 | ||
24 | //#include <qpe/mediaplayerplugininterface.h> | ||
24 | #include "../mediaplayerplugininterface.h" | 25 | #include "../mediaplayerplugininterface.h" |
25 | 26 | ||
26 | 27 | ||
27 | class LibFlashPlugin; | 28 | class LibFlashPlugin; |
28 | 29 | ||
29 | 30 | ||
30 | class LibFlashPluginImpl : public MediaPlayerPluginInterface | 31 | class LibFlashPluginImpl : public MediaPlayerPluginInterface |
31 | { | 32 | { |
32 | public: | 33 | public: |
33 | LibFlashPluginImpl(); | 34 | LibFlashPluginImpl(); |
34 | virtual ~LibFlashPluginImpl(); | 35 | virtual ~LibFlashPluginImpl(); |
35 | 36 | ||
36 | #ifndef QT_NO_COMPONENT | 37 | #ifndef QT_NO_COMPONENT |
37 | 38 | ||
38 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 39 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
39 | Q_REFCOUNT | 40 | Q_REFCOUNT |
40 | 41 | ||
41 | #endif | 42 | #endif |
42 | 43 | ||
43 | virtual MediaPlayerDecoder *decoder(); | 44 | virtual MediaPlayerDecoder *decoder(); |
44 | virtual MediaPlayerEncoder *encoder(); | 45 | virtual MediaPlayerEncoder *encoder(); |
45 | 46 | ||
46 | private: | 47 | private: |
47 | LibFlashPlugin *libflashplugin; | 48 | LibFlashPlugin *libflashplugin; |
48 | ulong ref; | 49 | ulong ref; |
49 | }; | 50 | }; |
50 | 51 | ||
51 | 52 | ||
52 | #endif | 53 | #endif |
53 | 54 | ||
diff --git a/core/multimedia/opieplayer/libflash/swf.h b/core/multimedia/opieplayer/libflash/swf.h index 5f5e4f7..48986cc 100644 --- a/core/multimedia/opieplayer/libflash/swf.h +++ b/core/multimedia/opieplayer/libflash/swf.h | |||
@@ -163,67 +163,67 @@ enum | |||
163 | stagStartSound = 15, | 163 | stagStartSound = 15, |
164 | stagStopSound = 16, | 164 | stagStopSound = 16, |
165 | stagDefineButtonSound= 17, | 165 | stagDefineButtonSound= 17, |
166 | stagSoundStreamHead = 18, | 166 | stagSoundStreamHead = 18, |
167 | stagSoundStreamBlock= 19, | 167 | stagSoundStreamBlock= 19, |
168 | stagDefineBitsLossless = 20,// A bitmap using lossless zlib compression. | 168 | stagDefineBitsLossless = 20,// A bitmap using lossless zlib compression. |
169 | stagDefineBitsJPEG2 = 21,// A bitmap using an internal JPEG compression table. | 169 | stagDefineBitsJPEG2 = 21,// A bitmap using an internal JPEG compression table. |
170 | stagDefineShape2 = 22, | 170 | stagDefineShape2 = 22, |
171 | stagDefineButtonCxform= 23, | 171 | stagDefineButtonCxform= 23, |
172 | stagProtect = 24,// This file should not be importable for editing. | 172 | stagProtect = 24,// This file should not be importable for editing. |
173 | 173 | ||
174 | // These are the new tags for Flash 3. | 174 | // These are the new tags for Flash 3. |
175 | stagPlaceObject2 = 26,// The new style place w/ alpha color transform and name. | 175 | stagPlaceObject2 = 26,// The new style place w/ alpha color transform and name. |
176 | stagRemoveObject2 = 28,// A more compact remove object that omits the character tag (just depth). | 176 | stagRemoveObject2 = 28,// A more compact remove object that omits the character tag (just depth). |
177 | stagDefineShape3 = 32,// A shape V3 includes alpha values. | 177 | stagDefineShape3 = 32,// A shape V3 includes alpha values. |
178 | stagDefineText2 = 33,// A text V2 includes alpha values. | 178 | stagDefineText2 = 33,// A text V2 includes alpha values. |
179 | stagDefineButton2 = 34,// A button V2 includes color transform, alpha and multiple actions | 179 | stagDefineButton2 = 34,// A button V2 includes color transform, alpha and multiple actions |
180 | stagDefineBitsJPEG3 = 35,// A JPEG bitmap with alpha info. | 180 | stagDefineBitsJPEG3 = 35,// A JPEG bitmap with alpha info. |
181 | stagDefineBitsLossless2 = 36,// A lossless bitmap with alpha info. | 181 | stagDefineBitsLossless2 = 36,// A lossless bitmap with alpha info. |
182 | stagDefineSprite = 39,// Define a sequence of tags that describe the behavior of a sprite. | 182 | stagDefineSprite = 39,// Define a sequence of tags that describe the behavior of a sprite. |
183 | stagNameCharacter = 40,// Name a character definition, character id and a string, (used for buttons, bitmaps, sprites and sounds). | 183 | stagNameCharacter = 40,// Name a character definition, character id and a string, (used for buttons, bitmaps, sprites and sounds). |
184 | stagFrameLabel = 43,// A string label for the current frame. | 184 | stagFrameLabel = 43,// A string label for the current frame. |
185 | stagSoundStreamHead2 = 45,// For lossless streaming sound, should not have needed this... | 185 | stagSoundStreamHead2 = 45,// For lossless streaming sound, should not have needed this... |
186 | stagDefineMorphShape = 46,// A morph shape definition | 186 | stagDefineMorphShape = 46,// A morph shape definition |
187 | stagDefineFont2 = 48, | 187 | stagDefineFont2 = 48, |
188 | 188 | ||
189 | notEnoughData = 0xffff,// Special code | 189 | notEnoughData = 0xffff,// Special code |
190 | }; | 190 | }; |
191 | 191 | ||
192 | #ifndef false | 192 | #ifndef false |
193 | #define false 0 | 193 | #define false 0 |
194 | #endif | 194 | #endif |
195 | #ifndef true | 195 | #ifndef true |
196 | #define true 1 | 196 | #define true 1 |
197 | #endif | 197 | #endif |
198 | 198 | ||
199 | extern int shape_size,shape_nb,shaperecord_size,shaperecord_nb,style_size,style_nb; | 199 | extern int shape_size,shape_nb,shaperecord_size,shaperecord_nb,style_size,style_nb; |
200 | 200 | ||
201 | typedef void (*ScanLineFunc)(void *id, long y, long start, long end); | 201 | typedef void (*ScanLineFunc)(void *id, long y, long start, long end); |
202 | 202 | ||
203 | class Bitmap; | 203 | class Bitmap; |
204 | struct FlashMovie; | 204 | struct FlashMovie; |
205 | 205 | ||
206 | extern "C" { | 206 | extern "C" { |
207 | #include "jpeglib.h" | 207 | #include "jpeglib.h" |
208 | }; | 208 | }; |
209 | extern "C" { | 209 | extern "C" { |
210 | //#include "zlib.h" | 210 | //#include "zlib.h" |
211 | #include "../src/3rdparty/zlib/zlib.h" | 211 | #include "/opt/qt-2.3.2-embedded/src/3rdparty/zlib/zlib.h" |
212 | }; | 212 | }; |
213 | 213 | ||
214 | #include "graphic.h" | 214 | #include "graphic.h" |
215 | #include "character.h" | 215 | #include "character.h" |
216 | #include "bitmap.h" | 216 | #include "bitmap.h" |
217 | #include "shape.h" | 217 | #include "shape.h" |
218 | #include "displaylist.h" | 218 | #include "displaylist.h" |
219 | #include "sound.h" | 219 | #include "sound.h" |
220 | #include "button.h" | 220 | #include "button.h" |
221 | #include "font.h" | 221 | #include "font.h" |
222 | #include "text.h" | 222 | #include "text.h" |
223 | #include "adpcm.h" | 223 | #include "adpcm.h" |
224 | #include "program.h" | 224 | #include "program.h" |
225 | #include "sprite.h" | 225 | #include "sprite.h" |
226 | #include "script.h" | 226 | #include "script.h" |
227 | #include "movie.h" | 227 | #include "movie.h" |
228 | 228 | ||
229 | #endif /* _SWF_H_ */ | 229 | #endif /* _SWF_H_ */ |
diff --git a/core/multimedia/opieplayer/libmad/Makefile.in b/core/multimedia/opieplayer/libmad/Makefile.in index e9f74e7..552043c 100644 --- a/core/multimedia/opieplayer/libmad/Makefile.in +++ b/core/multimedia/opieplayer/libmad/Makefile.in | |||
@@ -169,55 +169,57 @@ synth.o: synth.c \ | |||
169 | libmad_global.h \ | 169 | libmad_global.h \ |
170 | fixed.h \ | 170 | fixed.h \ |
171 | frame.h \ | 171 | frame.h \ |
172 | timer.h \ | 172 | timer.h \ |
173 | stream.h \ | 173 | stream.h \ |
174 | bit.h \ | 174 | bit.h \ |
175 | synth.h \ | 175 | synth.h \ |
176 | D.dat | 176 | D.dat |
177 | 177 | ||
178 | decoder.o: decoder.c \ | 178 | decoder.o: decoder.c \ |
179 | libmad_global.h \ | 179 | libmad_global.h \ |
180 | stream.h \ | 180 | stream.h \ |
181 | bit.h \ | 181 | bit.h \ |
182 | frame.h \ | 182 | frame.h \ |
183 | fixed.h \ | 183 | fixed.h \ |
184 | timer.h \ | 184 | timer.h \ |
185 | synth.h \ | 185 | synth.h \ |
186 | decoder.h | 186 | decoder.h |
187 | 187 | ||
188 | layer12.o: layer12.c \ | 188 | layer12.o: layer12.c \ |
189 | libmad_global.h \ | 189 | libmad_global.h \ |
190 | fixed.h \ | 190 | fixed.h \ |
191 | bit.h \ | 191 | bit.h \ |
192 | stream.h \ | 192 | stream.h \ |
193 | frame.h \ | 193 | frame.h \ |
194 | timer.h \ | 194 | timer.h \ |
195 | layer12.h \ | 195 | layer12.h \ |
196 | sf_table.dat \ | 196 | sf_table.dat \ |
197 | qc_table.dat | 197 | qc_table.dat |
198 | 198 | ||
199 | layer3.o: layer3.c \ | 199 | layer3.o: layer3.c \ |
200 | libmad_global.h \ | 200 | libmad_global.h \ |
201 | fixed.h \ | 201 | fixed.h \ |
202 | bit.h \ | 202 | bit.h \ |
203 | stream.h \ | 203 | stream.h \ |
204 | frame.h \ | 204 | frame.h \ |
205 | timer.h \ | 205 | timer.h \ |
206 | huffman.h \ | 206 | huffman.h \ |
207 | layer3.h \ | 207 | layer3.h \ |
208 | rq_table.dat \ | 208 | rq_table.dat \ |
209 | imdct_s.dat | 209 | imdct_s.dat |
210 | 210 | ||
211 | huffman.o: huffman.c \ | 211 | huffman.o: huffman.c \ |
212 | libmad_global.h \ | 212 | libmad_global.h \ |
213 | huffman.h | 213 | huffman.h |
214 | 214 | ||
215 | libmadplugin.o: libmadplugin.cpp \ | 215 | libmadplugin.o: libmadplugin.cpp \ |
216 | libmadplugin.h \ | 216 | libmadplugin.h \ |
217 | ../mediaplayerplugininterface.h \ | ||
217 | mad.h | 218 | mad.h |
218 | 219 | ||
219 | libmadpluginimpl.o: libmadpluginimpl.cpp \ | 220 | libmadpluginimpl.o: libmadpluginimpl.cpp \ |
220 | libmadplugin.h \ | 221 | libmadplugin.h \ |
222 | ../mediaplayerplugininterface.h \ | ||
221 | libmadpluginimpl.h | 223 | libmadpluginimpl.h |
222 | 224 | ||
223 | 225 | ||
diff --git a/core/multimedia/opieplayer/libmad/libmad.pro b/core/multimedia/opieplayer/libmad/libmad.pro index 6c40a15..b54ca6b 100644 --- a/core/multimedia/opieplayer/libmad/libmad.pro +++ b/core/multimedia/opieplayer/libmad/libmad.pro | |||
@@ -1,12 +1,14 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | HEADERS = libmad_version.h fixed.h bit.h timer.h stream.h frame.h synth.h decoder.h \ | 3 | HEADERS = libmad_version.h fixed.h bit.h timer.h stream.h frame.h synth.h decoder.h \ |
4 | layer12.h layer3.h huffman.h libmad_global.h mad.h libmadplugin.h libmadpluginimpl.h | 4 | layer12.h layer3.h huffman.h libmad_global.h mad.h libmadplugin.h libmadpluginimpl.h |
5 | SOURCES = version.c fixed.c bit.c timer.c stream.c frame.c synth.c decoder.c \ | 5 | SOURCES = version.c fixed.c bit.c timer.c stream.c frame.c synth.c decoder.c \ |
6 | layer12.c layer3.c huffman.c libmadplugin.cpp libmadpluginimpl.cpp | 6 | layer12.c layer3.c huffman.c libmadplugin.cpp libmadpluginimpl.cpp |
7 | TARGET = madplugin | 7 | TARGET = madplugin |
8 | DESTDIR = ../../plugins/codecs | 8 | DESTDIR = ../../plugins/codecs |
9 | INCLUDEPATH += $(OPIEDIR)/include .. | 9 | INCLUDEPATH += $(OPIEDIR)/include .. |
10 | DEPENDPATH += ../$(OPIEDIR)/include .. | 10 | DEPENDPATH += ../$(OPIEDIR)/include .. |
11 | TMAKE_CFLAGS += -DFPM_64BIT | ||
12 | TMAKE_CXXFLAGS += -DFPM_64BIT | ||
11 | LIBS += -lqpe -lm | 13 | LIBS += -lqpe -lm |
12 | VERSION = 1.0.0 | 14 | VERSION = 1.0.0 |
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.h b/core/multimedia/opieplayer/libmad/libmadplugin.h index 88647ae..ff84c27 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.h +++ b/core/multimedia/opieplayer/libmad/libmadplugin.h | |||
@@ -1,101 +1,111 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LIBMAD_PLUGIN_H | 20 | #ifndef LIBMAD_PLUGIN_H |
21 | #define LIBMAD_PLUGIN_H | 21 | #define LIBMAD_PLUGIN_H |
22 | 22 | ||
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include "mediaplayerplugininterface.h" | 25 | //#include <qpe/mediaplayerplugininterface.h> |
26 | #include "../mediaplayerplugininterface.h" | ||
27 | |||
28 | |||
29 | // #define OLD_MEDIAPLAYER_API | ||
26 | 30 | ||
27 | 31 | ||
28 | class LibMadPluginData; | 32 | class LibMadPluginData; |
29 | 33 | ||
30 | 34 | ||
31 | class LibMadPlugin : public MediaPlayerDecoder { | 35 | class LibMadPlugin : public MediaPlayerDecoder { |
32 | 36 | ||
33 | public: | 37 | public: |
34 | LibMadPlugin(); | 38 | LibMadPlugin(); |
35 | ~LibMadPlugin(); | 39 | ~LibMadPlugin(); |
36 | 40 | ||
37 | const char *pluginName() { return "LibMadPlugin"; } | 41 | const char *pluginName() { return "LibMadPlugin"; } |
38 | const char *pluginComment() { return "This is the libmad library that has been wrapped as a plugin"; } | 42 | const char *pluginComment() { return "This is the libmad library that has been wrapped as a plugin"; } |
39 | double pluginVersion() { return 1.0; } | 43 | double pluginVersion() { return 1.0; } |
40 | 44 | ||
41 | bool isFileSupported( const QString& ); | 45 | bool isFileSupported( const QString& ); |
42 | bool open( const QString& ); | 46 | bool open( const QString& ); |
43 | bool close(); | 47 | bool close(); |
44 | bool isOpen(); | 48 | bool isOpen(); |
45 | const QString &fileInfo() { return info; } | 49 | const QString &fileInfo() { return info; } |
46 | 50 | ||
47 | // If decoder doesn't support audio then return 0 here | 51 | // If decoder doesn't support audio then return 0 here |
48 | int audioStreams(); | 52 | int audioStreams(); |
49 | int audioChannels( int stream ); | 53 | int audioChannels( int stream ); |
50 | int audioFrequency( int stream ); | 54 | int audioFrequency( int stream ); |
51 | int audioSamples( int stream ); | 55 | int audioSamples( int stream ); |
52 | bool audioSetSample( long sample, int stream ); | 56 | bool audioSetSample( long sample, int stream ); |
57 | int audioBitsPerSample(int) {return 0;} | ||
53 | long audioGetSample( int stream ); | 58 | long audioGetSample( int stream ); |
54 | // bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 59 | #ifdef OLD_MEDIAPLAYER_API |
55 | // bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 60 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
61 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | ||
62 | bool audioReadSamples( short *output, int channel, long samples, int stream ); | ||
63 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); | ||
64 | #else | ||
56 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); | 65 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); |
57 | // bool audioReadSamples( short *output, int channel, long samples, int stream ); | 66 | #endif |
58 | // bool audioReReadSamples( short *output, int channel, long samples, int stream ); | ||
59 | 67 | ||
60 | 68 | ||
61 | bool read(); | 69 | bool read(); |
62 | bool decode( short *output, long samples, long& samplesRead ); | 70 | bool decode( short *output, long samples, long& samplesRead ); |
63 | void printID3Tags(); | 71 | void printID3Tags(); |
64 | 72 | ||
65 | 73 | ||
66 | // If decoder doesn't support video then return 0 here | 74 | // If decoder doesn't support video then return 0 here |
67 | int videoStreams() { return 0; } | 75 | int videoStreams() { return 0; } |
68 | int videoWidth( int ) { return 0; } | 76 | int videoWidth( int ) { return 0; } |
69 | int videoHeight( int ) { return 0; } | 77 | int videoHeight( int ) { return 0; } |
70 | double videoFrameRate( int ) { return 0.0; } | 78 | double videoFrameRate( int ) { return 0.0; } |
71 | int videoFrames( int ) { return 0; } | 79 | int videoFrames( int ) { return 0; } |
72 | bool videoSetFrame( long, int ) { return FALSE; } | 80 | bool videoSetFrame( long, int ) { return FALSE; } |
73 | long videoGetFrame( int ) { return 0; } | 81 | long videoGetFrame( int ) { return 0; } |
74 | bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } | 82 | bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } |
75 | bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } | 83 | bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } |
76 | bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } | 84 | bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } |
77 | 85 | ||
78 | // Profiling | 86 | // Profiling |
79 | double getTime(); | 87 | double getTime(); |
80 | 88 | ||
81 | // Ignore if these aren't supported | 89 | // Ignore if these aren't supported |
82 | bool setSMP( int ) { return FALSE; } | 90 | bool setSMP( int ) { return FALSE; } |
83 | bool setMMX( bool ) { return FALSE; } | 91 | bool setMMX( bool ) { return FALSE; } |
84 | 92 | ||
85 | // Capabilities | 93 | // Capabilities |
86 | bool supportsAudio() { return TRUE; } | 94 | bool supportsAudio() { return TRUE; } |
87 | bool supportsVideo() { return FALSE; } | 95 | bool supportsVideo() { return FALSE; } |
88 | bool supportsYUV() { return FALSE; } | 96 | bool supportsYUV() { return FALSE; } |
89 | bool supportsMMX() { return TRUE; } | 97 | bool supportsMMX() { return TRUE; } |
90 | bool supportsSMP() { return FALSE; } | 98 | bool supportsSMP() { return FALSE; } |
91 | bool supportsStereo() { return TRUE; } | 99 | bool supportsStereo() { return TRUE; } |
92 | bool supportsScaling() { return FALSE; } | 100 | bool supportsScaling() { return FALSE; } |
93 | 101 | ||
102 | long getPlayTime() { return -1; } | ||
103 | |||
94 | private: | 104 | private: |
95 | LibMadPluginData *d; | 105 | LibMadPluginData *d; |
96 | QString info; | 106 | QString info; |
97 | 107 | ||
98 | }; | 108 | }; |
99 | 109 | ||
100 | 110 | ||
101 | #endif | 111 | #endif |
diff --git a/core/multimedia/opieplayer/libmad/libmadpluginimpl.h b/core/multimedia/opieplayer/libmad/libmadpluginimpl.h index a26b421..8ad4956 100644 --- a/core/multimedia/opieplayer/libmad/libmadpluginimpl.h +++ b/core/multimedia/opieplayer/libmad/libmadpluginimpl.h | |||
@@ -1,53 +1,53 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LIBMAD_PLUGIN_IMPL_H | 20 | #ifndef LIBMAD_PLUGIN_IMPL_H |
21 | #define LIBMAD_PLUGIN_IMPL_H | 21 | #define LIBMAD_PLUGIN_IMPL_H |
22 | 22 | ||
23 | 23 | ||
24 | //#include <qpe/mediaplayerplugininterface.h> | ||
24 | #include "../mediaplayerplugininterface.h" | 25 | #include "../mediaplayerplugininterface.h" |
25 | 26 | ||
26 | 27 | ||
27 | class LibMadPlugin; | 28 | class LibMadPlugin; |
28 | 29 | ||
29 | 30 | ||
30 | class LibMadPluginImpl : public MediaPlayerPluginInterface | 31 | class LibMadPluginImpl : public MediaPlayerPluginInterface |
31 | { | 32 | { |
32 | public: | 33 | public: |
33 | LibMadPluginImpl(); | 34 | LibMadPluginImpl(); |
34 | virtual ~LibMadPluginImpl(); | 35 | virtual ~LibMadPluginImpl(); |
35 | 36 | ||
36 | #ifndef QT_NO_COMPONENT | 37 | #ifndef QT_NO_COMPONENT |
37 | 38 | ||
38 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 39 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
39 | Q_REFCOUNT | 40 | Q_REFCOUNT |
40 | 41 | ||
41 | #endif | 42 | #endif |
42 | 43 | ||
43 | virtual MediaPlayerDecoder *decoder(); | 44 | virtual MediaPlayerDecoder *decoder(); |
44 | virtual MediaPlayerEncoder *encoder(); | 45 | virtual MediaPlayerEncoder *encoder(); |
45 | |||
46 | private: | 46 | private: |
47 | LibMadPlugin *libmadplugin; | 47 | LibMadPlugin *libmadplugin; |
48 | ulong ref; | 48 | ulong ref; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | 51 | ||
52 | #endif | 52 | #endif |
53 | 53 | ||
diff --git a/core/multimedia/opieplayer/libmad/version.c b/core/multimedia/opieplayer/libmad/version.c index 413d54b..1baba26 100644 --- a/core/multimedia/opieplayer/libmad/version.c +++ b/core/multimedia/opieplayer/libmad/version.c | |||
@@ -43,49 +43,49 @@ char const mad_build[] = | |||
43 | # elif defined(FPM_SPARC) | 43 | # elif defined(FPM_SPARC) |
44 | "FPM_SPARC " | 44 | "FPM_SPARC " |
45 | # elif defined(FPM_PPC) | 45 | # elif defined(FPM_PPC) |
46 | "FPM_PPC " | 46 | "FPM_PPC " |
47 | # elif defined(FPM_DEFAULT) | 47 | # elif defined(FPM_DEFAULT) |
48 | "FPM_DEFAULT " | 48 | "FPM_DEFAULT " |
49 | # endif | 49 | # endif |
50 | 50 | ||
51 | # if defined(ASO_IMDCT) | 51 | # if defined(ASO_IMDCT) |
52 | "ASO_IMDCT " | 52 | "ASO_IMDCT " |
53 | # endif | 53 | # endif |
54 | # if defined(ASO_INTERLEAVE1) | 54 | # if defined(ASO_INTERLEAVE1) |
55 | "ASO_INTERLEAVE1 " | 55 | "ASO_INTERLEAVE1 " |
56 | # endif | 56 | # endif |
57 | # if defined(ASO_INTERLEAVE2) | 57 | # if defined(ASO_INTERLEAVE2) |
58 | "ASO_INTERLEAVE2 " | 58 | "ASO_INTERLEAVE2 " |
59 | # endif | 59 | # endif |
60 | # if defined(ASO_ZEROCHECK) | 60 | # if defined(ASO_ZEROCHECK) |
61 | "ASO_ZEROCHECK " | 61 | "ASO_ZEROCHECK " |
62 | # endif | 62 | # endif |
63 | 63 | ||
64 | # if defined(OPT_SPEED) | 64 | # if defined(OPT_SPEED) |
65 | "OPT_SPEED " | 65 | "OPT_SPEED " |
66 | # elif defined(OPT_ACCURACY) | 66 | # elif defined(OPT_ACCURACY) |
67 | "OPT_ACCURACY " | 67 | "OPT_ACCURACY " |
68 | # endif | 68 | # endif |
69 | 69 | ||
70 | # if defined(OPT_SSO) | 70 | # if defined(OPT_SSO) |
71 | "OPT_SSO " | 71 | "OPT_SSO " |
72 | # endif | 72 | # endif |
73 | 73 | ||
74 | # if defined(OPT_DCTO) /* never defined here */ | 74 | # if defined(OPT_DCTO) /* never defined here */ |
75 | "OPT_DCTO " | 75 | "OPT_DCTO " |
76 | # endif | 76 | # endif |
77 | 77 | ||
78 | # if defined(OPT_STRICT) | 78 | # if defined(OPT_STRICT) |
79 | "OPT_STRICT " | 79 | "OPT_STRICT " |
80 | # endif | 80 | # endif |
81 | 81 | ||
82 | # if defined(EXPERIMENTAL) | 82 | # if defined(EXPERIMENTAL) |
83 | "EXPERIMENTAL " | 83 | "EXPERIMENTAL " |
84 | # endif | 84 | # endif |
85 | 85 | ||
86 | # if defined(DEBUG) | 86 | # if defined(DEBUG) |
87 | "DEBUG " | 87 | "DEBUG " |
88 | # elif defined(NDEBUG) | 88 | # elif defined(NDEBUG) |
89 | "NDEBUG " | 89 | "NDEBUG " |
90 | # endif | 90 | # endif |
91 | ; | 91 | ; \ No newline at end of file |
diff --git a/core/multimedia/opieplayer/libmpeg3/Makefile.in b/core/multimedia/opieplayer/libmpeg3/Makefile.in index 154f85d..d255e4f 100644 --- a/core/multimedia/opieplayer/libmpeg3/Makefile.in +++ b/core/multimedia/opieplayer/libmpeg3/Makefile.in | |||
@@ -131,112 +131,114 @@ moc: $(SRCMOC) | |||
131 | 131 | ||
132 | tmake: | 132 | tmake: |
133 | tmake libmpeg3.pro | 133 | tmake libmpeg3.pro |
134 | 134 | ||
135 | clean: | 135 | clean: |
136 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) | 136 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) |
137 | -rm -f *~ core | 137 | -rm -f *~ core |
138 | -rm -f allmoc.cpp | 138 | -rm -f allmoc.cpp |
139 | 139 | ||
140 | ####### Extension Modules | 140 | ####### Extension Modules |
141 | 141 | ||
142 | listpromodules: | 142 | listpromodules: |
143 | @echo | 143 | @echo |
144 | 144 | ||
145 | listallmodules: | 145 | listallmodules: |
146 | @echo | 146 | @echo |
147 | 147 | ||
148 | listaddonpromodules: | 148 | listaddonpromodules: |
149 | @echo | 149 | @echo |
150 | 150 | ||
151 | listaddonentmodules: | 151 | listaddonentmodules: |
152 | @echo | 152 | @echo |
153 | 153 | ||
154 | 154 | ||
155 | REQUIRES= | 155 | REQUIRES= |
156 | 156 | ||
157 | ####### Sub-libraries | 157 | ####### Sub-libraries |
158 | 158 | ||
159 | 159 | ||
160 | ###### Combined headers | 160 | ###### Combined headers |
161 | 161 | ||
162 | 162 | ||
163 | 163 | ||
164 | ####### Compile | 164 | ####### Compile |
165 | 165 | ||
166 | libmpeg3plugin.o: libmpeg3plugin.cpp \ | 166 | libmpeg3plugin.o: libmpeg3plugin.cpp \ |
167 | libmpeg3plugin.h \ | 167 | libmpeg3plugin.h \ |
168 | libmpeg3.h \ | 168 | libmpeg3.h \ |
169 | mpeg3private.h \ | 169 | mpeg3private.h \ |
170 | mpeg3atrack.h \ | 170 | mpeg3atrack.h \ |
171 | mpeg3demux.h \ | 171 | mpeg3demux.h \ |
172 | mpeg3title.h \ | 172 | mpeg3title.h \ |
173 | mpeg3io.h \ | 173 | mpeg3io.h \ |
174 | mpeg3css.h \ | 174 | mpeg3css.h \ |
175 | mpeg3private.inc \ | 175 | mpeg3private.inc \ |
176 | audio/mpeg3audio.h \ | 176 | audio/mpeg3audio.h \ |
177 | mpeg3vtrack.h \ | 177 | mpeg3vtrack.h \ |
178 | video/mpeg3video.h \ | 178 | video/mpeg3video.h \ |
179 | mpeg3protos.h | 179 | mpeg3protos.h \ |
180 | ../mediaplayerplugininterface.h | ||
180 | 181 | ||
181 | libmpeg3pluginimpl.o: libmpeg3pluginimpl.cpp \ | 182 | libmpeg3pluginimpl.o: libmpeg3pluginimpl.cpp \ |
182 | libmpeg3plugin.h \ | 183 | libmpeg3plugin.h \ |
183 | libmpeg3.h \ | 184 | libmpeg3.h \ |
184 | mpeg3private.h \ | 185 | mpeg3private.h \ |
185 | mpeg3atrack.h \ | 186 | mpeg3atrack.h \ |
186 | mpeg3demux.h \ | 187 | mpeg3demux.h \ |
187 | mpeg3title.h \ | 188 | mpeg3title.h \ |
188 | mpeg3io.h \ | 189 | mpeg3io.h \ |
189 | mpeg3css.h \ | 190 | mpeg3css.h \ |
190 | mpeg3private.inc \ | 191 | mpeg3private.inc \ |
191 | audio/mpeg3audio.h \ | 192 | audio/mpeg3audio.h \ |
192 | mpeg3vtrack.h \ | 193 | mpeg3vtrack.h \ |
193 | video/mpeg3video.h \ | 194 | video/mpeg3video.h \ |
194 | mpeg3protos.h \ | 195 | mpeg3protos.h \ |
196 | ../mediaplayerplugininterface.h \ | ||
195 | libmpeg3pluginimpl.h | 197 | libmpeg3pluginimpl.h |
196 | 198 | ||
197 | bitstream.o: bitstream.c \ | 199 | bitstream.o: bitstream.c \ |
198 | mpeg3private.h \ | 200 | mpeg3private.h \ |
199 | mpeg3atrack.h \ | 201 | mpeg3atrack.h \ |
200 | mpeg3demux.h \ | 202 | mpeg3demux.h \ |
201 | mpeg3title.h \ | 203 | mpeg3title.h \ |
202 | mpeg3io.h \ | 204 | mpeg3io.h \ |
203 | mpeg3css.h \ | 205 | mpeg3css.h \ |
204 | mpeg3private.inc \ | 206 | mpeg3private.inc \ |
205 | audio/mpeg3audio.h \ | 207 | audio/mpeg3audio.h \ |
206 | mpeg3vtrack.h \ | 208 | mpeg3vtrack.h \ |
207 | video/mpeg3video.h \ | 209 | video/mpeg3video.h \ |
208 | mpeg3protos.h | 210 | mpeg3protos.h |
209 | 211 | ||
210 | libmpeg3.o: libmpeg3.c \ | 212 | libmpeg3.o: libmpeg3.c \ |
211 | libmpeg3.h \ | 213 | libmpeg3.h \ |
212 | mpeg3private.h \ | 214 | mpeg3private.h \ |
213 | mpeg3atrack.h \ | 215 | mpeg3atrack.h \ |
214 | mpeg3demux.h \ | 216 | mpeg3demux.h \ |
215 | mpeg3title.h \ | 217 | mpeg3title.h \ |
216 | mpeg3io.h \ | 218 | mpeg3io.h \ |
217 | mpeg3css.h \ | 219 | mpeg3css.h \ |
218 | mpeg3private.inc \ | 220 | mpeg3private.inc \ |
219 | audio/mpeg3audio.h \ | 221 | audio/mpeg3audio.h \ |
220 | mpeg3vtrack.h \ | 222 | mpeg3vtrack.h \ |
221 | video/mpeg3video.h \ | 223 | video/mpeg3video.h \ |
222 | mpeg3protos.h | 224 | mpeg3protos.h |
223 | 225 | ||
224 | mpeg3atrack.o: mpeg3atrack.c \ | 226 | mpeg3atrack.o: mpeg3atrack.c \ |
225 | libmpeg3.h \ | 227 | libmpeg3.h \ |
226 | mpeg3private.h \ | 228 | mpeg3private.h \ |
227 | mpeg3atrack.h \ | 229 | mpeg3atrack.h \ |
228 | mpeg3demux.h \ | 230 | mpeg3demux.h \ |
229 | mpeg3title.h \ | 231 | mpeg3title.h \ |
230 | mpeg3io.h \ | 232 | mpeg3io.h \ |
231 | mpeg3css.h \ | 233 | mpeg3css.h \ |
232 | mpeg3private.inc \ | 234 | mpeg3private.inc \ |
233 | audio/mpeg3audio.h \ | 235 | audio/mpeg3audio.h \ |
234 | mpeg3vtrack.h \ | 236 | mpeg3vtrack.h \ |
235 | video/mpeg3video.h \ | 237 | video/mpeg3video.h \ |
236 | mpeg3protos.h | 238 | mpeg3protos.h |
237 | 239 | ||
238 | mpeg3css.o: mpeg3css.c \ | 240 | mpeg3css.o: mpeg3css.c \ |
239 | mpeg3css.h \ | 241 | mpeg3css.h \ |
240 | mpeg3private.h \ | 242 | mpeg3private.h \ |
241 | mpeg3atrack.h \ | 243 | mpeg3atrack.h \ |
242 | mpeg3demux.h \ | 244 | mpeg3demux.h \ |
@@ -369,97 +371,97 @@ audio/exponents.o: audio/exponents.c \ | |||
369 | mpeg3private.inc \ | 371 | mpeg3private.inc \ |
370 | audio/../libmpeg3.h \ | 372 | audio/../libmpeg3.h \ |
371 | mpeg3private.h \ | 373 | mpeg3private.h \ |
372 | mpeg3atrack.h \ | 374 | mpeg3atrack.h \ |
373 | audio/mpeg3audio.h \ | 375 | audio/mpeg3audio.h \ |
374 | mpeg3vtrack.h \ | 376 | mpeg3vtrack.h \ |
375 | video/mpeg3video.h \ | 377 | video/mpeg3video.h \ |
376 | audio/../mpeg3protos.h | 378 | audio/../mpeg3protos.h |
377 | 379 | ||
378 | audio/header.o: audio/header.c \ | 380 | audio/header.o: audio/header.c \ |
379 | audio/mpeg3audio.h \ | 381 | audio/mpeg3audio.h \ |
380 | audio/ac3.h \ | 382 | audio/ac3.h \ |
381 | audio/mpeg3real.h \ | 383 | audio/mpeg3real.h \ |
382 | audio/../bitstream.h \ | 384 | audio/../bitstream.h \ |
383 | mpeg3demux.h \ | 385 | mpeg3demux.h \ |
384 | mpeg3title.h \ | 386 | mpeg3title.h \ |
385 | mpeg3io.h \ | 387 | mpeg3io.h \ |
386 | mpeg3css.h \ | 388 | mpeg3css.h \ |
387 | mpeg3private.inc \ | 389 | mpeg3private.inc \ |
388 | audio/tables.h \ | 390 | audio/tables.h \ |
389 | audio/../libmpeg3.h \ | 391 | audio/../libmpeg3.h \ |
390 | mpeg3private.h \ | 392 | mpeg3private.h \ |
391 | mpeg3atrack.h \ | 393 | mpeg3atrack.h \ |
392 | audio/mpeg3audio.h \ | 394 | audio/mpeg3audio.h \ |
393 | mpeg3vtrack.h \ | 395 | mpeg3vtrack.h \ |
394 | video/mpeg3video.h \ | 396 | video/mpeg3video.h \ |
395 | audio/../mpeg3protos.h | 397 | audio/../mpeg3protos.h |
396 | 398 | ||
397 | audio/layer2.o: audio/layer2.c \ | 399 | audio/layer2.o: audio/layer2.c \ |
398 | audio/mpeg3audio.h \ | 400 | audio/mpeg3audio.h \ |
399 | audio/ac3.h \ | 401 | audio/ac3.h \ |
400 | audio/mpeg3real.h \ | 402 | audio/mpeg3real.h \ |
401 | audio/../bitstream.h \ | 403 | audio/../bitstream.h \ |
402 | mpeg3demux.h \ | 404 | mpeg3demux.h \ |
403 | mpeg3title.h \ | 405 | mpeg3title.h \ |
404 | mpeg3io.h \ | 406 | mpeg3io.h \ |
405 | mpeg3css.h \ | 407 | mpeg3css.h \ |
406 | mpeg3private.inc \ | 408 | mpeg3private.inc \ |
407 | audio/../libmpeg3.h \ | 409 | audio/../libmpeg3.h \ |
408 | mpeg3private.h \ | 410 | mpeg3private.h \ |
409 | mpeg3atrack.h \ | 411 | mpeg3atrack.h \ |
410 | audio/mpeg3audio.h \ | 412 | audio/mpeg3audio.h \ |
411 | mpeg3vtrack.h \ | 413 | mpeg3vtrack.h \ |
412 | video/mpeg3video.h \ | 414 | video/mpeg3video.h \ |
413 | audio/../mpeg3protos.h \ | 415 | audio/../mpeg3protos.h \ |
414 | audio/tables.h | 416 | audio/tables.h |
415 | 417 | ||
416 | audio/layer3.o: audio/layer3.c \ | 418 | audio/layer3.o: audio/layer3.c \ |
417 | audio/huffman.h \ | 419 | huffman.h \ |
418 | audio/mpeg3audio.h \ | 420 | audio/mpeg3audio.h \ |
419 | audio/ac3.h \ | 421 | audio/ac3.h \ |
420 | audio/mpeg3real.h \ | 422 | audio/mpeg3real.h \ |
421 | audio/../bitstream.h \ | 423 | audio/../bitstream.h \ |
422 | mpeg3demux.h \ | 424 | mpeg3demux.h \ |
423 | mpeg3title.h \ | 425 | mpeg3title.h \ |
424 | mpeg3io.h \ | 426 | mpeg3io.h \ |
425 | mpeg3css.h \ | 427 | mpeg3css.h \ |
426 | mpeg3private.inc \ | 428 | mpeg3private.inc \ |
427 | audio/../libmpeg3.h \ | 429 | audio/../libmpeg3.h \ |
428 | mpeg3private.h \ | 430 | mpeg3private.h \ |
429 | mpeg3atrack.h \ | 431 | mpeg3atrack.h \ |
430 | audio/mpeg3audio.h \ | 432 | audio/mpeg3audio.h \ |
431 | mpeg3vtrack.h \ | 433 | mpeg3vtrack.h \ |
432 | video/mpeg3video.h \ | 434 | video/mpeg3video.h \ |
433 | audio/../mpeg3protos.h \ | 435 | audio/../mpeg3protos.h \ |
434 | audio/tables.h | 436 | audio/tables.h |
435 | 437 | ||
436 | audio/mantissa.o: audio/mantissa.c \ | 438 | audio/mantissa.o: audio/mantissa.c \ |
437 | audio/mpeg3audio.h \ | 439 | audio/mpeg3audio.h \ |
438 | audio/ac3.h \ | 440 | audio/ac3.h \ |
439 | audio/mpeg3real.h \ | 441 | audio/mpeg3real.h \ |
440 | audio/../bitstream.h \ | 442 | audio/../bitstream.h \ |
441 | mpeg3demux.h \ | 443 | mpeg3demux.h \ |
442 | mpeg3title.h \ | 444 | mpeg3title.h \ |
443 | mpeg3io.h \ | 445 | mpeg3io.h \ |
444 | mpeg3css.h \ | 446 | mpeg3css.h \ |
445 | mpeg3private.inc \ | 447 | mpeg3private.inc \ |
446 | audio/../libmpeg3.h \ | 448 | audio/../libmpeg3.h \ |
447 | mpeg3private.h \ | 449 | mpeg3private.h \ |
448 | mpeg3atrack.h \ | 450 | mpeg3atrack.h \ |
449 | audio/mpeg3audio.h \ | 451 | audio/mpeg3audio.h \ |
450 | mpeg3vtrack.h \ | 452 | mpeg3vtrack.h \ |
451 | video/mpeg3video.h \ | 453 | video/mpeg3video.h \ |
452 | audio/../mpeg3protos.h | 454 | audio/../mpeg3protos.h |
453 | 455 | ||
454 | audio/mpeg3audio.o: audio/mpeg3audio.c \ | 456 | audio/mpeg3audio.o: audio/mpeg3audio.c \ |
455 | audio/../libmpeg3.h \ | 457 | audio/../libmpeg3.h \ |
456 | mpeg3private.h \ | 458 | mpeg3private.h \ |
457 | mpeg3atrack.h \ | 459 | mpeg3atrack.h \ |
458 | mpeg3demux.h \ | 460 | mpeg3demux.h \ |
459 | mpeg3title.h \ | 461 | mpeg3title.h \ |
460 | mpeg3io.h \ | 462 | mpeg3io.h \ |
461 | mpeg3css.h \ | 463 | mpeg3css.h \ |
462 | mpeg3private.inc \ | 464 | mpeg3private.inc \ |
463 | audio/mpeg3audio.h \ | 465 | audio/mpeg3audio.h \ |
464 | audio/ac3.h \ | 466 | audio/ac3.h \ |
465 | audio/mpeg3real.h \ | 467 | audio/mpeg3real.h \ |
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h index 0a06264..54f259b 100644 --- a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h +++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h | |||
@@ -1,113 +1,123 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LIBMPEG3_PLUGIN_H | 20 | #ifndef LIBMPEG3_PLUGIN_H |
21 | #define LIBMPEG3_PLUGIN_H | 21 | #define LIBMPEG3_PLUGIN_H |
22 | 22 | ||
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qapplication.h> | 25 | #include <qapplication.h> |
26 | #include "libmpeg3.h" | 26 | #include "libmpeg3.h" |
27 | #include "mpeg3protos.h" | 27 | #include "mpeg3protos.h" |
28 | #include "mediaplayerplugininterface.h" | 28 | //#include <qpe/mediaplayerplugininterface.h> |
29 | #include "../mediaplayerplugininterface.h" | ||
30 | |||
31 | |||
32 | // #define OLD_MEDIAPLAYER_API | ||
29 | 33 | ||
30 | 34 | ||
31 | class LibMpeg3Plugin : public MediaPlayerDecoder { | 35 | class LibMpeg3Plugin : public MediaPlayerDecoder { |
32 | 36 | ||
33 | public: | 37 | public: |
34 | LibMpeg3Plugin() { file = NULL; } | 38 | LibMpeg3Plugin() { file = NULL; } |
35 | ~LibMpeg3Plugin() { close(); } | 39 | ~LibMpeg3Plugin() { close(); } |
36 | 40 | ||
37 | const char *pluginName() { return "LibMpeg3Plugin"; } | 41 | const char *pluginName() { return "LibMpeg3Plugin"; } |
38 | const char *pluginComment() { return "This is the libmpeg3 library writen by ... which has been modified by trolltech to use fixed point maths"; } | 42 | const char *pluginComment() { return "This is the libmpeg3 library writen by ... which has been modified by trolltech to use fixed point maths"; } |
39 | double pluginVersion() { return 1.0; } | 43 | double pluginVersion() { return 1.0; } |
40 | 44 | ||
41 | bool isFileSupported( const QString& fileName ) { return mpeg3_check_sig( (char *)fileName.latin1() ) == 1; } | 45 | bool isFileSupported( const QString& fileName ) { return mpeg3_check_sig( (char *)fileName.latin1() ) == 1; } |
42 | bool open( const QString& fileName ) { file = mpeg3_open( (char *)fileName.latin1() ); return file != NULL; } | 46 | bool open( const QString& fileName ) { file = mpeg3_open( (char *)fileName.latin1() ); return file != NULL; } |
43 | bool close() { if ( file ) { int r = mpeg3_close( file ); file = NULL; return r == 1; } return FALSE; } | 47 | bool close() { if ( file ) { int r = mpeg3_close( file ); file = NULL; return r == 1; } return FALSE; } |
44 | bool isOpen() { return file != NULL; } | 48 | bool isOpen() { return file != NULL; } |
45 | const QString &fileInfo() { return strInfo = QString( "" ); } | 49 | const QString &fileInfo() { return strInfo = ""; } |
46 | 50 | ||
47 | // If decoder doesn't support audio then return 0 here | 51 | // If decoder doesn't support audio then return 0 here |
48 | int audioStreams() { return file ? mpeg3_total_astreams( file ) : 0; } | 52 | int audioStreams() { return file ? mpeg3_total_astreams( file ) : 0; } |
49 | int audioChannels( int stream ) { return file ? mpeg3_audio_channels( file, stream ) : 0; } | 53 | int audioChannels( int stream ) { return file ? mpeg3_audio_channels( file, stream ) : 0; } |
50 | int audioFrequency( int stream ) { return file ? mpeg3_sample_rate( file, stream ) : 0; } | 54 | int audioFrequency( int stream ) { return file ? mpeg3_sample_rate( file, stream ) : 0; } |
55 | int audioBitsPerSample(int) { return 0;} | ||
51 | int audioSamples( int stream ) { return file ? mpeg3_audio_samples( file, stream ) : 0; } | 56 | int audioSamples( int stream ) { return file ? mpeg3_audio_samples( file, stream ) : 0; } |
52 | bool audioSetSample( long sample, int stream ) { return file ? mpeg3_set_sample( file, sample, stream) == 1 : FALSE; } | 57 | bool audioSetSample( long sample, int stream ) { return file ? mpeg3_set_sample( file, sample, stream) == 1 : FALSE; } |
53 | long audioGetSample( int stream ) { return file ? mpeg3_get_sample( file, stream ) : 0; } | 58 | long audioGetSample( int stream ) { return file ? mpeg3_get_sample( file, stream ) : 0; } |
54 | // bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 59 | #ifdef OLD_MEDIAPLAYER_API |
55 | // bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 60 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
61 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | ||
62 | bool audioReadSamples( short *output, int channel, long samples, int stream ); | ||
63 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); | ||
64 | #else | ||
56 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); | 65 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); |
57 | // bool audioReadSamples( short *output, int channel, long samples, int stream ); | 66 | #endif |
58 | // bool audioReReadSamples( short *output, int channel, long samples, int stream ); | ||
59 | 67 | ||
60 | // If decoder doesn't support video then return 0 here | 68 | // If decoder doesn't support video then return 0 here |
61 | int videoStreams() { return file ? mpeg3_total_vstreams( file ) : 0; } | 69 | int videoStreams() { return file ? mpeg3_total_vstreams( file ) : 0; } |
62 | int videoWidth( int stream ) { return file ? mpeg3_video_width( file, stream ) : 0; } | 70 | int videoWidth( int stream ) { return file ? mpeg3_video_width( file, stream ) : 0; } |
63 | int videoHeight( int stream ) { return file ? mpeg3_video_height( file, stream ) : 0; } | 71 | int videoHeight( int stream ) { return file ? mpeg3_video_height( file, stream ) : 0; } |
64 | double videoFrameRate( int stream ) { return file ? mpeg3_frame_rate( file, stream ) : 0.0; } | 72 | double videoFrameRate( int stream ) { return file ? mpeg3_frame_rate( file, stream ) : 0.0; } |
65 | int videoFrames( int stream ) | 73 | int videoFrames( int stream ) |
66 | { return file ? mpeg3_video_frames( file, stream ) : 0; } | 74 | { return file ? mpeg3_video_frames( file, stream ) : 0; } |
67 | /* | 75 | /* |
68 | { | 76 | { |
69 | if ( file ) { | 77 | if ( file ) { |
70 | int frames = mpeg3_video_frames( file, stream ); | 78 | int frames = mpeg3_video_frames( file, stream ); |
71 | if ( frames == 1 ) { | 79 | if ( frames == 1 ) { |
72 | int res = mpeg3_seek_percentage( file, 0.99 ); | 80 | int res = mpeg3_seek_percentage( file, 0.99 ); |
73 | printf("res: %i\n", res ); | 81 | printf("res: %i\n", res ); |
74 | mpeg3video_seek( file->vtrack[stream]->video ); | 82 | mpeg3video_seek( file->vtrack[stream]->video ); |
75 | frames = mpeg3_get_frame( file, stream ); | 83 | frames = mpeg3_get_frame( file, stream ); |
76 | mpeg3_seek_percentage( file, 0.0 ); | 84 | mpeg3_seek_percentage( file, 0.0 ); |
77 | } | 85 | } |
78 | return frames; | 86 | return frames; |
79 | } | 87 | } |
80 | return 0; | 88 | return 0; |
81 | } | 89 | } |
82 | */ | 90 | */ |
83 | bool videoSetFrame( long frame, int stream ) { return file ? mpeg3_set_frame( file, frame, stream) == 1 : FALSE; } | 91 | bool videoSetFrame( long frame, int stream ) { return file ? mpeg3_set_frame( file, frame, stream) == 1 : FALSE; } |
84 | long videoGetFrame( int stream ) { return file ? mpeg3_get_frame( file, stream ) : 0; } | 92 | long videoGetFrame( int stream ) { return file ? mpeg3_get_frame( file, stream ) : 0; } |
85 | bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ); | 93 | bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ); |
86 | bool videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ); | 94 | bool videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ); |
87 | bool videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ); | 95 | bool videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ); |
88 | 96 | ||
89 | // Profiling | 97 | // Profiling |
90 | double getTime() { return file ? mpeg3_get_time( file ) : 0.0; } | 98 | double getTime() { return file ? mpeg3_get_time( file ) : 0.0; } |
91 | 99 | ||
92 | // Ignore if these aren't supported | 100 | // Ignore if these aren't supported |
93 | bool setSMP( int cpus ) { return file ? mpeg3_set_cpus( file, cpus ) == 1 : FALSE; } | 101 | bool setSMP( int cpus ) { return file ? mpeg3_set_cpus( file, cpus ) == 1 : FALSE; } |
94 | bool setMMX( bool useMMX ) { return file ? mpeg3_set_mmx( file, useMMX ) == 1 : FALSE; } | 102 | bool setMMX( bool useMMX ) { return file ? mpeg3_set_mmx( file, useMMX ) == 1 : FALSE; } |
95 | 103 | ||
96 | // Capabilities | 104 | // Capabilities |
97 | bool supportsAudio() { return TRUE; } | 105 | bool supportsAudio() { return TRUE; } |
98 | bool supportsVideo() { return TRUE; } | 106 | bool supportsVideo() { return TRUE; } |
99 | bool supportsYUV() { return TRUE; } | 107 | bool supportsYUV() { return TRUE; } |
100 | bool supportsMMX() { return TRUE; } | 108 | bool supportsMMX() { return TRUE; } |
101 | bool supportsSMP() { return TRUE; } | 109 | bool supportsSMP() { return TRUE; } |
102 | bool supportsStereo() { return TRUE; } | 110 | bool supportsStereo() { return TRUE; } |
103 | bool supportsScaling() { return TRUE; } | 111 | bool supportsScaling() { return TRUE; } |
104 | 112 | ||
113 | long getPlayTime() { return -1; } | ||
114 | |||
105 | private: | 115 | private: |
106 | mpeg3_t *file; | 116 | mpeg3_t *file; |
107 | QString strInfo; | 117 | QString strInfo; |
108 | 118 | ||
109 | }; | 119 | }; |
110 | 120 | ||
111 | 121 | ||
112 | #endif | 122 | #endif |
113 | 123 | ||
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h index 29ec6ba..89abf97 100644 --- a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h +++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h | |||
@@ -1,53 +1,54 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LIBMPEG3_PLUGIN_IMPL_H | 20 | #ifndef LIBMPEG3_PLUGIN_IMPL_H |
21 | #define LIBMPEG3_PLUGIN_IMPL_H | 21 | #define LIBMPEG3_PLUGIN_IMPL_H |
22 | 22 | ||
23 | 23 | ||
24 | //#include <qpe/mediaplayerplugininterface.h> | ||
24 | #include "../mediaplayerplugininterface.h" | 25 | #include "../mediaplayerplugininterface.h" |
25 | 26 | ||
26 | 27 | ||
27 | class LibMpeg3Plugin; | 28 | class LibMpeg3Plugin; |
28 | 29 | ||
29 | 30 | ||
30 | class LibMpeg3PluginImpl : public MediaPlayerPluginInterface | 31 | class LibMpeg3PluginImpl : public MediaPlayerPluginInterface |
31 | { | 32 | { |
32 | public: | 33 | public: |
33 | LibMpeg3PluginImpl(); | 34 | LibMpeg3PluginImpl(); |
34 | virtual ~LibMpeg3PluginImpl(); | 35 | virtual ~LibMpeg3PluginImpl(); |
35 | 36 | ||
36 | #ifndef QT_NO_COMPONENT | 37 | #ifndef QT_NO_COMPONENT |
37 | 38 | ||
38 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 39 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
39 | Q_REFCOUNT | 40 | Q_REFCOUNT |
40 | 41 | ||
41 | #endif | 42 | #endif |
42 | 43 | ||
43 | virtual MediaPlayerDecoder *decoder(); | 44 | virtual MediaPlayerDecoder *decoder(); |
44 | virtual MediaPlayerEncoder *encoder(); | 45 | virtual MediaPlayerEncoder *encoder(); |
45 | 46 | ||
46 | private: | 47 | private: |
47 | LibMpeg3Plugin *libmpeg3plugin; | 48 | LibMpeg3Plugin *libmpeg3plugin; |
48 | ulong ref; | 49 | ulong ref; |
49 | }; | 50 | }; |
50 | 51 | ||
51 | 52 | ||
52 | #endif | 53 | #endif |
53 | 54 | ||
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 6dfd057..859a67a 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp | |||
@@ -1,464 +1,468 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
20 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
23 | |||
21 | #ifdef Q_WS_QWS | 24 | #ifdef Q_WS_QWS |
22 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
23 | #endif | 26 | #endif |
24 | #include <stdio.h> | 27 | #include <stdio.h> |
25 | #include <stdlib.h> | 28 | #include <stdlib.h> |
26 | #include <string.h> | 29 | #include <string.h> |
27 | #include <pthread.h> | 30 | #include <pthread.h> |
28 | #include <errno.h> | 31 | #include <errno.h> |
29 | #include <unistd.h> | 32 | #include <unistd.h> |
30 | #include "loopcontrol.h" | 33 | #include "loopcontrol.h" |
31 | #include "videowidget.h" | 34 | #include "videowidget.h" |
32 | #include "audiodevice.h" | 35 | #include "audiodevice.h" |
33 | #include "mediaplayerplugininterface.h" | 36 | #include "mediaplayerplugininterface.h" |
34 | #include "mediaplayerstate.h" | 37 | #include "mediaplayerstate.h" |
35 | 38 | ||
36 | 39 | ||
37 | extern VideoWidget *videoUI; // now only needed to tell it to play a frame | 40 | extern VideoWidget *videoUI; // now only needed to tell it to play a frame |
38 | extern MediaPlayerState *mediaPlayerState; | 41 | extern MediaPlayerState *mediaPlayerState; |
39 | 42 | ||
40 | 43 | ||
41 | //#define DecodeLoopDebug(x) qDebug x | 44 | //#define DecodeLoopDebug(x) qDebug x |
42 | #define DecodeLoopDebug(x) | 45 | #define DecodeLoopDebug(x) |
43 | 46 | ||
44 | 47 | ||
45 | static char *audioBuffer = NULL; | 48 | static char *audioBuffer = NULL; |
46 | static AudioDevice *audioDevice = NULL; | 49 | static AudioDevice *audioDevice = NULL; |
47 | static bool disabledSuspendScreenSaver = FALSE; | 50 | static bool disabledSuspendScreenSaver = FALSE; |
48 | static bool previousSuspendMode = FALSE; | 51 | static bool previousSuspendMode = FALSE; |
49 | 52 | ||
50 | 53 | ||
51 | pthread_taudio_tid; | 54 | pthread_t audio_tid; |
52 | pthread_attr_t audio_attr; | 55 | pthread_attr_t audio_attr; |
53 | bool threadOkToGo = FALSE; | 56 | bool threadOkToGo = FALSE; |
54 | 57 | ||
55 | 58 | ||
56 | class Mutex { | 59 | class Mutex { |
57 | public: | 60 | public: |
58 | Mutex() { | 61 | Mutex() { |
59 | pthread_mutexattr_t attr; | 62 | pthread_mutexattr_t attr; |
60 | pthread_mutexattr_init( &attr ); | 63 | pthread_mutexattr_init( &attr ); |
61 | pthread_mutex_init( &mutex, &attr ); | 64 | pthread_mutex_init( &mutex, &attr ); |
62 | pthread_mutexattr_destroy( &attr ); | 65 | pthread_mutexattr_destroy( &attr ); |
63 | } | 66 | } |
64 | 67 | ||
65 | ~Mutex() { | 68 | ~Mutex() { |
66 | pthread_mutex_destroy( &mutex ); | 69 | pthread_mutex_destroy( &mutex ); |
67 | } | 70 | } |
68 | 71 | ||
69 | void lock() { | 72 | void lock() { |
70 | pthread_mutex_lock( &mutex ); | 73 | pthread_mutex_lock( &mutex ); |
71 | } | 74 | } |
72 | 75 | ||
73 | void unlock() { | 76 | void unlock() { |
74 | pthread_mutex_unlock( &mutex ); | 77 | pthread_mutex_unlock( &mutex ); |
75 | } | 78 | } |
76 | private: | 79 | private: |
77 | pthread_mutex_t mutex; | 80 | pthread_mutex_t mutex; |
78 | }; | 81 | }; |
79 | 82 | ||
80 | 83 | ||
81 | void *startAudioThread( void *ptr ) { | 84 | void *startAudioThread( void *ptr ) { |
82 | LoopControl *mpegView = (LoopControl *)ptr; | 85 | LoopControl *mpegView = (LoopControl *)ptr; |
83 | while ( TRUE ) { | 86 | while ( TRUE ) { |
84 | if ( threadOkToGo && mpegView->moreAudio ) | 87 | if ( threadOkToGo && mpegView->moreAudio ) |
85 | mpegView->startAudio(); | 88 | mpegView->startAudio(); |
86 | else | 89 | else |
87 | usleep( 10000 ); // Semi-buzy-wait till we are playing again | 90 | usleep( 10000 ); // Semi-buzy-wait till we are playing again |
88 | } | 91 | } |
89 | return 0; | 92 | return 0; |
90 | } | 93 | } |
91 | 94 | ||
92 | 95 | ||
93 | Mutex *audioMutex; | 96 | Mutex *audioMutex; |
94 | 97 | ||
95 | 98 | ||
96 | LoopControl::LoopControl( QObject *parent, const char *name ) | 99 | LoopControl::LoopControl( QObject *parent, const char *name ) |
97 | : QObject( parent, name ) { | 100 | : QObject( parent, name ) { |
98 | isMuted = FALSE; | 101 | isMuted = FALSE; |
99 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); | 102 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); |
100 | 103 | ||
101 | audioMutex = new Mutex; | 104 | audioMutex = new Mutex; |
102 | 105 | ||
103 | pthread_attr_init(&audio_attr); | 106 | pthread_attr_init(&audio_attr); |
104 | #define USE_REALTIME_AUDIO_THREAD | 107 | #define USE_REALTIME_AUDIO_THREAD |
105 | #ifdef USE_REALTIME_AUDIO_THREAD | 108 | #ifdef USE_REALTIME_AUDIO_THREAD |
106 | // Attempt to set it to real-time round robin | 109 | // Attempt to set it to real-time round robin |
107 | if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { | 110 | if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { |
108 | sched_param params; | 111 | sched_param params; |
109 | params.sched_priority = 50; | 112 | params.sched_priority = 50; |
110 | pthread_attr_setschedparam(&audio_attr,¶ms); | 113 | pthread_attr_setschedparam(&audio_attr,¶ms); |
111 | } else { | 114 | } else { |
112 | qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); | 115 | qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); |
113 | pthread_attr_destroy(&audio_attr); | 116 | pthread_attr_destroy(&audio_attr); |
114 | pthread_attr_init(&audio_attr); | 117 | pthread_attr_init(&audio_attr); |
115 | } | 118 | } |
116 | #endif | 119 | #endif |
117 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); | 120 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); |
118 | } | 121 | } |
119 | 122 | ||
120 | 123 | ||
121 | LoopControl::~LoopControl() { | 124 | LoopControl::~LoopControl() { |
122 | stop(); | 125 | stop(); |
123 | } | 126 | } |
124 | 127 | ||
125 | 128 | ||
126 | static long prev_frame = 0; | 129 | static long prev_frame = 0; |
127 | static int currentSample = 0; | 130 | static int currentSample = 0; |
128 | 131 | ||
129 | 132 | ||
130 | void LoopControl::timerEvent( QTimerEvent *te ) { | 133 | void LoopControl::timerEvent( QTimerEvent *te ) { |
131 | 134 | ||
132 | if ( te->timerId() == videoId ) | 135 | if ( te->timerId() == videoId ) |
133 | startVideo(); | 136 | startVideo(); |
134 | 137 | ||
135 | if ( te->timerId() == sliderId ) { | 138 | if ( te->timerId() == sliderId ) { |
136 | if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { | 139 | if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { |
137 | mediaPlayerState->updatePosition( audioSampleCounter ); | 140 | mediaPlayerState->updatePosition( audioSampleCounter ); |
138 | } else if ( hasVideoChannel && moreVideo ) { | 141 | } else if ( hasVideoChannel && moreVideo ) { |
139 | mediaPlayerState->updatePosition( current_frame ); | 142 | mediaPlayerState->updatePosition( current_frame ); |
140 | } | 143 | } |
141 | } | 144 | } |
142 | 145 | ||
143 | if ( !moreVideo && !moreAudio ) { | 146 | if ( !moreVideo && !moreAudio ) { |
144 | mediaPlayerState->setPlaying( FALSE ); | 147 | mediaPlayerState->setPlaying( FALSE ); |
145 | mediaPlayerState->setNext(); | 148 | mediaPlayerState->setNext(); |
146 | } | 149 | } |
147 | } | 150 | } |
148 | 151 | ||
149 | 152 | ||
150 | void LoopControl::setPosition( long pos ) { | 153 | void LoopControl::setPosition( long pos ) { |
151 | audioMutex->lock(); | 154 | audioMutex->lock(); |
152 | 155 | ||
153 | if ( hasVideoChannel && hasAudioChannel ) { | 156 | if ( hasVideoChannel && hasAudioChannel ) { |
154 | playtime.restart(); | 157 | playtime.restart(); |
155 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); | 158 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); |
156 | current_frame = pos + 1; | 159 | current_frame = pos + 1; |
157 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 160 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
158 | prev_frame = current_frame - 1; | 161 | prev_frame = current_frame - 1; |
159 | currentSample = (int)( (double)current_frame * freq / framerate ); | 162 | currentSample = (int)( (double)current_frame * freq / framerate ); |
160 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); | 163 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); |
161 | audioSampleCounter = currentSample - 1; | 164 | audioSampleCounter = currentSample - 1; |
162 | } else if ( hasVideoChannel ) { | 165 | } else if ( hasVideoChannel ) { |
163 | playtime.restart(); | 166 | playtime.restart(); |
164 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); | 167 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); |
165 | current_frame = pos + 1; | 168 | current_frame = pos + 1; |
166 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 169 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
167 | prev_frame = current_frame - 1; | 170 | prev_frame = current_frame - 1; |
168 | } else if ( hasAudioChannel ) { | 171 | } else if ( hasAudioChannel ) { |
169 | playtime.restart(); | 172 | playtime.restart(); |
170 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) ); | 173 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) ); |
171 | currentSample = pos + 1; | 174 | currentSample = pos + 1; |
172 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); | 175 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); |
173 | audioSampleCounter = currentSample - 1; | 176 | audioSampleCounter = currentSample - 1; |
174 | } | 177 | } |
175 | 178 | ||
176 | audioMutex->unlock(); | 179 | audioMutex->unlock(); |
177 | } | 180 | } |
178 | 181 | ||
179 | 182 | ||
180 | void LoopControl::startVideo() { | 183 | void LoopControl::startVideo() { |
181 | 184 | ||
182 | if ( moreVideo ) { | 185 | if ( moreVideo ) { |
183 | 186 | ||
184 | if ( mediaPlayerState->curDecoder() ) { | 187 | if ( mediaPlayerState->curDecoder() ) { |
185 | 188 | ||
186 | if ( hasAudioChannel && !isMuted ) { | 189 | if ( hasAudioChannel && !isMuted ) { |
187 | 190 | ||
188 | current_frame = long( playtime.elapsed() * framerate / 1000 ); | 191 | current_frame = long( playtime.elapsed() * framerate / 1000 ); |
189 | 192 | ||
190 | if ( prev_frame != -1 && current_frame <= prev_frame ) | 193 | if ( prev_frame != -1 && current_frame <= prev_frame ) |
191 | return; | 194 | return; |
192 | 195 | ||
193 | } else { | 196 | } else { |
194 | // Don't skip | 197 | // Don't skip |
195 | current_frame++; | 198 | current_frame++; |
196 | } | 199 | } |
197 | 200 | ||
198 | if ( prev_frame == -1 || current_frame > prev_frame ) { | 201 | if ( prev_frame == -1 || current_frame > prev_frame ) { |
199 | if ( current_frame > prev_frame + 1 ) { | 202 | if ( current_frame > prev_frame + 1 ) { |
200 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 203 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
201 | } | 204 | } |
202 | moreVideo = videoUI->playVideo(); | 205 | moreVideo = videoUI->playVideo(); |
203 | prev_frame = current_frame; | 206 | prev_frame = current_frame; |
204 | } | 207 | } |
205 | 208 | ||
206 | } else { | 209 | } else { |
207 | 210 | ||
208 | moreVideo = FALSE; | 211 | moreVideo = FALSE; |
209 | killTimer( videoId ); | 212 | killTimer( videoId ); |
210 | 213 | ||
211 | } | 214 | } |
212 | 215 | ||
213 | } | 216 | } |
214 | } | 217 | } |
215 | 218 | ||
216 | 219 | ||
217 | void LoopControl::startAudio() { | 220 | void LoopControl::startAudio() { |
218 | 221 | ||
219 | audioMutex->lock(); | 222 | audioMutex->lock(); |
220 | 223 | ||
221 | if ( moreAudio ) { | 224 | if ( moreAudio ) { |
222 | 225 | ||
223 | if ( !isMuted && mediaPlayerState->curDecoder() ) { | 226 | if ( !isMuted && mediaPlayerState->curDecoder() ) { |
224 | 227 | ||
225 | currentSample = audioSampleCounter + 1; | 228 | currentSample = audioSampleCounter + 1; |
226 | 229 | ||
227 | if ( currentSample != audioSampleCounter + 1 ) | 230 | if ( currentSample != audioSampleCounter + 1 ) |
228 | qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); | 231 | qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); |
229 | 232 | ||
230 | long samplesRead = 0; | 233 | long samplesRead = 0; |
231 | bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); | 234 | bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); |
232 | long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; | 235 | long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; |
233 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; | 236 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; |
234 | 237 | ||
235 | if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { | 238 | // if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 5000 ) ) { |
236 | usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); | 239 | // usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); |
237 | } else if ( sampleWaitTime <= -5000 ) { | 240 | // } |
238 | qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); | 241 | // else if ( sampleWaitTime <= -5000 ) { |
239 | //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); | 242 | // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); |
240 | currentSample = sampleWeShouldBeAt; | 243 | // //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); |
241 | } | 244 | // currentSample = sampleWeShouldBeAt; |
245 | // } | ||
242 | 246 | ||
243 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); | 247 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); |
244 | audioSampleCounter = currentSample + samplesRead - 1; | 248 | audioSampleCounter = currentSample + samplesRead - 1; |
245 | 249 | ||
246 | moreAudio = readOk && (audioSampleCounter <= total_audio_samples); | 250 | moreAudio = readOk && (audioSampleCounter <= total_audio_samples); |
247 | 251 | ||
248 | } else { | 252 | } else { |
249 | 253 | ||
250 | moreAudio = FALSE; | 254 | moreAudio = FALSE; |
251 | 255 | ||
252 | } | 256 | } |
253 | 257 | ||
254 | } | 258 | } |
255 | 259 | ||
256 | audioMutex->unlock(); | 260 | audioMutex->unlock(); |
257 | } | 261 | } |
258 | 262 | ||
259 | 263 | ||
260 | void LoopControl::killTimers() { | 264 | void LoopControl::killTimers() { |
261 | 265 | ||
262 | audioMutex->lock(); | 266 | audioMutex->lock(); |
263 | 267 | ||
264 | if ( hasVideoChannel ) | 268 | if ( hasVideoChannel ) |
265 | killTimer( videoId ); | 269 | killTimer( videoId ); |
266 | killTimer( sliderId ); | 270 | killTimer( sliderId ); |
267 | threadOkToGo = FALSE; | 271 | threadOkToGo = FALSE; |
268 | 272 | ||
269 | audioMutex->unlock(); | 273 | audioMutex->unlock(); |
270 | } | 274 | } |
271 | 275 | ||
272 | 276 | ||
273 | void LoopControl::startTimers() { | 277 | void LoopControl::startTimers() { |
274 | 278 | ||
275 | audioMutex->lock(); | 279 | audioMutex->lock(); |
276 | 280 | ||
277 | moreVideo = FALSE; | 281 | moreVideo = FALSE; |
278 | moreAudio = FALSE; | 282 | moreAudio = FALSE; |
279 | 283 | ||
280 | if ( hasVideoChannel ) { | 284 | if ( hasVideoChannel ) { |
281 | moreVideo = TRUE; | 285 | moreVideo = TRUE; |
282 | int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value | 286 | int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value |
283 | videoId = startTimer( mSecsBetweenFrames ); | 287 | videoId = startTimer( mSecsBetweenFrames ); |
284 | } | 288 | } |
285 | 289 | ||
286 | if ( hasAudioChannel ) { | 290 | if ( hasAudioChannel ) { |
287 | moreAudio = TRUE; | 291 | moreAudio = TRUE; |
288 | threadOkToGo = TRUE; | 292 | threadOkToGo = TRUE; |
289 | } | 293 | } |
290 | 294 | ||
291 | sliderId = startTimer( 300 ); // update slider every 1/3 second | 295 | sliderId = startTimer( 300 ); // update slider every 1/3 second |
292 | 296 | ||
293 | audioMutex->unlock(); | 297 | audioMutex->unlock(); |
294 | } | 298 | } |
295 | 299 | ||
296 | 300 | ||
297 | void LoopControl::setPaused( bool pause ) { | 301 | void LoopControl::setPaused( bool pause ) { |
298 | 302 | ||
299 | if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) | 303 | if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) |
300 | return; | 304 | return; |
301 | 305 | ||
302 | if ( pause ) { | 306 | if ( pause ) { |
303 | killTimers(); | 307 | killTimers(); |
304 | } else { | 308 | } else { |
305 | // Force an update of the position | 309 | // Force an update of the position |
306 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); | 310 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); |
307 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); | 311 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); |
308 | // Just like we never stopped | 312 | // Just like we never stopped |
309 | startTimers(); | 313 | startTimers(); |
310 | } | 314 | } |
311 | } | 315 | } |
312 | 316 | ||
313 | 317 | ||
314 | void LoopControl::stop( bool willPlayAgainShortly ) { | 318 | void LoopControl::stop( bool willPlayAgainShortly ) { |
315 | 319 | ||
316 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 320 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
317 | if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { | 321 | if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { |
318 | disabledSuspendScreenSaver = FALSE; | 322 | disabledSuspendScreenSaver = FALSE; |
319 | // Re-enable the suspend mode | 323 | // Re-enable the suspend mode |
320 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 324 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
321 | } | 325 | } |
322 | #endif | 326 | #endif |
323 | 327 | ||
324 | if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { | 328 | if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { |
325 | 329 | ||
326 | killTimers(); | 330 | killTimers(); |
327 | 331 | ||
328 | audioMutex->lock(); | 332 | audioMutex->lock(); |
329 | 333 | ||
330 | mediaPlayerState->curDecoder()->close(); | 334 | mediaPlayerState->curDecoder()->close(); |
331 | 335 | ||
332 | if ( audioDevice ) { | 336 | if ( audioDevice ) { |
333 | delete audioDevice; | 337 | delete audioDevice; |
334 | delete audioBuffer; | 338 | delete audioBuffer; |
335 | audioDevice = 0; | 339 | audioDevice = 0; |
336 | audioBuffer = 0; | 340 | audioBuffer = 0; |
337 | } | 341 | } |
338 | 342 | ||
339 | audioMutex->unlock(); | 343 | audioMutex->unlock(); |
340 | 344 | ||
341 | } | 345 | } |
342 | } | 346 | } |
343 | 347 | ||
344 | 348 | ||
345 | bool LoopControl::init( const QString& filename ) { | 349 | bool LoopControl::init( const QString& filename ) { |
346 | stop(); | 350 | stop(); |
347 | 351 | ||
348 | audioMutex->lock(); | 352 | audioMutex->lock(); |
349 | 353 | ||
350 | fileName = filename; | 354 | fileName = filename; |
351 | stream = 0; // only play stream 0 for now | 355 | stream = 0; // only play stream 0 for now |
352 | current_frame = total_video_frames = total_audio_samples = 0; | 356 | current_frame = total_video_frames = total_audio_samples = 0; |
353 | 357 | ||
354 | qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); | 358 | qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); |
355 | 359 | ||
356 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin | 360 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin |
357 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { | 361 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { |
358 | if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { | 362 | if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { |
359 | total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); | 363 | total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); |
360 | mediaPlayerState->libMpeg3Decoder()->close(); | 364 | mediaPlayerState->libMpeg3Decoder()->close(); |
361 | } | 365 | } |
362 | } | 366 | } |
363 | 367 | ||
364 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { | 368 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { |
365 | audioMutex->unlock(); | 369 | audioMutex->unlock(); |
366 | return FALSE; | 370 | return FALSE; |
367 | } | 371 | } |
368 | 372 | ||
369 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; | 373 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; |
370 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; | 374 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; |
371 | 375 | ||
372 | if ( hasAudioChannel ) { | 376 | if ( hasAudioChannel ) { |
373 | int astream = 0; | 377 | int astream = 0; |
374 | 378 | ||
375 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); | 379 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); |
376 | DecodeLoopDebug(( "channels = %d\n", channels )); | 380 | qDebug( "LC- channels = %d", channels ); |
377 | 381 | ||
378 | if ( !total_audio_samples ) | 382 | if ( !total_audio_samples ) |
379 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); | 383 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); |
380 | 384 | ||
381 | total_audio_samples += 1000; | 385 | // total_audio_samples += 1000; |
382 | 386 | ||
383 | mediaPlayerState->setLength( total_audio_samples ); | 387 | mediaPlayerState->setLength( total_audio_samples ); |
384 | 388 | ||
385 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); | 389 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); |
386 | DecodeLoopDebug(( "frequency = %d\n", freq )); | 390 | qDebug( "LC- frequency = %d", freq ); |
387 | 391 | ||
388 | audioSampleCounter = 0; | 392 | audioSampleCounter = 0; |
389 | 393 | ||
390 | static const int bytes_per_sample = 2; //16 bit | 394 | int bits_per_sample = mediaPlayerState->curDecoder()->audioBitsPerSample( astream); |
391 | 395 | ||
392 | audioDevice = new AudioDevice( freq, channels, bytes_per_sample ); | 396 | audioDevice = new AudioDevice( freq, channels, bits_per_sample); |
393 | audioBuffer = new char[ audioDevice->bufferSize() ]; | 397 | audioBuffer = new char[ audioDevice->bufferSize() ]; |
394 | channels = audioDevice->channels(); | 398 | channels = audioDevice->channels(); |
395 | 399 | ||
396 | //### must check which frequency is actually used. | 400 | //### must check which frequency is actually used. |
397 | static const int size = 1; | 401 | static const int size = 1; |
398 | short int buf[size]; | 402 | short int buf[size]; |
399 | long samplesRead = 0; | 403 | long samplesRead = 0; |
400 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); | 404 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); |
401 | } | 405 | } |
402 | 406 | ||
403 | if ( hasVideoChannel ) { | 407 | if ( hasVideoChannel ) { |
404 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); | 408 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); |
405 | 409 | ||
406 | mediaPlayerState->setLength( total_video_frames ); | 410 | mediaPlayerState->setLength( total_video_frames ); |
407 | 411 | ||
408 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); | 412 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); |
409 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); | 413 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); |
410 | 414 | ||
411 | if ( framerate <= 1.0 ) { | 415 | if ( framerate <= 1.0 ) { |
412 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); | 416 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); |
413 | framerate = 25; | 417 | framerate = 25; |
414 | } | 418 | } |
415 | 419 | ||
416 | if ( total_video_frames == 1 ) { | 420 | if ( total_video_frames == 1 ) { |
417 | DecodeLoopDebug(( "Cannot seek to frame" )); | 421 | DecodeLoopDebug(( "Cannot seek to frame" )); |
418 | } | 422 | } |
419 | 423 | ||
420 | } | 424 | } |
421 | 425 | ||
422 | current_frame = 0; | 426 | current_frame = 0; |
423 | prev_frame = -1; | 427 | prev_frame = -1; |
424 | 428 | ||
425 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); | 429 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); |
426 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); | 430 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); |
427 | 431 | ||
428 | audioMutex->unlock(); | 432 | audioMutex->unlock(); |
429 | 433 | ||
430 | return TRUE; | 434 | return TRUE; |
431 | } | 435 | } |
432 | 436 | ||
433 | 437 | ||
434 | void LoopControl::play() { | 438 | void LoopControl::play() { |
435 | 439 | ||
436 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 440 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
437 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { | 441 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { |
438 | disabledSuspendScreenSaver = TRUE; | 442 | disabledSuspendScreenSaver = TRUE; |
439 | previousSuspendMode = hasVideoChannel; | 443 | previousSuspendMode = hasVideoChannel; |
440 | // Stop the screen from blanking and power saving state | 444 | // Stop the screen from blanking and power saving state |
441 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | 445 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) |
442 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 446 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
443 | } | 447 | } |
444 | #endif | 448 | #endif |
445 | 449 | ||
446 | playtime.start(); | 450 | playtime.start(); |
447 | startTimers(); | 451 | startTimers(); |
448 | } | 452 | } |
449 | 453 | ||
450 | 454 | ||
451 | void LoopControl::setMute( bool on ) { | 455 | void LoopControl::setMute( bool on ) { |
452 | if ( on != isMuted ) { | 456 | if ( on != isMuted ) { |
453 | isMuted = on; | 457 | isMuted = on; |
454 | if ( !on ) { | 458 | if ( !on ) { |
455 | // Force an update of the position | 459 | // Force an update of the position |
456 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); | 460 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); |
457 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); | 461 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); |
458 | // Resume playing audio | 462 | // Resume playing audio |
459 | moreAudio = TRUE; | 463 | moreAudio = TRUE; |
460 | } | 464 | } |
461 | } | 465 | } |
462 | } | 466 | } |
463 | 467 | ||
464 | 468 | ||
diff --git a/core/multimedia/opieplayer/loopcontrol.h b/core/multimedia/opieplayer/loopcontrol.h index 967ee25..fc7d316 100644 --- a/core/multimedia/opieplayer/loopcontrol.h +++ b/core/multimedia/opieplayer/loopcontrol.h | |||
@@ -1,67 +1,69 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
20 | #ifndef MPEGVIEW_H | 22 | #ifndef MPEGVIEW_H |
21 | #define MPEGVIEW_H | 23 | #define MPEGVIEW_H |
22 | 24 | ||
23 | 25 | ||
24 | #include <qwidget.h> | 26 | #include <qwidget.h> |
25 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
26 | 28 | ||
27 | 29 | ||
28 | class LoopControl : public QObject { | 30 | class LoopControl : public QObject { |
29 | Q_OBJECT | 31 | Q_OBJECT |
30 | public: | 32 | public: |
31 | LoopControl( QObject *parent, const char *name ); | 33 | LoopControl( QObject *parent, const char *name ); |
32 | ~LoopControl(); | 34 | ~LoopControl(); |
33 | 35 | ||
34 | bool init( const QString& filename ); | 36 | bool init( const QString& filename ); |
35 | 37 | ||
36 | bool hasVideo() const { return hasVideoChannel; } | 38 | bool hasVideo() const { return hasVideoChannel; } |
37 | bool hasAudio() const { return hasAudioChannel; } | 39 | bool hasAudio() const { return hasAudioChannel; } |
38 | 40 | ||
39 | long totalPlaytime() { return (long)(hasVideoChannel ? total_video_frames / framerate : total_audio_samples / freq); } | 41 | long totalPlaytime() { return (long)(hasVideoChannel ? total_video_frames / framerate : total_audio_samples / freq); } |
40 | 42 | ||
41 | // These are public to run them from global functions needed to start threads | 43 | // These are public to run them from global functions needed to start threads |
42 | // Otherwise they would be private | 44 | // Otherwise they would be private |
43 | void startAudio(); | 45 | void startAudio(); |
44 | void startVideo(); | 46 | void startVideo(); |
45 | bool moreAudio; | 47 | bool moreAudio; |
46 | bool moreVideo; | 48 | bool moreVideo; |
47 | public slots: | 49 | public slots: |
48 | void play(); | 50 | void play(); |
49 | void stop( bool willPlayAgainShortly = FALSE ); | 51 | void stop( bool willPlayAgainShortly = FALSE ); |
50 | 52 | ||
51 | void setMute( bool ); | 53 | void setMute( bool ); |
52 | void setPaused( bool ); | 54 | void setPaused( bool ); |
53 | void setPosition( long ); | 55 | void setPosition( long ); |
54 | 56 | ||
55 | signals: | 57 | signals: |
56 | void positionChanged( long, long ); | 58 | void positionChanged( long, long ); |
57 | 59 | ||
58 | protected: | 60 | protected: |
59 | void timerEvent(QTimerEvent*); | 61 | void timerEvent(QTimerEvent*); |
60 | 62 | ||
61 | private: | 63 | private: |
62 | void startTimers(); | 64 | void startTimers(); |
63 | void killTimers(); | 65 | void killTimers(); |
64 | 66 | ||
65 | QTime playtime; | 67 | QTime playtime; |
66 | int videoId; | 68 | int videoId; |
67 | int sliderId; | 69 | int sliderId; |
diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.cpp b/core/multimedia/opieplayer/loopcontrol_threaded.cpp index 2ec4a48..2e49bb7 100644 --- a/core/multimedia/opieplayer/loopcontrol_threaded.cpp +++ b/core/multimedia/opieplayer/loopcontrol_threaded.cpp | |||
@@ -1,87 +1,87 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define _REENTRANT | 21 | #define _REENTRANT |
22 | 22 | ||
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qimage.h> | 24 | #include <qimage.h> |
25 | #include <qpainter.h> | 25 | #include <qpainter.h> |
26 | #ifdef Q_WS_QWS | 26 | #ifdef Q_WS_QWS |
27 | #include <qpe/qcopenvelope_qws.h> | 27 | #include <qpe/qcopenvelope_qws.h> |
28 | #endif | 28 | #endif |
29 | #include "mediaplayerplugininterface.h" | ||
29 | #include <stdio.h> | 30 | #include <stdio.h> |
30 | #include <stdlib.h> | 31 | #include <stdlib.h> |
31 | #include <string.h> | 32 | #include <string.h> |
32 | #include <time.h> | 33 | #include <time.h> |
33 | #include <unistd.h> | 34 | #include <unistd.h> |
34 | #include <pthread.h> | 35 | #include <pthread.h> |
35 | #include "loopcontrol.h" | 36 | #include "loopcontrol.h" |
36 | #include "audiodevice.h" | 37 | #include "audiodevice.h" |
37 | #include "videowidget.h" | 38 | #include "videowidget.h" |
38 | #include "audiowidget.h" | 39 | #include "audiowidget.h" |
39 | #include "mediaplayerplugininterface.h" | ||
40 | #include "mediaplayerstate.h" | 40 | #include "mediaplayerstate.h" |
41 | 41 | ||
42 | 42 | ||
43 | #if defined(QT_QWS_CUSTOM) || defined(QT_QWS_IPAQ) | 43 | #if defined(QT_QWS_CUSTOM) || defined(QT_QWS_IPAQ) |
44 | #define USE_REALTIME_AUDIO_THREAD | 44 | #define USE_REALTIME_AUDIO_THREAD |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | 47 | ||
48 | extern VideoWidget *videoUI; // now only needed to tell it to play a frame | 48 | extern VideoWidget *videoUI; // now only needed to tell it to play a frame |
49 | extern MediaPlayerState *mediaPlayerState; | 49 | extern MediaPlayerState *mediaPlayerState; |
50 | 50 | ||
51 | 51 | ||
52 | #define DecodeLoopDebug(x) qDebug x | 52 | #define DecodeLoopDebug(x) qDebug x |
53 | //#define DecodeLoopDebug(x) | 53 | //#define DecodeLoopDebug(x) |
54 | 54 | ||
55 | 55 | ||
56 | static char *audioBuffer = NULL; | 56 | static char *audioBuffer = NULL; |
57 | static AudioDevice *audioDevice = NULL; | 57 | static AudioDevice *audioDevice = NULL; |
58 | static bool disabledSuspendScreenSaver = FALSE; | 58 | static bool disabledSuspendScreenSaver = FALSE; |
59 | 59 | ||
60 | 60 | ||
61 | pthread_tvideo_tid; | 61 | pthread_tvideo_tid; |
62 | pthread_attr_t video_attr; | 62 | pthread_attr_t video_attr; |
63 | pthread_taudio_tid; | 63 | pthread_taudio_tid; |
64 | pthread_attr_t audio_attr; | 64 | pthread_attr_t audio_attr; |
65 | 65 | ||
66 | 66 | ||
67 | bool emitPlayFinished = FALSE; | 67 | bool emitPlayFinished = FALSE; |
68 | bool emitChangePos = FALSE; | 68 | bool emitChangePos = FALSE; |
69 | 69 | ||
70 | 70 | ||
71 | class Mutex { | 71 | class Mutex { |
72 | public: | 72 | public: |
73 | Mutex() { | 73 | Mutex() { |
74 | pthread_mutexattr_t attr; | 74 | pthread_mutexattr_t attr; |
75 | pthread_mutexattr_init( &attr ); | 75 | pthread_mutexattr_init( &attr ); |
76 | pthread_mutex_init( &mutex, &attr ); | 76 | pthread_mutex_init( &mutex, &attr ); |
77 | pthread_mutexattr_destroy( &attr ); | 77 | pthread_mutexattr_destroy( &attr ); |
78 | } | 78 | } |
79 | 79 | ||
80 | ~Mutex() { | 80 | ~Mutex() { |
81 | pthread_mutex_destroy( &mutex ); | 81 | pthread_mutex_destroy( &mutex ); |
82 | } | 82 | } |
83 | 83 | ||
84 | void lock() { | 84 | void lock() { |
85 | pthread_mutex_lock( &mutex ); | 85 | pthread_mutex_lock( &mutex ); |
86 | } | 86 | } |
87 | 87 | ||
diff --git a/core/multimedia/opieplayer/main.cpp b/core/multimedia/opieplayer/main.cpp index 5246e40..9f7ef73 100644 --- a/core/multimedia/opieplayer/main.cpp +++ b/core/multimedia/opieplayer/main.cpp | |||
@@ -3,55 +3,55 @@ | |||
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include "mediaplayerstate.h" | 21 | #include "mediaplayerstate.h" |
22 | #include "playlistwidget.h" | 22 | #include "playlistwidget.h" |
23 | #include "audiowidget.h" | 23 | #include "audiowidget.h" |
24 | #include "videowidget.h" | 24 | #include "videowidget.h" |
25 | #include "loopcontrol.h" | 25 | #include "loopcontrol.h" |
26 | #include "mediaplayer.h" | 26 | #include "mediaplayer.h" |
27 | 27 | ||
28 | 28 | ||
29 | MediaPlayerState *mediaPlayerState; | 29 | MediaPlayerState *mediaPlayerState; |
30 | PlayListWidget *playList; | 30 | PlayListWidget *playList; |
31 | AudioWidget *audioUI; | 31 | AudioWidget *audioUI; |
32 | VideoWidget *videoUI; | 32 | VideoWidget *videoUI; |
33 | LoopControl *loopControl; | 33 | LoopControl *loopControl; |
34 | 34 | ||
35 | 35 | ||
36 | int main(int argc, char **argv) { | 36 | int main(int argc, char **argv) { |
37 | QPEApplication a(argc,argv); | 37 | QPEApplication a(argc,argv); |
38 | 38 | ||
39 | MediaPlayerState st( 0, "mediaPlayerState" ); | 39 | MediaPlayerState st( 0, "mediaPlayerState" ); |
40 | mediaPlayerState = &st; | 40 | mediaPlayerState = &st; |
41 | PlayListWidget pl( 0, "playList" ); | 41 | PlayListWidget pl( 0, "playList" ); |
42 | playList = &pl; | 42 | playList = &pl; |
43 | AudioWidget aw( 0, "audioUI" ); | 43 | AudioWidget aw( 0, "audioUI" ); |
44 | audioUI = &aw; | 44 | audioUI = &aw; |
45 | VideoWidget vw( 0, "videoUI" ); | 45 | VideoWidget vw( 0, "videoUI" ); |
46 | videoUI = &vw; | 46 | videoUI = &vw; |
47 | LoopControl lc( 0, "loopControl" ); | 47 | LoopControl lc( 0, "loopControl" ); |
48 | loopControl = &lc; | 48 | loopControl = &lc; |
49 | MediaPlayer mp( 0, "mediaPlayer" ); | 49 | MediaPlayer mp( 0, "mediaPlayer" ); |
50 | 50 | ||
51 | pl.setCaption( MediaPlayer::tr("Media Player") ); | 51 | pl.setCaption( MediaPlayer::tr("Opie Player") ); |
52 | a.showMainDocumentWidget(&pl); | 52 | a.showMainDocumentWidget(&pl); |
53 | 53 | ||
54 | return a.exec(); | 54 | return a.exec(); |
55 | } | 55 | } |
56 | 56 | ||
57 | 57 | ||
diff --git a/core/multimedia/opieplayer/mediaplayerplugininterface.h b/core/multimedia/opieplayer/mediaplayerplugininterface.h index 24d5a80..339b2e4 100644 --- a/core/multimedia/opieplayer/mediaplayerplugininterface.h +++ b/core/multimedia/opieplayer/mediaplayerplugininterface.h | |||
@@ -16,98 +16,96 @@ | |||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef MEDIA_PLAYER_PLUGIN_INTERFACE_H | 20 | #ifndef MEDIA_PLAYER_PLUGIN_INTERFACE_H |
21 | #define MEDIA_PLAYER_PLUGIN_INTERFACE_H | 21 | #define MEDIA_PLAYER_PLUGIN_INTERFACE_H |
22 | 22 | ||
23 | #include <qpe/qcom.h> | 23 | #include <qpe/qcom.h> |
24 | 24 | ||
25 | #ifndef QT_NO_COMPONENT | 25 | #ifndef QT_NO_COMPONENT |
26 | // {c0093632-b44c-4cf7-a279-d82fe8a8890c} | 26 | // {c0093632-b44c-4cf7-a279-d82fe8a8890c} |
27 | # ifndef IID_MediaPlayerPlugin | 27 | # ifndef IID_MediaPlayerPlugin |
28 | # define IID_MediaPlayerPlugin QUuid( 0xc0093632, 0xb44c, 0x4cf7, 0xa2, 0x79, 0xd8, 0x2f, 0xe8, 0xa8, 0x89, 0x0c ) | 28 | # define IID_MediaPlayerPlugin QUuid( 0xc0093632, 0xb44c, 0x4cf7, 0xa2, 0x79, 0xd8, 0x2f, 0xe8, 0xa8, 0x89, 0x0c ) |
29 | # endif | 29 | # endif |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | 32 | ||
33 | enum ColorFormat { | 33 | enum ColorFormat { |
34 | RGB565, | 34 | RGB565, |
35 | BGR565, | 35 | BGR565, |
36 | RGBA8888, | 36 | RGBA8888, |
37 | BGRA8888 | 37 | BGRA8888 |
38 | }; | 38 | }; |
39 | 39 | ||
40 | 40 | ||
41 | class MediaPlayerDecoder { | 41 | class MediaPlayerDecoder { |
42 | 42 | ||
43 | public: | 43 | public: |
44 | virtual ~MediaPlayerDecoder() { }; | 44 | virtual ~MediaPlayerDecoder() { }; |
45 | 45 | ||
46 | // About Plugin | 46 | // About Plugin |
47 | virtual const char *pluginName() = 0; | 47 | virtual const char *pluginName() = 0; |
48 | virtual const char *pluginComment() = 0; | 48 | virtual const char *pluginComment() = 0; |
49 | virtual double pluginVersion() = 0; | 49 | virtual double pluginVersion() = 0; |
50 | 50 | ||
51 | virtual bool isFileSupported( const QString& file ) = 0; | 51 | virtual bool isFileSupported( const QString& file ) = 0; |
52 | virtual bool open( const QString& file ) = 0; | 52 | virtual bool open( const QString& file ) = 0; |
53 | virtual bool close() = 0; | 53 | virtual bool close() = 0; |
54 | virtual bool isOpen() = 0; | 54 | virtual bool isOpen() = 0; |
55 | virtual const QString &fileInfo() = 0; | 55 | virtual const QString &fileInfo() = 0; |
56 | 56 | ||
57 | // If decoder doesn't support audio then return 0 here | 57 | // If decoder doesn't support audio then return 0 here |
58 | virtual int audioStreams() = 0; | 58 | virtual int audioStreams() = 0; |
59 | virtual int audioChannels( int stream ) = 0; | 59 | virtual int audioChannels( int stream ) = 0; |
60 | virtual int audioFrequency( int stream ) = 0; | 60 | virtual int audioFrequency( int stream ) = 0; |
61 | virtual int audioSamples( int stream ) = 0; | 61 | virtual int audioSamples( int stream ) = 0; |
62 | virtual bool audioSetSample( long sample, int stream ) = 0; | 62 | virtual bool audioSetSample( long sample, int stream ) = 0; |
63 | virtual long audioGetSample( int stream ) = 0; | 63 | virtual long audioGetSample( int stream ) = 0; |
64 | // virtual bool audioReadMonoSamples( short *samples, long samples, long& samplesRead, int stream ) = 0; | ||
65 | // virtual bool audioReadStereoSamples( short *samples, long samples, long& samplesRead, int stream ) = 0; | ||
66 | virtual bool audioReadSamples( short *samples, int channels, long samples, long& samplesRead, int stream ) = 0; | 64 | virtual bool audioReadSamples( short *samples, int channels, long samples, long& samplesRead, int stream ) = 0; |
67 | // Libmpeg3 functions, perhaps good for reading an audio file with 5 channels or something! | ||
68 | // virtual bool audioReadSamples( short *samples, int channel, long samples, int stream ) = 0; | ||
69 | // virtual bool audioReReadSamples( short *samples, int channel, long samples, int stream ) = 0; | ||
70 | 65 | ||
71 | // If decoder doesn't support video then return 0 here | 66 | // If decoder doesn't support video then return 0 here |
72 | virtual int videoStreams() = 0; | 67 | virtual int videoStreams() = 0; |
73 | virtual int videoWidth( int stream ) = 0; | 68 | virtual int videoWidth( int stream ) = 0; |
74 | virtual int videoHeight( int stream ) = 0; | 69 | virtual int videoHeight( int stream ) = 0; |
75 | virtual double videoFrameRate( int stream ) = 0; // frames per second (this may change to frames/1000secs) | 70 | virtual double videoFrameRate( int stream ) = 0; // frames per second (this may change to frames/1000secs) |
76 | virtual int videoFrames( int stream ) = 0; | 71 | virtual int videoFrames( int stream ) = 0; |
77 | virtual bool videoSetFrame( long sample, int stream ) = 0; | 72 | virtual bool videoSetFrame( long sample, int stream ) = 0; |
78 | virtual long videoGetFrame( int stream ) = 0; | 73 | virtual long videoGetFrame( int stream ) = 0; |
79 | virtual bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) = 0; | 74 | virtual bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) = 0; |
80 | virtual bool videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ) = 0; | 75 | virtual bool videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ) = 0; |
81 | virtual bool videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ) = 0; | 76 | virtual bool videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ) = 0; |
82 | 77 | ||
83 | // Profiling | 78 | // Profiling |
84 | virtual double getTime() = 0; | 79 | virtual double getTime() = 0; |
85 | 80 | ||
86 | // Ignore if these aren't supported | 81 | // Ignore if these aren't supported |
87 | virtual bool setSMP( int cpus ) = 0; | 82 | virtual bool setSMP( int cpus ) = 0; |
88 | virtual bool setMMX( bool useMMX ) = 0; | 83 | virtual bool setMMX( bool useMMX ) = 0; |
89 | 84 | ||
90 | // Capabilities | 85 | // Capabilities |
91 | virtual bool supportsAudio() = 0; | 86 | virtual bool supportsAudio() = 0; |
92 | virtual bool supportsVideo() = 0; | 87 | virtual bool supportsVideo() = 0; |
93 | virtual bool supportsYUV() = 0; | 88 | virtual bool supportsYUV() = 0; |
94 | virtual bool supportsMMX() = 0; | 89 | virtual bool supportsMMX() = 0; |
95 | virtual bool supportsSMP() = 0; | 90 | virtual bool supportsSMP() = 0; |
96 | virtual bool supportsStereo() = 0; | 91 | virtual bool supportsStereo() = 0; |
97 | virtual bool supportsScaling() = 0; | 92 | virtual bool supportsScaling() = 0; |
98 | 93 | ||
94 | // File Properies | ||
95 | virtual long getPlayTime() { return -1; } | ||
96 | virtual int audioBitsPerSample( int stream ) = 0; | ||
99 | }; | 97 | }; |
100 | 98 | ||
101 | 99 | ||
102 | class MediaPlayerEncoder; | 100 | class MediaPlayerEncoder; |
103 | 101 | ||
104 | 102 | ||
105 | struct MediaPlayerPluginInterface : public QUnknownInterface | 103 | struct MediaPlayerPluginInterface : public QUnknownInterface |
106 | { | 104 | { |
107 | virtual MediaPlayerDecoder *decoder() = 0; | 105 | virtual MediaPlayerDecoder *decoder() = 0; |
108 | virtual MediaPlayerEncoder *encoder() = 0; | 106 | virtual MediaPlayerEncoder *encoder() = 0; |
109 | }; | 107 | }; |
110 | 108 | ||
111 | 109 | ||
112 | #endif | 110 | #endif |
113 | 111 | ||
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp index 9b9d133..2a6bca3 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.cpp +++ b/core/multimedia/opieplayer/mediaplayerstate.cpp | |||
@@ -1,185 +1,191 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/qlibrary.h> | 21 | #include <qpe/qlibrary.h> |
22 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
23 | #include <qvaluelist.h> | 23 | #include <qvaluelist.h> |
24 | #include <qobject.h> | 24 | #include <qobject.h> |
25 | #include <qdir.h> | 25 | #include <qdir.h> |
26 | #include "mediaplayerplugininterface.h" | 26 | #include "mediaplayerplugininterface.h" |
27 | #include "mediaplayerstate.h" | 27 | #include "mediaplayerstate.h" |
28 | 28 | ||
29 | |||
30 | |||
29 | #ifdef QT_NO_COMPONENT | 31 | #ifdef QT_NO_COMPONENT |
30 | // Plugins which are compiled in when no plugin architecture available | 32 | // Plugins which are compiled in when no plugin architecture available |
31 | #include "libmad/libmadpluginimpl.h" | 33 | #include "libmad/libmadpluginimpl.h" |
32 | #include "libmpeg3/libmpeg3pluginimpl.h" | 34 | #include "libmpeg3/libmpeg3pluginimpl.h" |
33 | #include "wavplugin/wavpluginimpl.h" | 35 | #include "wavplugin/wavpluginimpl.h" |
34 | #endif | 36 | #endif |
35 | 37 | ||
36 | 38 | ||
37 | //#define MediaPlayerDebug(x)qDebug x | 39 | //#define MediaPlayerDebug(x) qDebug x |
38 | #define MediaPlayerDebug(x) | 40 | #define MediaPlayerDebug(x) |
39 | 41 | ||
40 | 42 | ||
41 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 43 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) |
42 | : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { | 44 | : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { |
43 | Config cfg( "MediaPlayer" ); | 45 | Config cfg( "MediaPlayer" ); |
44 | readConfig( cfg ); | 46 | readConfig( cfg ); |
45 | loadPlugins(); | 47 | loadPlugins(); |
46 | } | 48 | } |
47 | 49 | ||
48 | 50 | ||
49 | MediaPlayerState::~MediaPlayerState() { | 51 | MediaPlayerState::~MediaPlayerState() { |
50 | Config cfg( "MediaPlayer" ); | 52 | Config cfg( "MediaPlayer" ); |
51 | writeConfig( cfg ); | 53 | writeConfig( cfg ); |
52 | } | 54 | } |
53 | 55 | ||
54 | 56 | ||
55 | void MediaPlayerState::readConfig( Config& cfg ) { | 57 | void MediaPlayerState::readConfig( Config& cfg ) { |
56 | cfg.setGroup("Options"); | 58 | cfg.setGroup("Options"); |
57 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); | 59 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); |
58 | isScaled = cfg.readBoolEntry( "Scaling" ); | 60 | isScaled = cfg.readBoolEntry( "Scaling" ); |
59 | isLooping = cfg.readBoolEntry( "Looping" ); | 61 | isLooping = cfg.readBoolEntry( "Looping" ); |
60 | isShuffled = cfg.readBoolEntry( "Shuffle" ); | 62 | isShuffled = cfg.readBoolEntry( "Shuffle" ); |
61 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); | 63 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); |
62 | isPlaying = FALSE; | 64 | isPlaying = FALSE; |
63 | isPaused = FALSE; | 65 | isPaused = FALSE; |
64 | curPosition = 0; | 66 | curPosition = 0; |
65 | curLength = 0; | 67 | curLength = 0; |
66 | curView = 'l'; | 68 | curView = 'l'; |
67 | } | 69 | } |
68 | 70 | ||
69 | 71 | ||
70 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 72 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
71 | cfg.setGroup("Options"); | 73 | cfg.setGroup("Options"); |
72 | cfg.writeEntry("FullScreen", isFullscreen ); | 74 | cfg.writeEntry("FullScreen", isFullscreen ); |
73 | cfg.writeEntry("Scaling", isScaled ); | 75 | cfg.writeEntry("Scaling", isScaled ); |
74 | cfg.writeEntry("Looping", isLooping ); | 76 | cfg.writeEntry("Looping", isLooping ); |
75 | cfg.writeEntry("Shuffle", isShuffled ); | 77 | cfg.writeEntry("Shuffle", isShuffled ); |
76 | cfg.writeEntry("UsePlayList", usePlaylist ); | 78 | cfg.writeEntry("UsePlayList", usePlaylist ); |
77 | } | 79 | } |
78 | 80 | ||
79 | 81 | ||
80 | struct MediaPlayerPlugin { | 82 | struct MediaPlayerPlugin { |
81 | #ifndef QT_NO_COMPONENT | 83 | #ifndef QT_NO_COMPONENT |
82 | QLibrary *library; | 84 | QLibrary *library; |
83 | #endif | 85 | #endif |
84 | MediaPlayerPluginInterface *iface; | 86 | MediaPlayerPluginInterface *iface; |
85 | MediaPlayerDecoder *decoder; | 87 | MediaPlayerDecoder *decoder; |
86 | MediaPlayerEncoder *encoder; | 88 | MediaPlayerEncoder *encoder; |
87 | }; | 89 | }; |
88 | 90 | ||
89 | 91 | ||
90 | static QValueList<MediaPlayerPlugin> pluginList; | 92 | static QValueList<MediaPlayerPlugin> pluginList; |
91 | 93 | ||
92 | 94 | ||
93 | // Find the first decoder which supports this type of file | 95 | // Find the first decoder which supports this type of file |
94 | MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { | 96 | MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { |
95 | MediaPlayerDecoder *tmpDecoder = NULL; | 97 | MediaPlayerDecoder *tmpDecoder = NULL; |
96 | QValueList<MediaPlayerPlugin>::Iterator it; | 98 | QValueList<MediaPlayerPlugin>::Iterator it; |
97 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { | 99 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { |
98 | if ( (*it).decoder->isFileSupported( file ) ) { | 100 | if ( (*it).decoder->isFileSupported( file ) ) { |
99 | tmpDecoder = (*it).decoder; | 101 | tmpDecoder = (*it).decoder; |
100 | break; | 102 | break; |
101 | } | 103 | } |
102 | } | 104 | } |
103 | return decoder = tmpDecoder; | 105 | return decoder = tmpDecoder; |
104 | } | 106 | } |
105 | 107 | ||
106 | 108 | ||
107 | MediaPlayerDecoder *MediaPlayerState::curDecoder() { | 109 | MediaPlayerDecoder *MediaPlayerState::curDecoder() { |
108 | return decoder; | 110 | return decoder; |
109 | } | 111 | } |
110 | 112 | ||
111 | 113 | ||
112 | // ### hack to get true sample count | 114 | // ### hack to get true sample count |
113 | MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { | 115 | MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { |
114 | return libmpeg3decoder; | 116 | return libmpeg3decoder; |
115 | } | 117 | } |
116 | 118 | ||
119 | // ### hack to get true sample count | ||
120 | // MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { | ||
121 | // return libwavdecoder; | ||
122 | // } | ||
117 | 123 | ||
118 | void MediaPlayerState::loadPlugins() { | 124 | void MediaPlayerState::loadPlugins() { |
119 | 125 | ||
120 | #ifndef QT_NO_COMPONENT | 126 | #ifndef QT_NO_COMPONENT |
121 | QValueList<MediaPlayerPlugin>::Iterator mit; | 127 | QValueList<MediaPlayerPlugin>::Iterator mit; |
122 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { | 128 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { |
123 | (*mit).iface->release(); | 129 | (*mit).iface->release(); |
124 | (*mit).library->unload(); | 130 | (*mit).library->unload(); |
125 | delete (*mit).library; | 131 | delete (*mit).library; |
126 | } | 132 | } |
127 | pluginList.clear(); | 133 | pluginList.clear(); |
128 | 134 | ||
129 | QString path = QPEApplication::qpeDir() + "/plugins/codecs"; | 135 | QString path = QPEApplication::qpeDir() + "/plugins/codecs"; |
130 | QDir dir( path, "lib*.so" ); | 136 | QDir dir( path, "lib*.so" ); |
131 | QStringList list = dir.entryList(); | 137 | QStringList list = dir.entryList(); |
132 | QStringList::Iterator it; | 138 | QStringList::Iterator it; |
133 | for ( it = list.begin(); it != list.end(); ++it ) { | 139 | for ( it = list.begin(); it != list.end(); ++it ) { |
134 | MediaPlayerPluginInterface *iface = 0; | 140 | MediaPlayerPluginInterface *iface = 0; |
135 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 141 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
136 | 142 | ||
137 | MediaPlayerDebug(( "querying: %s", QString( path + "/" + *it ).latin1() )); | 143 | MediaPlayerDebug(( "querying: %s", QString( path + "/" + *it ).latin1() )); |
138 | 144 | ||
139 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { | 145 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { |
140 | 146 | ||
141 | MediaPlayerDebug(( "loading: %s", QString( path + "/" + *it ).latin1() )); | 147 | MediaPlayerDebug(( "loading: %s", QString( path + "/" + *it ).latin1() )); |
142 | 148 | ||
143 | MediaPlayerPlugin plugin; | 149 | MediaPlayerPlugin plugin; |
144 | plugin.library = lib; | 150 | plugin.library = lib; |
145 | plugin.iface = iface; | 151 | plugin.iface = iface; |
146 | plugin.decoder = plugin.iface->decoder(); | 152 | plugin.decoder = plugin.iface->decoder(); |
147 | plugin.encoder = plugin.iface->encoder(); | 153 | plugin.encoder = plugin.iface->encoder(); |
148 | pluginList.append( plugin ); | 154 | pluginList.append( plugin ); |
149 | 155 | ||
150 | // ### hack to get true sample count | 156 | // ### hack to get true sample count |
151 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) | 157 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) |
152 | libmpeg3decoder = plugin.decoder; | 158 | libmpeg3decoder = plugin.decoder; |
153 | 159 | ||
154 | } else { | 160 | } else { |
155 | delete lib; | 161 | delete lib; |
156 | } | 162 | } |
157 | } | 163 | } |
158 | #else | 164 | #else |
159 | pluginList.clear(); | 165 | pluginList.clear(); |
160 | 166 | ||
161 | MediaPlayerPlugin plugin0; | 167 | MediaPlayerPlugin plugin0; |
162 | plugin0.iface = new LibMpeg3PluginImpl; | 168 | plugin0.iface = new LibMpeg3PluginImpl; |
163 | plugin0.decoder = plugin0.iface->decoder(); | 169 | plugin0.decoder = plugin0.iface->decoder(); |
164 | plugin0.encoder = plugin0.iface->encoder(); | 170 | plugin0.encoder = plugin0.iface->encoder(); |
165 | pluginList.append( plugin0 ); | 171 | pluginList.append( plugin0 ); |
166 | 172 | ||
167 | MediaPlayerPlugin plugin1; | 173 | MediaPlayerPlugin plugin1; |
168 | plugin1.iface = new LibMadPluginImpl; | 174 | plugin1.iface = new LibMadPluginImpl; |
169 | plugin1.decoder = plugin1.iface->decoder(); | 175 | plugin1.decoder = plugin1.iface->decoder(); |
170 | plugin1.encoder = plugin1.iface->encoder(); | 176 | plugin1.encoder = plugin1.iface->encoder(); |
171 | pluginList.append( plugin1 ); | 177 | pluginList.append( plugin1 ); |
172 | 178 | ||
173 | MediaPlayerPlugin plugin2; | 179 | MediaPlayerPlugin plugin2; |
174 | plugin2.iface = new WavPluginImpl; | 180 | plugin2.iface = new WavPluginImpl; |
175 | plugin2.decoder = plugin2.iface->decoder(); | 181 | plugin2.decoder = plugin2.iface->decoder(); |
176 | plugin2.encoder = plugin2.iface->encoder(); | 182 | plugin2.encoder = plugin2.iface->encoder(); |
177 | pluginList.append( plugin2 ); | 183 | pluginList.append( plugin2 ); |
178 | #endif | 184 | #endif |
179 | 185 | ||
180 | if ( pluginList.count() ) | 186 | if ( pluginList.count() ) |
181 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); | 187 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); |
182 | else | 188 | else |
183 | MediaPlayerDebug(( "No decoders found" )); | 189 | MediaPlayerDebug(( "No decoders found" )); |
184 | } | 190 | } |
185 | 191 | ||
diff --git a/core/multimedia/opieplayer/mediaplayerstate.h b/core/multimedia/opieplayer/mediaplayerstate.h index 5d95b92..1a23742 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.h +++ b/core/multimedia/opieplayer/mediaplayerstate.h | |||
@@ -1,117 +1,118 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef MEDIA_PLAYER_STATE_H | 20 | #ifndef MEDIA_PLAYER_STATE_H |
21 | #define MEDIA_PLAYER_STATE_H | 21 | #define MEDIA_PLAYER_STATE_H |
22 | 22 | ||
23 | 23 | ||
24 | #include <qobject.h> | 24 | #include <qobject.h> |
25 | 25 | ||
26 | 26 | ||
27 | class MediaPlayerDecoder; | 27 | class MediaPlayerDecoder; |
28 | class Config; | 28 | class Config; |
29 | 29 | ||
30 | 30 | ||
31 | class MediaPlayerState : public QObject { | 31 | class MediaPlayerState : public QObject { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | public: | 33 | public: |
34 | MediaPlayerState( QObject *parent, const char *name ); | 34 | MediaPlayerState( QObject *parent, const char *name ); |
35 | ~MediaPlayerState(); | 35 | ~MediaPlayerState(); |
36 | 36 | ||
37 | bool fullscreen() { return isFullscreen; } | 37 | bool fullscreen() { return isFullscreen; } |
38 | bool scaled() { return isScaled; } | 38 | bool scaled() { return isScaled; } |
39 | bool looping() { return isLooping; } | 39 | bool looping() { return isLooping; } |
40 | bool shuffled() { return isShuffled; } | 40 | bool shuffled() { return isShuffled; } |
41 | bool playlist() { return usePlaylist; } | 41 | bool playlist() { return usePlaylist; } |
42 | bool paused() { return isPaused; } | 42 | bool paused() { return isPaused; } |
43 | bool playing() { return isPlaying; } | 43 | bool playing() { return isPlaying; } |
44 | long position() { return curPosition; } | 44 | long position() { return curPosition; } |
45 | long length() { return curLength; } | 45 | long length() { return curLength; } |
46 | char view() { return curView; } | 46 | char view() { return curView; } |
47 | 47 | ||
48 | MediaPlayerDecoder *newDecoder( const QString& file ); | 48 | MediaPlayerDecoder *newDecoder( const QString& file ); |
49 | MediaPlayerDecoder *curDecoder(); | 49 | MediaPlayerDecoder *curDecoder(); |
50 | MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the | 50 | MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the |
51 | // number of audio samples if we are using the libmad plugin | 51 | // number of audio samples if we are using the libmad plugin |
52 | public slots: | 52 | public slots: |
53 | void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } | 53 | void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } |
54 | void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } | 54 | void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } |
55 | void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } | 55 | void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } |
56 | void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } | 56 | void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } |
57 | void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } | 57 | void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } |
58 | void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } | 58 | void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } |
59 | void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } | 59 | void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } |
60 | void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } | 60 | void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } |
61 | void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } | 61 | void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } |
62 | void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } | 62 | void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } |
63 | void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } | 63 | void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } |
64 | 64 | ||
65 | void setPrev() { emit prev(); } | 65 | void setPrev() { emit prev(); } |
66 | void setNext() { emit next(); } | 66 | void setNext() { emit next(); } |
67 | void setList() { setPlaying( FALSE ); setView('l'); } | 67 | void setList() { setPlaying( FALSE ); setView('l'); } |
68 | void setVideo() { setView('v'); } | 68 | void setVideo() { setView('v'); } |
69 | void setAudio() { setView('a'); } | 69 | void setAudio() { setView('a'); } |
70 | 70 | ||
71 | void toggleFullscreen() { setFullscreen( !isFullscreen ); } | 71 | void toggleFullscreen() { setFullscreen( !isFullscreen ); } |
72 | void toggleScaled() { setScaled( !isScaled); } | 72 | void toggleScaled() { setScaled( !isScaled); } |
73 | void toggleLooping() { setLooping( !isLooping); } | 73 | void toggleLooping() { setLooping( !isLooping); } |
74 | void toggleShuffled() { setShuffled( !isShuffled); } | 74 | void toggleShuffled() { setShuffled( !isShuffled); } |
75 | void togglePlaylist() { setPlaylist( !usePlaylist); } | 75 | void togglePlaylist() { setPlaylist( !usePlaylist); } |
76 | void togglePaused() { setPaused( !isPaused); } | 76 | void togglePaused() { setPaused( !isPaused); } |
77 | void togglePlaying() { setPlaying( !isPlaying); } | 77 | void togglePlaying() { setPlaying( !isPlaying); } |
78 | 78 | ||
79 | signals: | 79 | signals: |
80 | void fullscreenToggled( bool ); | 80 | void fullscreenToggled( bool ); |
81 | void scaledToggled( bool ); | 81 | void scaledToggled( bool ); |
82 | void loopingToggled( bool ); | 82 | void loopingToggled( bool ); |
83 | void shuffledToggled( bool ); | 83 | void shuffledToggled( bool ); |
84 | void playlistToggled( bool ); | 84 | void playlistToggled( bool ); |
85 | void pausedToggled( bool ); | 85 | void pausedToggled( bool ); |
86 | void playingToggled( bool ); | 86 | void playingToggled( bool ); |
87 | void positionChanged( long ); // When the slider is moved | 87 | void positionChanged( long ); // When the slider is moved |
88 | void positionUpdated( long ); // When the media file progresses | 88 | void positionUpdated( long ); // When the media file progresses |
89 | void lengthChanged( long ); | 89 | void lengthChanged( long ); |
90 | void viewChanged( char ); | 90 | void viewChanged( char ); |
91 | 91 | ||
92 | void prev(); | 92 | void prev(); |
93 | void next(); | 93 | void next(); |
94 | 94 | ||
95 | private: | 95 | private: |
96 | bool isFullscreen; | 96 | bool isFullscreen; |
97 | bool isScaled; | 97 | bool isScaled; |
98 | bool isLooping; | 98 | bool isLooping; |
99 | bool isShuffled; | 99 | bool isShuffled; |
100 | bool usePlaylist; | 100 | bool usePlaylist; |
101 | bool isPaused; | 101 | bool isPaused; |
102 | bool isPlaying; | 102 | bool isPlaying; |
103 | long curPosition; | 103 | long curPosition; |
104 | long curLength; | 104 | long curLength; |
105 | char curView; | 105 | char curView; |
106 | 106 | ||
107 | MediaPlayerDecoder *decoder; | 107 | MediaPlayerDecoder *decoder; |
108 | MediaPlayerDecoder *libmpeg3decoder; | 108 | MediaPlayerDecoder *libmpeg3decoder; |
109 | // MediaPlayerDecoder *libwavdecoder; | ||
109 | 110 | ||
110 | void loadPlugins(); | 111 | void loadPlugins(); |
111 | void readConfig( Config& cfg ); | 112 | void readConfig( Config& cfg ); |
112 | void writeConfig( Config& cfg ) const; | 113 | void writeConfig( Config& cfg ) const; |
113 | }; | 114 | }; |
114 | 115 | ||
115 | 116 | ||
116 | #endif // MEDIA_PLAYER_STATE_H | 117 | #endif // MEDIA_PLAYER_STATE_H |
117 | 118 | ||
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index fbfb946..f17ab6f 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp | |||
@@ -1,179 +1,179 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/applnk.h> | 20 | #include <qpe/applnk.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpainter.h> | 22 | #include <qpainter.h> |
23 | #include <qimage.h> | 23 | #include <qimage.h> |
24 | #include <qheader.h> | 24 | #include <qheader.h> |
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qlist.h> | 26 | #include <qlist.h> |
27 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
28 | 28 | ||
29 | #include "playlistselection.h" | 29 | #include "playlistselection.h" |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | 33 | ||
34 | class PlayListSelectionItem : public QListViewItem { | 34 | class PlayListSelectionItem : public QListViewItem { |
35 | public: | 35 | public: |
36 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 36 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
37 | setText( 0, f->name() ); | 37 | setText( 0, f->name() ); |
38 | setPixmap( 0, f->pixmap() ); | 38 | setPixmap( 0, f->pixmap() ); |
39 | } | 39 | } |
40 | 40 | ||
41 | ~PlayListSelectionItem() { | 41 | ~PlayListSelectionItem() { |
42 | }; | 42 | }; |
43 | 43 | ||
44 | const DocLnk *file() const { return fl; } | 44 | const DocLnk *file() const { return fl; } |
45 | 45 | ||
46 | private: | 46 | private: |
47 | const DocLnk *fl; | 47 | const DocLnk *fl; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | 50 | ||
51 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 51 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
52 | : QListView( parent, name ) | 52 | : QListView( parent, name ) |
53 | { | 53 | { |
54 | #ifdef USE_PLAYLIST_BACKGROUND | 54 | #ifdef USE_PLAYLIST_BACKGROUND |
55 | setStaticBackground( TRUE ); | 55 | setStaticBackground( TRUE ); |
56 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); | 56 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); |
57 | #endif | 57 | #endif |
58 | setAllColumnsShowFocus( TRUE ); | 58 | setAllColumnsShowFocus( TRUE ); |
59 | addColumn( tr( "Playlist Selection" ) ); | 59 | addColumn( tr( "Playlist Selection" ) ); |
60 | header()->hide(); | 60 | header()->hide(); |
61 | setSorting( -1, FALSE ); | 61 | setSorting( -1, FALSE ); |
62 | } | 62 | } |
63 | 63 | ||
64 | 64 | ||
65 | PlayListSelection::~PlayListSelection() { | 65 | PlayListSelection::~PlayListSelection() { |
66 | } | 66 | } |
67 | 67 | ||
68 | 68 | ||
69 | #ifdef USE_PLAYLIST_BACKGROUND | 69 | #ifdef USE_PLAYLIST_BACKGROUND |
70 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | 70 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { |
71 | p->fillRect( r, QBrush( white ) ); | 71 | p->fillRect( r, QBrush( white ) ); |
72 | QImage logo = Resource::loadImage( "mpegplayer/background" ); | 72 | QImage logo = Resource::loadImage( "mpegplayer/background" ); |
73 | if ( !logo.isNull() ) | 73 | if ( !logo.isNull() ) |
74 | p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | 74 | p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); |
75 | } | 75 | } |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | 78 | ||
79 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 79 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
80 | if ( event->state() == QMouseEvent::LeftButton ) { | 80 | if ( event->state() == QMouseEvent::LeftButton ) { |
81 | QListViewItem *currentItem = selectedItem(); | 81 | QListViewItem *currentItem = selectedItem(); |
82 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 82 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
83 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 83 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
84 | moveSelectedUp(); | 84 | moveSelectedUp(); |
85 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 85 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
86 | moveSelectedDown(); | 86 | moveSelectedDown(); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | const DocLnk *PlayListSelection::current() { | 91 | const DocLnk *PlayListSelection::current() { |
92 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 92 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
93 | if ( item ) | 93 | if ( item ) |
94 | return item->file(); | 94 | return item->file(); |
95 | return NULL; | 95 | return NULL; |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { | 99 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { |
100 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); | 100 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); |
101 | QListViewItem *current = selectedItem(); | 101 | QListViewItem *current = selectedItem(); |
102 | if ( current ) | 102 | if ( current ) |
103 | item->moveItem( current ); | 103 | item->moveItem( current ); |
104 | setSelected( item, TRUE ); | 104 | setSelected( item, TRUE ); |
105 | ensureItemVisible( selectedItem() ); | 105 | ensureItemVisible( selectedItem() ); |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | void PlayListSelection::removeSelected() { | 109 | void PlayListSelection::removeSelected() { |
110 | QListViewItem *item = selectedItem(); | 110 | QListViewItem *item = selectedItem(); |
111 | if ( item ) | 111 | if ( item ) |
112 | delete item; | 112 | delete item; |
113 | setSelected( currentItem(), TRUE ); | 113 | setSelected( currentItem(), TRUE ); |
114 | ensureItemVisible( selectedItem() ); | 114 | ensureItemVisible( selectedItem() ); |
115 | } | 115 | } |
116 | 116 | ||
117 | 117 | ||
118 | void PlayListSelection::moveSelectedUp() { | 118 | void PlayListSelection::moveSelectedUp() { |
119 | QListViewItem *item = selectedItem(); | 119 | QListViewItem *item = selectedItem(); |
120 | if ( item && item->itemAbove() ) | 120 | if ( item && item->itemAbove() ) |
121 | item->itemAbove()->moveItem( item ); | 121 | item->itemAbove()->moveItem( item ); |
122 | ensureItemVisible( selectedItem() ); | 122 | ensureItemVisible( selectedItem() ); |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | void PlayListSelection::moveSelectedDown() { | 126 | void PlayListSelection::moveSelectedDown() { |
127 | QListViewItem *item = selectedItem(); | 127 | QListViewItem *item = selectedItem(); |
128 | if ( item && item->itemBelow() ) | 128 | if ( item && item->itemBelow() ) |
129 | item->moveItem( item->itemBelow() ); | 129 | item->moveItem( item->itemBelow() ); |
130 | ensureItemVisible( selectedItem() ); | 130 | ensureItemVisible( selectedItem() ); |
131 | } | 131 | } |
132 | 132 | ||
133 | 133 | ||
134 | bool PlayListSelection::prev() { | 134 | bool PlayListSelection::prev() { |
135 | QListViewItem *item = selectedItem(); | 135 | QListViewItem *item = selectedItem(); |
136 | if ( item && item->itemAbove() ) | 136 | if ( item && item->itemAbove() ) |
137 | setSelected( item->itemAbove(), TRUE ); | 137 | setSelected( item->itemAbove(), TRUE ); |
138 | else | 138 | else |
139 | return FALSE; | 139 | return FALSE; |
140 | ensureItemVisible( selectedItem() ); | 140 | ensureItemVisible( selectedItem() ); |
141 | return TRUE; | 141 | return TRUE; |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | bool PlayListSelection::next() { | 145 | bool PlayListSelection::next() { |
146 | QListViewItem *item = selectedItem(); | 146 | QListViewItem *item = selectedItem(); |
147 | if ( item && item->itemBelow() ) | 147 | if ( item && item->itemBelow() ) |
148 | setSelected( item->itemBelow(), TRUE ); | 148 | setSelected( item->itemBelow(), TRUE ); |
149 | else | 149 | else |
150 | return FALSE; | 150 | return FALSE; |
151 | ensureItemVisible( selectedItem() ); | 151 | ensureItemVisible( selectedItem() ); |
152 | return TRUE; | 152 | return TRUE; |
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
156 | bool PlayListSelection::first() { | 156 | bool PlayListSelection::first() { |
157 | QListViewItem *item = firstChild(); | 157 | QListViewItem *item = firstChild(); |
158 | if ( item ) | 158 | if ( item ) |
159 | setSelected( item, TRUE ); | 159 | setSelected( item, TRUE ); |
160 | else | 160 | else |
161 | return FALSE; | 161 | return FALSE; |
162 | ensureItemVisible( selectedItem() ); | 162 | ensureItemVisible( selectedItem() ); |
163 | return TRUE; | 163 | return TRUE; |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | bool PlayListSelection::last() { | 167 | bool PlayListSelection::last() { |
168 | QListViewItem *prevItem = NULL; | 168 | QListViewItem *prevItem = NULL; |
169 | QListViewItem *item = firstChild(); | 169 | QListViewItem *item = firstChild(); |
170 | while ( ( item = item->nextSibling() ) ) | 170 | while ( ( item = item->nextSibling() ) ) |
171 | prevItem = item; | 171 | prevItem = item; |
172 | if ( prevItem ) | 172 | if ( prevItem ) |
173 | setSelected( prevItem, TRUE ); | 173 | setSelected( prevItem, TRUE ); |
174 | else | 174 | else |
175 | return FALSE; | 175 | return FALSE; |
176 | ensureItemVisible( selectedItem() ); | 176 | ensureItemVisible( selectedItem() ); |
177 | return TRUE; | 177 | return TRUE; |
178 | } | 178 | } |
179 | 179 | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 969fc4b..4e1543e 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,448 +1,693 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/qpemenubar.h> | 20 | #include <qpe/qpemenubar.h> |
21 | #include <qpe/qpetoolbar.h> | 21 | #include <qpe/qpetoolbar.h> |
22 | #include <qpe/fileselector.h> | 22 | #include <qpe/fileselector.h> |
23 | #include <qpe/qpeapplication.h> | ||
24 | |||
23 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
24 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
25 | #include <qpe/global.h> | 27 | #include <qpe/global.h> |
26 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
27 | #include <qaction.h> | 29 | #include <qaction.h> |
28 | #include <qimage.h> | 30 | #include <qimage.h> |
29 | #include <qfile.h> | 31 | #include <qfile.h> |
30 | #include <qlayout.h> | 32 | #include <qlayout.h> |
31 | #include <qlabel.h> | 33 | #include <qlabel.h> |
32 | #include <qlist.h> | 34 | #include <qlist.h> |
33 | #include <qlistbox.h> | 35 | #include <qlistbox.h> |
34 | #include <qmainwindow.h> | 36 | #include <qmainwindow.h> |
35 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
36 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
39 | #include <qtabwidget.h> | ||
40 | #include <qlistview.h> | ||
41 | #include <qpoint.h> | ||
42 | #include <qtimer.h> | ||
37 | 43 | ||
38 | #include "playlistselection.h" | 44 | #include "playlistselection.h" |
39 | #include "playlistwidget.h" | 45 | #include "playlistwidget.h" |
40 | #include "mediaplayerstate.h" | 46 | #include "mediaplayerstate.h" |
41 | 47 | ||
42 | #include <stdlib.h> | 48 | #include <stdlib.h> |
43 | 49 | ||
50 | #define BUTTONS_ON_TOOLBAR | ||
51 | #define SIDE_BUTTONS | ||
52 | #define CAN_SAVE_LOAD_PLAYLISTS | ||
44 | 53 | ||
45 | extern MediaPlayerState *mediaPlayerState; | 54 | extern MediaPlayerState *mediaPlayerState; |
46 | 55 | ||
56 | // class myFileSelector { | ||
47 | 57 | ||
58 | // }; | ||
48 | class PlayListWidgetPrivate { | 59 | class PlayListWidgetPrivate { |
49 | public: | 60 | public: |
50 | QToolButton *tbPlay; | 61 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
51 | QToolButton *tbFull; | ||
52 | QToolButton *tbLoop; | ||
53 | QToolButton *tbScale; | ||
54 | QToolButton *tbShuffle; | ||
55 | |||
56 | QFrame *playListFrame; | 62 | QFrame *playListFrame; |
57 | FileSelector *files; | 63 | FileSelector *files; |
58 | PlayListSelection *selectedFiles; | 64 | PlayListSelection *selectedFiles; |
59 | bool setDocumentUsed; | 65 | bool setDocumentUsed; |
60 | DocLnk *current; | 66 | DocLnk *current; |
61 | }; | 67 | }; |
62 | 68 | ||
63 | 69 | ||
64 | class ToolButton : public QToolButton { | 70 | class ToolButton : public QToolButton { |
65 | public: | 71 | public: |
66 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 72 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
67 | : QToolButton( parent, name ) { | 73 | : QToolButton( parent, name ) { |
68 | setTextLabel( name ); | 74 | setTextLabel( name ); |
69 | setPixmap( Resource::loadPixmap( icon ) ); | 75 | setPixmap( Resource::loadPixmap( icon ) ); |
70 | setAutoRaise( TRUE ); | 76 | setAutoRaise( TRUE ); |
71 | setFocusPolicy( QWidget::NoFocus ); | 77 | setFocusPolicy( QWidget::NoFocus ); |
72 | setToggleButton( t ); | 78 | setToggleButton( t ); |
73 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 79 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
74 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 80 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
75 | } | 81 | } |
76 | }; | 82 | }; |
77 | 83 | ||
78 | 84 | ||
79 | class MenuItem : public QAction { | 85 | class MenuItem : public QAction { |
80 | public: | 86 | public: |
81 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 87 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
82 | : QAction( text, QString::null, 0, 0 ) { | 88 | : QAction( text, QString::null, 0, 0 ) { |
83 | connect( this, SIGNAL( activated() ), handler, slot ); | 89 | connect( this, SIGNAL( activated() ), handler, slot ); |
84 | addTo( parent ); | 90 | addTo( parent ); |
85 | } | 91 | } |
86 | }; | 92 | }; |
87 | 93 | ||
88 | 94 | ||
89 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 95 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
90 | : QMainWindow( parent, name, fl ) { | 96 | : QMainWindow( parent, name, fl ) { |
91 | 97 | ||
92 | d = new PlayListWidgetPrivate; | 98 | d = new PlayListWidgetPrivate; |
93 | d->setDocumentUsed = FALSE; | 99 | d->setDocumentUsed = FALSE; |
94 | d->current = NULL; | 100 | d->current = NULL; |
101 | menuTimer = new QTimer( this ,"menu timer"), | ||
102 | connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | ||
95 | 103 | ||
96 | setBackgroundMode( PaletteButton ); | 104 | setBackgroundMode( PaletteButton ); |
97 | 105 | ||
98 | setCaption( tr("MediaPlayer") ); | 106 | setCaption( tr("OpiePlayer") ); |
99 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); | 107 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); |
100 | 108 | ||
101 | setToolBarsMovable( FALSE ); | 109 | setToolBarsMovable( FALSE ); |
102 | 110 | ||
103 | // Create Toolbar | 111 | // Create Toolbar |
104 | QPEToolBar *toolbar = new QPEToolBar( this ); | 112 | QPEToolBar *toolbar = new QPEToolBar( this ); |
105 | toolbar->setHorizontalStretchable( TRUE ); | 113 | toolbar->setHorizontalStretchable( TRUE ); |
106 | 114 | ||
107 | // Create Menubar | 115 | // Create Menubar |
108 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 116 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
109 | menu->setMargin( 0 ); | 117 | menu->setMargin( 0 ); |
110 | 118 | ||
111 | QPEToolBar *bar = new QPEToolBar( this ); | 119 | QPEToolBar *bar = new QPEToolBar( this ); |
112 | bar->setLabel( tr( "Play Operations" ) ); | 120 | bar->setLabel( tr( "Play Operations" ) ); |
113 | #ifdef BUTTONS_ON_TOOLBAR | 121 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", |
114 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); | 122 | this , SLOT(addSelected()) ); |
115 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 123 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", |
116 | #endif | 124 | this , SLOT(removeSelected()) ); |
117 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 125 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", |
118 | d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE ); | 126 | mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); |
119 | d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE ); | 127 | |
128 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", | ||
129 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | ||
130 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop", | ||
131 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | ||
132 | |||
133 | // d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE ); | ||
134 | // d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE ); | ||
120 | 135 | ||
121 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 136 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
122 | menu->insertItem( tr( "PlayList" ), pmPlayList ); | 137 | menu->insertItem( tr( "File" ), pmPlayList ); |
123 | new MenuItem( pmPlayList, tr( "Toggle PlayList" ), mediaPlayerState, SLOT( togglePlaylist() ) ); | ||
124 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 138 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
125 | new MenuItem( pmPlayList, tr( "Add all music files" ), this, SLOT( addAllMusicToList() ) ); | 139 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
126 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 140 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
127 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 141 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
128 | #ifdef CAN_SAVE_LOAD_PLAYLISTS | ||
129 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 142 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
130 | new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); | 143 | new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); |
131 | #endif | 144 | |
145 | QPopupMenu *pmView = new QPopupMenu( this ); | ||
146 | menu->insertItem( tr( "View" ), pmView ); | ||
147 | |||
148 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | ||
149 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | ||
150 | fullScreenButton->addTo(pmView); | ||
151 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); | ||
152 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | ||
153 | scaleButton->addTo(pmView); | ||
132 | 154 | ||
133 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 155 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
156 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | ||
157 | // vbox4->setMargin(4); | ||
158 | // libString = new QLabel( tr(" Media Library"), vbox4 ); | ||
159 | // libString->setBackgroundMode( QButton::PaletteButton ); | ||
160 | // libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) ); | ||
161 | |||
162 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | ||
163 | |||
164 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | ||
165 | tabWidget->setTabShape(QTabWidget::Triangular); | ||
166 | |||
167 | |||
168 | QWidget *pTab; | ||
169 | pTab = new QWidget( tabWidget, "pTab" ); | ||
170 | playlistView = new QListView( pTab, "Videoview" ); | ||
171 | playlistView->setMinimumSize(236,260); | ||
172 | tabWidget->insertTab( pTab,"Playlist"); | ||
134 | 173 | ||
135 | // Add the playlist area | 174 | // Add the playlist area |
136 | QVBox *vbox3 = new QVBox( vbox5 ); vbox3->setBackgroundMode( PaletteButton ); | ||
137 | d->playListFrame = vbox3; | ||
138 | 175 | ||
139 | QLabel *plString = new QLabel( tr(" PlayList"), vbox3 ); | 176 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
140 | plString->setBackgroundMode( QButton::PaletteButton ); | 177 | d->playListFrame = vbox3; |
141 | plString->setFont( QFont( "Helvetica", 8, QFont::Bold ) ); | 178 | d->playListFrame ->setMinimumSize(235,260); |
142 | 179 | ||
143 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 180 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
144 | d->selectedFiles = new PlayListSelection( hbox2 ); | 181 | d->selectedFiles = new PlayListSelection( hbox2); |
145 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 182 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
146 | 183 | ||
147 | #ifndef BUTTONS_ON_TOOLBAR | 184 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
148 | d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); | 185 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
149 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 186 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
150 | #endif | 187 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
151 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 188 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
152 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 189 | |
153 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 190 | QWidget *aTab; |
154 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 191 | aTab = new QWidget( tabWidget, "aTab" ); |
155 | #ifndef BUTTONS_ON_TOOLBAR | 192 | audioView = new QListView( aTab, "Audioview" ); |
156 | d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 193 | audioView->setMinimumSize(233,260); |
157 | #endif | 194 | audioView->addColumn( "Title",150); |
195 | audioView->addColumn("Size", 45); | ||
196 | audioView->addColumn("Media",35); | ||
197 | audioView->setColumnAlignment(1, Qt::AlignRight); | ||
198 | audioView->setColumnAlignment(2, Qt::AlignRight); | ||
199 | tabWidget->insertTab(aTab,"Audio"); | ||
200 | // audioView | ||
201 | Global::findDocuments(&files, "audio/*"); | ||
202 | QListIterator<DocLnk> dit( files.children() ); | ||
203 | QString storage; | ||
204 | for ( ; dit.current(); ++dit ) { | ||
205 | QListViewItem * newItem; | ||
206 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | ||
207 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | ||
208 | else storage="RAM"; | ||
209 | |||
210 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | ||
211 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | ||
212 | } | ||
213 | // videowidget | ||
214 | |||
215 | QWidget *vTab; | ||
216 | vTab = new QWidget( tabWidget, "vTab" ); | ||
217 | videoView = new QListView( vTab, "Videoview" ); | ||
218 | videoView->setMinimumSize(233,260); | ||
219 | |||
220 | videoView->addColumn("Title",150); | ||
221 | videoView->addColumn("Size",45); | ||
222 | videoView->addColumn("Media",35); | ||
223 | videoView->setColumnAlignment(1, Qt::AlignRight); | ||
224 | videoView->setColumnAlignment(2, Qt::AlignRight); | ||
225 | |||
226 | tabWidget->insertTab( vTab,"Video"); | ||
227 | |||
228 | Global::findDocuments(&vFiles, "video/*"); | ||
229 | QListIterator<DocLnk> Vdit( vFiles.children() ); | ||
230 | for ( ; Vdit.current(); ++Vdit ) { | ||
231 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | ||
232 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | ||
233 | else storage="RAM"; | ||
234 | QListViewItem * newItem; | ||
235 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | ||
236 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | ||
237 | } | ||
238 | |||
239 | |||
240 | // d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); | ||
241 | // d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | ||
158 | 242 | ||
159 | // add the library area | 243 | // add the library area |
160 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | ||
161 | 244 | ||
162 | QLabel *libString = new QLabel( tr(" Media Library"), vbox4 ); | 245 | // d->files->setBackgroundMode( PaletteButton ); |
163 | libString->setBackgroundMode( QButton::PaletteButton ); | 246 | // QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton ); |
164 | libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) ); | ||
165 | 247 | ||
166 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 248 | // #ifdef SIDE_BUTTONS |
167 | d->files = new FileSelector( "video/*;audio/*", hbox6, "Find Media Files", FALSE, FALSE ); | 249 | // QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch |
168 | d->files->setBackgroundMode( PaletteButton ); | 250 | // #endif |
169 | QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton ); | 251 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
252 | |||
253 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | ||
254 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | ||
170 | 255 | ||
171 | #ifdef SIDE_BUTTONS | 256 | connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
172 | new ToolButton( vbox7, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", d->selectedFiles, SLOT(addSelected()) ); | 257 | connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
173 | new ToolButton( vbox7, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", d->selectedFiles, SLOT(removeSelected()) ); | ||
174 | QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch | ||
175 | #endif | ||
176 | 258 | ||
177 | connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 259 | connect( audioView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), |
260 | this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); | ||
261 | connect( videoView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), | ||
262 | this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); | ||
263 | |||
264 | connect( playlistView, SIGNAL( pressed( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | ||
265 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | ||
266 | // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | ||
267 | // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | ||
178 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 268 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
179 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 269 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
180 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 270 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
181 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbFull, SLOT( setOn( bool ) ) ); | 271 | |
182 | connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), d->tbScale, SLOT( setOn( bool ) ) ); | 272 | // connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setOn( bool ) ) ); |
183 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbScale, SLOT( setEnabled( bool ) ) ); | 273 | // connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), scaleButton, SLOT( setEnabled( bool ) ) ); |
274 | // connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setEnabled( bool ) ) ); | ||
275 | |||
184 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 276 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
185 | 277 | ||
186 | setCentralWidget( vbox5 ); | 278 | setCentralWidget( vbox5 ); |
187 | 279 | ||
188 | Config cfg( "MediaPlayer" ); | 280 | Config cfg( "MediaPlayer" ); |
189 | readConfig( cfg ); | 281 | readConfig( cfg ); |
190 | 282 | ||
191 | initializeStates(); | 283 | initializeStates(); |
192 | } | 284 | } |
193 | 285 | ||
194 | 286 | ||
195 | PlayListWidget::~PlayListWidget() { | 287 | PlayListWidget::~PlayListWidget() { |
196 | Config cfg( "MediaPlayer" ); | 288 | Config cfg( "MediaPlayer" ); |
197 | writeConfig( cfg ); | 289 | writeConfig( cfg ); |
198 | 290 | ||
199 | if ( d->current ) | 291 | if ( d->current ) |
200 | delete d->current; | 292 | delete d->current; |
201 | delete d; | 293 | delete d; |
202 | } | 294 | } |
203 | 295 | ||
204 | 296 | ||
205 | void PlayListWidget::initializeStates() { | 297 | void PlayListWidget::initializeStates() { |
298 | |||
206 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 299 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
207 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 300 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
208 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 301 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
209 | d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 302 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
210 | d->tbScale->setOn( mediaPlayerState->scaled() ); | 303 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
211 | d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 304 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
212 | setPlaylist( mediaPlayerState->playlist() ); | 305 | // setPlaylist( mediaPlayerState->playlist() ); |
213 | } | 306 | } |
214 | 307 | ||
215 | 308 | ||
216 | void PlayListWidget::readConfig( Config& cfg ) { | 309 | void PlayListWidget::readConfig( Config& cfg ) { |
217 | cfg.setGroup("PlayList"); | 310 | cfg.setGroup("PlayList"); |
218 | 311 | ||
219 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 312 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
220 | 313 | ||
221 | for ( int i = 0; i < noOfFiles; i++ ) { | 314 | for ( int i = 0; i < noOfFiles; i++ ) { |
222 | QString entryName; | 315 | QString entryName; |
223 | entryName.sprintf( "File%i", i + 1 ); | 316 | entryName.sprintf( "File%i", i + 1 ); |
224 | QString linkFile = cfg.readEntry( entryName ); | 317 | QString linkFile = cfg.readEntry( entryName ); |
225 | DocLnk lnk( linkFile ); | 318 | DocLnk lnk( linkFile ); |
226 | if ( lnk.isValid() ) | 319 | if ( lnk.isValid() ) |
227 | d->selectedFiles->addToSelection( lnk ); | 320 | d->selectedFiles->addToSelection( lnk ); |
228 | 321 | ||
229 | } | 322 | } |
230 | } | 323 | } |
231 | 324 | ||
232 | 325 | ||
233 | void PlayListWidget::writeConfig( Config& cfg ) const { | 326 | void PlayListWidget::writeConfig( Config& cfg ) const { |
234 | cfg.setGroup("PlayList"); | 327 | cfg.setGroup("PlayList"); |
235 | 328 | ||
236 | int noOfFiles = 0; | 329 | int noOfFiles = 0; |
237 | 330 | ||
238 | d->selectedFiles->first(); | 331 | d->selectedFiles->first(); |
239 | do { | 332 | do { |
240 | const DocLnk *lnk = d->selectedFiles->current(); | 333 | const DocLnk *lnk = d->selectedFiles->current(); |
241 | if ( lnk ) { | 334 | if ( lnk ) { |
242 | QString entryName; | 335 | QString entryName; |
243 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 336 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
244 | cfg.writeEntry( entryName, lnk->linkFile() ); | 337 | cfg.writeEntry( entryName, lnk->linkFile() ); |
245 | // if this link does exist, add it so we have the file | 338 | // if this link does exist, add it so we have the file |
246 | // next time... | 339 | // next time... |
247 | if ( !QFile::exists( lnk->linkFile() ) ) { | 340 | if ( !QFile::exists( lnk->linkFile() ) ) { |
248 | // the way writing lnks doesn't really check for out | 341 | // the way writing lnks doesn't really check for out |
249 | // of disk space, but check it anyway. | 342 | // of disk space, but check it anyway. |
250 | if ( !lnk->writeLink() ) { | 343 | if ( !lnk->writeLink() ) { |
251 | QMessageBox::critical( 0, tr("Out of space"), | 344 | QMessageBox::critical( 0, tr("Out of space"), |
252 | tr( "There was a problem saving " | 345 | tr( "There was a problem saving " |
253 | "the playlist.\n" | 346 | "the playlist.\n" |
254 | "Your playlist " | 347 | "Your playlist " |
255 | "may be missing some entries\n" | 348 | "may be missing some entries\n" |
256 | "the next time you start it." ) | 349 | "the next time you start it." ) |
257 | ); | 350 | ); |
258 | } | 351 | } |
259 | } | 352 | } |
260 | noOfFiles++; | 353 | noOfFiles++; |
261 | } | 354 | } |
262 | } while ( d->selectedFiles->next() ); | 355 | } while ( d->selectedFiles->next() ); |
263 | 356 | ||
264 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 357 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
265 | } | 358 | } |
266 | 359 | ||
267 | 360 | ||
268 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 361 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
269 | d->setDocumentUsed = FALSE; | 362 | d->setDocumentUsed = FALSE; |
270 | if ( mediaPlayerState->playlist() ) | 363 | if ( mediaPlayerState->playlist() ) |
271 | d->selectedFiles->addToSelection( lnk ); | 364 | d->selectedFiles->addToSelection( lnk ); |
272 | else | 365 | else |
273 | mediaPlayerState->setPlaying( TRUE ); | 366 | mediaPlayerState->setPlaying( TRUE ); |
367 | } | ||
368 | |||
369 | |||
370 | void PlayListWidget::addToSelection( QListViewItem *it ,const QPoint & p, int index) { | ||
371 | qDebug("add"); | ||
372 | // d->selectedFiles->addToSelection( lnk ); | ||
373 | // } | ||
374 | // else | ||
375 | // mediaPlayerState->setPlaying( TRUE ); | ||
376 | // | ||
274 | } | 377 | } |
275 | 378 | ||
276 | 379 | ||
277 | void PlayListWidget::clearList() { | 380 | void PlayListWidget::clearList() { |
278 | while ( first() ) | 381 | while ( first() ) |
279 | d->selectedFiles->removeSelected(); | 382 | d->selectedFiles->removeSelected(); |
280 | } | 383 | } |
281 | 384 | ||
282 | 385 | ||
283 | void PlayListWidget::addAllToList() { | 386 | void PlayListWidget::addAllToList() { |
284 | DocLnkSet files; | 387 | DocLnkSet files; |
285 | Global::findDocuments(&files, "video/*;audio/*"); | 388 | Global::findDocuments(&files, "video/*;audio/*"); |
286 | QListIterator<DocLnk> dit( files.children() ); | 389 | QListIterator<DocLnk> dit( files.children() ); |
287 | for ( ; dit.current(); ++dit ) | 390 | for ( ; dit.current(); ++dit ) |
288 | d->selectedFiles->addToSelection( **dit ); | 391 | d->selectedFiles->addToSelection( **dit ); |
289 | } | 392 | } |
290 | 393 | ||
291 | 394 | ||
292 | void PlayListWidget::addAllMusicToList() { | 395 | void PlayListWidget::addAllMusicToList() { |
293 | DocLnkSet files; | 396 | DocLnkSet files; |
294 | Global::findDocuments(&files, "audio/*"); | 397 | Global::findDocuments(&files, "audio/*"); |
295 | QListIterator<DocLnk> dit( files.children() ); | 398 | QListIterator<DocLnk> dit( files.children() ); |
296 | for ( ; dit.current(); ++dit ) | 399 | for ( ; dit.current(); ++dit ) |
297 | d->selectedFiles->addToSelection( **dit ); | 400 | d->selectedFiles->addToSelection( **dit ); |
298 | } | 401 | } |
299 | 402 | ||
300 | 403 | ||
301 | void PlayListWidget::addAllVideoToList() { | 404 | void PlayListWidget::addAllVideoToList() { |
302 | DocLnkSet files; | 405 | DocLnkSet files; |
303 | Global::findDocuments(&files, "video/*"); | 406 | Global::findDocuments(&files, "video/*"); |
304 | QListIterator<DocLnk> dit( files.children() ); | 407 | QListIterator<DocLnk> dit( files.children() ); |
305 | for ( ; dit.current(); ++dit ) | 408 | for ( ; dit.current(); ++dit ) |
306 | d->selectedFiles->addToSelection( **dit ); | 409 | d->selectedFiles->addToSelection( **dit ); |
307 | } | 410 | } |
308 | 411 | ||
309 | 412 | ||
310 | void PlayListWidget::setDocument(const QString& fileref) { | 413 | void PlayListWidget::setDocument(const QString& fileref) { |
311 | if ( fileref.isNull() ) { | 414 | if ( fileref.isNull() ) { |
312 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 415 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
313 | return; | 416 | return; |
314 | } | 417 | } |
315 | if ( mediaPlayerState->playlist() ) | 418 | if ( mediaPlayerState->playlist() ) |
316 | addToSelection( DocLnk( fileref ) ); | 419 | addToSelection( DocLnk( fileref ) ); |
317 | else { | 420 | else { |
318 | d->setDocumentUsed = TRUE; | 421 | d->setDocumentUsed = TRUE; |
319 | if ( d->current ) | 422 | if ( d->current ) |
320 | delete d->current; | 423 | delete d->current; |
321 | d->current = new DocLnk( fileref ); | 424 | d->current = new DocLnk( fileref ); |
322 | } | 425 | } |
323 | mediaPlayerState->setPlaying( FALSE ); | 426 | mediaPlayerState->setPlaying( FALSE ); |
324 | mediaPlayerState->setPlaying( TRUE ); | 427 | mediaPlayerState->setPlaying( TRUE ); |
325 | } | 428 | } |
326 | 429 | ||
327 | 430 | ||
328 | void PlayListWidget::setActiveWindow() { | 431 | void PlayListWidget::setActiveWindow() { |
329 | // When we get raised we need to ensure that it switches views | 432 | // When we get raised we need to ensure that it switches views |
330 | char origView = mediaPlayerState->view(); | 433 | char origView = mediaPlayerState->view(); |
331 | mediaPlayerState->setView( 'l' ); // invalidate | 434 | mediaPlayerState->setView( 'l' ); // invalidate |
332 | mediaPlayerState->setView( origView ); // now switch back | 435 | mediaPlayerState->setView( origView ); // now switch back |
333 | } | 436 | } |
334 | 437 | ||
335 | 438 | ||
336 | void PlayListWidget::useSelectedDocument() { | 439 | void PlayListWidget::useSelectedDocument() { |
337 | d->setDocumentUsed = FALSE; | 440 | d->setDocumentUsed = FALSE; |
338 | } | 441 | } |
339 | 442 | ||
340 | 443 | ||
341 | const DocLnk *PlayListWidget::current() { | 444 | const DocLnk *PlayListWidget::current() { |
342 | if ( mediaPlayerState->playlist() ) | 445 | if ( mediaPlayerState->playlist() ) |
343 | return d->selectedFiles->current(); | 446 | return d->selectedFiles->current(); |
344 | else if ( d->setDocumentUsed && d->current ) { | 447 | else if ( d->setDocumentUsed && d->current ) { |
345 | return d->current; | 448 | return d->current; |
346 | } else | 449 | } else |
347 | return d->files->selected(); | 450 | return d->files->selected(); |
348 | } | 451 | } |
349 | 452 | ||
350 | 453 | ||
351 | bool PlayListWidget::prev() { | 454 | bool PlayListWidget::prev() { |
352 | if ( mediaPlayerState->playlist() ) { | 455 | if ( mediaPlayerState->playlist() ) { |
353 | if ( mediaPlayerState->shuffled() ) { | 456 | if ( mediaPlayerState->shuffled() ) { |
354 | const DocLnk *cur = current(); | 457 | const DocLnk *cur = current(); |
355 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 458 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
356 | for ( int i = 0; i < j; i++ ) { | 459 | for ( int i = 0; i < j; i++ ) { |
357 | if ( !d->selectedFiles->next() ) | 460 | if ( !d->selectedFiles->next() ) |
358 | d->selectedFiles->first(); | 461 | d->selectedFiles->first(); |
359 | } | 462 | } |
360 | if ( cur == current() ) | 463 | if ( cur == current() ) |
361 | if ( !d->selectedFiles->next() ) | 464 | if ( !d->selectedFiles->next() ) |
362 | d->selectedFiles->first(); | 465 | d->selectedFiles->first(); |
363 | return TRUE; | 466 | return TRUE; |
364 | } else { | 467 | } else { |
365 | if ( !d->selectedFiles->prev() ) { | 468 | if ( !d->selectedFiles->prev() ) { |
366 | if ( mediaPlayerState->looping() ) { | 469 | if ( mediaPlayerState->looping() ) { |
367 | return d->selectedFiles->last(); | 470 | return d->selectedFiles->last(); |
368 | } else { | 471 | } else { |
369 | return FALSE; | 472 | return FALSE; |
370 | } | 473 | } |
371 | } | 474 | } |
372 | return TRUE; | 475 | return TRUE; |
373 | } | 476 | } |
374 | } else { | 477 | } else { |
375 | return mediaPlayerState->looping(); | 478 | return mediaPlayerState->looping(); |
376 | } | 479 | } |
377 | } | 480 | } |
378 | 481 | ||
379 | 482 | ||
380 | bool PlayListWidget::next() { | 483 | bool PlayListWidget::next() { |
381 | if ( mediaPlayerState->playlist() ) { | 484 | if ( mediaPlayerState->playlist() ) { |
382 | if ( mediaPlayerState->shuffled() ) { | 485 | if ( mediaPlayerState->shuffled() ) { |
383 | return prev(); | 486 | return prev(); |
384 | } else { | 487 | } else { |
385 | if ( !d->selectedFiles->next() ) { | 488 | if ( !d->selectedFiles->next() ) { |
386 | if ( mediaPlayerState->looping() ) { | 489 | if ( mediaPlayerState->looping() ) { |
387 | return d->selectedFiles->first(); | 490 | return d->selectedFiles->first(); |
388 | } else { | ||
389 | return FALSE; | ||
390 | } | ||
391 | } | ||
392 | return TRUE; | ||
393 | } | ||
394 | } else { | 491 | } else { |
395 | return mediaPlayerState->looping(); | 492 | return FALSE; |
493 | } | ||
494 | } | ||
495 | return TRUE; | ||
496 | } | ||
497 | } else { | ||
498 | return mediaPlayerState->looping(); | ||
396 | } | 499 | } |
397 | } | 500 | } |
398 | 501 | ||
399 | 502 | ||
400 | bool PlayListWidget::first() { | 503 | bool PlayListWidget::first() { |
401 | if ( mediaPlayerState->playlist() ) | 504 | if ( mediaPlayerState->playlist() ) |
402 | return d->selectedFiles->first(); | 505 | return d->selectedFiles->first(); |
403 | else | 506 | else |
404 | return mediaPlayerState->looping(); | 507 | return mediaPlayerState->looping(); |
405 | } | 508 | } |
406 | 509 | ||
407 | 510 | ||
408 | bool PlayListWidget::last() { | 511 | bool PlayListWidget::last() { |
409 | if ( mediaPlayerState->playlist() ) | 512 | if ( mediaPlayerState->playlist() ) |
410 | return d->selectedFiles->last(); | 513 | return d->selectedFiles->last(); |
411 | else | 514 | else |
412 | return mediaPlayerState->looping(); | 515 | return mediaPlayerState->looping(); |
413 | } | 516 | } |
414 | 517 | ||
415 | 518 | ||
416 | void PlayListWidget::saveList() { | 519 | void PlayListWidget::saveList() { |
417 | QString filename; | 520 | QString filename; |
418 | // pseudo code | 521 | // pseudo code |
419 | // filename = QLineEdit->getText(); | 522 | // filename = QLineEdit->getText(); |
420 | Config cfg( filename + ".playlist" ); | 523 | Config cfg( filename + ".playlist" ); |
421 | writeConfig( cfg ); | 524 | writeConfig( cfg ); |
422 | } | 525 | } |
423 | 526 | ||
424 | 527 | ||
425 | void PlayListWidget::loadList() { | 528 | void PlayListWidget::loadList() { |
426 | QString filename; | 529 | QString filename; |
427 | // pseudo code | 530 | // pseudo code |
428 | // filename = FileSelector->openFile( "*.playlist" ); | 531 | // filename = FileSelector->openFile( "*.playlist" ); |
429 | Config cfg( filename + ".playlist" ); | 532 | Config cfg( filename + ".playlist" ); |
430 | readConfig( cfg ); | 533 | readConfig( cfg ); |
431 | } | 534 | } |
432 | 535 | ||
433 | 536 | ||
434 | void PlayListWidget::setPlaylist( bool shown ) { | 537 | void PlayListWidget::setPlaylist( bool shown ) { |
435 | if ( shown ) | 538 | if ( shown ) |
436 | d->playListFrame->show(); | 539 | d->playListFrame->show(); |
437 | else | 540 | else |
438 | d->playListFrame->hide(); | 541 | d->playListFrame->hide(); |
439 | } | 542 | } |
440 | 543 | ||
441 | 544 | ||
442 | void PlayListWidget::setView( char view ) { | 545 | void PlayListWidget::setView( char view ) { |
443 | if ( view == 'l' ) | 546 | if ( view == 'l' ) |
444 | showMaximized(); | 547 | showMaximized(); |
445 | else | 548 | else |
446 | hide(); | 549 | hide(); |
550 | } | ||
551 | |||
552 | void PlayListWidget::addSelected() { | ||
553 | // QMessageBox::message("Note","Bozo the clown thinks\nthere's something actually here"); | ||
554 | int tabPage=tabWidget->currentPageIndex(); | ||
555 | switch (tabPage) { | ||
556 | case 0: //playlist | ||
557 | break; | ||
558 | case 1: { //audio | ||
559 | addToSelection( audioView->selectedItem() ); | ||
560 | } | ||
561 | break; | ||
562 | case 2: { // video | ||
563 | addToSelection( videoView->selectedItem() ); | ||
564 | } | ||
565 | break; | ||
566 | }; | ||
567 | } | ||
568 | |||
569 | void PlayListWidget::removeSelected() { | ||
570 | d->selectedFiles->removeSelected( ); | ||
571 | } | ||
572 | |||
573 | |||
574 | void PlayListWidget::playIt( QListViewItem *it) { | ||
575 | d->setDocumentUsed = FALSE; | ||
576 | |||
577 | if(it) { | ||
578 | qDebug("playit"); | ||
579 | int tabPage=tabWidget->currentPageIndex(); | ||
580 | switch (tabPage) { | ||
581 | case 1: { | ||
582 | DocLnkSet files; | ||
583 | QListIterator<DocLnk> dit( files.children() ); | ||
584 | for ( ; dit.current(); ++dit ) { | ||
585 | if( dit.current()->name() == it->text(0)) { | ||
586 | setDocument( dit.current()->name()); | ||
587 | } | ||
588 | } | ||
589 | } | ||
590 | break; | ||
591 | case 2: { | ||
592 | DocLnkSet vFiles; | ||
593 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
594 | for ( ; dit.current(); ++dit ) { | ||
595 | qDebug(dit.current()->name()); | ||
596 | if( dit.current()->name() == it->text(0)) { | ||
597 | qDebug(it->text(0)); | ||
598 | setDocument( dit.current()->name()); | ||
599 | } | ||
600 | } | ||
601 | } | ||
602 | break; | ||
603 | }; | ||
604 | } | ||
605 | } | ||
606 | |||
607 | void PlayListWidget::addToSelection( QListViewItem *it) { | ||
608 | d->setDocumentUsed = FALSE; | ||
609 | |||
610 | if(it) { | ||
611 | qDebug("add to selection"); | ||
612 | int tabPage=tabWidget->currentPageIndex(); | ||
613 | switch (tabPage) { | ||
614 | case 1: { | ||
615 | QListIterator<DocLnk> dit( files.children() ); | ||
616 | for ( ; dit.current(); ++dit ) { | ||
617 | if( dit.current()->name() == it->text(0)) { | ||
618 | d->selectedFiles->addToSelection( **dit ); | ||
619 | } | ||
620 | } | ||
621 | } | ||
622 | break; | ||
623 | case 2: { | ||
624 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
625 | for ( ; dit.current(); ++dit ) { | ||
626 | qDebug(dit.current()->name()); | ||
627 | if( dit.current()->name() == it->text(0)) { | ||
628 | d->selectedFiles->addToSelection( **dit ); | ||
629 | } | ||
630 | } | ||
631 | } | ||
632 | break; | ||
633 | case 0: | ||
634 | break; | ||
635 | }; | ||
636 | tabWidget->setCurrentPage(0); | ||
637 | // mediaPlayerState->setPlaying( TRUE ); | ||
638 | } | ||
639 | } | ||
640 | |||
641 | void PlayListWidget::tabChanged(QWidget *widg) { | ||
642 | |||
643 | int tabPage=tabWidget->currentPageIndex(); | ||
644 | switch (tabPage) { | ||
645 | case 0: | ||
646 | { | ||
647 | d->tbRemoveFromList->setEnabled(TRUE); | ||
648 | d->tbAddToList->setEnabled(FALSE); | ||
649 | } | ||
650 | break; | ||
651 | case 1: | ||
652 | { | ||
653 | d->tbRemoveFromList->setEnabled(FALSE); | ||
654 | d->tbAddToList->setEnabled(TRUE); | ||
655 | } | ||
656 | break; | ||
657 | case 2: | ||
658 | { | ||
659 | d->tbRemoveFromList->setEnabled(FALSE); | ||
660 | d->tbAddToList->setEnabled(TRUE); | ||
661 | } | ||
662 | break; | ||
663 | }; | ||
664 | } | ||
665 | |||
666 | void PlayListWidget::cancelMenuTimer() { | ||
667 | if( menuTimer->isActive() ) | ||
668 | menuTimer->stop(); | ||
669 | } | ||
670 | |||
671 | void PlayListWidget::showFileMenu() { | ||
672 | |||
673 | } | ||
674 | |||
675 | void PlayListWidget::contentsMousePressEvent( QMouseEvent * e ) | ||
676 | { | ||
677 | // QListView::contentsMousePressEvent( e ); | ||
678 | menuTimer->start( 750, TRUE ); | ||
679 | } | ||
680 | |||
681 | |||
682 | void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e ) | ||
683 | { | ||
684 | // QListView::contentsMouseReleaseEvent( e ); | ||
685 | menuTimer->stop(); | ||
447 | } | 686 | } |
687 | // void PlayListWidget::setFullScreen() { | ||
688 | // mediaPlayerState->toggleFullscreen( ); | ||
689 | // } | ||
448 | 690 | ||
691 | // void PlayListWidget::setScaled() { | ||
692 | // mediaPlayerState->toggleScaled(); | ||
693 | // } | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index 6976641..3a52dd5 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h | |||
@@ -1,68 +1,97 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef PLAY_LIST_WIDGET_H | 20 | #ifndef PLAY_LIST_WIDGET_H |
21 | #define PLAY_LIST_WIDGET_H | 21 | #define PLAY_LIST_WIDGET_H |
22 | 22 | ||
23 | 23 | ||
24 | #include <qmainwindow.h> | 24 | #include <qmainwindow.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | #include <qtabwidget.h> | ||
27 | #include <qtimer.h> | ||
26 | 28 | ||
27 | 29 | ||
28 | class PlayListWidgetPrivate; | 30 | class PlayListWidgetPrivate; |
29 | class Config; | 31 | class Config; |
30 | 32 | class QListViewItem; | |
33 | class QListView; | ||
34 | class QPoint; | ||
35 | class QAction; | ||
36 | class QLabel; | ||
31 | 37 | ||
32 | class PlayListWidget : public QMainWindow { | 38 | class PlayListWidget : public QMainWindow { |
33 | Q_OBJECT | 39 | Q_OBJECT |
34 | public: | 40 | public: |
35 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 41 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
36 | ~PlayListWidget(); | 42 | ~PlayListWidget(); |
37 | 43 | QTabWidget * tabWidget; | |
44 | QAction *fullScreenButton, *scaleButton; | ||
45 | DocLnkSet files; | ||
46 | DocLnkSet vFiles; | ||
47 | QListView *audioView, *videoView, *playlistView; | ||
48 | QLabel *libString; | ||
38 | // retrieve the current playlist entry (media file link) | 49 | // retrieve the current playlist entry (media file link) |
39 | const DocLnk *current(); | 50 | const DocLnk *current(); |
40 | void useSelectedDocument(); | 51 | void useSelectedDocument(); |
52 | QTimer * menuTimer; | ||
41 | 53 | ||
42 | public slots: | 54 | public slots: |
43 | void setDocument( const QString& fileref ); | 55 | void setDocument( const QString& fileref ); |
44 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 56 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
57 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | ||
58 | void addToSelection( QListViewItem*, const QPoint&,int ); // Add a media file to the playlist | ||
45 | void setActiveWindow(); // need to handle this to show the right view | 59 | void setActiveWindow(); // need to handle this to show the right view |
46 | void setPlaylist( bool ); // Show/Hide the playlist | 60 | void setPlaylist( bool ); // Show/Hide the playlist |
47 | void setView( char ); | 61 | void setView( char ); |
48 | void clearList(); | 62 | void clearList(); |
49 | void addAllToList(); | 63 | void addAllToList(); |
50 | void addAllMusicToList(); | 64 | void addAllMusicToList(); |
51 | void addAllVideoToList(); | 65 | void addAllVideoToList(); |
52 | void saveList(); // Save the playlist | 66 | void saveList(); // Save the playlist |
53 | void loadList(); // Load a playlist | 67 | void loadList(); // Load a playlist |
68 | void playIt( QListViewItem *); | ||
54 | bool first(); | 69 | bool first(); |
55 | bool last(); | 70 | bool last(); |
56 | bool next(); | 71 | bool next(); |
57 | bool prev(); | 72 | bool prev(); |
73 | void addSelected(); | ||
74 | void removeSelected(); | ||
75 | void tabChanged(QWidget*); | ||
76 | /* void setFullScreen(); */ | ||
77 | /* void setScaled(); */ | ||
78 | protected: | ||
79 | void contentsMousePressEvent( QMouseEvent * e ); | ||
80 | void contentsMouseReleaseEvent( QMouseEvent * e ); | ||
58 | 81 | ||
59 | private: | 82 | private: |
60 | void initializeStates(); | 83 | void initializeStates(); |
61 | void readConfig( Config& cfg ); | 84 | void readConfig( Config& cfg ); |
62 | void writeConfig( Config& cfg ) const; | 85 | void writeConfig( Config& cfg ) const; |
63 | PlayListWidgetPrivate *d; // Private implementation data | 86 | PlayListWidgetPrivate *d; // Private implementation data |
87 | |||
88 | protected slots: | ||
89 | void cancelMenuTimer(); | ||
90 | void showFileMenu(); | ||
91 | |||
92 | |||
64 | }; | 93 | }; |
65 | 94 | ||
66 | 95 | ||
67 | #endif // PLAY_LIST_WIDGET_H | 96 | #endif // PLAY_LIST_WIDGET_H |
68 | 97 | ||
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index f3974a0..1f128a4 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp | |||
@@ -1,423 +1,423 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/resource.h> | 20 | #include <qpe/resource.h> |
21 | #include "mediaplayerplugininterface.h" | ||
21 | #include <qwidget.h> | 22 | #include <qwidget.h> |
22 | #include <qpainter.h> | 23 | #include <qpainter.h> |
23 | #include <qpixmap.h> | 24 | #include <qpixmap.h> |
24 | #include <qslider.h> | 25 | #include <qslider.h> |
25 | #include <qdrawutil.h> | 26 | #include <qdrawutil.h> |
26 | #include "videowidget.h" | 27 | #include "videowidget.h" |
27 | #include "mediaplayerplugininterface.h" | ||
28 | #include "mediaplayerstate.h" | 28 | #include "mediaplayerstate.h" |
29 | 29 | ||
30 | 30 | ||
31 | #ifdef Q_WS_QWS | 31 | #ifdef Q_WS_QWS |
32 | # define USE_DIRECT_PAINTER | 32 | # define USE_DIRECT_PAINTER |
33 | # include <qdirectpainter_qws.h> | 33 | # include <qdirectpainter_qws.h> |
34 | # include <qgfxraster_qws.h> | 34 | # include <qgfxraster_qws.h> |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | 37 | ||
38 | extern MediaPlayerState *mediaPlayerState; | 38 | extern MediaPlayerState *mediaPlayerState; |
39 | 39 | ||
40 | 40 | ||
41 | static const int xo = 2; // movable x offset | 41 | static const int xo = 2; // movable x offset |
42 | static const int yo = 0; // movable y offset | 42 | static const int yo = 0; // movable y offset |
43 | 43 | ||
44 | 44 | ||
45 | struct MediaButton { | 45 | struct MediaButton { |
46 | int xPos, yPos; | 46 | int xPos, yPos; |
47 | bool isToggle, isHeld, isDown; | 47 | bool isToggle, isHeld, isDown; |
48 | int controlType; | 48 | int controlType; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | 51 | ||
52 | // Layout information for the videoButtons (and if it is a toggle button or not) | 52 | // Layout information for the videoButtons (and if it is a toggle button or not) |
53 | MediaButton videoButtons[] = { | 53 | MediaButton videoButtons[] = { |
54 | { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous | 54 | { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous |
55 | { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop | 55 | { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop |
56 | { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play | 56 | { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play |
57 | { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause | 57 | { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause |
58 | { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next | 58 | { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next |
59 | { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist | 59 | { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist |
60 | { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen | 60 | { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen |
61 | }; | 61 | }; |
62 | 62 | ||
63 | 63 | ||
64 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 64 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
65 | 65 | ||
66 | 66 | ||
67 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 67 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
68 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 68 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
69 | setCaption( tr("MediaPlayer") ); | 69 | setCaption( tr("OpiePlayer") ); |
70 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 70 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); |
71 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0a" ) ); | 71 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0a" ) ); |
72 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0b" ) ); | 72 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0b" ) ); |
73 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls0" ) ); | 73 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls0" ) ); |
74 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); | 74 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); |
75 | 75 | ||
76 | slider = new QSlider( Qt::Horizontal, this ); | 76 | slider = new QSlider( Qt::Horizontal, this ); |
77 | slider->setMinValue( 0 ); | 77 | slider->setMinValue( 0 ); |
78 | slider->setMaxValue( 1 ); | 78 | slider->setMaxValue( 1 ); |
79 | slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 79 | slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); |
80 | slider->setFocusPolicy( QWidget::NoFocus ); | 80 | slider->setFocusPolicy( QWidget::NoFocus ); |
81 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 81 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
82 | 82 | ||
83 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 83 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
84 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 84 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
85 | 85 | ||
86 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 86 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
87 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 87 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
88 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 88 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
89 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 89 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
90 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 90 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
91 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 91 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
92 | 92 | ||
93 | // Intialise state | 93 | // Intialise state |
94 | setLength( mediaPlayerState->length() ); | 94 | setLength( mediaPlayerState->length() ); |
95 | setPosition( mediaPlayerState->position() ); | 95 | setPosition( mediaPlayerState->position() ); |
96 | setFullscreen( mediaPlayerState->fullscreen() ); | 96 | setFullscreen( mediaPlayerState->fullscreen() ); |
97 | setPaused( mediaPlayerState->paused() ); | 97 | setPaused( mediaPlayerState->paused() ); |
98 | setPlaying( mediaPlayerState->playing() ); | 98 | setPlaying( mediaPlayerState->playing() ); |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | VideoWidget::~VideoWidget() { | 102 | VideoWidget::~VideoWidget() { |
103 | for ( int i = 0; i < 3; i++ ) | 103 | for ( int i = 0; i < 3; i++ ) |
104 | delete pixmaps[i]; | 104 | delete pixmaps[i]; |
105 | delete currentFrame; | 105 | delete currentFrame; |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | static bool videoSliderBeingMoved = FALSE; | 109 | static bool videoSliderBeingMoved = FALSE; |
110 | 110 | ||
111 | 111 | ||
112 | void VideoWidget::sliderPressed() { | 112 | void VideoWidget::sliderPressed() { |
113 | videoSliderBeingMoved = TRUE; | 113 | videoSliderBeingMoved = TRUE; |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | void VideoWidget::sliderReleased() { | 117 | void VideoWidget::sliderReleased() { |
118 | videoSliderBeingMoved = FALSE; | 118 | videoSliderBeingMoved = FALSE; |
119 | if ( slider->width() == 0 ) | 119 | if ( slider->width() == 0 ) |
120 | return; | 120 | return; |
121 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 121 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
122 | mediaPlayerState->setPosition( val ); | 122 | mediaPlayerState->setPosition( val ); |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | void VideoWidget::setPosition( long i ) { | 126 | void VideoWidget::setPosition( long i ) { |
127 | updateSlider( i, mediaPlayerState->length() ); | 127 | updateSlider( i, mediaPlayerState->length() ); |
128 | } | 128 | } |
129 | 129 | ||
130 | 130 | ||
131 | void VideoWidget::setLength( long max ) { | 131 | void VideoWidget::setLength( long max ) { |
132 | updateSlider( mediaPlayerState->position(), max ); | 132 | updateSlider( mediaPlayerState->position(), max ); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | void VideoWidget::setView( char view ) { | 136 | void VideoWidget::setView( char view ) { |
137 | if ( view == 'v' ) { | 137 | if ( view == 'v' ) { |
138 | makeVisible(); | 138 | makeVisible(); |
139 | } else { | 139 | } else { |
140 | // Effectively blank the view next time we show it so it looks nicer | 140 | // Effectively blank the view next time we show it so it looks nicer |
141 | scaledWidth = 0; | 141 | scaledWidth = 0; |
142 | scaledHeight = 0; | 142 | scaledHeight = 0; |
143 | hide(); | 143 | hide(); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | void VideoWidget::updateSlider( long i, long max ) { | 148 | void VideoWidget::updateSlider( long i, long max ) { |
149 | // Will flicker too much if we don't do this | 149 | // Will flicker too much if we don't do this |
150 | if ( max == 0 ) | 150 | if ( max == 0 ) |
151 | return; | 151 | return; |
152 | int width = slider->width(); | 152 | int width = slider->width(); |
153 | int val = int((double)i * width / max); | 153 | int val = int((double)i * width / max); |
154 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { | 154 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { |
155 | if ( slider->value() != val ) | 155 | if ( slider->value() != val ) |
156 | slider->setValue( val ); | 156 | slider->setValue( val ); |
157 | if ( slider->maxValue() != width ) | 157 | if ( slider->maxValue() != width ) |
158 | slider->setMaxValue( width ); | 158 | slider->setMaxValue( width ); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | void VideoWidget::setToggleButton( int i, bool down ) { | 163 | void VideoWidget::setToggleButton( int i, bool down ) { |
164 | if ( down != videoButtons[i].isDown ) | 164 | if ( down != videoButtons[i].isDown ) |
165 | toggleButton( i ); | 165 | toggleButton( i ); |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
169 | void VideoWidget::toggleButton( int i ) { | 169 | void VideoWidget::toggleButton( int i ) { |
170 | videoButtons[i].isDown = !videoButtons[i].isDown; | 170 | videoButtons[i].isDown = !videoButtons[i].isDown; |
171 | QPainter p(this); | 171 | QPainter p(this); |
172 | paintButton ( &p, i ); | 172 | paintButton ( &p, i ); |
173 | } | 173 | } |
174 | 174 | ||
175 | 175 | ||
176 | void VideoWidget::paintButton( QPainter *p, int i ) { | 176 | void VideoWidget::paintButton( QPainter *p, int i ) { |
177 | int x = videoButtons[i].xPos; | 177 | int x = videoButtons[i].xPos; |
178 | int y = videoButtons[i].yPos; | 178 | int y = videoButtons[i].yPos; |
179 | int offset = 10 + videoButtons[i].isDown; | 179 | int offset = 10 + videoButtons[i].isDown; |
180 | p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); | 180 | p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); |
181 | p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); | 181 | p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 185 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
186 | for ( int i = 0; i < numButtons; i++ ) { | 186 | for ( int i = 0; i < numButtons; i++ ) { |
187 | int x = videoButtons[i].xPos; | 187 | int x = videoButtons[i].xPos; |
188 | int y = videoButtons[i].yPos; | 188 | int y = videoButtons[i].yPos; |
189 | if ( event->state() == QMouseEvent::LeftButton ) { | 189 | if ( event->state() == QMouseEvent::LeftButton ) { |
190 | // The test to see if the mouse click is inside the circular button or not | 190 | // The test to see if the mouse click is inside the circular button or not |
191 | // (compared with the radius squared to avoid a square-root of our distance) | 191 | // (compared with the radius squared to avoid a square-root of our distance) |
192 | int radius = 16; | 192 | int radius = 16; |
193 | QPoint center = QPoint( x + radius, y + radius ); | 193 | QPoint center = QPoint( x + radius, y + radius ); |
194 | QPoint dXY = center - event->pos(); | 194 | QPoint dXY = center - event->pos(); |
195 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 195 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); |
196 | bool isOnButton = dist <= (radius * radius); | 196 | bool isOnButton = dist <= (radius * radius); |
197 | if ( isOnButton != videoButtons[i].isHeld ) { | 197 | if ( isOnButton != videoButtons[i].isHeld ) { |
198 | videoButtons[i].isHeld = isOnButton; | 198 | videoButtons[i].isHeld = isOnButton; |
199 | toggleButton(i); | 199 | toggleButton(i); |
200 | } | 200 | } |
201 | } else { | 201 | } else { |
202 | if ( videoButtons[i].isHeld ) { | 202 | if ( videoButtons[i].isHeld ) { |
203 | videoButtons[i].isHeld = FALSE; | 203 | videoButtons[i].isHeld = FALSE; |
204 | if ( !videoButtons[i].isToggle ) | 204 | if ( !videoButtons[i].isToggle ) |
205 | setToggleButton( i, FALSE ); | 205 | setToggleButton( i, FALSE ); |
206 | switch (i) { | 206 | switch (i) { |
207 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | 207 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; |
208 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 208 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; |
209 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 209 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
210 | case VideoNext: mediaPlayerState->setNext(); return; | 210 | case VideoNext: mediaPlayerState->setNext(); return; |
211 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 211 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
212 | case VideoPlayList: mediaPlayerState->setList(); return; | 212 | case VideoPlayList: mediaPlayerState->setList(); return; |
213 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 213 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
214 | } | 214 | } |
215 | } | 215 | } |
216 | } | 216 | } |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 221 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
222 | mouseMoveEvent( event ); | 222 | mouseMoveEvent( event ); |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 226 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
227 | if ( mediaPlayerState->fullscreen() ) { | 227 | if ( mediaPlayerState->fullscreen() ) { |
228 | mediaPlayerState->setFullscreen( FALSE ); | 228 | mediaPlayerState->setFullscreen( FALSE ); |
229 | makeVisible(); | 229 | makeVisible(); |
230 | } else { | 230 | } else { |
231 | mouseMoveEvent( event ); | 231 | mouseMoveEvent( event ); |
232 | } | 232 | } |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | void VideoWidget::makeVisible() { | 236 | void VideoWidget::makeVisible() { |
237 | if ( mediaPlayerState->fullscreen() ) { | 237 | if ( mediaPlayerState->fullscreen() ) { |
238 | setBackgroundMode( QWidget::NoBackground ); | 238 | setBackgroundMode( QWidget::NoBackground ); |
239 | showFullScreen(); | 239 | showFullScreen(); |
240 | resize( qApp->desktop()->size() ); | 240 | resize( qApp->desktop()->size() ); |
241 | slider->hide(); | 241 | slider->hide(); |
242 | } else { | 242 | } else { |
243 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 243 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); |
244 | showNormal(); | 244 | showNormal(); |
245 | showMaximized(); | 245 | showMaximized(); |
246 | slider->show(); | 246 | slider->show(); |
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
250 | 250 | ||
251 | void VideoWidget::paintEvent( QPaintEvent * ) { | 251 | void VideoWidget::paintEvent( QPaintEvent * ) { |
252 | QPainter p( this ); | 252 | QPainter p( this ); |
253 | 253 | ||
254 | if ( mediaPlayerState->fullscreen() ) { | 254 | if ( mediaPlayerState->fullscreen() ) { |
255 | // Clear the background | 255 | // Clear the background |
256 | p.setBrush( QBrush( Qt::black ) ); | 256 | p.setBrush( QBrush( Qt::black ) ); |
257 | p.drawRect( rect() ); | 257 | p.drawRect( rect() ); |
258 | 258 | ||
259 | // Draw the current frame | 259 | // Draw the current frame |
260 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen | 260 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen |
261 | } else { | 261 | } else { |
262 | // draw border | 262 | // draw border |
263 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); | 263 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); |
264 | 264 | ||
265 | // Clear the movie screen first | 265 | // Clear the movie screen first |
266 | p.setBrush( QBrush( Qt::black ) ); | 266 | p.setBrush( QBrush( Qt::black ) ); |
267 | p.drawRect( 9, 20, 220, 160 ); | 267 | p.drawRect( 9, 20, 220, 160 ); |
268 | 268 | ||
269 | // draw current frame (centrally positioned from scaling to maintain aspect ratio) | 269 | // draw current frame (centrally positioned from scaling to maintain aspect ratio) |
270 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 270 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); |
271 | 271 | ||
272 | // draw the buttons | 272 | // draw the buttons |
273 | for ( int i = 0; i < numButtons; i++ ) | 273 | for ( int i = 0; i < numButtons; i++ ) |
274 | paintButton( &p, i ); | 274 | paintButton( &p, i ); |
275 | 275 | ||
276 | // draw the slider | 276 | // draw the slider |
277 | slider->repaint( TRUE ); | 277 | slider->repaint( TRUE ); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | 281 | ||
282 | void VideoWidget::closeEvent( QCloseEvent* ) { | 282 | void VideoWidget::closeEvent( QCloseEvent* ) { |
283 | mediaPlayerState->setList(); | 283 | mediaPlayerState->setList(); |
284 | } | 284 | } |
285 | 285 | ||
286 | 286 | ||
287 | bool VideoWidget::playVideo() { | 287 | bool VideoWidget::playVideo() { |
288 | bool result = FALSE; | 288 | bool result = FALSE; |
289 | 289 | ||
290 | int stream = 0; | 290 | int stream = 0; |
291 | 291 | ||
292 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); | 292 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); |
293 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); | 293 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); |
294 | int dd = QPixmap::defaultDepth(); | 294 | int dd = QPixmap::defaultDepth(); |
295 | int w = height(); | 295 | int w = height(); |
296 | int h = width(); | 296 | int h = width(); |
297 | 297 | ||
298 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; | 298 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; |
299 | 299 | ||
300 | if ( mediaPlayerState->fullscreen() ) { | 300 | if ( mediaPlayerState->fullscreen() ) { |
301 | #ifdef USE_DIRECT_PAINTER | 301 | #ifdef USE_DIRECT_PAINTER |
302 | QDirectPainter p(this); | 302 | QDirectPainter p(this); |
303 | 303 | ||
304 | if ( ( qt_screen->transformOrientation() == 3 ) && | 304 | if ( ( qt_screen->transformOrientation() == 3 ) && |
305 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { | 305 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { |
306 | 306 | ||
307 | w = 320; | 307 | w = 320; |
308 | h = 240; | 308 | h = 240; |
309 | 309 | ||
310 | if ( mediaPlayerState->scaled() ) { | 310 | if ( mediaPlayerState->scaled() ) { |
311 | // maintain aspect ratio | 311 | // maintain aspect ratio |
312 | if ( w * sh > sw * h ) | 312 | if ( w * sh > sw * h ) |
313 | w = sw * h / sh; | 313 | w = sw * h / sh; |
314 | else | 314 | else |
315 | h = sh * w / sw; | 315 | h = sh * w / sw; |
316 | } else { | 316 | } else { |
317 | w = sw; | 317 | w = sw; |
318 | h = sh; | 318 | h = sh; |
319 | } | 319 | } |
320 | 320 | ||
321 | w--; // we can't allow libmpeg to overwrite. | 321 | w--; // we can't allow libmpeg to overwrite. |
322 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); | 322 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); |
323 | 323 | ||
324 | int ox = roff.x() - height() + 2 + (height() - w) / 2; | 324 | int ox = roff.x() - height() + 2 + (height() - w) / 2; |
325 | int oy = roff.y() + (width() - h) / 2; | 325 | int oy = roff.y() + (width() - h) / 2; |
326 | int sx = 0, sy = 0; | 326 | int sx = 0, sy = 0; |
327 | 327 | ||
328 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; | 328 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; |
329 | fp += dd * ox / 8; | 329 | fp += dd * ox / 8; |
330 | uchar **jt = new uchar*[h]; | 330 | uchar **jt = new uchar*[h]; |
331 | for ( int i = h; i; i-- ) { | 331 | for ( int i = h; i; i-- ) { |
332 | jt[h - i] = fp; | 332 | jt[h - i] = fp; |
333 | fp += p.lineStep(); | 333 | fp += p.lineStep(); |
334 | } | 334 | } |
335 | 335 | ||
336 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; | 336 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; |
337 | 337 | ||
338 | delete [] jt; | 338 | delete [] jt; |
339 | } else { | 339 | } else { |
340 | #endif | 340 | #endif |
341 | QPainter p(this); | 341 | QPainter p(this); |
342 | 342 | ||
343 | w = 320; | 343 | w = 320; |
344 | h = 240; | 344 | h = 240; |
345 | 345 | ||
346 | if ( mediaPlayerState->scaled() ) { | 346 | if ( mediaPlayerState->scaled() ) { |
347 | // maintain aspect ratio | 347 | // maintain aspect ratio |
348 | if ( w * sh > sw * h ) | 348 | if ( w * sh > sw * h ) |
349 | w = sw * h / sh; | 349 | w = sw * h / sh; |
350 | else | 350 | else |
351 | h = sh * w / sw; | 351 | h = sh * w / sw; |
352 | } else { | 352 | } else { |
353 | w = sw; | 353 | w = sw; |
354 | h = sh; | 354 | h = sh; |
355 | } | 355 | } |
356 | 356 | ||
357 | int bytes = ( dd == 16 ) ? 2 : 4; | 357 | int bytes = ( dd == 16 ) ? 2 : 4; |
358 | QImage tempFrame( w, h, bytes << 3 ); | 358 | QImage tempFrame( w, h, bytes << 3 ); |
359 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), | 359 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), |
360 | 0, 0, sw, sh, w, h, format, 0) == 0; | 360 | 0, 0, sw, sh, w, h, format, 0) == 0; |
361 | if ( result && mediaPlayerState->fullscreen() ) { | 361 | if ( result && mediaPlayerState->fullscreen() ) { |
362 | 362 | ||
363 | int rw = h, rh = w; | 363 | int rw = h, rh = w; |
364 | QImage rotatedFrame( rw, rh, bytes << 3 ); | 364 | QImage rotatedFrame( rw, rh, bytes << 3 ); |
365 | 365 | ||
366 | ushort* in = (ushort*)tempFrame.bits(); | 366 | ushort* in = (ushort*)tempFrame.bits(); |
367 | ushort* out = (ushort*)rotatedFrame.bits(); | 367 | ushort* out = (ushort*)rotatedFrame.bits(); |
368 | int spl = rotatedFrame.bytesPerLine() / bytes; | 368 | int spl = rotatedFrame.bytesPerLine() / bytes; |
369 | for (int x=0; x<h; x++) { | 369 | for (int x=0; x<h; x++) { |
370 | if ( bytes == 2 ) { | 370 | if ( bytes == 2 ) { |
371 | ushort* lout = out++ + (w - 1)*spl; | 371 | ushort* lout = out++ + (w - 1)*spl; |
372 | for (int y=0; y<w; y++) { | 372 | for (int y=0; y<w; y++) { |
373 | *lout=*in++; | 373 | *lout=*in++; |
374 | lout-=spl; | 374 | lout-=spl; |
375 | } | 375 | } |
376 | } else { | 376 | } else { |
377 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; | 377 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; |
378 | for (int y=0; y<w; y++) { | 378 | for (int y=0; y<w; y++) { |
379 | *lout=*((ulong*)in)++; | 379 | *lout=*((ulong*)in)++; |
380 | lout-=spl; | 380 | lout-=spl; |
381 | } | 381 | } |
382 | } | 382 | } |
383 | } | 383 | } |
384 | 384 | ||
385 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); | 385 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); |
386 | } | 386 | } |
387 | #ifdef USE_DIRECT_PAINTER | 387 | #ifdef USE_DIRECT_PAINTER |
388 | } | 388 | } |
389 | #endif | 389 | #endif |
390 | } else { | 390 | } else { |
391 | 391 | ||
392 | w = 220; | 392 | w = 220; |
393 | h = 160; | 393 | h = 160; |
394 | 394 | ||
395 | // maintain aspect ratio | 395 | // maintain aspect ratio |
396 | if ( w * sh > sw * h ) | 396 | if ( w * sh > sw * h ) |
397 | w = sw * h / sh; | 397 | w = sw * h / sh; |
398 | else | 398 | else |
399 | h = sh * w / sw; | 399 | h = sh * w / sw; |
400 | 400 | ||
401 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; | 401 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; |
402 | 402 | ||
403 | QPainter p( this ); | 403 | QPainter p( this ); |
404 | 404 | ||
405 | // Image changed size, therefore need to blank the possibly unpainted regions first | 405 | // Image changed size, therefore need to blank the possibly unpainted regions first |
406 | if ( scaledWidth != w || scaledHeight != h ) { | 406 | if ( scaledWidth != w || scaledHeight != h ) { |
407 | p.setBrush( QBrush( Qt::black ) ); | 407 | p.setBrush( QBrush( Qt::black ) ); |
408 | p.drawRect( 9, 20, 220, 160 ); | 408 | p.drawRect( 9, 20, 220, 160 ); |
409 | } | 409 | } |
410 | 410 | ||
411 | scaledWidth = w; | 411 | scaledWidth = w; |
412 | scaledHeight = h; | 412 | scaledHeight = h; |
413 | 413 | ||
414 | if ( result ) { | 414 | if ( result ) { |
415 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 415 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); |
416 | } | 416 | } |
417 | 417 | ||
418 | } | 418 | } |
419 | 419 | ||
420 | return result; | 420 | return result; |
421 | } | 421 | } |
422 | 422 | ||
423 | 423 | ||
diff --git a/core/multimedia/opieplayer/wavplugin/Makefile.in b/core/multimedia/opieplayer/wavplugin/Makefile.in index bcbe7f2..a46b925 100644 --- a/core/multimedia/opieplayer/wavplugin/Makefile.in +++ b/core/multimedia/opieplayer/wavplugin/Makefile.in | |||
@@ -55,55 +55,57 @@ OBJMOC = | |||
55 | .c.o: | 55 | .c.o: |
56 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< | 56 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< |
57 | 57 | ||
58 | ####### Build rules | 58 | ####### Build rules |
59 | 59 | ||
60 | 60 | ||
61 | all: $(DESTDIR)$(SYSCONF_LINK_TARGET) | 61 | all: $(DESTDIR)$(SYSCONF_LINK_TARGET) |
62 | 62 | ||
63 | $(DESTDIR)$(SYSCONF_LINK_TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) | 63 | $(DESTDIR)$(SYSCONF_LINK_TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) |
64 | $(SYSCONF_LINK_LIB) | 64 | $(SYSCONF_LINK_LIB) |
65 | 65 | ||
66 | moc: $(SRCMOC) | 66 | moc: $(SRCMOC) |
67 | 67 | ||
68 | tmake: | 68 | tmake: |
69 | tmake wavplugin.pro | 69 | tmake wavplugin.pro |
70 | 70 | ||
71 | clean: | 71 | clean: |
72 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) | 72 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) |
73 | -rm -f *~ core | 73 | -rm -f *~ core |
74 | -rm -f allmoc.cpp | 74 | -rm -f allmoc.cpp |
75 | 75 | ||
76 | ####### Extension Modules | 76 | ####### Extension Modules |
77 | 77 | ||
78 | listpromodules: | 78 | listpromodules: |
79 | @echo | 79 | @echo |
80 | 80 | ||
81 | listallmodules: | 81 | listallmodules: |
82 | @echo | 82 | @echo |
83 | 83 | ||
84 | listaddonpromodules: | 84 | listaddonpromodules: |
85 | @echo | 85 | @echo |
86 | 86 | ||
87 | listaddonentmodules: | 87 | listaddonentmodules: |
88 | @echo | 88 | @echo |
89 | 89 | ||
90 | 90 | ||
91 | REQUIRES= | 91 | REQUIRES= |
92 | 92 | ||
93 | ####### Sub-libraries | 93 | ####### Sub-libraries |
94 | 94 | ||
95 | 95 | ||
96 | ###### Combined headers | 96 | ###### Combined headers |
97 | 97 | ||
98 | 98 | ||
99 | 99 | ||
100 | ####### Compile | 100 | ####### Compile |
101 | 101 | ||
102 | wavplugin.o: wavplugin.cpp \ | 102 | wavplugin.o: wavplugin.cpp \ |
103 | wavplugin.h | 103 | wavplugin.h \ |
104 | ../mediaplayerplugininterface.h | ||
104 | 105 | ||
105 | wavpluginimpl.o: wavpluginimpl.cpp \ | 106 | wavpluginimpl.o: wavpluginimpl.cpp \ |
106 | wavplugin.h \ | 107 | wavplugin.h \ |
108 | ../mediaplayerplugininterface.h \ | ||
107 | wavpluginimpl.h | 109 | wavpluginimpl.h |
108 | 110 | ||
109 | 111 | ||
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp index a6bd974..7f63b3b 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp | |||
@@ -1,334 +1,341 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
20 | #include <stdio.h> | 22 | #include <stdio.h> |
21 | #include <stdarg.h> | 23 | #include <stdarg.h> |
22 | #include <stdlib.h> | 24 | #include <stdlib.h> |
23 | #include <errno.h> | 25 | #include <errno.h> |
24 | #include <unistd.h> | 26 | #include <unistd.h> |
25 | #include <qfile.h> | 27 | #include <qfile.h> |
26 | #include "wavplugin.h" | 28 | #include "wavplugin.h" |
27 | 29 | ||
28 | 30 | ||
29 | //#define debugMsg(a) qDebug(a) | 31 | //#define debugMsg(a) qDebug(a) |
30 | #define debugMsg(a) | 32 | #define debugMsg(a) |
31 | 33 | ||
32 | 34 | ||
33 | struct RiffChunk { | 35 | struct RiffChunk { |
34 | char id[4]; | 36 | char id[4]; |
35 | Q_UINT32 size; | 37 | Q_UINT32 size; |
36 | char data[4]; | 38 | char data[4]; |
37 | }; | 39 | }; |
38 | 40 | ||
39 | 41 | ||
40 | struct ChunkData { | 42 | struct ChunkData { |
41 | Q_INT16 formatTag; | 43 | Q_INT16 formatTag; |
42 | Q_INT16 channels; | 44 | Q_INT16 channels; |
43 | Q_INT32 samplesPerSec; | 45 | Q_INT32 samplesPerSec; |
44 | Q_INT32 avgBytesPerSec; | 46 | Q_INT32 avgBytesPerSec; |
45 | Q_INT16 blockAlign; | 47 | Q_INT16 blockAlign; |
46 | Q_INT16 wBitsPerSample; | 48 | Q_INT16 wBitsPerSample; |
47 | }; | 49 | }; |
48 | 50 | ||
49 | 51 | ||
50 | const int sound_buffer_size = 4096; | 52 | const int sound_buffer_size = 512; // 4096; // you got to be kidding right? |
51 | 53 | ||
52 | 54 | ||
53 | class WavPluginData { | 55 | class WavPluginData { |
54 | public: | 56 | public: |
55 | QFile *input; | 57 | QFile *input; |
56 | 58 | ||
57 | int wavedata_remaining; | 59 | int wavedata_remaining; |
58 | ChunkData chunkdata; | 60 | ChunkData chunkdata; |
59 | RiffChunk chunk; | 61 | RiffChunk chunk; |
60 | uchar data[sound_buffer_size+32]; // +32 to handle badly aligned input data | 62 | uchar data[sound_buffer_size+32]; // +32 to handle badly aligned input data |
61 | int out,max; | 63 | int out,max; |
62 | int samples_due; | 64 | int samples_due; |
63 | int samples; | 65 | int samples; |
64 | 66 | ||
65 | WavPluginData() { | 67 | WavPluginData() { |
66 | max = out = sound_buffer_size; | 68 | max = out = sound_buffer_size; |
67 | wavedata_remaining = 0; | 69 | wavedata_remaining = 0; |
68 | samples_due = 0; | 70 | samples_due = 0; |
69 | samples = -1; | 71 | samples = -1; |
70 | } | 72 | } |
71 | 73 | ||
72 | // expands out samples to the frequency of 44kHz | 74 | // expands out samples to the frequency of 44kHz |
73 | bool add( short *output, long count, long& done, bool stereo ) | 75 | bool add( short *output, long count, long& done, bool stereo ) |
74 | { | 76 | { |
75 | done = 0; | 77 | done = 0; |
78 | qApp->processEvents(); | ||
76 | 79 | ||
77 | if ( input == 0 ) { | 80 | if ( input == 0 ) { |
78 | qDebug("no input"); | 81 | qDebug("no input"); |
79 | return FALSE; | 82 | return FALSE; |
80 | } | 83 | } |
81 | 84 | ||
82 | while ( count ) { | 85 | while ( count ) { |
83 | int l,r; | 86 | int l,r; |
84 | if ( getSample(l, r) == FALSE ) { | 87 | if ( getSample(l, r) == FALSE ) { |
85 | qDebug("didn't get sample"); | 88 | qDebug("didn't get sample"); |
86 | return FALSE; | 89 | return FALSE; |
87 | } | 90 | } |
88 | samples_due += 44100; | 91 | samples_due += chunkdata.samplesPerSec; |
89 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { | 92 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { |
90 | *output++ = l; | 93 | *output++ = l; |
91 | if ( stereo ) | 94 | if ( stereo ) |
92 | *output++ = r; | 95 | *output++ = r; |
93 | samples_due -= chunkdata.samplesPerSec; | 96 | samples_due -= chunkdata.samplesPerSec; |
94 | count--; | 97 | count--; |
95 | done++; | 98 | done++; |
96 | } | 99 | } |
97 | } | 100 | } |
98 | |||
99 | return TRUE; | 101 | return TRUE; |
100 | } | 102 | } |
101 | 103 | ||
102 | bool initialise() { | 104 | bool initialise() { |
103 | if ( input == 0 ) | 105 | if ( input == 0 ) |
104 | return FALSE; | 106 | return FALSE; |
105 | 107 | ||
106 | wavedata_remaining = -1; | 108 | wavedata_remaining = -1; |
107 | 109 | ||
108 | while ( wavedata_remaining == -1 ) { | 110 | while ( wavedata_remaining == -1 ) { |
109 | // Keep reading chunks... | 111 | // Keep reading chunks... |
110 | const int n = sizeof(chunk) - sizeof(chunk.data); | 112 | const int n = sizeof(chunk) - sizeof(chunk.data); |
111 | int t = input->readBlock( (char*)&chunk, n ); | 113 | int t = input->readBlock( (char*)&chunk, n ); |
112 | if ( t != n ) { | 114 | if ( t != n ) { |
113 | if ( t == -1 ) | 115 | if ( t == -1 ) |
114 | return FALSE; | 116 | return FALSE; |
115 | return TRUE; | 117 | return TRUE; |
116 | } | 118 | } |
117 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { | 119 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { |
118 | samples = wavedata_remaining = chunk.size; | 120 | samples = wavedata_remaining = chunk.size; |
119 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { | 121 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { |
120 | char d[4]; | 122 | char d[4]; |
121 | if ( input->readBlock(d,4) != 4 ) { | 123 | if ( input->readBlock(d,4) != 4 ) { |
122 | return FALSE; | 124 | return FALSE; |
123 | } | 125 | } |
124 | if ( qstrncmp(d,"WAVE",4) != 0 ) { | 126 | if ( qstrncmp(d,"WAVE",4) != 0 ) { |
125 | // skip | 127 | // skip |
126 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) { | 128 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) { |
127 | return FALSE; | 129 | return FALSE; |
128 | } | 130 | } |
129 | } | 131 | } |
130 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { | 132 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { |
131 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { | 133 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { |
132 | return FALSE; | 134 | return FALSE; |
133 | } | 135 | } |
134 | #define WAVE_FORMAT_PCM 1 | 136 | #define WAVE_FORMAT_PCM 1 |
135 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { | 137 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { |
136 | qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); | 138 | qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); |
137 | return FALSE; | 139 | return FALSE; |
138 | } | 140 | } |
139 | } else { | 141 | } else { |
140 | // ignored chunk | 142 | // ignored chunk |
141 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { | 143 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { |
142 | return FALSE; | 144 | return FALSE; |
143 | } | 145 | } |
144 | } | 146 | } |
145 | } // while | 147 | } // while |
146 | 148 | qDebug("bits %d", chunkdata.wBitsPerSample); | |
147 | return TRUE; | 149 | return TRUE; |
148 | } | 150 | } |
149 | 151 | ||
150 | 152 | ||
151 | // gets a sample from the file | 153 | // gets a sample from the file |
152 | bool getSample(int& l, int& r) | 154 | bool getSample(int& l, int& r) |
153 | { | 155 | { |
154 | l = r = 0; | 156 | l = r = 0; |
155 | 157 | ||
156 | if ( input == 0 ) | 158 | if ( input == 0 ) |
157 | return FALSE; | 159 | return FALSE; |
158 | 160 | ||
159 | if ( (wavedata_remaining < 0) || !max ) | 161 | if ( (wavedata_remaining < 0) || !max ) |
160 | return FALSE; | 162 | return FALSE; |
161 | 163 | ||
162 | if ( out >= max ) { | 164 | if ( out >= max ) { |
163 | max = input->readBlock( (char*)data, (uint)QMIN(sound_buffer_size,wavedata_remaining) ); | 165 | max = input->readBlock( (char*)data, (uint)QMIN(sound_buffer_size,wavedata_remaining) ); |
164 | 166 | ||
165 | wavedata_remaining -= max; | 167 | wavedata_remaining -= max; |
166 | 168 | ||
167 | out = 0; | 169 | out = 0; |
168 | if ( max <= 0 ) { | 170 | if ( max <= 0 ) { |
169 | max = 0; | 171 | max = 0; |
170 | return TRUE; | 172 | return TRUE; |
171 | } | 173 | } |
172 | } | 174 | } |
173 | if ( chunkdata.wBitsPerSample == 8 ) { | 175 | if ( chunkdata.wBitsPerSample == 8 ) { |
174 | l = (data[out++] - 128) * 128; | 176 | l = (data[out++] - 128) * 128; |
175 | } else { | 177 | } else { |
176 | l = ((short*)data)[out/2]; | 178 | l = ((short*)data)[out/2]; |
177 | out += 2; | 179 | out += 2; |
178 | } | 180 | } |
179 | if ( chunkdata.channels == 1 ) { | 181 | if ( chunkdata.channels == 1 ) { |
180 | r = l; | 182 | r = l; |
181 | } else { | 183 | } else { |
182 | if ( chunkdata.wBitsPerSample == 8 ) { | 184 | if ( chunkdata.wBitsPerSample == 8 ) { |
183 | r = (data[out++] - 128) * 128; | 185 | r = (data[out++] - 128) * 128; |
184 | } else { | 186 | } else { |
185 | r = ((short*)data)[out/2]; | 187 | r = ((short*)data)[out/2]; |
186 | out += 2; | 188 | out += 2; |
187 | } | 189 | } |
188 | } | 190 | } |
189 | return TRUE; | 191 | return TRUE; |
190 | } // getSample | 192 | } // getSample |
191 | 193 | ||
192 | }; | 194 | }; |
193 | 195 | ||
194 | 196 | ||
195 | WavPlugin::WavPlugin() { | 197 | WavPlugin::WavPlugin() { |
196 | d = new WavPluginData; | 198 | d = new WavPluginData; |
197 | d->input = 0; | 199 | d->input = 0; |
198 | } | 200 | } |
199 | 201 | ||
200 | 202 | ||
201 | WavPlugin::~WavPlugin() { | 203 | WavPlugin::~WavPlugin() { |
202 | close(); | 204 | close(); |
203 | delete d; | 205 | delete d; |
204 | } | 206 | } |
205 | 207 | ||
206 | 208 | ||
207 | bool WavPlugin::isFileSupported( const QString& path ) { | 209 | bool WavPlugin::isFileSupported( const QString& path ) { |
208 | debugMsg( "WavPlugin::isFileSupported" ); | 210 | // qDebug( "WavPlugin::isFileSupported" ); |
209 | 211 | ||
210 | char *ext = strrchr( path.latin1(), '.' ); | 212 | char *ext = strrchr( path.latin1(), '.' ); |
211 | 213 | ||
212 | // Test file extension | 214 | // Test file extension |
213 | if ( ext ) { | 215 | if ( ext ) { |
214 | if ( strncasecmp(ext, ".raw", 4) == 0 ) | 216 | if ( strncasecmp(ext, ".raw", 4) == 0 ) |
215 | return TRUE; | 217 | return TRUE; |
216 | if ( strncasecmp(ext, ".wav", 4) == 0 ) | 218 | if ( strncasecmp(ext, ".wav", 4) == 0 ) |
217 | return TRUE; | 219 | return TRUE; |
218 | if ( strncasecmp(ext, ".wave", 4) == 0 ) | 220 | if ( strncasecmp(ext, ".wave", 4) == 0 ) |
219 | return TRUE; | 221 | return TRUE; |
220 | } | 222 | } |
221 | 223 | ||
222 | return FALSE; | 224 | return FALSE; |
223 | } | 225 | } |
224 | 226 | ||
225 | 227 | ||
226 | bool WavPlugin::open( const QString& path ) { | 228 | bool WavPlugin::open( const QString& path ) { |
227 | debugMsg( "WavPlugin::open" ); | 229 | // qDebug( "WavPlugin::open" ); |
228 | 230 | ||
229 | d->max = d->out = sound_buffer_size; | 231 | d->max = d->out = sound_buffer_size; |
230 | d->wavedata_remaining = 0; | 232 | d->wavedata_remaining = 0; |
231 | d->samples_due = 0; | 233 | d->samples_due = 0; |
232 | 234 | ||
233 | d->input = new QFile( path ); | 235 | d->input = new QFile( path ); |
234 | if ( d->input->open(IO_ReadOnly) == FALSE ) { | 236 | if ( d->input->open(IO_ReadOnly) == FALSE ) { |
235 | qDebug("couldn't open file"); | 237 | qDebug("couldn't open file"); |
236 | delete d->input; | 238 | delete d->input; |
237 | d->input = 0; | 239 | d->input = 0; |
238 | return FALSE; | 240 | return FALSE; |
239 | } | 241 | } |
240 | 242 | ||
241 | d->initialise(); | 243 | d->initialise(); |
242 | 244 | ||
243 | return TRUE; | 245 | return TRUE; |
244 | } | 246 | } |
245 | 247 | ||
246 | 248 | ||
247 | bool WavPlugin::close() { | 249 | bool WavPlugin::close() { |
248 | debugMsg( "WavPlugin::close" ); | 250 | // qDebug( "WavPlugin::close" ); |
249 | 251 | ||
250 | d->input->close(); | 252 | d->input->close(); |
251 | delete d->input; | 253 | delete d->input; |
252 | d->input = 0; | 254 | d->input = 0; |
253 | return TRUE; | 255 | return TRUE; |
254 | } | 256 | } |
255 | 257 | ||
256 | 258 | ||
257 | bool WavPlugin::isOpen() { | 259 | bool WavPlugin::isOpen() { |
258 | debugMsg( "WavPlugin::isOpen" ); | 260 | // qDebug( "WavPlugin::isOpen" ); |
259 | return ( d->input != 0 ); | 261 | return ( d->input != 0 ); |
260 | } | 262 | } |
261 | 263 | ||
262 | 264 | ||
263 | int WavPlugin::audioStreams() { | 265 | int WavPlugin::audioStreams() { |
264 | debugMsg( "WavPlugin::audioStreams" ); | 266 | // qDebug( "WavPlugin::audioStreams" ); |
265 | return 1; | 267 | return 1; |
266 | } | 268 | } |
267 | 269 | ||
268 | 270 | ||
269 | int WavPlugin::audioChannels( int ) { | 271 | int WavPlugin::audioChannels( int ) { |
270 | debugMsg( "WavPlugin::audioChannels" ); | 272 | // qDebug( "WavPlugin::audioChannels" ); |
271 | return 2; // ### Always scale audio to stereo samples | 273 | return d->chunkdata.channels;// 2; // ### Always scale audio to stereo samples |
272 | } | 274 | } |
273 | 275 | ||
274 | 276 | ||
275 | int WavPlugin::audioFrequency( int ) { | 277 | int WavPlugin::audioFrequency( int ) { |
276 | debugMsg( "WavPlugin::audioFrequency" ); | 278 | // qDebug( "WavPlugin::audioFrequency %d", d->chunkdata.samplesPerSec ); |
277 | return 44100; // ### Always scale to frequency of 44100 | 279 | return d->chunkdata.samplesPerSec; //44100; // ### Always scale to frequency of 44100 |
278 | } | 280 | } |
279 | 281 | ||
280 | 282 | ||
281 | int WavPlugin::audioSamples( int ) { | 283 | int WavPlugin::audioSamples( int ) { |
282 | debugMsg( "WavPlugin::audioSamples" ); | 284 | // qDebug( "WavPlugin::audioSamples" ); |
283 | return d->samples * 2 / d->chunkdata.channels; // ### Scaled samples will be made stereo, | 285 | return d->samples / d->chunkdata.channels/2; // ### Scaled samples will be made stereo, |
284 | // Therefore if source is mono we will double the number of samples | 286 | // Therefore if source is mono we will double the number of samples |
285 | } | 287 | } |
286 | 288 | ||
287 | 289 | ||
288 | bool WavPlugin::audioSetSample( long, int ) { | 290 | bool WavPlugin::audioSetSample( long, int ) { |
289 | debugMsg( "WavPlugin::audioSetSample" ); | 291 | // qDebug( "WavPlugin::audioSetSample" ); |
290 | return FALSE; | 292 | return FALSE; |
291 | } | 293 | } |
292 | 294 | ||
293 | 295 | ||
294 | long WavPlugin::audioGetSample( int ) { | 296 | long WavPlugin::audioGetSample( int ) { |
295 | debugMsg( "WavPlugin::audioGetSample" ); | 297 | // qDebug( "WavPlugin::audioGetSample" ); |
296 | return 0; | 298 | return 0; |
297 | } | 299 | } |
298 | 300 | ||
299 | /* | 301 | /* |
300 | bool WavPlugin::audioReadSamples( short *, int, long, int ) { | 302 | bool WavPlugin::audioReadSamples( short *, int, long, int ) { |
301 | debugMsg( "WavPlugin::audioReadSamples" ); | 303 | debugMsg( "WavPlugin::audioReadSamples" ); |
302 | return FALSE; | 304 | return FALSE; |
303 | } | 305 | } |
304 | 306 | ||
305 | 307 | ||
306 | bool WavPlugin::audioReReadSamples( short *, int, long, int ) { | 308 | bool WavPlugin::audioReReadSamples( short *, int, long, int ) { |
307 | debugMsg( "WavPlugin::audioReReadSamples" ); | 309 | debugMsg( "WavPlugin::audioReReadSamples" ); |
308 | return FALSE; | 310 | return FALSE; |
309 | } | 311 | } |
310 | 312 | ||
311 | 313 | ||
312 | bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) { | 314 | bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) { |
313 | debugMsg( "WavPlugin::audioReadMonoSamples" ); | 315 | debugMsg( "WavPlugin::audioReadMonoSamples" ); |
314 | return !d->add( output, samples, samplesMade, FALSE ); | 316 | return !d->add( output, samples, samplesMade, FALSE ); |
315 | } | 317 | } |
316 | 318 | ||
317 | 319 | ||
318 | bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { | 320 | bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { |
319 | debugMsg( "WavPlugin::audioReadStereoSamples" ); | 321 | debugMsg( "WavPlugin::audioReadStereoSamples" ); |
320 | return !d->add( output, samples, samplesMade, TRUE ); | 322 | return !d->add( output, samples, samplesMade, TRUE ); |
321 | } | 323 | } |
322 | */ | 324 | */ |
323 | 325 | ||
324 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { | 326 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { |
325 | debugMsg( "WavPlugin::audioReadSamples" ); | 327 | // qDebug( "WavPlugin::audioReadSamples" ); |
326 | return d->add( output, samples, samplesMade, channels != 1 ); | 328 | return d->add( output, samples, samplesMade, channels != 1 ); |
327 | } | 329 | } |
328 | 330 | ||
329 | double WavPlugin::getTime() { | 331 | double WavPlugin::getTime() { |
330 | debugMsg( "WavPlugin::getTime" ); | 332 | // qDebug( "WavPlugin::getTime" ); |
331 | return 0.0; | 333 | return 0.0; |
332 | } | 334 | } |
333 | 335 | ||
336 | int WavPlugin::audioBitsPerSample( int ) { | ||
337 | // qDebug( "WavPlugin::audioFormat %d", d->chunkdata.wBitsPerSample ); | ||
338 | return d->chunkdata.wBitsPerSample; // | ||
339 | } | ||
340 | |||
334 | 341 | ||
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.h b/core/multimedia/opieplayer/wavplugin/wavplugin.h index 64635ca..6afd67e 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.h +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.h | |||
@@ -1,97 +1,107 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
20 | #ifndef WAV_PLUGIN_H | 22 | #ifndef WAV_PLUGIN_H |
21 | #define WAV_PLUGIN_H | 23 | #define WAV_PLUGIN_H |
22 | 24 | ||
23 | 25 | ||
24 | #include <qstring.h> | 26 | #include <qstring.h> |
25 | #include <qapplication.h> | 27 | #include <qapplication.h> |
26 | #include "mediaplayerplugininterface.h" | 28 | #include "../mediaplayerplugininterface.h" |
29 | |||
30 | |||
31 | // #define OLD_MEDIAPLAYER_API | ||
27 | 32 | ||
28 | 33 | ||
29 | class WavPluginData; | 34 | class WavPluginData; |
30 | 35 | ||
31 | 36 | ||
32 | class WavPlugin : public MediaPlayerDecoder { | 37 | class WavPlugin : public MediaPlayerDecoder { |
33 | 38 | ||
34 | public: | 39 | public: |
35 | WavPlugin(); | 40 | WavPlugin(); |
36 | ~WavPlugin(); | 41 | ~WavPlugin(); |
37 | 42 | ||
38 | const char *pluginName() { return "WavPlugin"; } | 43 | const char *pluginName() { return "WavPlugin"; } |
39 | const char *pluginComment() { return "This is a simple plugin for playing wav files"; } | 44 | const char *pluginComment() { return "This is a simple plugin for playing wav files"; } |
40 | double pluginVersion() { return 1.0; } | 45 | double pluginVersion() { return 1.0; } |
41 | 46 | ||
42 | bool isFileSupported( const QString& ); | 47 | bool isFileSupported( const QString& ); |
43 | bool open( const QString& ); | 48 | bool open( const QString& ); |
44 | bool close(); | 49 | bool close(); |
45 | bool isOpen(); | 50 | bool isOpen(); |
46 | //const QString &fileInfo() { return strInfo = qApp->translate( "MediaPlayer", "No Information Available", "media plugin text" ); } | 51 | const QString &fileInfo() { return strInfo = ""; } |
47 | const QString &fileInfo() { return strInfo = QString(""); } | ||
48 | 52 | ||
49 | // If decoder doesn't support audio then return 0 here | 53 | // If decoder doesn't support audio then return 0 here |
50 | int audioStreams(); | 54 | int audioStreams(); |
51 | int audioChannels( int stream ); | 55 | int audioChannels( int stream ); |
52 | int audioFrequency( int stream ); | 56 | int audioFrequency( int stream ); |
57 | int audioBitsPerSample( int stream ); | ||
53 | int audioSamples( int stream ); | 58 | int audioSamples( int stream ); |
54 | bool audioSetSample( long sample, int stream ); | 59 | bool audioSetSample( long sample, int stream ); |
55 | long audioGetSample( int stream ); | 60 | long audioGetSample( int stream ); |
56 | //bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 61 | #ifdef OLD_MEDIAPLAYER_API |
57 | //bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 62 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
63 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | ||
64 | bool audioReadSamples( short *output, int channel, long samples, int stream ); | ||
65 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); | ||
66 | #else | ||
58 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); | 67 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); |
59 | //bool audioReadSamples( short *output, int channel, long samples, int stream ); | 68 | #endif |
60 | //bool audioReReadSamples( short *output, int channel, long samples, int stream ); | ||
61 | 69 | ||
62 | // If decoder doesn't support video then return 0 here | 70 | // If decoder doesn't support video then return 0 here |
63 | int videoStreams() { return 0; } | 71 | int videoStreams() { return 0; } |
64 | int videoWidth( int ) { return 0; } | 72 | int videoWidth( int ) { return 0; } |
65 | int videoHeight( int ) { return 0; } | 73 | int videoHeight( int ) { return 0; } |
66 | double videoFrameRate( int ) { return 0.0; } | 74 | double videoFrameRate( int ) { return 0.0; } |
67 | int videoFrames( int ) { return 0; } | 75 | int videoFrames( int ) { return 0; } |
68 | bool videoSetFrame( long, int ) { return FALSE; } | 76 | bool videoSetFrame( long, int ) { return FALSE; } |
69 | long videoGetFrame( int ) { return 0; } | 77 | long videoGetFrame( int ) { return 0; } |
70 | bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } | 78 | bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } |
71 | bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } | 79 | bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } |
72 | bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } | 80 | bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } |
73 | 81 | ||
74 | // Profiling | 82 | // Profiling |
75 | double getTime(); | 83 | double getTime(); |
76 | 84 | ||
77 | // Ignore if these aren't supported | 85 | // Ignore if these aren't supported |
78 | bool setSMP( int ) { return FALSE; } | 86 | bool setSMP( int ) { return FALSE; } |
79 | bool setMMX( bool ) { return FALSE; } | 87 | bool setMMX( bool ) { return FALSE; } |
80 | 88 | ||
81 | // Capabilities | 89 | // Capabilities |
82 | bool supportsAudio() { return TRUE; } | 90 | bool supportsAudio() { return TRUE; } |
83 | bool supportsVideo() { return FALSE; } | 91 | bool supportsVideo() { return FALSE; } |
84 | bool supportsYUV() { return FALSE; } | 92 | bool supportsYUV() { return FALSE; } |
85 | bool supportsMMX() { return TRUE; } | 93 | bool supportsMMX() { return TRUE; } |
86 | bool supportsSMP() { return FALSE; } | 94 | bool supportsSMP() { return FALSE; } |
87 | bool supportsStereo() { return TRUE; } | 95 | bool supportsStereo() { return TRUE; } |
88 | bool supportsScaling() { return FALSE; } | 96 | bool supportsScaling() { return FALSE; } |
89 | 97 | ||
98 | long getPlayTime() { return -1; } | ||
99 | |||
90 | private: | 100 | private: |
91 | WavPluginData *d; | 101 | WavPluginData *d; |
92 | QString strInfo; | 102 | QString strInfo; |
93 | 103 | ||
94 | }; | 104 | }; |
95 | 105 | ||
96 | 106 | ||
97 | #endif | 107 | #endif |