summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/loopcontrol_threaded.cpp
Side-by-side diff
Diffstat (limited to 'core/multimedia/opieplayer/loopcontrol_threaded.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/loopcontrol_threaded.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.cpp b/core/multimedia/opieplayer/loopcontrol_threaded.cpp
index e99c97b..364e77b 100644
--- a/core/multimedia/opieplayer/loopcontrol_threaded.cpp
+++ b/core/multimedia/opieplayer/loopcontrol_threaded.cpp
@@ -183,25 +183,25 @@ void LoopControl::timerEvent( QTimerEvent* ) {
void LoopControl::setPosition( long pos ) {
if ( sendingNewPos ) {
sendingNewPos = FALSE;
return;
}
if ( hasVideoChannel && hasAudioChannel ) {
videoMutex->lock();
audioMutex->lock();
-qDebug("setting position");
+ //qDebug("setting position");
playtime.restart();
playtime = playtime.addMSecs( -pos * 1000 / framerate );
//begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate;
current_frame = pos + 1;
mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
prev_frame = current_frame - 1;
currentSample = (int)( current_frame * freq / framerate );
mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
audioSampleCounter = currentSample - 1;
audioMutex->unlock();
videoMutex->unlock();
} else if ( hasVideoChannel ) {
@@ -299,25 +299,25 @@ void LoopControl::startVideo() {
videoMutex->lock();
current_frame++;
videoMutex->unlock();
}
videoMutex->lock();
bool check = current_frame && current_frame > prev_frame;
videoMutex->unlock();
if ( check ) {
videoMutex->lock();
if ( current_frame > prev_frame + 1 ) {
- qDebug("skipped a frame");
+ // qDebug("skipped a frame");
mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
}
prev_frame = current_frame;
if ( moreVideo = videoUI->playVideo() )
emitChangePos = TRUE;
videoMutex->unlock();
}
} else
moreVideo = FALSE;
}
@@ -332,26 +332,26 @@ void LoopControl::startAudio() {
moreAudio = TRUE;
while ( moreAudio ) {
if ( !isMuted && mediaPlayerState->curDecoder() && hasAudioChannel ) {
audioMutex->lock();
currentSample = mediaPlayerState->curDecoder()->audioGetSample( stream );
if ( currentSample == 0 )
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);
audioMutex->unlock();
/*
int sampleWeShouldBeAt = int( playtime.elapsed() ) * freq / 1000;
if ( sampleWeShouldBeAt - currentSample > 20000 ) {
mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
currentSample = sampleWeShouldBeAt;
}
*/
long samplesRead = 0;
@@ -362,25 +362,25 @@ void LoopControl::startAudio() {
audioMutex->lock();
long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
//long sampleWeShouldBeAt = long( clock() - begin ) * (double) freq / CLOCKS_PER_SEC;
long sampleWaitTime = currentSample - sampleWeShouldBeAt;
audioMutex->unlock();
if ( sampleWaitTime >= 0 && sampleWaitTime <= 2000 ) {
//qDebug("sampleWaitTime: %i", sampleWaitTime);
usleep( ( sampleWaitTime * 1000000 ) / ( freq ) );
} else {
audioMutex->lock();
if ( sampleWaitTime <= -2000 ) {
- qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
+ // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
currentSample = sampleWeShouldBeAt;
}
audioMutex->unlock();
}
audioDevice->write( audioBuffer, samplesRead * 2 * channels );
audioMutex->lock();
// audioSampleCounter += samplesRead;
audioSampleCounter = currentSample + samplesRead - 1;
audioMutex->unlock();
@@ -393,49 +393,49 @@ void LoopControl::startAudio() {
moreAudio = audioSampleCounter <= total_audio_samples;
} else {
if ( mediaPlayerState->curDecoder() && hasAudioChannel )
usleep( 100000 ); // Check every 1/10 sec to see if mute is off
else
moreAudio = FALSE;
}
}
- qDebug( "End of file" );
+ // qDebug( "End of file" );
if ( !moreVideo && !moreAudio )
emitPlayFinished = TRUE;
pthread_exit(NULL);
}
void LoopControl::killTimers() {
if ( hasVideoChannel ) {
if ( pthread_self() != video_tid ) {
if ( pthread_cancel(video_tid) == 0 ) {
void *thread_result = 0;
if ( pthread_join(video_tid,&thread_result) != 0 )
- qDebug("thread join error 1");
+ // qDebug("thread join error 1");
pthread_attr_destroy(&video_attr);
}
}
}
if ( hasAudioChannel ) {
if ( pthread_self() != audio_tid ) {
if ( pthread_cancel(audio_tid) == 0 ) {
void *thread_result = 0;
if ( pthread_join(audio_tid,&thread_result) != 0 )
- qDebug("thread join error 2");
+ // qDebug("thread join error 2");
pthread_attr_destroy(&audio_attr);
}
}
}
}
void LoopControl::startTimers() {
moreVideo = FALSE;
moreAudio = FALSE;
if ( hasVideoChannel ) {
moreVideo = TRUE;
@@ -504,25 +504,25 @@ void LoopControl::stop( bool willPlayAgainShortly ) {
}
}
}
bool LoopControl::init( const QString& filename ) {
stop();
fileName = filename;
stream = 0; // only play stream 0 for now
current_frame = total_video_frames = total_audio_samples = 0;
- qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() );
+ // 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
if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) {
if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) {
total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 );
mediaPlayerState->libMpeg3Decoder()->close();
}
}
if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) )
return FALSE;