lastPlayedSongs changed to icecastLastPlayedSongs. playlistFired changed to playlistChanged.
This commit is contained in:
parent
a7d91dc92e
commit
3727f44381
@ -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 {
|
if err != nil {
|
||||||
return make([]Song, 0), err
|
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 {
|
if err != nil {
|
||||||
return Song{}, err
|
return Song{}, err
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ func IcecastLastSong(playlistPath string) (Song, error) {
|
|||||||
return song[0], nil
|
return song[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func lastPlayedSongs(playlistPath string, n int) ([]Song, error) {
|
func icecastLastPlayedSongs(playlistPath string, n int) ([]Song, error) {
|
||||||
songs := make([]Song, n)
|
songs := make([]Song, n)
|
||||||
buf := make([]byte, bufferSize)
|
buf := make([]byte, bufferSize)
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ func lastPlayedSongs(playlistPath string, n int) ([]Song, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var playlistWatcher watcher.InotifyWatcher
|
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 {
|
func IcecastWatchPlaylist(playlistPath string, lastNSongs int) error {
|
||||||
playlistWatcher, err := watcher.NewInotifyWatcher()
|
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")
|
return errors.Wrap(err, "cannot set a playlist to watch")
|
||||||
}
|
}
|
||||||
|
|
||||||
playlistWatcher.WatchForMask(playlistFired, watcher.ModIgnMask)
|
playlistWatcher.WatchForMask(playlistChanged, watcher.ModIgnMask)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case mask := <-playlistFired:
|
case mask := <-playlistChanged:
|
||||||
if mask&syscall.IN_MODIFY > 0 {
|
if mask&syscall.IN_MODIFY > 0 {
|
||||||
lastPlayedCacheMutex.Lock()
|
lastPlayedCacheMutex.Lock()
|
||||||
if songs, err := lastPlayedSongs(playlistPath, lastNSongs); err == nil {
|
if songs, err := icecastLastPlayedSongs(playlistPath, lastNSongs); err == nil {
|
||||||
lastPlayedCache = songs
|
lastPlayedCache = songs
|
||||||
}
|
}
|
||||||
lastPlayedCacheMutex.Unlock()
|
lastPlayedCacheMutex.Unlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user