git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

commit 8fa02e0ea2b4bbb8c0cdc735663a327377662264
parent 7a24073f6d6376b3279ca030c82f0f57144707cf
Author: Maximilian Mader <max@bastelstu.be>
Date:   Wed, 13 Jul 2022 15:54:57 +0200

Make sure that audio resumes playing after clearing the queue

Diffstat:
MSDL/audio/openal.c30+++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/SDL/audio/openal.c b/SDL/audio/openal.c @@ -119,17 +119,6 @@ static bool _audio_is_playing(void) return state == AL_PLAYING; } -static void _audio_clear_queue(void) -{ - alSourceStop(al_source); - if (AL_ERROR(NULL)) { - _audio_deinit(); - return; - } - - free_processed_buffers(); -} - static void _audio_set_paused(bool paused) { if (paused) { @@ -144,6 +133,25 @@ static void _audio_set_paused(bool paused) } } +static void _audio_clear_queue(void) +{ + bool is_playing = _audio_is_playing(); + + // Stopping a source clears its queue + alSourceStop(al_source); + if (AL_ERROR(NULL)) { + _audio_deinit(); + return; + } + + free_processed_buffers(); + buffer_pos = 0; + + if (is_playing) { + _audio_set_paused(false); + } +} + static unsigned _audio_get_frequency(void) { return sample_rate;

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.