Oh, last commit led to loading of full list of prev songs. Let's remove this code.
This commit is contained in:
parent
10048c671e
commit
0409da3ca3
@ -80,7 +80,6 @@ func IcecastGetStatus(icecastURL string) (*IcecastStatus, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IcecastLastPlayedSongs(lastNSongs int, playlistPath string) ([]Song, error) {
|
func IcecastLastPlayedSongs(lastNSongs int, playlistPath string) ([]Song, error) {
|
||||||
{
|
|
||||||
lastPlayedCacheMutex.Lock()
|
lastPlayedCacheMutex.Lock()
|
||||||
defer lastPlayedCacheMutex.Unlock()
|
defer lastPlayedCacheMutex.Unlock()
|
||||||
if lpcLen := len(lastPlayedCache); lpcLen > 0 {
|
if lpcLen := len(lastPlayedCache); lpcLen > 0 {
|
||||||
@ -91,31 +90,17 @@ func IcecastLastPlayedSongs(lastNSongs int, playlistPath string) ([]Song, error)
|
|||||||
copy(ret[:], lastPlayedCache[lpcLen-lastNSongs:])
|
copy(ret[:], lastPlayedCache[lpcLen-lastNSongs:])
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
songs, err := icecastLastPlayedSongs(playlistPath, lastNSongs)
|
return nil, nil
|
||||||
if err != nil {
|
|
||||||
return make([]Song, 0), err
|
|
||||||
}
|
|
||||||
|
|
||||||
return songs, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func IcecastLastSong(playlistPath string) (Song, error) {
|
func IcecastLastSong(playlistPath string) (*Song, error) {
|
||||||
{
|
|
||||||
lastPlayedCacheMutex.Lock()
|
lastPlayedCacheMutex.Lock()
|
||||||
defer lastPlayedCacheMutex.Unlock()
|
defer lastPlayedCacheMutex.Unlock()
|
||||||
if lpcLen := len(lastPlayedCache); lpcLen > 0 {
|
if lpcLen := len(lastPlayedCache); lpcLen > 0 {
|
||||||
return lastPlayedCache[lpcLen-1], nil
|
return &lastPlayedCache[lpcLen-1], nil
|
||||||
}
|
}
|
||||||
}
|
return nil, nil
|
||||||
|
|
||||||
song, err := icecastLastPlayedSongs(playlistPath, 1)
|
|
||||||
if err != nil {
|
|
||||||
return Song{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return song[0], nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func icecastLastPlayedSongs(playlistPath string, n int) ([]Song, error) {
|
func icecastLastPlayedSongs(playlistPath string, n int) ([]Song, error) {
|
||||||
@ -206,8 +191,7 @@ func (pw *PlaylistLogWatcher) Watch(playlistPath string, n int) (err error) {
|
|||||||
if mask&syscall.IN_MODIFY > 0 {
|
if mask&syscall.IN_MODIFY > 0 {
|
||||||
if isJustStarted {
|
if isJustStarted {
|
||||||
isJustStarted = false
|
isJustStarted = false
|
||||||
break
|
} else {
|
||||||
}
|
|
||||||
lastPlayedCacheMutex.Lock()
|
lastPlayedCacheMutex.Lock()
|
||||||
if lastPlayedCache == nil {
|
if lastPlayedCache == nil {
|
||||||
lastPlayedCache = make([]Song, n)
|
lastPlayedCache = make([]Song, n)
|
||||||
@ -220,6 +204,7 @@ func (pw *PlaylistLogWatcher) Watch(playlistPath string, n int) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastPlayedCacheMutex.Unlock()
|
lastPlayedCacheMutex.Unlock()
|
||||||
|
}
|
||||||
} else if mask&syscall.IN_IGNORED > 0 {
|
} else if mask&syscall.IN_IGNORED > 0 {
|
||||||
pw.Close()
|
pw.Close()
|
||||||
pw.Watch(playlistPath, n)
|
pw.Watch(playlistPath, n)
|
||||||
|
Loading…
Reference in New Issue
Block a user