summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/loopcontrol.cpp
Side-by-side diff
Diffstat (limited to 'core/multimedia/opieplayer/loopcontrol.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index 6dfd057..859a67a 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -14,13 +14,16 @@
** 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>
+
#ifdef Q_WS_QWS
#include <qpe/qcopenvelope_qws.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -229,19 +232,20 @@ void LoopControl::startAudio() {
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;
- 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 < 5000 ) ) {
+// 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 );
audioSampleCounter = currentSample + samplesRead - 1;
moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
@@ -370,29 +374,29 @@ bool LoopControl::init( const QString& filename ) {
hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0;
if ( hasAudioChannel ) {
int astream = 0;
channels = mediaPlayerState->curDecoder()->audioChannels( astream );
- DecodeLoopDebug(( "channels = %d\n", channels ));
+ qDebug( "LC- channels = %d", channels );
if ( !total_audio_samples )
total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream );
- total_audio_samples += 1000;
+// total_audio_samples += 1000;
mediaPlayerState->setLength( total_audio_samples );
freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
- DecodeLoopDebug(( "frequency = %d\n", freq ));
+ qDebug( "LC- frequency = %d", freq );
audioSampleCounter = 0;
- static const int bytes_per_sample = 2; //16 bit
+ int bits_per_sample = mediaPlayerState->curDecoder()->audioBitsPerSample( astream);
- audioDevice = new AudioDevice( freq, channels, bytes_per_sample );
+ 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];