author | ar <ar> | 2004-05-02 17:04:41 (UTC) |
---|---|---|
committer | ar <ar> | 2004-05-02 17:04:41 (UTC) |
commit | 4d3379027557e251201b531896974a69ae4c665a (patch) (unidiff) | |
tree | 6e813be1aa29131f8f8e91f532f38f8a381e38f4 | |
parent | f8add41b2e0b0371754521b44d95f87fa70a6ff2 (diff) | |
download | opie-4d3379027557e251201b531896974a69ae4c665a.zip opie-4d3379027557e251201b531896974a69ae4c665a.tar.gz opie-4d3379027557e251201b531896974a69ae4c665a.tar.bz2 |
- convert qDebug to odebug
-rw-r--r-- | core/multimedia/opieplayer/audiodevice.cpp | 50 | ||||
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 63 | ||||
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.cpp | 72 | ||||
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol.cpp | 68 | ||||
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol_threaded.cpp | 54 | ||||
-rw-r--r-- | core/multimedia/opieplayer/mediaplayer.cpp | 26 | ||||
-rw-r--r-- | core/multimedia/opieplayer/mediaplayerstate.cpp | 34 | ||||
-rw-r--r-- | core/multimedia/opieplayer/modplug/memfile.cpp | 30 | ||||
-rw-r--r-- | core/multimedia/opieplayer/om3u.cpp | 28 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 19 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 176 | ||||
-rw-r--r-- | core/multimedia/opieplayer/videowidget.cpp | 39 | ||||
-rw-r--r-- | core/multimedia/opieplayer/vorbis/libtremorplugin.cpp | 31 | ||||
-rw-r--r-- | core/multimedia/opieplayer/wavplugin/wavplugin.cpp | 50 |
14 files changed, 402 insertions, 338 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index 355062b..9b64e07 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp | |||
@@ -7,47 +7,51 @@ | |||
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 | 20 | // L.J.Potter added better error code Fri 02-15-2002 14:37:47 |
21 | 21 | ||
22 | 22 | ||
23 | #include <stdlib.h> | ||
24 | #include <stdio.h> | ||
25 | #include <qpe/qpeapplication.h> | ||
26 | #include <qpe/config.h> | ||
27 | #include <qmessagebox.h> | ||
28 | |||
29 | #include "audiodevice.h" | 23 | #include "audiodevice.h" |
30 | 24 | ||
31 | 25 | /* OPIE */ | |
32 | #include <errno.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/config.h> | ||
28 | #include <opie2/odebug.h> | ||
33 | 29 | ||
34 | #if !defined(QT_NO_COP) | 30 | #if !defined(QT_NO_COP) |
35 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
36 | #endif | 32 | #endif |
37 | 33 | ||
34 | /* QT */ | ||
35 | #include <qmessagebox.h> | ||
36 | |||
37 | /* STD */ | ||
38 | #include <stdlib.h> | ||
39 | #include <stdio.h> | ||
40 | #include <errno.h> | ||
41 | |||
38 | #if defined(Q_WS_X11) || defined(Q_WS_QWS) | 42 | #if defined(Q_WS_X11) || defined(Q_WS_QWS) |
39 | #include <fcntl.h> | 43 | #include <fcntl.h> |
40 | #include <sys/ioctl.h> | 44 | #include <sys/ioctl.h> |
41 | #include <sys/soundcard.h> | 45 | #include <sys/soundcard.h> |
42 | #include <sys/stat.h> | 46 | #include <sys/stat.h> |
43 | #include <sys/time.h> | 47 | #include <sys/time.h> |
44 | #include <sys/types.h> | 48 | #include <sys/types.h> |
45 | #include <unistd.h> | 49 | #include <unistd.h> |
46 | #endif | 50 | #endif |
47 | 51 | ||
48 | #ifdef OPIE_SOUND_FRAGMENT_SHIFT | 52 | #ifdef OPIE_SOUND_FRAGMENT_SHIFT |
49 | static const int sound_fragment_shift = OPIE_SOUND_FRAGMENT_SHIFT; | 53 | static const int sound_fragment_shift = OPIE_SOUND_FRAGMENT_SHIFT; |
50 | #else | 54 | #else |
51 | static const int sound_fragment_shift = 16; | 55 | static const int sound_fragment_shift = 16; |
52 | #endif | 56 | #endif |
53 | static const int sound_fragment_bytes = (1<<sound_fragment_shift); | 57 | static const int sound_fragment_bytes = (1<<sound_fragment_shift); |
@@ -132,54 +136,54 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, | |||
132 | #endif | 136 | #endif |
133 | if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) | 137 | if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) |
134 | perror("ioctl(\"MIXER_WRITE\")"); | 138 | perror("ioctl(\"MIXER_WRITE\")"); |
135 | close( mixerHandle ); | 139 | close( mixerHandle ); |
136 | } else | 140 | } else |
137 | perror("open(\"/dev/mixer\")"); | 141 | perror("open(\"/dev/mixer\")"); |
138 | 142 | ||
139 | # else | 143 | # else |
140 | // This is the way this has to be done now I guess, doesn't allow for | 144 | // This is the way this has to be done now I guess, doesn't allow for |
141 | // independant right and left channel setting, or setting for different outputs | 145 | // independant right and left channel setting, or setting for different outputs |
142 | Config cfg("qpe"); // qtopia is "Sound" | 146 | Config cfg("qpe"); // qtopia is "Sound" |
143 | cfg.setGroup("Volume"); // qtopia is "Settings" | 147 | cfg.setGroup("Volume"); // qtopia is "Settings" |
144 | cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume | 148 | cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume |
145 | # endif | 149 | # endif |
146 | 150 | ||
147 | //#endif | 151 | //#endif |
148 | // qDebug( "setting volume to: 0x%x", volume ); | 152 | // odebug << "setting volume to: 0x" << volume << "" << oendl; |
149 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 153 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
150 | // Send notification that the volume has changed | 154 | // Send notification that the volume has changed |
151 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; | 155 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; |
152 | #endif | 156 | #endif |
153 | } | 157 | } |
154 | 158 | ||
155 | 159 | ||
156 | 160 | ||
157 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { | 161 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { |
158 | // qDebug("creating new audio device"); | 162 | // odebug << "creating new audio device" << oendl; |
159 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; | 163 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; |
160 | d = new AudioDevicePrivate; | 164 | d = new AudioDevicePrivate; |
161 | d->frequency = f; | 165 | d->frequency = f; |
162 | d->channels = chs; | 166 | d->channels = chs; |
163 | d->bytesPerSample = bps; | 167 | d->bytesPerSample = bps; |
164 | // qDebug("%d",bps); | 168 | // odebug << "" << bps << "" << oendl; |
165 | int format=0; | 169 | int format=0; |
166 | if( bps == 8) format = AFMT_U8; | 170 | if( bps == 8) format = AFMT_U8; |
167 | else if( bps <= 0) format = AFMT_S16_LE; | 171 | else if( bps <= 0) format = AFMT_S16_LE; |
168 | else format = AFMT_S16_LE; | 172 | else format = AFMT_S16_LE; |
169 | // qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); | 173 | // odebug << "AD- freq " << f << ", channels " << chs << ", b/sample " << bps << ", bitrate " << format << "" << oendl; |
170 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); | 174 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); |
171 | 175 | ||
172 | int fragments = 0x10000 * 8 + sound_fragment_shift; | 176 | int fragments = 0x10000 * 8 + sound_fragment_shift; |
173 | int capabilities = 0; | 177 | int capabilities = 0; |
174 | 178 | ||
175 | 179 | ||
176 | #ifdef KEEP_DEVICE_OPEN | 180 | #ifdef KEEP_DEVICE_OPEN |
177 | if ( AudioDevicePrivate::dspFd == 0 ) { | 181 | if ( AudioDevicePrivate::dspFd == 0 ) { |
178 | #endif | 182 | #endif |
179 | #ifdef QT_QWS_DEVFS | 183 | #ifdef QT_QWS_DEVFS |
180 | if ( ( d->handle = ::open( "/dev/sound/dsp", O_WRONLY ) ) < 0 ) { | 184 | if ( ( d->handle = ::open( "/dev/sound/dsp", O_WRONLY ) ) < 0 ) { |
181 | #else | 185 | #else |
182 | if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { | 186 | if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { |
183 | #endif | 187 | #endif |
184 | 188 | ||
185 | perror("open(\"/dev/dsp\")"); | 189 | perror("open(\"/dev/dsp\")"); |
@@ -187,84 +191,84 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { | |||
187 | QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort")); | 191 | QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort")); |
188 | exit(-1); //harsh? | 192 | exit(-1); //harsh? |
189 | } | 193 | } |
190 | #ifdef KEEP_DEVICE_OPEN | 194 | #ifdef KEEP_DEVICE_OPEN |
191 | AudioDevicePrivate::dspFd = d->handle; | 195 | AudioDevicePrivate::dspFd = d->handle; |
192 | } else { | 196 | } else { |
193 | d->handle = AudioDevicePrivate::dspFd; | 197 | d->handle = AudioDevicePrivate::dspFd; |
194 | } | 198 | } |
195 | #endif | 199 | #endif |
196 | 200 | ||
197 | if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) | 201 | if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) |
198 | perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); | 202 | perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); |
199 | if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) | 203 | if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) |
200 | perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); | 204 | perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); |
201 | if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) | 205 | if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) |
202 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 206 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
203 | // qDebug("freq %d", d->frequency); | 207 | // odebug << "freq " << d->frequency << "" << oendl; |
204 | if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) | 208 | if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) |
205 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 209 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
206 | // qDebug("channels %d",d->channels); | 210 | // odebug << "channels " << d->channels << "" << oendl; |
207 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { | 211 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { |
208 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; | 212 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; |
209 | if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) | 213 | if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) |
210 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 214 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
211 | } | 215 | } |
212 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; | 216 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; |
213 | 217 | ||
214 | d->bufferSize = sound_fragment_bytes; | 218 | d->bufferSize = sound_fragment_bytes; |
215 | d->unwrittenBuffer = new char[d->bufferSize]; | 219 | d->unwrittenBuffer = new char[d->bufferSize]; |
216 | d->unwritten = 0; | 220 | d->unwritten = 0; |
217 | d->can_GETOSPACE = TRUE; // until we find otherwise | 221 | d->can_GETOSPACE = TRUE; // until we find otherwise |
218 | 222 | ||
219 | //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); | 223 | //if ( chs != d->channels ) odebug << "Wanted " << chs << ", got " << d->channels << " channels" << oendl; |
220 | //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); | 224 | //if ( f != d->frequency ) odebug << "wanted " << f << "Hz, got " << d->frequency << "Hz" << oendl; |
221 | //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); | 225 | //if ( capabilities & DSP_CAP_BATCH ) odebug << "Sound card has local buffer" << oendl; |
222 | //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); | 226 | //if ( capabilities & DSP_CAP_REALTIME )odebug << "Sound card has realtime sync" << oendl; |
223 | //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); | 227 | //if ( capabilities & DSP_CAP_TRIGGER ) odebug << "Sound card has precise trigger" << oendl; |
224 | //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); | 228 | //if ( capabilities & DSP_CAP_MMAP ) odebug << "Sound card can mmap" << oendl; |
225 | 229 | ||
226 | } | 230 | } |
227 | 231 | ||
228 | 232 | ||
229 | AudioDevice::~AudioDevice() { | 233 | AudioDevice::~AudioDevice() { |
230 | // qDebug("destryo audiodevice"); | 234 | // odebug << "destryo audiodevice" << oendl; |
231 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; | 235 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; |
232 | 236 | ||
233 | # ifndef KEEP_DEVICE_OPEN | 237 | # ifndef KEEP_DEVICE_OPEN |
234 | close( d->handle ); // Now it should be safe to shut the handle | 238 | close( d->handle ); // Now it should be safe to shut the handle |
235 | # endif | 239 | # endif |
236 | delete d->unwrittenBuffer; | 240 | delete d->unwrittenBuffer; |
237 | delete d; | 241 | delete d; |
238 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; | 242 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; |
239 | 243 | ||
240 | } | 244 | } |
241 | 245 | ||
242 | 246 | ||
243 | void AudioDevice::volumeChanged( bool muted ) | 247 | void AudioDevice::volumeChanged( bool muted ) |
244 | { | 248 | { |
245 | AudioDevicePrivate::muted = muted; | 249 | AudioDevicePrivate::muted = muted; |
246 | } | 250 | } |
247 | 251 | ||
248 | 252 | ||
249 | void AudioDevice::write( char *buffer, unsigned int length ) | 253 | void AudioDevice::write( char *buffer, unsigned int length ) |
250 | { | 254 | { |
251 | int t = ::write( d->handle, buffer, length ); | 255 | int t = ::write( d->handle, buffer, length ); |
252 | if ( t<0 ) t = 0; | 256 | if ( t<0 ) t = 0; |
253 | if ( t != (int)length) { | 257 | if ( t != (int)length) { |
254 | // qDebug("Ahhh!! memcpys 1"); | 258 | // odebug << "Ahhh!! memcpys 1" << oendl; |
255 | memcpy(d->unwrittenBuffer,buffer+t,length-t); | 259 | memcpy(d->unwrittenBuffer,buffer+t,length-t); |
256 | d->unwritten = length-t; | 260 | d->unwritten = length-t; |
257 | } | 261 | } |
258 | //#endif | 262 | //#endif |
259 | } | 263 | } |
260 | 264 | ||
261 | 265 | ||
262 | unsigned int AudioDevice::channels() const | 266 | unsigned int AudioDevice::channels() const |
263 | { | 267 | { |
264 | return d->channels; | 268 | return d->channels; |
265 | } | 269 | } |
266 | 270 | ||
267 | 271 | ||
268 | unsigned int AudioDevice::frequency() const | 272 | unsigned int AudioDevice::frequency() const |
269 | { | 273 | { |
270 | return d->frequency; | 274 | return d->frequency; |
@@ -301,22 +305,22 @@ unsigned int AudioDevice::canWrite() const | |||
301 | d->unwritten -= t; | 305 | d->unwritten -= t; |
302 | } else { | 306 | } else { |
303 | d->unwritten = 0; | 307 | d->unwritten = 0; |
304 | } | 308 | } |
305 | } | 309 | } |
306 | if ( d->unwritten ) | 310 | if ( d->unwritten ) |
307 | return 0; | 311 | return 0; |
308 | else | 312 | else |
309 | return d->bufferSize; | 313 | return d->bufferSize; |
310 | } | 314 | } |
311 | } | 315 | } |
312 | 316 | ||
313 | 317 | ||
314 | int AudioDevice::bytesWritten() { | 318 | int AudioDevice::bytesWritten() { |
315 | int buffered = 0; | 319 | int buffered = 0; |
316 | if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) { | 320 | if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) { |
317 | // qDebug( "failed to get audio device position" ); | 321 | // odebug << "failed to get audio device position" << oendl; |
318 | return -1; | 322 | return -1; |
319 | } | 323 | } |
320 | return buffered; | 324 | return buffered; |
321 | } | 325 | } |
322 | 326 | ||
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index 7da2d54..376f8d3 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp | |||
@@ -4,40 +4,45 @@ | |||
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 "audiowidget.h" | ||
21 | #include "mediaplayerstate.h" | ||
22 | |||
23 | /* OPIE */ | ||
20 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
22 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | #include <opie2/odebug.h> | ||
23 | 28 | ||
29 | /* QT */ | ||
24 | #include <qdir.h> | 30 | #include <qdir.h> |
25 | #include "audiowidget.h" | ||
26 | #include "mediaplayerstate.h" | ||
27 | 31 | ||
32 | /* STD */ | ||
28 | #include <stdlib.h> | 33 | #include <stdlib.h> |
29 | #include <stdio.h> | 34 | #include <stdio.h> |
30 | 35 | ||
31 | extern MediaPlayerState *mediaPlayerState; | 36 | extern MediaPlayerState *mediaPlayerState; |
32 | 37 | ||
33 | 38 | ||
34 | static const int xo = -2; // movable x offset | 39 | static const int xo = -2; // movable x offset |
35 | static const int yo = 22; // movable y offset | 40 | static const int yo = 22; // movable y offset |
36 | 41 | ||
37 | using namespace Opie::Ui; | 42 | using namespace Opie::Ui; |
38 | struct MediaButton { | 43 | struct MediaButton { |
39 | bool isToggle, isHeld, isDown; | 44 | bool isToggle, isHeld, isDown; |
40 | }; | 45 | }; |
41 | 46 | ||
42 | //Layout information for the audioButtons (and if it is a toggle button or not) | 47 | //Layout information for the audioButtons (and if it is a toggle button or not) |
43 | MediaButton audioButtons[] = { | 48 | MediaButton audioButtons[] = { |
@@ -58,98 +63,98 @@ const char *skin_mask_file_names[10] = { | |||
58 | "down", "loop", "playlist", "forward", "back" | 63 | "down", "loop", "playlist", "forward", "back" |
59 | }; | 64 | }; |
60 | 65 | ||
61 | static void changeTextColor( QWidget *w ) { | 66 | static void changeTextColor( QWidget *w ) { |
62 | QPalette p = w->palette(); | 67 | QPalette p = w->palette(); |
63 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 68 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
64 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 69 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
65 | w->setPalette( p ); | 70 | w->setPalette( p ); |
66 | } | 71 | } |
67 | 72 | ||
68 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 73 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
69 | 74 | ||
70 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 75 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
71 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) | 76 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) |
72 | { | 77 | { |
73 | setCaption( tr("OpiePlayer") ); | 78 | setCaption( tr("OpiePlayer") ); |
74 | // qDebug("<<<<<audioWidget"); | 79 | // odebug << "<<<<<audioWidget" << oendl; |
75 | 80 | ||
76 | Config cfg("OpiePlayer"); | 81 | Config cfg("OpiePlayer"); |
77 | cfg.setGroup("Options"); | 82 | cfg.setGroup("Options"); |
78 | skin = cfg.readEntry("Skin","default"); | 83 | skin = cfg.readEntry("Skin","default"); |
79 | //skin = "scaleTest"; | 84 | //skin = "scaleTest"; |
80 | // color of background, frame, degree of transparency | 85 | // color of background, frame, degree of transparency |
81 | 86 | ||
82 | // QString skinPath = "opieplayer/skins/" + skin; | 87 | // QString skinPath = "opieplayer/skins/" + skin; |
83 | QString skinPath; | 88 | QString skinPath; |
84 | skinPath = "opieplayer2/skins/" + skin; | 89 | skinPath = "opieplayer2/skins/" + skin; |
85 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) | 90 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) |
86 | skinPath = "opieplayer2/skins/default"; | 91 | skinPath = "opieplayer2/skins/default"; |
87 | 92 | ||
88 | // qDebug("skin path " + skinPath); | 93 | // odebug << "skin path " + skinPath << oendl; |
89 | 94 | ||
90 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 95 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
91 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 96 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
92 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 97 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
93 | 98 | ||
94 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 99 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
95 | imgButtonMask->fill( 0 ); | 100 | imgButtonMask->fill( 0 ); |
96 | 101 | ||
97 | for ( int i = 0; i < 10; i++ ) { | 102 | for ( int i = 0; i < 10; i++ ) { |
98 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; | 103 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; |
99 | masks[i] = new QBitmap( filename ); | 104 | masks[i] = new QBitmap( filename ); |
100 | 105 | ||
101 | if ( !masks[i]->isNull() ) { | 106 | if ( !masks[i]->isNull() ) { |
102 | QImage imgMask = masks[i]->convertToImage(); | 107 | QImage imgMask = masks[i]->convertToImage(); |
103 | uchar **dest = imgButtonMask->jumpTable(); | 108 | uchar **dest = imgButtonMask->jumpTable(); |
104 | for ( int y = 0; y < imgUp->height(); y++ ) { | 109 | for ( int y = 0; y < imgUp->height(); y++ ) { |
105 | uchar *line = dest[y]; | 110 | uchar *line = dest[y]; |
106 | for ( int x = 0; x < imgUp->width(); x++ ) | 111 | for ( int x = 0; x < imgUp->width(); x++ ) |
107 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 112 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
108 | line[x] = i + 1; | 113 | line[x] = i + 1; |
109 | } | 114 | } |
110 | } | 115 | } |
111 | 116 | ||
112 | } | 117 | } |
113 | 118 | ||
114 | for ( int i = 0; i < 11; i++ ) { | 119 | for ( int i = 0; i < 11; i++ ) { |
115 | buttonPixUp[i] = NULL; | 120 | buttonPixUp[i] = NULL; |
116 | buttonPixDown[i] = NULL; | 121 | buttonPixDown[i] = NULL; |
117 | } | 122 | } |
118 | 123 | ||
119 | QWidget *d = QApplication::desktop(); | 124 | QWidget *d = QApplication::desktop(); |
120 | int width = d->width(); | 125 | int width = d->width(); |
121 | int height = d->height(); | 126 | int height = d->height(); |
122 | 127 | ||
123 | if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { | 128 | if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { |
124 | // qDebug("<<<<<<<< scale image >>>>>>>>>>>>"); | 129 | // odebug << "<<<<<<<< scale image >>>>>>>>>>>>" << oendl; |
125 | QImage img; | 130 | QImage img; |
126 | img = pixBg->convertToImage(); | 131 | img = pixBg->convertToImage(); |
127 | pixBg->convertFromImage( img.smoothScale( width, height)); | 132 | pixBg->convertFromImage( img.smoothScale( width, height)); |
128 | } | 133 | } |
129 | setBackgroundPixmap( *pixBg); | 134 | setBackgroundPixmap( *pixBg); |
130 | 135 | ||
131 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 136 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
132 | 137 | ||
133 | // changeTextColor( &songInfo ); | 138 | // changeTextColor( &songInfo ); |
134 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 139 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
135 | // songInfo.setFrameStyle( QFrame::NoFrame); | 140 | // songInfo.setFrameStyle( QFrame::NoFrame); |
136 | // songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 141 | // songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
137 | //NoFrame | 142 | //NoFrame |
138 | // songInfo.setForegroundColor(Qt::white); | 143 | // songInfo.setForegroundColor(Qt::white); |
139 | 144 | ||
140 | slider.setFixedHeight( 20 ); | 145 | slider.setFixedHeight( 20 ); |
141 | slider.setMinValue( 0 ); | 146 | slider.setMinValue( 0 ); |
142 | slider.setMaxValue( 1 ); | 147 | slider.setMaxValue( 1 ); |
143 | slider.setFocusPolicy( QWidget::NoFocus ); | 148 | slider.setFocusPolicy( QWidget::NoFocus ); |
144 | 149 | ||
145 | slider.setBackgroundPixmap( *pixBg ); | 150 | slider.setBackgroundPixmap( *pixBg ); |
146 | 151 | ||
147 | time.setFocusPolicy( QWidget::NoFocus ); | 152 | time.setFocusPolicy( QWidget::NoFocus ); |
148 | time.setAlignment( Qt::AlignCenter ); | 153 | time.setAlignment( Qt::AlignCenter ); |
149 | time.setFrame(FALSE); | 154 | time.setFrame(FALSE); |
150 | changeTextColor( &time ); | 155 | changeTextColor( &time ); |
151 | 156 | ||
152 | resizeEvent( NULL ); | 157 | resizeEvent( NULL ); |
153 | 158 | ||
154 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 159 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
155 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 160 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
@@ -159,33 +164,33 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | |||
159 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 164 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
160 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 165 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
161 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 166 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
162 | 167 | ||
163 | // Intialise state | 168 | // Intialise state |
164 | setLength( mediaPlayerState->length() ); | 169 | setLength( mediaPlayerState->length() ); |
165 | setPosition( mediaPlayerState->position() ); | 170 | setPosition( mediaPlayerState->position() ); |
166 | setLooping( mediaPlayerState->fullscreen() ); | 171 | setLooping( mediaPlayerState->fullscreen() ); |
167 | // setPaused( mediaPlayerState->paused() ); | 172 | // setPaused( mediaPlayerState->paused() ); |
168 | setPlaying( mediaPlayerState->playing() ); | 173 | setPlaying( mediaPlayerState->playing() ); |
169 | this->setFocus(); | 174 | this->setFocus(); |
170 | } | 175 | } |
171 | 176 | ||
172 | 177 | ||
173 | AudioWidget::~AudioWidget() { | 178 | AudioWidget::~AudioWidget() { |
174 | // setPlaying( false); | 179 | // setPlaying( false); |
175 | 180 | ||
176 | for ( int i = 0; i < 10; i++ ) { | 181 | for ( int i = 0; i < 10; i++ ) { |
177 | if(buttonPixUp[i]) delete buttonPixUp[i]; | 182 | if(buttonPixUp[i]) delete buttonPixUp[i]; |
178 | if(buttonPixDown[i]) delete buttonPixDown[i]; | 183 | if(buttonPixDown[i]) delete buttonPixDown[i]; |
179 | } | 184 | } |
180 | if(pixBg) delete pixBg; | 185 | if(pixBg) delete pixBg; |
181 | if(imgUp) delete imgUp; | 186 | if(imgUp) delete imgUp; |
182 | if(imgDn) delete imgDn; | 187 | if(imgDn) delete imgDn; |
183 | if(imgButtonMask) delete imgButtonMask; | 188 | if(imgButtonMask) delete imgButtonMask; |
184 | for ( int i = 0; i < 10; i++ ) { | 189 | for ( int i = 0; i < 10; i++ ) { |
185 | if(masks[i]) delete masks[i]; | 190 | if(masks[i]) delete masks[i]; |
186 | } | 191 | } |
187 | } | 192 | } |
188 | 193 | ||
189 | 194 | ||
190 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 195 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
191 | QPixmap pix( img.width(), img.height() ); | 196 | QPixmap pix( img.width(), img.height() ); |
@@ -240,33 +245,33 @@ static bool audioSliderBeingMoved = FALSE; | |||
240 | 245 | ||
241 | void AudioWidget::sliderPressed() { | 246 | void AudioWidget::sliderPressed() { |
242 | audioSliderBeingMoved = TRUE; | 247 | audioSliderBeingMoved = TRUE; |
243 | } | 248 | } |
244 | 249 | ||
245 | 250 | ||
246 | void AudioWidget::sliderReleased() { | 251 | void AudioWidget::sliderReleased() { |
247 | audioSliderBeingMoved = FALSE; | 252 | audioSliderBeingMoved = FALSE; |
248 | if ( slider.width() == 0 ) | 253 | if ( slider.width() == 0 ) |
249 | return; | 254 | return; |
250 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); | 255 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); |
251 | mediaPlayerState->setPosition( val ); | 256 | mediaPlayerState->setPosition( val ); |
252 | } | 257 | } |
253 | 258 | ||
254 | 259 | ||
255 | void AudioWidget::setPosition( long i ) { | 260 | void AudioWidget::setPosition( long i ) { |
256 | // qDebug("set position %d",i); | 261 | // odebug << "set position " << i << "" << oendl; |
257 | long length = mediaPlayerState->length(); | 262 | long length = mediaPlayerState->length(); |
258 | updateSlider( i, length ); | 263 | updateSlider( i, length ); |
259 | } | 264 | } |
260 | 265 | ||
261 | 266 | ||
262 | void AudioWidget::setLength( long max ) { | 267 | void AudioWidget::setLength( long max ) { |
263 | updateSlider( mediaPlayerState->position(), max ); | 268 | updateSlider( mediaPlayerState->position(), max ); |
264 | } | 269 | } |
265 | 270 | ||
266 | 271 | ||
267 | void AudioWidget::setView( char view ) { | 272 | void AudioWidget::setView( char view ) { |
268 | 273 | ||
269 | if (mediaPlayerState->isStreaming) { | 274 | if (mediaPlayerState->isStreaming) { |
270 | if( !slider.isHidden()) slider.hide(); | 275 | if( !slider.isHidden()) slider.hide(); |
271 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 276 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
272 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 277 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
@@ -287,33 +292,33 @@ void AudioWidget::setView( char view ) { | |||
287 | hide(); | 292 | hide(); |
288 | } | 293 | } |
289 | 294 | ||
290 | } | 295 | } |
291 | 296 | ||
292 | 297 | ||
293 | static QString timeAsString( long length ) { | 298 | static QString timeAsString( long length ) { |
294 | length /= 44100; | 299 | length /= 44100; |
295 | int minutes = length / 60; | 300 | int minutes = length / 60; |
296 | int seconds = length % 60; | 301 | int seconds = length % 60; |
297 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 302 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
298 | } | 303 | } |
299 | 304 | ||
300 | void AudioWidget::updateSlider( long i, long max ) { | 305 | void AudioWidget::updateSlider( long i, long max ) { |
301 | this->setFocus(); | 306 | this->setFocus(); |
302 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 307 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
303 | 308 | ||
304 | if ( max == 0 ) | 309 | if ( max == 0 ) |
305 | return; | 310 | return; |
306 | // Will flicker too much if we don't do this | 311 | // Will flicker too much if we don't do this |
307 | // Scale to something reasonable | 312 | // Scale to something reasonable |
308 | int width = slider.width(); | 313 | int width = slider.width(); |
309 | int val = int((double)i * width / max); | 314 | int val = int((double)i * width / max); |
310 | if ( !audioSliderBeingMoved ) { | 315 | if ( !audioSliderBeingMoved ) { |
311 | if ( slider.value() != val ) | 316 | if ( slider.value() != val ) |
312 | slider.setValue( val ); | 317 | slider.setValue( val ); |
313 | if ( slider.maxValue() != width ) | 318 | if ( slider.maxValue() != width ) |
314 | slider.setMaxValue( width ); | 319 | slider.setMaxValue( width ); |
315 | } | 320 | } |
316 | } | 321 | } |
317 | 322 | ||
318 | 323 | ||
319 | void AudioWidget::setToggleButton( int i, bool down ) { | 324 | void AudioWidget::setToggleButton( int i, bool down ) { |
@@ -353,45 +358,45 @@ void AudioWidget::timerEvent( QTimerEvent * ) { | |||
353 | } | 358 | } |
354 | */ | 359 | */ |
355 | } | 360 | } |
356 | 361 | ||
357 | 362 | ||
358 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 363 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
359 | for ( int i = 0; i < numButtons; i++ ) { | 364 | for ( int i = 0; i < numButtons; i++ ) { |
360 | if ( event->state() == QMouseEvent::LeftButton ) { | 365 | if ( event->state() == QMouseEvent::LeftButton ) { |
361 | 366 | ||
362 | // The test to see if the mouse click is inside the button or not | 367 | // The test to see if the mouse click is inside the button or not |
363 | int x = event->pos().x() - xoff; | 368 | int x = event->pos().x() - xoff; |
364 | int y = event->pos().y() - yoff; | 369 | int y = event->pos().y() - yoff; |
365 | 370 | ||
366 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 371 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
367 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 372 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
368 | 373 | ||
369 | // if ( isOnButton && i == AudioVolumeUp ) | 374 | // if ( isOnButton && i == AudioVolumeUp ) |
370 | // qDebug("on up"); | 375 | // odebug << "on up" << oendl; |
371 | 376 | ||
372 | if ( isOnButton && !audioButtons[i].isHeld ) { | 377 | if ( isOnButton && !audioButtons[i].isHeld ) { |
373 | audioButtons[i].isHeld = TRUE; | 378 | audioButtons[i].isHeld = TRUE; |
374 | toggleButton(i); | 379 | toggleButton(i); |
375 | switch (i) { | 380 | switch (i) { |
376 | case AudioVolumeUp: | 381 | case AudioVolumeUp: |
377 | // qDebug("more clicked"); | 382 | // odebug << "more clicked" << oendl; |
378 | emit moreClicked(); | 383 | emit moreClicked(); |
379 | return; | 384 | return; |
380 | case AudioVolumeDown: | 385 | case AudioVolumeDown: |
381 | // qDebug("less clicked"); | 386 | // odebug << "less clicked" << oendl; |
382 | emit lessClicked(); | 387 | emit lessClicked(); |
383 | return; | 388 | return; |
384 | case AudioForward: | 389 | case AudioForward: |
385 | emit forwardClicked(); | 390 | emit forwardClicked(); |
386 | return; | 391 | return; |
387 | case AudioBack: | 392 | case AudioBack: |
388 | emit backClicked(); | 393 | emit backClicked(); |
389 | return; | 394 | return; |
390 | } | 395 | } |
391 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 396 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
392 | audioButtons[i].isHeld = FALSE; | 397 | audioButtons[i].isHeld = FALSE; |
393 | toggleButton(i); | 398 | toggleButton(i); |
394 | } | 399 | } |
395 | } else { | 400 | } else { |
396 | if ( audioButtons[i].isHeld ) { | 401 | if ( audioButtons[i].isHeld ) { |
397 | audioButtons[i].isHeld = FALSE; | 402 | audioButtons[i].isHeld = FALSE; |
@@ -457,33 +462,33 @@ void AudioWidget::paintEvent( QPaintEvent * pe) { | |||
457 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 462 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
458 | } else { | 463 | } else { |
459 | QPainter p( this ); | 464 | QPainter p( this ); |
460 | for ( int i = 0; i < numButtons; i++ ) | 465 | for ( int i = 0; i < numButtons; i++ ) |
461 | paintButton( &p, i ); | 466 | paintButton( &p, i ); |
462 | } | 467 | } |
463 | } | 468 | } |
464 | 469 | ||
465 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) | 470 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) |
466 | { | 471 | { |
467 | switch ( e->key() ) { | 472 | switch ( e->key() ) { |
468 | ////////////////////////////// Zaurus keys | 473 | ////////////////////////////// Zaurus keys |
469 | case Key_Home: | 474 | case Key_Home: |
470 | break; | 475 | break; |
471 | case Key_F9: //activity | 476 | case Key_F9: //activity |
472 | hide(); | 477 | hide(); |
473 | // qDebug("Audio F9"); | 478 | // odebug << "Audio F9" << oendl; |
474 | break; | 479 | break; |
475 | case Key_F10: //contacts | 480 | case Key_F10: //contacts |
476 | break; | 481 | break; |
477 | case Key_F11: //menu | 482 | case Key_F11: //menu |
478 | break; | 483 | break; |
479 | case Key_F12: //home | 484 | case Key_F12: //home |
480 | break; | 485 | break; |
481 | case Key_F13: //mail | 486 | case Key_F13: //mail |
482 | break; | 487 | break; |
483 | case Key_Space: { | 488 | case Key_Space: { |
484 | 489 | ||
485 | if(mediaPlayerState->playing()) { | 490 | if(mediaPlayerState->playing()) { |
486 | // toggleButton(1); | 491 | // toggleButton(1); |
487 | mediaPlayerState->setPlaying(FALSE); | 492 | mediaPlayerState->setPlaying(FALSE); |
488 | // toggleButton(1); | 493 | // toggleButton(1); |
489 | } else { | 494 | } else { |
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp index 1989b4a..428fc28 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp +++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp | |||
@@ -6,68 +6,73 @@ | |||
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 | // largly modified by Maximilian Reiss <max.reiss@gmx.de> | 20 | // largly modified by Maximilian Reiss <max.reiss@gmx.de> |
21 | 21 | ||
22 | #include "libmadplugin.h" | ||
23 | |||
24 | /* OPIE */ | ||
25 | #include <qpe/config.h> | ||
26 | #include <opie2/odebug.h> | ||
27 | |||
28 | /* QT */ | ||
29 | #include <qapplication.h> | ||
30 | #include <qmessagebox.h> | ||
31 | #include <qregexp.h> | ||
32 | |||
33 | /* STD */ | ||
22 | #include <stdio.h> | 34 | #include <stdio.h> |
23 | #include <stdarg.h> | 35 | #include <stdarg.h> |
24 | #include <stdlib.h> | 36 | #include <stdlib.h> |
25 | #include <sys/types.h> | 37 | #include <sys/types.h> |
26 | #include <sys/stat.h> | 38 | #include <sys/stat.h> |
27 | #include <fcntl.h> | 39 | #include <fcntl.h> |
28 | #include <unistd.h> | 40 | #include <unistd.h> |
29 | #include <string.h> | 41 | #include <string.h> |
30 | #include <ctype.h> | 42 | #include <ctype.h> |
31 | #include <errno.h> | 43 | #include <errno.h> |
32 | #include <time.h> | 44 | #include <time.h> |
33 | #include <locale.h> | 45 | #include <locale.h> |
34 | #include <math.h> | 46 | #include <math.h> |
35 | #include <assert.h> | 47 | #include <assert.h> |
36 | 48 | ||
37 | #include <qapplication.h> | ||
38 | #include <qmessagebox.h> | ||
39 | #include <qregexp.h> | ||
40 | |||
41 | #include <qpe/config.h> | ||
42 | |||
43 | // for network handling | 49 | // for network handling |
44 | #include <netinet/in.h> | 50 | #include <netinet/in.h> |
45 | #include <netdb.h> | 51 | #include <netdb.h> |
46 | #include <linux/limits.h> | 52 | #include <linux/limits.h> |
47 | #include <sys/socket.h> | 53 | #include <sys/socket.h> |
48 | #include <arpa/inet.h> | 54 | #include <arpa/inet.h> |
49 | #include <unistd.h> | 55 | #include <unistd.h> |
50 | 56 | ||
51 | 57 | ||
52 | //#define HAVE_MMAP | 58 | //#define HAVE_MMAP |
53 | 59 | ||
54 | #if defined(HAVE_MMAP) | 60 | #if defined(HAVE_MMAP) |
55 | # include <sys/mman.h> | 61 | # include <sys/mman.h> |
56 | #endif | 62 | #endif |
57 | #include "libmadplugin.h" | ||
58 | 63 | ||
59 | 64 | ||
60 | extern "C" { | 65 | extern "C" { |
61 | #include "mad.h" | 66 | #include "mad.h" |
62 | } | 67 | } |
63 | 68 | ||
64 | 69 | ||
65 | #define MPEG_BUFFER_SIZE 65536 | 70 | #define MPEG_BUFFER_SIZE 65536 |
66 | //#define MPEG_BUFFER_SIZE 32768 //16384 // 8192 | 71 | //#define MPEG_BUFFER_SIZE 32768 //16384 // 8192 |
67 | //#define debugMsg(a) qDebug(a) | 72 | //#define debugMsg(a) qDebug(a) |
68 | #define debugMsg(a) | 73 | #define debugMsg(a) |
69 | 74 | ||
70 | 75 | ||
71 | class Input { | 76 | class Input { |
72 | public: | 77 | public: |
73 | char const *path; | 78 | char const *path; |
@@ -369,243 +374,242 @@ int LibMadPlugin::http_open(const QString& path ) { | |||
369 | return (0); | 374 | return (0); |
370 | } | 375 | } |
371 | #endif | 376 | #endif |
372 | 377 | ||
373 | QString name; | 378 | QString name; |
374 | QString genre; | 379 | QString genre; |
375 | QString bitrate; | 380 | QString bitrate; |
376 | QString url; | 381 | QString url; |
377 | QString message = tr("Info: "); | 382 | QString message = tr("Info: "); |
378 | do { | 383 | do { |
379 | 384 | ||
380 | int len; | 385 | int len; |
381 | 386 | ||
382 | len = http_read_line(tcp_sock, http_request, sizeof(http_request)); | 387 | len = http_read_line(tcp_sock, http_request, sizeof(http_request)); |
383 | 388 | ||
384 | if (len == -1) { | 389 | if (len == -1) { |
385 | // qDebug( "http_open: "+ QString(strerror(errno)) +"\n"); | 390 | // odebug << "http_open: "+ QString(strerror(errno)) +"\n" << oendl; |
386 | return 0; | 391 | return 0; |
387 | } | 392 | } |
388 | 393 | ||
389 | if (QString(http_request).left(9) == "Location:") { | 394 | if (QString(http_request).left(9) == "Location:") { |
390 | /* redirect */ | 395 | /* redirect */ |
391 | ::close(tcp_sock); | 396 | ::close(tcp_sock); |
392 | http_request[strlen(http_request) - 1] = '\0'; | 397 | http_request[strlen(http_request) - 1] = '\0'; |
393 | return http_open(&http_request[10]); | 398 | return http_open(&http_request[10]); |
394 | } | 399 | } |
395 | 400 | ||
396 | if (QString(http_request).left(4) == "ICY ") { | 401 | if (QString(http_request).left(4) == "ICY ") { |
397 | /* This is shoutcast/icecast streaming */ | 402 | /* This is shoutcast/icecast streaming */ |
398 | if (strncmp(http_request + 4, "200 ", 4)) { | 403 | if (strncmp(http_request + 4, "200 ", 4)) { |
399 | // qDebug("http_open: " + QString(http_request) + "\n"); | 404 | // odebug << "http_open: " + QString(http_request) + "\n" << oendl; |
400 | return 0; | 405 | return 0; |
401 | } | 406 | } |
402 | } else if (QString(http_request).left(4) == "icy-") { | 407 | } else if (QString(http_request).left(4) == "icy-") { |
403 | /* we can have: icy-noticeX, icy-name, icy-genre, icy-url, icy-pub, icy-metaint, icy-br */ | 408 | /* we can have: icy-noticeX, icy-name, icy-genre, icy-url, icy-pub, icy-metaint, icy-br */ |
404 | if ( QString( http_request ).left( 8 ) == "icy-name" ) { | 409 | if ( QString( http_request ).left( 8 ) == "icy-name" ) { |
405 | name = tr("Name: ") + QString(http_request).mid(9, (QString(http_request).length())- 9 ); | 410 | name = tr("Name: ") + QString(http_request).mid(9, (QString(http_request).length())- 9 ); |
406 | } else if ( QString( http_request ).left( 9 ) == "icy-genre" ) { | 411 | } else if ( QString( http_request ).left( 9 ) == "icy-genre" ) { |
407 | genre = tr("Genre: ") + QString(http_request).mid(10, (QString(http_request).length())-10 ); | 412 | genre = tr("Genre: ") + QString(http_request).mid(10, (QString(http_request).length())-10 ); |
408 | } else if ( QString( http_request ).left( 6 ) == "icy-br" ) { | 413 | } else if ( QString( http_request ).left( 6 ) == "icy-br" ) { |
409 | bitrate = tr("Bitrate: ") + QString(http_request).mid(7, (QString(http_request).length())- 7 ); | 414 | bitrate = tr("Bitrate: ") + QString(http_request).mid(7, (QString(http_request).length())- 7 ); |
410 | } else if ( QString( http_request ).left( 7 ) == "icy-url" ) { | 415 | } else if ( QString( http_request ).left( 7 ) == "icy-url" ) { |
411 | url = tr("URL: ") + QString(http_request).mid(8, (QString(http_request).length())- 8 ); | 416 | url = tr("URL: ") + QString(http_request).mid(8, (QString(http_request).length())- 8 ); |
412 | } else if ( QString( http_request ).left( 10 ) == "icy-notice" ) { | 417 | } else if ( QString( http_request ).left( 10 ) == "icy-notice" ) { |
413 | message += QString(http_request).mid(11, QString(http_request).length()-11 ) ; | 418 | message += QString(http_request).mid(11, QString(http_request).length()-11 ) ; |
414 | } | 419 | } |
415 | } | 420 | } |
416 | } while (strcmp(http_request, "\n") != 0); | 421 | } while (strcmp(http_request, "\n") != 0); |
417 | 422 | ||
418 | info = QString(name + genre + url + bitrate + message).replace( QRegExp("\n"), " : " ); | 423 | info = QString(name + genre + url + bitrate + message).replace( QRegExp("\n"), " : " ); |
419 | 424 | ||
420 | // qDebug("Stream info: " + info); | 425 | // odebug << "Stream info: " + info << oendl; |
421 | 426 | ||
422 | return (tcp_sock); | 427 | return (tcp_sock); |
423 | } | 428 | } |
424 | 429 | ||
425 | 430 | ||
426 | 431 | ||
427 | bool LibMadPlugin::open( const QString& path ) { | 432 | bool LibMadPlugin::open( const QString& path ) { |
428 | debugMsg( "LibMadPlugin::open" ); | 433 | debugMsg( "LibMadPlugin::open" ); |
429 | Config cfg("OpiePlayer"); | 434 | Config cfg("OpiePlayer"); |
430 | cfg.setGroup("Options"); | 435 | cfg.setGroup("Options"); |
431 | bufferSize = cfg.readNumEntry("MPeg_BufferSize",MPEG_BUFFER_SIZE); | 436 | bufferSize = cfg.readNumEntry("MPeg_BufferSize",MPEG_BUFFER_SIZE); |
432 | // qDebug("buffer size is %d", bufferSize); | 437 | // odebug << "buffer size is " << bufferSize << "" << oendl; |
433 | d->bad_last_frame = 0; | 438 | d->bad_last_frame = 0; |
434 | d->flush = TRUE; | 439 | d->flush = TRUE; |
435 | info = QString( "" ); | 440 | info = QString( "" ); |
436 | 441 | ||
437 | //qDebug( "Opening %s", path.latin1() ); | 442 | //odebug << "Opening " << path << "" << oendl; |
438 | 443 | ||
439 | if (path.left( 4 ) == "http" ) { | 444 | if (path.left( 4 ) == "http" ) { |
440 | // in case of any error we get 0 here | 445 | // in case of any error we get 0 here |
441 | if ( !(http_open(path) == 0) ) { | 446 | if ( !(http_open(path) == 0) ) { |
442 | d->input.fd = http_open(path); | 447 | d->input.fd = http_open(path); |
443 | } else { | 448 | } else { |
444 | return FALSE; | 449 | return FALSE; |
445 | } | 450 | } |
446 | } else { | 451 | } else { |
447 | d->input.path = path.latin1(); | 452 | d->input.path = path.latin1(); |
448 | d->input.fd = ::open( d->input.path, O_RDONLY ); | 453 | d->input.fd = ::open( d->input.path, O_RDONLY ); |
449 | // thats a better place, since it should only seek for ID3 tags on mp3 files, not streams | 454 | // thats a better place, since it should only seek for ID3 tags on mp3 files, not streams |
450 | printID3Tags(); | 455 | printID3Tags(); |
451 | } | 456 | } |
452 | if (d->input.fd == -1) { | 457 | if (d->input.fd == -1) { |
453 | // qDebug("error opening %s", d->input.path ); | 458 | // odebug << "error opening " << d->input.path << "" << oendl; |
454 | return FALSE; | 459 | return FALSE; |
455 | } | 460 | } |
456 | 461 | ||
457 | struct stat stat; | 462 | struct stat stat; |
458 | if (fstat(d->input.fd, &stat) == -1) { | 463 | if (fstat(d->input.fd, &stat) == -1) { |
459 | // qDebug("error calling fstat"); return FALSE; | 464 | // odebug << "error calling fstat" << oendl; return FALSE; |
460 | } | 465 | } |
461 | if (S_ISREG(stat.st_mode) && stat.st_size > 0) | 466 | if (S_ISREG(stat.st_mode) && stat.st_size > 0) |
462 | d->input.fileLength = stat.st_size; | 467 | d->input.fileLength = stat.st_size; |
463 | else | 468 | else |
464 | d->input.fileLength = 0; | 469 | d->input.fileLength = 0; |
465 | 470 | ||
466 | #if defined(HAVE_MMAP) | 471 | #if defined(HAVE_MMAP) |
467 | if (S_ISREG(stat.st_mode) && stat.st_size > 0) { | 472 | if (S_ISREG(stat.st_mode) && stat.st_size > 0) { |
468 | d->input.length = stat.st_size; | 473 | d->input.length = stat.st_size; |
469 | d->input.fdm = map_file(d->input.fd, &d->input.length); | 474 | d->input.fdm = map_file(d->input.fd, &d->input.length); |
470 | if (d->input.fdm == 0) { | 475 | if (d->input.fdm == 0) { |
471 | // qDebug("error mmapping file"); return FALSE; | 476 | // odebug << "error mmapping file" << oendl; return FALSE; |
472 | } | 477 | } |
473 | d->input.data = (unsigned char *)d->input.fdm; | 478 | d->input.data = (unsigned char *)d->input.fdm; |
474 | } | 479 | } |
475 | #endif | 480 | #endif |
476 | 481 | ||
477 | if (d->input.data == 0) { | 482 | if (d->input.data == 0) { |
478 | d->input.data = (unsigned char *)malloc( bufferSize /*MPEG_BUFFER_SIZE*/); | 483 | d->input.data = (unsigned char *)malloc( bufferSize /*MPEG_BUFFER_SIZE*/); |
479 | if (d->input.data == 0) { | 484 | if (d->input.data == 0) { |
480 | // qDebug("error allocating input buffer"); | 485 | // odebug << "error allocating input buffer" << oendl; |
481 | return FALSE; | 486 | return FALSE; |
482 | } | 487 | } |
483 | d->input.length = 0; | 488 | d->input.length = 0; |
484 | } | 489 | } |
485 | 490 | ||
486 | d->input.eof = 0; | 491 | d->input.eof = 0; |
487 | 492 | ||
488 | mad_stream_init(&d->stream); | 493 | mad_stream_init(&d->stream); |
489 | mad_frame_init(&d->frame); | 494 | mad_frame_init(&d->frame); |
490 | mad_synth_init(&d->synth); | 495 | mad_synth_init(&d->synth); |
491 | 496 | ||
492 | return TRUE; | 497 | return TRUE; |
493 | } | 498 | } |
494 | 499 | ||
495 | 500 | ||
496 | bool LibMadPlugin::close() { | 501 | bool LibMadPlugin::close() { |
497 | debugMsg( "LibMadPlugin::close" ); | 502 | debugMsg( "LibMadPlugin::close" ); |
498 | 503 | ||
499 | int result = TRUE; | 504 | int result = TRUE; |
500 | 505 | ||
501 | mad_synth_finish(&d->synth); | 506 | mad_synth_finish(&d->synth); |
502 | mad_frame_finish(&d->frame); | 507 | mad_frame_finish(&d->frame); |
503 | mad_stream_finish(&d->stream); | 508 | mad_stream_finish(&d->stream); |
504 | 509 | ||
505 | #if defined(HAVE_MMAP) | 510 | #if defined(HAVE_MMAP) |
506 | if (d->input.fdm) { | 511 | if (d->input.fdm) { |
507 | if (unmap_file(d->input.fdm, d->input.length) == -1) { | 512 | if (unmap_file(d->input.fdm, d->input.length) == -1) { |
508 | // qDebug("error munmapping file"); | 513 | // odebug << "error munmapping file" << oendl; |
509 | result = FALSE; | 514 | result = FALSE; |
510 | } | 515 | } |
511 | d->input.fdm = 0; | 516 | d->input.fdm = 0; |
512 | d->input.data = 0; | 517 | d->input.data = 0; |
513 | } | 518 | } |
514 | #endif | 519 | #endif |
515 | 520 | ||
516 | if (d->input.data) { | 521 | if (d->input.data) { |
517 | free(d->input.data); | 522 | free(d->input.data); |
518 | d->input.data = 0; | 523 | d->input.data = 0; |
519 | } | 524 | } |
520 | 525 | ||
521 | if (::close(d->input.fd) == -1) { | 526 | if (::close(d->input.fd) == -1) { |
522 | // qDebug("error closing file %s", d->input.path); | 527 | // odebug << "error closing file " << d->input.path << "" << oendl; |
523 | result = FALSE; | 528 | result = FALSE; |
524 | } | 529 | } |
525 | 530 | ||
526 | d->input.fd = 0; | 531 | d->input.fd = 0; |
527 | 532 | ||
528 | return result; | 533 | return result; |
529 | } | 534 | } |
530 | 535 | ||
531 | 536 | ||
532 | bool LibMadPlugin::isOpen() { | 537 | bool LibMadPlugin::isOpen() { |
533 | debugMsg( "LibMadPlugin::isOpen" ); | 538 | debugMsg( "LibMadPlugin::isOpen" ); |
534 | return ( d->input.fd != 0 ); | 539 | return ( d->input.fd != 0 ); |
535 | } | 540 | } |
536 | 541 | ||
537 | 542 | ||
538 | int LibMadPlugin::audioStreams() { | 543 | int LibMadPlugin::audioStreams() { |
539 | debugMsg( "LibMadPlugin::audioStreams" ); | 544 | debugMsg( "LibMadPlugin::audioStreams" ); |
540 | return 1; | 545 | return 1; |
541 | } | 546 | } |
542 | 547 | ||
543 | 548 | ||
544 | int LibMadPlugin::audioChannels( int ) { | 549 | int LibMadPlugin::audioChannels( int ) { |
545 | debugMsg( "LibMadPlugin::audioChannels" ); | 550 | debugMsg( "LibMadPlugin::audioChannels" ); |
546 | /* | 551 | /* |
547 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); | 552 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); |
548 | qDebug( "LibMadPlugin::audioChannels: %i", d->frame.header.mode > 0 ? 2 : 1 ); | 553 | odebug << "LibMadPlugin::audioChannels: " << d->frame.header.mode > 0 ? 2 : 1 << "" << oendl; |
549 | return d->frame.header.mode > 0 ? 2 : 1; | 554 | return d->frame.header.mode > 0 ? 2 : 1; |
550 | */ | 555 | */ |
551 | return 2; | 556 | return 2; |
552 | } | 557 | } |
553 | 558 | ||
554 | 559 | ||
555 | int LibMadPlugin::audioFrequency( int ) { | 560 | int LibMadPlugin::audioFrequency( int ) { |
556 | debugMsg( "LibMadPlugin::audioFrequency" ); | 561 | debugMsg( "LibMadPlugin::audioFrequency" ); |
557 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); | 562 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); |
558 | // qDebug( "LibMadPlugin::audioFrequency: %i", d->frame.header.samplerate ); | 563 | // odebug << "LibMadPlugin::audioFrequency: " << d->frame.header.samplerate << "" << oendl; |
559 | return d->frame.header.samplerate; | 564 | return d->frame.header.samplerate; |
560 | } | 565 | } |
561 | 566 | ||
562 | 567 | ||
563 | int LibMadPlugin::audioSamples( int ) { | 568 | int LibMadPlugin::audioSamples( int ) { |
564 | debugMsg( "LibMadPlugin::audioSamples" ); | 569 | debugMsg( "LibMadPlugin::audioSamples" ); |
565 | 570 | ||
566 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); | 571 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); |
567 | mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream ); | 572 | mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream ); |
568 | /* | 573 | /* |
569 | qDebug( "LibMadPlugin::audioSamples: %i*%i", d->frame.header.duration.seconds, | 574 | odebug << "LibMadPlugin::audioSamples: " << d->frame.header.duration.seconds << "*" << d->frame.header.samplerate << oendl; |
570 | d->frame.header.samplerate ); | ||
571 | return d->frame.header.duration.seconds * d->frame.header.samplerate; | 575 | return d->frame.header.duration.seconds * d->frame.header.samplerate; |
572 | */ | 576 | */ |
573 | if ( d->frame.header.bitrate == 0 ) | 577 | if ( d->frame.header.bitrate == 0 ) |
574 | return 0; | 578 | return 0; |
575 | int samples = (d->input.fileLength / (d->frame.header.bitrate/8)) * d->frame.header.samplerate; | 579 | int samples = (d->input.fileLength / (d->frame.header.bitrate/8)) * d->frame.header.samplerate; |
576 | 580 | ||
577 | // qDebug( "LibMadPlugin::audioSamples: %i * %i * 8 / %i", (int)d->input.fileLength, | 581 | // qDebug( "LibMadPlugin::audioSamples: %i * %i * 8 / %i", (int)d->input.fileLength, |
578 | // (int)d->frame.header.samplerate, (int)d->frame.header.bitrate ); | 582 | // (int)d->frame.header.samplerate, (int)d->frame.header.bitrate ); |
579 | // qDebug( "LibMadPlugin::audioSamples: %i", samples ); | 583 | // odebug << "LibMadPlugin::audioSamples: " << samples << "" << oendl; |
580 | 584 | ||
581 | return samples; | 585 | return samples; |
582 | 586 | ||
583 | // return 10000000; | 587 | // return 10000000; |
584 | } | 588 | } |
585 | 589 | ||
586 | 590 | ||
587 | bool LibMadPlugin::audioSetSample( long, int ) { | 591 | bool LibMadPlugin::audioSetSample( long, int ) { |
588 | debugMsg( "LibMadPlugin::audioSetSample" ); | 592 | debugMsg( "LibMadPlugin::audioSetSample" ); |
589 | 593 | ||
590 | // long totalSamples = audioSamples(0); | 594 | // long totalSamples = audioSamples(0); |
591 | // if ( totalSamples <= 1 ) | 595 | // if ( totalSamples <= 1 ) |
592 | // return FALSE; | 596 | // return FALSE; |
593 | 597 | ||
594 | // // Seek to requested position | 598 | // // Seek to requested position |
595 | // qDebug( "seek pos: %i", (int)((double)pos * d->input.fileLength / totalSamples) ); | 599 | // odebug << "seek pos: " << (int)((double)pos * d->input.fileLength / totalSamples) << "" << oendl; |
596 | // ::lseek( d->input.fd, (long)((double)pos * d->input.fileLength / totalSamples), SEEK_SET ); | 600 | // ::lseek( d->input.fd, (long)((double)pos * d->input.fileLength / totalSamples), SEEK_SET ); |
597 | // mad_stream_sync(&d->stream); | 601 | // mad_stream_sync(&d->stream); |
598 | 602 | ||
599 | // mad_stream_init(&d->stream); | 603 | // mad_stream_init(&d->stream); |
600 | // mad_frame_init(&d->frame); | 604 | // mad_frame_init(&d->frame); |
601 | // mad_synth_init(&d->synth); | 605 | // mad_synth_init(&d->synth); |
602 | 606 | ||
603 | // return TRUE; | 607 | // return TRUE; |
604 | debugMsg( "LibMadPlugin::audioSetSample" ); | 608 | debugMsg( "LibMadPlugin::audioSetSample" ); |
605 | return FALSE; | 609 | return FALSE; |
606 | } | 610 | } |
607 | 611 | ||
608 | 612 | ||
609 | long LibMadPlugin::audioGetSample( int ) { | 613 | long LibMadPlugin::audioGetSample( int ) { |
610 | debugMsg( "LibMadPlugin::audioGetSample" ); | 614 | debugMsg( "LibMadPlugin::audioGetSample" ); |
611 | return 0; | 615 | return 0; |
@@ -667,33 +671,33 @@ bool LibMadPlugin::read() { | |||
667 | mad_stream_buffer(&d->stream, d->input.data + skip, d->input.length - skip); | 671 | mad_stream_buffer(&d->stream, d->input.data + skip, d->input.length - skip); |
668 | 672 | ||
669 | } else | 673 | } else |
670 | #endif | 674 | #endif |
671 | { | 675 | { |
672 | if (d->stream.next_frame) { | 676 | if (d->stream.next_frame) { |
673 | memmove(d->input.data, d->stream.next_frame, | 677 | memmove(d->input.data, d->stream.next_frame, |
674 | d->input.length = &d->input.data[d->input.length] - d->stream.next_frame); | 678 | d->input.length = &d->input.data[d->input.length] - d->stream.next_frame); |
675 | } | 679 | } |
676 | 680 | ||
677 | do { | 681 | do { |
678 | len = ::read(d->input.fd, d->input.data + d->input.length, bufferSize /* MPEG_BUFFER_SIZE*/ - d->input.length); | 682 | len = ::read(d->input.fd, d->input.data + d->input.length, bufferSize /* MPEG_BUFFER_SIZE*/ - d->input.length); |
679 | } | 683 | } |
680 | while (len == -1 && errno == EINTR); | 684 | while (len == -1 && errno == EINTR); |
681 | 685 | ||
682 | if (len == -1) { | 686 | if (len == -1) { |
683 | // qDebug("error reading audio"); | 687 | // odebug << "error reading audio" << oendl; |
684 | return FALSE; | 688 | return FALSE; |
685 | } | 689 | } |
686 | else if (len == 0) { | 690 | else if (len == 0) { |
687 | d->input.eof = 1; | 691 | d->input.eof = 1; |
688 | 692 | ||
689 | assert(bufferSize /*MPEG_BUFFER_SIZE*/ - d->input.length >= MAD_BUFFER_GUARD); | 693 | assert(bufferSize /*MPEG_BUFFER_SIZE*/ - d->input.length >= MAD_BUFFER_GUARD); |
690 | 694 | ||
691 | while (len < MAD_BUFFER_GUARD) | 695 | while (len < MAD_BUFFER_GUARD) |
692 | d->input.data[d->input.length + len++] = 0; | 696 | d->input.data[d->input.length + len++] = 0; |
693 | } | 697 | } |
694 | 698 | ||
695 | mad_stream_buffer(&d->stream, d->input.data, d->input.length += len); | 699 | mad_stream_buffer(&d->stream, d->input.data, d->input.length += len); |
696 | } | 700 | } |
697 | 701 | ||
698 | return TRUE; | 702 | return TRUE; |
699 | } | 703 | } |
@@ -745,33 +749,33 @@ bool LibMadPlugin::decode( short *output, long samples, long& samplesMade ) { | |||
745 | 749 | ||
746 | if ( d->flush ) { | 750 | if ( d->flush ) { |
747 | buffered = 0; | 751 | buffered = 0; |
748 | offset = 0; | 752 | offset = 0; |
749 | d->flush = FALSE; | 753 | d->flush = FALSE; |
750 | } | 754 | } |
751 | 755 | ||
752 | while ( buffered < maxBuffered ) { | 756 | while ( buffered < maxBuffered ) { |
753 | 757 | ||
754 | while (mad_frame_decode(&d->frame, &d->stream) == -1) { | 758 | while (mad_frame_decode(&d->frame, &d->stream) == -1) { |
755 | if (!MAD_RECOVERABLE(d->stream.error)) { | 759 | if (!MAD_RECOVERABLE(d->stream.error)) { |
756 | debugMsg( "feed me" ); | 760 | debugMsg( "feed me" ); |
757 | return FALSE; // Feed me | 761 | return FALSE; // Feed me |
758 | } | 762 | } |
759 | if ( d->stream.error == MAD_ERROR_BADCRC ) { | 763 | if ( d->stream.error == MAD_ERROR_BADCRC ) { |
760 | mad_frame_mute(&d->frame); | 764 | mad_frame_mute(&d->frame); |
761 | // qDebug( "error decoding, bad crc" ); | 765 | // odebug << "error decoding, bad crc" << oendl; |
762 | } | 766 | } |
763 | } | 767 | } |
764 | 768 | ||
765 | mad_synth_frame(&d->synth, &d->frame); | 769 | mad_synth_frame(&d->synth, &d->frame); |
766 | int decodedSamples = d->synth.pcm.length; | 770 | int decodedSamples = d->synth.pcm.length; |
767 | memcpy( &(buffer[0][offset]), d->synth.pcm.samples[0], decodedSamples * sizeof(mad_fixed_t) ); | 771 | memcpy( &(buffer[0][offset]), d->synth.pcm.samples[0], decodedSamples * sizeof(mad_fixed_t) ); |
768 | if ( d->synth.pcm.channels == 2 ) | 772 | if ( d->synth.pcm.channels == 2 ) |
769 | memcpy( &(buffer[1][offset]), d->synth.pcm.samples[1], decodedSamples * sizeof(mad_fixed_t) ); | 773 | memcpy( &(buffer[1][offset]), d->synth.pcm.samples[1], decodedSamples * sizeof(mad_fixed_t) ); |
770 | offset += decodedSamples; | 774 | offset += decodedSamples; |
771 | buffered += decodedSamples; | 775 | buffered += decodedSamples; |
772 | } | 776 | } |
773 | 777 | ||
774 | //qApp->processEvents(); | 778 | //qApp->processEvents(); |
775 | audio_pcm( output, samples, buffer[0], (d->synth.pcm.channels == 2) ? buffer[1] : 0 ); | 779 | audio_pcm( output, samples, buffer[0], (d->synth.pcm.channels == 2) ? buffer[1] : 0 ); |
776 | // audio_pcm( output, samples, buffer[1], buffer[0] ); | 780 | // audio_pcm( output, samples, buffer[1], buffer[0] ); |
777 | // audio_pcm( output, samples, buffer[0], buffer[1] ); | 781 | // audio_pcm( output, samples, buffer[0], buffer[1] ); |
@@ -808,62 +812,62 @@ bool LibMadPlugin::audioReadSamples( short *output, int /*channels*/, long sampl | |||
808 | else | 812 | else |
809 | needInput = TRUE; | 813 | needInput = TRUE; |
810 | } | 814 | } |
811 | while ( ( samplesMade < samples ) && ( !d->input.eof ) ); | 815 | while ( ( samplesMade < samples ) && ( !d->input.eof ) ); |
812 | 816 | ||
813 | return FALSE; | 817 | return FALSE; |
814 | } | 818 | } |
815 | 819 | ||
816 | 820 | ||
817 | double LibMadPlugin::getTime() { | 821 | double LibMadPlugin::getTime() { |
818 | debugMsg( "LibMadPlugin::getTime" ); | 822 | debugMsg( "LibMadPlugin::getTime" ); |
819 | return 0.0; | 823 | return 0.0; |
820 | } | 824 | } |
821 | 825 | ||
822 | 826 | ||
823 | void LibMadPlugin::printID3Tags() { | 827 | void LibMadPlugin::printID3Tags() { |
824 | // qDebug( "LibMadPlugin::printID3Tags" ); | 828 | // odebug << "LibMadPlugin::printID3Tags" << oendl; |
825 | 829 | ||
826 | char id3v1[128 + 1]; | 830 | char id3v1[128 + 1]; |
827 | 831 | ||
828 | if ( ::lseek( d->input.fd, -128, SEEK_END ) == -1 ) { | 832 | if ( ::lseek( d->input.fd, -128, SEEK_END ) == -1 ) { |
829 | // qDebug( "error seeking to id3 tags" ); | 833 | // odebug << "error seeking to id3 tags" << oendl; |
830 | return; | 834 | return; |
831 | } | 835 | } |
832 | 836 | ||
833 | if ( ::read( d->input.fd, id3v1, 128 ) != 128 ) { | 837 | if ( ::read( d->input.fd, id3v1, 128 ) != 128 ) { |
834 | // qDebug( "error reading in id3 tags" ); | 838 | // odebug << "error reading in id3 tags" << oendl; |
835 | return; | 839 | return; |
836 | } | 840 | } |
837 | 841 | ||
838 | if ( ::strncmp( (const char *)id3v1, "TAG", 3 ) != 0 ) { | 842 | if ( ::strncmp( (const char *)id3v1, "TAG", 3 ) != 0 ) { |
839 | debugMsg( "sorry, no id3 tags" ); | 843 | debugMsg( "sorry, no id3 tags" ); |
840 | } else { | 844 | } else { |
841 | int len[5] = { 30, 30, 30, 4, 30 }; | 845 | int len[5] = { 30, 30, 30, 4, 30 }; |
842 | QString label[5] = { tr( "Title" ), tr( "Artist" ), tr( "Album" ), tr( "Year" ), tr( "Comment" ) }; | 846 | QString label[5] = { tr( "Title" ), tr( "Artist" ), tr( "Album" ), tr( "Year" ), tr( "Comment" ) }; |
843 | char *ptr = id3v1 + 3, *ptr2 = ptr + len[0]; | 847 | char *ptr = id3v1 + 3, *ptr2 = ptr + len[0]; |
844 | // qDebug( "ID3 tags in file:" ); | 848 | // odebug << "ID3 tags in file:" << oendl; |
845 | info = ""; | 849 | info = ""; |
846 | for ( int i = 0; i < 5; ptr += len[i], i++, ptr2 += len[i] ) { | 850 | for ( int i = 0; i < 5; ptr += len[i], i++, ptr2 += len[i] ) { |
847 | char push = *ptr2; | 851 | char push = *ptr2; |
848 | *ptr2 = '\0'; | 852 | *ptr2 = '\0'; |
849 | char *ptr3 = ptr2; | 853 | char *ptr3 = ptr2; |
850 | while ( ptr3-1 >= ptr && isspace(ptr3[-1]) ) ptr3--; | 854 | while ( ptr3-1 >= ptr && isspace(ptr3[-1]) ) ptr3--; |
851 | char push2 = *ptr3; *ptr3 = '\0'; | 855 | char push2 = *ptr3; *ptr3 = '\0'; |
852 | if ( strcmp( ptr, "" ) ) { | 856 | if ( strcmp( ptr, "" ) ) { |
853 | if( ((QString)ptr).find(" ") == -1) // don't add anything that has blanks | 857 | if( ((QString)ptr).find(" ") == -1) // don't add anything that has blanks |
854 | info += ( i != 0 ? ", " : "" ) + label[i] + ": " + ptr; | 858 | info += ( i != 0 ? ", " : "" ) + label[i] + ": " + ptr; |
855 | } | 859 | } |
856 | // qDebug( info.latin1() ); | 860 | // odebug << info.latin1() << oendl; |
857 | *ptr3 = push2; | 861 | *ptr3 = push2; |
858 | *ptr2 = push; | 862 | *ptr2 = push; |
859 | } | 863 | } |
860 | if (id3v1[126] == 0 && id3v1[127] != 0) | 864 | if (id3v1[126] == 0 && id3v1[127] != 0) |
861 | info += tr( ", Track: " ) + id3v1[127]; | 865 | info += tr( ", Track: " ) + id3v1[127]; |
862 | } | 866 | } |
863 | 867 | ||
864 | if ( ::lseek(d->input.fd, 0, SEEK_SET) == -1 ) { | 868 | if ( ::lseek(d->input.fd, 0, SEEK_SET) == -1 ) { |
865 | // qDebug( "error seeking back to beginning" ); | 869 | // odebug << "error seeking back to beginning" << oendl; |
866 | return; | 870 | return; |
867 | } | 871 | } |
868 | } | 872 | } |
869 | 873 | ||
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 4ed5921..91153fd 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp | |||
@@ -6,48 +6,56 @@ | |||
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 | 20 | // L.J.Potter added changes Fri 02-15-2002 |
21 | 21 | ||
22 | |||
23 | #include "mediaplayerstate.h" | ||
24 | #include "loopcontrol.h" | ||
25 | #include "videowidget.h" | ||
26 | #include "audiodevice.h" | ||
27 | |||
28 | /* OPIE */ | ||
22 | #include <qpe/qpeapplication.h> | 29 | #include <qpe/qpeapplication.h> |
30 | #include <qpe/mediaplayerplugininterface.h> | ||
31 | #include <opie2/odebug.h> | ||
23 | 32 | ||
24 | #ifdef Q_WS_QWS | 33 | #ifdef Q_WS_QWS |
25 | #include <qpe/qcopenvelope_qws.h> | 34 | #include <qpe/qcopenvelope_qws.h> |
26 | #endif | 35 | #endif |
36 | |||
37 | /* QT */ | ||
38 | |||
39 | /* STD */ | ||
27 | #include <stdio.h> | 40 | #include <stdio.h> |
28 | #include <stdlib.h> | 41 | #include <stdlib.h> |
29 | #include <string.h> | 42 | #include <string.h> |
30 | #include <pthread.h> | 43 | #include <pthread.h> |
31 | #include <errno.h> | 44 | #include <errno.h> |
32 | #include <unistd.h> | 45 | #include <unistd.h> |
33 | #include "loopcontrol.h" | ||
34 | #include "videowidget.h" | ||
35 | #include "audiodevice.h" | ||
36 | #include <qpe/mediaplayerplugininterface.h> | ||
37 | #include "mediaplayerstate.h" | ||
38 | 46 | ||
39 | 47 | ||
40 | 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 |
41 | extern MediaPlayerState *mediaPlayerState; | 49 | extern MediaPlayerState *mediaPlayerState; |
42 | 50 | ||
43 | 51 | ||
44 | //#define DecodeLoopDebug(x) qDebug x | 52 | //#define DecodeLoopDebug(x) qDebug x |
45 | #define DecodeLoopDebug(x) | 53 | #define DecodeLoopDebug(x) |
46 | 54 | ||
47 | 55 | ||
48 | static char *audioBuffer = NULL; | 56 | static char *audioBuffer = NULL; |
49 | static AudioDevice *audioDevice = NULL; | 57 | static AudioDevice *audioDevice = NULL; |
50 | static bool disabledSuspendScreenSaver = FALSE; | 58 | static bool disabledSuspendScreenSaver = FALSE; |
51 | static bool previousSuspendMode = FALSE; | 59 | static bool previousSuspendMode = FALSE; |
52 | 60 | ||
53 | 61 | ||
@@ -87,86 +95,86 @@ void *startAudioThread( void *ptr ) { | |||
87 | if ( threadOkToGo && mpegView->moreAudio ) | 95 | if ( threadOkToGo && mpegView->moreAudio ) |
88 | mpegView->startAudio(); | 96 | mpegView->startAudio(); |
89 | else | 97 | else |
90 | usleep( 10000 ); // Semi-buzy-wait till we are playing again | 98 | usleep( 10000 ); // Semi-buzy-wait till we are playing again |
91 | } | 99 | } |
92 | return 0; | 100 | return 0; |
93 | } | 101 | } |
94 | 102 | ||
95 | 103 | ||
96 | Mutex *audioMutex; | 104 | Mutex *audioMutex; |
97 | 105 | ||
98 | 106 | ||
99 | LoopControl::LoopControl( QObject *parent, const char *name ) | 107 | LoopControl::LoopControl( QObject *parent, const char *name ) |
100 | : QObject( parent, name ) { | 108 | : QObject( parent, name ) { |
101 | isMuted = FALSE; | 109 | isMuted = FALSE; |
102 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); | 110 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); |
103 | //qDebug("starting loopcontrol"); | 111 | //odebug << "starting loopcontrol" << oendl; |
104 | audioMutex = new Mutex; | 112 | audioMutex = new Mutex; |
105 | 113 | ||
106 | pthread_attr_init(&audio_attr); | 114 | pthread_attr_init(&audio_attr); |
107 | #define USE_REALTIME_AUDIO_THREAD | 115 | #define USE_REALTIME_AUDIO_THREAD |
108 | #ifdef USE_REALTIME_AUDIO_THREAD | 116 | #ifdef USE_REALTIME_AUDIO_THREAD |
109 | // Attempt to set it to real-time round robin | 117 | // Attempt to set it to real-time round robin |
110 | if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { | 118 | if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { |
111 | sched_param params; | 119 | sched_param params; |
112 | params.sched_priority = 50; | 120 | params.sched_priority = 50; |
113 | pthread_attr_setschedparam(&audio_attr,¶ms); | 121 | pthread_attr_setschedparam(&audio_attr,¶ms); |
114 | } else { | 122 | } else { |
115 | // qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); | 123 | // odebug << "Error setting up a realtime thread, reverting to using a normal thread." << oendl; |
116 | pthread_attr_destroy(&audio_attr); | 124 | pthread_attr_destroy(&audio_attr); |
117 | pthread_attr_init(&audio_attr); | 125 | pthread_attr_init(&audio_attr); |
118 | } | 126 | } |
119 | #endif | 127 | #endif |
120 | //qDebug("create audio thread"); | 128 | //odebug << "create audio thread" << oendl; |
121 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); | 129 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); |
122 | } | 130 | } |
123 | 131 | ||
124 | 132 | ||
125 | LoopControl::~LoopControl() { | 133 | LoopControl::~LoopControl() { |
126 | stop(); | 134 | stop(); |
127 | } | 135 | } |
128 | 136 | ||
129 | 137 | ||
130 | static long prev_frame = 0; | 138 | static long prev_frame = 0; |
131 | static int currentSample = 0; | 139 | static int currentSample = 0; |
132 | 140 | ||
133 | 141 | ||
134 | void LoopControl::timerEvent( QTimerEvent *te ) { | 142 | void LoopControl::timerEvent( QTimerEvent *te ) { |
135 | 143 | ||
136 | if ( te->timerId() == videoId ) | 144 | if ( te->timerId() == videoId ) |
137 | startVideo(); | 145 | startVideo(); |
138 | 146 | ||
139 | if ( te->timerId() == sliderId ) { | 147 | if ( te->timerId() == sliderId ) { |
140 | if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { | 148 | if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { |
141 | mediaPlayerState->updatePosition( audioSampleCounter ); | 149 | mediaPlayerState->updatePosition( audioSampleCounter ); |
142 | } else if ( hasVideoChannel && moreVideo ) { | 150 | } else if ( hasVideoChannel && moreVideo ) { |
143 | mediaPlayerState->updatePosition( current_frame ); | 151 | mediaPlayerState->updatePosition( current_frame ); |
144 | } | 152 | } |
145 | } | 153 | } |
146 | 154 | ||
147 | if ( !moreVideo && !moreAudio ) { | 155 | if ( !moreVideo && !moreAudio ) { |
148 | mediaPlayerState->setPlaying( FALSE ); | 156 | mediaPlayerState->setPlaying( FALSE ); |
149 | mediaPlayerState->setNext(); | 157 | mediaPlayerState->setNext(); |
150 | } | 158 | } |
151 | } | 159 | } |
152 | 160 | ||
153 | 161 | ||
154 | void LoopControl::setPosition( long pos ) { | 162 | void LoopControl::setPosition( long pos ) { |
155 | audioMutex->lock(); | 163 | audioMutex->lock(); |
156 | // qDebug("Loop control %d", pos); | 164 | // odebug << "Loop control " << pos << "" << oendl; |
157 | if ( hasVideoChannel && hasAudioChannel ) { | 165 | if ( hasVideoChannel && hasAudioChannel ) { |
158 | playtime.restart(); | 166 | playtime.restart(); |
159 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); | 167 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); |
160 | current_frame = pos + 1; | 168 | current_frame = pos + 1; |
161 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 169 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
162 | prev_frame = current_frame - 1; | 170 | prev_frame = current_frame - 1; |
163 | currentSample = (int)( (double)current_frame * freq / framerate ); | 171 | currentSample = (int)( (double)current_frame * freq / framerate ); |
164 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); | 172 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); |
165 | audioSampleCounter = currentSample - 1; | 173 | audioSampleCounter = currentSample - 1; |
166 | } else if ( hasVideoChannel ) { | 174 | } else if ( hasVideoChannel ) { |
167 | playtime.restart(); | 175 | playtime.restart(); |
168 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); | 176 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); |
169 | current_frame = pos + 1; | 177 | current_frame = pos + 1; |
170 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 178 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
171 | prev_frame = current_frame - 1; | 179 | prev_frame = current_frame - 1; |
172 | } else if ( hasAudioChannel ) { | 180 | } else if ( hasAudioChannel ) { |
@@ -206,84 +214,84 @@ void LoopControl::startVideo() { | |||
206 | moreVideo = videoUI->playVideo(); | 214 | moreVideo = videoUI->playVideo(); |
207 | prev_frame = current_frame; | 215 | prev_frame = current_frame; |
208 | } | 216 | } |
209 | 217 | ||
210 | } else { | 218 | } else { |
211 | 219 | ||
212 | moreVideo = FALSE; | 220 | moreVideo = FALSE; |
213 | killTimer( videoId ); | 221 | killTimer( videoId ); |
214 | 222 | ||
215 | } | 223 | } |
216 | 224 | ||
217 | } | 225 | } |
218 | } | 226 | } |
219 | 227 | ||
220 | 228 | ||
221 | void LoopControl::startAudio() { | 229 | void LoopControl::startAudio() { |
222 | 230 | ||
223 | audioMutex->lock(); | 231 | audioMutex->lock(); |
224 | if ( moreAudio ) { | 232 | if ( moreAudio ) { |
225 | 233 | ||
226 | if ( !isMuted && mediaPlayerState->curDecoder() ) { | 234 | if ( !isMuted && mediaPlayerState->curDecoder() ) { |
227 | 235 | ||
228 | currentSample = audioSampleCounter + 1; | 236 | currentSample = audioSampleCounter + 1; |
229 | 237 | ||
230 | // if ( currentSample != audioSampleCounter + 1 ) | 238 | // if ( currentSample != audioSampleCounter + 1 ) |
231 | // qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); | 239 | // odebug << "out of sync with decoder " << currentSample << " " << audioSampleCounter << "" << oendl; |
232 | 240 | ||
233 | long samplesRead = 0; | 241 | long samplesRead = 0; |
234 | bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); | 242 | bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); |
235 | long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; | 243 | long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; |
236 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; | 244 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; |
237 | 245 | ||
238 | // this causes drop outs not sure why its even here | 246 | // this causes drop outs not sure why its even here |
239 | if ( hasVideoChannel ) { | 247 | if ( hasVideoChannel ) { |
240 | if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { | 248 | if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { |
241 | usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); | 249 | usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); |
242 | } | 250 | } |
243 | else if ( sampleWaitTime <= -5000 ) { | 251 | else if ( sampleWaitTime <= -5000 ) { |
244 | // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); | 252 | // odebug << "need to catch up by: " << -sampleWaitTime << " (" << currentSample << "," << sampleWeShouldBeAt << ")" << oendl; |
245 | // //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); | 253 | // //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); |
246 | currentSample = sampleWeShouldBeAt; | 254 | currentSample = sampleWeShouldBeAt; |
247 | } | 255 | } |
248 | } | 256 | } |
249 | 257 | ||
250 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); | 258 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); |
251 | 259 | ||
252 | if( mediaPlayerState->isStreaming == FALSE) | 260 | if( mediaPlayerState->isStreaming == FALSE) |
253 | audioSampleCounter = currentSample + samplesRead - 1; | 261 | audioSampleCounter = currentSample + samplesRead - 1; |
254 | 262 | ||
255 | moreAudio = readOk && (audioSampleCounter <= total_audio_samples); | 263 | moreAudio = readOk && (audioSampleCounter <= total_audio_samples); |
256 | 264 | ||
257 | } else { | 265 | } else { |
258 | 266 | ||
259 | moreAudio = FALSE; | 267 | moreAudio = FALSE; |
260 | 268 | ||
261 | } | 269 | } |
262 | 270 | ||
263 | } | 271 | } |
264 | 272 | ||
265 | audioMutex->unlock(); | 273 | audioMutex->unlock(); |
266 | } | 274 | } |
267 | 275 | ||
268 | 276 | ||
269 | void LoopControl::killTimers() { | 277 | void LoopControl::killTimers() { |
270 | 278 | ||
271 | audioMutex->lock(); | 279 | audioMutex->lock(); |
272 | 280 | ||
273 | if ( hasVideoChannel ) | 281 | if ( hasVideoChannel ) |
274 | killTimer( videoId ); | 282 | killTimer( videoId ); |
275 | killTimer( sliderId ); | 283 | killTimer( sliderId ); |
276 | threadOkToGo = FALSE; | 284 | threadOkToGo = FALSE; |
277 | 285 | ||
278 | audioMutex->unlock(); | 286 | audioMutex->unlock(); |
279 | } | 287 | } |
280 | 288 | ||
281 | 289 | ||
282 | void LoopControl::startTimers() { | 290 | void LoopControl::startTimers() { |
283 | 291 | ||
284 | audioMutex->lock(); | 292 | audioMutex->lock(); |
285 | 293 | ||
286 | moreVideo = FALSE; | 294 | moreVideo = FALSE; |
287 | moreAudio = FALSE; | 295 | moreAudio = FALSE; |
288 | 296 | ||
289 | if ( hasVideoChannel ) { | 297 | if ( hasVideoChannel ) { |
@@ -311,112 +319,112 @@ void LoopControl::setPaused( bool pause ) { | |||
311 | if ( pause ) { | 319 | if ( pause ) { |
312 | killTimers(); | 320 | killTimers(); |
313 | } else { | 321 | } else { |
314 | // Force an update of the position | 322 | // Force an update of the position |
315 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); | 323 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); |
316 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); | 324 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); |
317 | // Just like we never stopped | 325 | // Just like we never stopped |
318 | startTimers(); | 326 | startTimers(); |
319 | } | 327 | } |
320 | } | 328 | } |
321 | 329 | ||
322 | 330 | ||
323 | void LoopControl::stop( bool willPlayAgainShortly ) { | 331 | void LoopControl::stop( bool willPlayAgainShortly ) { |
324 | 332 | ||
325 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 333 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
326 | if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { | 334 | if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { |
327 | disabledSuspendScreenSaver = FALSE; | 335 | disabledSuspendScreenSaver = FALSE; |
328 | // Re-enable the suspend mode | 336 | // Re-enable the suspend mode |
329 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 337 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
330 | } | 338 | } |
331 | #endif | 339 | #endif |
332 | 340 | ||
333 | if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { | 341 | if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { |
334 | 342 | ||
335 | killTimers(); | 343 | killTimers(); |
336 | 344 | ||
337 | audioMutex->lock(); | 345 | audioMutex->lock(); |
338 | 346 | ||
339 | mediaPlayerState->curDecoder()->close(); | 347 | mediaPlayerState->curDecoder()->close(); |
340 | 348 | ||
341 | if ( audioDevice ) { | 349 | if ( audioDevice ) { |
342 | delete audioDevice; | 350 | delete audioDevice; |
343 | delete audioBuffer; | 351 | delete audioBuffer; |
344 | audioDevice = 0; | 352 | audioDevice = 0; |
345 | audioBuffer = 0; | 353 | audioBuffer = 0; |
346 | } | 354 | } |
347 | 355 | ||
348 | audioMutex->unlock(); | 356 | audioMutex->unlock(); |
349 | } | 357 | } |
350 | audioSampleCounter=0; | 358 | audioSampleCounter=0; |
351 | current_frame=0; | 359 | current_frame=0; |
352 | total_audio_samples=0; | 360 | total_audio_samples=0; |
353 | } | 361 | } |
354 | 362 | ||
355 | 363 | ||
356 | bool LoopControl::init( const QString& filename ) { | 364 | bool LoopControl::init( const QString& filename ) { |
357 | stop(); | 365 | stop(); |
358 | audioMutex->lock(); | 366 | audioMutex->lock(); |
359 | 367 | ||
360 | fileName = filename; | 368 | fileName = filename; |
361 | stream = 0; // only play stream 0 for now | 369 | stream = 0; // only play stream 0 for now |
362 | current_frame = total_video_frames = total_audio_samples = 0; | 370 | current_frame = total_video_frames = total_audio_samples = 0; |
363 | 371 | ||
364 | // qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); | 372 | // odebug << "Using the " << mediaPlayerState->curDecoder()->pluginName() << " decoder" << oendl; |
365 | 373 | ||
366 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin | 374 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin |
367 | // if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { | 375 | // if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { |
368 | // if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename )) { | 376 | // if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename )) { |
369 | // total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); | 377 | // total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); |
370 | // mediaPlayerState->libMpeg3Decoder()->close(); | 378 | // mediaPlayerState->libMpeg3Decoder()->close(); |
371 | // } | 379 | // } |
372 | // } | 380 | // } |
373 | 381 | ||
374 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { | 382 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { |
375 | audioMutex->unlock(); | 383 | audioMutex->unlock(); |
376 | return FALSE; | 384 | return FALSE; |
377 | } | 385 | } |
378 | 386 | ||
379 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; | 387 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; |
380 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; | 388 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; |
381 | 389 | ||
382 | if ( hasAudioChannel ) { | 390 | if ( hasAudioChannel ) { |
383 | int astream = 0; | 391 | int astream = 0; |
384 | 392 | ||
385 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMpeg3Plugin") ) | 393 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMpeg3Plugin") ) |
386 | channels = 2; //dont akx me why, but it needs this hack | 394 | channels = 2; //dont akx me why, but it needs this hack |
387 | else | 395 | else |
388 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); | 396 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); |
389 | 397 | ||
390 | // qDebug( "LC- channels = %d", channels ); | 398 | // odebug << "LC- channels = " << channels << "" << oendl; |
391 | 399 | ||
392 | // if ( !total_audio_samples ) | 400 | // if ( !total_audio_samples ) |
393 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); | 401 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); |
394 | 402 | ||
395 | total_audio_samples += 1000; | 403 | total_audio_samples += 1000; |
396 | // qDebug("total samples %d", total_audio_samples); | 404 | // odebug << "total samples " << total_audio_samples << "" << oendl; |
397 | mediaPlayerState->setLength( total_audio_samples ); | 405 | mediaPlayerState->setLength( total_audio_samples ); |
398 | 406 | ||
399 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); | 407 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); |
400 | // qDebug( "LC- frequency = %d", freq ); | 408 | // odebug << "LC- frequency = " << freq << "" << oendl; |
401 | 409 | ||
402 | audioSampleCounter = 0; | 410 | audioSampleCounter = 0; |
403 | int bits_per_sample; | 411 | int bits_per_sample; |
404 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { | 412 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { |
405 | bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); | 413 | bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); |
406 | // qDebug("using stupid hack"); | 414 | // odebug << "using stupid hack" << oendl; |
407 | } else { | 415 | } else { |
408 | bits_per_sample=0; | 416 | bits_per_sample=0; |
409 | } | 417 | } |
410 | 418 | ||
411 | audioDevice = new AudioDevice( freq, channels, bits_per_sample); | 419 | audioDevice = new AudioDevice( freq, channels, bits_per_sample); |
412 | audioBuffer = new char[ audioDevice->bufferSize() ]; | 420 | audioBuffer = new char[ audioDevice->bufferSize() ]; |
413 | channels = audioDevice->channels(); | 421 | channels = audioDevice->channels(); |
414 | 422 | ||
415 | //### must check which frequency is actually used. | 423 | //### must check which frequency is actually used. |
416 | static const int size = 1; | 424 | static const int size = 1; |
417 | short int buf[size]; | 425 | short int buf[size]; |
418 | long samplesRead = 0; | 426 | long samplesRead = 0; |
419 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); | 427 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); |
420 | } | 428 | } |
421 | 429 | ||
422 | if ( hasVideoChannel ) { | 430 | if ( hasVideoChannel ) { |
@@ -438,41 +446,41 @@ bool LoopControl::init( const QString& filename ) { | |||
438 | 446 | ||
439 | } | 447 | } |
440 | 448 | ||
441 | current_frame = 0; | 449 | current_frame = 0; |
442 | prev_frame = -1; | 450 | prev_frame = -1; |
443 | 451 | ||
444 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( setPosition(long) ) ); | 452 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( setPosition(long) ) ); |
445 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 453 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
446 | 454 | ||
447 | audioMutex->unlock(); | 455 | audioMutex->unlock(); |
448 | 456 | ||
449 | return TRUE; | 457 | return TRUE; |
450 | } | 458 | } |
451 | 459 | ||
452 | 460 | ||
453 | void LoopControl::play() { | 461 | void LoopControl::play() { |
454 | // qDebug("LC- play"); | 462 | // odebug << "LC- play" << oendl; |
455 | mediaPlayerState->setPosition( 0); //uglyhack | 463 | mediaPlayerState->setPosition( 0); //uglyhack |
456 | 464 | ||
457 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 465 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
458 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { | 466 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { |
459 | disabledSuspendScreenSaver = TRUE; | 467 | disabledSuspendScreenSaver = TRUE; |
460 | previousSuspendMode = hasVideoChannel; | 468 | previousSuspendMode = hasVideoChannel; |
461 | // Stop the screen from blanking and power saving state | 469 | // Stop the screen from blanking and power saving state |
462 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | 470 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) |
463 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 471 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
464 | } | 472 | } |
465 | #endif | 473 | #endif |
466 | 474 | ||
467 | playtime.start(); | 475 | playtime.start(); |
468 | startTimers(); | 476 | startTimers(); |
469 | } | 477 | } |
470 | 478 | ||
471 | 479 | ||
472 | void LoopControl::setMute( bool on ) { | 480 | void LoopControl::setMute( bool on ) { |
473 | if ( on != isMuted ) { | 481 | if ( on != isMuted ) { |
474 | isMuted = on; | 482 | isMuted = on; |
475 | if ( !on ) { | 483 | if ( !on ) { |
476 | // Force an update of the position | 484 | // Force an update of the position |
477 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); | 485 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); |
478 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); | 486 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); |
diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.cpp b/core/multimedia/opieplayer/loopcontrol_threaded.cpp index 0a1fc17..9a162c2 100644 --- a/core/multimedia/opieplayer/loopcontrol_threaded.cpp +++ b/core/multimedia/opieplayer/loopcontrol_threaded.cpp | |||
@@ -6,54 +6,60 @@ | |||
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 | #define _REENTRANT | 20 | #define _REENTRANT |
21 | 21 | ||
22 | #include "mediaplayerplugininterface.h" | ||
23 | #include "loopcontrol.h" | ||
24 | #include "audiodevice.h" | ||
25 | #include "videowidget.h" | ||
26 | #include "audiowidget.h" | ||
27 | #include "mediaplayerstate.h" | ||
28 | |||
29 | /* OPIE */ | ||
22 | #include <qpe/qpeapplication.h> | 30 | #include <qpe/qpeapplication.h> |
23 | #include <qpe/custom.h> | 31 | #include <qpe/custom.h> |
24 | #include <qimage.h> | 32 | |
25 | #include <qpainter.h> | ||
26 | #if !defined(QT_NO_COP) | 33 | #if !defined(QT_NO_COP) |
27 | #include <qpe/qcopenvelope_qws.h> | 34 | #include <qpe/qcopenvelope_qws.h> |
28 | #endif | 35 | #endif |
29 | #include "mediaplayerplugininterface.h" | 36 | |
37 | #include <opie2/odebug.h> | ||
38 | |||
39 | /* QT */ | ||
40 | #include <qimage.h> | ||
41 | #include <qpainter.h> | ||
42 | |||
43 | /* STD */ | ||
30 | #include <stdio.h> | 44 | #include <stdio.h> |
31 | #include <stdlib.h> | 45 | #include <stdlib.h> |
32 | #include <string.h> | 46 | #include <string.h> |
33 | #include <time.h> | 47 | #include <time.h> |
34 | #include <unistd.h> | 48 | #include <unistd.h> |
35 | #include <pthread.h> | 49 | #include <pthread.h> |
36 | #include "loopcontrol.h" | ||
37 | #include "audiodevice.h" | ||
38 | #include "videowidget.h" | ||
39 | #include "audiowidget.h" | ||
40 | #include "mediaplayerstate.h" | ||
41 | |||
42 | |||
43 | |||
44 | 50 | ||
45 | 51 | ||
46 | extern VideoWidget *videoUI; // now only needed to tell it to play a frame | 52 | extern VideoWidget *videoUI; // now only needed to tell it to play a frame |
47 | extern MediaPlayerState *mediaPlayerState; | 53 | extern MediaPlayerState *mediaPlayerState; |
48 | 54 | ||
49 | 55 | ||
50 | #define DecodeLoopDebug(x) qDebug x | 56 | #define DecodeLoopDebug(x) qDebug x |
51 | //#define DecodeLoopDebug(x) | 57 | //#define DecodeLoopDebug(x) |
52 | 58 | ||
53 | 59 | ||
54 | static char *audioBuffer = NULL; | 60 | static char *audioBuffer = NULL; |
55 | static AudioDevice *audioDevice = NULL; | 61 | static AudioDevice *audioDevice = NULL; |
56 | static bool disabledSuspendScreenSaver = FALSE; | 62 | static bool disabledSuspendScreenSaver = FALSE; |
57 | 63 | ||
58 | 64 | ||
59 | pthread_t video_tid; | 65 | pthread_t video_tid; |
@@ -178,33 +184,33 @@ void LoopControl::timerEvent( QTimerEvent* ) { | |||
178 | 184 | ||
179 | } | 185 | } |
180 | } | 186 | } |
181 | 187 | ||
182 | 188 | ||
183 | 189 | ||
184 | 190 | ||
185 | void LoopControl::setPosition( long pos ) { | 191 | void LoopControl::setPosition( long pos ) { |
186 | if ( sendingNewPos ) { | 192 | if ( sendingNewPos ) { |
187 | sendingNewPos = FALSE; | 193 | sendingNewPos = FALSE; |
188 | return; | 194 | return; |
189 | } | 195 | } |
190 | 196 | ||
191 | if ( hasVideoChannel && hasAudioChannel ) { | 197 | if ( hasVideoChannel && hasAudioChannel ) { |
192 | videoMutex->lock(); | 198 | videoMutex->lock(); |
193 | audioMutex->lock(); | 199 | audioMutex->lock(); |
194 | //qDebug("setting position"); | 200 | //odebug << "setting position" << oendl; |
195 | playtime.restart(); | 201 | playtime.restart(); |
196 | playtime = playtime.addMSecs( -pos * 1000 / framerate ); | 202 | playtime = playtime.addMSecs( -pos * 1000 / framerate ); |
197 | //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate; | 203 | //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate; |
198 | current_frame = pos + 1; | 204 | current_frame = pos + 1; |
199 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 205 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
200 | prev_frame = current_frame - 1; | 206 | prev_frame = current_frame - 1; |
201 | currentSample = (int)( current_frame * freq / framerate ); | 207 | currentSample = (int)( current_frame * freq / framerate ); |
202 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); | 208 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); |
203 | audioSampleCounter = currentSample - 1; | 209 | audioSampleCounter = currentSample - 1; |
204 | audioMutex->unlock(); | 210 | audioMutex->unlock(); |
205 | videoMutex->unlock(); | 211 | videoMutex->unlock(); |
206 | } else if ( hasVideoChannel ) { | 212 | } else if ( hasVideoChannel ) { |
207 | videoMutex->lock(); | 213 | videoMutex->lock(); |
208 | playtime.restart(); | 214 | playtime.restart(); |
209 | playtime = playtime.addMSecs( -pos * 1000 / framerate ); | 215 | playtime = playtime.addMSecs( -pos * 1000 / framerate ); |
210 | //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate; | 216 | //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate; |
@@ -279,48 +285,48 @@ void LoopControl::startVideo() { | |||
279 | videoMutex->unlock(); | 285 | videoMutex->unlock(); |
280 | } | 286 | } |
281 | 287 | ||
282 | videoMutex->lock(); | 288 | videoMutex->lock(); |
283 | done = current_frame >= prev_frame; | 289 | done = current_frame >= prev_frame; |
284 | videoMutex->unlock(); | 290 | videoMutex->unlock(); |
285 | */ | 291 | */ |
286 | videoMutex->lock(); | 292 | videoMutex->lock(); |
287 | current_frame = int( (double)playtime.elapsed() * (double)framerate / 1000.0 ); | 293 | current_frame = int( (double)playtime.elapsed() * (double)framerate / 1000.0 ); |
288 | done = current_frame >= prev_frame; | 294 | done = current_frame >= prev_frame; |
289 | videoMutex->unlock(); | 295 | videoMutex->unlock(); |
290 | if ( !done ) | 296 | if ( !done ) |
291 | usleep( 1000 ); // wait a bit | 297 | usleep( 1000 ); // wait a bit |
292 | 298 | ||
293 | } while ( !done ); | 299 | } while ( !done ); |
294 | 300 | ||
295 | // qDebug("elapsed: %i %i (%f)", int( playtime.elapsed() ), current_frame, framerate ); | 301 | // odebug << "elapsed: " << int( playtime.elapsed() ) << " " << current_frame << " (" << framerate << ")" << oendl; |
296 | 302 | ||
297 | } else { | 303 | } else { |
298 | videoMutex->lock(); | 304 | videoMutex->lock(); |
299 | current_frame++; | 305 | current_frame++; |
300 | videoMutex->unlock(); | 306 | videoMutex->unlock(); |
301 | } | 307 | } |
302 | 308 | ||
303 | videoMutex->lock(); | 309 | videoMutex->lock(); |
304 | bool check = current_frame && current_frame > prev_frame; | 310 | bool check = current_frame && current_frame > prev_frame; |
305 | videoMutex->unlock(); | 311 | videoMutex->unlock(); |
306 | 312 | ||
307 | if ( check ) { | 313 | if ( check ) { |
308 | videoMutex->lock(); | 314 | videoMutex->lock(); |
309 | if ( current_frame > prev_frame + 1 ) { | 315 | if ( current_frame > prev_frame + 1 ) { |
310 | // qDebug("skipped a frame"); | 316 | // odebug << "skipped a frame" << oendl; |
311 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 317 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
312 | } | 318 | } |
313 | prev_frame = current_frame; | 319 | prev_frame = current_frame; |
314 | if ( moreVideo = videoUI->playVideo() ) | 320 | if ( moreVideo = videoUI->playVideo() ) |
315 | emitChangePos = TRUE; | 321 | emitChangePos = TRUE; |
316 | videoMutex->unlock(); | 322 | videoMutex->unlock(); |
317 | } | 323 | } |
318 | 324 | ||
319 | } else | 325 | } else |
320 | moreVideo = FALSE; | 326 | moreVideo = FALSE; |
321 | 327 | ||
322 | } | 328 | } |
323 | 329 | ||
324 | if ( !moreVideo && !moreAudio ) | 330 | if ( !moreVideo && !moreAudio ) |
325 | emitPlayFinished = TRUE; | 331 | emitPlayFinished = TRUE; |
326 | 332 | ||
@@ -328,139 +334,139 @@ void LoopControl::startVideo() { | |||
328 | } | 334 | } |
329 | 335 | ||
330 | void LoopControl::startAudio() { | 336 | void LoopControl::startAudio() { |
331 | moreAudio = TRUE; | 337 | moreAudio = TRUE; |
332 | 338 | ||
333 | while ( moreAudio ) { | 339 | while ( moreAudio ) { |
334 | 340 | ||
335 | if ( !isMuted && mediaPlayerState->curDecoder() && hasAudioChannel ) { | 341 | if ( !isMuted && mediaPlayerState->curDecoder() && hasAudioChannel ) { |
336 | 342 | ||
337 | audioMutex->lock(); | 343 | audioMutex->lock(); |
338 | currentSample = mediaPlayerState->curDecoder()->audioGetSample( stream ); | 344 | currentSample = mediaPlayerState->curDecoder()->audioGetSample( stream ); |
339 | 345 | ||
340 | if ( currentSample == 0 ) | 346 | if ( currentSample == 0 ) |
341 | currentSample = audioSampleCounter + 1; | 347 | currentSample = audioSampleCounter + 1; |
342 | 348 | ||
343 | // if ( currentSample != audioSampleCounter + 1 ) | 349 | // if ( currentSample != audioSampleCounter + 1 ) |
344 | // qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); | 350 | // odebug << "out of sync with decoder " << currentSample << " " << audioSampleCounter << "" << oendl; |
345 | audioMutex->unlock(); | 351 | audioMutex->unlock(); |
346 | 352 | ||
347 | /* | 353 | /* |
348 | int sampleWeShouldBeAt = int( playtime.elapsed() ) * freq / 1000; | 354 | int sampleWeShouldBeAt = int( playtime.elapsed() ) * freq / 1000; |
349 | 355 | ||
350 | if ( sampleWeShouldBeAt - currentSample > 20000 ) { | 356 | if ( sampleWeShouldBeAt - currentSample > 20000 ) { |
351 | mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); | 357 | mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); |
352 | currentSample = sampleWeShouldBeAt; | 358 | currentSample = sampleWeShouldBeAt; |
353 | } | 359 | } |
354 | */ | 360 | */ |
355 | long samplesRead = 0; | 361 | long samplesRead = 0; |
356 | 362 | ||
357 | const long samples = 1024; | 363 | const long samples = 1024; |
358 | 364 | ||
359 | moreAudio = !mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, samples, samplesRead, stream ); | 365 | moreAudio = !mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, samples, samplesRead, stream ); |
360 | 366 | ||
361 | audioMutex->lock(); | 367 | audioMutex->lock(); |
362 | long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; | 368 | long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; |
363 | //long sampleWeShouldBeAt = long( clock() - begin ) * (double) freq / CLOCKS_PER_SEC; | 369 | //long sampleWeShouldBeAt = long( clock() - begin ) * (double) freq / CLOCKS_PER_SEC; |
364 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; | 370 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; |
365 | audioMutex->unlock(); | 371 | audioMutex->unlock(); |
366 | 372 | ||
367 | if ( sampleWaitTime >= 0 && sampleWaitTime <= 2000 ) { | 373 | if ( sampleWaitTime >= 0 && sampleWaitTime <= 2000 ) { |
368 | //qDebug("sampleWaitTime: %i", sampleWaitTime); | 374 | //odebug << "sampleWaitTime: " << sampleWaitTime << "" << oendl; |
369 | usleep( ( sampleWaitTime * 1000000 ) / ( freq ) ); | 375 | usleep( ( sampleWaitTime * 1000000 ) / ( freq ) ); |
370 | } else { | 376 | } else { |
371 | audioMutex->lock(); | 377 | audioMutex->lock(); |
372 | if ( sampleWaitTime <= -2000 ) { | 378 | if ( sampleWaitTime <= -2000 ) { |
373 | // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); | 379 | // odebug << "need to catch up by: " << -sampleWaitTime << " (" << currentSample << "," << sampleWeShouldBeAt << ")" << oendl; |
374 | mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); | 380 | mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); |
375 | currentSample = sampleWeShouldBeAt; | 381 | currentSample = sampleWeShouldBeAt; |
376 | } | 382 | } |
377 | audioMutex->unlock(); | 383 | audioMutex->unlock(); |
378 | } | 384 | } |
379 | 385 | ||
380 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); | 386 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); |
381 | 387 | ||
382 | audioMutex->lock(); | 388 | audioMutex->lock(); |
383 | // audioSampleCounter += samplesRead; | 389 | // audioSampleCounter += samplesRead; |
384 | audioSampleCounter = currentSample + samplesRead - 1; | 390 | audioSampleCounter = currentSample + samplesRead - 1; |
385 | audioMutex->unlock(); | 391 | audioMutex->unlock(); |
386 | 392 | ||
387 | if ( !hasVideoChannel ) | 393 | if ( !hasVideoChannel ) |
388 | emitChangePos = TRUE; | 394 | emitChangePos = TRUE; |
389 | 395 | ||
390 | //qDebug("currentSample: %i audioSampleCounter: %i total_audio_samples: %i", currentSample, audioSampleCounter, total_audio_samples); | 396 | //odebug << "currentSample: " << currentSample << " audioSampleCounter: " << audioSampleCounter << " total_audio_samples: " << total_audio_samples << "" << oendl; |
391 | // qDebug("current: %i counter: %i total: %i", currentSample, audioSampleCounter, (int)total_audio_samples); | 397 | // odebug << "current: " << currentSample << " counter: " << audioSampleCounter << " total: " << (int)total_audio_samples << "" << oendl; |
392 | moreAudio = audioSampleCounter <= total_audio_samples; | 398 | moreAudio = audioSampleCounter <= total_audio_samples; |
393 | 399 | ||
394 | } else { | 400 | } else { |
395 | 401 | ||
396 | if ( mediaPlayerState->curDecoder() && hasAudioChannel ) | 402 | if ( mediaPlayerState->curDecoder() && hasAudioChannel ) |
397 | usleep( 100000 ); // Check every 1/10 sec to see if mute is off | 403 | usleep( 100000 ); // Check every 1/10 sec to see if mute is off |
398 | else | 404 | else |
399 | moreAudio = FALSE; | 405 | moreAudio = FALSE; |
400 | 406 | ||
401 | } | 407 | } |
402 | } | 408 | } |
403 | 409 | ||
404 | // qDebug( "End of file" ); | 410 | // odebug << "End of file" << oendl; |
405 | 411 | ||
406 | if ( !moreVideo && !moreAudio ) | 412 | if ( !moreVideo && !moreAudio ) |
407 | emitPlayFinished = TRUE; | 413 | emitPlayFinished = TRUE; |
408 | 414 | ||
409 | pthread_exit(NULL); | 415 | pthread_exit(NULL); |
410 | } | 416 | } |
411 | 417 | ||
412 | void LoopControl::killTimers() { | 418 | void LoopControl::killTimers() { |
413 | if ( hasVideoChannel ) { | 419 | if ( hasVideoChannel ) { |
414 | if ( pthread_self() != video_tid ) { | 420 | if ( pthread_self() != video_tid ) { |
415 | if ( pthread_cancel(video_tid) == 0 ) { | 421 | if ( pthread_cancel(video_tid) == 0 ) { |
416 | void *thread_result = 0; | 422 | void *thread_result = 0; |
417 | if ( pthread_join(video_tid,&thread_result) != 0 ) | 423 | if ( pthread_join(video_tid,&thread_result) != 0 ) |
418 | // qDebug("thread join error 1"); | 424 | // odebug << "thread join error 1" << oendl; |
419 | pthread_attr_destroy(&video_attr); | 425 | pthread_attr_destroy(&video_attr); |
420 | } | 426 | } |
421 | } | 427 | } |
422 | } | 428 | } |
423 | if ( hasAudioChannel ) { | 429 | if ( hasAudioChannel ) { |
424 | if ( pthread_self() != audio_tid ) { | 430 | if ( pthread_self() != audio_tid ) { |
425 | if ( pthread_cancel(audio_tid) == 0 ) { | 431 | if ( pthread_cancel(audio_tid) == 0 ) { |
426 | void *thread_result = 0; | 432 | void *thread_result = 0; |
427 | if ( pthread_join(audio_tid,&thread_result) != 0 ) | 433 | if ( pthread_join(audio_tid,&thread_result) != 0 ) |
428 | // qDebug("thread join error 2"); | 434 | // odebug << "thread join error 2" << oendl; |
429 | pthread_attr_destroy(&audio_attr); | 435 | pthread_attr_destroy(&audio_attr); |
430 | } | 436 | } |
431 | } | 437 | } |
432 | } | 438 | } |
433 | } | 439 | } |
434 | 440 | ||
435 | void LoopControl::startTimers() { | 441 | void LoopControl::startTimers() { |
436 | moreVideo = FALSE; | 442 | moreVideo = FALSE; |
437 | moreAudio = FALSE; | 443 | moreAudio = FALSE; |
438 | 444 | ||
439 | if ( hasVideoChannel ) { | 445 | if ( hasVideoChannel ) { |
440 | moreVideo = TRUE; | 446 | moreVideo = TRUE; |
441 | pthread_attr_init(&video_attr); | 447 | pthread_attr_init(&video_attr); |
442 | pthread_create(&video_tid, &video_attr, (void * (*)(void *))startVideoThread, this); | 448 | pthread_create(&video_tid, &video_attr, (void * (*)(void *))startVideoThread, this); |
443 | } | 449 | } |
444 | 450 | ||
445 | if ( hasAudioChannel ) { | 451 | if ( hasAudioChannel ) { |
446 | moreAudio = TRUE; | 452 | moreAudio = TRUE; |
447 | pthread_attr_init(&audio_attr); | 453 | pthread_attr_init(&audio_attr); |
448 | #ifdef USE_REALTIME_AUDIO_THREAD | 454 | #ifdef USE_REALTIME_AUDIO_THREAD |
449 | pthread_attr_setschedpolicy(&audio_attr,SCHED_RR); // Real-time round robin | 455 | pthread_attr_setschedpolicy(&audio_attr,SCHED_RR); // Real-time round robin |
450 | //qDebug("min: %i, max: %i", sched_get_priority_min( SCHED_RR ), sched_get_priority_max( SCHED_RR ) ); | 456 | //odebug << "min: " << sched_get_priority_min( SCHED_RR ) << ", max: " << sched_get_priority_max( SCHED_RR ) << "" << oendl; |
451 | sched_param params; | 457 | sched_param params; |
452 | params.sched_priority = 50; | 458 | params.sched_priority = 50; |
453 | pthread_attr_setschedparam(&audio_attr,¶ms); | 459 | pthread_attr_setschedparam(&audio_attr,¶ms); |
454 | #endif | 460 | #endif |
455 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); | 461 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); |
456 | } | 462 | } |
457 | } | 463 | } |
458 | 464 | ||
459 | 465 | ||
460 | 466 | ||
461 | 467 | ||
462 | void LoopControl::setPaused( bool pause ) { | 468 | void LoopControl::setPaused( bool pause ) { |
463 | static int whenPaused = 0; | 469 | static int whenPaused = 0; |
464 | 470 | ||
465 | if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) | 471 | if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) |
466 | return; | 472 | return; |
@@ -499,33 +505,33 @@ void LoopControl::stop( bool willPlayAgainShortly ) { | |||
499 | delete audioDevice; | 505 | delete audioDevice; |
500 | delete audioBuffer; | 506 | delete audioBuffer; |
501 | audioDevice = 0; | 507 | audioDevice = 0; |
502 | audioBuffer = 0; | 508 | audioBuffer = 0; |
503 | } | 509 | } |
504 | 510 | ||
505 | } | 511 | } |
506 | } | 512 | } |
507 | 513 | ||
508 | 514 | ||
509 | bool LoopControl::init( const QString& filename ) { | 515 | bool LoopControl::init( const QString& filename ) { |
510 | stop(); | 516 | stop(); |
511 | fileName = filename; | 517 | fileName = filename; |
512 | stream = 0; // only play stream 0 for now | 518 | stream = 0; // only play stream 0 for now |
513 | current_frame = total_video_frames = total_audio_samples = 0; | 519 | current_frame = total_video_frames = total_audio_samples = 0; |
514 | 520 | ||
515 | // qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); | 521 | // odebug << "Using the " << mediaPlayerState->curDecoder()->pluginName() << " decoder" << oendl; |
516 | 522 | ||
517 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin | 523 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin |
518 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { | 524 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { |
519 | if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { | 525 | if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { |
520 | total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); | 526 | total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); |
521 | mediaPlayerState->libMpeg3Decoder()->close(); | 527 | mediaPlayerState->libMpeg3Decoder()->close(); |
522 | } | 528 | } |
523 | } | 529 | } |
524 | 530 | ||
525 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) | 531 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) |
526 | return FALSE; | 532 | return FALSE; |
527 | 533 | ||
528 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; | 534 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; |
529 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; | 535 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; |
530 | 536 | ||
531 | if ( hasAudioChannel ) { | 537 | if ( hasAudioChannel ) { |
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp index 6c743ec..15f6928 100644 --- a/core/multimedia/opieplayer/mediaplayer.cpp +++ b/core/multimedia/opieplayer/mediaplayer.cpp | |||
@@ -6,42 +6,44 @@ | |||
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 | 21 | ||
22 | #include <qmessagebox.h> | ||
23 | |||
24 | #include "mediaplayer.h" | 22 | #include "mediaplayer.h" |
25 | #include "playlistwidget.h" | 23 | #include "playlistwidget.h" |
26 | #include "audiowidget.h" | 24 | #include "audiowidget.h" |
27 | #include "loopcontrol.h" | 25 | #include "loopcontrol.h" |
28 | #include "audiodevice.h" | 26 | #include "audiodevice.h" |
29 | |||
30 | #include "mediaplayerstate.h" | 27 | #include "mediaplayerstate.h" |
31 | 28 | ||
29 | /* OPIE */ | ||
30 | #include <opie2/odebug.h> | ||
31 | |||
32 | /* QT */ | ||
33 | #include <qmessagebox.h> | ||
32 | 34 | ||
33 | extern AudioWidget *audioUI; | 35 | extern AudioWidget *audioUI; |
34 | extern PlayListWidget *playList; | 36 | extern PlayListWidget *playList; |
35 | extern LoopControl *loopControl; | 37 | extern LoopControl *loopControl; |
36 | extern MediaPlayerState *mediaPlayerState; | 38 | extern MediaPlayerState *mediaPlayerState; |
37 | 39 | ||
38 | 40 | ||
39 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 41 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) |
40 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { | 42 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { |
41 | 43 | ||
42 | // QPEApplication::grabKeyboard(); | 44 | // QPEApplication::grabKeyboard(); |
43 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 45 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
44 | 46 | ||
45 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 47 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
46 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) ); | 48 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) ); |
47 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 49 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
@@ -60,46 +62,46 @@ MediaPlayer::~MediaPlayer() { | |||
60 | 62 | ||
61 | 63 | ||
62 | void MediaPlayer::pauseCheck( bool b ) { | 64 | void MediaPlayer::pauseCheck( bool b ) { |
63 | // Only pause if playing | 65 | // Only pause if playing |
64 | if ( b && !mediaPlayerState->playing() ) | 66 | if ( b && !mediaPlayerState->playing() ) |
65 | mediaPlayerState->setPaused( FALSE ); | 67 | mediaPlayerState->setPaused( FALSE ); |
66 | } | 68 | } |
67 | 69 | ||
68 | 70 | ||
69 | void MediaPlayer::play() { | 71 | void MediaPlayer::play() { |
70 | mediaPlayerState->setPlaying( FALSE ); | 72 | mediaPlayerState->setPlaying( FALSE ); |
71 | mediaPlayerState->setPlaying( TRUE ); | 73 | mediaPlayerState->setPlaying( TRUE ); |
72 | } | 74 | } |
73 | 75 | ||
74 | 76 | ||
75 | void MediaPlayer::setPlaying( bool play ) { | 77 | void MediaPlayer::setPlaying( bool play ) { |
76 | // qDebug("MediaPlayer setPlaying %d", play); | 78 | // odebug << "MediaPlayer setPlaying " << play << "" << oendl; |
77 | if ( !play ) { | 79 | if ( !play ) { |
78 | mediaPlayerState->setPaused( FALSE ); | 80 | mediaPlayerState->setPaused( FALSE ); |
79 | loopControl->stop( FALSE ); | 81 | loopControl->stop( FALSE ); |
80 | return; | 82 | return; |
81 | } | 83 | } |
82 | 84 | ||
83 | if ( mediaPlayerState->paused() ) { | 85 | if ( mediaPlayerState->paused() ) { |
84 | mediaPlayerState->setPaused( FALSE ); | 86 | mediaPlayerState->setPaused( FALSE ); |
85 | return; | 87 | return; |
86 | } | 88 | } |
87 | // qDebug("about to ctrash"); | 89 | // odebug << "about to ctrash" << oendl; |
88 | const DocLnk *playListCurrent = playList->current(); | 90 | const DocLnk *playListCurrent = playList->current(); |
89 | 91 | ||
90 | if ( playListCurrent != NULL ) { | 92 | if ( playListCurrent != NULL ) { |
91 | loopControl->stop( TRUE ); | 93 | loopControl->stop( TRUE ); |
92 | currentFile = playListCurrent; | 94 | currentFile = playListCurrent; |
93 | } | 95 | } |
94 | if ( currentFile == NULL ) { | 96 | if ( currentFile == NULL ) { |
95 | QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); | 97 | QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); |
96 | mediaPlayerState->setPlaying( FALSE ); | 98 | mediaPlayerState->setPlaying( FALSE ); |
97 | return; | 99 | return; |
98 | } | 100 | } |
99 | 101 | ||
100 | if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) { | 102 | if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) { |
101 | QMessageBox::critical( 0, tr( "File not found"), | 103 | QMessageBox::critical( 0, tr( "File not found"), |
102 | tr( "The following file was not found: <i>" ) | 104 | tr( "The following file was not found: <i>" ) |
103 | + currentFile->file() + "</i>" ); | 105 | + currentFile->file() + "</i>" ); |
104 | mediaPlayerState->setPlaying( FALSE ); | 106 | mediaPlayerState->setPlaying( FALSE ); |
105 | return; | 107 | return; |
@@ -158,111 +160,111 @@ void MediaPlayer::next() { | |||
158 | } else | 160 | } else |
159 | mediaPlayerState->setList(); | 161 | mediaPlayerState->setList(); |
160 | } | 162 | } |
161 | 163 | ||
162 | 164 | ||
163 | void MediaPlayer::startDecreasingVolume() { | 165 | void MediaPlayer::startDecreasingVolume() { |
164 | volumeDirection = -1; | 166 | volumeDirection = -1; |
165 | startTimer( 100 ); | 167 | startTimer( 100 ); |
166 | AudioDevice::decreaseVolume(); | 168 | AudioDevice::decreaseVolume(); |
167 | } | 169 | } |
168 | 170 | ||
169 | 171 | ||
170 | void MediaPlayer::startIncreasingVolume() { | 172 | void MediaPlayer::startIncreasingVolume() { |
171 | volumeDirection = +1; | 173 | volumeDirection = +1; |
172 | startTimer( 100 ); | 174 | startTimer( 100 ); |
173 | AudioDevice::increaseVolume(); | 175 | AudioDevice::increaseVolume(); |
174 | 176 | ||
175 | } | 177 | } |
176 | 178 | ||
177 | bool drawnOnScreenDisplay = FALSE; | 179 | bool drawnOnScreenDisplay = FALSE; |
178 | unsigned int onScreenDisplayVolume = 0; | 180 | unsigned int onScreenDisplayVolume = 0; |
179 | const int yoff = 110; | 181 | const int yoff = 110; |
180 | 182 | ||
181 | void MediaPlayer::stopChangingVolume() { | 183 | void MediaPlayer::stopChangingVolume() { |
182 | killTimers(); | 184 | killTimers(); |
183 | 185 | ||
184 | // Get rid of the on-screen display stuff | 186 | // Get rid of the on-screen display stuff |
185 | drawnOnScreenDisplay = FALSE; | 187 | drawnOnScreenDisplay = FALSE; |
186 | onScreenDisplayVolume = 0; | 188 | onScreenDisplayVolume = 0; |
187 | int w = audioUI->width(); | 189 | int w = audioUI->width(); |
188 | int h = audioUI->height(); | 190 | int h = audioUI->height(); |
189 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | 191 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); |
190 | } | 192 | } |
191 | 193 | ||
192 | 194 | ||
193 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 195 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
194 | // qDebug("timer"); | 196 | // odebug << "timer" << oendl; |
195 | if ( volumeDirection == +1 ) | 197 | if ( volumeDirection == +1 ) |
196 | AudioDevice::increaseVolume(); | 198 | AudioDevice::increaseVolume(); |
197 | else if ( volumeDirection == -1 ) | 199 | else if ( volumeDirection == -1 ) |
198 | AudioDevice::decreaseVolume(); | 200 | AudioDevice::decreaseVolume(); |
199 | 201 | ||
200 | // Display an on-screen display volume | 202 | // Display an on-screen display volume |
201 | unsigned int l, r, v; bool m; | 203 | unsigned int l, r, v; bool m; |
202 | AudioDevice::getVolume( l, r, m ); | 204 | AudioDevice::getVolume( l, r, m ); |
203 | v = ((l + r) * 11) / (2*0xFFFF); | 205 | v = ((l + r) * 11) / (2*0xFFFF); |
204 | 206 | ||
205 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 207 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
206 | // qDebug("returning %d, %d, %d, %d", v, l, r, m); | 208 | // odebug << "returning " << v << ", " << l << ", " << r << ", " << m << "" << oendl; |
207 | return; | 209 | return; |
208 | } | 210 | } |
209 | 211 | ||
210 | int w = audioUI->width(); | 212 | int w = audioUI->width(); |
211 | int h = audioUI->height(); | 213 | int h = audioUI->height(); |
212 | 214 | ||
213 | if ( drawnOnScreenDisplay ) { | 215 | if ( drawnOnScreenDisplay ) { |
214 | if ( onScreenDisplayVolume > v ) | 216 | if ( onScreenDisplayVolume > v ) |
215 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, | 217 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, |
216 | (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | 218 | (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); |
217 | } | 219 | } |
218 | 220 | ||
219 | drawnOnScreenDisplay = TRUE; | 221 | drawnOnScreenDisplay = TRUE; |
220 | onScreenDisplayVolume = v; | 222 | onScreenDisplayVolume = v; |
221 | 223 | ||
222 | QPainter p( audioUI ); | 224 | QPainter p( audioUI ); |
223 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 225 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
224 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 226 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
225 | 227 | ||
226 | QFont f; | 228 | QFont f; |
227 | f.setPixelSize( 20 ); | 229 | f.setPixelSize( 20 ); |
228 | f.setBold( TRUE ); | 230 | f.setBold( TRUE ); |
229 | p.setFont( f ); | 231 | p.setFont( f ); |
230 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 232 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
231 | 233 | ||
232 | for ( unsigned int i = 0; i < 10; i++ ) { | 234 | for ( unsigned int i = 0; i < 10; i++ ) { |
233 | if ( v > i ) | 235 | if ( v > i ) |
234 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 236 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
235 | else | 237 | else |
236 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 238 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
237 | } | 239 | } |
238 | } | 240 | } |
239 | 241 | ||
240 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 242 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
241 | switch ( e->key() ) { | 243 | switch ( e->key() ) { |
242 | ////////////////////////////// Zaurus keys | 244 | ////////////////////////////// Zaurus keys |
243 | case Key_Home: | 245 | case Key_Home: |
244 | break; | 246 | break; |
245 | case Key_F9: //activity | 247 | case Key_F9: //activity |
246 | break; | 248 | break; |
247 | case Key_F10: //contacts | 249 | case Key_F10: //contacts |
248 | break; | 250 | break; |
249 | case Key_F11: //menu | 251 | case Key_F11: //menu |
250 | break; | 252 | break; |
251 | case Key_F12: //home | 253 | case Key_F12: //home |
252 | // qDebug("Blank here"); | 254 | // odebug << "Blank here" << oendl; |
253 | break; | 255 | break; |
254 | case Key_F13: //mail | 256 | case Key_F13: //mail |
255 | break; | 257 | break; |
256 | } | 258 | } |
257 | } | 259 | } |
258 | 260 | ||
259 | void MediaPlayer::doBlank() { | 261 | void MediaPlayer::doBlank() { |
260 | 262 | ||
261 | } | 263 | } |
262 | 264 | ||
263 | void MediaPlayer::doUnblank() { | 265 | void MediaPlayer::doUnblank() { |
264 | 266 | ||
265 | } | 267 | } |
266 | 268 | ||
267 | void MediaPlayer::cleanUp() { | 269 | void MediaPlayer::cleanUp() { |
268 | // QPEApplication::grabKeyboard(); | 270 | // QPEApplication::grabKeyboard(); |
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp index 5bfb87e..b700cd1 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.cpp +++ b/core/multimedia/opieplayer/mediaplayerstate.cpp | |||
@@ -4,48 +4,52 @@ | |||
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> | ||
21 | #include <qpe/qlibrary.h> | ||
22 | #include <qpe/config.h> | ||
23 | #include <qdir.h> | ||
24 | #include <qpe/mediaplayerplugininterface.h> | ||
25 | #include "mediaplayerstate.h" | ||
26 | |||
27 | |||
28 | 20 | ||
29 | #ifdef QT_NO_COMPONENT | 21 | #ifdef QT_NO_COMPONENT |
30 | // Plugins which are compiled in when no plugin architecture available | 22 | // Plugins which are compiled in when no plugin architecture available |
31 | #include "libmad/libmadpluginimpl.h" | 23 | #include "libmad/libmadpluginimpl.h" |
32 | #include "libmpeg3/libmpeg3pluginimpl.h" | 24 | #include "libmpeg3/libmpeg3pluginimpl.h" |
33 | #include "wavplugin/wavpluginimpl.h" | 25 | #include "wavplugin/wavpluginimpl.h" |
34 | #endif | 26 | #endif |
35 | 27 | ||
28 | #include "mediaplayerstate.h" | ||
29 | |||
30 | /* OPIE */ | ||
31 | #include <qpe/qpeapplication.h> | ||
32 | #include <qpe/qlibrary.h> | ||
33 | #include <qpe/config.h> | ||
34 | #include <qpe/mediaplayerplugininterface.h> | ||
35 | #include <opie2/odebug.h> | ||
36 | |||
37 | /* QT */ | ||
38 | #include <qdir.h> | ||
39 | |||
36 | 40 | ||
37 | //#define MediaPlayerDebug(x) qDebug x | 41 | //#define MediaPlayerDebug(x) qDebug x |
38 | #define MediaPlayerDebug(x) | 42 | #define MediaPlayerDebug(x) |
39 | 43 | ||
40 | 44 | ||
41 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 45 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) |
42 | : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { | 46 | : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { |
43 | Config cfg( "OpiePlayer" ); | 47 | Config cfg( "OpiePlayer" ); |
44 | readConfig( cfg ); | 48 | readConfig( cfg ); |
45 | loadPlugins(); | 49 | loadPlugins(); |
46 | } | 50 | } |
47 | 51 | ||
48 | 52 | ||
49 | MediaPlayerState::~MediaPlayerState() { | 53 | MediaPlayerState::~MediaPlayerState() { |
50 | Config cfg( "OpiePlayer" ); | 54 | Config cfg( "OpiePlayer" ); |
51 | writeConfig( cfg ); | 55 | writeConfig( cfg ); |
@@ -91,103 +95,103 @@ struct MediaPlayerPlugin { | |||
91 | static QValueList<MediaPlayerPlugin> pluginList; | 95 | static QValueList<MediaPlayerPlugin> pluginList; |
92 | 96 | ||
93 | 97 | ||
94 | // Find the first decoder which supports this type of file | 98 | // Find the first decoder which supports this type of file |
95 | MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { | 99 | MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { |
96 | MediaPlayerDecoder *tmpDecoder = NULL; | 100 | MediaPlayerDecoder *tmpDecoder = NULL; |
97 | QValueList<MediaPlayerPlugin>::Iterator it; | 101 | QValueList<MediaPlayerPlugin>::Iterator it; |
98 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { | 102 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { |
99 | if ( (*it).decoder->isFileSupported( file ) ) { | 103 | if ( (*it).decoder->isFileSupported( file ) ) { |
100 | tmpDecoder = (*it).decoder; | 104 | tmpDecoder = (*it).decoder; |
101 | break; | 105 | break; |
102 | } | 106 | } |
103 | } | 107 | } |
104 | if(file.left(4)=="http") | 108 | if(file.left(4)=="http") |
105 | isStreaming = TRUE; | 109 | isStreaming = TRUE; |
106 | else | 110 | else |
107 | isStreaming = FALSE; | 111 | isStreaming = FALSE; |
108 | return decoder = tmpDecoder; | 112 | return decoder = tmpDecoder; |
109 | } | 113 | } |
110 | 114 | ||
111 | 115 | ||
112 | MediaPlayerDecoder *MediaPlayerState::curDecoder() { | 116 | MediaPlayerDecoder *MediaPlayerState::curDecoder() { |
113 | return decoder; | 117 | return decoder; |
114 | } | 118 | } |
115 | 119 | ||
116 | 120 | ||
117 | // ### hack to get true sample count | 121 | // ### hack to get true sample count |
118 | MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { | 122 | MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { |
119 | return libmpeg3decoder; | 123 | return libmpeg3decoder; |
120 | } | 124 | } |
121 | 125 | ||
122 | // ### hack to get true sample count | 126 | // ### hack to get true sample count |
123 | // MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { | 127 | // MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { |
124 | // return libwavdecoder; | 128 | // return libwavdecoder; |
125 | // } | 129 | // } |
126 | 130 | ||
127 | void MediaPlayerState::loadPlugins() { | 131 | void MediaPlayerState::loadPlugins() { |
128 | // qDebug("load plugins"); | 132 | // odebug << "load plugins" << oendl; |
129 | #ifndef QT_NO_COMPONENT | 133 | #ifndef QT_NO_COMPONENT |
130 | QValueList<MediaPlayerPlugin>::Iterator mit; | 134 | QValueList<MediaPlayerPlugin>::Iterator mit; |
131 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { | 135 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { |
132 | (*mit).iface->release(); | 136 | (*mit).iface->release(); |
133 | (*mit).library->unload(); | 137 | (*mit).library->unload(); |
134 | delete (*mit).library; | 138 | delete (*mit).library; |
135 | } | 139 | } |
136 | pluginList.clear(); | 140 | pluginList.clear(); |
137 | 141 | ||
138 | QString path = QPEApplication::qpeDir() + "/plugins/codecs"; | 142 | QString path = QPEApplication::qpeDir() + "/plugins/codecs"; |
139 | QDir dir( path, "lib*.so" ); | 143 | QDir dir( path, "lib*.so" ); |
140 | QStringList list = dir.entryList(); | 144 | QStringList list = dir.entryList(); |
141 | QStringList::Iterator it; | 145 | QStringList::Iterator it; |
142 | for ( it = list.begin(); it != list.end(); ++it ) { | 146 | for ( it = list.begin(); it != list.end(); ++it ) { |
143 | MediaPlayerPluginInterface *iface = 0; | 147 | MediaPlayerPluginInterface *iface = 0; |
144 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 148 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
145 | // qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); | 149 | // odebug << "querying: " << QString( path + "/" + *it ) << "" << oendl; |
146 | 150 | ||
147 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { | 151 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { |
148 | 152 | ||
149 | // qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); | 153 | // odebug << "loading: " << QString( path + "/" + *it ) << "" << oendl; |
150 | 154 | ||
151 | MediaPlayerPlugin plugin; | 155 | MediaPlayerPlugin plugin; |
152 | plugin.library = lib; | 156 | plugin.library = lib; |
153 | plugin.iface = iface; | 157 | plugin.iface = iface; |
154 | plugin.decoder = plugin.iface->decoder(); | 158 | plugin.decoder = plugin.iface->decoder(); |
155 | plugin.encoder = plugin.iface->encoder(); | 159 | plugin.encoder = plugin.iface->encoder(); |
156 | pluginList.append( plugin ); | 160 | pluginList.append( plugin ); |
157 | 161 | ||
158 | // ### hack to get true sample count | 162 | // ### hack to get true sample count |
159 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) | 163 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) |
160 | libmpeg3decoder = plugin.decoder; | 164 | libmpeg3decoder = plugin.decoder; |
161 | 165 | ||
162 | } else { | 166 | } else { |
163 | delete lib; | 167 | delete lib; |
164 | } | 168 | } |
165 | } | 169 | } |
166 | #else | 170 | #else |
167 | pluginList.clear(); | 171 | pluginList.clear(); |
168 | 172 | ||
169 | MediaPlayerPlugin plugin0; | 173 | MediaPlayerPlugin plugin0; |
170 | plugin0.iface = new LibMpeg3PluginImpl; | 174 | plugin0.iface = new LibMpeg3PluginImpl; |
171 | plugin0.decoder = plugin0.iface->decoder(); | 175 | plugin0.decoder = plugin0.iface->decoder(); |
172 | plugin0.encoder = plugin0.iface->encoder(); | 176 | plugin0.encoder = plugin0.iface->encoder(); |
173 | pluginList.append( plugin0 ); | 177 | pluginList.append( plugin0 ); |
174 | 178 | ||
175 | MediaPlayerPlugin plugin1; | 179 | MediaPlayerPlugin plugin1; |
176 | plugin1.iface = new LibMadPluginImpl; | 180 | plugin1.iface = new LibMadPluginImpl; |
177 | plugin1.decoder = plugin1.iface->decoder(); | 181 | plugin1.decoder = plugin1.iface->decoder(); |
178 | plugin1.encoder = plugin1.iface->encoder(); | 182 | plugin1.encoder = plugin1.iface->encoder(); |
179 | pluginList.append( plugin1 ); | 183 | pluginList.append( plugin1 ); |
180 | 184 | ||
181 | MediaPlayerPlugin plugin2; | 185 | MediaPlayerPlugin plugin2; |
182 | plugin2.iface = new WavPluginImpl; | 186 | plugin2.iface = new WavPluginImpl; |
183 | plugin2.decoder = plugin2.iface->decoder(); | 187 | plugin2.decoder = plugin2.iface->decoder(); |
184 | plugin2.encoder = plugin2.iface->encoder(); | 188 | plugin2.encoder = plugin2.iface->encoder(); |
185 | pluginList.append( plugin2 ); | 189 | pluginList.append( plugin2 ); |
186 | #endif | 190 | #endif |
187 | 191 | ||
188 | if ( pluginList.count() ) | 192 | if ( pluginList.count() ) |
189 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); | 193 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); |
190 | else | 194 | else |
191 | MediaPlayerDebug(( "No decoders found" )); | 195 | MediaPlayerDebug(( "No decoders found" )); |
192 | } | 196 | } |
193 | 197 | ||
diff --git a/core/multimedia/opieplayer/modplug/memfile.cpp b/core/multimedia/opieplayer/modplug/memfile.cpp index 8a29997..cd243c7 100644 --- a/core/multimedia/opieplayer/modplug/memfile.cpp +++ b/core/multimedia/opieplayer/modplug/memfile.cpp | |||
@@ -6,71 +6,75 @@ | |||
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, | 9 | This program is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | General Public License for more details. | 12 | General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License |
15 | along with this program; see the file COPYING. If not, write to | 15 | along with this program; see the file COPYING. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "memfile.h" | 20 | #include "memfile.h" |
21 | 21 | ||
22 | /* OPIE */ | ||
23 | #include <opie2/odebug.h> | ||
24 | |||
25 | /* STD */ | ||
22 | #include <unistd.h> | 26 | #include <unistd.h> |
23 | #include <sys/mman.h> | 27 | #include <sys/mman.h> |
24 | 28 | ||
25 | MemFile::MemFile() | 29 | MemFile::MemFile() |
26 | { | 30 | { |
27 | } | 31 | } |
28 | 32 | ||
29 | MemFile::MemFile( const QString &name ) | 33 | MemFile::MemFile( const QString &name ) |
30 | : QFile( name ) | 34 | : QFile( name ) |
31 | { | 35 | { |
32 | } | 36 | } |
33 | 37 | ||
34 | MemFile::~MemFile() | 38 | MemFile::~MemFile() |
35 | { | 39 | { |
36 | close(); | 40 | close(); |
37 | } | 41 | } |
38 | 42 | ||
39 | void MemFile::close() | 43 | void MemFile::close() |
40 | { | 44 | { |
41 | unmap(); | 45 | unmap(); |
42 | QFile::close(); | 46 | QFile::close(); |
43 | } | 47 | } |
44 | 48 | ||
45 | void MemFile::unmap() | 49 | void MemFile::unmap() |
46 | { | 50 | { |
47 | #if defined(Q_WS_X11) || defined(Q_WS_QWS) | 51 | #if defined(Q_WS_X11) || defined(Q_WS_QWS) |
48 | if ( m_data.data() ) | 52 | if ( m_data.data() ) |
49 | { | 53 | { |
50 | munmap( m_data.data(), m_data.size() ); | 54 | munmap( m_data.data(), m_data.size() ); |
51 | m_data.resetRawData( m_data.data(), m_data.size() ); | 55 | m_data.resetRawData( m_data.data(), m_data.size() ); |
52 | } | 56 | } |
53 | #endif | 57 | #endif |
54 | } | 58 | } |
55 | 59 | ||
56 | QByteArray &MemFile::data() | 60 | QByteArray &MemFile::data() |
57 | { | 61 | { |
58 | if ( !m_data.data() ) | 62 | if ( !m_data.data() ) |
59 | { | 63 | { |
60 | #if defined(Q_WS_X11) || defined(Q_WS_QWS) | 64 | #if defined(Q_WS_X11) || defined(Q_WS_QWS) |
61 | const char *rawData = (const char *)mmap( 0, size(), PROT_READ, | 65 | const char *rawData = (const char *)mmap( 0, size(), PROT_READ, |
62 | MAP_SHARED, handle(), 0 ); | 66 | MAP_SHARED, handle(), 0 ); |
63 | if ( rawData ) | 67 | if ( rawData ) |
64 | { | 68 | { |
65 | m_data.setRawData( rawData, size() ); | 69 | m_data.setRawData( rawData, size() ); |
66 | return m_data; | 70 | return m_data; |
67 | } | 71 | } |
68 | else | 72 | else |
69 | qDebug( "MemFile: mmap() failed!" ); | 73 | odebug << "MemFile: mmap() failed!" << oendl; |
70 | // fallback | 74 | // fallback |
71 | #endif | 75 | #endif |
72 | m_data = readAll(); | 76 | m_data = readAll(); |
73 | } | 77 | } |
74 | return m_data; | 78 | return m_data; |
75 | } | 79 | } |
76 | 80 | ||
diff --git a/core/multimedia/opieplayer/om3u.cpp b/core/multimedia/opieplayer/om3u.cpp index ae89518..95ed03c 100644 --- a/core/multimedia/opieplayer/om3u.cpp +++ b/core/multimedia/opieplayer/om3u.cpp | |||
@@ -18,145 +18,147 @@ | |||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; General Public License for more | 20 | ..}^=.= = ; General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = General Public License along with | 24 | -_. . . )=. = General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include "om3u.h" | 32 | #include "om3u.h" |
33 | 33 | ||
34 | /* OPIE */ | ||
35 | #include <opie2/odebug.h> | ||
34 | 36 | ||
35 | 37 | ||
36 | static inline QString fullBaseName ( const QFileInfo &fi ) | 38 | static inline QString fullBaseName ( const QFileInfo &fi ) |
37 | { | 39 | { |
38 | QString str = fi. fileName ( ); | 40 | QString str = fi. fileName ( ); |
39 | return str. left ( str. findRev ( '.' )); | 41 | return str. left ( str. findRev ( '.' )); |
40 | } | 42 | } |
41 | 43 | ||
42 | 44 | ||
43 | //extern PlayListWidget *playList; | 45 | //extern PlayListWidget *playList; |
44 | 46 | ||
45 | Om3u::Om3u( const QString &filePath, int mode) | 47 | Om3u::Om3u( const QString &filePath, int mode) |
46 | : QStringList (){ | 48 | : QStringList (){ |
47 | //qDebug("<<<<<<<new m3u "+filePath); | 49 | //odebug << "<<<<<<<new m3u "+filePath << oendl; |
48 | f.setName(filePath); | 50 | f.setName(filePath); |
49 | f.open(mode); | 51 | f.open(mode); |
50 | } | 52 | } |
51 | 53 | ||
52 | Om3u::~Om3u(){} | 54 | Om3u::~Om3u(){} |
53 | 55 | ||
54 | void Om3u::readM3u() { | 56 | void Om3u::readM3u() { |
55 | // qDebug("<<<<<<reading m3u "+f.name()); | 57 | // odebug << "<<<<<<reading m3u "+f.name() << oendl; |
56 | QTextStream t(&f); | 58 | QTextStream t(&f); |
57 | t.setEncoding(QTextStream::UnicodeUTF8); | 59 | t.setEncoding(QTextStream::UnicodeUTF8); |
58 | QString s; | 60 | QString s; |
59 | while ( !t.atEnd() ) { | 61 | while ( !t.atEnd() ) { |
60 | s=t.readLine(); | 62 | s=t.readLine(); |
61 | // qDebug(s); | 63 | // odebug << s << oendl; |
62 | if( s.find( "#", 0, TRUE) == -1 ) { | 64 | if( s.find( "#", 0, TRUE) == -1 ) { |
63 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 65 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
64 | s = s.right( s.length() -2 ); | 66 | s = s.right( s.length() -2 ); |
65 | QFileInfo f( s ); | 67 | QFileInfo f( s ); |
66 | QString name = fullBaseName ( f ); | 68 | QString name = fullBaseName ( f ); |
67 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 69 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
68 | s=s.replace( QRegExp( "\\" ), "/" ); | 70 | s=s.replace( QRegExp( "\\" ), "/" ); |
69 | append(s); | 71 | append(s); |
70 | // qDebug(s); | 72 | // odebug << s << oendl; |
71 | } else { // is url | 73 | } else { // is url |
72 | s.replace( QRegExp( "%20" )," " ); | 74 | s.replace( QRegExp( "%20" )," " ); |
73 | QString name; | 75 | QString name; |
74 | // if( name.left( 4 ) == "http" ) { | 76 | // if( name.left( 4 ) == "http" ) { |
75 | // name = s.right( s.length() - 7 ); | 77 | // name = s.right( s.length() - 7 ); |
76 | // } else { | 78 | // } else { |
77 | name = s; | 79 | name = s; |
78 | // } | 80 | // } |
79 | append(name); | 81 | append(name); |
80 | // qDebug(name); | 82 | // odebug << name << oendl; |
81 | } | 83 | } |
82 | } | 84 | } |
83 | } | 85 | } |
84 | } | 86 | } |
85 | 87 | ||
86 | void Om3u::readPls() { //it's a pls file | 88 | void Om3u::readPls() { //it's a pls file |
87 | QTextStream t( &f ); | 89 | QTextStream t( &f ); |
88 | t.setEncoding(QTextStream::UnicodeUTF8); | 90 | t.setEncoding(QTextStream::UnicodeUTF8); |
89 | QString s; | 91 | QString s; |
90 | while ( !t.atEnd() ) { | 92 | while ( !t.atEnd() ) { |
91 | s = t.readLine(); | 93 | s = t.readLine(); |
92 | if( s.left(4) == "File" ) { | 94 | if( s.left(4) == "File" ) { |
93 | s = s.right( s.length() - 6 ); | 95 | s = s.right( s.length() - 6 ); |
94 | s.replace( QRegExp( "%20" )," "); | 96 | s.replace( QRegExp( "%20" )," "); |
95 | // qDebug( "adding " + s + " to playlist" ); | 97 | // odebug << "adding " + s + " to playlist" << oendl; |
96 | // numberofentries=2 | 98 | // numberofentries=2 |
97 | // File1=http | 99 | // File1=http |
98 | // Title | 100 | // Title |
99 | // Length | 101 | // Length |
100 | // Version | 102 | // Version |
101 | // File2=http | 103 | // File2=http |
102 | s = s.replace( QRegExp( "\\" ), "/" ); | 104 | s = s.replace( QRegExp( "\\" ), "/" ); |
103 | QFileInfo f( s ); | 105 | QFileInfo f( s ); |
104 | QString name = fullBaseName ( f ); | 106 | QString name = fullBaseName ( f ); |
105 | if( name.left( 4 ) == "http" ) { | 107 | if( name.left( 4 ) == "http" ) { |
106 | name = s.right( s.length() - 7); | 108 | name = s.right( s.length() - 7); |
107 | } else { | 109 | } else { |
108 | name = s; | 110 | name = s; |
109 | } | 111 | } |
110 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 112 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
111 | if( s.at( s.length() - 4) == '.') // if this is probably a file | 113 | if( s.at( s.length() - 4) == '.') // if this is probably a file |
112 | append(s); | 114 | append(s); |
113 | else { //if its a url | 115 | else { //if its a url |
114 | if( name.right( 1 ).find( '/' ) == -1) { | 116 | if( name.right( 1 ).find( '/' ) == -1) { |
115 | s += "/"; | 117 | s += "/"; |
116 | } | 118 | } |
117 | append(s); | 119 | append(s); |
118 | } | 120 | } |
119 | } | 121 | } |
120 | } | 122 | } |
121 | } | 123 | } |
122 | 124 | ||
123 | void Om3u::write() { //writes list to m3u file | 125 | void Om3u::write() { //writes list to m3u file |
124 | QString list; | 126 | QString list; |
125 | QTextStream t(&f); | 127 | QTextStream t(&f); |
126 | t.setEncoding(QTextStream::UnicodeUTF8); | 128 | t.setEncoding(QTextStream::UnicodeUTF8); |
127 | if(count()>0) { | 129 | if(count()>0) { |
128 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 130 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
129 | // qDebug(*it); | 131 | // odebug << *it << oendl; |
130 | t << *it << "\n"; | 132 | t << *it << "\n"; |
131 | } | 133 | } |
132 | } | 134 | } |
133 | // f.close(); | 135 | // f.close(); |
134 | } | 136 | } |
135 | 137 | ||
136 | void Om3u::add(const QString &filePath) { //adds to m3u file | 138 | void Om3u::add(const QString &filePath) { //adds to m3u file |
137 | append(filePath); | 139 | append(filePath); |
138 | } | 140 | } |
139 | 141 | ||
140 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 142 | void Om3u::remove(const QString &filePath) { //removes from m3u list |
141 | QString list, currentFile; | 143 | QString list, currentFile; |
142 | if(count()>0) { | 144 | if(count()>0) { |
143 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 145 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
144 | currentFile=*it; | 146 | currentFile=*it; |
145 | // qDebug(*it); | 147 | // odebug << *it << oendl; |
146 | 148 | ||
147 | if( filePath != currentFile) | 149 | if( filePath != currentFile) |
148 | list += currentFile+"\n"; | 150 | list += currentFile+"\n"; |
149 | } | 151 | } |
150 | f.writeBlock( list, list.length() ); | 152 | f.writeBlock( list, list.length() ); |
151 | } | 153 | } |
152 | } | 154 | } |
153 | 155 | ||
154 | void Om3u::deleteFile(const QString &filePath) {//deletes m3u file | 156 | void Om3u::deleteFile(const QString &filePath) {//deletes m3u file |
155 | f.close(); | 157 | f.close(); |
156 | f.remove(); | 158 | f.remove(); |
157 | 159 | ||
158 | } | 160 | } |
159 | 161 | ||
160 | void Om3u::close() { //closes m3u file | 162 | void Om3u::close() { //closes m3u file |
161 | f.close(); | 163 | f.close(); |
162 | } | 164 | } |
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index ad831cf..58c3966 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp | |||
@@ -5,81 +5,86 @@ | |||
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 | #include <qheader.h> | ||
22 | |||
23 | #include "playlistselection.h" | 21 | #include "playlistselection.h" |
24 | 22 | ||
23 | /* OPIE */ | ||
24 | #include <opie2/odebug.h> | ||
25 | |||
26 | /* QT */ | ||
27 | #include <qheader.h> | ||
28 | |||
29 | /* STD */ | ||
25 | #include <stdlib.h> | 30 | #include <stdlib.h> |
26 | 31 | ||
27 | class PlayListSelectionItem : public QListViewItem { | 32 | class PlayListSelectionItem : public QListViewItem { |
28 | public: | 33 | public: |
29 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 34 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
30 | setText( 0, f->name() ); | 35 | setText( 0, f->name() ); |
31 | setPixmap( 0, f->pixmap() ); | 36 | setPixmap( 0, f->pixmap() ); |
32 | } | 37 | } |
33 | 38 | ||
34 | ~PlayListSelectionItem() { | 39 | ~PlayListSelectionItem() { |
35 | }; | 40 | }; |
36 | 41 | ||
37 | const DocLnk *file() const { return fl; } | 42 | const DocLnk *file() const { return fl; } |
38 | 43 | ||
39 | private: | 44 | private: |
40 | const DocLnk *fl; | 45 | const DocLnk *fl; |
41 | }; | 46 | }; |
42 | 47 | ||
43 | 48 | ||
44 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 49 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
45 | : QListView( parent, name ) | 50 | : QListView( parent, name ) |
46 | { | 51 | { |
47 | // qDebug("starting playlistselector"); | 52 | // odebug << "starting playlistselector" << oendl; |
48 | // #ifdef USE_PLAYLIST_BACKGROUND | 53 | // #ifdef USE_PLAYLIST_BACKGROUND |
49 | // setStaticBackground( TRUE ); | 54 | // setStaticBackground( TRUE ); |
50 | // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); | 55 | // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); |
51 | 56 | ||
52 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); | 57 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); |
53 | // #endif | 58 | // #endif |
54 | // addColumn("Title",236); | 59 | // addColumn("Title",236); |
55 | // setAllColumnsShowFocus( TRUE ); | 60 | // setAllColumnsShowFocus( TRUE ); |
56 | addColumn( tr( "Playlist Selection" ) ); | 61 | addColumn( tr( "Playlist Selection" ) ); |
57 | header()->hide(); | 62 | header()->hide(); |
58 | // setSorting( -1, FALSE ); | 63 | // setSorting( -1, FALSE ); |
59 | // FIXME | 64 | // FIXME |
60 | } | 65 | } |
61 | 66 | ||
62 | 67 | ||
63 | PlayListSelection::~PlayListSelection() { | 68 | PlayListSelection::~PlayListSelection() { |
64 | } | 69 | } |
65 | 70 | ||
66 | 71 | ||
67 | // #ifdef USE_PLAYLIST_BACKGROUND | 72 | // #ifdef USE_PLAYLIST_BACKGROUND |
68 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | 73 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { |
69 | // qDebug("drawBackground"); | 74 | // odebug << "drawBackground" << oendl; |
70 | p->fillRect( r, QBrush( white ) ); | 75 | p->fillRect( r, QBrush( white ) ); |
71 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); | 76 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); |
72 | // if ( !logo.isNull() ) | 77 | // if ( !logo.isNull() ) |
73 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | 78 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); |
74 | } | 79 | } |
75 | // #endif | 80 | // #endif |
76 | 81 | ||
77 | 82 | ||
78 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 83 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
79 | if ( event->state() == QMouseEvent::LeftButton ) { | 84 | if ( event->state() == QMouseEvent::LeftButton ) { |
80 | QListViewItem *currentItem = selectedItem(); | 85 | QListViewItem *currentItem = selectedItem(); |
81 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 86 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
82 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 87 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
83 | moveSelectedUp(); | 88 | moveSelectedUp(); |
84 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 89 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
85 | moveSelectedDown(); | 90 | moveSelectedDown(); |
@@ -173,36 +178,36 @@ bool PlayListSelection::last() { | |||
173 | return FALSE; | 178 | return FALSE; |
174 | ensureItemVisible( selectedItem() ); | 179 | ensureItemVisible( selectedItem() ); |
175 | return TRUE; | 180 | return TRUE; |
176 | } | 181 | } |
177 | 182 | ||
178 | void PlayListSelection::unSelect() | 183 | void PlayListSelection::unSelect() |
179 | { | 184 | { |
180 | QListViewItem *item = selectedItem(); | 185 | QListViewItem *item = selectedItem(); |
181 | setSelected( currentItem(), FALSE); | 186 | setSelected( currentItem(), FALSE); |
182 | } | 187 | } |
183 | 188 | ||
184 | void PlayListSelection::writeCurrent( Config& cfg ) { | 189 | void PlayListSelection::writeCurrent( Config& cfg ) { |
185 | cfg.setGroup("PlayList"); | 190 | cfg.setGroup("PlayList"); |
186 | QListViewItem *item = selectedItem(); | 191 | QListViewItem *item = selectedItem(); |
187 | if ( item ) | 192 | if ( item ) |
188 | cfg.writeEntry("current", item->text(0) ); | 193 | cfg.writeEntry("current", item->text(0) ); |
189 | // qDebug(item->text(0)); | 194 | // odebug << item->text(0) << oendl; |
190 | 195 | ||
191 | } | 196 | } |
192 | 197 | ||
193 | void PlayListSelection::setSelectedItem(const QString &strk ) { | 198 | void PlayListSelection::setSelectedItem(const QString &strk ) { |
194 | 199 | ||
195 | unSelect(); | 200 | unSelect(); |
196 | QListViewItemIterator it( this ); | 201 | QListViewItemIterator it( this ); |
197 | for ( ; it.current(); ++it ) { | 202 | for ( ; it.current(); ++it ) { |
198 | // qDebug( it.current()->text(0)); | 203 | // odebug << it.current()->text(0) << oendl; |
199 | if( strk == it.current()->text(0)) { | 204 | if( strk == it.current()->text(0)) { |
200 | // qDebug( "We have a match "+strk); | 205 | // odebug << "We have a match "+strk << oendl; |
201 | setSelected( it.current(), TRUE); | 206 | setSelected( it.current(), TRUE); |
202 | ensureItemVisible( it.current() ); | 207 | ensureItemVisible( it.current() ); |
203 | return; | 208 | return; |
204 | } | 209 | } |
205 | } | 210 | } |
206 | // setSelected( item, TRUE ); | 211 | // setSelected( item, TRUE ); |
207 | // ensureItemVisible( selectedItem() ); | 212 | // ensureItemVisible( selectedItem() ); |
208 | } | 213 | } |
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 3609f5d..d85ce50 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -7,51 +7,53 @@ | |||
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 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | 21 | #define QTOPIA_INTERNAL_FSLP |
22 | 22 | ||
23 | #include <qtoolbar.h> | 23 | #include "playlistselection.h" |
24 | #include "playlistwidget.h" | ||
25 | #include "mediaplayerstate.h" | ||
26 | #include "inputDialog.h" | ||
27 | #include "audiowidget.h" | ||
28 | #include "videowidget.h" | ||
29 | |||
30 | /* OPIE */ | ||
24 | #include <qpe/qpemenubar.h> | 31 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/lnkproperties.h> | 32 | #include <qpe/lnkproperties.h> |
33 | #include <opie2/odebug.h> | ||
26 | 34 | ||
35 | /* QT */ | ||
36 | #include <qtoolbar.h> | ||
27 | #include <qaction.h> | 37 | #include <qaction.h> |
28 | #include <qlayout.h> | 38 | #include <qlayout.h> |
29 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
30 | |||
31 | //#include <qtimer.h> | 40 | //#include <qtimer.h> |
32 | 41 | ||
33 | #include "playlistselection.h" | 42 | /* STD */ |
34 | #include "playlistwidget.h" | ||
35 | #include "mediaplayerstate.h" | ||
36 | |||
37 | #include "inputDialog.h" | ||
38 | |||
39 | #include <stdlib.h> | 43 | #include <stdlib.h> |
40 | #include "audiowidget.h" | ||
41 | #include "videowidget.h" | ||
42 | 44 | ||
43 | #include <unistd.h> | 45 | #include <unistd.h> |
44 | #include <sys/file.h> | 46 | #include <sys/file.h> |
45 | #include <sys/ioctl.h> | 47 | #include <sys/ioctl.h> |
46 | #include <sys/soundcard.h> | 48 | #include <sys/soundcard.h> |
47 | 49 | ||
48 | // for setBacklight() | 50 | // for setBacklight() |
49 | #include <linux/fb.h> | 51 | #include <linux/fb.h> |
50 | #include <sys/types.h> | 52 | #include <sys/types.h> |
51 | #include <sys/stat.h> | 53 | #include <sys/stat.h> |
52 | #include <stdlib.h> | 54 | #include <stdlib.h> |
53 | 55 | ||
54 | #define BUTTONS_ON_TOOLBAR | 56 | #define BUTTONS_ON_TOOLBAR |
55 | #define SIDE_BUTTONS | 57 | #define SIDE_BUTTONS |
56 | #define CAN_SAVE_LOAD_PLAYLISTS | 58 | #define CAN_SAVE_LOAD_PLAYLISTS |
57 | 59 | ||
@@ -132,33 +134,33 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
132 | // Create Toolbar | 134 | // Create Toolbar |
133 | QToolBar *toolbar = new QToolBar( this ); | 135 | QToolBar *toolbar = new QToolBar( this ); |
134 | toolbar->setHorizontalStretchable( TRUE ); | 136 | toolbar->setHorizontalStretchable( TRUE ); |
135 | 137 | ||
136 | // Create Menubar | 138 | // Create Menubar |
137 | QMenuBar *menu = new QMenuBar( toolbar ); | 139 | QMenuBar *menu = new QMenuBar( toolbar ); |
138 | menu->setMargin( 0 ); | 140 | menu->setMargin( 0 ); |
139 | 141 | ||
140 | QToolBar *bar = new QToolBar( this ); | 142 | QToolBar *bar = new QToolBar( this ); |
141 | bar->setLabel( tr( "Play Operations" ) ); | 143 | bar->setLabel( tr( "Play Operations" ) ); |
142 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", | 144 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", |
143 | // this , SLOT( addSelected()) ); | 145 | // this , SLOT( addSelected()) ); |
144 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 146 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
145 | tbDeletePlaylist->setFlat(TRUE); | 147 | tbDeletePlaylist->setFlat(TRUE); |
146 | 148 | ||
147 | tbDeletePlaylist->setFixedSize(20,20); | 149 | tbDeletePlaylist->setFixedSize(20,20); |
148 | 150 | ||
149 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 151 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
150 | this , SLOT(addSelected()) ); | 152 | this , SLOT(addSelected()) ); |
151 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 153 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
152 | this , SLOT(removeSelected()) ); | 154 | this , SLOT(removeSelected()) ); |
153 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool)/*btnPlay()*/), TRUE ); | 155 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool)/*btnPlay()*/), TRUE ); |
154 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 156 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
155 | this , SLOT( btnPlay(bool) ), TRUE ); | 157 | this , SLOT( btnPlay(bool) ), TRUE ); |
156 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 158 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
157 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 159 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
158 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 160 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
159 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 161 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
160 | tbDeletePlaylist->hide(); | 162 | tbDeletePlaylist->hide(); |
161 | 163 | ||
162 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 164 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
163 | menu->insertItem( tr( "File" ), pmPlayList ); | 165 | menu->insertItem( tr( "File" ), pmPlayList ); |
164 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 166 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
@@ -179,107 +181,107 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
179 | fullScreenButton->addTo(pmView); | 181 | fullScreenButton->addTo(pmView); |
180 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 182 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
181 | scaleButton->addTo(pmView); | 183 | scaleButton->addTo(pmView); |
182 | 184 | ||
183 | 185 | ||
184 | skinsMenu = new QPopupMenu( this ); | 186 | skinsMenu = new QPopupMenu( this ); |
185 | menu->insertItem( tr( "Skins" ), skinsMenu ); | 187 | menu->insertItem( tr( "Skins" ), skinsMenu ); |
186 | skinsMenu->isCheckable(); | 188 | skinsMenu->isCheckable(); |
187 | connect( skinsMenu, SIGNAL( activated(int) ) , | 189 | connect( skinsMenu, SIGNAL( activated(int) ) , |
188 | this, SLOT( skinsMenuActivated(int) ) ); | 190 | this, SLOT( skinsMenuActivated(int) ) ); |
189 | populateSkinsMenu(); | 191 | populateSkinsMenu(); |
190 | 192 | ||
191 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 193 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
192 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 194 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
193 | 195 | ||
194 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 196 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
195 | 197 | ||
196 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 198 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
197 | // tabWidget->setTabShape(QTabWidget::Triangular); | 199 | // tabWidget->setTabShape(QTabWidget::Triangular); |
198 | 200 | ||
199 | QWidget *pTab; | 201 | QWidget *pTab; |
200 | pTab = new QWidget( tabWidget, "pTab" ); | 202 | pTab = new QWidget( tabWidget, "pTab" ); |
201 | // playlistView = new QListView( pTab, "playlistview" ); | 203 | // playlistView = new QListView( pTab, "playlistview" ); |
202 | // playlistView->setMinimumSize(236,260); | 204 | // playlistView->setMinimumSize(236,260); |
203 | tabWidget->insertTab( pTab,"Playlist"); | 205 | tabWidget->insertTab( pTab,"Playlist"); |
204 | 206 | ||
205 | 207 | ||
206 | // Add the playlist area | 208 | // Add the playlist area |
207 | 209 | ||
208 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 210 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
209 | d->playListFrame = vbox3; | 211 | d->playListFrame = vbox3; |
210 | 212 | ||
211 | QGridLayout *layoutF = new QGridLayout( pTab ); | 213 | QGridLayout *layoutF = new QGridLayout( pTab ); |
212 | layoutF->setSpacing( 2); | 214 | layoutF->setSpacing( 2); |
213 | layoutF->setMargin( 2); | 215 | layoutF->setMargin( 2); |
214 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); | 216 | layoutF->addMultiCellWidget( d->playListFrame , 0, 0, 0, 1 ); |
215 | 217 | ||
216 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 218 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
217 | 219 | ||
218 | d->selectedFiles = new PlayListSelection( hbox2); | 220 | d->selectedFiles = new PlayListSelection( hbox2); |
219 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 221 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
220 | 222 | ||
221 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 223 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
222 | 224 | ||
223 | 225 | ||
224 | 226 | ||
225 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 227 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
226 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 228 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
227 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 229 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
228 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 230 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
229 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 231 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
230 | 232 | ||
231 | QWidget *aTab; | 233 | QWidget *aTab; |
232 | aTab = new QWidget( tabWidget, "aTab" ); | 234 | aTab = new QWidget( tabWidget, "aTab" ); |
233 | audioView = new QListView( aTab, "Audioview" ); | 235 | audioView = new QListView( aTab, "Audioview" ); |
234 | 236 | ||
235 | QGridLayout *layoutA = new QGridLayout( aTab ); | 237 | QGridLayout *layoutA = new QGridLayout( aTab ); |
236 | layoutA->setSpacing( 2); | 238 | layoutA->setSpacing( 2); |
237 | layoutA->setMargin( 2); | 239 | layoutA->setMargin( 2); |
238 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 240 | layoutA->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
239 | 241 | ||
240 | audioView->addColumn( tr("Title"),-1); | 242 | audioView->addColumn( tr("Title"),-1); |
241 | audioView->addColumn(tr("Size"), -1); | 243 | audioView->addColumn(tr("Size"), -1); |
242 | audioView->addColumn(tr("Media"),-1); | 244 | audioView->addColumn(tr("Media"),-1); |
243 | audioView->addColumn( tr( "Path" ), -1 ); | 245 | audioView->addColumn( tr( "Path" ), -1 ); |
244 | 246 | ||
245 | audioView->setColumnAlignment(1, Qt::AlignRight); | 247 | audioView->setColumnAlignment(1, Qt::AlignRight); |
246 | audioView->setColumnAlignment(2, Qt::AlignRight); | 248 | audioView->setColumnAlignment(2, Qt::AlignRight); |
247 | audioView->setAllColumnsShowFocus(TRUE); | 249 | audioView->setAllColumnsShowFocus(TRUE); |
248 | 250 | ||
249 | audioView->setMultiSelection( TRUE ); | 251 | audioView->setMultiSelection( TRUE ); |
250 | audioView->setSelectionMode( QListView::Extended); | 252 | audioView->setSelectionMode( QListView::Extended); |
251 | audioView->setSorting( 3, TRUE ); | 253 | audioView->setSorting( 3, TRUE ); |
252 | 254 | ||
253 | tabWidget->insertTab(aTab,tr("Audio")); | 255 | tabWidget->insertTab(aTab,tr("Audio")); |
254 | 256 | ||
255 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 257 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
256 | 258 | ||
257 | // audioView | 259 | // audioView |
258 | // populateAudioView(); | 260 | // populateAudioView(); |
259 | // videowidget | 261 | // videowidget |
260 | 262 | ||
261 | QWidget *vTab; | 263 | QWidget *vTab; |
262 | vTab = new QWidget( tabWidget, "vTab" ); | 264 | vTab = new QWidget( tabWidget, "vTab" ); |
263 | videoView = new QListView( vTab, "Videoview" ); | 265 | videoView = new QListView( vTab, "Videoview" ); |
264 | 266 | ||
265 | QGridLayout *layoutV = new QGridLayout( vTab ); | 267 | QGridLayout *layoutV = new QGridLayout( vTab ); |
266 | layoutV->setSpacing( 2); | 268 | layoutV->setSpacing( 2); |
267 | layoutV->setMargin( 2); | 269 | layoutV->setMargin( 2); |
268 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 270 | layoutV->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
269 | 271 | ||
270 | videoView->addColumn(tr("Title"),-1); | 272 | videoView->addColumn(tr("Title"),-1); |
271 | videoView->addColumn(tr("Size"),-1); | 273 | videoView->addColumn(tr("Size"),-1); |
272 | videoView->addColumn(tr("Media"),-1); | 274 | videoView->addColumn(tr("Media"),-1); |
273 | videoView->addColumn(tr( "Path" ), -1 ); | 275 | videoView->addColumn(tr( "Path" ), -1 ); |
274 | videoView->setColumnAlignment(1, Qt::AlignRight); | 276 | videoView->setColumnAlignment(1, Qt::AlignRight); |
275 | videoView->setColumnAlignment(2, Qt::AlignRight); | 277 | videoView->setColumnAlignment(2, Qt::AlignRight); |
276 | videoView->setAllColumnsShowFocus(TRUE); | 278 | videoView->setAllColumnsShowFocus(TRUE); |
277 | videoView->setMultiSelection( TRUE ); | 279 | videoView->setMultiSelection( TRUE ); |
278 | videoView->setSelectionMode( QListView::Extended); | 280 | videoView->setSelectionMode( QListView::Extended); |
279 | 281 | ||
280 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 282 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
281 | 283 | ||
282 | tabWidget->insertTab( vTab,tr("Video")); | 284 | tabWidget->insertTab( vTab,tr("Video")); |
283 | 285 | ||
284 | QWidget *LTab; | 286 | QWidget *LTab; |
285 | LTab = new QWidget( tabWidget, "LTab" ); | 287 | LTab = new QWidget( tabWidget, "LTab" ); |
@@ -290,33 +292,33 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
290 | layoutL->setMargin( 2); | 292 | layoutL->setMargin( 2); |
291 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 293 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
292 | 294 | ||
293 | tabWidget->insertTab(LTab,tr("Lists")); | 295 | tabWidget->insertTab(LTab,tr("Lists")); |
294 | 296 | ||
295 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 297 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
296 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 298 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
297 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 299 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
298 | 300 | ||
299 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), | 301 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
300 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int)) ); | 302 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int)) ); |
301 | 303 | ||
302 | 304 | ||
303 | ///audioView | 305 | ///audioView |
304 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), | 306 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
305 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); | 307 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); |
306 | 308 | ||
307 | connect( audioView, SIGNAL( returnPressed(QListViewItem*)), | 309 | connect( audioView, SIGNAL( returnPressed(QListViewItem*)), |
308 | this,SLOT( playIt(QListViewItem*)) ); | 310 | this,SLOT( playIt(QListViewItem*)) ); |
309 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); | 311 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); |
310 | 312 | ||
311 | 313 | ||
312 | //videoView | 314 | //videoView |
313 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), | 315 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
314 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); | 316 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int)) ); |
315 | connect( videoView, SIGNAL( returnPressed(QListViewItem*)), | 317 | connect( videoView, SIGNAL( returnPressed(QListViewItem*)), |
316 | this,SLOT( playIt(QListViewItem*)) ); | 318 | this,SLOT( playIt(QListViewItem*)) ); |
317 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); | 319 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( addToSelection(QListViewItem*) ) ); |
318 | 320 | ||
319 | //playlists | 321 | //playlists |
320 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( loadList(const DocLnk&) ) ); | 322 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( loadList(const DocLnk&) ) ); |
321 | 323 | ||
322 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 324 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
@@ -324,33 +326,33 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
324 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), d->tbPlay, SLOT( setOn(bool) ) ); | 326 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), d->tbPlay, SLOT( setOn(bool) ) ); |
325 | 327 | ||
326 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), d->tbLoop, SLOT( setOn(bool) ) ); | 328 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), d->tbLoop, SLOT( setOn(bool) ) ); |
327 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), d->tbShuffle, SLOT( setOn(bool) ) ); | 329 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), d->tbShuffle, SLOT( setOn(bool) ) ); |
328 | connect( mediaPlayerState, SIGNAL( playlistToggled(bool) ), this, SLOT( setPlaylist(bool) ) ); | 330 | connect( mediaPlayerState, SIGNAL( playlistToggled(bool) ), this, SLOT( setPlaylist(bool) ) ); |
329 | 331 | ||
330 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( playIt(QListViewItem*) ) ); | 332 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( playIt(QListViewItem*) ) ); |
331 | 333 | ||
332 | setCentralWidget( vbox5 ); | 334 | setCentralWidget( vbox5 ); |
333 | 335 | ||
334 | Config cfg( "OpiePlayer" ); | 336 | Config cfg( "OpiePlayer" ); |
335 | readConfig( cfg ); | 337 | readConfig( cfg ); |
336 | 338 | ||
337 | currentPlayList = cfg.readEntry("CurrentPlaylist","default"); | 339 | currentPlayList = cfg.readEntry("CurrentPlaylist","default"); |
338 | loadList(DocLnk( currentPlayList)); | 340 | loadList(DocLnk( currentPlayList)); |
339 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); | 341 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); |
340 | 342 | ||
341 | initializeStates(); | 343 | initializeStates(); |
342 | } | 344 | } |
343 | 345 | ||
344 | 346 | ||
345 | PlayListWidget::~PlayListWidget() { | 347 | PlayListWidget::~PlayListWidget() { |
346 | Config cfg( "OpiePlayer" ); | 348 | Config cfg( "OpiePlayer" ); |
347 | writeConfig( cfg ); | 349 | writeConfig( cfg ); |
348 | 350 | ||
349 | if ( d->current ) | 351 | if ( d->current ) |
350 | delete d->current; | 352 | delete d->current; |
351 | if(d) delete d; | 353 | if(d) delete d; |
352 | } | 354 | } |
353 | 355 | ||
354 | 356 | ||
355 | void PlayListWidget::initializeStates() { | 357 | void PlayListWidget::initializeStates() { |
356 | 358 | ||
@@ -376,50 +378,50 @@ void PlayListWidget::readConfig( Config& cfg ) { | |||
376 | } | 378 | } |
377 | d->selectedFiles->setSelectedItem( currentString); | 379 | d->selectedFiles->setSelectedItem( currentString); |
378 | } | 380 | } |
379 | 381 | ||
380 | 382 | ||
381 | void PlayListWidget::writeConfig( Config& cfg ) const { | 383 | void PlayListWidget::writeConfig( Config& cfg ) const { |
382 | 384 | ||
383 | d->selectedFiles->writeCurrent( cfg); | 385 | d->selectedFiles->writeCurrent( cfg); |
384 | cfg.setGroup("PlayList"); | 386 | cfg.setGroup("PlayList"); |
385 | int noOfFiles = 0; | 387 | int noOfFiles = 0; |
386 | d->selectedFiles->first(); | 388 | d->selectedFiles->first(); |
387 | do { | 389 | do { |
388 | const DocLnk *lnk = d->selectedFiles->current(); | 390 | const DocLnk *lnk = d->selectedFiles->current(); |
389 | if ( lnk ) { | 391 | if ( lnk ) { |
390 | QString entryName; | 392 | QString entryName; |
391 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 393 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
392 | // qDebug(entryName); | 394 | // odebug << entryName << oendl; |
393 | cfg.writeEntry( entryName, lnk->linkFile() ); | 395 | cfg.writeEntry( entryName, lnk->linkFile() ); |
394 | // if this link does exist, add it so we have the file | 396 | // if this link does exist, add it so we have the file |
395 | // next time... | 397 | // next time... |
396 | if ( !QFile::exists( lnk->linkFile() ) ) { | 398 | if ( !QFile::exists( lnk->linkFile() ) ) { |
397 | // the way writing lnks doesn't really check for out | 399 | // the way writing lnks doesn't really check for out |
398 | // of disk space, but check it anyway. | 400 | // of disk space, but check it anyway. |
399 | // if ( !lnk->writeLink() ) { | 401 | // if ( !lnk->writeLink() ) { |
400 | // QMessageBox::critical( 0, tr("Out of space"), | 402 | // QMessageBox::critical( 0, tr("Out of space"), |
401 | // tr( "There was a problem saving " | 403 | // tr( "There was a problem saving " |
402 | // "the playlist.\n" | 404 | // "the playlist.\n" |
403 | // "Your playlist " | 405 | // "Your playlist " |
404 | // "may be missing some entries\n" | 406 | // "may be missing some entries\n" |
405 | // "the next time you start it." ) | 407 | // "the next time you start it." ) |
406 | // ); | 408 | // ); |
407 | // } | 409 | // } |
408 | 410 | ||
409 | } | 411 | } |
410 | noOfFiles++; | 412 | noOfFiles++; |
411 | } | 413 | } |
412 | } | 414 | } |
413 | while ( d->selectedFiles->next() ); | 415 | while ( d->selectedFiles->next() ); |
414 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 416 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
415 | } | 417 | } |
416 | 418 | ||
417 | 419 | ||
418 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 420 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
419 | d->setDocumentUsed = false; | 421 | d->setDocumentUsed = false; |
420 | if ( mediaPlayerState->playlist() ) { | 422 | if ( mediaPlayerState->playlist() ) { |
421 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 423 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
422 | d->selectedFiles->addToSelection( lnk ); | 424 | d->selectedFiles->addToSelection( lnk ); |
423 | } | 425 | } |
424 | else | 426 | else |
425 | mediaPlayerState->setPlaying( true); | 427 | mediaPlayerState->setPlaying( true); |
@@ -433,79 +435,79 @@ void PlayListWidget::clearList() { | |||
433 | Config cfg( "OpiePlayer" ); | 435 | Config cfg( "OpiePlayer" ); |
434 | cfg.setGroup("PlayList"); | 436 | cfg.setGroup("PlayList"); |
435 | cfg.writeEntry("CurrentPlaylist",""); | 437 | cfg.writeEntry("CurrentPlaylist",""); |
436 | currentPlayList=""; | 438 | currentPlayList=""; |
437 | 439 | ||
438 | } | 440 | } |
439 | 441 | ||
440 | 442 | ||
441 | void PlayListWidget::addAllToList() { | 443 | void PlayListWidget::addAllToList() { |
442 | DocLnkSet filesAll; | 444 | DocLnkSet filesAll; |
443 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 445 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
444 | QListIterator<DocLnk> Adit( filesAll.children() ); | 446 | QListIterator<DocLnk> Adit( filesAll.children() ); |
445 | for ( ; Adit.current(); ++Adit ) | 447 | for ( ; Adit.current(); ++Adit ) |
446 | if(QFileInfo(Adit.current()->file()).exists()) | 448 | if(QFileInfo(Adit.current()->file()).exists()) |
447 | d->selectedFiles->addToSelection( **Adit ); | 449 | d->selectedFiles->addToSelection( **Adit ); |
448 | tabWidget->setCurrentPage(0); | 450 | tabWidget->setCurrentPage(0); |
449 | 451 | ||
450 | writeCurrentM3u(); | 452 | writeCurrentM3u(); |
451 | d->selectedFiles->first(); | 453 | d->selectedFiles->first(); |
452 | } | 454 | } |
453 | 455 | ||
454 | 456 | ||
455 | void PlayListWidget::addAllMusicToList() { | 457 | void PlayListWidget::addAllMusicToList() { |
456 | QListIterator<DocLnk> dit( files.children() ); | 458 | QListIterator<DocLnk> dit( files.children() ); |
457 | for ( ; dit.current(); ++dit ) | 459 | for ( ; dit.current(); ++dit ) |
458 | if(QFileInfo(dit.current()->file()).exists()) | 460 | if(QFileInfo(dit.current()->file()).exists()) |
459 | d->selectedFiles->addToSelection( **dit ); | 461 | d->selectedFiles->addToSelection( **dit ); |
460 | tabWidget->setCurrentPage(0); | 462 | tabWidget->setCurrentPage(0); |
461 | 463 | ||
462 | writeCurrentM3u(); | 464 | writeCurrentM3u(); |
463 | d->selectedFiles->first(); | 465 | d->selectedFiles->first(); |
464 | } | 466 | } |
465 | 467 | ||
466 | 468 | ||
467 | void PlayListWidget::addAllVideoToList() { | 469 | void PlayListWidget::addAllVideoToList() { |
468 | QListIterator<DocLnk> dit( vFiles.children() ); | 470 | QListIterator<DocLnk> dit( vFiles.children() ); |
469 | for ( ; dit.current(); ++dit ) | 471 | for ( ; dit.current(); ++dit ) |
470 | if(QFileInfo( dit.current()->file()).exists()) | 472 | if(QFileInfo( dit.current()->file()).exists()) |
471 | d->selectedFiles->addToSelection( **dit ); | 473 | d->selectedFiles->addToSelection( **dit ); |
472 | tabWidget->setCurrentPage(0); | 474 | tabWidget->setCurrentPage(0); |
473 | 475 | ||
474 | writeCurrentM3u(); | 476 | writeCurrentM3u(); |
475 | d->selectedFiles->first(); | 477 | d->selectedFiles->first(); |
476 | } | 478 | } |
477 | 479 | ||
478 | 480 | ||
479 | void PlayListWidget::setDocument(const QString& fileref) { | 481 | void PlayListWidget::setDocument(const QString& fileref) { |
480 | fromSetDocument = true; | 482 | fromSetDocument = true; |
481 | d->setDocumentUsed = TRUE; | 483 | d->setDocumentUsed = TRUE; |
482 | setDocumentEx(fileref); | 484 | setDocumentEx(fileref); |
483 | } | 485 | } |
484 | 486 | ||
485 | void PlayListWidget::setDocumentEx(const QString& fileref) { | 487 | void PlayListWidget::setDocumentEx(const QString& fileref) { |
486 | qDebug("opieplayer receive "+fileref); | 488 | odebug << "opieplayer receive "+fileref << oendl; |
487 | clearList(); | 489 | clearList(); |
488 | DocLnk lnk; | 490 | DocLnk lnk; |
489 | QFileInfo fileInfo(fileref); | 491 | QFileInfo fileInfo(fileref); |
490 | if ( !fileInfo.exists() ) { | 492 | if ( !fileInfo.exists() ) { |
491 | QMessageBox::critical( 0, tr( "Invalid File" ), | 493 | QMessageBox::critical( 0, tr( "Invalid File" ), |
492 | tr( "There was a problem in getting the file." ) ); | 494 | tr( "There was a problem in getting the file." ) ); |
493 | return; | 495 | return; |
494 | } | 496 | } |
495 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref); | 497 | // odebug << "<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref << oendl; |
496 | QString extension = fileInfo.extension(false); | 498 | QString extension = fileInfo.extension(false); |
497 | if( extension.find( "m3u", 0, false) != -1) { //is m3u | 499 | if( extension.find( "m3u", 0, false) != -1) { //is m3u |
498 | readm3u( fileref); | 500 | readm3u( fileref); |
499 | } | 501 | } |
500 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls | 502 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls |
501 | readPls( fileref); | 503 | readPls( fileref); |
502 | } | 504 | } |
503 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist | 505 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist |
504 | clearList(); | 506 | clearList(); |
505 | lnk.setName( fileInfo.baseName() ); //sets name | 507 | lnk.setName( fileInfo.baseName() ); //sets name |
506 | lnk.setFile( fileref ); //sets file name | 508 | lnk.setFile( fileref ); //sets file name |
507 | lnk.setIcon("Sound"); | 509 | lnk.setIcon("Sound"); |
508 | //addToSelection( lnk ); | 510 | //addToSelection( lnk ); |
509 | 511 | ||
510 | loadList( lnk); | 512 | loadList( lnk); |
511 | d->selectedFiles->first(); | 513 | d->selectedFiles->first(); |
@@ -521,71 +523,71 @@ void PlayListWidget::setDocumentEx(const QString& fileref) { | |||
521 | addToSelection( lnk ); | 523 | addToSelection( lnk ); |
522 | // addToSelection( DocLnk( fileref ) ); | 524 | // addToSelection( DocLnk( fileref ) ); |
523 | lnk.removeLinkFile(); | 525 | lnk.removeLinkFile(); |
524 | // qApp->processEvents(); | 526 | // qApp->processEvents(); |
525 | } | 527 | } |
526 | setCaption(tr("OpiePlayer")); | 528 | setCaption(tr("OpiePlayer")); |
527 | d->setDocumentUsed = TRUE; | 529 | d->setDocumentUsed = TRUE; |
528 | d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); | 530 | d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); |
529 | mediaPlayerState->setPlaying( FALSE ); | 531 | mediaPlayerState->setPlaying( FALSE ); |
530 | qApp->processEvents(); | 532 | qApp->processEvents(); |
531 | mediaPlayerState->setPlaying( TRUE ); | 533 | mediaPlayerState->setPlaying( TRUE ); |
532 | 534 | ||
533 | } | 535 | } |
534 | 536 | ||
535 | 537 | ||
536 | void PlayListWidget::setActiveWindow() { | 538 | void PlayListWidget::setActiveWindow() { |
537 | // qDebug("SETTING active window"); | 539 | // odebug << "SETTING active window" << oendl; |
538 | // When we get raised we need to ensure that it switches views | 540 | // When we get raised we need to ensure that it switches views |
539 | char origView = mediaPlayerState->view(); | 541 | char origView = mediaPlayerState->view(); |
540 | mediaPlayerState->setView( 'l' ); // invalidate | 542 | mediaPlayerState->setView( 'l' ); // invalidate |
541 | mediaPlayerState->setView( origView ); // now switch back | 543 | mediaPlayerState->setView( origView ); // now switch back |
542 | } | 544 | } |
543 | 545 | ||
544 | 546 | ||
545 | void PlayListWidget::useSelectedDocument() { | 547 | void PlayListWidget::useSelectedDocument() { |
546 | d->setDocumentUsed = FALSE; | 548 | d->setDocumentUsed = FALSE; |
547 | } | 549 | } |
548 | 550 | ||
549 | 551 | ||
550 | const DocLnk *PlayListWidget::current() { // this is fugly | 552 | const DocLnk *PlayListWidget::current() { // this is fugly |
551 | switch (tabWidget->currentPageIndex()) { | 553 | switch (tabWidget->currentPageIndex()) { |
552 | case 0: //playlist | 554 | case 0: //playlist |
553 | { | 555 | { |
554 | // qDebug("playlist"); | 556 | // odebug << "playlist" << oendl; |
555 | if ( mediaPlayerState->playlist() ) { | 557 | if ( mediaPlayerState->playlist() ) { |
556 | return d->selectedFiles->current(); | 558 | return d->selectedFiles->current(); |
557 | } | 559 | } |
558 | else if ( d->setDocumentUsed && d->current ) { | 560 | else if ( d->setDocumentUsed && d->current ) { |
559 | return d->current; | 561 | return d->current; |
560 | } else { | 562 | } else { |
561 | return &(d->files->selectedDocument()); | 563 | return &(d->files->selectedDocument()); |
562 | } | 564 | } |
563 | } | 565 | } |
564 | break; | 566 | break; |
565 | case 1://audio | 567 | case 1://audio |
566 | { | 568 | { |
567 | // qDebug("audioView"); | 569 | // odebug << "audioView" << oendl; |
568 | QListIterator<DocLnk> dit( files.children() ); | 570 | QListIterator<DocLnk> dit( files.children() ); |
569 | for ( ; dit.current(); ++dit ) { | 571 | for ( ; dit.current(); ++dit ) { |
570 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 572 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
571 | insanityBool=TRUE; | 573 | insanityBool=TRUE; |
572 | return dit; | 574 | return dit; |
573 | } | 575 | } |
574 | } | 576 | } |
575 | } | 577 | } |
576 | break; | 578 | break; |
577 | case 2: // video | 579 | case 2: // video |
578 | { | 580 | { |
579 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 581 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
580 | for ( ; Vdit.current(); ++Vdit ) { | 582 | for ( ; Vdit.current(); ++Vdit ) { |
581 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 583 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
582 | insanityBool=TRUE; | 584 | insanityBool=TRUE; |
583 | return Vdit; | 585 | return Vdit; |
584 | } | 586 | } |
585 | } | 587 | } |
586 | } | 588 | } |
587 | break; | 589 | break; |
588 | }; | 590 | }; |
589 | return 0; | 591 | return 0; |
590 | } | 592 | } |
591 | 593 | ||
@@ -647,45 +649,45 @@ bool PlayListWidget::first() { | |||
647 | 649 | ||
648 | 650 | ||
649 | bool PlayListWidget::last() { | 651 | bool PlayListWidget::last() { |
650 | if ( mediaPlayerState->playlist() ) | 652 | if ( mediaPlayerState->playlist() ) |
651 | return d->selectedFiles->last(); | 653 | return d->selectedFiles->last(); |
652 | else | 654 | else |
653 | return mediaPlayerState->looping(); | 655 | return mediaPlayerState->looping(); |
654 | } | 656 | } |
655 | 657 | ||
656 | 658 | ||
657 | void PlayListWidget::saveList() { | 659 | void PlayListWidget::saveList() { |
658 | writem3u(); | 660 | writem3u(); |
659 | } | 661 | } |
660 | 662 | ||
661 | void PlayListWidget::loadList( const DocLnk & lnk) { | 663 | void PlayListWidget::loadList( const DocLnk & lnk) { |
662 | QString name = lnk.name(); | 664 | QString name = lnk.name(); |
663 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 665 | // odebug << "<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name << oendl; |
664 | 666 | ||
665 | if( name.length()>0) { | 667 | if( name.length()>0) { |
666 | setCaption("OpiePlayer: "+name); | 668 | setCaption("OpiePlayer: "+name); |
667 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 669 | // odebug << "<<<<<<<<<<<<load list "+ lnk.file() << oendl; |
668 | clearList(); | 670 | clearList(); |
669 | readm3u(lnk.file()); | 671 | readm3u(lnk.file()); |
670 | tabWidget->setCurrentPage(0); | 672 | tabWidget->setCurrentPage(0); |
671 | } | 673 | } |
672 | } | 674 | } |
673 | 675 | ||
674 | void PlayListWidget::setPlaylist( bool shown ) { | 676 | void PlayListWidget::setPlaylist( bool shown ) { |
675 | if ( shown ) | 677 | if ( shown ) |
676 | d->playListFrame->show(); | 678 | d->playListFrame->show(); |
677 | else | 679 | else |
678 | d->playListFrame->hide(); | 680 | d->playListFrame->hide(); |
679 | } | 681 | } |
680 | 682 | ||
681 | void PlayListWidget::setView( char view ) { | 683 | void PlayListWidget::setView( char view ) { |
682 | if ( view == 'l' ) | 684 | if ( view == 'l' ) |
683 | QPEApplication::showWidget( this ); | 685 | QPEApplication::showWidget( this ); |
684 | else | 686 | else |
685 | hide(); | 687 | hide(); |
686 | } | 688 | } |
687 | 689 | ||
688 | void PlayListWidget::addSelected() { | 690 | void PlayListWidget::addSelected() { |
689 | DocLnk lnk; | 691 | DocLnk lnk; |
690 | QString filename; | 692 | QString filename; |
691 | switch (tabWidget->currentPageIndex()) { | 693 | switch (tabWidget->currentPageIndex()) { |
@@ -694,87 +696,87 @@ void PlayListWidget::addSelected() { | |||
694 | return; | 696 | return; |
695 | break; | 697 | break; |
696 | case 1: { //audio | 698 | case 1: { //audio |
697 | QListViewItemIterator it( audioView ); | 699 | QListViewItemIterator it( audioView ); |
698 | for ( ; it.current(); ++it ) { | 700 | for ( ; it.current(); ++it ) { |
699 | if ( it.current()->isSelected() ) { | 701 | if ( it.current()->isSelected() ) { |
700 | filename = it.current()->text(3); | 702 | filename = it.current()->text(3); |
701 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 703 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
702 | lnk.setFile( filename ); //sets file name | 704 | lnk.setFile( filename ); //sets file name |
703 | d->selectedFiles->addToSelection( lnk); | 705 | d->selectedFiles->addToSelection( lnk); |
704 | } | 706 | } |
705 | } | 707 | } |
706 | audioView->clearSelection(); | 708 | audioView->clearSelection(); |
707 | // d->selectedFiles->next(); | 709 | // d->selectedFiles->next(); |
708 | } | 710 | } |
709 | break; | 711 | break; |
710 | 712 | ||
711 | case 2: { // video | 713 | case 2: { // video |
712 | QListViewItemIterator it( videoView ); | 714 | QListViewItemIterator it( videoView ); |
713 | for ( ; it.current(); ++it ) { | 715 | for ( ; it.current(); ++it ) { |
714 | if ( it.current()->isSelected() ) { | 716 | if ( it.current()->isSelected() ) { |
715 | 717 | ||
716 | filename = it.current()->text(3); | 718 | filename = it.current()->text(3); |
717 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 719 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
718 | lnk.setFile( filename ); //sets file name | 720 | lnk.setFile( filename ); //sets file name |
719 | d->selectedFiles->addToSelection( lnk); | 721 | d->selectedFiles->addToSelection( lnk); |
720 | } | 722 | } |
721 | } | 723 | } |
722 | videoView->clearSelection(); | 724 | videoView->clearSelection(); |
723 | } | 725 | } |
724 | break; | 726 | break; |
725 | }; | 727 | }; |
726 | // tabWidget->setCurrentPage(0); | 728 | // tabWidget->setCurrentPage(0); |
727 | writeCurrentM3u(); | 729 | writeCurrentM3u(); |
728 | 730 | ||
729 | } | 731 | } |
730 | 732 | ||
731 | void PlayListWidget::removeSelected() { | 733 | void PlayListWidget::removeSelected() { |
732 | d->selectedFiles->removeSelected( ); | 734 | d->selectedFiles->removeSelected( ); |
733 | } | 735 | } |
734 | 736 | ||
735 | void PlayListWidget::playIt( QListViewItem *) { | 737 | void PlayListWidget::playIt( QListViewItem *) { |
736 | // d->setDocumentUsed = FALSE; | 738 | // d->setDocumentUsed = FALSE; |
737 | // mediaPlayerState->curPosition =0; | 739 | // mediaPlayerState->curPosition =0; |
738 | // mediaPlayerState->setPlaying(FALSE); | 740 | // mediaPlayerState->setPlaying(FALSE); |
739 | mediaPlayerState->setPlaying(TRUE); | 741 | mediaPlayerState->setPlaying(TRUE); |
740 | d->selectedFiles->unSelect(); | 742 | d->selectedFiles->unSelect(); |
741 | } | 743 | } |
742 | 744 | ||
743 | void PlayListWidget::addToSelection( QListViewItem *it) { | 745 | void PlayListWidget::addToSelection( QListViewItem *it) { |
744 | d->setDocumentUsed = FALSE; | 746 | d->setDocumentUsed = FALSE; |
745 | 747 | ||
746 | if(it) { | 748 | if(it) { |
747 | switch ( tabWidget->currentPageIndex()) { | 749 | switch ( tabWidget->currentPageIndex()) { |
748 | case 0: //playlist | 750 | case 0: //playlist |
749 | return; | 751 | return; |
750 | break; | 752 | break; |
751 | }; | 753 | }; |
752 | // case 1: { | 754 | // case 1: { |
753 | DocLnk lnk; | 755 | DocLnk lnk; |
754 | QString filename; | 756 | QString filename; |
755 | 757 | ||
756 | filename=it->text(3); | 758 | filename=it->text(3); |
757 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 759 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
758 | lnk.setFile( filename ); //sets file name | 760 | lnk.setFile( filename ); //sets file name |
759 | d->selectedFiles->addToSelection( lnk); | 761 | d->selectedFiles->addToSelection( lnk); |
760 | 762 | ||
761 | if(tabWidget->currentPageIndex() == 0) | 763 | if(tabWidget->currentPageIndex() == 0) |
762 | writeCurrentM3u(); | 764 | writeCurrentM3u(); |
763 | // tabWidget->setCurrentPage(0); | 765 | // tabWidget->setCurrentPage(0); |
764 | 766 | ||
765 | } | 767 | } |
766 | } | 768 | } |
767 | 769 | ||
768 | void PlayListWidget::tabChanged(QWidget *) { | 770 | void PlayListWidget::tabChanged(QWidget *) { |
769 | 771 | ||
770 | switch ( tabWidget->currentPageIndex()) { | 772 | switch ( tabWidget->currentPageIndex()) { |
771 | case 0: | 773 | case 0: |
772 | { | 774 | { |
773 | if( !tbDeletePlaylist->isHidden()) | 775 | if( !tbDeletePlaylist->isHidden()) |
774 | tbDeletePlaylist->hide(); | 776 | tbDeletePlaylist->hide(); |
775 | d->tbRemoveFromList->setEnabled(TRUE); | 777 | d->tbRemoveFromList->setEnabled(TRUE); |
776 | d->tbAddToList->setEnabled(FALSE); | 778 | d->tbAddToList->setEnabled(FALSE); |
777 | } | 779 | } |
778 | break; | 780 | break; |
779 | case 1: | 781 | case 1: |
780 | { | 782 | { |
@@ -805,130 +807,130 @@ void PlayListWidget::tabChanged(QWidget *) { | |||
805 | } | 807 | } |
806 | break; | 808 | break; |
807 | }; | 809 | }; |
808 | } | 810 | } |
809 | 811 | ||
810 | void PlayListWidget::btnPlay(bool b) { | 812 | void PlayListWidget::btnPlay(bool b) { |
811 | // mediaPlayerState->setPlaying(b); | 813 | // mediaPlayerState->setPlaying(b); |
812 | switch ( tabWidget->currentPageIndex()) { | 814 | switch ( tabWidget->currentPageIndex()) { |
813 | case 0: | 815 | case 0: |
814 | { | 816 | { |
815 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 817 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
816 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 818 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
817 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 819 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
818 | // } else { | 820 | // } else { |
819 | mediaPlayerState->setPlaying(b); | 821 | mediaPlayerState->setPlaying(b); |
820 | insanityBool=FALSE; | 822 | insanityBool=FALSE; |
821 | qDebug("insanity"); | 823 | odebug << "insanity" << oendl; |
822 | // } | 824 | // } |
823 | } | 825 | } |
824 | break; | 826 | break; |
825 | case 1: | 827 | case 1: |
826 | { | 828 | { |
827 | // d->selectedFiles->unSelect(); | 829 | // d->selectedFiles->unSelect(); |
828 | addToSelection( audioView->currentItem() ); | 830 | addToSelection( audioView->currentItem() ); |
829 | mediaPlayerState->setPlaying( b); | 831 | mediaPlayerState->setPlaying( b); |
830 | d->selectedFiles->removeSelected( ); | 832 | d->selectedFiles->removeSelected( ); |
831 | d->selectedFiles->unSelect(); | 833 | d->selectedFiles->unSelect(); |
832 | tabWidget->setCurrentPage(1); | 834 | tabWidget->setCurrentPage(1); |
833 | insanityBool=FALSE; | 835 | insanityBool=FALSE; |
834 | }// audioView->clearSelection(); | 836 | }// audioView->clearSelection(); |
835 | break; | 837 | break; |
836 | case 2: | 838 | case 2: |
837 | { | 839 | { |
838 | 840 | ||
839 | addToSelection( videoView->currentItem() ); | 841 | addToSelection( videoView->currentItem() ); |
840 | mediaPlayerState->setPlaying( b); | 842 | mediaPlayerState->setPlaying( b); |
841 | // qApp->processEvents(); | 843 | // qApp->processEvents(); |
842 | d->selectedFiles->removeSelected( ); | 844 | d->selectedFiles->removeSelected( ); |
843 | d->selectedFiles->unSelect(); | 845 | d->selectedFiles->unSelect(); |
844 | tabWidget->setCurrentPage(2); | 846 | tabWidget->setCurrentPage(2); |
845 | insanityBool=FALSE; | 847 | insanityBool=FALSE; |
846 | }// videoView->clearSelection(); | 848 | }// videoView->clearSelection(); |
847 | break; | 849 | break; |
848 | }; | 850 | }; |
849 | 851 | ||
850 | } | 852 | } |
851 | 853 | ||
852 | void PlayListWidget::deletePlaylist() { | 854 | void PlayListWidget::deletePlaylist() { |
853 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 855 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
854 | (tr("You really want to delete\nthis playlist?")), | 856 | (tr("You really want to delete\nthis playlist?")), |
855 | (tr("Yes")), (tr("No")), 0 )){ | 857 | (tr("Yes")), (tr("No")), 0 )){ |
856 | case 0: // Yes clicked, | 858 | case 0: // Yes clicked, |
857 | QFile().remove(playLists->selectedDocument().file()); | 859 | QFile().remove(playLists->selectedDocument().file()); |
858 | QFile().remove(playLists->selectedDocument().linkFile()); | 860 | QFile().remove(playLists->selectedDocument().linkFile()); |
859 | playLists->reread(); | 861 | playLists->reread(); |
860 | break; | 862 | break; |
861 | case 1: // Cancel | 863 | case 1: // Cancel |
862 | break; | 864 | break; |
863 | }; | 865 | }; |
864 | } | 866 | } |
865 | 867 | ||
866 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) | 868 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) |
867 | { | 869 | { |
868 | switch (mouse) { | 870 | switch (mouse) { |
869 | case 1: | 871 | case 1: |
870 | break; | 872 | break; |
871 | case 2:{ | 873 | case 2:{ |
872 | 874 | ||
873 | QPopupMenu m; | 875 | QPopupMenu m; |
874 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 876 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
875 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 877 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
876 | m.insertSeparator(); | 878 | m.insertSeparator(); |
877 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 879 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
878 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 880 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
879 | 881 | ||
880 | m.exec( QCursor::pos() ); | 882 | m.exec( QCursor::pos() ); |
881 | } | 883 | } |
882 | break; | 884 | break; |
883 | }; | 885 | }; |
884 | } | 886 | } |
885 | 887 | ||
886 | void PlayListWidget::playSelected() | 888 | void PlayListWidget::playSelected() |
887 | { | 889 | { |
888 | btnPlay( true); | 890 | btnPlay( true); |
889 | // d->selectedFiles->unSelect(); | 891 | // d->selectedFiles->unSelect(); |
890 | } | 892 | } |
891 | 893 | ||
892 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) | 894 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) |
893 | { | 895 | { |
894 | switch (mouse) { | 896 | switch (mouse) { |
895 | case 1: | 897 | case 1: |
896 | 898 | ||
897 | break; | 899 | break; |
898 | case 2:{ | 900 | case 2:{ |
899 | QPopupMenu m; | 901 | QPopupMenu m; |
900 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 902 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
901 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 903 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
902 | // m.insertSeparator(); | 904 | // m.insertSeparator(); |
903 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 905 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
904 | m.exec( QCursor::pos() ); | 906 | m.exec( QCursor::pos() ); |
905 | } | 907 | } |
906 | break; | 908 | break; |
907 | }; | 909 | }; |
908 | 910 | ||
909 | } | 911 | } |
910 | 912 | ||
911 | void PlayListWidget::listDelete() { | 913 | void PlayListWidget::listDelete() { |
912 | Config cfg( "OpiePlayer" ); | 914 | Config cfg( "OpiePlayer" ); |
913 | cfg.setGroup("PlayList"); | 915 | cfg.setGroup("PlayList"); |
914 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); | 916 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); |
915 | QString file; | 917 | QString file; |
916 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 918 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
917 | switch ( tabWidget->currentPageIndex()) { | 919 | switch ( tabWidget->currentPageIndex()) { |
918 | case 0: | 920 | case 0: |
919 | break; | 921 | break; |
920 | case 1: | 922 | case 1: |
921 | { | 923 | { |
922 | file = audioView->currentItem()->text(0); | 924 | file = audioView->currentItem()->text(0); |
923 | QListIterator<DocLnk> Pdit( files.children() ); | 925 | QListIterator<DocLnk> Pdit( files.children() ); |
924 | for ( ; Pdit.current(); ++Pdit ) { | 926 | for ( ; Pdit.current(); ++Pdit ) { |
925 | if( Pdit.current()->name() == file) { | 927 | if( Pdit.current()->name() == file) { |
926 | LnkProperties prop( Pdit.current() ); | 928 | LnkProperties prop( Pdit.current() ); |
927 | QPEApplication::execDialog( &prop ); | 929 | QPEApplication::execDialog( &prop ); |
928 | } | 930 | } |
929 | } | 931 | } |
930 | populateAudioView(); | 932 | populateAudioView(); |
931 | } | 933 | } |
932 | break; | 934 | break; |
933 | case 2: | 935 | case 2: |
934 | { | 936 | { |
@@ -938,78 +940,78 @@ void PlayListWidget::listDelete() { | |||
938 | // entryName.sprintf( "File%i", i + 1 ); | 940 | // entryName.sprintf( "File%i", i + 1 ); |
939 | // QString linkFile = cfg.readEntry( entryName ); | 941 | // QString linkFile = cfg.readEntry( entryName ); |
940 | // AppLnk lnk( AppLnk(linkFile)); | 942 | // AppLnk lnk( AppLnk(linkFile)); |
941 | // if( lnk.name() == file ) { | 943 | // if( lnk.name() == file ) { |
942 | // LnkProperties prop( &lnk); | 944 | // LnkProperties prop( &lnk); |
943 | // // connect(&prop, SIGNAL(select(const AppLnk*)), this, SLOT(externalSelected(const AppLnk*))); | 945 | // // connect(&prop, SIGNAL(select(const AppLnk*)), this, SLOT(externalSelected(const AppLnk*))); |
944 | // prop.showMaximized(); | 946 | // prop.showMaximized(); |
945 | // prop.exec(); | 947 | // prop.exec(); |
946 | // } | 948 | // } |
947 | // } | 949 | // } |
948 | } | 950 | } |
949 | break; | 951 | break; |
950 | }; | 952 | }; |
951 | } | 953 | } |
952 | 954 | ||
953 | void PlayListWidget::scanForAudio() { | 955 | void PlayListWidget::scanForAudio() { |
954 | // qDebug("scan for audio"); | 956 | // odebug << "scan for audio" << oendl; |
955 | files.detachChildren(); | 957 | files.detachChildren(); |
956 | QListIterator<DocLnk> sdit( files.children() ); | 958 | QListIterator<DocLnk> sdit( files.children() ); |
957 | for ( ; sdit.current(); ++sdit ) { | 959 | for ( ; sdit.current(); ++sdit ) { |
958 | delete sdit.current(); | 960 | delete sdit.current(); |
959 | } | 961 | } |
960 | Global::findDocuments( &files, audioMimes); | 962 | Global::findDocuments( &files, audioMimes); |
961 | audioScan = true; | 963 | audioScan = true; |
962 | } | 964 | } |
963 | void PlayListWidget::scanForVideo() { | 965 | void PlayListWidget::scanForVideo() { |
964 | // qDebug("scan for video"); | 966 | // odebug << "scan for video" << oendl; |
965 | vFiles.detachChildren(); | 967 | vFiles.detachChildren(); |
966 | QListIterator<DocLnk> sdit( vFiles.children() ); | 968 | QListIterator<DocLnk> sdit( vFiles.children() ); |
967 | for ( ; sdit.current(); ++sdit ) { | 969 | for ( ; sdit.current(); ++sdit ) { |
968 | delete sdit.current(); | 970 | delete sdit.current(); |
969 | } | 971 | } |
970 | Global::findDocuments(&vFiles, "video/*"); | 972 | Global::findDocuments(&vFiles, "video/*"); |
971 | videoScan = true; | 973 | videoScan = true; |
972 | } | 974 | } |
973 | 975 | ||
974 | void PlayListWidget::populateAudioView() { | 976 | void PlayListWidget::populateAudioView() { |
975 | 977 | ||
976 | audioView->clear(); | 978 | audioView->clear(); |
977 | StorageInfo storageInfo; | 979 | StorageInfo storageInfo; |
978 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 980 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
979 | if(!audioScan) scanForAudio(); | 981 | if(!audioScan) scanForAudio(); |
980 | 982 | ||
981 | QListIterator<DocLnk> dit( files.children() ); | 983 | QListIterator<DocLnk> dit( files.children() ); |
982 | QListIterator<FileSystem> it ( fs ); | 984 | QListIterator<FileSystem> it ( fs ); |
983 | 985 | ||
984 | QString storage; | 986 | QString storage; |
985 | for ( ; dit.current(); ++dit ) { | 987 | for ( ; dit.current(); ++dit ) { |
986 | for( ; it.current(); ++it ){ | 988 | for( ; it.current(); ++it ){ |
987 | const QString name = (*it)->name(); | 989 | const QString name = (*it)->name(); |
988 | const QString path = (*it)->path(); | 990 | const QString path = (*it)->path(); |
989 | if(dit.current()->file().find(path) != -1 ) storage=name; | 991 | if(dit.current()->file().find(path) != -1 ) storage=name; |
990 | } | 992 | } |
991 | 993 | ||
992 | QListViewItem * newItem; | 994 | QListViewItem * newItem; |
993 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 995 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
994 | long size; | 996 | long size; |
995 | if( dit.current()->file().left(4) == "http" ) | 997 | if( dit.current()->file().left(4) == "http" ) |
996 | size=0; | 998 | size=0; |
997 | else | 999 | else |
998 | size = QFile( dit.current()->file() ).size(); | 1000 | size = QFile( dit.current()->file() ).size(); |
999 | // qDebug(dit.current()->name()); | 1001 | // odebug << dit.current()->name() << oendl; |
1000 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 1002 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1001 | QString::number(size ), storage, dit.current()->file()); | 1003 | QString::number(size ), storage, dit.current()->file()); |
1002 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 1004 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1003 | } | 1005 | } |
1004 | } | 1006 | } |
1005 | 1007 | ||
1006 | } | 1008 | } |
1007 | 1009 | ||
1008 | void PlayListWidget::populateVideoView() { | 1010 | void PlayListWidget::populateVideoView() { |
1009 | videoView->clear(); | 1011 | videoView->clear(); |
1010 | StorageInfo storageInfo; | 1012 | StorageInfo storageInfo; |
1011 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1013 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1012 | 1014 | ||
1013 | if(!videoScan ) scanForVideo(); | 1015 | if(!videoScan ) scanForVideo(); |
1014 | 1016 | ||
1015 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1017 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
@@ -1027,33 +1029,33 @@ void PlayListWidget::populateVideoView() { | |||
1027 | if ( QFile( Vdit.current()->file()).exists() ) { | 1029 | if ( QFile( Vdit.current()->file()).exists() ) { |
1028 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 1030 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1029 | QString::number( QFile( Vdit.current()->file() ).size() ), | 1031 | QString::number( QFile( Vdit.current()->file() ).size() ), |
1030 | storage, Vdit.current()->file()); | 1032 | storage, Vdit.current()->file()); |
1031 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1033 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1032 | } | 1034 | } |
1033 | } | 1035 | } |
1034 | } | 1036 | } |
1035 | 1037 | ||
1036 | void PlayListWidget::openFile() { | 1038 | void PlayListWidget::openFile() { |
1037 | QString filename, name; | 1039 | QString filename, name; |
1038 | InputDialog *fileDlg; | 1040 | InputDialog *fileDlg; |
1039 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1041 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1040 | fileDlg->exec(); | 1042 | fileDlg->exec(); |
1041 | if( fileDlg->result() == 1 ) { | 1043 | if( fileDlg->result() == 1 ) { |
1042 | filename = fileDlg->text(); | 1044 | filename = fileDlg->text(); |
1043 | // qDebug( "Selected filename is " + filename ); | 1045 | // odebug << "Selected filename is " + filename << oendl; |
1044 | DocLnk lnk; | 1046 | DocLnk lnk; |
1045 | Config cfg( "OpiePlayer" ); | 1047 | Config cfg( "OpiePlayer" ); |
1046 | cfg.setGroup("PlayList"); | 1048 | cfg.setGroup("PlayList"); |
1047 | 1049 | ||
1048 | QString m3uFile; | 1050 | QString m3uFile; |
1049 | m3uFile = filename; | 1051 | m3uFile = filename; |
1050 | if(filename.left(4) == "http") { | 1052 | if(filename.left(4) == "http") { |
1051 | if(filename.find(":",8,TRUE) != -1) { //found a port | 1053 | if(filename.find(":",8,TRUE) != -1) { //found a port |
1052 | 1054 | ||
1053 | m3uFile = filename; | 1055 | m3uFile = filename; |
1054 | if( m3uFile.right( 1 ).find( '/' ) == -1) { | 1056 | if( m3uFile.right( 1 ).find( '/' ) == -1) { |
1055 | m3uFile += "/"; | 1057 | m3uFile += "/"; |
1056 | } | 1058 | } |
1057 | filename = m3uFile; | 1059 | filename = m3uFile; |
1058 | } | 1060 | } |
1059 | lnk.setName( m3uFile ); //sets name | 1061 | lnk.setName( m3uFile ); //sets name |
@@ -1062,100 +1064,100 @@ void PlayListWidget::openFile() { | |||
1062 | d->selectedFiles->addToSelection( lnk ); | 1064 | d->selectedFiles->addToSelection( lnk ); |
1063 | writeCurrentM3u(); | 1065 | writeCurrentM3u(); |
1064 | } | 1066 | } |
1065 | else if( filename.right( 3) == "m3u" ) { | 1067 | else if( filename.right( 3) == "m3u" ) { |
1066 | readm3u( filename ); | 1068 | readm3u( filename ); |
1067 | 1069 | ||
1068 | } else if( filename.right(3) == "pls" ) { | 1070 | } else if( filename.right(3) == "pls" ) { |
1069 | readPls( filename ); | 1071 | readPls( filename ); |
1070 | } else { | 1072 | } else { |
1071 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 1073 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
1072 | lnk.setFile( filename ); //sets file name | 1074 | lnk.setFile( filename ); //sets file name |
1073 | d->selectedFiles->addToSelection( lnk); | 1075 | d->selectedFiles->addToSelection( lnk); |
1074 | lnk.removeLinkFile(); | 1076 | lnk.removeLinkFile(); |
1075 | writeCurrentM3u(); | 1077 | writeCurrentM3u(); |
1076 | } | 1078 | } |
1077 | } | 1079 | } |
1078 | 1080 | ||
1079 | if( fileDlg ) { | 1081 | if( fileDlg ) { |
1080 | delete fileDlg; | 1082 | delete fileDlg; |
1081 | } | 1083 | } |
1082 | } | 1084 | } |
1083 | 1085 | ||
1084 | 1086 | ||
1085 | /* | 1087 | /* |
1086 | reads m3u and shows files/urls to playlist widget */ | 1088 | reads m3u and shows files/urls to playlist widget */ |
1087 | void PlayListWidget::readm3u( const QString &filename ) { | 1089 | void PlayListWidget::readm3u( const QString &filename ) { |
1088 | // qDebug( "read m3u filename " + filename ); | 1090 | // odebug << "read m3u filename " + filename << oendl; |
1089 | 1091 | ||
1090 | Om3u *m3uList; | 1092 | Om3u *m3uList; |
1091 | QString s, name; | 1093 | QString s, name; |
1092 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1094 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1093 | m3uList->readM3u(); | 1095 | m3uList->readM3u(); |
1094 | DocLnk lnk; | 1096 | DocLnk lnk; |
1095 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1097 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1096 | s = *it; | 1098 | s = *it; |
1097 | // qDebug("reading "+ s); | 1099 | // odebug << "reading "+ s << oendl; |
1098 | if(s.left(4)=="http") { | 1100 | if(s.left(4)=="http") { |
1099 | lnk.setName( s ); //sets file name | 1101 | lnk.setName( s ); //sets file name |
1100 | lnk.setIcon("opieplayer2/musicfile"); | 1102 | lnk.setIcon("opieplayer2/musicfile"); |
1101 | 1103 | ||
1102 | // if(s.right(4) != '.' || s.right(5) != '.') | 1104 | // if(s.right(4) != '.' || s.right(5) != '.') |
1103 | if(s.right(4) != '.' || s.right(5) != '.' ) | 1105 | if(s.right(4) != '.' || s.right(5) != '.' ) |
1104 | if( s.right(1) != "/") | 1106 | if( s.right(1) != "/") |
1105 | lnk.setFile( s+"/"); //if url with no extension | 1107 | lnk.setFile( s+"/"); //if url with no extension |
1106 | else | 1108 | else |
1107 | lnk.setFile( s ); //sets file name | 1109 | lnk.setFile( s ); //sets file name |
1108 | 1110 | ||
1109 | } else { | 1111 | } else { |
1110 | // if( QFileInfo( s ).exists() ) { | 1112 | // if( QFileInfo( s ).exists() ) { |
1111 | lnk.setName( fullBaseName ( QFileInfo(s))); | 1113 | lnk.setName( fullBaseName ( QFileInfo(s))); |
1112 | // if(s.right(4) == '.') {//if regular file | 1114 | // if(s.right(4) == '.') {//if regular file |
1113 | if(s.left(1) != "/") { | 1115 | if(s.left(1) != "/") { |
1114 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 1116 | // odebug << "set link "+QFileInfo(filename).dirPath()+"/"+s << oendl; |
1115 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 1117 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
1116 | lnk.setIcon("SoundPlayer"); | 1118 | lnk.setIcon("SoundPlayer"); |
1117 | } else { | 1119 | } else { |
1118 | // qDebug("set link2 "+s); | 1120 | // odebug << "set link2 "+s << oendl; |
1119 | lnk.setFile( s); | 1121 | lnk.setFile( s); |
1120 | lnk.setIcon("SoundPlayer"); | 1122 | lnk.setIcon("SoundPlayer"); |
1121 | } | 1123 | } |
1122 | } | 1124 | } |
1123 | d->selectedFiles->addToSelection( lnk ); | 1125 | d->selectedFiles->addToSelection( lnk ); |
1124 | } | 1126 | } |
1125 | Config config( "OpiePlayer" ); | 1127 | Config config( "OpiePlayer" ); |
1126 | config.setGroup( "PlayList" ); | 1128 | config.setGroup( "PlayList" ); |
1127 | 1129 | ||
1128 | config.writeEntry("CurrentPlaylist",filename); | 1130 | config.writeEntry("CurrentPlaylist",filename); |
1129 | config.write(); | 1131 | config.write(); |
1130 | currentPlayList=filename; | 1132 | currentPlayList=filename; |
1131 | 1133 | ||
1132 | // m3uList->write(); | 1134 | // m3uList->write(); |
1133 | m3uList->close(); | 1135 | m3uList->close(); |
1134 | if(m3uList) delete m3uList; | 1136 | if(m3uList) delete m3uList; |
1135 | 1137 | ||
1136 | d->selectedFiles->setSelectedItem( s); | 1138 | d->selectedFiles->setSelectedItem( s); |
1137 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); | 1139 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); |
1138 | 1140 | ||
1139 | } | 1141 | } |
1140 | 1142 | ||
1141 | /* | 1143 | /* |
1142 | reads pls and adds files/urls to playlist */ | 1144 | reads pls and adds files/urls to playlist */ |
1143 | void PlayListWidget::readPls( const QString &filename ) { | 1145 | void PlayListWidget::readPls( const QString &filename ) { |
1144 | 1146 | ||
1145 | // qDebug( "pls filename is " + filename ); | 1147 | // odebug << "pls filename is " + filename << oendl; |
1146 | Om3u *m3uList; | 1148 | Om3u *m3uList; |
1147 | QString s, name; | 1149 | QString s, name; |
1148 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1150 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1149 | m3uList->readPls(); | 1151 | m3uList->readPls(); |
1150 | 1152 | ||
1151 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1153 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1152 | s = *it; | 1154 | s = *it; |
1153 | // s.replace( QRegExp( "%20" )," " ); | 1155 | // s.replace( QRegExp( "%20" )," " ); |
1154 | DocLnk lnk( s ); | 1156 | DocLnk lnk( s ); |
1155 | QFileInfo f( s ); | 1157 | QFileInfo f( s ); |
1156 | QString name = fullBaseName ( f); | 1158 | QString name = fullBaseName ( f); |
1157 | 1159 | ||
1158 | if( name.left( 4 ) == "http" ) { | 1160 | if( name.left( 4 ) == "http" ) { |
1159 | name = s.right( s.length() - 7); | 1161 | name = s.right( s.length() - 7); |
1160 | } else { | 1162 | } else { |
1161 | name = s; | 1163 | name = s; |
@@ -1172,103 +1174,103 @@ void PlayListWidget::readPls( const QString &filename ) { | |||
1172 | } | 1174 | } |
1173 | lnk.setFile( s ); | 1175 | lnk.setFile( s ); |
1174 | } | 1176 | } |
1175 | lnk.setType( "audio/x-mpegurl" ); | 1177 | lnk.setType( "audio/x-mpegurl" ); |
1176 | 1178 | ||
1177 | lnk.writeLink(); | 1179 | lnk.writeLink(); |
1178 | d->selectedFiles->addToSelection( lnk ); | 1180 | d->selectedFiles->addToSelection( lnk ); |
1179 | } | 1181 | } |
1180 | 1182 | ||
1181 | m3uList->close(); | 1183 | m3uList->close(); |
1182 | if(m3uList) delete m3uList; | 1184 | if(m3uList) delete m3uList; |
1183 | } | 1185 | } |
1184 | 1186 | ||
1185 | /* | 1187 | /* |
1186 | writes current playlist to current m3u file */ | 1188 | writes current playlist to current m3u file */ |
1187 | void PlayListWidget::writeCurrentM3u() { | 1189 | void PlayListWidget::writeCurrentM3u() { |
1188 | // qDebug("writing to current m3u"); | 1190 | // odebug << "writing to current m3u" << oendl; |
1189 | Config cfg( "OpiePlayer" ); | 1191 | Config cfg( "OpiePlayer" ); |
1190 | cfg.setGroup("PlayList"); | 1192 | cfg.setGroup("PlayList"); |
1191 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); | 1193 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); |
1192 | Om3u *m3uList; | 1194 | Om3u *m3uList; |
1193 | m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); | 1195 | m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); |
1194 | 1196 | ||
1195 | if( d->selectedFiles->first()) { | 1197 | if( d->selectedFiles->first()) { |
1196 | do { | 1198 | do { |
1197 | // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | 1199 | // odebug << "writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; |
1198 | m3uList->add( d->selectedFiles->current()->file() ); | 1200 | m3uList->add( d->selectedFiles->current()->file() ); |
1199 | } | 1201 | } |
1200 | while ( d->selectedFiles->next() ); | 1202 | while ( d->selectedFiles->next() ); |
1201 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 1203 | // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; |
1202 | m3uList->write(); | 1204 | m3uList->write(); |
1203 | m3uList->close(); | 1205 | m3uList->close(); |
1204 | 1206 | ||
1205 | if(m3uList) delete m3uList; | 1207 | if(m3uList) delete m3uList; |
1206 | } | 1208 | } |
1207 | } | 1209 | } |
1208 | 1210 | ||
1209 | /* | 1211 | /* |
1210 | writes current playlist to m3u file */ | 1212 | writes current playlist to m3u file */ |
1211 | void PlayListWidget::writem3u() { | 1213 | void PlayListWidget::writem3u() { |
1212 | InputDialog *fileDlg; | 1214 | InputDialog *fileDlg; |
1213 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 1215 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
1214 | fileDlg->exec(); | 1216 | fileDlg->exec(); |
1215 | QString name, filename, list; | 1217 | QString name, filename, list; |
1216 | Om3u *m3uList; | 1218 | Om3u *m3uList; |
1217 | 1219 | ||
1218 | if( fileDlg->result() == 1 ) { | 1220 | if( fileDlg->result() == 1 ) { |
1219 | name = fileDlg->text(); | 1221 | name = fileDlg->text(); |
1220 | // qDebug( filename ); | 1222 | // odebug << filename << oendl; |
1221 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 1223 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
1222 | filename = name; | 1224 | filename = name; |
1223 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 1225 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
1224 | } | 1226 | } |
1225 | else //otherwise dump it somewhere noticable | 1227 | else //otherwise dump it somewhere noticable |
1226 | filename = QPEApplication::documentDir() + "/" + name; | 1228 | filename = QPEApplication::documentDir() + "/" + name; |
1227 | 1229 | ||
1228 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 1230 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
1229 | filename += ".m3u"; | 1231 | filename += ".m3u"; |
1230 | 1232 | ||
1231 | if( d->selectedFiles->first()) { | 1233 | if( d->selectedFiles->first()) { |
1232 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 1234 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
1233 | 1235 | ||
1234 | do { | 1236 | do { |
1235 | m3uList->add( d->selectedFiles->current()->file()); | 1237 | m3uList->add( d->selectedFiles->current()->file()); |
1236 | } | 1238 | } |
1237 | while ( d->selectedFiles->next() ); | 1239 | while ( d->selectedFiles->next() ); |
1238 | // qDebug( list ); | 1240 | // odebug << list << oendl; |
1239 | m3uList->write(); | 1241 | m3uList->write(); |
1240 | m3uList->close(); | 1242 | m3uList->close(); |
1241 | if(m3uList) delete m3uList; | 1243 | if(m3uList) delete m3uList; |
1242 | 1244 | ||
1243 | if(fileDlg) delete fileDlg; | 1245 | if(fileDlg) delete fileDlg; |
1244 | 1246 | ||
1245 | DocLnk lnk; | 1247 | DocLnk lnk; |
1246 | lnk.setFile( filename); | 1248 | lnk.setFile( filename); |
1247 | lnk.setIcon("opieplayer2/playlist2"); | 1249 | lnk.setIcon("opieplayer2/playlist2"); |
1248 | lnk.setName( name); //sets file name | 1250 | lnk.setName( name); //sets file name |
1249 | 1251 | ||
1250 | // qDebug(filename); | 1252 | // odebug << filename << oendl; |
1251 | Config config( "OpiePlayer" ); | 1253 | Config config( "OpiePlayer" ); |
1252 | config.setGroup( "PlayList" ); | 1254 | config.setGroup( "PlayList" ); |
1253 | 1255 | ||
1254 | config.writeEntry("CurrentPlaylist",filename); | 1256 | config.writeEntry("CurrentPlaylist",filename); |
1255 | currentPlayList=filename; | 1257 | currentPlayList=filename; |
1256 | 1258 | ||
1257 | if(!lnk.writeLink()) { | 1259 | if(!lnk.writeLink()) { |
1258 | // qDebug("Writing doclink did not work"); | 1260 | // odebug << "Writing doclink did not work" << oendl; |
1259 | } | 1261 | } |
1260 | 1262 | ||
1261 | setCaption(tr("OpiePlayer: ") + name); | 1263 | setCaption(tr("OpiePlayer: ") + name); |
1262 | } | 1264 | } |
1263 | } | 1265 | } |
1264 | } | 1266 | } |
1265 | 1267 | ||
1266 | 1268 | ||
1267 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1269 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1268 | { | 1270 | { |
1269 | switch ( e->key() ) { | 1271 | switch ( e->key() ) { |
1270 | ////////////////////////////// Zaurus keys | 1272 | ////////////////////////////// Zaurus keys |
1271 | case Key_F9: //activity | 1273 | case Key_F9: //activity |
1272 | // if(audioUI->isHidden()) | 1274 | // if(audioUI->isHidden()) |
1273 | // audioUI->showMaximized(); | 1275 | // audioUI->showMaximized(); |
1274 | break; | 1276 | break; |
@@ -1278,167 +1280,167 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | |||
1278 | break; | 1280 | break; |
1279 | case Key_F11: //menu | 1281 | case Key_F11: //menu |
1280 | break; | 1282 | break; |
1281 | case Key_F12: //home | 1283 | case Key_F12: //home |
1282 | // doBlank(); | 1284 | // doBlank(); |
1283 | break; | 1285 | break; |
1284 | case Key_F13: //mail | 1286 | case Key_F13: //mail |
1285 | // doUnblank(); | 1287 | // doUnblank(); |
1286 | break; | 1288 | break; |
1287 | case Key_Q: //add to playlist | 1289 | case Key_Q: //add to playlist |
1288 | addSelected(); | 1290 | addSelected(); |
1289 | break; | 1291 | break; |
1290 | case Key_R: //remove from playlist | 1292 | case Key_R: //remove from playlist |
1291 | removeSelected(); | 1293 | removeSelected(); |
1292 | break; | 1294 | break; |
1293 | // case Key_P: //play | 1295 | // case Key_P: //play |
1294 | // qDebug("Play"); | 1296 | // odebug << "Play" << oendl; |
1295 | // playSelected(); | 1297 | // playSelected(); |
1296 | // break; | 1298 | // break; |
1297 | case Key_Space: | 1299 | case Key_Space: |
1298 | // playSelected(); puh | 1300 | // playSelected(); puh |
1299 | break; | 1301 | break; |
1300 | case Key_1: | 1302 | case Key_1: |
1301 | tabWidget->setCurrentPage(0); | 1303 | tabWidget->setCurrentPage(0); |
1302 | break; | 1304 | break; |
1303 | case Key_2: | 1305 | case Key_2: |
1304 | tabWidget->setCurrentPage(1); | 1306 | tabWidget->setCurrentPage(1); |
1305 | break; | 1307 | break; |
1306 | case Key_3: | 1308 | case Key_3: |
1307 | tabWidget->setCurrentPage(2); | 1309 | tabWidget->setCurrentPage(2); |
1308 | break; | 1310 | break; |
1309 | case Key_4: | 1311 | case Key_4: |
1310 | tabWidget->setCurrentPage(3); | 1312 | tabWidget->setCurrentPage(3); |
1311 | break; | 1313 | break; |
1312 | case Key_Down: | 1314 | case Key_Down: |
1313 | if ( !d->selectedFiles->next() ) | 1315 | if ( !d->selectedFiles->next() ) |
1314 | d->selectedFiles->first(); | 1316 | d->selectedFiles->first(); |
1315 | 1317 | ||
1316 | break; | 1318 | break; |
1317 | case Key_Up: | 1319 | case Key_Up: |
1318 | if ( !d->selectedFiles->prev() ) | 1320 | if ( !d->selectedFiles->prev() ) |
1319 | // d->selectedFiles->last(); | 1321 | // d->selectedFiles->last(); |
1320 | 1322 | ||
1321 | break; | 1323 | break; |
1322 | 1324 | ||
1323 | } | 1325 | } |
1324 | } | 1326 | } |
1325 | 1327 | ||
1326 | void PlayListWidget::keyPressEvent( QKeyEvent *) | 1328 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1327 | { | 1329 | { |
1328 | // qDebug("Key press"); | 1330 | // odebug << "Key press" << oendl; |
1329 | // switch ( e->key() ) { | 1331 | // switch ( e->key() ) { |
1330 | // ////////////////////////////// Zaurus keys | 1332 | // ////////////////////////////// Zaurus keys |
1331 | // case Key_A: //add to playlist | 1333 | // case Key_A: //add to playlist |
1332 | // qDebug("Add"); | 1334 | // odebug << "Add" << oendl; |
1333 | // addSelected(); | 1335 | // addSelected(); |
1334 | // break; | 1336 | // break; |
1335 | // case Key_R: //remove from playlist | 1337 | // case Key_R: //remove from playlist |
1336 | // removeSelected(); | 1338 | // removeSelected(); |
1337 | // break; | 1339 | // break; |
1338 | // case Key_P: //play | 1340 | // case Key_P: //play |
1339 | // qDebug("Play"); | 1341 | // odebug << "Play" << oendl; |
1340 | // playSelected(); | 1342 | // playSelected(); |
1341 | // break; | 1343 | // break; |
1342 | // case Key_Space: | 1344 | // case Key_Space: |
1343 | // qDebug("Play"); | 1345 | // odebug << "Play" << oendl; |
1344 | // playSelected(); | 1346 | // playSelected(); |
1345 | // break; | 1347 | // break; |
1346 | // } | 1348 | // } |
1347 | } | 1349 | } |
1348 | 1350 | ||
1349 | void PlayListWidget::doBlank() { | 1351 | void PlayListWidget::doBlank() { |
1350 | // qDebug("do blanking"); | 1352 | // odebug << "do blanking" << oendl; |
1351 | #ifdef QT_QWS_DEVFS | 1353 | #ifdef QT_QWS_DEVFS |
1352 | fd=open("/dev/fb/0",O_RDWR); | 1354 | fd=open("/dev/fb/0",O_RDWR); |
1353 | #else | 1355 | #else |
1354 | fd=open("/dev/fb0",O_RDWR); | 1356 | fd=open("/dev/fb0",O_RDWR); |
1355 | #endif | 1357 | #endif |
1356 | if (fd != -1) { | 1358 | if (fd != -1) { |
1357 | ioctl(fd,FBIOBLANK,1); | 1359 | ioctl(fd,FBIOBLANK,1); |
1358 | // close(fd); | 1360 | // close(fd); |
1359 | } | 1361 | } |
1360 | } | 1362 | } |
1361 | 1363 | ||
1362 | void PlayListWidget::doUnblank() { | 1364 | void PlayListWidget::doUnblank() { |
1363 | // this crashes opieplayer with a segfault | 1365 | // this crashes opieplayer with a segfault |
1364 | // int fd; | 1366 | // int fd; |
1365 | // fd=open("/dev/fb0",O_RDWR); | 1367 | // fd=open("/dev/fb0",O_RDWR); |
1366 | // qDebug("do unblanking"); | 1368 | // odebug << "do unblanking" << oendl; |
1367 | if (fd != -1) { | 1369 | if (fd != -1) { |
1368 | ioctl(fd,FBIOBLANK,0); | 1370 | ioctl(fd,FBIOBLANK,0); |
1369 | close(fd); | 1371 | close(fd); |
1370 | } | 1372 | } |
1371 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1373 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1372 | h <<-3;// v[1]; // -3 Force on | 1374 | h <<-3;// v[1]; // -3 Force on |
1373 | } | 1375 | } |
1374 | 1376 | ||
1375 | void PlayListWidget::populateSkinsMenu() { | 1377 | void PlayListWidget::populateSkinsMenu() { |
1376 | int item = 0; | 1378 | int item = 0; |
1377 | defaultSkinIndex = 0; | 1379 | defaultSkinIndex = 0; |
1378 | QString skinName; | 1380 | QString skinName; |
1379 | Config cfg( "OpiePlayer" ); | 1381 | Config cfg( "OpiePlayer" ); |
1380 | cfg.setGroup("Options" ); | 1382 | cfg.setGroup("Options" ); |
1381 | QString skin = cfg.readEntry( "Skin", "default" ); | 1383 | QString skin = cfg.readEntry( "Skin", "default" ); |
1382 | 1384 | ||
1383 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1385 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1384 | skinsDir.setFilter( QDir::Dirs ); | 1386 | skinsDir.setFilter( QDir::Dirs ); |
1385 | skinsDir.setSorting(QDir::Name ); | 1387 | skinsDir.setSorting(QDir::Name ); |
1386 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1388 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1387 | QFileInfoListIterator it( *skinslist ); | 1389 | QFileInfoListIterator it( *skinslist ); |
1388 | QFileInfo *fi; | 1390 | QFileInfo *fi; |
1389 | while ( ( fi = it.current() ) ) { | 1391 | while ( ( fi = it.current() ) ) { |
1390 | skinName = fi->fileName(); | 1392 | skinName = fi->fileName(); |
1391 | // qDebug( fi->fileName() ); | 1393 | // odebug << fi->fileName() << oendl; |
1392 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1394 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1393 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1395 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1394 | } | 1396 | } |
1395 | if( skinName == "default" ) { | 1397 | if( skinName == "default" ) { |
1396 | defaultSkinIndex = item; | 1398 | defaultSkinIndex = item; |
1397 | } | 1399 | } |
1398 | if( skinName == skin ) { | 1400 | if( skinName == skin ) { |
1399 | skinsMenu->setItemChecked( item, TRUE ); | 1401 | skinsMenu->setItemChecked( item, TRUE ); |
1400 | } | 1402 | } |
1401 | ++it; | 1403 | ++it; |
1402 | } | 1404 | } |
1403 | } | 1405 | } |
1404 | 1406 | ||
1405 | void PlayListWidget::skinsMenuActivated( int item ) { | 1407 | void PlayListWidget::skinsMenuActivated( int item ) { |
1406 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1408 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1407 | skinsMenu->setItemChecked( i, FALSE ); | 1409 | skinsMenu->setItemChecked( i, FALSE ); |
1408 | } | 1410 | } |
1409 | skinsMenu->setItemChecked( item, TRUE ); | 1411 | skinsMenu->setItemChecked( item, TRUE ); |
1410 | 1412 | ||
1411 | Config cfg( "OpiePlayer" ); | 1413 | Config cfg( "OpiePlayer" ); |
1412 | cfg.setGroup("Options"); | 1414 | cfg.setGroup("Options"); |
1413 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1415 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1414 | } | 1416 | } |
1415 | 1417 | ||
1416 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1418 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1417 | // qDebug("qcop message "+msg ); | 1419 | // odebug << "qcop message "+msg << oendl; |
1418 | QDataStream stream ( data, IO_ReadOnly ); | 1420 | QDataStream stream ( data, IO_ReadOnly ); |
1419 | if ( msg == "play()" ) { //plays current selection | 1421 | if ( msg == "play()" ) { //plays current selection |
1420 | btnPlay( true); | 1422 | btnPlay( true); |
1421 | } else if ( msg == "stop()" ) { | 1423 | } else if ( msg == "stop()" ) { |
1422 | mediaPlayerState->setPlaying( false); | 1424 | mediaPlayerState->setPlaying( false); |
1423 | } else if ( msg == "togglePause()" ) { | 1425 | } else if ( msg == "togglePause()" ) { |
1424 | mediaPlayerState->togglePaused(); | 1426 | mediaPlayerState->togglePaused(); |
1425 | } else if ( msg == "next()" ) { //select next in lis | 1427 | } else if ( msg == "next()" ) { //select next in lis |
1426 | mediaPlayerState->setNext(); | 1428 | mediaPlayerState->setNext(); |
1427 | } else if ( msg == "prev()" ) { //select previous in list | 1429 | } else if ( msg == "prev()" ) { //select previous in list |
1428 | mediaPlayerState->setPrev(); | 1430 | mediaPlayerState->setPrev(); |
1429 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1431 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1430 | mediaPlayerState->toggleLooping(); | 1432 | mediaPlayerState->toggleLooping(); |
1431 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1433 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1432 | mediaPlayerState->toggleShuffled(); | 1434 | mediaPlayerState->toggleShuffled(); |
1433 | } else if ( msg == "volUp()" ) { //volume more | 1435 | } else if ( msg == "volUp()" ) { //volume more |
1434 | // emit moreClicked(); | 1436 | // emit moreClicked(); |
1435 | // emit moreReleased(); | 1437 | // emit moreReleased(); |
1436 | } else if ( msg == "volDown()" ) { //volume less | 1438 | } else if ( msg == "volDown()" ) { //volume less |
1437 | // emit lessClicked(); | 1439 | // emit lessClicked(); |
1438 | // emit lessReleased(); | 1440 | // emit lessReleased(); |
1439 | } else if ( msg == "play(QString)" ) { //play this now | 1441 | } else if ( msg == "play(QString)" ) { //play this now |
1440 | QString file; | 1442 | QString file; |
1441 | stream >> file; | 1443 | stream >> file; |
1442 | setDocumentEx( (const QString &) file); | 1444 | setDocumentEx( (const QString &) file); |
1443 | } else if ( msg == "add(QString)" ) { //add to playlist | 1445 | } else if ( msg == "add(QString)" ) { //add to playlist |
1444 | QString file; | 1446 | QString file; |
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index 164458b..e851044 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp | |||
@@ -4,41 +4,46 @@ | |||
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 | |||
21 | #include "videowidget.h" | ||
22 | #include "mediaplayerstate.h" | ||
23 | |||
24 | /* OPIE */ | ||
20 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
21 | #include <qpe/mediaplayerplugininterface.h> | 26 | #include <qpe/mediaplayerplugininterface.h> |
22 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
23 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #include <opie2/odebug.h> | ||
24 | 30 | ||
31 | /* QT */ | ||
25 | #include <qdir.h> | 32 | #include <qdir.h> |
26 | #include <qslider.h> | 33 | #include <qslider.h> |
27 | #include "videowidget.h" | ||
28 | #include "mediaplayerstate.h" | ||
29 | 34 | ||
30 | 35 | ||
31 | #ifdef Q_WS_QWS | 36 | #ifdef Q_WS_QWS |
32 | # define USE_DIRECT_PAINTER | 37 | # define USE_DIRECT_PAINTER |
33 | # include <qdirectpainter_qws.h> | 38 | # include <qdirectpainter_qws.h> |
34 | # include <qgfxraster_qws.h> | 39 | # include <qgfxraster_qws.h> |
35 | #endif | 40 | #endif |
36 | 41 | ||
37 | 42 | ||
38 | extern MediaPlayerState *mediaPlayerState; | 43 | extern MediaPlayerState *mediaPlayerState; |
39 | 44 | ||
40 | 45 | ||
41 | static const int xo = 2; // movable x offset | 46 | static const int xo = 2; // movable x offset |
42 | static const int yo = 0; // movable y offset | 47 | static const int yo = 0; // movable y offset |
43 | 48 | ||
44 | 49 | ||
@@ -69,78 +74,78 @@ const char *skinV_mask_file_names[7] = { | |||
69 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 74 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
70 | 75 | ||
71 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 76 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
72 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) | 77 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) |
73 | { | 78 | { |
74 | setCaption( tr("OpiePlayer") ); | 79 | setCaption( tr("OpiePlayer") ); |
75 | Config cfg("OpiePlayer"); | 80 | Config cfg("OpiePlayer"); |
76 | 81 | ||
77 | cfg.setGroup("Options"); | 82 | cfg.setGroup("Options"); |
78 | skin = cfg.readEntry("Skin","default"); | 83 | skin = cfg.readEntry("Skin","default"); |
79 | 84 | ||
80 | QString skinPath; | 85 | QString skinPath; |
81 | skinPath = "opieplayer2/skins/" + skin; | 86 | skinPath = "opieplayer2/skins/" + skin; |
82 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) | 87 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) |
83 | skinPath = "opieplayer2/skins/default"; | 88 | skinPath = "opieplayer2/skins/default"; |
84 | 89 | ||
85 | // qDebug("skin path " + skinPath); | 90 | // odebug << "skin path " + skinPath << oendl; |
86 | 91 | ||
87 | // QString skinPath = "opieplayer2/skins/" + skin; | 92 | // QString skinPath = "opieplayer2/skins/" + skin; |
88 | 93 | ||
89 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 94 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
90 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 95 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
91 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 96 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
92 | 97 | ||
93 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 98 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
94 | imgButtonMask->fill( 0 ); | 99 | imgButtonMask->fill( 0 ); |
95 | 100 | ||
96 | for ( int i = 0; i < 7; i++ ) { | 101 | for ( int i = 0; i < 7; i++ ) { |
97 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + | 102 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + |
98 | "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | 103 | "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); |
99 | // qDebug("loading "+filename); | 104 | // odebug << "loading "+filename << oendl; |
100 | masks[i] = new QBitmap( filename ); | 105 | masks[i] = new QBitmap( filename ); |
101 | 106 | ||
102 | if ( !masks[i]->isNull() ) { | 107 | if ( !masks[i]->isNull() ) { |
103 | QImage imgMask = masks[i]->convertToImage(); | 108 | QImage imgMask = masks[i]->convertToImage(); |
104 | uchar **dest = imgButtonMask->jumpTable(); | 109 | uchar **dest = imgButtonMask->jumpTable(); |
105 | for ( int y = 0; y < imgUp->height(); y++ ) { | 110 | for ( int y = 0; y < imgUp->height(); y++ ) { |
106 | uchar *line = dest[y]; | 111 | uchar *line = dest[y]; |
107 | for ( int x = 0; x < imgUp->width(); x++ ) { | 112 | for ( int x = 0; x < imgUp->width(); x++ ) { |
108 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 113 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
109 | line[x] = i + 1; | 114 | line[x] = i + 1; |
110 | } | 115 | } |
111 | } | 116 | } |
112 | } | 117 | } |
113 | } | 118 | } |
114 | // qDebug("finished loading first pics"); | 119 | // odebug << "finished loading first pics" << oendl; |
115 | for ( int i = 0; i < 7; i++ ) { | 120 | for ( int i = 0; i < 7; i++ ) { |
116 | buttonPixUp[i] = NULL; | 121 | buttonPixUp[i] = NULL; |
117 | buttonPixDown[i] = NULL; | 122 | buttonPixDown[i] = NULL; |
118 | } | 123 | } |
119 | 124 | ||
120 | 125 | ||
121 | QWidget *d = QApplication::desktop(); | 126 | QWidget *d = QApplication::desktop(); |
122 | int width = d->width(); | 127 | int width = d->width(); |
123 | int height = d->height(); | 128 | int height = d->height(); |
124 | 129 | ||
125 | if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { | 130 | if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { |
126 | // qDebug("<<<<<<<< scale image >>>>>>>>>>>>"); | 131 | // odebug << "<<<<<<<< scale image >>>>>>>>>>>>" << oendl; |
127 | QImage img; | 132 | QImage img; |
128 | img = pixBg->convertToImage(); | 133 | img = pixBg->convertToImage(); |
129 | pixBg->convertFromImage( img.smoothScale( width, height)); | 134 | pixBg->convertFromImage( img.smoothScale( width, height)); |
130 | } | 135 | } |
131 | setBackgroundPixmap( *pixBg ); | 136 | setBackgroundPixmap( *pixBg ); |
132 | 137 | ||
133 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); | 138 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); |
134 | 139 | ||
135 | slider = new QSlider( Qt::Horizontal, this ); | 140 | slider = new QSlider( Qt::Horizontal, this ); |
136 | slider->setMinValue( 0 ); | 141 | slider->setMinValue( 0 ); |
137 | slider->setMaxValue( 1 ); | 142 | slider->setMaxValue( 1 ); |
138 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 143 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
139 | slider->setFocusPolicy( QWidget::NoFocus ); | 144 | slider->setFocusPolicy( QWidget::NoFocus ); |
140 | // slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 145 | // slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
141 | 146 | ||
142 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 147 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
143 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 148 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
144 | 149 | ||
145 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 150 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
146 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 151 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
@@ -340,46 +345,46 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
340 | } | 345 | } |
341 | } else if ( !isOnButton && videoButtons[i].isHeld ) { | 346 | } else if ( !isOnButton && videoButtons[i].isHeld ) { |
342 | videoButtons[i].isHeld = FALSE; | 347 | videoButtons[i].isHeld = FALSE; |
343 | toggleButton(i); | 348 | toggleButton(i); |
344 | } | 349 | } |
345 | } else { | 350 | } else { |
346 | 351 | ||
347 | if ( videoButtons[i].isHeld ) { | 352 | if ( videoButtons[i].isHeld ) { |
348 | videoButtons[i].isHeld = FALSE; | 353 | videoButtons[i].isHeld = FALSE; |
349 | if ( !videoButtons[i].isToggle ) { | 354 | if ( !videoButtons[i].isToggle ) { |
350 | setToggleButton( i, FALSE ); | 355 | setToggleButton( i, FALSE ); |
351 | } | 356 | } |
352 | 357 | ||
353 | switch(i) { | 358 | switch(i) { |
354 | 359 | ||
355 | case VideoPlay: { | 360 | case VideoPlay: { |
356 | // qDebug("play"); | 361 | // odebug << "play" << oendl; |
357 | if( !mediaPlayerState->playing()) { | 362 | if( !mediaPlayerState->playing()) { |
358 | mediaPlayerState->setPlaying( true); | 363 | mediaPlayerState->setPlaying( true); |
359 | setToggleButton( i-1, false ); | 364 | setToggleButton( i-1, false ); |
360 | setToggleButton( i, false ); | 365 | setToggleButton( i, false ); |
361 | return; | 366 | return; |
362 | } | 367 | } |
363 | if( mediaPlayerState->isPaused ) { | 368 | if( mediaPlayerState->isPaused ) { |
364 | // qDebug("isPaused"); | 369 | // odebug << "isPaused" << oendl; |
365 | setToggleButton( i, FALSE ); | 370 | setToggleButton( i, FALSE ); |
366 | mediaPlayerState->setPaused( FALSE ); | 371 | mediaPlayerState->setPaused( FALSE ); |
367 | return; | 372 | return; |
368 | } else if( !mediaPlayerState->isPaused ) { | 373 | } else if( !mediaPlayerState->isPaused ) { |
369 | // qDebug("is not paused"); | 374 | // odebug << "is not paused" << oendl; |
370 | setToggleButton( i, TRUE ); | 375 | setToggleButton( i, TRUE ); |
371 | mediaPlayerState->setPaused( TRUE ); | 376 | mediaPlayerState->setPaused( TRUE ); |
372 | return; | 377 | return; |
373 | } else { | 378 | } else { |
374 | return; | 379 | return; |
375 | } | 380 | } |
376 | } | 381 | } |
377 | 382 | ||
378 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return; | 383 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return; |
379 | case VideoNext: mediaPlayerState->setNext(); return; | 384 | case VideoNext: mediaPlayerState->setNext(); return; |
380 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 385 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
381 | case VideoVolUp: emit moreReleased(); return; | 386 | case VideoVolUp: emit moreReleased(); return; |
382 | case VideoVolDown: emit lessReleased(); return; | 387 | case VideoVolDown: emit lessReleased(); return; |
383 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 388 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
384 | } | 389 | } |
385 | } | 390 | } |
@@ -445,33 +450,33 @@ void VideoWidget::paintEvent( QPaintEvent * pe) { | |||
445 | QPainter p( this ); | 450 | QPainter p( this ); |
446 | for ( int i = 0; i < numVButtons; i++ ) | 451 | for ( int i = 0; i < numVButtons; i++ ) |
447 | paintButton( &p, i ); | 452 | paintButton( &p, i ); |
448 | } | 453 | } |
449 | slider->repaint( TRUE ); | 454 | slider->repaint( TRUE ); |
450 | } | 455 | } |
451 | } | 456 | } |
452 | 457 | ||
453 | 458 | ||
454 | void VideoWidget::closeEvent( QCloseEvent* ) { | 459 | void VideoWidget::closeEvent( QCloseEvent* ) { |
455 | mediaPlayerState->setList(); | 460 | mediaPlayerState->setList(); |
456 | } | 461 | } |
457 | 462 | ||
458 | 463 | ||
459 | bool VideoWidget::playVideo() { | 464 | bool VideoWidget::playVideo() { |
460 | bool result = FALSE; | 465 | bool result = FALSE; |
461 | // qDebug("<<<<<<<<<<<<<<<< play video"); | 466 | // odebug << "<<<<<<<<<<<<<<<< play video" << oendl; |
462 | int stream = 0; | 467 | int stream = 0; |
463 | 468 | ||
464 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); | 469 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); |
465 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); | 470 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); |
466 | int dd = QPixmap::defaultDepth(); | 471 | int dd = QPixmap::defaultDepth(); |
467 | int w = height(); | 472 | int w = height(); |
468 | int h = width(); | 473 | int h = width(); |
469 | 474 | ||
470 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; | 475 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; |
471 | 476 | ||
472 | if ( mediaPlayerState->fullscreen() ) | 477 | if ( mediaPlayerState->fullscreen() ) |
473 | { | 478 | { |
474 | #ifdef USE_DIRECT_PAINTER | 479 | #ifdef USE_DIRECT_PAINTER |
475 | QDirectPainter p(this); | 480 | QDirectPainter p(this); |
476 | 481 | ||
477 | if ( ( qt_screen->transformOrientation() == 3 ) && | 482 | if ( ( qt_screen->transformOrientation() == 3 ) && |
diff --git a/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp b/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp index 53c4b2b..0002213 100644 --- a/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp +++ b/core/multimedia/opieplayer/vorbis/libtremorplugin.cpp | |||
@@ -6,76 +6,81 @@ | |||
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or | 8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. | 9 | * (at your option) any later version. |
10 | * | 10 | * |
11 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
16 | * You should have received a copy of the GNU General Public License | 16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software | 17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | ****************************************************************************/ | 19 | ****************************************************************************/ |
20 | // fixed and adapted for opieplayer 2003 ljp <llornkcor@handhelds.org> | 20 | // fixed and adapted for opieplayer 2003 ljp <llornkcor@handhelds.org> |
21 | 21 | ||
22 | #include "libtremorplugin.h" | ||
23 | |||
24 | /* OPIE */ | ||
25 | #include <opie2/odebug.h> | ||
26 | |||
27 | /* QT */ | ||
28 | #include <qmap.h> | ||
29 | |||
30 | /* STD */ | ||
22 | #include <stdio.h> | 31 | #include <stdio.h> |
23 | #include <stdarg.h> | 32 | #include <stdarg.h> |
24 | #include <stdlib.h> | 33 | #include <stdlib.h> |
25 | #include <sys/types.h> | 34 | #include <sys/types.h> |
26 | #include <sys/stat.h> | 35 | #include <sys/stat.h> |
27 | #include <fcntl.h> | 36 | #include <fcntl.h> |
28 | #include <unistd.h> | 37 | #include <unistd.h> |
29 | #include <string.h> | 38 | #include <string.h> |
30 | #include <errno.h> | 39 | #include <errno.h> |
31 | #include <time.h> | 40 | #include <time.h> |
32 | #include <locale.h> | 41 | #include <locale.h> |
33 | #include <math.h> | 42 | #include <math.h> |
34 | #include <assert.h> | 43 | #include <assert.h> |
35 | 44 | ||
36 | #include <qmap.h> | ||
37 | |||
38 | #include "libtremorplugin.h" | ||
39 | |||
40 | 45 | ||
41 | extern "C" { | 46 | extern "C" { |
42 | #include "tremor/ivorbisfile.h" | 47 | #include "tremor/ivorbisfile.h" |
43 | } | 48 | } |
44 | 49 | ||
45 | 50 | ||
46 | #define MPEG_BUFFER_SIZE 65536 | 51 | #define MPEG_BUFFER_SIZE 65536 |
47 | //#define debugMsg(a) qDebug(a) | 52 | //#define debugMsg(a) qDebug(a) |
48 | #define debugMsg(a) | 53 | #define debugMsg(a) |
49 | 54 | ||
50 | 55 | ||
51 | class LibTremorPluginData { | 56 | class LibTremorPluginData { |
52 | public: | 57 | public: |
53 | char* filename; | 58 | char* filename; |
54 | FILE* f; | 59 | FILE* f; |
55 | OggVorbis_File vf; | 60 | OggVorbis_File vf; |
56 | vorbis_info* vi; | 61 | vorbis_info* vi; |
57 | vorbis_comment* vc; | 62 | vorbis_comment* vc; |
58 | bool bos; | 63 | bool bos; |
59 | int csection; | 64 | int csection; |
60 | QString finfo; | 65 | QString finfo; |
61 | }; | 66 | }; |
62 | 67 | ||
63 | 68 | ||
64 | LibTremorPlugin::LibTremorPlugin() { | 69 | LibTremorPlugin::LibTremorPlugin() { |
65 | qDebug("<<<<<<<<<<<<<TREMOR!!!!!>>>>>>>>>>>>>>>>>>"); | 70 | odebug << "<<<<<<<<<<<<<TREMOR!!!!!>>>>>>>>>>>>>>>>>>" << oendl; |
66 | d = new LibTremorPluginData; | 71 | d = new LibTremorPluginData; |
67 | d->f = 0; | 72 | d->f = 0; |
68 | d->vi = 0; | 73 | d->vi = 0; |
69 | d->vc = 0; | 74 | d->vc = 0; |
70 | d->bos = 0; | 75 | d->bos = 0; |
71 | d->csection = 0; | 76 | d->csection = 0; |
72 | d->finfo = ""; | 77 | d->finfo = ""; |
73 | } | 78 | } |
74 | 79 | ||
75 | 80 | ||
76 | LibTremorPlugin::~LibTremorPlugin() { | 81 | LibTremorPlugin::~LibTremorPlugin() { |
77 | close(); | 82 | close(); |
78 | delete d; | 83 | delete d; |
79 | } | 84 | } |
80 | 85 | ||
81 | 86 | ||
@@ -92,38 +97,38 @@ bool LibTremorPlugin::isFileSupported( const QString& path ) { | |||
92 | // Test file extension | 97 | // Test file extension |
93 | if ( ext ) { | 98 | if ( ext ) { |
94 | if ( strncasecmp(ext, ".ogg", 4) == 0 ) | 99 | if ( strncasecmp(ext, ".ogg", 4) == 0 ) |
95 | return TRUE; | 100 | return TRUE; |
96 | } | 101 | } |
97 | 102 | ||
98 | return FALSE; | 103 | return FALSE; |
99 | } | 104 | } |
100 | 105 | ||
101 | 106 | ||
102 | bool LibTremorPlugin::open( const QString& path ) { | 107 | bool LibTremorPlugin::open( const QString& path ) { |
103 | debugMsg( "LibTremorPlugin::open" ); | 108 | debugMsg( "LibTremorPlugin::open" ); |
104 | 109 | ||
105 | d->filename = (char*) path.latin1(); | 110 | d->filename = (char*) path.latin1(); |
106 | d->f = fopen( d->filename, "r" ); | 111 | d->f = fopen( d->filename, "r" ); |
107 | if (d->f == 0) { | 112 | if (d->f == 0) { |
108 | qDebug("error opening %s", d->filename ); | 113 | odebug << "error opening " << d->filename << "" << oendl; |
109 | return FALSE; | 114 | return FALSE; |
110 | } | 115 | } |
111 | 116 | ||
112 | if (ov_open(d->f, &d->vf, NULL, 0) < 0) { | 117 | if (ov_open(d->f, &d->vf, NULL, 0) < 0) { |
113 | qDebug("error opening %s", d->filename); | 118 | odebug << "error opening " << d->filename << "" << oendl; |
114 | return FALSE; | 119 | return FALSE; |
115 | } | 120 | } |
116 | 121 | ||
117 | d->vc = ov_comment(&d->vf, -1); | 122 | d->vc = ov_comment(&d->vf, -1); |
118 | d->vi = ov_info(&d->vf, -1); | 123 | d->vi = ov_info(&d->vf, -1); |
119 | d->bos = false; | 124 | d->bos = false; |
120 | 125 | ||
121 | QString comments[] = { "title", "artist", "album", "year", "tracknumber", "" }; | 126 | QString comments[] = { "title", "artist", "album", "year", "tracknumber", "" }; |
122 | QString cdescr[] = { "Title", "Artist", "Album", "Year", "Track", "" }; | 127 | QString cdescr[] = { "Title", "Artist", "Album", "Year", "Track", "" }; |
123 | 128 | ||
124 | 129 | ||
125 | QMap<QString, QString> cmap; | 130 | QMap<QString, QString> cmap; |
126 | char** cptr = d->vc->user_comments; | 131 | char** cptr = d->vc->user_comments; |
127 | 132 | ||
128 | while (*cptr != 0) { | 133 | while (*cptr != 0) { |
129 | QString s(*cptr); | 134 | QString s(*cptr); |
@@ -140,125 +145,125 @@ bool LibTremorPlugin::open( const QString& path ) { | |||
140 | cptr++; | 145 | cptr++; |
141 | } | 146 | } |
142 | 147 | ||
143 | d->finfo = ""; | 148 | d->finfo = ""; |
144 | for(int i = 0; !comments[i].isEmpty(); i++) { | 149 | for(int i = 0; !comments[i].isEmpty(); i++) { |
145 | QString v = cmap[comments[i].lower()]; | 150 | QString v = cmap[comments[i].lower()]; |
146 | 151 | ||
147 | if (!v.isEmpty()) { | 152 | if (!v.isEmpty()) { |
148 | if (!d->finfo.isEmpty()) { | 153 | if (!d->finfo.isEmpty()) { |
149 | d->finfo += ", "; | 154 | d->finfo += ", "; |
150 | } | 155 | } |
151 | 156 | ||
152 | d->finfo += cdescr[i] + ": " + v; | 157 | d->finfo += cdescr[i] + ": " + v; |
153 | } | 158 | } |
154 | } | 159 | } |
155 | 160 | ||
156 | qDebug("finfo: " + d->finfo); | 161 | odebug << "finfo: " + d->finfo << oendl; |
157 | 162 | ||
158 | return TRUE; | 163 | return TRUE; |
159 | } | 164 | } |
160 | 165 | ||
161 | 166 | ||
162 | bool LibTremorPlugin::close() { | 167 | bool LibTremorPlugin::close() { |
163 | debugMsg( "LibTremorPlugin::close" ); | 168 | debugMsg( "LibTremorPlugin::close" ); |
164 | 169 | ||
165 | int result = TRUE; | 170 | int result = TRUE; |
166 | 171 | ||
167 | if (fclose(d->f) == -1) { | 172 | if (fclose(d->f) == -1) { |
168 | qDebug("error closing file %s", d->filename); | 173 | odebug << "error closing file " << d->filename << "" << oendl; |
169 | result = FALSE; | 174 | result = FALSE; |
170 | } | 175 | } |
171 | 176 | ||
172 | d->f = 0; | 177 | d->f = 0; |
173 | d->finfo = ""; | 178 | d->finfo = ""; |
174 | 179 | ||
175 | return result; | 180 | return result; |
176 | } | 181 | } |
177 | 182 | ||
178 | 183 | ||
179 | bool LibTremorPlugin::isOpen() { | 184 | bool LibTremorPlugin::isOpen() { |
180 | debugMsg( "LibTremorPlugin::isOpen" ); | 185 | debugMsg( "LibTremorPlugin::isOpen" ); |
181 | return ( d->f != 0 ); | 186 | return ( d->f != 0 ); |
182 | } | 187 | } |
183 | 188 | ||
184 | 189 | ||
185 | const QString &LibTremorPlugin::fileInfo() { | 190 | const QString &LibTremorPlugin::fileInfo() { |
186 | return d->finfo; | 191 | return d->finfo; |
187 | } | 192 | } |
188 | 193 | ||
189 | int LibTremorPlugin::audioStreams() { | 194 | int LibTremorPlugin::audioStreams() { |
190 | debugMsg( "LibTremorPlugin::audioStreams" ); | 195 | debugMsg( "LibTremorPlugin::audioStreams" ); |
191 | return 1; | 196 | return 1; |
192 | } | 197 | } |
193 | 198 | ||
194 | 199 | ||
195 | int LibTremorPlugin::audioChannels( int ) { | 200 | int LibTremorPlugin::audioChannels( int ) { |
196 | qDebug( "LibTremorPlugin::audioChannels: %i", d->vi->channels ); | 201 | odebug << "LibTremorPlugin::audioChannels: " << d->vi->channels << "" << oendl; |
197 | return d->vi->channels; | 202 | return d->vi->channels; |
198 | } | 203 | } |
199 | 204 | ||
200 | 205 | ||
201 | int LibTremorPlugin::audioFrequency( int ) { | 206 | int LibTremorPlugin::audioFrequency( int ) { |
202 | qDebug( "LibTremorPlugin::audioFrequency: %ld", d->vi->rate ); | 207 | odebug << "LibTremorPlugin::audioFrequency: " << d->vi->rate << "" << oendl; |
203 | return d->vi->rate; | 208 | return d->vi->rate; |
204 | } | 209 | } |
205 | 210 | ||
206 | 211 | ||
207 | int LibTremorPlugin::audioSamples( int ) { | 212 | int LibTremorPlugin::audioSamples( int ) { |
208 | debugMsg( "LibTremorPlugin::audioSamples" ); | 213 | debugMsg( "LibTremorPlugin::audioSamples" ); |
209 | return (int) ov_pcm_total(&d->vf,-1); | 214 | return (int) ov_pcm_total(&d->vf,-1); |
210 | } | 215 | } |
211 | 216 | ||
212 | 217 | ||
213 | bool LibTremorPlugin::audioSetSample( long, int ) { | 218 | bool LibTremorPlugin::audioSetSample( long, int ) { |
214 | debugMsg( "LibTremorPlugin::audioSetSample" ); | 219 | debugMsg( "LibTremorPlugin::audioSetSample" ); |
215 | return FALSE; | 220 | return FALSE; |
216 | } | 221 | } |
217 | 222 | ||
218 | 223 | ||
219 | long LibTremorPlugin::audioGetSample( int ) { | 224 | long LibTremorPlugin::audioGetSample( int ) { |
220 | debugMsg( "LibTremorPlugin::audioGetSample" ); | 225 | debugMsg( "LibTremorPlugin::audioGetSample" ); |
221 | return 0; | 226 | return 0; |
222 | } | 227 | } |
223 | 228 | ||
224 | 229 | ||
225 | bool LibTremorPlugin::audioReadSamples( short *output, int, long samples, long& samplesMade, int ) { | 230 | bool LibTremorPlugin::audioReadSamples( short *output, int, long samples, long& samplesMade, int ) { |
226 | // qDebug( "<<<<<<<<<<<<LibTremorPlugin::audioReadStereoSamples %d", samples ); | 231 | // odebug << "<<<<<<<<<<<<LibTremorPlugin::audioReadStereoSamples " << samples << "" << oendl; |
227 | 232 | ||
228 | int old_section = d->csection; | 233 | int old_section = d->csection; |
229 | 234 | ||
230 | char* buf = (char*) output; | 235 | char* buf = (char*) output; |
231 | int length = samples * 4; | 236 | int length = samples * 4; |
232 | 237 | ||
233 | if ( samples == 0 ) | 238 | if ( samples == 0 ) |
234 | return false; | 239 | return false; |
235 | 240 | ||
236 | while (length > 0) { | 241 | while (length > 0) { |
237 | if (d->bos) { | 242 | if (d->bos) { |
238 | d->vi = ov_info(&d->vf, -1); | 243 | d->vi = ov_info(&d->vf, -1); |
239 | d->vc = ov_comment(&d->vf, -1); | 244 | d->vc = ov_comment(&d->vf, -1); |
240 | } | 245 | } |
241 | 246 | ||
242 | int n = 4096; | 247 | int n = 4096; |
243 | if (length < n) { | 248 | if (length < n) { |
244 | n = length; | 249 | n = length; |
245 | } | 250 | } |
246 | 251 | ||
247 | long ret = ov_read(&d->vf, buf, n, &d->csection); | 252 | long ret = ov_read(&d->vf, buf, n, &d->csection); |
248 | // qDebug("%d", ret); | 253 | // odebug << "" << ret << "" << oendl; |
249 | if (ret == 0) { | 254 | if (ret == 0) { |
250 | break; | 255 | break; |
251 | } else if (ret < 0) { | 256 | } else if (ret < 0) { |
252 | return true; | 257 | return true; |
253 | } | 258 | } |
254 | 259 | ||
255 | if (old_section != d->csection) { | 260 | if (old_section != d->csection) { |
256 | d->bos = true; | 261 | d->bos = true; |
257 | } | 262 | } |
258 | 263 | ||
259 | buf += ret; | 264 | buf += ret; |
260 | length -= ret; | 265 | length -= ret; |
261 | 266 | ||
262 | } | 267 | } |
263 | 268 | ||
264 | samplesMade = samples; | 269 | samplesMade = samples; |
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp index 4e82900..7f3a0a8 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp | |||
@@ -6,39 +6,47 @@ | |||
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 | 20 | // L.J.Potter added changes Fri 02-15-2002 |
21 | 21 | ||
22 | |||
23 | #include "wavplugin.h" | ||
24 | |||
25 | /* OPIE */ | ||
26 | #include <opie2/odebug.h> | ||
27 | |||
28 | /* QT */ | ||
29 | #include <qfile.h> | ||
30 | |||
31 | /* STD */ | ||
22 | #include <stdio.h> | 32 | #include <stdio.h> |
23 | #include <stdarg.h> | 33 | #include <stdarg.h> |
24 | #include <stdlib.h> | 34 | #include <stdlib.h> |
25 | #include <errno.h> | 35 | #include <errno.h> |
26 | #include <unistd.h> | 36 | #include <unistd.h> |
27 | #include <qfile.h> | ||
28 | #include "wavplugin.h" | ||
29 | 37 | ||
30 | //#define debugMsg(a) qDebug(a) | 38 | //#define debugMsg(a) qDebug(a) |
31 | #define debugMsg(a) | 39 | #define debugMsg(a) |
32 | 40 | ||
33 | 41 | ||
34 | struct RiffChunk { | 42 | struct RiffChunk { |
35 | char id[4]; | 43 | char id[4]; |
36 | Q_UINT32 size; | 44 | Q_UINT32 size; |
37 | char data[4]; | 45 | char data[4]; |
38 | }; | 46 | }; |
39 | 47 | ||
40 | 48 | ||
41 | struct ChunkData { | 49 | struct ChunkData { |
42 | Q_INT16 formatTag; | 50 | Q_INT16 formatTag; |
43 | Q_INT16 channels; | 51 | Q_INT16 channels; |
44 | Q_INT32 samplesPerSec; | 52 | Q_INT32 samplesPerSec; |
@@ -63,40 +71,40 @@ public: | |||
63 | int samples_due; | 71 | int samples_due; |
64 | int samples; | 72 | int samples; |
65 | 73 | ||
66 | WavPluginData() { | 74 | WavPluginData() { |
67 | max = out = sound_buffer_size; | 75 | max = out = sound_buffer_size; |
68 | wavedata_remaining = 0; | 76 | wavedata_remaining = 0; |
69 | samples_due = 0; | 77 | samples_due = 0; |
70 | samples = -1; | 78 | samples = -1; |
71 | } | 79 | } |
72 | 80 | ||
73 | // expands out samples to the frequency of 44kHz //not any more | 81 | // expands out samples to the frequency of 44kHz //not any more |
74 | bool add( short *output, long count, long& done, bool stereo ) | 82 | bool add( short *output, long count, long& done, bool stereo ) |
75 | { | 83 | { |
76 | done = 0; | 84 | done = 0; |
77 | 85 | ||
78 | if ( input == 0 ) { | 86 | if ( input == 0 ) { |
79 | qDebug("no input"); | 87 | odebug << "no input" << oendl; |
80 | return FALSE; | 88 | return FALSE; |
81 | } | 89 | } |
82 | 90 | ||
83 | while ( count ) { | 91 | while ( count ) { |
84 | int l,r; | 92 | int l,r; |
85 | if ( getSample(l, r) == FALSE ) { | 93 | if ( getSample(l, r) == FALSE ) { |
86 | qDebug("didn't get sample"); | 94 | odebug << "didn't get sample" << oendl; |
87 | return FALSE; | 95 | return FALSE; |
88 | } | 96 | } |
89 | samples_due += chunkdata.samplesPerSec; | 97 | samples_due += chunkdata.samplesPerSec; |
90 | printf("samples due %d\r", samples_due); | 98 | printf("samples due %d\r", samples_due); |
91 | fflush(stdout); | 99 | fflush(stdout); |
92 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { | 100 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { |
93 | *output++ = l; | 101 | *output++ = l; |
94 | if ( stereo ) | 102 | if ( stereo ) |
95 | *output++ = r; | 103 | *output++ = r; |
96 | samples_due -= chunkdata.samplesPerSec; | 104 | samples_due -= chunkdata.samplesPerSec; |
97 | count--; | 105 | count--; |
98 | done++; | 106 | done++; |
99 | } | 107 | } |
100 | } | 108 | } |
101 | return TRUE; | 109 | return TRUE; |
102 | } | 110 | } |
@@ -122,43 +130,43 @@ public: | |||
122 | char d[4]; | 130 | char d[4]; |
123 | if ( input->readBlock(d,4) != 4 ) { | 131 | if ( input->readBlock(d,4) != 4 ) { |
124 | return FALSE; | 132 | return FALSE; |
125 | } | 133 | } |
126 | if ( qstrncmp(d,"WAVE",4) != 0 ) { | 134 | if ( qstrncmp(d,"WAVE",4) != 0 ) { |
127 | // skip | 135 | // skip |
128 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) { | 136 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) { |
129 | return FALSE; | 137 | return FALSE; |
130 | } | 138 | } |
131 | } | 139 | } |
132 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { | 140 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { |
133 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { | 141 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { |
134 | return FALSE; | 142 | return FALSE; |
135 | } | 143 | } |
136 | #define WAVE_FORMAT_PCM 1 | 144 | #define WAVE_FORMAT_PCM 1 |
137 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { | 145 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { |
138 | qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); | 146 | odebug << "WAV file: UNSUPPORTED FORMAT " << chunkdata.formatTag << "" << oendl; |
139 | return FALSE; | 147 | return FALSE; |
140 | } | 148 | } |
141 | } else { | 149 | } else { |
142 | // ignored chunk | 150 | // ignored chunk |
143 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { | 151 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { |
144 | return FALSE; | 152 | return FALSE; |
145 | } | 153 | } |
146 | } | 154 | } |
147 | } // while | 155 | } // while |
148 | qDebug("bits %d", chunkdata.wBitsPerSample); | 156 | odebug << "bits " << chunkdata.wBitsPerSample << "" << oendl; |
149 | return TRUE; | 157 | return TRUE; |
150 | } | 158 | } |
151 | 159 | ||
152 | 160 | ||
153 | // gets a sample from the file | 161 | // gets a sample from the file |
154 | bool getSample(int& l, int& r) | 162 | bool getSample(int& l, int& r) |
155 | { | 163 | { |
156 | l = r = 0; | 164 | l = r = 0; |
157 | 165 | ||
158 | if ( input == 0 ) | 166 | if ( input == 0 ) |
159 | return FALSE; | 167 | return FALSE; |
160 | 168 | ||
161 | if ( (wavedata_remaining < 0) || !max ) | 169 | if ( (wavedata_remaining < 0) || !max ) |
162 | return FALSE; | 170 | return FALSE; |
163 | 171 | ||
164 | if ( out >= max ) { | 172 | if ( out >= max ) { |
@@ -194,149 +202,149 @@ public: | |||
194 | }; | 202 | }; |
195 | 203 | ||
196 | 204 | ||
197 | WavPlugin::WavPlugin() { | 205 | WavPlugin::WavPlugin() { |
198 | d = new WavPluginData; | 206 | d = new WavPluginData; |
199 | d->input = 0; | 207 | d->input = 0; |
200 | } | 208 | } |
201 | 209 | ||
202 | 210 | ||
203 | WavPlugin::~WavPlugin() { | 211 | WavPlugin::~WavPlugin() { |
204 | close(); | 212 | close(); |
205 | delete d; | 213 | delete d; |
206 | } | 214 | } |
207 | 215 | ||
208 | 216 | ||
209 | bool WavPlugin::isFileSupported( const QString& path ) { | 217 | bool WavPlugin::isFileSupported( const QString& path ) { |
210 | // qDebug( "WavPlugin::isFileSupported" ); | 218 | // odebug << "WavPlugin::isFileSupported" << oendl; |
211 | 219 | ||
212 | char *ext = strrchr( path.latin1(), '.' ); | 220 | char *ext = strrchr( path.latin1(), '.' ); |
213 | 221 | ||
214 | // Test file extension | 222 | // Test file extension |
215 | if ( ext ) { | 223 | if ( ext ) { |
216 | if ( strncasecmp(ext, ".raw", 4) == 0 ) | 224 | if ( strncasecmp(ext, ".raw", 4) == 0 ) |
217 | return TRUE; | 225 | return TRUE; |
218 | if ( strncasecmp(ext, ".wav", 4) == 0 ) | 226 | if ( strncasecmp(ext, ".wav", 4) == 0 ) |
219 | return TRUE; | 227 | return TRUE; |
220 | if ( strncasecmp(ext, ".wave", 4) == 0 ) | 228 | if ( strncasecmp(ext, ".wave", 4) == 0 ) |
221 | return TRUE; | 229 | return TRUE; |
222 | } | 230 | } |
223 | 231 | ||
224 | return FALSE; | 232 | return FALSE; |
225 | } | 233 | } |
226 | 234 | ||
227 | 235 | ||
228 | bool WavPlugin::open( const QString& path ) { | 236 | bool WavPlugin::open( const QString& path ) { |
229 | // qDebug( "WavPlugin::open" ); | 237 | // odebug << "WavPlugin::open" << oendl; |
230 | 238 | ||
231 | d->max = d->out = sound_buffer_size; | 239 | d->max = d->out = sound_buffer_size; |
232 | d->wavedata_remaining = 0; | 240 | d->wavedata_remaining = 0; |
233 | d->samples_due = 0; | 241 | d->samples_due = 0; |
234 | 242 | ||
235 | d->input = new QFile( path ); | 243 | d->input = new QFile( path ); |
236 | if ( d->input->open(IO_ReadOnly) == FALSE ) { | 244 | if ( d->input->open(IO_ReadOnly) == FALSE ) { |
237 | qDebug("couldn't open file"); | 245 | odebug << "couldn't open file" << oendl; |
238 | delete d->input; | 246 | delete d->input; |
239 | d->input = 0; | 247 | d->input = 0; |
240 | return FALSE; | 248 | return FALSE; |
241 | } | 249 | } |
242 | 250 | ||
243 | d->initialise(); | 251 | d->initialise(); |
244 | qApp->processEvents(); | 252 | qApp->processEvents(); |
245 | 253 | ||
246 | return TRUE; | 254 | return TRUE; |
247 | } | 255 | } |
248 | 256 | ||
249 | 257 | ||
250 | bool WavPlugin::close() { | 258 | bool WavPlugin::close() { |
251 | // qDebug( "WavPlugin::close" ); | 259 | // odebug << "WavPlugin::close" << oendl; |
252 | 260 | ||
253 | d->input->close(); | 261 | d->input->close(); |
254 | delete d->input; | 262 | delete d->input; |
255 | d->input = 0; | 263 | d->input = 0; |
256 | return TRUE; | 264 | return TRUE; |
257 | } | 265 | } |
258 | 266 | ||
259 | 267 | ||
260 | bool WavPlugin::isOpen() { | 268 | bool WavPlugin::isOpen() { |
261 | // qDebug( "WavPlugin::isOpen" ); | 269 | // odebug << "WavPlugin::isOpen" << oendl; |
262 | return ( d->input != 0 ); | 270 | return ( d->input != 0 ); |
263 | } | 271 | } |
264 | 272 | ||
265 | 273 | ||
266 | int WavPlugin::audioStreams() { | 274 | int WavPlugin::audioStreams() { |
267 | // qDebug( "WavPlugin::audioStreams" ); | 275 | // odebug << "WavPlugin::audioStreams" << oendl; |
268 | return 1; | 276 | return 1; |
269 | } | 277 | } |
270 | 278 | ||
271 | 279 | ||
272 | int WavPlugin::audioChannels( int ) { | 280 | int WavPlugin::audioChannels( int ) { |
273 | // qDebug( "WavPlugin::audioChannels" ); | 281 | // odebug << "WavPlugin::audioChannels" << oendl; |
274 | return d->chunkdata.channels;// 2; // ### Always scale audio to stereo samples | 282 | return d->chunkdata.channels;// 2; // ### Always scale audio to stereo samples |
275 | } | 283 | } |
276 | 284 | ||
277 | 285 | ||
278 | int WavPlugin::audioFrequency( int ) { | 286 | int WavPlugin::audioFrequency( int ) { |
279 | // qDebug( "WavPlugin::audioFrequency %d", d->chunkdata.samplesPerSec ); | 287 | // odebug << "WavPlugin::audioFrequency " << d->chunkdata.samplesPerSec << "" << oendl; |
280 | return d->chunkdata.samplesPerSec; //44100; // ### Always scale to frequency of 44100 | 288 | return d->chunkdata.samplesPerSec; //44100; // ### Always scale to frequency of 44100 |
281 | } | 289 | } |
282 | 290 | ||
283 | 291 | ||
284 | int WavPlugin::audioSamples( int ) { | 292 | int WavPlugin::audioSamples( int ) { |
285 | // qDebug( "WavPlugin::audioSamples" ); | 293 | // odebug << "WavPlugin::audioSamples" << oendl; |
286 | return d->samples / d->chunkdata.channels/2; // ### Scaled samples will be made stereo, | 294 | return d->samples / d->chunkdata.channels/2; // ### Scaled samples will be made stereo, |
287 | // Therefore if source is mono we will double the number of samples | 295 | // Therefore if source is mono we will double the number of samples |
288 | } | 296 | } |
289 | 297 | ||
290 | 298 | ||
291 | bool WavPlugin::audioSetSample( long, int ) { | 299 | bool WavPlugin::audioSetSample( long, int ) { |
292 | // qDebug( "WavPlugin::audioSetSample" ); | 300 | // odebug << "WavPlugin::audioSetSample" << oendl; |
293 | return FALSE; | 301 | return FALSE; |
294 | } | 302 | } |
295 | 303 | ||
296 | 304 | ||
297 | long WavPlugin::audioGetSample( int ) { | 305 | long WavPlugin::audioGetSample( int ) { |
298 | // qDebug( "WavPlugin::audioGetSample" ); | 306 | // odebug << "WavPlugin::audioGetSample" << oendl; |
299 | return 0; | 307 | return 0; |
300 | } | 308 | } |
301 | 309 | ||
302 | /* | 310 | /* |
303 | bool WavPlugin::audioReadSamples( short *, int, long, int ) { | 311 | bool WavPlugin::audioReadSamples( short *, int, long, int ) { |
304 | debugMsg( "WavPlugin::audioReadSamples" ); | 312 | debugMsg( "WavPlugin::audioReadSamples" ); |
305 | return FALSE; | 313 | return FALSE; |
306 | } | 314 | } |
307 | 315 | ||
308 | 316 | ||
309 | bool WavPlugin::audioReReadSamples( short *, int, long, int ) { | 317 | bool WavPlugin::audioReReadSamples( short *, int, long, int ) { |
310 | debugMsg( "WavPlugin::audioReReadSamples" ); | 318 | debugMsg( "WavPlugin::audioReReadSamples" ); |
311 | return FALSE; | 319 | return FALSE; |
312 | } | 320 | } |
313 | 321 | ||
314 | 322 | ||
315 | bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) { | 323 | bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) { |
316 | debugMsg( "WavPlugin::audioReadMonoSamples" ); | 324 | debugMsg( "WavPlugin::audioReadMonoSamples" ); |
317 | return !d->add( output, samples, samplesMade, FALSE ); | 325 | return !d->add( output, samples, samplesMade, FALSE ); |
318 | } | 326 | } |
319 | 327 | ||
320 | 328 | ||
321 | bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { | 329 | bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { |
322 | debugMsg( "WavPlugin::audioReadStereoSamples" ); | 330 | debugMsg( "WavPlugin::audioReadStereoSamples" ); |
323 | return !d->add( output, samples, samplesMade, TRUE ); | 331 | return !d->add( output, samples, samplesMade, TRUE ); |
324 | } | 332 | } |
325 | */ | 333 | */ |
326 | 334 | ||
327 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { | 335 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { |
328 | // qDebug( "WavPlugin::audioReadSamples" ); | 336 | // odebug << "WavPlugin::audioReadSamples" << oendl; |
329 | return d->add( output, samples, samplesMade, channels != 1 ); | 337 | return d->add( output, samples, samplesMade, channels != 1 ); |
330 | } | 338 | } |
331 | 339 | ||
332 | double WavPlugin::getTime() { | 340 | double WavPlugin::getTime() { |
333 | // qDebug( "WavPlugin::getTime" ); //this is a stupid hack here!! | 341 | // odebug << "WavPlugin::getTime" << oendl; //this is a stupid hack here!! |
334 | return d->chunkdata.wBitsPerSample; /*0.0*/; | 342 | return d->chunkdata.wBitsPerSample; /*0.0*/; |
335 | } | 343 | } |
336 | 344 | ||
337 | // int WavPlugin::audioBitsPerSample( int ) { | 345 | // int WavPlugin::audioBitsPerSample( int ) { |
338 | // // qDebug( "WavPlugin::audioFormat %d", d->chunkdata.wBitsPerSample ); | 346 | // // odebug << "WavPlugin::audioFormat " << d->chunkdata.wBitsPerSample << "" << oendl; |
339 | // return d->chunkdata.wBitsPerSample; // | 347 | // return d->chunkdata.wBitsPerSample; // |
340 | // } | 348 | // } |
341 | 349 | ||
342 | 350 | ||