audio/wav: Bug fix: seek correctly when using io.SeekEnd

This commit is contained in:
Hajime Hoshi 2017-01-16 22:29:20 +09:00
parent 2439d407df
commit 244d8204c5

View File

@ -74,8 +74,13 @@ func (s *stream) Read(p []byte) (int, error) {
// Seek is implementation of io.Seeker's Seek. // Seek is implementation of io.Seeker's Seek.
func (s *stream) Seek(offset int64, whence int) (int64, error) { func (s *stream) Seek(offset int64, whence int) (int64, error) {
if whence == io.SeekStart { switch whence {
offset += s.headerSize case io.SeekStart:
offset = offset + s.headerSize
case io.SeekCurrent:
case io.SeekEnd:
offset = s.headerSize + s.dataSize + offset
whence = io.SeekStart
} }
n, err := s.src.Seek(offset, whence) n, err := s.src.Seek(offset, whence)
if err != nil { if err != nil {