audio/internal/readerdriver: Make Play async on Android

Updates #1549
This commit is contained in:
Hajime Hoshi 2021-05-16 20:10:29 +09:00
parent cf6edae5b3
commit d1138bc615

View File

@ -95,9 +95,20 @@ func (p *player) Pause() {
}
func (p *player) Play() {
p.cond.L.Lock()
defer p.cond.L.Unlock()
// Call Play asynchronously since Oboe's Play might take long.
ch := make(chan struct{})
go func() {
p.cond.L.Lock()
defer p.cond.L.Unlock()
close(ch)
p.playImpl()
}()
// Wait until the mutex is locked in the above goroutine.
<-ch
}
func (p *player) playImpl() {
if p.err != nil {
return
}