Join capture worker before stopping OpenAL

This commit is contained in:
Brandon McGinty (chatgpt) authored and Brandon McGinty committed 2026-08-09 15:09:39 -04:00
1 parent 28a59832c4
commit cc62f8e4a7
3 files changed
+38 -11

No files matched your search

@@ -4,6 +4,22 @@ import "testing"
// Regression: audio cleanup could send a final render command after Destroy
// had closed renderCh, panicking instead of safely discarding that work.
// Regression: StopSource returned before the capture worker ended, allowing
// Destroy to close the device while that worker still used it.
func TestStopSourceWaitsForWorker(t *testing.T) {
stop, done := make(chan bool), make(chan struct{})
s := &Stream{sourceStop: stop, sourceDone: done}
returned := make(chan struct{})
go func() { _ = s.StopSource(); close(returned) }()
select {
case <-returned:
t.Fatal("StopSource returned before worker")
default:
}
close(done)
<-returned
}
func TestRenderRejectsWorkAfterShutdown(t *testing.T) {
s := &Stream{renderClosed: true}
called := false