CVolume: remove duplicate code

This commit is contained in:
Stefan Seyfried
2013-03-24 13:21:51 +01:00
committed by svenhoefer
parent 36e95d7fbc
commit 3a32fab2f0

View File

@@ -265,12 +265,12 @@ void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowa
do { do {
if (msg <= CRCInput::RC_MaxRC) if (msg <= CRCInput::RC_MaxRC)
{ {
int sub_chan_keybind = 0; bool sub_chan_keybind = g_settings.mode_left_right_key_tv == SNeutrinoSettings::VOLUME
if (g_settings.mode_left_right_key_tv == SNeutrinoSettings::VOLUME && g_RemoteControl->subChannels.size() < 1) && g_RemoteControl && g_RemoteControl->subChannels.size() < 1;
sub_chan_keybind = 1; if ((msg == CRCInput::RC_plus || msg == CRCInput::RC_minus) ||
(sub_chan_keybind && (msg == CRCInput::RC_right || msg == CRCInput::RC_left))) {
if ((msg == CRCInput::RC_plus) || (sub_chan_keybind == 1 && (msg == CRCInput::RC_right))) { int dir = (msg == CRCInput::RC_plus || msg == CRCInput::RC_right) ? 1 : -1;
if(CNeutrinoApp::getInstance()->isMuted()) { if (CNeutrinoApp::getInstance()->isMuted() && (dir > 0 || g_settings.current_volume > 0)) {
if ((bDoPaint) && (pixbuf!= NULL)) { if ((bDoPaint) && (pixbuf!= NULL)) {
frameBuffer->RestoreScreen(x, y, vbar_w+ShadowOffset, vbar_h+ShadowOffset, pixbuf); frameBuffer->RestoreScreen(x, y, vbar_w+ShadowOffset, vbar_h+ShadowOffset, pixbuf);
delete [] pixbuf; delete [] pixbuf;
@@ -281,46 +281,29 @@ void CVolume::setVolume(const neutrino_msg_t key, const bool bDoPaint, bool nowa
return; return;
} }
if(!CNeutrinoApp::getInstance()->isMuted()) { if (!CNeutrinoApp::getInstance()->isMuted()) {
if (g_settings.current_volume < 100 - g_settings.current_volume_step) /* current_volume is char, we need signed to catch v < 0 */
g_settings.current_volume += g_settings.current_volume_step; int v = g_settings.current_volume;
else v += dir * g_settings.current_volume_step;
g_settings.current_volume = 100; if (v > 100)
} v = 100;
} else if (v < 1) {
else if ((msg == CRCInput::RC_minus) || (sub_chan_keybind == 1 && (msg == CRCInput::RC_left))) { v = 0;
if(CNeutrinoApp::getInstance()->isMuted() && g_settings.current_volume > 0) { g_settings.current_volume = 0;
if ((bDoPaint) && (pixbuf!= NULL)) { if (g_settings.show_mute_icon) {
if (bDoPaint && pixbuf != NULL) {
frameBuffer->RestoreScreen(x, y, vbar_w+ShadowOffset, vbar_h+ShadowOffset, pixbuf); frameBuffer->RestoreScreen(x, y, vbar_w+ShadowOffset, vbar_h+ShadowOffset, pixbuf);
delete [] pixbuf; delete []pixbuf;
} }
AudioMute(false, true); AudioMute(true, true);
Init(); Init();
setVolume(msg); setVolume(msg);
return; return;
} }
if(!CNeutrinoApp::getInstance()->isMuted()) {
if (g_settings.current_volume > g_settings.current_volume_step)
g_settings.current_volume -= g_settings.current_volume_step;
else if (g_settings.show_mute_icon == 1) {
if ((bDoPaint) && (pixbuf!= NULL)) {
frameBuffer->RestoreScreen(x, y, vbar_w+ShadowOffset, vbar_h+ShadowOffset, pixbuf);
delete [] pixbuf;
} }
g_settings.current_volume = 0; g_settings.current_volume = v;
AudioMute( true, true);
Init();
setVolume(msg);
return;
}
else if (g_settings.show_mute_icon == 0)
g_settings.current_volume = 0;
} }
} }
else if (msg == CRCInput::RC_home) else if (msg == CRCInput::RC_home)
break; break;
else { else {