Skip to content

Commit 2e2a468

Browse files
committed
[Nokia N-Gage] Fix audio deinit which caused an error message on exit. I forgot to add this when I prepared the PR.
1 parent ee4ffb4 commit 2e2a468

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/audio/ngage/SDL_ngageaudio.cpp

+18-10
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,15 @@ void CAudio::ConstructL(TInt aLatency)
7575

7676
CAudio::~CAudio()
7777
{
78-
Cancel();
79-
StopThread();
80-
8178
if (iStream)
8279
{
8380
iStream->Stop();
81+
82+
while (iState != EStateDone)
83+
{
84+
User::After(100000); // 100ms.
85+
}
86+
8487
delete iStream;
8588
}
8689
}
@@ -258,6 +261,7 @@ void CAudio::MaoscOpenComplete(TInt aError)
258261
iStream->SetVolume(1);
259262
iStreamStarted = ETrue;
260263
StartThread();
264+
261265
}
262266
else
263267
{
@@ -274,8 +278,8 @@ void CAudio::MaoscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/)
274278
}
275279
else if (aError == KErrAbort)
276280
{
277-
Cancel();
278-
iState = EStateNone;
281+
// The stream has been stopped.
282+
iState = EStateDone;
279283
}
280284
else
281285
{
@@ -303,11 +307,15 @@ void CAudio::MaoscPlayComplete(TInt aError)
303307
iState = EStatePlaying;
304308
Feed();
305309
return;
310+
306311
}
307312
else if (aError != KErrNone)
308313
{
309314
// Handle error.
310315
}
316+
317+
// We shouldn't get here.
318+
SDL_Log("%s: %d", __FUNCTION__, aError);
311319
}
312320

313321
static TBool gAudioRunning;
@@ -390,13 +398,13 @@ void InitAudio(TInt* aLatency)
390398

391399
void DeinitAudio()
392400
{
393-
gAudioRunning = EFalse;
401+
gAudioRunning = EFalse;
394402

395-
TRequestStatus status;
396-
audioThread.Logon(status);
397-
User::WaitForRequest(status);
403+
TRequestStatus status;
404+
audioThread.Logon(status);
405+
User::WaitForRequest(status);
398406

399-
audioThread.Close();
407+
audioThread.Close();
400408
}
401409

402410
#endif // SDL_AUDIO_DRIVER_NGAGE

src/audio/ngage/SDL_ngageaudio.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ class CAudio : public CActive, public MMdaAudioOutputStreamCallback
6666
EStateNone = 0,
6767
EStateOpening,
6868
EStatePlaying,
69-
EStateWriting
69+
EStateWriting,
70+
EStateDone
7071
} iState;
7172

7273
private:

0 commit comments

Comments
 (0)