From 554c60ea89a9e27438b81212b649327773a89fa8 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 15 Nov 2008 22:10:00 +0100 Subject: [PATCH] Crackle-free audio playback. Provide flawless audio playback by removing stupid and things-breaking delays. Current implementation uses 10s timer that is cancelled when next audio sample is needed to provide mutex-like logic for active scheduler instead of calculating some never-correct wait times. --- src/audio/symbian/SDL_epocaudio.cpp | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/src/audio/symbian/SDL_epocaudio.cpp b/src/audio/symbian/SDL_epocaudio.cpp index b5bf1b9..f7346ce 100644 --- a/src/audio/symbian/SDL_epocaudio.cpp +++ b/src/audio/symbian/SDL_epocaudio.cpp @@ -65,7 +65,6 @@ class CSimpleWait : public CTimer { public: CSimpleWait(); - void Wait(TTimeIntervalMicroSeconds32 aWait); private: void RunL(); @@ -78,12 +77,6 @@ CSimpleWait::CSimpleWait() ConstructL(); } -void CSimpleWait::Wait(TTimeIntervalMicroSeconds32 aWait) -{ - After(aWait); - CActiveScheduler::Start(); -} - void CSimpleWait::RunL() { CActiveScheduler::Stop(); @@ -100,7 +93,6 @@ class CEpocAudio : public CBase, public MStreamObs, public MStreamProvider static void Free(SDL_AudioDevice* thisdevice); void Wait(); - void Play(); void ThreadInitL(); TUint8* Buffer(); @@ -114,7 +106,6 @@ class CEpocAudio : public CBase, public MStreamObs, public MStreamProvider TUint32 iType; int iBufferSize; TUint8* iBuffer; - TTime iStart; CSimpleWait* iWait; }; @@ -177,7 +168,6 @@ void CEpocAudio::ThreadInitL() TUint8* CEpocAudio::Buffer() { - iStart.UniversalTime(); return iBuffer; } @@ -210,27 +200,11 @@ TPtrC8 CEpocAudio::Data() return data; } -void CEpocAudio::Play() -{ -} - void CEpocAudio::Wait() { - const TInt64 bufMs = TInt64(iBufferSize) * TInt64(1000000); - const TInt64 specTime = bufMs / TInt64(iRate * iChannels * 2); - iWait->After(specTime); - + // This wait will be terminated by call to Data() from audio buffer callback. + iWait->After(10000000); CActiveScheduler::Start(); - TTime end; - end.UniversalTime(); - const TTimeIntervalMicroSeconds delta = end.MicroSecondsFrom(iStart); - - const int diff = specTime - delta.Int64(); - - if(diff > 0) - { - usleep(diff); - } } /* Audio driver bootstrap functions */ @@ -355,7 +329,6 @@ static void EPOC_WaitAudio(SDL_AudioDevice* thisdevice) static void EPOC_PlayAudio(SDL_AudioDevice* thisdevice) { - CEpocAudio::Current(thisdevice).Play(); } static Uint8 *EPOC_GetAudioBuf(SDL_AudioDevice* thisdevice) -- 2.11.4.GIT