mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
audio: Bug fix: runningReadLoop must be set to true before starting the goroutine
This can cause deadlock by multiple goroutines if runningReadLoop is set to true in the goroutine. Related to #855?
This commit is contained in:
parent
89f6eba925
commit
d2979e288d
@ -375,6 +375,7 @@ func (p *playerImpl) ensureReadLoop() error {
|
||||
if p.runningReadLoop {
|
||||
return nil
|
||||
}
|
||||
p.runningReadLoop = true
|
||||
go p.readLoop()
|
||||
return nil
|
||||
}
|
||||
@ -417,9 +418,6 @@ func (p *playerImpl) Play() {
|
||||
}
|
||||
|
||||
func (p *playerImpl) readLoop() {
|
||||
p.m.Lock()
|
||||
p.runningReadLoop = true
|
||||
p.m.Unlock()
|
||||
defer func() {
|
||||
p.m.Lock()
|
||||
p.runningReadLoop = false
|
||||
|
Loading…
Reference in New Issue
Block a user