From 296c69b4faad71539aa784baa69af0355563f8d0 Mon Sep 17 00:00:00 2001 From: Michael Fitzmayer Date: Sat, 1 Feb 2025 23:58:21 +0100 Subject: [PATCH] [Nokia N-Gage] Fix audio deinit which caused an error message on exit. I forgot to add this when I prepared the PR. --- src/audio/ngage/SDL_ngageaudio.cpp | 28 ++++++++++++++++++---------- src/audio/ngage/SDL_ngageaudio.hpp | 3 ++- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/audio/ngage/SDL_ngageaudio.cpp b/src/audio/ngage/SDL_ngageaudio.cpp index 519904eec91383..0a749a5c1a45b1 100644 --- a/src/audio/ngage/SDL_ngageaudio.cpp +++ b/src/audio/ngage/SDL_ngageaudio.cpp @@ -75,12 +75,15 @@ void CAudio::ConstructL(TInt aLatency) CAudio::~CAudio() { - Cancel(); - StopThread(); - if (iStream) { iStream->Stop(); + + while (iState != EStateDone) + { + User::After(100000); // 100ms. + } + delete iStream; } } @@ -258,6 +261,7 @@ void CAudio::MaoscOpenComplete(TInt aError) iStream->SetVolume(1); iStreamStarted = ETrue; StartThread(); + } else { @@ -274,8 +278,8 @@ void CAudio::MaoscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/) } else if (aError == KErrAbort) { - Cancel(); - iState = EStateNone; + // The stream has been stopped. + iState = EStateDone; } else { @@ -303,11 +307,15 @@ void CAudio::MaoscPlayComplete(TInt aError) iState = EStatePlaying; Feed(); return; + } else if (aError != KErrNone) { // Handle error. } + + // We shouldn't get here. + SDL_Log("%s: %d", __FUNCTION__, aError); } static TBool gAudioRunning; @@ -390,13 +398,13 @@ void InitAudio(TInt* aLatency) void DeinitAudio() { - gAudioRunning = EFalse; + gAudioRunning = EFalse; - TRequestStatus status; - audioThread.Logon(status); - User::WaitForRequest(status); + TRequestStatus status; + audioThread.Logon(status); + User::WaitForRequest(status); - audioThread.Close(); + audioThread.Close(); } #endif // SDL_AUDIO_DRIVER_NGAGE diff --git a/src/audio/ngage/SDL_ngageaudio.hpp b/src/audio/ngage/SDL_ngageaudio.hpp index 877ed76bb80c23..11ebea074f0f7f 100644 --- a/src/audio/ngage/SDL_ngageaudio.hpp +++ b/src/audio/ngage/SDL_ngageaudio.hpp @@ -66,7 +66,8 @@ class CAudio : public CActive, public MMdaAudioOutputStreamCallback EStateNone = 0, EStateOpening, EStatePlaying, - EStateWriting + EStateWriting, + EStateDone } iState; private: