summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/loopcontrol.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/loopcontrol.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp39
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,5 +1,5 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
@@ -19,8 +19,10 @@
19**********************************************************************/ 19**********************************************************************/
20// L.J.Potter added changes Fri 02-15-2002
21
22
20#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
21#ifdef Q_WS_QWS
22 24
25#ifdef Q_WS_QWS
23#include <qpe/qcopenvelope_qws.h> 26#include <qpe/qcopenvelope_qws.h>
24#endif 27#endif
25#include <qpe/mediaplayerplugininterface.h>
26#include <stdio.h> 28#include <stdio.h>
@@ -34,2 +36,3 @@
34#include "audiodevice.h" 36#include "audiodevice.h"
37#include "mediaplayerplugininterface.h"
35#include "mediaplayerstate.h" 38#include "mediaplayerstate.h"
@@ -104,6 +107,4 @@ LoopControl::LoopControl( QObject *parent, const char *name )
104 pthread_attr_init(&audio_attr); 107 pthread_attr_init(&audio_attr);
105 108#define USE_REALTIME_AUDIO_THREAD
106 if ( getuid() == 0 ) { 109#ifdef USE_REALTIME_AUDIO_THREAD
107 printf("true, guid = %i\n", getuid());
108
109 // Attempt to set it to real-time round robin 110 // Attempt to set it to real-time round robin
@@ -118,6 +119,3 @@ LoopControl::LoopControl( QObject *parent, const char *name )
118 } 119 }
119 } 120#endif
120// printf("false, guid = %i\n", getuid());
121 usleep( 100 );
122
123 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); 121 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this);
@@ -236,3 +234,3 @@ void LoopControl::startAudio() {
236 long samplesRead = 0; 234 long samplesRead = 0;
237 mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); 235 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream );
238 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; 236 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
@@ -242,3 +240,4 @@ void LoopControl::startAudio() {
242 usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); 240 usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) );
243 } else if ( sampleWaitTime <= -5000 ) { 241 }
242 else if ( sampleWaitTime <= -5000 ) {
244 qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); 243 qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
@@ -251,3 +250,3 @@ void LoopControl::startAudio() {
251 250
252 moreAudio = audioSampleCounter <= total_audio_samples; 251 moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
253 252
@@ -381,3 +380,3 @@ bool LoopControl::init( const QString& filename ) {
381 channels = mediaPlayerState->curDecoder()->audioChannels( astream ); 380 channels = mediaPlayerState->curDecoder()->audioChannels( astream );
382 DecodeLoopDebug(( "channels = %d\n", channels )); 381 qDebug( "LC- channels = %d", channels );
383 382
@@ -386,3 +385,3 @@ bool LoopControl::init( const QString& filename ) {
386 385
387 total_audio_samples += 1000; 386// total_audio_samples += 1000;
388 387
@@ -391,3 +390,3 @@ bool LoopControl::init( const QString& filename ) {
391 freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); 390 freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
392 DecodeLoopDebug(( "frequency = %d\n", freq )); 391 qDebug( "LC- frequency = %d", freq );
393 392
@@ -395,5 +394,5 @@ bool LoopControl::init( const QString& filename ) {
395 394
396 static const int bytes_per_sample = 2; //16 bit 395 int bits_per_sample = mediaPlayerState->curDecoder()->audioBitsPerSample( astream);
397 396
398 audioDevice = new AudioDevice( freq, channels, bytes_per_sample ); 397 audioDevice = new AudioDevice( freq, channels, bits_per_sample);
399 audioBuffer = new char[ audioDevice->bufferSize() ]; 398 audioBuffer = new char[ audioDevice->bufferSize() ];