Skip to content

Commit

Permalink
Update recent ProcessStop functionality #2
Browse files Browse the repository at this point in the history
  • Loading branch information
alexballas committed Jun 14, 2022
1 parent 8b1b9c7 commit dc680fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
6 changes: 3 additions & 3 deletions httphandlers/httphandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ func (s *HTTPserver) callbackHandler(tv *soapcalls.TVPayload, screen Screen) htt
return
}

if processStop && newstate == "STOPPED" {
if !processStop && newstate == "STOPPED" {
tv.SetProcessStopTrue(uuid)
fmt.Fprintf(w, "OK\n")
return
}
Expand All @@ -153,12 +154,11 @@ func (s *HTTPserver) callbackHandler(tv *soapcalls.TVPayload, screen Screen) htt

switch newstate {
case "PLAYING":
tv.SetProcessStopFalse(uuid)
screen.EmitMsg("Playing")
tv.SetProcessStopTrue(uuid)
case "PAUSED_PLAYBACK":
screen.EmitMsg("Paused")
case "STOPPED":
tv.SetProcessStopTrue(uuid)

This comment has been minimized.

Copy link
@Mikescops

Mikescops Jun 14, 2022

Contributor

you'll have probably an unhandled case (like using a remote controller to stop) by not doing this

This comment has been minimized.

Copy link
@alexballas

alexballas Jun 14, 2022

Author Owner

So firstly I'd like to mention that I swapped a bit the logic of this bool variable. If it's true it means that stop callbacks should be respected and not ignored. When a stop callback is received (and not ignored), tv.UnsubscribeSoapCall(uuid) is called and clean deletes any state variable for this uuid anyway. Setting the variable back to the previous state would not have any effect as it will be cleaned up.

screen.EmitMsg("Stopped")
_ = tv.UnsubscribeSoapCall(uuid)
screen.Fini()
Expand Down
7 changes: 0 additions & 7 deletions soapcalls/soapcallers.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,13 +564,6 @@ func (p *TVPayload) SetProcessStopTrue(uuid string) {
p.MediaRenderersStates[uuid].ProcessStop = true
}

// SetProcessStopFalse set the stop process to false
func (p *TVPayload) SetProcessStopFalse(uuid string) {
p.Lock()
defer p.Unlock()
p.MediaRenderersStates[uuid].ProcessStop = false
}

// GetProcessStop returns the processStop value of the specific UUID.
func (p *TVPayload) GetProcessStop(uuid string) (bool, error) {
p.RLock()
Expand Down

0 comments on commit dc680fa

Please sign in to comment.