diff --git a/config.go b/config.go index 294b28a..705707d 100644 --- a/config.go +++ b/config.go @@ -15,6 +15,7 @@ type Config struct { BufferLengthInKiB int `toml:"buffer_len"` BufferSeconds int `toml:"buffer_size"` ReplayGain bool `toml:"replaygain"` + Length int `toml:"length"` } `toml:"queue"` Radio struct { Port int `toml:"port"` diff --git a/queue.go b/queue.go index 74d45b4..ad2e0b7 100644 --- a/queue.go +++ b/queue.go @@ -249,6 +249,10 @@ func (q *Queue) AddTrack(entry *QueueTrackEntry, tail bool) error { q.mutex.Lock() defer q.mutex.Unlock() + if q.config.Queue.Length > 0 && len(q.queue) >= q.config.Queue.Length { + return errors.New("queue too long") + } + source := entry.source if q.config.Queue.ReplayGain { if entry.Metadata.ReplayGain.TrackPeak != 0 {