audio: pair locks with defer and move the disposal of a context to audio.go
This commit is contained in:
1 parent
8198c5c4b3
commit
4300b92d4b
3 files changed
+35
-24
No files matched your search
@@ -233,6 +233,19 @@ func (c *Context) waitForPlayingPlayers() bool {
|
||||
return !c.disposed
|
||||
}
|
||||
|
||||
// dispose makes the goroutine updating the players exit, and waits for it to exit.
|
||||
func (c *Context) dispose() {
|
||||
c.markDisposed()
|
||||
c.updater.Wait()
|
||||
}
|
||||
|
||||
func (c *Context) markDisposed() {
|
||||
c.m.Lock()
|
||||
defer c.m.Unlock()
|
||||
c.disposed = true
|
||||
c.cond.Broadcast()
|
||||
}
|
||||
|
||||
func (c *Context) addPlayingPlayer(p *playerImpl) {
|
||||
c.m.Lock()
|
||||
defer c.m.Unlock()
|
||||
|
||||
Reference in new issue
Block a user