audio: rename the context disposal to close, like the other unexported close methods

This commit is contained in:
dualfroz committed 2026-10-05 16:19:48 +02:00
1 parent 4300b92d4b
commit ecb0c10f07
2 files changed
+12 -12

No files matched your search

+11 -11
View File
@@ -74,12 +74,12 @@ type Context struct {
m sync.Mutex m sync.Mutex
// cond is signalled under m when a player is added to playingPlayers or when the context is // 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 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. // 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 // updater tracks the goroutine updating the players, so that a test discarding the context can wait
// for the goroutine to exit. // 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 // 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 { func (c *Context) waitForPlayingPlayers() bool {
c.m.Lock() c.m.Lock()
defer c.m.Unlock() defer c.m.Unlock()
for len(c.playingPlayers) == 0 && !c.disposed { for len(c.playingPlayers) == 0 && !c.closed {
c.cond.Wait() c.cond.Wait()
} }
return !c.disposed return !c.closed
} }
// dispose makes the goroutine updating the players exit, and waits for it to exit. // close makes the goroutine updating the players exit, and waits for it to exit.
func (c *Context) dispose() { func (c *Context) close() {
c.markDisposed() c.markClosed()
c.updater.Wait() c.updater.Wait()
} }
func (c *Context) markDisposed() { func (c *Context) markClosed() {
c.m.Lock() c.m.Lock()
defer c.m.Unlock() defer c.m.Unlock()
c.disposed = true c.closed = true
c.cond.Broadcast() c.cond.Broadcast()
} }
+1 -1
View File
@@ -356,7 +356,7 @@ func ContextCreatedForTesting() bool {
// players' sources, and waits for them to exit. // players' sources, and waits for them to exit.
func ResetContextForTesting() { func ResetContextForTesting() {
if c := takeContextForTesting(); c != nil { if c := takeContextForTesting(); c != nil {
c.dispose() c.close()
} }
dummyContextForTesting.stopPlayers() dummyContextForTesting.stopPlayers()
} }