Skip to content

Commit

Permalink
[Nokia N-Gage] Fix audio deinit which caused an error message on exit…
Browse files Browse the repository at this point in the history
…. I forgot to add this when I prepared the PR.
  • Loading branch information
mupfdev committed Feb 1, 2025
1 parent ee4ffb4 commit 2e2a468
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
28 changes: 18 additions & 10 deletions src/audio/ngage/SDL_ngageaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -258,6 +261,7 @@ void CAudio::MaoscOpenComplete(TInt aError)
iStream->SetVolume(1);
iStreamStarted = ETrue;
StartThread();

}
else
{
Expand All @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
3 changes: 2 additions & 1 deletion src/audio/ngage/SDL_ngageaudio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class CAudio : public CActive, public MMdaAudioOutputStreamCallback
EStateNone = 0,
EStateOpening,
EStatePlaying,
EStateWriting
EStateWriting,
EStateDone
} iState;

private:
Expand Down

0 comments on commit 2e2a468

Please sign in to comment.