audio: mixedPlayerStream.Read now may return 0 byte result

This commit is contained in:
Hajime Hoshi 2016-03-05 20:09:29 +09:00
parent 976d61816c
commit 6d85d82c85

View File

@ -43,13 +43,12 @@ 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
if len(s.context.players) == 0 { if len(s.context.players) == 0 {
copy(b, make([]byte, l)) return 0, nil
return l, nil
} }
closed := []*Player{} closed := []*Player{}
bb := make([]byte, max(1024, l)) l := len(b) / 4 * 4
bb := make([]byte, l)
ll := l ll := l
for p := range s.context.players { for p := range s.context.players {
n, err := p.src.Read(bb) n, err := p.src.Read(bb)