mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
audio: Bug fix: mixedPlayersStream.Read must return 0 when nothing plays (#180)
This commit is contained in:
parent
b1568e19cb
commit
bcd7bfc74e
@ -33,22 +33,13 @@ func min(a, b int) int {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
func max(a, b int) int {
|
|
||||||
if a > b {
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *mixedPlayersStream) Read(b []byte) (int, error) {
|
func (s *mixedPlayersStream) Read(b []byte) (int, error) {
|
||||||
s.context.Lock()
|
s.context.Lock()
|
||||||
defer s.context.Unlock()
|
defer s.context.Unlock()
|
||||||
|
|
||||||
l := len(b) / 4 * 4
|
l := len(b) / 4 * 4
|
||||||
if len(s.context.players) == 0 {
|
if len(s.context.players) == 0 {
|
||||||
ll := min(4096, len(b))
|
return 0, nil
|
||||||
copy(b, make([]byte, ll))
|
|
||||||
return ll, nil
|
|
||||||
}
|
}
|
||||||
closed := []*Player{}
|
closed := []*Player{}
|
||||||
ll := l
|
ll := l
|
||||||
|
Loading…
Reference in New Issue
Block a user