Skip to content

Commit 18f6db1

Browse files
committed
Fix SDL mixer guards and cleanup
1 parent 1cc6d57 commit 18f6db1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/syscall_sdl.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,8 +849,10 @@ static void play_sfx(riscv_t *rv)
849849
* after sfx_handler return, thus we have to join them. sfx_handler does not
850850
* contain infinite loop,so do not worry to be stalled by it */
851851
#ifdef __EMSCRIPTEN__
852+
#if RV32_HAS(SDL_MIXER)
852853
pthread_join(sfx_thread, NULL);
853854
#endif
855+
#endif
854856
}
855857

856858
static void play_music(riscv_t *rv)
@@ -908,8 +910,10 @@ static void play_music(riscv_t *rv)
908910
* after music_handler return, thus we have to join them. music_handler does
909911
* not contain infinite loop,so do not worry to be stalled by it */
910912
#ifdef __EMSCRIPTEN__
913+
#if RV32_HAS(SDL_MIXER)
911914
pthread_join(music_thread, NULL);
912915
#endif
916+
#endif
913917
}
914918

915919
static void stop_music()
@@ -981,14 +985,17 @@ static void shutdown_audio()
981985
pthread_join(sfx_thread, NULL);
982986
Mix_HaltChannel(-1);
983987
Mix_FreeChunk(sfx_chunk);
984-
free(sfx_samples);
985-
sfx_samples = NULL;
986988
}
987989

988990
Mix_CloseAudio();
989991
Mix_Quit();
990992
#endif
991993

994+
if (sfx_samples) {
995+
free(sfx_samples);
996+
sfx_samples = NULL;
997+
}
998+
992999
audio_init = sfx_thread_init = music_thread_init = false;
9931000
}
9941001

0 commit comments

Comments
 (0)