1
0

Let's dynamically calculate bufferSize with 320 bytes per line.

This commit is contained in:
Alexander Andreev 2023-05-21 23:11:15 +04:00
parent 95a6da8f5d
commit 3e513087ca
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -18,7 +18,7 @@ const (
IcecastPlaylistDateFormat = "02/Jan/2006:15:04:05 -0700" IcecastPlaylistDateFormat = "02/Jan/2006:15:04:05 -0700"
SongTimeFormat = "2006 15:04-0700" SongTimeFormat = "2006 15:04-0700"
bufferSize = 3072 bufferSizePerLine = 320
) )
var ( var (
@ -103,6 +103,7 @@ func IcecastLastSong(playlistPath string) (*Song, error) {
func icecastLastPlayedSongs(playlistPath string, n int) ([]Song, error) { func icecastLastPlayedSongs(playlistPath string, n int) ([]Song, error) {
var buf []byte var buf []byte
var offset int64 = 0 var offset int64 = 0
var bufferSize int64 = int64(n) * bufferSizePerLine
playlist, err := os.Open(playlistPath) playlist, err := os.Open(playlistPath)
if err != nil { if err != nil {