diff --git a/flac.go b/flac.go index e87fa9c..20d4531 100644 --- a/flac.go +++ b/flac.go @@ -343,7 +343,7 @@ func (stream *Stream) Seek(sampleNum uint64) (uint64, error) { if err != nil { return 0, err } - if frame.SampleNumber()+uint64(frame.BlockSize) >= sampleNum { + if frame.SampleNumber()+uint64(frame.BlockSize) > sampleNum { // Restore seek offset to the start of the frame containing the // specified sample number. _, err := rs.Seek(offset, io.SeekStart) diff --git a/flac_test.go b/flac_test.go index 231f648..d373a4d 100644 --- a/flac_test.go +++ b/flac_test.go @@ -48,6 +48,8 @@ func TestSeek(t *testing.T) { {seek: 0, expected: 0}, {seek: 50000, expected: 0, err: "unable to seek to sample number 50000"}, {seek: 100, expected: 0}, + {seek: 8192, expected: 8192}, + {seek: 8191, expected: 4096}, } stream, err := flac.NewSeek(f)