From b9288c0084e64b3c530ed4390cf0bdbde6bbc049 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 5 Jan 2025 19:05:58 +0400 Subject: [PATCH] There is a periodic panic because of out of bounds in GetDuration. Let's catch it and see what songs cause it. Also let's use a little bigger buffer of 6200, but I believe it doesn't fix this panic. --- internal/http/dj_handlers.go | 6 ++++++ pkg/oggtag/oggtag.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/http/dj_handlers.go b/internal/http/dj_handlers.go index e191fd1..34cecae 100644 --- a/internal/http/dj_handlers.go +++ b/internal/http/dj_handlers.go @@ -88,6 +88,12 @@ func (dj *DJHandlers) PlaylistNext(w http.ResponseWriter, _ *http.Request) { return } + defer func() { + if err := recover(); err != nil { + log.Printf("Panic occured with %s: %s", nxt, err) + } + }() + newSong := radio.Song{ Artist: oggf.GetTag("artist"), Title: oggf.GetTag("title"), diff --git a/pkg/oggtag/oggtag.go b/pkg/oggtag/oggtag.go index dc43de0..cbbc712 100644 --- a/pkg/oggtag/oggtag.go +++ b/pkg/oggtag/oggtag.go @@ -13,7 +13,7 @@ import ( ) const ( - bufferLength = 6144 + bufferLength = 6200 OggS = "OggS" OggSLen = len(OggS) Vorbis = "vorbis"