mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
audio: bug fix: potential busy reading after the source reaches EOF
Closes #2167 Updates hajimehoshi/oto#171
This commit is contained in:
parent
8b86751237
commit
d6e257084d
@ -221,9 +221,7 @@ func (p *playerImpl) playImpl() {
|
||||
}
|
||||
p.buf = append(p.buf, buf[:n]...)
|
||||
if err == io.EOF {
|
||||
if len(p.buf) == 0 {
|
||||
p.eof = true
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -367,6 +365,10 @@ func (p *playerImpl) readBufferAndAdd(buf []float32) int {
|
||||
copy(p.buf, p.buf[n*bitDepthInBytes:])
|
||||
p.buf = p.buf[:len(p.buf)-n*bitDepthInBytes]
|
||||
|
||||
if p.eof && len(p.buf) == 0 {
|
||||
p.state = playerPaused
|
||||
}
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
@ -404,9 +406,11 @@ func (p *playerImpl) readSourceToBuffer() {
|
||||
}
|
||||
|
||||
p.buf = append(p.buf, buf[:n]...)
|
||||
if err == io.EOF && len(p.buf) == 0 {
|
||||
p.state = playerPaused
|
||||
if err == io.EOF {
|
||||
p.eof = true
|
||||
if len(p.buf) == 0 {
|
||||
p.state = playerPaused
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
2
go.mod
2
go.mod
@ -8,7 +8,7 @@ require (
|
||||
github.com/hajimehoshi/bitmapfont/v2 v2.2.0
|
||||
github.com/hajimehoshi/file2byteslice v0.0.0-20210813153925-5340248a8f41
|
||||
github.com/hajimehoshi/go-mp3 v0.3.3
|
||||
github.com/hajimehoshi/oto/v2 v2.2.0-alpha.3
|
||||
github.com/hajimehoshi/oto/v2 v2.2.0-alpha.3.0.20220627134823-65dbd988610c
|
||||
github.com/jakecoffman/cp v1.2.0
|
||||
github.com/jezek/xgb v1.0.1
|
||||
github.com/jfreymuth/oggvorbis v1.0.3
|
||||
|
4
go.sum
4
go.sum
@ -11,8 +11,8 @@ github.com/hajimehoshi/go-mp3 v0.3.3 h1:cWnfRdpye2m9ElSoVqneYRcpt/l3ijttgjMeQh+r
|
||||
github.com/hajimehoshi/go-mp3 v0.3.3/go.mod h1:qMJj/CSDxx6CGHiZeCgbiq2DSUkbK0UbtXShQcnfyMM=
|
||||
github.com/hajimehoshi/oto v0.6.1 h1:7cJz/zRQV4aJvMSSRqzN2TImoVVMpE0BCY4nrNJaDOM=
|
||||
github.com/hajimehoshi/oto v0.6.1/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=
|
||||
github.com/hajimehoshi/oto/v2 v2.2.0-alpha.3 h1:hBxyR67t2ErMcF/aTxB8FOzMaBj+62T5RTgjfth6fXE=
|
||||
github.com/hajimehoshi/oto/v2 v2.2.0-alpha.3/go.mod h1:9i0oYbpJ8BhVGkXDKdXKfFthX1JUNfXjeTp944W8TGM=
|
||||
github.com/hajimehoshi/oto/v2 v2.2.0-alpha.3.0.20220627134823-65dbd988610c h1:hHMvizeDtTgaLcvh78CvzVi82yrYkUJsr81vfRBeeg0=
|
||||
github.com/hajimehoshi/oto/v2 v2.2.0-alpha.3.0.20220627134823-65dbd988610c/go.mod h1:9i0oYbpJ8BhVGkXDKdXKfFthX1JUNfXjeTp944W8TGM=
|
||||
github.com/jakecoffman/cp v1.2.0 h1:ZdCFqHglNYJibiIeRvpAktJ7ZuWUnh0cnBsZNKVbY3A=
|
||||
github.com/jakecoffman/cp v1.2.0/go.mod h1:JjY/Fp6d8E1CHnu74gWNnU0+b9VzEdUVPoJxg2PsTQg=
|
||||
github.com/jezek/xgb v1.0.1 h1:YUGhxps0aR7J2Xplbs23OHnV1mWaxFVcOl9b+1RQkt8=
|
||||
|
Loading…
Reference in New Issue
Block a user