summaryrefslogtreecommitdiff
path: root/core/multimedia
authorllornkcor <llornkcor>2002-06-17 12:54:54 (UTC)
committer llornkcor <llornkcor>2002-06-17 12:54:54 (UTC)
commit282007e58a8a038a0db042341528510e73ac80fc (patch) (side-by-side diff)
treef1a16c9a6a380bdc4217e9f92ac6ef6128d10717 /core/multimedia
parent2917d7481dc8c1b053e3212a699e64948a90ec4c (diff)
downloadopie-282007e58a8a038a0db042341528510e73ac80fc.zip
opie-282007e58a8a038a0db042341528510e73ac80fc.tar.gz
opie-282007e58a8a038a0db042341528510e73ac80fc.tar.bz2
fixes for goofy crap going on
Diffstat (limited to 'core/multimedia') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp292
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp2
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp384
-rw-r--r--core/multimedia/opieplayer/mediaplayer.cpp1
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.cpp80
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp43
6 files changed, 406 insertions, 396 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
@@ -1,22 +1,22 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+ ** Copyright (C) 2000 Trolltech AS. All rights reserved.
+ **
+ ** This file is part of Qtopia Environment.
+ **
+ ** This file may be distributed and/or modified under the terms of the
+ ** GNU General Public License version 2 as published by the Free Software
+ ** Foundation and appearing in the file LICENSE.GPL included in the
+ ** packaging of this file.
+ **
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ **
+ ** See http://www.trolltech.com/gpl/ for GPL licensing information.
+ **
+ ** Contact info@trolltech.com if any conditions of this licensing are
+ ** not clear to you.
+ **
+ **********************************************************************/
// L.J.Potter added better error code Fri 02-15-2002 14:37:47
@@ -30,12 +30,11 @@
#include "qpe/qcopenvelope_qws.h"
#endif
-#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)
#include <fcntl.h>
#include <sys/ioctl.h>
@@ -46,18 +45,18 @@
#include <unistd.h>
#endif
-#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)
static const int sound_fragment_shift = 14;
# else
static const int sound_fragment_shift = 16;
# endif
static const int sound_fragment_bytes = (1<<sound_fragment_shift);
-#endif
+//#endif
class AudioDevicePrivate {
@@ -67,11 +66,11 @@ public:
unsigned int channels;
unsigned int bytesPerSample;
unsigned int bufferSize;
-#ifndef Q_OS_WIN32
+//#ifndef Q_OS_WIN32
bool can_GETOSPACE;
char* unwrittenBuffer;
unsigned int unwritten;
-#endif
+//#endif
static int dspFd;
static bool muted;
@@ -97,64 +96,64 @@ unsigned int AudioDevicePrivate::rightVolume = 0;
void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) {
muted = AudioDevicePrivate::muted;
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 );
if ( mixerHandle >= 0 ) {
if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1)
- perror("ioctl(\"MIXER_READ\")");
+ perror("ioctl(\"MIXER_READ\")");
close( mixerHandle );
} else
perror("open(\"/dev/mixer\")");
leftVolume = ((volume & 0x00FF) << 16) / 101;
rightVolume = ((volume & 0xFF00) << 8) / 101;
-#endif
+//#endif
}
void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) {
AudioDevicePrivate::muted = muted;
if ( muted ) {
- AudioDevicePrivate::leftVolume = leftVolume;
- AudioDevicePrivate::rightVolume = rightVolume;
- leftVolume = 0;
- rightVolume = 0;
+ AudioDevicePrivate::leftVolume = leftVolume;
+ AudioDevicePrivate::rightVolume = rightVolume;
+ leftVolume = 0;
+ rightVolume = 0;
} else {
leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume );
- rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume );
+ rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : 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
- // Volume can be from 0 to 100 which is 101 distinct values
+// #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
unsigned int rV = (rightVolume * 101) >> 16;
# if 0
@@ -169,17 +168,17 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume,
perror("open(\"/dev/mixer\")");
# else
- // This is the way this has to be done now I guess, doesn't allow for
- // independant right and left channel setting, or setting for different outputs
+ // This is the way this has to be done now I guess, doesn't allow for
+ // independant right and left channel setting, or setting for different outputs
Config cfg("Sound");
cfg.setGroup("System");
cfg.writeEntry("Volume",(int)rV);
# endif
-#endif
+//#endif
// qDebug( "setting volume to: 0x%x", volume );
#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
- // Send notification that the volume has changed
+ // Send notification that the volume has changed
QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted;
#endif
}
@@ -188,9 +187,9 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume,
AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
- qDebug("creating new audio device");
+ qDebug("creating new audio device");
QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
- d = new AudioDevicePrivate;
+ d = new AudioDevicePrivate;
d->frequency = f;
d->channels = chs;
d->bytesPerSample = bps;
@@ -209,12 +208,12 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
#ifdef KEEP_DEVICE_OPEN
if ( AudioDevicePrivate::dspFd == 0 ) {
#endif
- if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) {
- perror("open(\"/dev/dsp\") sending to /dev/null instead");
- d->handle = ::open( "/dev/null", O_WRONLY );
- }
+ if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) {
+ perror("open(\"/dev/dsp\") sending to /dev/null instead");
+ d->handle = ::open( "/dev/null", O_WRONLY );
+ }
#ifdef KEEP_DEVICE_OPEN
- AudioDevicePrivate::dspFd = d->handle;
+ AudioDevicePrivate::dspFd = d->handle;
} else {
d->handle = AudioDevicePrivate::dspFd;
}
@@ -241,12 +240,12 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
d->unwritten = 0;
d->can_GETOSPACE = TRUE; // until we find otherwise
- //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels );
- //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency );
- //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" );
- //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" );
- //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" );
- //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" );
+ //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels );
+ //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency );
+ //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" );
+ //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" );
+ //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" );
+ //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" );
QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
}
@@ -254,17 +253,18 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
AudioDevice::~AudioDevice() {
qDebug("destryo audiodevice");
- QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
+ QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
-#ifdef Q_OS_WIN32
- waveOutClose( (HWAVEOUT)d->handle );
-#else
+// #ifdef Q_OS_WIN32
+// waveOutClose( (HWAVEOUT)d->handle );
+// #else
# ifndef KEEP_DEVICE_OPEN
close( d->handle ); // Now it should be safe to shut the handle
# endif
delete d->unwrittenBuffer;
delete d;
-#endif
+//#endif
+ QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
}
@@ -277,28 +277,28 @@ void AudioDevice::volumeChanged( bool muted )
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 );
if ( t<0 ) t = 0;
if ( t != (int)length) {
- qDebug("Ahhh!! memcpys 1");
- memcpy(d->unwrittenBuffer,buffer+t,length-t);
- d->unwritten = length-t;
+ qDebug("Ahhh!! memcpys 1");
+ memcpy(d->unwrittenBuffer,buffer+t,length-t);
+ d->unwritten = length-t;
}
-#endif
+//#endif
}
@@ -327,52 +327,52 @@ unsigned int AudioDevice::bufferSize() const
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;
if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) {
- d->can_GETOSPACE = FALSE;
- fcntl( d->handle, F_SETFL, O_NONBLOCK );
+ d->can_GETOSPACE = FALSE;
+ fcntl( d->handle, F_SETFL, O_NONBLOCK );
}
if ( d->can_GETOSPACE ) {
- int t = info.fragments * sound_fragment_bytes;
- return QMIN(t,(int)bufferSize());
+ int t = info.fragments * sound_fragment_bytes;
+ return QMIN(t,(int)bufferSize());
} else {
- if ( d->unwritten ) {
- int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten );
- if ( t<0 ) t = 0;
- if ( (unsigned)t!=d->unwritten ) {
- memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t);
- d->unwritten -= t;
- } else {
- d->unwritten = 0;
- }
- }
- if ( d->unwritten )
- return 0;
- else
- return d->bufferSize;
+ if ( d->unwritten ) {
+ int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten );
+ if ( t<0 ) t = 0;
+ if ( (unsigned)t!=d->unwritten ) {
+ memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t);
+ d->unwritten -= t;
+ } else {
+ d->unwritten = 0;
+ }
+ }
+ if ( d->unwritten )
+ return 0;
+ else
+ return d->bufferSize;
}
-#endif
+//#endif
}
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;
if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) {
- qDebug( "failed to get audio device position" );
- return -1;
+ qDebug( "failed to get audio device position" );
+ return -1;
}
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
@@ -143,6 +143,7 @@ void AudioWidget::sliderReleased() {
void AudioWidget::setPosition( long i ) {
+// qDebug("set position %d",i);
updateSlider( i, mediaPlayerState->length() );
}
@@ -153,7 +154,6 @@ void AudioWidget::setLength( long max ) {
void AudioWidget::setView( char view ) {
-
if (mediaPlayerState->isStreaming) {
if( !slider->isHidden()) slider->hide();
disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
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
@@ -1,22 +1,22 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+ ** Copyright (C) 2000 Trolltech AS. All rights reserved.
+ **
+ ** This file is part of Qtopia Environment.
+ **
+ ** This file may be distributed and/or modified under the terms of the
+ ** GNU General Public License version 2 as published by the Free Software
+ ** Foundation and appearing in the file LICENSE.GPL included in the
+ ** packaging of this file.
+ **
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ **
+ ** See http://www.trolltech.com/gpl/ for GPL licensing information.
+ **
+ ** Contact info@trolltech.com if any conditions of this licensing are
+ ** not clear to you.
+ **
+ **********************************************************************/
// L.J.Potter added changes Fri 02-15-2002
#include <qpe/qpeapplication.h>
@@ -59,22 +59,22 @@ bool threadOkToGo = FALSE;
class Mutex {
public:
Mutex() {
- pthread_mutexattr_t attr;
- pthread_mutexattr_init( &attr );
- pthread_mutex_init( &mutex, &attr );
- pthread_mutexattr_destroy( &attr );
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init( &attr );
+ pthread_mutex_init( &mutex, &attr );
+ pthread_mutexattr_destroy( &attr );
}
~Mutex() {
- pthread_mutex_destroy( &mutex );
+ pthread_mutex_destroy( &mutex );
}
void lock() {
- pthread_mutex_lock( &mutex );
+ pthread_mutex_lock( &mutex );
}
void unlock() {
- pthread_mutex_unlock( &mutex );
+ pthread_mutex_unlock( &mutex );
}
private:
pthread_mutex_t mutex;
@@ -84,10 +84,10 @@ private:
void *startAudioThread( void *ptr ) {
LoopControl *mpegView = (LoopControl *)ptr;
while ( TRUE ) {
- if ( threadOkToGo && mpegView->moreAudio )
- mpegView->startAudio();
- else
- usleep( 10000 ); // Semi-buzy-wait till we are playing again
+ if ( threadOkToGo && mpegView->moreAudio )
+ mpegView->startAudio();
+ else
+ usleep( 10000 ); // Semi-buzy-wait till we are playing again
}
return 0;
}
@@ -97,7 +97,7 @@ Mutex *audioMutex;
LoopControl::LoopControl( QObject *parent, const char *name )
- : QObject( parent, name ) {
+ : QObject( parent, name ) {
isMuted = FALSE;
connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) );
//qDebug("starting loopcontrol");
@@ -106,15 +106,15 @@ LoopControl::LoopControl( QObject *parent, const char *name )
pthread_attr_init(&audio_attr);
#define USE_REALTIME_AUDIO_THREAD
#ifdef USE_REALTIME_AUDIO_THREAD
- // Attempt to set it to real-time round robin
+ // Attempt to set it to real-time round robin
if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) {
- sched_param params;
- params.sched_priority = 50;
- pthread_attr_setschedparam(&audio_attr,&params);
+ sched_param params;
+ params.sched_priority = 50;
+ pthread_attr_setschedparam(&audio_attr,&params);
} else {
- qDebug( "Error setting up a realtime thread, reverting to using a normal thread." );
- pthread_attr_destroy(&audio_attr);
- pthread_attr_init(&audio_attr);
+ qDebug( "Error setting up a realtime thread, reverting to using a normal thread." );
+ pthread_attr_destroy(&audio_attr);
+ pthread_attr_init(&audio_attr);
}
#endif
//qDebug("create audio thread");
@@ -134,14 +134,14 @@ static int currentSample = 0;
void LoopControl::timerEvent( QTimerEvent *te ) {
if ( te->timerId() == videoId )
- startVideo();
+ startVideo();
if ( te->timerId() == sliderId ) {
- if ( hasAudioChannel && !hasVideoChannel && moreAudio ) {
- mediaPlayerState->updatePosition( audioSampleCounter );
- } else if ( hasVideoChannel && moreVideo ) {
- mediaPlayerState->updatePosition( current_frame );
- }
+ if ( hasAudioChannel && !hasVideoChannel && moreAudio ) {
+ mediaPlayerState->updatePosition( audioSampleCounter );
+ } else if ( hasVideoChannel && moreVideo ) {
+ mediaPlayerState->updatePosition( current_frame );
+ }
}
if ( !moreVideo && !moreAudio ) {
@@ -153,28 +153,28 @@ void LoopControl::timerEvent( QTimerEvent *te ) {
void LoopControl::setPosition( long pos ) {
audioMutex->lock();
-
+// qDebug("Loop control %d", pos);
if ( hasVideoChannel && hasAudioChannel ) {
- playtime.restart();
- playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
- current_frame = pos + 1;
- mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
- prev_frame = current_frame - 1;
- currentSample = (int)( (double)current_frame * freq / framerate );
- mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
- audioSampleCounter = currentSample - 1;
+ playtime.restart();
+ playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
+ current_frame = pos + 1;
+ mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
+ prev_frame = current_frame - 1;
+ currentSample = (int)( (double)current_frame * freq / framerate );
+ mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
+ audioSampleCounter = currentSample - 1;
} else if ( hasVideoChannel ) {
- playtime.restart();
- playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
- current_frame = pos + 1;
- mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
- prev_frame = current_frame - 1;
+ playtime.restart();
+ playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
+ current_frame = pos + 1;
+ mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
+ prev_frame = current_frame - 1;
} else if ( hasAudioChannel ) {
- playtime.restart();
- playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) );
- currentSample = pos + 1;
- mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
- audioSampleCounter = currentSample - 1;
+ playtime.restart();
+ playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) );
+ currentSample = pos + 1;
+ mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
+ audioSampleCounter = currentSample - 1;
}
audioMutex->unlock();
@@ -187,32 +187,32 @@ void LoopControl::startVideo() {
if ( mediaPlayerState->curDecoder() ) {
- if ( hasAudioChannel && !isMuted ) {
+ if ( hasAudioChannel && !isMuted ) {
- current_frame = long( playtime.elapsed() * framerate / 1000 );
+ current_frame = long( playtime.elapsed() * framerate / 1000 );
- if ( prev_frame != -1 && current_frame <= prev_frame )
- return;
+ if ( prev_frame != -1 && current_frame <= prev_frame )
+ return;
- } else {
- // Don't skip
- current_frame++;
- }
+ } else {
+ // Don't skip
+ current_frame++;
+ }
- if ( prev_frame == -1 || current_frame > prev_frame ) {
- if ( current_frame > prev_frame + 1 ) {
- mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
- }
- moreVideo = videoUI->playVideo();
- prev_frame = current_frame;
- }
+ if ( prev_frame == -1 || current_frame > prev_frame ) {
+ if ( current_frame > prev_frame + 1 ) {
+ mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
+ }
+ moreVideo = videoUI->playVideo();
+ prev_frame = current_frame;
+ }
- } else {
+ } else {
- moreVideo = FALSE;
- killTimer( videoId );
+ moreVideo = FALSE;
+ killTimer( videoId );
- }
+ }
}
}
@@ -220,44 +220,43 @@ void LoopControl::startVideo() {
void LoopControl::startAudio() {
-//qDebug("start audio");
audioMutex->lock();
if ( moreAudio ) {
- if ( !isMuted && mediaPlayerState->curDecoder() ) {
+ if ( !isMuted && mediaPlayerState->curDecoder() ) {
- currentSample = audioSampleCounter + 1;
+ currentSample = audioSampleCounter + 1;
- if ( currentSample != audioSampleCounter + 1 )
- qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
+ if ( currentSample != audioSampleCounter + 1 )
+ qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
- long samplesRead = 0;
- bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream );
- long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
- long sampleWaitTime = currentSample - sampleWeShouldBeAt;
+ long samplesRead = 0;
+ bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream );
+ long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
+ long sampleWaitTime = currentSample - sampleWeShouldBeAt;
// 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;
+// }
- audioDevice->write( audioBuffer, samplesRead * 2 * channels );
+ audioDevice->write( audioBuffer, samplesRead * 2 * channels );
- if( mediaPlayerState->isStreaming == FALSE)
- audioSampleCounter = currentSample + samplesRead - 1;
+ if( mediaPlayerState->isStreaming == FALSE)
+ audioSampleCounter = currentSample + samplesRead - 1;
- moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
+ moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
- } else {
+ } else {
- moreAudio = FALSE;
+ moreAudio = FALSE;
- }
+ }
}
@@ -270,7 +269,7 @@ void LoopControl::killTimers() {
audioMutex->lock();
if ( hasVideoChannel )
- killTimer( videoId );
+ killTimer( videoId );
killTimer( sliderId );
threadOkToGo = FALSE;
@@ -286,14 +285,14 @@ void LoopControl::startTimers() {
moreAudio = FALSE;
if ( hasVideoChannel ) {
- moreVideo = TRUE;
- int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value
- videoId = startTimer( mSecsBetweenFrames );
+ moreVideo = TRUE;
+ int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value
+ videoId = startTimer( mSecsBetweenFrames );
}
if ( hasAudioChannel ) {
- moreAudio = TRUE;
- threadOkToGo = TRUE;
+ moreAudio = TRUE;
+ threadOkToGo = TRUE;
}
sliderId = startTimer( 300 ); // update slider every 1/3 second
@@ -305,16 +304,16 @@ void LoopControl::startTimers() {
void LoopControl::setPaused( bool pause ) {
if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() )
- return;
+ return;
if ( pause ) {
- killTimers();
+ killTimers();
} else {
- // Force an update of the position
- mediaPlayerState->setPosition( mediaPlayerState->position() + 1 );
- mediaPlayerState->setPosition( mediaPlayerState->position() - 1 );
- // Just like we never stopped
- startTimers();
+ // Force an update of the position
+ mediaPlayerState->setPosition( mediaPlayerState->position() + 1 );
+ mediaPlayerState->setPosition( mediaPlayerState->position() - 1 );
+ // Just like we never stopped
+ startTimers();
}
}
@@ -323,36 +322,37 @@ void LoopControl::stop( bool willPlayAgainShortly ) {
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) {
- disabledSuspendScreenSaver = FALSE;
- // Re-enable the suspend mode
- QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
+ disabledSuspendScreenSaver = FALSE;
+ // Re-enable the suspend mode
+ QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
}
#endif
if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) {
- killTimers();
+ killTimers();
- audioMutex->lock();
+ audioMutex->lock();
- mediaPlayerState->curDecoder()->close();
+ mediaPlayerState->curDecoder()->close();
- if ( audioDevice ) {
- delete audioDevice;
- delete audioBuffer;
- audioDevice = 0;
- audioBuffer = 0;
- }
-
- audioMutex->unlock();
+ if ( audioDevice ) {
+ delete audioDevice;
+ delete audioBuffer;
+ audioDevice = 0;
+ audioBuffer = 0;
+ }
+ audioMutex->unlock();
}
+ audioSampleCounter=0;
+ current_frame=0;
+ total_audio_samples=0;
}
bool LoopControl::init( const QString& filename ) {
stop();
-
audioMutex->lock();
fileName = filename;
@@ -361,7 +361,7 @@ bool LoopControl::init( const QString& filename ) {
qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() );
- // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin
+ // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin
if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) {
if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename )) {
total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 );
@@ -370,69 +370,69 @@ bool LoopControl::init( const QString& filename ) {
}
if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) {
- audioMutex->unlock();
- return FALSE;
+ audioMutex->unlock();
+ return FALSE;
}
hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0;
hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0;
if ( hasAudioChannel ) {
- int astream = 0;
+ int astream = 0;
- if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMpeg3Plugin") )
- channels = 2; //dont akx me why, but it needs this hack
- else
- channels = mediaPlayerState->curDecoder()->audioChannels( astream );
+ if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMpeg3Plugin") )
+ channels = 2; //dont akx me why, but it needs this hack
+ else
+ channels = mediaPlayerState->curDecoder()->audioChannels( astream );
- qDebug( "LC- channels = %d", channels );
+ qDebug( "LC- channels = %d", channels );
- if ( !total_audio_samples )
- total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream );
+ if ( !total_audio_samples )
+ total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream );
- total_audio_samples += 1000;
+ total_audio_samples += 1000;
- mediaPlayerState->setLength( total_audio_samples );
+ mediaPlayerState->setLength( total_audio_samples );
- freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
- qDebug( "LC- frequency = %d", freq );
-
- audioSampleCounter = 0;
- int bits_per_sample;
- if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) {
- bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime();
- qDebug("using stupid hack");
- } else {
- bits_per_sample=0;
- }
-
- audioDevice = new AudioDevice( freq, channels, bits_per_sample);
- audioBuffer = new char[ audioDevice->bufferSize() ];
- channels = audioDevice->channels();
-
- //### must check which frequency is actually used.
- static const int size = 1;
- short int buf[size];
- long samplesRead = 0;
- mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream );
+ freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
+ qDebug( "LC- frequency = %d", freq );
+
+ audioSampleCounter = 0;
+ int bits_per_sample;
+ if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) {
+ bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime();
+ qDebug("using stupid hack");
+ } else {
+ bits_per_sample=0;
+ }
+
+ audioDevice = new AudioDevice( freq, channels, bits_per_sample);
+ audioBuffer = new char[ audioDevice->bufferSize() ];
+ channels = audioDevice->channels();
+
+ //### must check which frequency is actually used.
+ static const int size = 1;
+ short int buf[size];
+ long samplesRead = 0;
+ mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream );
}
if ( hasVideoChannel ) {
- total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream );
+ total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream );
- mediaPlayerState->setLength( total_video_frames );
+ mediaPlayerState->setLength( total_video_frames );
- framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream );
- DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames ));
+ framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream );
+ DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames ));
- if ( framerate <= 1.0 ) {
- DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" ));
- framerate = 25;
- }
+ if ( framerate <= 1.0 ) {
+ DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" ));
+ framerate = 25;
+ }
- if ( total_video_frames == 1 ) {
- DecodeLoopDebug(( "Cannot seek to frame" ));
- }
+ if ( total_video_frames == 1 ) {
+ DecodeLoopDebug(( "Cannot seek to frame" ));
+ }
}
@@ -450,13 +450,15 @@ bool LoopControl::init( const QString& filename ) {
void LoopControl::play() {
qDebug("LC- play");
+ mediaPlayerState->setPosition( 0); //uglyhack
+
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) {
- disabledSuspendScreenSaver = TRUE;
- previousSuspendMode = hasVideoChannel;
- // Stop the screen from blanking and power saving state
- QCopEnvelope("QPE/System", "setScreenSaverMode(int)" )
- << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend );
+ disabledSuspendScreenSaver = TRUE;
+ previousSuspendMode = hasVideoChannel;
+ // Stop the screen from blanking and power saving state
+ QCopEnvelope("QPE/System", "setScreenSaverMode(int)" )
+ << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend );
}
#endif
@@ -467,14 +469,14 @@ void LoopControl::play() {
void LoopControl::setMute( bool on ) {
if ( on != isMuted ) {
- isMuted = on;
- if ( !on ) {
- // Force an update of the position
- mediaPlayerState->setPosition( mediaPlayerState->position() + 1 );
- mediaPlayerState->setPosition( mediaPlayerState->position() - 1 );
- // Resume playing audio
- moreAudio = TRUE;
- }
+ isMuted = on;
+ if ( !on ) {
+ // Force an update of the position
+ mediaPlayerState->setPosition( mediaPlayerState->position() + 1 );
+ mediaPlayerState->setPosition( mediaPlayerState->position() - 1 );
+ // Resume playing audio
+ moreAudio = TRUE;
+ }
}
}
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
@@ -62,6 +62,7 @@ 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
@@ -1,22 +1,22 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of Qtopia Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-** See http://www.trolltech.com/gpl/ for GPL licensing information.
-**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
-**********************************************************************/
+ ** Copyright (C) 2000 Trolltech AS. All rights reserved.
+ **
+ ** This file is part of Qtopia Environment.
+ **
+ ** This file may be distributed and/or modified under the terms of the
+ ** GNU General Public License version 2 as published by the Free Software
+ ** Foundation and appearing in the file LICENSE.GPL included in the
+ ** packaging of this file.
+ **
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ **
+ ** See http://www.trolltech.com/gpl/ for GPL licensing information.
+ **
+ ** Contact info@trolltech.com if any conditions of this licensing are
+ ** not clear to you.
+ **
+ **********************************************************************/
#include <qpe/qpeapplication.h>
#include <qpe/qlibrary.h>
#include <qpe/config.h>
@@ -41,7 +41,7 @@
MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
- : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) {
+ : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) {
Config cfg( "OpiePlayer" );
readConfig( cfg );
loadPlugins();
@@ -106,7 +106,7 @@ MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) {
if(file.left(4)=="http")
isStreaming = TRUE;
else
- isStreaming = FALSE;
+ isStreaming = FALSE;
return decoder = tmpDecoder;
}
@@ -131,9 +131,9 @@ void MediaPlayerState::loadPlugins() {
#ifndef QT_NO_COMPONENT
QValueList<MediaPlayerPlugin>::Iterator mit;
for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) {
- (*mit).iface->release();
- (*mit).library->unload();
- delete (*mit).library;
+ (*mit).iface->release();
+ (*mit).library->unload();
+ delete (*mit).library;
}
pluginList.clear();
@@ -142,28 +142,28 @@ void MediaPlayerState::loadPlugins() {
QStringList list = dir.entryList();
QStringList::Iterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
- MediaPlayerPluginInterface *iface = 0;
- QLibrary *lib = new QLibrary( path + "/" + *it );
+ MediaPlayerPluginInterface *iface = 0;
+ QLibrary *lib = new QLibrary( path + "/" + *it );
// qDebug( "querying: %s", QString( path + "/" + *it ).latin1() );
- if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) {
+ if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) {
// qDebug( "loading: %s", QString( path + "/" + *it ).latin1() );
- MediaPlayerPlugin plugin;
- plugin.library = lib;
- plugin.iface = iface;
- plugin.decoder = plugin.iface->decoder();
- plugin.encoder = plugin.iface->encoder();
- pluginList.append( plugin );
+ MediaPlayerPlugin plugin;
+ plugin.library = lib;
+ plugin.iface = iface;
+ plugin.decoder = plugin.iface->decoder();
+ plugin.encoder = plugin.iface->encoder();
+ pluginList.append( plugin );
- // ### hack to get true sample count
- if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") )
- libmpeg3decoder = plugin.decoder;
+ // ### hack to get true sample count
+ if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") )
+ libmpeg3decoder = plugin.decoder;
- } else {
- delete lib;
- }
+ } else {
+ delete lib;
+ }
}
#else
pluginList.clear();
@@ -188,8 +188,8 @@ void MediaPlayerState::loadPlugins() {
#endif
if ( pluginList.count() )
- MediaPlayerDebug(( "%i decoders found", pluginList.count() ));
+ MediaPlayerDebug(( "%i decoders found", pluginList.count() ));
else
- MediaPlayerDebug(( "No decoders found" ));
+ MediaPlayerDebug(( "No decoders found" ));
}
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
@@ -157,7 +157,6 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
tbDeletePlaylist->setFlat(TRUE);
tbDeletePlaylist->setFixedSize(20,20);
- connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
this , SLOT(addSelected()) );
@@ -190,10 +189,8 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
menu->insertItem( tr( "View" ), pmView );
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);
QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
@@ -224,8 +221,6 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
- connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
- this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
@@ -251,11 +246,6 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
tabWidget->insertTab(aTab,tr("Audio"));
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 *)) );
// audioView
// populateAudioView();
@@ -277,11 +267,6 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
- 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"));
// populateVideoView();
@@ -292,7 +277,6 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
playLists->setMinimumSize(233,260);
tabWidget->insertTab(LTab,tr("Lists"));
- connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
// add the library area
@@ -305,10 +289,30 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
- connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
+ 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 ) ) );
connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
@@ -752,7 +756,9 @@ void PlayListWidget::removeSelected() {
void PlayListWidget::playIt( QListViewItem *it) {
// d->setDocumentUsed = FALSE;
- mediaPlayerState->setPlaying(FALSE);
+// mediaPlayerState->curPosition =0;
+ qDebug("playIt");
+ mediaPlayerState->setPlaying(FALSE);
mediaPlayerState->setPlaying(TRUE);
d->selectedFiles->unSelect();
}
@@ -835,6 +841,7 @@ void PlayListWidget::btnPlay(bool b) {
switch ( tabWidget->currentPageIndex()) {
case 0:
{
+
mediaPlayerState->setPlaying(b);
}
break;