From ada482989c8a1e93b53c0540f5ca9714c59eb2ed Mon Sep 17 00:00:00 2001 From: Wessie Date: Thu, 30 May 2024 22:23:49 +0100 Subject: [PATCH] streamer: fix buffer calculation being recalculated on every song --- streamer/streamer.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/streamer/streamer.go b/streamer/streamer.go index 4212c9c8..cc4c73ff 100644 --- a/streamer/streamer.go +++ b/streamer/streamer.go @@ -519,6 +519,12 @@ func (s *Streamer) icecast(ctx context.Context, conn net.Conn, trackCh <-chan St var track StreamTrack var ok bool buf := make([]byte, bufferMP3Size) + // bufferEnd is when the audio data we've read so far is supposed + // to end if played back in realtime + bufferEnd := time.Now() + // bufferSlack is the period of time we subtract from our sleeping + // period, to make sure we don't sleep too long + bufferSlack := time.Second * 2 for !s.forced.Load() { select { @@ -542,12 +548,6 @@ func (s *Streamer) icecast(ctx context.Context, conn net.Conn, trackCh <-chan St // send the entries metadata to icecast go s.metadataToIcecast(ctx, track.QueueEntry) - // bufferEnd is when the audio data we've read so far is supposed - // to end if played back in realtime - bufferEnd := time.Now() - // bufferSlack is the period of time we subtract from our sleeping - // period, to make sure we don't sleep too long - bufferSlack := time.Second * 2 // lastProgress is the value of the previous loops Progress call lastProgress := time.Duration(0)