summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rhctl/playout_server.go1
-rw-r--r--src/rhctl/switch_control.go27
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 != "" {