Skip to content

Commit

Permalink
darwin: bug fix: race at a channel
Browse files Browse the repository at this point in the history
Closes #252
  • Loading branch information
hajimehoshi committed Dec 9, 2024
1 parent 95db1d7 commit b2e2cd5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions driver_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}()
Expand Down Expand Up @@ -158,7 +159,7 @@ func newContext(sampleRate int, channelCount int, format mux.Format, bufferSizeI
}

close(ready)
ready = nil
readyClosed = true

c.loop()
}()
Expand Down

0 comments on commit b2e2cd5

Please sign in to comment.