In oggtag.go bufTail was renamed to a more suitable bufLast.
This commit is contained in:
parent
3ba47c2d41
commit
5de3f8e9af
@ -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 +
|
||||
|
Loading…
Reference in New Issue
Block a user