From ecb0c10f071f02de36cdb3ee081d9694128b3ecd Mon Sep 17 00:00:00 2001 From: DualFroz Date: Mon, 5 Oct 2026 16:19:48 +0200 Subject: [PATCH] audio: rename the context disposal to close, like the other unexported close methods --- audio/audio.go | 22 +++++++++++----------- audio/export_test.go | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/audio/audio.go b/audio/audio.go index a7a9f4c..d4ac420 100644 --- a/audio/audio.go +++ b/audio/audio.go @@ -74,12 +74,12 @@ type Context struct { m sync.Mutex // cond is signalled under m when a player is added to playingPlayers or when the context is - // disposed. The goroutine updating the players waits on it while playingPlayers is empty. + // closed. The goroutine updating the players waits on it while playingPlayers is empty. cond *sync.Cond - // disposed reports that the goroutine updating the players must exit. A context lives until the + // closed reports that the goroutine updating the players must exit. A context lives until the // process exits, so this is set only when a test discards the context. - disposed bool + closed bool // updater tracks the goroutine updating the players, so that a test discarding the context can wait // for the goroutine to exit. @@ -223,26 +223,26 @@ func (c *Context) setReady() { } // waitForPlayingPlayers blocks until at least one player is registered as playing, and reports -// whether the players should be updated. It returns false once the context is disposed. +// whether the players should be updated. It returns false once the context is closed. func (c *Context) waitForPlayingPlayers() bool { c.m.Lock() defer c.m.Unlock() - for len(c.playingPlayers) == 0 && !c.disposed { + for len(c.playingPlayers) == 0 && !c.closed { c.cond.Wait() } - return !c.disposed + return !c.closed } -// dispose makes the goroutine updating the players exit, and waits for it to exit. -func (c *Context) dispose() { - c.markDisposed() +// close makes the goroutine updating the players exit, and waits for it to exit. +func (c *Context) close() { + c.markClosed() c.updater.Wait() } -func (c *Context) markDisposed() { +func (c *Context) markClosed() { c.m.Lock() defer c.m.Unlock() - c.disposed = true + c.closed = true c.cond.Broadcast() } diff --git a/audio/export_test.go b/audio/export_test.go index 82abad6..1591038 100644 --- a/audio/export_test.go +++ b/audio/export_test.go @@ -356,7 +356,7 @@ func ContextCreatedForTesting() bool { // players' sources, and waits for them to exit. func ResetContextForTesting() { if c := takeContextForTesting(); c != nil { - c.dispose() + c.close() } dummyContextForTesting.stopPlayers() }