audio: mixedPlayingStream returns empty 0s again

This commit is contained in:
Hajime Hoshi 2016-03-05 22:42:16 +09:00
parent d33bb06f1d
commit 8631fbc027

View File

@ -43,11 +43,13 @@ 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 {
return 0, nil
ll := min(4096, len(b))
copy(b, make([]byte, ll))
return ll, nil
}
closed := []*Player{}
l := len(b) / 4 * 4
bb := make([]byte, l)
ll := l
for p := range s.context.players {
@ -57,9 +59,7 @@ func (s *mixedPlayersStream) Read(b []byte) (int, error) {
}
if err == io.EOF {
closed = append(closed, p)
continue
}
if err != nil {
} else if err != nil {
return 0, err
}
ll = min(len(p.buf)/4*4, ll)