1
0

SongList.Current() now returns a copy of Song instead of a pointer.

This commit is contained in:
Alexander Andreev 2023-10-05 18:52:18 +04:00
parent 9b14d7846b
commit 9beb179cc0
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -77,13 +77,13 @@ func (sl *SongList) Add(newSong Song) {
} }
// Current returns a currently playing song. // Current returns a currently playing song.
func (sl *SongList) Current() *Song { func (sl *SongList) Current() Song {
sl.Lock() sl.Lock()
defer sl.Unlock() defer sl.Unlock()
if sl.current.StartAt.Year() == 1 { if sl.current.StartAt.Year() == 1 {
return nil return Song{}
} }
return &sl.current return sl.current
} }
// UpdateCurrentMaxListeners checks and updates a maximal number of listeners // UpdateCurrentMaxListeners checks and updates a maximal number of listeners