Terminate all MPV instances when stopping Navidrome (#3008)
* Terminate all mpv instances when stopping Navidrome * Exit trackSwitcher goroutine when terminating * Remove potential race condition when starting the Playback device * Fix lint error * Removed unused and unneeded vars/functions * Use device short name in log * Small refactor * Small nitpick * Make start functions more uniform
This commit is contained in:
@@ -14,11 +14,11 @@ import (
|
||||
"github.com/navidrome/navidrome/log"
|
||||
)
|
||||
|
||||
func start(args []string) (Executor, error) {
|
||||
func start(ctx context.Context, args []string) (Executor, error) {
|
||||
log.Debug("Executing mpv command", "cmd", args)
|
||||
j := Executor{args: args}
|
||||
j.PipeReader, j.out = io.Pipe()
|
||||
err := j.start()
|
||||
err := j.start(ctx)
|
||||
if err != nil {
|
||||
return Executor{}, err
|
||||
}
|
||||
@@ -38,12 +38,9 @@ type Executor struct {
|
||||
out *io.PipeWriter
|
||||
args []string
|
||||
cmd *exec.Cmd
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
func (j *Executor) start() error {
|
||||
ctx := context.Background()
|
||||
j.ctx = ctx
|
||||
func (j *Executor) start(ctx context.Context) error {
|
||||
cmd := exec.CommandContext(ctx, j.args[0], j.args[1:]...) // #nosec
|
||||
cmd.Stdout = j.out
|
||||
if log.IsGreaterOrEqualTo(log.LevelTrace) {
|
||||
|
||||
Reference in New Issue
Block a user