audio: Bug fix: mixedPlayersStream.Read must return 0 when nothing plays (#180)

This commit is contained in:
Hajime Hoshi 2016-03-11 04:17:19 +09:00
parent b1568e19cb
commit bcd7bfc74e

View File

@ -33,22 +33,13 @@ func min(a, b int) int {
return b
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
func (s *mixedPlayersStream) Read(b []byte) (int, error) {
s.context.Lock()
defer s.context.Unlock()
l := len(b) / 4 * 4
if len(s.context.players) == 0 {
ll := min(4096, len(b))
copy(b, make([]byte, ll))
return ll, nil
return 0, nil
}
closed := []*Player{}
ll := l