From fc5970768d63f611cbdaf63750311bea846e3af9 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 3 May 2021 17:54:22 +0900 Subject: [PATCH] audio/internal/go2cpp: Bug fix: Potential deadlock at Play Closes #1629 --- audio/internal/go2cpp/player_js.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/audio/internal/go2cpp/player_js.go b/audio/internal/go2cpp/player_js.go index 8102c2cda..b9c1a4cc8 100644 --- a/audio/internal/go2cpp/player_js.go +++ b/audio/internal/go2cpp/player_js.go @@ -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()