From cd6d3b4f7d9f8d44bdfab7178d0b26ba96d57861 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Mon, 24 Jun 2024 15:44:47 +0200 Subject: [PATCH] Track bytesReadSuccesfully in oggreader --- pkg/media/oggreader/oggreader.go | 2 ++ pkg/media/oggreader/oggreader_test.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pkg/media/oggreader/oggreader.go b/pkg/media/oggreader/oggreader.go index 50d1a7cd87b..5aaeb8b94eb 100644 --- a/pkg/media/oggreader/oggreader.go +++ b/pkg/media/oggreader/oggreader.go @@ -189,6 +189,8 @@ func (o *OggReader) ParseNextPage() ([]byte, *OggPageHeader, error) { } } + o.bytesReadSuccesfully += int64(len(h) + len(sizeBuffer) + len(payload)) + return payload, pageHeader, nil } diff --git a/pkg/media/oggreader/oggreader_test.go b/pkg/media/oggreader/oggreader_test.go index 787f5573b4e..cbb151e9e5f 100644 --- a/pkg/media/oggreader/oggreader_test.go +++ b/pkg/media/oggreader/oggreader_test.go @@ -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)