From 2e0c15bae76ec320faa06b81d11e35c0c71cd482 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Fri, 14 May 2021 19:04:54 +0200 Subject: [PATCH] sdl: fix audio recording --- core/oslib/audiobackend_sdl2.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/oslib/audiobackend_sdl2.cpp b/core/oslib/audiobackend_sdl2.cpp index 7a0244b05..9173e1b97 100644 --- a/core/oslib/audiobackend_sdl2.cpp +++ b/core/oslib/audiobackend_sdl2.cpp @@ -19,7 +19,7 @@ static struct { static unsigned sample_count = 0; static SDL_AudioDeviceID recorddev; -u8 recordbuf[480 * 2]; +u8 recordbuf[480 * 4]; std::atomic rec_read; std::atomic rec_write; @@ -195,6 +195,8 @@ static u32 sdl2_record(void* frame, u32 samples) while (samples > 0) { u32 avail = std::min(rec_write - rec_read, sizeof(recordbuf) - rec_read); + if (avail == 0) + break; avail = std::min(avail, samples); memcpy((u8 *)frame + count, &recordbuf[rec_read], avail); rec_read = (rec_read + avail) % sizeof(recordbuf);