diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-11-17 16:38:31 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-11-17 16:38:31 (GMT) |
commit | 99576365aed2fd1fff9101c14dbe545bc3820beb (patch) | |
tree | 787be1b549eb16132d85fafb4faf2516924ff246 | |
parent | bfface7eba6f620b4e63716b14ddb6cb2acecc7d (diff) |
added channel command to fix switch-switchback delay due to settling timeouts
-rw-r--r-- | src/rhctl/playout_server.go | 1 | ||||
-rw-r--r-- | src/rhctl/switch_control.go | 27 |
2 files changed, 25 insertions, 3 deletions
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 != "" { |