From d6dee0815e31114d0be2a0e65315ce6d78f7010c Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 26 May 2016 03:13:56 +0900 Subject: [PATCH] audio: Bug fix: Avoid deadlock --- audio/internal/driver/driver_android.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/audio/internal/driver/driver_android.go b/audio/internal/driver/driver_android.go index 33db9a056..e2ea0e317 100644 --- a/audio/internal/driver/driver_android.go +++ b/audio/internal/driver/driver_android.go @@ -255,17 +255,16 @@ func NewPlayer(sampleRate, channelNum, bytesPerSample int) (*Player, error) { } func (p *Player) Proceed(data []byte) error { - select { - case err := <-p.chErr: - return err - default: - } p.buffer = append(p.buffer, data...) if len(p.buffer) < p.bufferSize { return nil } buf := p.buffer[:p.bufferSize] - p.chBuffer <- buf + select { + case p.chBuffer <- buf: + case err := <-p.chErr: + return err + } p.buffer = p.buffer[p.bufferSize:] return nil }