mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48: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)
|
n, err := p.src.Read(p.buf)
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
p.setError(err)
|
p.setErrorImpl(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
@ -243,7 +243,10 @@ func (p *Player) close(remove bool) error {
|
|||||||
func (p *Player) setError(err error) {
|
func (p *Player) setError(err error) {
|
||||||
p.cond.L.Lock()
|
p.cond.L.Lock()
|
||||||
defer p.cond.L.Unlock()
|
defer p.cond.L.Unlock()
|
||||||
|
p.setErrorImpl(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Player) setErrorImpl(err error) {
|
||||||
if p.state != playerStateClosed && p.v.Truthy() {
|
if p.state != playerStateClosed && p.v.Truthy() {
|
||||||
p.v.Call("close", true)
|
p.v.Call("close", true)
|
||||||
p.v = js.Undefined()
|
p.v = js.Undefined()
|
||||||
|
Loading…
Reference in New Issue
Block a user