summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-06-12 00:33:13 (UTC)
committer llornkcor <llornkcor>2002-06-12 00:33:13 (UTC)
commit8a53908265672bd3feee0ace40f9e5e38de2f30e (patch) (side-by-side diff)
tree9895780102a1f63cbe8cba9550320542f9b0e43b
parentd7c563f849316c7a742769e88136058afb69a2d9 (diff)
downloadopie-8a53908265672bd3feee0ace40f9e5e38de2f30e.zip
opie-8a53908265672bd3feee0ace40f9e5e38de2f30e.tar.gz
opie-8a53908265672bd3feee0ace40f9e5e38de2f30e.tar.bz2
attempted to look at stumbling issues, and pops while starting and stoping audio device. needs to be re done
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp8
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp14
2 files changed, 15 insertions, 7 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index ad44abb..e0989d0 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -194,24 +194,26 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
d->bytesPerSample = bps;
qDebug("%d",bps);
int format=0;
if( bps == 8) format = AFMT_U8;
else if( bps <= 0) format = AFMT_S16_LE;
else format = AFMT_S16_LE;
qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format);
connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
int fragments = 0x10000 * 8 + sound_fragment_shift;
int capabilities = 0;
+ QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
+
#ifdef KEEP_DEVICE_OPEN
if ( AudioDevicePrivate::dspFd == 0 ) {
#endif
if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) {
perror("open(\"/dev/dsp\") sending to /dev/null instead");
d->handle = ::open( "/dev/null", O_WRONLY );
}
#ifdef KEEP_DEVICE_OPEN
AudioDevicePrivate::dspFd = d->handle;
} else {
d->handle = AudioDevicePrivate::dspFd;
}
@@ -235,38 +237,44 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
d->bufferSize = sound_fragment_bytes;
d->unwrittenBuffer = new char[d->bufferSize];
d->unwritten = 0;
d->can_GETOSPACE = TRUE; // until we find otherwise
//if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels );
//if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency );
//if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" );
//if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" );
//if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" );
//if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" );
+ QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
+
}
AudioDevice::~AudioDevice() {
qDebug("destryo audiodevice");
+ QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
+
#ifdef Q_OS_WIN32
waveOutClose( (HWAVEOUT)d->handle );
#else
# ifndef KEEP_DEVICE_OPEN
close( d->handle ); // Now it should be safe to shut the handle
# endif
delete d->unwrittenBuffer;
delete d;
#endif
+ QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
+
}
void AudioDevice::volumeChanged( bool muted )
{
AudioDevicePrivate::muted = muted;
}
void AudioDevice::write( char *buffer, unsigned int length )
{
#ifdef Q_OS_WIN32
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index 6f86b4a..3171c4b 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -228,32 +228,32 @@ void LoopControl::startAudio() {
currentSample = audioSampleCounter + 1;
if ( currentSample != audioSampleCounter + 1 )
qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
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;
// this causes drop outs not sure why its even here
-// 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 );
+ 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;
-// }
+ currentSample = sampleWeShouldBeAt;
+ }
audioDevice->write( audioBuffer, samplesRead * 2 * channels );
if( mediaPlayerState->isStreaming == FALSE)
audioSampleCounter = currentSample + samplesRead - 1;
moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
} else {
moreAudio = FALSE;