From 1154914e9a096179d6c91be2616a6dac642a4311 Mon Sep 17 00:00:00 2001 From: KingOfSpadesJFK Date: Tue, 17 Oct 2023 18:45:27 -0700 Subject: [PATCH] moved call to audio_game_loop_tick() to the audio thread --- src/game/game_init.c | 2 +- src/pc/pc_main.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/game/game_init.c b/src/game/game_init.c index c2df4510..3663e784 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c @@ -591,7 +591,7 @@ void game_loop_one_iteration(void) { osContStartReadData(&gSIEventMesgQueue); } - audio_game_loop_tick(); + // audio_game_loop_tick(); config_gfx_pool(); read_controller_inputs(); levelCommandAddr = level_script_execute(levelCommandAddr); diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 76717a69..35622fb5 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -65,6 +65,7 @@ bool audio_thread_running = false; extern void gfx_run(Gfx *commands); extern void thread5_game_loop(void *arg); +extern void audio_game_loop_tick(void); extern void create_next_audio_buffer(s16 *samples, u32 num_samples); void game_loop_one_iteration(void); void* audio_thread(); @@ -101,7 +102,7 @@ void produce_one_frame(void) { } // Seperate the audio thread from the main thread so that your ears won't bleed at a low framerate -// FIXME: Chance of a segfault when teleporting to a new level +// FIXME: Low but comman chance of a segfault when teleporting to a new level void* audio_thread() { const long framerateNano = 33333333L; // 33.333333 ms = 30 fps; run this thread 30 times a second like the original game int napResult = 0; @@ -114,6 +115,8 @@ void* audio_thread() { set_sequence_player_volume(SEQ_PLAYER_SFX, (f32)configSfxVolume / 127.0f * master_mod); set_sequence_player_volume(SEQ_PLAYER_ENV, (f32)configEnvVolume / 127.0f * master_mod); + audio_game_loop_tick(); + int samples_left = audio_api->buffered(); u32 num_audio_samples = samples_left < audio_api->get_desired_buffered() ? SAMPLES_HIGH : SAMPLES_LOW; // printf("Audio samples: %d %u\n", samples_left, num_audio_samples);