From b2e2cd5d0e0a0b4ef66034f37448292f012eb032 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 9 Dec 2024 22:22:18 +0900 Subject: [PATCH] darwin: bug fix: race at a channel Closes #252 --- driver_darwin.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/driver_darwin.go b/driver_darwin.go index 9fc7865..36fa94a 100644 --- a/driver_darwin.go +++ b/driver_darwin.go @@ -125,8 +125,9 @@ func newContext(sampleRate int, channelCount int, format mux.Format, bufferSizeI runtime.LockOSThread() defer runtime.UnlockOSThread() + var readyClosed bool defer func() { - if ready != nil { + if !readyClosed { close(ready) } }() @@ -158,7 +159,7 @@ func newContext(sampleRate int, channelCount int, format mux.Format, bufferSizeI } close(ready) - ready = nil + readyClosed = true c.loop() }()