mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-24 18:02:02 +01:00
audio/interna/readerdriver: Bug fix: Potential issue when all the players were gone
When all the players were gone, the waveOut is closed once. From this state, playing an audio again might take long. This change fixes the issue by not closing the waveOut even when all the players are gone. This change also changes the returning value of read when the player doesn't play.
This commit is contained in:
parent
c3b8fa1c45
commit
6a8abac194
@ -178,27 +178,7 @@ func (p *players) removeImpl(player *playerImpl) error {
|
||||
if p.err != nil {
|
||||
return p.err
|
||||
}
|
||||
|
||||
delete(p.players, player)
|
||||
if len(p.players) > 0 {
|
||||
return nil
|
||||
}
|
||||
if p.waveOut == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, h := range p.headers {
|
||||
if err := h.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
p.headers = p.headers[:0]
|
||||
if err := waveOutClose(p.waveOut); err != nil {
|
||||
return err
|
||||
}
|
||||
p.waveOut = 0
|
||||
p.cond.Signal()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -616,12 +596,12 @@ func (p *playerImpl) read(buf []byte) int {
|
||||
defer p.m.Unlock()
|
||||
|
||||
if p.state != playerPlay {
|
||||
return len(buf)
|
||||
return 0
|
||||
}
|
||||
|
||||
if len(p.buf) == 0 && p.eof {
|
||||
p.pauseImpl()
|
||||
return len(buf)
|
||||
return 0
|
||||
}
|
||||
|
||||
if len(p.buf) < p.context.maxBufferSize() {
|
||||
|
Loading…
Reference in New Issue
Block a user