refactor(volume): Cleanup
This commit is contained in:
parent
6037947b1d
commit
9754393c49
1 changed files with 6 additions and 11 deletions
|
@ -114,9 +114,6 @@ namespace modules {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_event() {
|
bool has_event() {
|
||||||
if (m_updated)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
bool has_event = false;
|
bool has_event = false;
|
||||||
if (m_master_mixer)
|
if (m_master_mixer)
|
||||||
|
@ -135,8 +132,6 @@ namespace modules {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool update() {
|
bool update() {
|
||||||
m_updated = false;
|
|
||||||
|
|
||||||
// Consume any other pending events
|
// Consume any other pending events
|
||||||
if (m_master_mixer)
|
if (m_master_mixer)
|
||||||
m_master_mixer->process_events();
|
m_master_mixer->process_events();
|
||||||
|
@ -229,10 +224,12 @@ namespace modules {
|
||||||
alsa_mixer* master_mixer = m_master_mixer.get();
|
alsa_mixer* master_mixer = m_master_mixer.get();
|
||||||
alsa_mixer* other_mixer = nullptr;
|
alsa_mixer* other_mixer = nullptr;
|
||||||
|
|
||||||
if (m_headphone_mixer && m_headphone_ctrl && m_headphone_ctrl->test_device_plugged())
|
if (m_headphone_mixer && m_headphones)
|
||||||
other_mixer = m_headphone_mixer.get();
|
other_mixer = m_headphone_mixer.get();
|
||||||
else if (m_speaker_mixer)
|
else if (m_speaker_mixer)
|
||||||
other_mixer = m_speaker_mixer.get();
|
other_mixer = m_speaker_mixer.get();
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
if (cmd.compare(0, strlen(EVENT_TOGGLE_MUTE), EVENT_TOGGLE_MUTE) == 0) {
|
if (cmd.compare(0, strlen(EVENT_TOGGLE_MUTE), EVENT_TOGGLE_MUTE) == 0) {
|
||||||
master_mixer->set_mute(m_muted);
|
master_mixer->set_mute(m_muted);
|
||||||
|
@ -250,8 +247,6 @@ namespace modules {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_updated = true;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,9 +283,9 @@ namespace modules {
|
||||||
unique_ptr<alsa_ctl_interface> m_headphone_ctrl;
|
unique_ptr<alsa_ctl_interface> m_headphone_ctrl;
|
||||||
int m_headphone_ctrl_numid = -1;
|
int m_headphone_ctrl_numid = -1;
|
||||||
int m_volume = 0;
|
int m_volume = 0;
|
||||||
bool m_muted = false;
|
|
||||||
bool m_updated = false;
|
stateflag m_muted{false};
|
||||||
bool m_headphones = false;
|
stateflag m_headphones{false};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue