summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/loopcontrol.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/loopcontrol.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index ba14882..8cf0a75 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -91,42 +91,42 @@ void *startAudioThread( void *ptr ) {
91 } 91 }
92 return 0; 92 return 0;
93} 93}
94 94
95 95
96Mutex *audioMutex; 96Mutex *audioMutex;
97 97
98 98
99LoopControl::LoopControl( QObject *parent, const char *name ) 99LoopControl::LoopControl( QObject *parent, const char *name )
100 : QObject( parent, name ) { 100 : QObject( parent, name ) {
101 isMuted = FALSE; 101 isMuted = FALSE;
102 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); 102 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) );
103//qDebug("starting loopcontrol"); 103qDebug("starting loopcontrol");
104 audioMutex = new Mutex; 104 audioMutex = new Mutex;
105 105
106 pthread_attr_init(&audio_attr); 106 pthread_attr_init(&audio_attr);
107#define USE_REALTIME_AUDIO_THREAD 107#define USE_REALTIME_AUDIO_THREAD
108#ifdef USE_REALTIME_AUDIO_THREAD 108#ifdef USE_REALTIME_AUDIO_THREAD
109 // Attempt to set it to real-time round robin 109 // Attempt to set it to real-time round robin
110 if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { 110 if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) {
111 sched_param params; 111 sched_param params;
112 params.sched_priority = 50; 112 params.sched_priority = 50;
113 pthread_attr_setschedparam(&audio_attr,&params); 113 pthread_attr_setschedparam(&audio_attr,&params);
114 } else { 114 } else {
115 qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); 115 qDebug( "Error setting up a realtime thread, reverting to using a normal thread." );
116 pthread_attr_destroy(&audio_attr); 116 pthread_attr_destroy(&audio_attr);
117 pthread_attr_init(&audio_attr); 117 pthread_attr_init(&audio_attr);
118 } 118 }
119#endif 119#endif
120//qDebug("create audio thread"); 120qDebug("create audio thread");
121 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); 121 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this);
122} 122}
123 123
124 124
125LoopControl::~LoopControl() { 125LoopControl::~LoopControl() {
126 stop(); 126 stop();
127} 127}
128 128
129 129
130static long prev_frame = 0; 130static long prev_frame = 0;
131static int currentSample = 0; 131static int currentSample = 0;
132 132
@@ -355,54 +355,54 @@ void LoopControl::stop( bool willPlayAgainShortly ) {
355 355
356bool LoopControl::init( const QString& filename ) { 356bool LoopControl::init( const QString& filename ) {
357 stop(); 357 stop();
358 audioMutex->lock(); 358 audioMutex->lock();
359 359
360 fileName = filename; 360 fileName = filename;
361 stream = 0; // only play stream 0 for now 361 stream = 0; // only play stream 0 for now
362 current_frame = total_video_frames = total_audio_samples = 0; 362 current_frame = total_video_frames = total_audio_samples = 0;
363 363
364 qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); 364 qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() );
365 365
366 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin 366 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin
367 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { 367// if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) {
368 if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename )) { 368// if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename )) {
369 total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); 369// total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 );
370 mediaPlayerState->libMpeg3Decoder()->close(); 370// mediaPlayerState->libMpeg3Decoder()->close();
371 } 371// }
372 } 372// }
373 373
374 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { 374 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) {
375 audioMutex->unlock(); 375 audioMutex->unlock();
376 return FALSE; 376 return FALSE;
377 } 377 }
378 378
379 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; 379 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0;
380 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; 380 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0;
381 381
382 if ( hasAudioChannel ) { 382 if ( hasAudioChannel ) {
383 int astream = 0; 383 int astream = 0;
384 384
385 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMpeg3Plugin") ) 385 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMpeg3Plugin") )
386 channels = 2; //dont akx me why, but it needs this hack 386 channels = 2; //dont akx me why, but it needs this hack
387 else 387 else
388 channels = mediaPlayerState->curDecoder()->audioChannels( astream ); 388 channels = mediaPlayerState->curDecoder()->audioChannels( astream );
389 389
390 qDebug( "LC- channels = %d", channels ); 390 qDebug( "LC- channels = %d", channels );
391 391
392 if ( !total_audio_samples ) 392// if ( !total_audio_samples )
393 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); 393 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream );
394 394
395 total_audio_samples += 1000; 395 total_audio_samples += 1000;
396 396 qDebug("total samples %d", total_audio_samples);
397 mediaPlayerState->setLength( total_audio_samples ); 397 mediaPlayerState->setLength( total_audio_samples );
398 398
399 freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); 399 freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
400 qDebug( "LC- frequency = %d", freq ); 400 qDebug( "LC- frequency = %d", freq );
401 401
402 audioSampleCounter = 0; 402 audioSampleCounter = 0;
403 int bits_per_sample; 403 int bits_per_sample;
404 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { 404 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) {
405 bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); 405 bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime();
406 qDebug("using stupid hack"); 406 qDebug("using stupid hack");
407 } else { 407 } else {
408 bits_per_sample=0; 408 bits_per_sample=0;