Added max queue length config entry
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DataHoarder 2022-04-20 11:08:33 +02:00
parent c9111f8e8c
commit 5b766f3116
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
2 changed files with 5 additions and 0 deletions

View file

@ -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"`

View file

@ -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 {