Skip to content

Commit

Permalink
Track bytesReadSuccesfully in oggreader
Browse files Browse the repository at this point in the history
  • Loading branch information
Kostassoid authored and edaniels committed Jun 25, 2024
1 parent 1bb9fa9 commit fc3521e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/media/oggreader/oggreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ func (o *OggReader) ParseNextPage() ([]byte, *OggPageHeader, error) {
}
}

o.bytesReadSuccesfully += int64(len(h) + len(sizeBuffer) + len(payload))

return payload, pageHeader, nil
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/media/oggreader/oggreader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ func TestOggReader_ParseNextPage(t *testing.T) {
reader, _, err := NewWith(ogg)
assert.NoError(t, err)
assert.NotNil(t, reader)
assert.Equal(t, int64(47), reader.bytesReadSuccesfully)

payload, _, err := reader.ParseNextPage()
assert.Equal(t, []byte{0x98, 0x36, 0xbe, 0x88, 0x9e}, payload)
assert.NoError(t, err)
assert.Equal(t, int64(80), reader.bytesReadSuccesfully)

_, _, err = reader.ParseNextPage()
assert.Equal(t, err, io.EOF)
Expand Down

0 comments on commit fc3521e

Please sign in to comment.