Skip to content

Commit af97c17

Browse files
authored
fix: Properly shutdown AudioUnit on macOS to avoid crash on exit (#419)
1 parent 7c3eb14 commit af97c17

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cute_sound.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,6 +1918,14 @@ void cs_shutdown()
19181918
IDirectSoundBuffer_Release(s_ctx->dsound);
19191919

19201920
#elif CUTE_SOUND_PLATFORM == CUTE_SOUND_APPLE
1921+
1922+
if (s_ctx->inst) {
1923+
AudioOutputUnitStop(s_ctx->inst);
1924+
AudioUnitUninitialize(s_ctx->inst);
1925+
AudioComponentInstanceDispose(s_ctx->inst);
1926+
s_ctx->inst = NULL;
1927+
}
1928+
pthread_mutex_destroy(&s_ctx->mutex);
19211929
#elif CUTE_SOUND_PLATFORM == CUTE_SOUND_SDL
19221930

19231931
SDL_DestroyMutex(s_ctx->mutex);

0 commit comments

Comments
 (0)