mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-05 05:27:37 +03:00
Improve some Jukebox error messages
This commit is contained in:
parent
3ca4f44118
commit
6c05493cda
1 changed files with 20 additions and 20 deletions
|
@ -77,37 +77,36 @@ func (t *MpvTrack) SetVolume(value float32) {
|
||||||
// mpv's volume as described in the --volume parameter:
|
// mpv's volume as described in the --volume parameter:
|
||||||
// Set the startup volume. 0 means silence, 100 means no volume reduction or amplification.
|
// Set the startup volume. 0 means silence, 100 means no volume reduction or amplification.
|
||||||
// Negative values can be passed for compatibility, but are treated as 0.
|
// Negative values can be passed for compatibility, but are treated as 0.
|
||||||
log.Debug("request for gain", "gain", value)
|
log.Debug("Setting volume", "volume", value, "track", t)
|
||||||
vol := int(value * 100)
|
vol := int(value * 100)
|
||||||
|
|
||||||
err := t.Conn.Set("volume", vol)
|
err := t.Conn.Set("volume", vol)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error("Error setting volume", "volume", value, "track", t, err)
|
||||||
}
|
}
|
||||||
log.Debug("set volume", "volume", vol)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *MpvTrack) Unpause() {
|
func (t *MpvTrack) Unpause() {
|
||||||
|
log.Debug("Unpausing track", "track", t)
|
||||||
err := t.Conn.Set("pause", false)
|
err := t.Conn.Set("pause", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error("Error unpausing track", "track", t, err)
|
||||||
}
|
}
|
||||||
log.Debug("Unpaused track", "track", t)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *MpvTrack) Pause() {
|
func (t *MpvTrack) Pause() {
|
||||||
|
log.Debug("Pausing track", "track", t)
|
||||||
err := t.Conn.Set("pause", true)
|
err := t.Conn.Set("pause", true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error("Error pausing track", "track", t, err)
|
||||||
}
|
}
|
||||||
log.Info("paused track")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *MpvTrack) Close() {
|
func (t *MpvTrack) Close() {
|
||||||
log.Debug("closing resources")
|
log.Debug("Closing resources", "track", t)
|
||||||
t.CloseCalled = true
|
t.CloseCalled = true
|
||||||
// trying to shutdown mpv process using socket
|
// trying to shutdown mpv process using socket
|
||||||
if t.isSocketfilePresent() {
|
if t.isSocketFilePresent() {
|
||||||
log.Debug("sending shutdown command")
|
log.Debug("sending shutdown command")
|
||||||
_, err := t.Conn.Call("quit")
|
_, err := t.Conn.Call("quit")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -117,22 +116,22 @@ func (t *MpvTrack) Close() {
|
||||||
log.Debug("cancelling executor")
|
log.Debug("cancelling executor")
|
||||||
err = t.Exe.Cancel()
|
err = t.Exe.Cancel()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("error canceling executor")
|
log.Error("Error canceling executor", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.isSocketfilePresent() {
|
if t.isSocketFilePresent() {
|
||||||
log.Debug("Removing socketfile", "socketfile", t.IPCSocketName)
|
log.Debug("Removing socketfile", "socketfile", t.IPCSocketName)
|
||||||
err := os.Remove(t.IPCSocketName)
|
err := os.Remove(t.IPCSocketName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("error cleaning up socketfile: ", t.IPCSocketName)
|
log.Error("Error cleaning up socketfile", "socketfile", t.IPCSocketName, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *MpvTrack) isSocketfilePresent() bool {
|
func (t *MpvTrack) isSocketFilePresent() bool {
|
||||||
if len(t.IPCSocketName) < 1 {
|
if len(t.IPCSocketName) < 1 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -158,13 +157,13 @@ func (t *MpvTrack) Position() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error getting position in track", err)
|
log.Error("Error getting position in track", "track", t, err)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
pos, ok := position.(float64)
|
pos, ok := position.(float64)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Error("Could not cast position from mpv into float64", "position", position)
|
log.Error("Could not cast position from mpv into float64", "position", position, "track", t)
|
||||||
return 0
|
return 0
|
||||||
} else {
|
} else {
|
||||||
return int(pos)
|
return int(pos)
|
||||||
|
@ -174,30 +173,31 @@ func (t *MpvTrack) Position() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *MpvTrack) SetPosition(offset int) error {
|
func (t *MpvTrack) SetPosition(offset int) error {
|
||||||
|
log.Debug("Setting position", "offset", offset, "track", t)
|
||||||
pos := t.Position()
|
pos := t.Position()
|
||||||
if pos == offset {
|
if pos == offset {
|
||||||
log.Debug("no position difference, skipping operation")
|
log.Debug("No position difference, skipping operation", "track", t)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
err := t.Conn.Set("time-pos", float64(offset))
|
err := t.Conn.Set("time-pos", float64(offset))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("could not set the position in track", "offset", offset, err)
|
log.Error("Could not set the position in track", "track", t, "offset", offset, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Info("set position", "offset", offset)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *MpvTrack) IsPlaying() bool {
|
func (t *MpvTrack) IsPlaying() bool {
|
||||||
|
log.Debug("Checking if track is playing", "track", t)
|
||||||
pausing, err := t.Conn.Get("pause")
|
pausing, err := t.Conn.Get("pause")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("problem getting paused status", err)
|
log.Error("Problem getting paused status", "track", t, err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
pause, ok := pausing.(bool)
|
pause, ok := pausing.(bool)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Error("could not cast pausing to boolean")
|
log.Error("Could not cast pausing to boolean", "track", t, "value", pausing)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return !pause
|
return !pause
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue