From 3e513087cae4bd2b7edede9bd94f368b10fde3e7 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 21 May 2023 23:11:15 +0400 Subject: [PATCH] Let's dynamically calculate bufferSize with 320 bytes per line. --- internal/radio/icecast.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/radio/icecast.go b/internal/radio/icecast.go index 3b81b22..317bc4d 100644 --- a/internal/radio/icecast.go +++ b/internal/radio/icecast.go @@ -18,7 +18,7 @@ const ( IcecastPlaylistDateFormat = "02/Jan/2006:15:04:05 -0700" SongTimeFormat = "2006 15:04-0700" - bufferSize = 3072 + bufferSizePerLine = 320 ) var ( @@ -103,6 +103,7 @@ func IcecastLastSong(playlistPath string) (*Song, error) { func icecastLastPlayedSongs(playlistPath string, n int) ([]Song, error) { var buf []byte var offset int64 = 0 + var bufferSize int64 = int64(n) * bufferSizePerLine playlist, err := os.Open(playlistPath) if err != nil {