From 99576365aed2fd1fff9101c14dbe545bc3820beb Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 17 Nov 2016 17:38:31 +0100 Subject: added channel command to fix switch-switchback delay due to settling timeouts diff --git a/src/rhctl/playout_server.go b/src/rhctl/playout_server.go index b0cf433..603414e 100644 --- a/src/rhctl/playout_server.go +++ b/src/rhctl/playout_server.go @@ -112,6 +112,7 @@ func (srv *PlayoutServer) handleMessage(data string) { } srv.state.Channel = data[8:] srv.state.Updated = time.Now() + srv.Commands <- Command{Type: CmdChannel, Args: []string{srv.name, data[8:]}, Response: nil} srv.StateChanges <- srv.state return } diff --git a/src/rhctl/switch_control.go b/src/rhctl/switch_control.go index 64da3c4..58575d6 100644 --- a/src/rhctl/switch_control.go +++ b/src/rhctl/switch_control.go @@ -70,6 +70,7 @@ type CommandType uint8 const ( CmdState CommandType = iota CmdServer + CmdChannel CmdSwitch ) @@ -79,6 +80,8 @@ func (c CommandType) String() string { return "state" case CmdServer: return "server" + case CmdChannel: + return "channel" case CmdSwitch: return "switch" } @@ -127,6 +130,20 @@ func (ctrl *SwitchControl) handleCommand(cmd *Command) { if cmd.Response != nil { cmd.Response <- result } + case CmdChannel: + if len(cmd.Args) != 2 { + if cmd.Response != nil { + cmd.Response <- fmt.Errorf("no server and or channel specified") + } + return + } + if ctrl.state.Mood == MoodAwakening || ctrl.state.ActiveServer != cmd.Args[0] { + return + } + result := ctrl.selectServerChannel(cmd.Args[0], cmd.Args[1]) + if cmd.Response != nil { + cmd.Response <- result + } case CmdSwitch: if len(cmd.Args) == 0 { if cmd.Response != nil { @@ -205,10 +222,10 @@ func (ctrl *SwitchControl) getSwitchServerAssignment() (swsrv, swch string, err return ctrl.sw.Inputs.GetServerAndChannel(activeInput) } -func (ctrl *SwitchControl) selectServer(server string) bool { - newIn, err := ctrl.sw.Inputs.GetNumber(server, ctrl.state.Server[server].Channel) +func (ctrl *SwitchControl) selectServerChannel(server, channel string) bool { + newIn, err := ctrl.sw.Inputs.GetNumber(server, channel) if err != nil { - rhdl.Printf("SwitchCTRL: no audio input configured for server/channel: '%s/%s'", server, ctrl.state.Server[server].Channel) + rhdl.Printf("SwitchCTRL: no audio input configured for server/channel: '%s/%s'", server, channel) return false } @@ -223,6 +240,10 @@ func (ctrl *SwitchControl) selectServer(server string) bool { return true } +func (ctrl *SwitchControl) selectServer(server string) bool { + return ctrl.selectServerChannel(server, ctrl.state.Server[server].Channel) +} + func (ctrl *SwitchControl) checkAndSelectServer(server string) bool { if state, exists := ctrl.state.Server[server]; exists { if state.Health == ServerAlive && state.Channel != "" { -- cgit v0.10.2