summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp76
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp35
-rw-r--r--core/multimedia/opieplayer/audiowidget.h13
-rw-r--r--core/multimedia/opieplayer/mediaplayer.cpp59
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.h2
5 files changed, 92 insertions, 93 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index 020f6be..136e06c 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -37,7 +37,2 @@
37 37
38// #ifdef Q_WS_WIN
39// #include <windows.h>
40// #include <mmsystem.h>
41// #include <mmreg.h>
42// #endif
43#if defined(Q_WS_X11) || defined(Q_WS_QWS) 38#if defined(Q_WS_X11) || defined(Q_WS_QWS)
@@ -52,7 +47,2 @@
52 47
53// #if defined(Q_OS_WIN32)
54// static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000;
55// static const int timerResolutionMilliSeconds = 30;
56// static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond;
57// #else
58# if defined(QT_QWS_IPAQ) 48# if defined(QT_QWS_IPAQ)
@@ -103,19 +93,2 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume
103 unsigned int volume; 93 unsigned int volume;
104// #ifdef Q_OS_WIN32
105// HWAVEOUT handle;
106// WAVEFORMATEX formatData;
107// formatData.cbSize = sizeof(WAVEFORMATEX);
108// formatData.wFormatTag = WAVE_FORMAT_PCM;
109// formatData.nAvgBytesPerSec = 4 * 44000;
110// formatData.nBlockAlign = 4;
111// formatData.nChannels = 2;
112// formatData.nSamplesPerSec = 44000;
113// formatData.wBitsPerSample = 16;
114// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
115// if ( waveOutGetVolume( handle, (LPDWORD)&volume ) )
116// // qDebug( "get volume of audio device failed" );
117// waveOutClose( handle );
118// leftVolume = volume & 0xFFFF;
119// rightVolume = volume >> 16;
120// #else
121 int mixerHandle = open( "/dev/mixer", O_RDWR ); 94 int mixerHandle = open( "/dev/mixer", O_RDWR );
@@ -129,3 +102,2 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume
129 rightVolume = ((volume & 0xFF00) << 8) / 101; 102 rightVolume = ((volume & 0xFF00) << 8) / 101;
130//#endif
131} 103}
@@ -144,18 +116,2 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume,
144 } 116 }
145// #ifdef Q_OS_WIN32
146// HWAVEOUT handle;
147// WAVEFORMATEX formatData;
148// formatData.cbSize = sizeof(WAVEFORMATEX);
149// formatData.wFormatTag = WAVE_FORMAT_PCM;
150// formatData.nAvgBytesPerSec = 4 * 44000;
151// formatData.nBlockAlign = 4;
152// formatData.nChannels = 2;
153// formatData.nSamplesPerSec = 44000;
154// formatData.wBitsPerSample = 16;
155// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
156// unsigned int volume = (rightVolume << 16) | leftVolume;
157// if ( waveOutSetVolume( handle, volume ) )
158// // qDebug( "set volume of audio device failed" );
159// waveOutClose( handle );
160// #else
161 // Volume can be from 0 to 100 which is 101 distinct values 117 // Volume can be from 0 to 100 which is 101 distinct values
@@ -192,3 +148,2 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume,
192 148
193
194AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { 149AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
@@ -268,5 +223,2 @@ AudioDevice::~AudioDevice() {
268 223
269// #ifdef Q_OS_WIN32
270// waveOutClose( (HWAVEOUT)d->handle );
271// #else
272# ifndef KEEP_DEVICE_OPEN 224# ifndef KEEP_DEVICE_OPEN
@@ -276,3 +228,2 @@ AudioDevice::~AudioDevice() {
276 delete d; 228 delete d;
277//#endif
278 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; 229 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
@@ -290,16 +241,2 @@ void AudioDevice::write( char *buffer, unsigned int length )
290{ 241{
291// #ifdef Q_OS_WIN32
292// // returns immediately and (to be implemented) emits completedIO() when finished writing
293// WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) );
294// // maybe the buffer should be copied so that this fool proof, but its a performance hit
295// lpWaveHdr->lpData = buffer;
296// lpWaveHdr->dwBufferLength = length;
297// lpWaveHdr->dwFlags = 0L;
298// lpWaveHdr->dwLoops = 0L;
299// waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) );
300// // waveOutWrite returns immediately. the data is sent in the background.
301// if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) )
302// qDebug( "failed to write block to audio device" );
303// // emit completedIO();
304// #else
305 int t = ::write( d->handle, buffer, length ); 242 int t = ::write( d->handle, buffer, length );
@@ -340,5 +277,2 @@ unsigned int AudioDevice::canWrite() const
340{ 277{
341// #ifdef Q_OS_WIN32
342// return bufferSize(); // Any better?
343// #else
344 audio_buf_info info; 278 audio_buf_info info;
@@ -367,3 +301,2 @@ unsigned int AudioDevice::canWrite() const
367 } 301 }
368//#endif
369} 302}
@@ -372,10 +305,2 @@ unsigned int AudioDevice::canWrite() const
372int AudioDevice::bytesWritten() { 305int AudioDevice::bytesWritten() {
373// #ifdef Q_OS_WIN32
374// MMTIME pmmt = { TIME_BYTES, 0 };
375// if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) {
376// qDebug( "failed to get audio device position" );
377// return -1;
378// }
379// return pmmt.u.cb;
380// #else
381 int buffered = 0; 306 int buffered = 0;
@@ -386,3 +311,2 @@ int AudioDevice::bytesWritten() {
386 return buffered; 311 return buffered;
387//#endif
388} 312}
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index d20d560..ef7c8dc 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -148,3 +148,3 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
148 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 148 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
149 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 149// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
150 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 150 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
@@ -155,3 +155,3 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
155 setLooping( mediaPlayerState->fullscreen() ); 155 setLooping( mediaPlayerState->fullscreen() );
156 setPaused( mediaPlayerState->paused() ); 156// setPaused( mediaPlayerState->paused() );
157 setPlaying( mediaPlayerState->playing() ); 157 setPlaying( mediaPlayerState->playing() );
@@ -365,3 +365,12 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
365 return; 365 return;
366 case AudioVolumeDown: emit lessClicked(); return; 366 case AudioVolumeDown:
367 qDebug("less clicked");
368 emit lessClicked();
369 return;
370 case AudioForward:
371 emit forwardClicked();
372 return;
373 case AudioBack:
374 emit backClicked();
375 return;
367 } 376 }
@@ -377,5 +386,13 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
377 switch (i) { 386 switch (i) {
378 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 387 case AudioPlay:
388 if( mediaPlayerState->isPaused ) {
389 mediaPlayerState->setPaused( FALSE );
390 return;
391 } else if( !mediaPlayerState->isPaused ) {
392 mediaPlayerState->setPaused( TRUE );
393 return;
394 }
395// case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
379 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 396 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
380 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 397// case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
381 case AudioNext: mediaPlayerState->setNext(); return; 398 case AudioNext: mediaPlayerState->setNext(); return;
@@ -465,12 +482,12 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e)
465 case Key_Down: //volume 482 case Key_Down: //volume
466 toggleButton(6); 483// toggleButton(6);
467 emit lessClicked(); 484 emit lessClicked();
468 emit lessReleased(); 485 emit lessReleased();
469 toggleButton(6); 486// toggleButton(6);
470 break; 487 break;
471 case Key_Up: //volume 488 case Key_Up: //volume
472 toggleButton(5); 489// toggleButton(5);
473 emit moreClicked(); 490 emit moreClicked();
474 emit moreReleased(); 491 emit moreReleased();
475 toggleButton(5); 492// toggleButton(5);
476 break; 493 break;
diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h
index c686741..96bc55c 100644
--- a/core/multimedia/opieplayer/audiowidget.h
+++ b/core/multimedia/opieplayer/audiowidget.h
@@ -38,5 +38,4 @@ class QPixmap;
38enum AudioButtons { 38enum AudioButtons {
39 AudioPlay, 39 AudioPlay=0,
40 AudioStop, 40 AudioStop,
41 AudioPause,
42 AudioNext, 41 AudioNext,
@@ -46,3 +45,5 @@ enum AudioButtons {
46 AudioLoop, 45 AudioLoop,
47 AudioPlayList 46 AudioPlayList,
47 AudioForward,
48 AudioBack
48}; 49};
@@ -63,3 +64,3 @@ public slots:
63 void sliderReleased( ); 64 void sliderReleased( );
64 void setPaused( bool b) { setToggleButton( AudioPause, b ); } 65// void setPaused( bool b) { setToggleButton( AudioPause, b ); }
65 void setLooping( bool b) { setToggleButton( AudioLoop, b ); } 66 void setLooping( bool b) { setToggleButton( AudioLoop, b ); }
@@ -76,2 +77,6 @@ signals:
76 void sliderMoved(long); 77 void sliderMoved(long);
78 void forwardClicked();
79 void backClicked();
80 void forwardReleased();
81 void backReleased();
77 82
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp
index b0963cf..4f3823a 100644
--- a/core/multimedia/opieplayer/mediaplayer.cpp
+++ b/core/multimedia/opieplayer/mediaplayer.cpp
@@ -108,3 +108,4 @@ void MediaPlayer::setPlaying( bool play ) {
108 QMessageBox::critical( 0, tr( "File not found"), 108 QMessageBox::critical( 0, tr( "File not found"),
109 tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" ); 109 tr( "The following file was not found: <i>" )
110 + currentFile->file() + "</i>" );
110 mediaPlayerState->setPlaying( FALSE ); 111 mediaPlayerState->setPlaying( FALSE );
@@ -115,3 +116,4 @@ void MediaPlayer::setPlaying( bool play ) {
115 QMessageBox::critical( 0, tr( "No decoder found"), 116 QMessageBox::critical( 0, tr( "No decoder found"),
116 tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" ); 117 tr( "Sorry, no appropriate decoders found for this file: <i>" )
118 + currentFile->file() + "</i>" );
117 mediaPlayerState->setPlaying( FALSE ); 119 mediaPlayerState->setPlaying( FALSE );
@@ -178,4 +180,8 @@ void MediaPlayer::startIncreasingVolume() {
178 AudioDevice::increaseVolume(); 180 AudioDevice::increaseVolume();
181
179} 182}
180 183
184bool drawnOnScreenDisplay = FALSE;
185unsigned int onScreenDisplayVolume = 0;
186const int yoff = 110;
181 187
@@ -183,2 +189,9 @@ void MediaPlayer::stopChangingVolume() {
183 killTimers(); 189 killTimers();
190
191 // Get rid of the on-screen display stuff
192 drawnOnScreenDisplay = FALSE;
193 onScreenDisplayVolume = 0;
194 int w = audioUI->width();
195 int h = audioUI->height();
196 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
184} 197}
@@ -187,6 +200,46 @@ void MediaPlayer::stopChangingVolume() {
187void MediaPlayer::timerEvent( QTimerEvent * ) { 200void MediaPlayer::timerEvent( QTimerEvent * ) {
201// qDebug("timer");
188 if ( volumeDirection == +1 ) 202 if ( volumeDirection == +1 )
189 AudioDevice::increaseVolume(); 203 AudioDevice::increaseVolume();
190 else if ( volumeDirection == -1 ) 204 else if ( volumeDirection == -1 )
191 AudioDevice::decreaseVolume(); 205 AudioDevice::decreaseVolume();
206
207 // Display an on-screen display volume
208 unsigned int l, r, v; bool m;
209 AudioDevice::getVolume( l, r, m );
210 v = ((l + r) * 11) / (2*0xFFFF);
211
212 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
213// qDebug("returning %d, %d, %d, %d", v, l, r, m);
214 return;
215 }
216
217 int w = audioUI->width();
218 int h = audioUI->height();
219
220 if ( drawnOnScreenDisplay ) {
221 if ( onScreenDisplayVolume > v )
222 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40,
223 (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
224 }
225
226 drawnOnScreenDisplay = TRUE;
227 onScreenDisplayVolume = v;
228
229 QPainter p( audioUI );
230 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
231 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
232
233 QFont f;
234 f.setPixelSize( 20 );
235 f.setBold( TRUE );
236 p.setFont( f );
237 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
238
239 for ( unsigned int i = 0; i < 10; i++ ) {
240 if ( v > i )
241 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
242 else
243 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
244 }
192} 245}
diff --git a/core/multimedia/opieplayer/mediaplayerstate.h b/core/multimedia/opieplayer/mediaplayerstate.h
index 26185c5..1c65599 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.h
+++ b/core/multimedia/opieplayer/mediaplayerstate.h
@@ -35,2 +35,3 @@ public:
35 ~MediaPlayerState(); 35 ~MediaPlayerState();
36 bool isPaused;
36 37
@@ -103,3 +104,2 @@ private:
103 bool usePlaylist; 104 bool usePlaylist;
104 bool isPaused;
105 bool isPlaying; 105 bool isPlaying;