From d4cd06c6647bdf4f2a835b52295131040b7e2c3d Mon Sep 17 00:00:00 2001 From: Wessie Date: Wed, 29 May 2024 23:41:48 +0100 Subject: [PATCH] streamer/audio: fix nil int --- streamer/audio/mp3_buffer.go | 5 ++++ streamer/audio/replaygaintest/main.go | 34 --------------------------- 2 files changed, 5 insertions(+), 34 deletions(-) delete mode 100644 streamer/audio/replaygaintest/main.go diff --git a/streamer/audio/mp3_buffer.go b/streamer/audio/mp3_buffer.go index 03e5554d..0c669150 100644 --- a/streamer/audio/mp3_buffer.go +++ b/streamer/audio/mp3_buffer.go @@ -116,6 +116,11 @@ func (mb *MP3Buffer) Reader() (*MP3Reader, error) { } func newMP3Reader(mbr *MemoryReader, length *atomic.Int64) *MP3Reader { + if length == nil { + length = new(atomic.Int64) + // TODO: add an estimated length calculation + } + var frame mp3.Frame return &MP3Reader{ diff --git a/streamer/audio/replaygaintest/main.go b/streamer/audio/replaygaintest/main.go deleted file mode 100644 index 93d3fe4b..00000000 --- a/streamer/audio/replaygaintest/main.go +++ /dev/null @@ -1,34 +0,0 @@ -package main - -import ( - "io" - "log" - "os" - - "github.com/R-a-dio/valkyrie/streamer/audio" -) - -func main() { - filename := os.Args[1] - - buf, err := audio.DecodeFileGain(filename) - if err != nil { - log.Println("decode:", err) - return - } - - output, err := os.Create(filename + ".replaygain.pcm") - if err != nil { - log.Println("create:", err) - return - } - defer output.Close() - - _, err = io.Copy(output, buf.Reader()) - if err != nil { - log.Println("copy:", err) - return - } - - log.Println("written:", filename+".replaygain.pcm") -}