1
0

lastPlayedSongs changed to icecastLastPlayedSongs. playlistFired changed to playlistChanged.

This commit is contained in:
Alexander Andreev 2022-09-19 01:37:47 +04:00
parent a7d91dc92e
commit 3727f44381
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -92,7 +92,7 @@ func IcecastLastPlayedSongs(lastNSongs int, playlistPath string) ([]Song, error)
}
}
songs, err := lastPlayedSongs(playlistPath, lastNSongs)
songs, err := icecastLastPlayedSongs(playlistPath, lastNSongs)
if err != nil {
return make([]Song, 0), err
}
@ -109,7 +109,7 @@ func IcecastLastSong(playlistPath string) (Song, error) {
}
}
song, err := lastPlayedSongs(playlistPath, 1)
song, err := icecastLastPlayedSongs(playlistPath, 1)
if err != nil {
return Song{}, err
}
@ -117,7 +117,7 @@ func IcecastLastSong(playlistPath string) (Song, error) {
return song[0], nil
}
func lastPlayedSongs(playlistPath string, n int) ([]Song, error) {
func icecastLastPlayedSongs(playlistPath string, n int) ([]Song, error) {
songs := make([]Song, n)
buf := make([]byte, bufferSize)
@ -167,7 +167,7 @@ func lastPlayedSongs(playlistPath string, n int) ([]Song, error) {
}
var playlistWatcher watcher.InotifyWatcher
var playlistFired chan uint32 = make(chan uint32)
var playlistChanged chan uint32 = make(chan uint32)
func IcecastWatchPlaylist(playlistPath string, lastNSongs int) error {
playlistWatcher, err := watcher.NewInotifyWatcher()
@ -180,15 +180,15 @@ func IcecastWatchPlaylist(playlistPath string, lastNSongs int) error {
return errors.Wrap(err, "cannot set a playlist to watch")
}
playlistWatcher.WatchForMask(playlistFired, watcher.ModIgnMask)
playlistWatcher.WatchForMask(playlistChanged, watcher.ModIgnMask)
go func() {
for {
select {
case mask := <-playlistFired:
case mask := <-playlistChanged:
if mask&syscall.IN_MODIFY > 0 {
lastPlayedCacheMutex.Lock()
if songs, err := lastPlayedSongs(playlistPath, lastNSongs); err == nil {
if songs, err := icecastLastPlayedSongs(playlistPath, lastNSongs); err == nil {
lastPlayedCache = songs
}
lastPlayedCacheMutex.Unlock()