From 370f02661dbeb169a83f8a9c1cd17c41ad87bf00 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 8 Feb 2020 12:31:06 +0200 Subject: [PATCH] Deadlock fix --- Cocoa/Document.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Cocoa/Document.m b/Cocoa/Document.m index d8fb71fa..e74b24f6 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -281,6 +281,10 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample) GB_set_sample_rate(&gb, 96000); self.audioClient = [[GBAudioClient alloc] initWithRendererBlock:^(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer) { [audioLock lock]; + if (stopping) { + memset(buffer, 0, nFrames * sizeof(*buffer)); + [audioLock unlock]; + } if (audioBufferPosition < nFrames) { audioBufferNeeded = nFrames;