mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
audio/internal/go2cpp: Bug fix: Potential deadlock at Play
Closes #1629
This commit is contained in:
parent
bea5ab3335
commit
fc5970768d
@ -138,7 +138,7 @@ func (p *Player) Play() {
|
||||
}
|
||||
n, err := p.src.Read(p.buf)
|
||||
if err != nil && err != io.EOF {
|
||||
p.setError(err)
|
||||
p.setErrorImpl(err)
|
||||
return
|
||||
}
|
||||
if n > 0 {
|
||||
@ -243,7 +243,10 @@ func (p *Player) close(remove bool) error {
|
||||
func (p *Player) setError(err error) {
|
||||
p.cond.L.Lock()
|
||||
defer p.cond.L.Unlock()
|
||||
p.setErrorImpl(err)
|
||||
}
|
||||
|
||||
func (p *Player) setErrorImpl(err error) {
|
||||
if p.state != playerStateClosed && p.v.Truthy() {
|
||||
p.v.Call("close", true)
|
||||
p.v = js.Undefined()
|
||||
|
Loading…
Reference in New Issue
Block a user