Skip to content

Commit

Permalink
Fix seek to frame start (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkKremer authored Aug 3, 2024
1 parent c38ea50 commit 2d14ac8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flac.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions flac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2d14ac8

Please sign in to comment.