mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
audio: Bug fix: Avoid deadlock
This commit is contained in:
parent
644dfcd0fd
commit
d6dee0815e
@ -255,17 +255,16 @@ func NewPlayer(sampleRate, channelNum, bytesPerSample int) (*Player, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Player) Proceed(data []byte) error {
|
func (p *Player) Proceed(data []byte) error {
|
||||||
select {
|
|
||||||
case err := <-p.chErr:
|
|
||||||
return err
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
p.buffer = append(p.buffer, data...)
|
p.buffer = append(p.buffer, data...)
|
||||||
if len(p.buffer) < p.bufferSize {
|
if len(p.buffer) < p.bufferSize {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
buf := p.buffer[:p.bufferSize]
|
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:]
|
p.buffer = p.buffer[p.bufferSize:]
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user