diff options
-rw-r--r-- | switchctl.c | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/switchctl.c b/switchctl.c index b3cc643..ce32195 100644 --- a/switchctl.c +++ b/switchctl.c @@ -351,45 +351,46 @@ int process_cmd_mode(const char* param, int fd, cmd_t **cmd_q, options_t* opt) return 0; } - // swap master with standby channels - - char* ch_from = NULL; - if(old_mode == MODE_MASTER && opt->channel_ == CHAN_MAIN) - ch_from = "master_main"; - else if(old_mode == MODE_MASTER && opt->channel_ == CHAN_MUSIC) - ch_from = "master_music"; - else if(old_mode == MODE_STANDBY && opt->channel_ == CHAN_MAIN) - ch_from = "standby_main"; - else if(old_mode == MODE_STANDBY && opt->channel_ == CHAN_MUSIC) - ch_from = "standby_music"; - else { - opt->mode_ = old_mode; - log_printf(ERROR, "EEE: mode: old config is illegal?!"); - return 0; - } - - char* ch_to = NULL; - if(opt->mode_ == MODE_MASTER && opt->channel_ == CHAN_MAIN) - ch_to = "master_main"; - else if(opt->mode_ == MODE_MASTER && opt->channel_ == CHAN_MUSIC) - ch_to = "master_music"; - else if(opt->mode_ == MODE_STANDBY && opt->channel_ == CHAN_MAIN) - ch_to = "standby_main"; - else if(opt->mode_ == MODE_STANDBY && opt->channel_ == CHAN_MUSIC) - ch_to = "standby_music"; - else { - opt->mode_ = old_mode; - log_printf(ERROR, "EEE: mode: current config is illegal?!"); - return 0; - } - - int ret = crossfade(ch_from, ch_to, fd, cmd_q, opt); - if(ret) { - opt->mode_ = old_mode; - if(ret > 0) + // swap master with standby channels only when mode has changed + if(old_mode != opt->mode_) { + char* ch_from = NULL; + if(old_mode == MODE_MASTER && opt->channel_ == CHAN_MAIN) + ch_from = "master_main"; + else if(old_mode == MODE_MASTER && opt->channel_ == CHAN_MUSIC) + ch_from = "master_music"; + else if(old_mode == MODE_STANDBY && opt->channel_ == CHAN_MAIN) + ch_from = "standby_main"; + else if(old_mode == MODE_STANDBY && opt->channel_ == CHAN_MUSIC) + ch_from = "standby_music"; + else { + opt->mode_ = old_mode; + log_printf(ERROR, "EEE: mode: old config is illegal?!"); return 0; + } - return ret; + char* ch_to = NULL; + if(opt->mode_ == MODE_MASTER && opt->channel_ == CHAN_MAIN) + ch_to = "master_main"; + else if(opt->mode_ == MODE_MASTER && opt->channel_ == CHAN_MUSIC) + ch_to = "master_music"; + else if(opt->mode_ == MODE_STANDBY && opt->channel_ == CHAN_MAIN) + ch_to = "standby_main"; + else if(opt->mode_ == MODE_STANDBY && opt->channel_ == CHAN_MUSIC) + ch_to = "standby_music"; + else { + opt->mode_ = old_mode; + log_printf(ERROR, "EEE: mode: current config is illegal?!"); + return 0; + } + + int ret = crossfade(ch_from, ch_to, fd, cmd_q, opt); + if(ret) { + opt->mode_ = old_mode; + if(ret > 0) + return 0; + + return ret; + } } } else { |