ensure casting playback stops when quitting app
This commit is contained in:
+1
-1
@@ -463,7 +463,7 @@ func (a *App) Shutdown() {
|
||||
a.WinSMTC.Shutdown()
|
||||
}
|
||||
a.PlaybackManager.DisableCallbacks()
|
||||
a.PlaybackManager.Stop() // will trigger scrobble check
|
||||
a.PlaybackManager.Shutdown() // will trigger scrobble check
|
||||
a.cancel()
|
||||
a.LocalPlayer.Destroy()
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ type playbackCommand struct {
|
||||
Arg any
|
||||
Arg2 any
|
||||
Arg3 any
|
||||
OnDone func()
|
||||
}
|
||||
|
||||
// playbackCommandQueue is a queue to accumulate player commands from the UI
|
||||
@@ -65,6 +66,13 @@ func (c *playbackCommandQueue) Stop() {
|
||||
playbackCommand{Type: cmdStop})
|
||||
}
|
||||
|
||||
func (c *playbackCommandQueue) StopAndWait() {
|
||||
done := make(chan struct{})
|
||||
c.filterCommandsAndAdd([]playbackCommandType{cmdContinue, cmdPause, cmdStop},
|
||||
playbackCommand{Type: cmdStop, OnDone: func() { close(done) }})
|
||||
<-done
|
||||
}
|
||||
|
||||
func (c *playbackCommandQueue) Continue() {
|
||||
c.filterCommandsAndAdd([]playbackCommandType{cmdContinue, cmdPause, cmdStop},
|
||||
playbackCommand{Type: cmdContinue})
|
||||
|
||||
@@ -512,6 +512,10 @@ func (p *PlaybackManager) Stop() {
|
||||
p.cmdQueue.Stop()
|
||||
}
|
||||
|
||||
func (p *PlaybackManager) Shutdown() {
|
||||
p.cmdQueue.StopAndWait()
|
||||
}
|
||||
|
||||
func (p *PlaybackManager) Pause() {
|
||||
p.cmdQueue.Pause()
|
||||
}
|
||||
@@ -662,6 +666,9 @@ func (p *PlaybackManager) runCmdQueue(ctx context.Context) {
|
||||
mpv.ForceRestartPlayback()
|
||||
}
|
||||
}
|
||||
if c.OnDone != nil {
|
||||
c.OnDone()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user