mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 19:58:54 +01:00
audio/internal/readerdriver: Bug fix: Deadlock at resuming
This commit is contained in:
parent
fa13b81d38
commit
c85ef4e40b
@ -259,15 +259,20 @@ func (p *players) suspend() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *players) resume() error {
|
func (p *players) resume() error {
|
||||||
|
// playerImpl's Play can touch p. Avoid the deadlock.
|
||||||
p.m.Lock()
|
p.m.Lock()
|
||||||
defer p.m.Unlock()
|
players := map[*playerImpl]struct{}{}
|
||||||
|
|
||||||
for pl := range p.toResume {
|
for pl := range p.toResume {
|
||||||
|
players[pl] = struct{}{}
|
||||||
|
delete(p.toResume, pl)
|
||||||
|
}
|
||||||
|
p.m.Unlock()
|
||||||
|
|
||||||
|
for pl := range players {
|
||||||
pl.Play()
|
pl.Play()
|
||||||
if err := pl.Err(); err != nil {
|
if err := pl.Err(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
delete(p.toResume, pl)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user