diff options
author | Christian Pointner <equinox@helsinki.at> | 2009-11-19 06:11:57 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2009-11-19 06:11:57 (GMT) |
commit | c209cfd639221d56e63b27db3f2efbf10e3a7bae (patch) | |
tree | b2f029eba0d270fd21bdbaae1c735467064d0c4c /switchctl.c | |
parent | 56d755c55d99cd0ae170a35348ba5dbfd68ebddd (diff) |
at mode change only send command to switch if the mode hast actually changed
Diffstat (limited to 'switchctl.c')
-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 { |