From 78b552fe822e54140f4d52942fb955fe995e7b34 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Fri, 6 Mar 2020 17:37:04 +0200 Subject: [PATCH] More attempts to fix this bug --- Cocoa/Document.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Cocoa/Document.m b/Cocoa/Document.m index 03d4acd..8264fb3 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -318,6 +318,7 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample) if (stopping) { memset(buffer, 0, nFrames * sizeof(*buffer)); [audioLock unlock]; + return; } if (audioBufferPosition >= nFrames && audioBufferPosition < nFrames + 4800) { @@ -380,7 +381,11 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample) [audioLock signal]; [audioLock unlock]; running = false; - while (stopping); + while (stopping) { + [audioLock lock]; + [audioLock signal]; + [audioLock unlock]; + } GB_debugger_set_disabled(&gb, false); }