Skip to content

Commit

Permalink
add back logging of playback errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Jan 5, 2025
1 parent 08fae68 commit 0b73f47
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions backend/playbackmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package backend

import (
"context"
"fmt"
"log"
"math/rand"
"time"
Expand Down Expand Up @@ -419,40 +420,47 @@ func (p *PlaybackManager) PlayPause() {
}

func (p *PlaybackManager) runCmdQueue(ctx context.Context) {
logIfErr := func(action string, err error) {
if err != nil {
log.Println("Playback error (%s): %v", action, err)
}
}
for {
select {
case <-ctx.Done():
return
case c := <-p.cmdQueue.C():
switch c.Type {
case cmdStop:
p.engine.Stop()
logIfErr("Stop", p.engine.Stop())
case cmdContinue:
p.engine.Continue()
logIfErr("Continue", p.engine.Continue())
case cmdPause:
p.engine.Pause()
logIfErr("Pause", p.engine.Pause())
case cmdPlayTrackAt:
p.engine.PlayTrackAt(c.Arg.(int))
logIfErr("PlayTrackAt", p.engine.PlayTrackAt(c.Arg.(int)))
case cmdSeekSeconds:
p.engine.SeekSeconds(c.Arg.(float64))
logIfErr("SeekSeconds", p.engine.SeekSeconds(c.Arg.(float64)))
case cmdSeekFwdBackN:
p.engine.SeekFwdBackN(c.Arg.(int))
action := fmt.Sprintf("SeekFwdBack[%d]", c.Arg.(int))
logIfErr(action, p.engine.SeekFwdBackN(c.Arg.(int)))
case cmdVolume:
p.engine.SetVolume(c.Arg.(int))
logIfErr("Volume", p.engine.SetVolume(c.Arg.(int)))
case cmdLoopMode:
p.engine.SetLoopMode(c.Arg.(LoopMode))
case cmdStopAndClearPlayQueue:
p.engine.StopAndClearPlayQueue()
case cmdUpdatePlayQueue:
p.engine.UpdatePlayQueue(c.Arg.([]mediaprovider.MediaItem))
logIfErr("UpdatePlayQueue", p.engine.UpdatePlayQueue(c.Arg.([]mediaprovider.MediaItem)))
case cmdRemoveTracksFromQueue:
p.engine.RemoveTracksFromQueue(c.Arg.([]int))
case cmdLoadItems:
p.engine.LoadItems(
err := p.engine.LoadItems(
c.Arg.([]mediaprovider.MediaItem),
c.Arg2.(InsertQueueMode),
c.Arg3.(bool),
)
logIfErr("LoadItems", err)
case cmdLoadRadioStation:
p.engine.LoadRadioStation(
c.Arg.(*mediaprovider.RadioStation),
Expand Down

0 comments on commit 0b73f47

Please sign in to comment.