Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
audio: fix crash on looped stream shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed May 5, 2024
1 parent 945ba57 commit e5b5d53
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/engine/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ bool Audio_Shutdown(void)
return false;
}

Audio_Sample_Shutdown();
Audio_Stream_Shutdown();

if (g_AudioDeviceID) {
SDL_PauseAudioDevice(g_AudioDeviceID, 1);
SDL_CloseAudioDevice(g_AudioDeviceID);
g_AudioDeviceID = 0;
}

Memory_FreePointer(&m_MixBuffer);

Audio_Sample_Shutdown();
Audio_Stream_Shutdown();
return true;
}

Expand Down
4 changes: 4 additions & 0 deletions src/engine/audio_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ bool Audio_Stream_Unpause(int32_t sound_id)

int32_t Audio_Stream_CreateFromFile(const char *file_path)
{
if (!g_AudioDeviceID) {
return AUDIO_NO_SOUND;
}

assert(file_path != NULL);

for (int32_t sound_id = 0; sound_id < AUDIO_MAX_ACTIVE_STREAMS;
Expand Down

0 comments on commit e5b5d53

Please sign in to comment.