From 080fde08b6fd0f4bc2af05345c8dd2f1ef239cce Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 22 Jun 2019 19:01:35 +0300 Subject: [PATCH] Improve audio quality on the SDL port by being more forgiving to system with bigger buffer sizes --- SDL/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/SDL/main.c b/SDL/main.c index 9dbea9b..e0b40e8 100755 --- a/SDL/main.c +++ b/SDL/main.c @@ -33,7 +33,6 @@ static double clock_mutliplier = 1.0; static char *filename = NULL; static typeof(free) *free_function = NULL; static char *battery_save_path_ptr; -static bool skip_audio; SDL_AudioDeviceID device_id; @@ -337,8 +336,6 @@ static void vblank(GB_gameboy_t *gb) } do_rewind = rewind_down; handle_events(gb); - - skip_audio = (SDL_GetQueuedAudioSize(device_id) / sizeof(GB_sample_t)) > have_aspec.freq / 20; } @@ -360,7 +357,9 @@ static void debugger_interrupt(int ignore) static void gb_audio_callback(GB_gameboy_t *gb, GB_sample_t *sample) { - if (skip_audio) return; + if ((SDL_GetQueuedAudioSize(device_id) / sizeof(GB_sample_t)) > have_aspec.freq / 12) { + return; + } SDL_QueueAudio(device_id, sample, sizeof(*sample)); }