author | llornkcor <llornkcor> | 2002-02-25 05:10:32 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-25 05:10:32 (UTC) |
commit | 1bebd27631a6c9d1ab967cbb32dd4e796b3b0402 (patch) (side-by-side diff) | |
tree | 8ce49800cba26f6f2c33de74a71d4efe0338843f /core/multimedia/opieplayer/loopcontrol.cpp | |
parent | d948361c1b475fab4660b28fbf5ec21fd34d923f (diff) | |
download | opie-1bebd27631a6c9d1ab967cbb32dd4e796b3b0402.zip opie-1bebd27631a6c9d1ab967cbb32dd4e796b3b0402.tar.gz opie-1bebd27631a6c9d1ab967cbb32dd4e796b3b0402.tar.bz2 |
fixed 2
Diffstat (limited to 'core/multimedia/opieplayer/loopcontrol.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol.cpp | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index dd466ed..90a7cc6 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp @@ -1,6 +1,6 @@ /********************************************************************** -** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. +** Copyright (C) 2000 Trolltech AS. All rights reserved. ** -** This file is part of the Qtopia Environment. +** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the @@ -18,10 +18,12 @@ ** **********************************************************************/ +// L.J.Potter added changes Fri 02-15-2002 + + #include <qpe/qpeapplication.h> -#ifdef Q_WS_QWS +#ifdef Q_WS_QWS #include <qpe/qcopenvelope_qws.h> #endif -#include <qpe/mediaplayerplugininterface.h> #include <stdio.h> #include <stdlib.h> @@ -33,4 +35,5 @@ #include "videowidget.h" #include "audiodevice.h" +#include "mediaplayerplugininterface.h" #include "mediaplayerstate.h" @@ -103,8 +106,6 @@ LoopControl::LoopControl( QObject *parent, const char *name ) pthread_attr_init(&audio_attr); - - if ( getuid() == 0 ) { - printf("true, guid = %i\n", getuid()); - +#define USE_REALTIME_AUDIO_THREAD +#ifdef USE_REALTIME_AUDIO_THREAD // Attempt to set it to real-time round robin if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { @@ -117,8 +118,5 @@ LoopControl::LoopControl( QObject *parent, const char *name ) pthread_attr_init(&audio_attr); } - } -// printf("false, guid = %i\n", getuid()); - usleep( 100 ); - +#endif pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); } @@ -235,5 +233,5 @@ void LoopControl::startAudio() { long samplesRead = 0; - mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); + bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; long sampleWaitTime = currentSample - sampleWeShouldBeAt; @@ -241,5 +239,6 @@ void LoopControl::startAudio() { if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); - } else if ( sampleWaitTime <= -5000 ) { + } + else if ( sampleWaitTime <= -5000 ) { qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); @@ -250,5 +249,5 @@ void LoopControl::startAudio() { audioSampleCounter = currentSample + samplesRead - 1; - moreAudio = audioSampleCounter <= total_audio_samples; + moreAudio = readOk && (audioSampleCounter <= total_audio_samples); } else { @@ -380,21 +379,21 @@ bool LoopControl::init( const QString& filename ) { 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(); |