audio: Bug fix: Fix Seek: wav file can have a tail

This commit is contained in:
Hajime Hoshi 2017-01-15 01:30:28 +09:00
parent f78f4002fa
commit ee3da352db

View File

@ -57,6 +57,11 @@ func (s *Stream) Seek(offset int64, whence int) (int64, error) {
return 0, fmt.Errorf("wav: invalid offset")
}
s.remaining = s.dataSize - (n - s.headerSize)
// There could be a tail in wav file.
if s.remaining < 0 {
s.remaining = 0
return s.dataSize, nil
}
return n - s.headerSize, nil
}