-rw-r--r-- | core/multimedia/opieplayer/audiodevice.cpp | 162 | ||||
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol.cpp | 26 | ||||
-rw-r--r-- | core/multimedia/opieplayer/mediaplayer.cpp | 1 | ||||
-rw-r--r-- | core/multimedia/opieplayer/mediaplayerstate.cpp | 0 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 39 |
6 files changed, 120 insertions, 110 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index 3262e38..4c5f12d 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp @@ -32,8 +32,7 @@ -#ifdef Q_WS_WIN -#include <windows.h> -#include <mmsystem.h> -#include <mmreg.h> -#endif - +// #ifdef Q_WS_WIN +// #include <windows.h> +// #include <mmsystem.h> +// #include <mmreg.h> +// #endif #if defined(Q_WS_X11) || defined(Q_WS_QWS) @@ -48,7 +47,7 @@ -#if defined(Q_OS_WIN32) -static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000; -static const int timerResolutionMilliSeconds = 30; -static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond; -#else +// #if defined(Q_OS_WIN32) +// static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000; +// static const int timerResolutionMilliSeconds = 30; +// static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond; +// #else # if defined(QT_QWS_IPAQ) @@ -59,3 +58,3 @@ static const int sound_fragment_shift = 16; static const int sound_fragment_bytes = (1<<sound_fragment_shift); -#endif +//#endif @@ -69,3 +68,3 @@ public: unsigned int bufferSize; -#ifndef Q_OS_WIN32 +//#ifndef Q_OS_WIN32 bool can_GETOSPACE; @@ -73,3 +72,3 @@ public: unsigned int unwritten; -#endif +//#endif @@ -99,19 +98,19 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume unsigned int volume; -#ifdef Q_OS_WIN32 - HWAVEOUT handle; - WAVEFORMATEX formatData; - formatData.cbSize = sizeof(WAVEFORMATEX); - formatData.wFormatTag = WAVE_FORMAT_PCM; - formatData.nAvgBytesPerSec = 4 * 44000; - formatData.nBlockAlign = 4; - formatData.nChannels = 2; - formatData.nSamplesPerSec = 44000; - formatData.wBitsPerSample = 16; - waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); - if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) -// qDebug( "get volume of audio device failed" ); - waveOutClose( handle ); - leftVolume = volume & 0xFFFF; - rightVolume = volume >> 16; -#else +// #ifdef Q_OS_WIN32 +// HWAVEOUT handle; +// WAVEFORMATEX formatData; +// formatData.cbSize = sizeof(WAVEFORMATEX); +// formatData.wFormatTag = WAVE_FORMAT_PCM; +// formatData.nAvgBytesPerSec = 4 * 44000; +// formatData.nBlockAlign = 4; +// formatData.nChannels = 2; +// formatData.nSamplesPerSec = 44000; +// formatData.wBitsPerSample = 16; +// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); +// if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) +// // qDebug( "get volume of audio device failed" ); +// waveOutClose( handle ); +// leftVolume = volume & 0xFFFF; +// rightVolume = volume >> 16; +// #else int mixerHandle = open( "/dev/mixer", O_RDWR ); @@ -125,3 +124,3 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume rightVolume = ((volume & 0xFF00) << 8) / 101; -#endif +//#endif } @@ -140,18 +139,18 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, } -#ifdef Q_OS_WIN32 - HWAVEOUT handle; - WAVEFORMATEX formatData; - formatData.cbSize = sizeof(WAVEFORMATEX); - formatData.wFormatTag = WAVE_FORMAT_PCM; - formatData.nAvgBytesPerSec = 4 * 44000; - formatData.nBlockAlign = 4; - formatData.nChannels = 2; - formatData.nSamplesPerSec = 44000; - formatData.wBitsPerSample = 16; - waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); - unsigned int volume = (rightVolume << 16) | leftVolume; - if ( waveOutSetVolume( handle, volume ) ) -// qDebug( "set volume of audio device failed" ); - waveOutClose( handle ); -#else +// #ifdef Q_OS_WIN32 +// HWAVEOUT handle; +// WAVEFORMATEX formatData; +// formatData.cbSize = sizeof(WAVEFORMATEX); +// formatData.wFormatTag = WAVE_FORMAT_PCM; +// formatData.nAvgBytesPerSec = 4 * 44000; +// formatData.nBlockAlign = 4; +// formatData.nChannels = 2; +// formatData.nSamplesPerSec = 44000; +// formatData.wBitsPerSample = 16; +// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); +// unsigned int volume = (rightVolume << 16) | leftVolume; +// if ( waveOutSetVolume( handle, volume ) ) +// // qDebug( "set volume of audio device failed" ); +// waveOutClose( handle ); +// #else // Volume can be from 0 to 100 which is 101 distinct values @@ -178,3 +177,3 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, -#endif +//#endif // qDebug( "setting volume to: 0x%x", volume ); @@ -258,5 +257,5 @@ AudioDevice::~AudioDevice() { -#ifdef Q_OS_WIN32 - waveOutClose( (HWAVEOUT)d->handle ); -#else +// #ifdef Q_OS_WIN32 +// waveOutClose( (HWAVEOUT)d->handle ); +// #else # ifndef KEEP_DEVICE_OPEN @@ -266,3 +265,4 @@ AudioDevice::~AudioDevice() { delete d; -#endif +//#endif + QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; @@ -279,16 +279,16 @@ void AudioDevice::write( char *buffer, unsigned int length ) { -#ifdef Q_OS_WIN32 - // returns immediately and (to be implemented) emits completedIO() when finished writing - WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) ); - // maybe the buffer should be copied so that this fool proof, but its a performance hit - lpWaveHdr->lpData = buffer; - lpWaveHdr->dwBufferLength = length; - lpWaveHdr->dwFlags = 0L; - lpWaveHdr->dwLoops = 0L; - waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ); - // waveOutWrite returns immediately. the data is sent in the background. - if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) ) - qDebug( "failed to write block to audio device" ); - // emit completedIO(); -#else +// #ifdef Q_OS_WIN32 +// // returns immediately and (to be implemented) emits completedIO() when finished writing +// WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) ); +// // maybe the buffer should be copied so that this fool proof, but its a performance hit +// lpWaveHdr->lpData = buffer; +// lpWaveHdr->dwBufferLength = length; +// lpWaveHdr->dwFlags = 0L; +// lpWaveHdr->dwLoops = 0L; +// waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ); +// // waveOutWrite returns immediately. the data is sent in the background. +// if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) ) +// qDebug( "failed to write block to audio device" ); +// // emit completedIO(); +// #else int t = ::write( d->handle, buffer, length ); @@ -300,3 +300,3 @@ void AudioDevice::write( char *buffer, unsigned int length ) } -#endif +//#endif } @@ -329,5 +329,5 @@ unsigned int AudioDevice::canWrite() const { -#ifdef Q_OS_WIN32 - return bufferSize(); // Any better? -#else +// #ifdef Q_OS_WIN32 +// return bufferSize(); // Any better? +// #else audio_buf_info info; @@ -356,3 +356,3 @@ unsigned int AudioDevice::canWrite() const } -#endif +//#endif } @@ -361,10 +361,10 @@ unsigned int AudioDevice::canWrite() const int AudioDevice::bytesWritten() { -#ifdef Q_OS_WIN32 - MMTIME pmmt = { TIME_BYTES, 0 }; - if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) { - qDebug( "failed to get audio device position" ); - return -1; - } - return pmmt.u.cb; -#else +// #ifdef Q_OS_WIN32 +// MMTIME pmmt = { TIME_BYTES, 0 }; +// if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) { +// qDebug( "failed to get audio device position" ); +// return -1; +// } +// return pmmt.u.cb; +// #else int buffered = 0; @@ -375,3 +375,3 @@ int AudioDevice::bytesWritten() { return buffered; -#endif +//#endif } diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index ac8c935..54e7ceb 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp @@ -145,2 +145,3 @@ void AudioWidget::sliderReleased() { void AudioWidget::setPosition( long i ) { +// qDebug("set position %d",i); updateSlider( i, mediaPlayerState->length() ); @@ -155,3 +156,2 @@ void AudioWidget::setLength( long max ) { void AudioWidget::setView( char view ) { - if (mediaPlayerState->isStreaming) { diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 3171c4b..70e4a78 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp @@ -155,3 +155,3 @@ void LoopControl::setPosition( long pos ) { audioMutex->lock(); - +// qDebug("Loop control %d", pos); if ( hasVideoChannel && hasAudioChannel ) { @@ -222,3 +222,2 @@ void LoopControl::startAudio() { -//qDebug("start audio"); audioMutex->lock(); @@ -239,10 +238,10 @@ void LoopControl::startAudio() { // this causes drop outs not sure why its even here - if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { - usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); - } - else if ( sampleWaitTime <= -5000 ) { - qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); -// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); - currentSample = sampleWeShouldBeAt; - } +// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { +// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); +// } +// else if ( sampleWaitTime <= -5000 ) { +// qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); +// // //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); +// currentSample = sampleWeShouldBeAt; +// } @@ -347,4 +346,6 @@ void LoopControl::stop( bool willPlayAgainShortly ) { audioMutex->unlock(); - } + audioSampleCounter=0; + current_frame=0; + total_audio_samples=0; } @@ -354,3 +355,2 @@ bool LoopControl::init( const QString& filename ) { stop(); - audioMutex->lock(); @@ -452,2 +452,4 @@ void LoopControl::play() { qDebug("LC- play"); + mediaPlayerState->setPosition( 0); //uglyhack + #if defined(Q_WS_QWS) && !defined(QT_NO_COP) diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp index b9e438b..64fdc01 100644 --- a/core/multimedia/opieplayer/mediaplayer.cpp +++ b/core/multimedia/opieplayer/mediaplayer.cpp @@ -64,2 +64,3 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name ) MediaPlayer::~MediaPlayer() { + } diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp index 3ac9ac4..cf166d6 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.cpp +++ b/core/multimedia/opieplayer/mediaplayerstate.cpp diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 200ec16..35208e4 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -159,3 +159,2 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) tbDeletePlaylist->setFixedSize(20,20); - connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); @@ -192,6 +191,4 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); - connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); fullScreenButton->addTo(pmView); scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); - connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); scaleButton->addTo(pmView); @@ -226,4 +223,2 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) - connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), - this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); @@ -253,7 +248,2 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); - connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), - this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); - - connect( audioView, SIGNAL( returnPressed( QListViewItem *)), - this,SLOT( playIt( QListViewItem *)) ); @@ -279,7 +269,2 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) - connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), - this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); - connect( videoView, SIGNAL( returnPressed( QListViewItem *)), - this,SLOT( playIt( QListViewItem *)) ); - tabWidget->insertTab( vTab,tr("Video")); @@ -294,3 +279,2 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) - connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); @@ -307,6 +291,26 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) + connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); + connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); + connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); + connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), + this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); + + connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), + this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); + + connect( audioView, SIGNAL( returnPressed( QListViewItem *)), + this,SLOT( playIt( QListViewItem *)) ); connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); + + connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), + this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); + connect( videoView, SIGNAL( returnPressed( QListViewItem *)), + this,SLOT( playIt( QListViewItem *)) ); connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); + connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); + + connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); + connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); @@ -754,2 +758,4 @@ void PlayListWidget::playIt( QListViewItem *it) { // d->setDocumentUsed = FALSE; +// mediaPlayerState->curPosition =0; + qDebug("playIt"); mediaPlayerState->setPlaying(FALSE); @@ -837,2 +843,3 @@ void PlayListWidget::btnPlay(bool b) { { + mediaPlayerState->setPlaying(b); |