From 5de3f8e9afea0aa8b64b4d24e4516eb3efa82b8d Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 9 Oct 2023 00:15:21 +0400 Subject: [PATCH] In oggtag.go bufTail was renamed to a more suitable bufLast. --- pkg/oggtag/oggtag.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/oggtag/oggtag.go b/pkg/oggtag/oggtag.go index df45911..dc43de0 100644 --- a/pkg/oggtag/oggtag.go +++ b/pkg/oggtag/oggtag.go @@ -22,7 +22,7 @@ const ( // OggFile holds a head of a file and a tail part conatining last granule. type OggFile struct { - bufHead, bufTail []byte + bufHead, bufLast []byte } // NewOggFile reads a file and returns a new OggFile. @@ -41,7 +41,7 @@ func NewOggFile(path string) (*OggFile, error) { return nil, err } - of.bufTail = make([]byte, bufferLength) + of.bufLast = make([]byte, bufferLength) if _, err := f.Seek(-bufferLength, io.SeekEnd); err != nil { return nil, err @@ -57,11 +57,11 @@ func NewOggFile(path string) (*OggFile, error) { return nil, err } - if _, err := f.Read(of.bufTail); err != nil { + if _, err := f.Read(of.bufLast); err != nil { return nil, err } - if bytes.Contains(of.bufTail, []byte(OggS)) { + if bytes.Contains(of.bufLast, []byte(OggS)) { break } } @@ -94,9 +94,9 @@ func (of *OggFile) GetDuration() time.Duration { rate := int32(rateBytes[0]) + int32(rateBytes[1])<<8 + int32(rateBytes[2])<<16 + int32(rateBytes[3])<<24 - granuleIdx := bytes.LastIndex(of.bufTail, []byte(OggS)) + + granuleIdx := bytes.LastIndex(of.bufLast, []byte(OggS)) + OggSLen + 2 - granuleBytes := of.bufTail[granuleIdx : granuleIdx+8] + granuleBytes := of.bufLast[granuleIdx : granuleIdx+8] granule := int64(granuleBytes[0]) + int64(granuleBytes[1])<<8 + int64(granuleBytes[2])<<16 + int64(granuleBytes[3])<<24 + int64(granuleBytes[4])<<32 + int64(granuleBytes[5])<<40 +