mirror of
https://github.com/polybar/polybar.git
synced 2024-11-03 04:33:30 -05:00
Update the mixer class to support setting the name of the soundcard we want to get the mixer of
This commit is contained in:
parent
497221b1ab
commit
22e255747a
2 changed files with 12 additions and 3 deletions
|
@ -18,13 +18,14 @@ POLYBAR_NS
|
|||
namespace alsa {
|
||||
class mixer {
|
||||
public:
|
||||
explicit mixer(string&& mixer_selem_name);
|
||||
explicit mixer(string&& mixer_selem_name, string&& sound_card_name);
|
||||
~mixer();
|
||||
|
||||
mixer(const mixer& o) = delete;
|
||||
mixer& operator=(const mixer& o) = delete;
|
||||
|
||||
const string& get_name();
|
||||
const string& get_sound_card();
|
||||
|
||||
bool wait(int timeout = -1);
|
||||
int process_events();
|
||||
|
@ -42,6 +43,7 @@ namespace alsa {
|
|||
snd_mixer_elem_t* m_elem{nullptr};
|
||||
|
||||
string m_name;
|
||||
string s_name;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace alsa {
|
|||
/**
|
||||
* Construct mixer object
|
||||
*/
|
||||
mixer::mixer(string&& mixer_selem_name) : m_name(forward<string>(mixer_selem_name)) {
|
||||
mixer::mixer(string&& mixer_selem_name, string&& soundcard_name) : m_name(forward<string>(mixer_selem_name)), s_name(soundcard_name) {
|
||||
int err = 0;
|
||||
|
||||
if ((err = snd_mixer_open(&m_mixer, 1)) == -1) {
|
||||
|
@ -21,7 +21,7 @@ namespace alsa {
|
|||
|
||||
snd_config_update_free_global();
|
||||
|
||||
if ((err = snd_mixer_attach(m_mixer, ALSA_SOUNDCARD)) == -1) {
|
||||
if ((err = snd_mixer_attach(m_mixer, s_name.c_str())) == -1) {
|
||||
throw_exception<mixer_error>("Failed to attach hardware mixer control", err);
|
||||
}
|
||||
if ((err = snd_mixer_selem_register(m_mixer, nullptr, nullptr)) == -1) {
|
||||
|
@ -57,6 +57,13 @@ namespace alsa {
|
|||
return m_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the soundcard that is associated with the mixer
|
||||
*/
|
||||
const string& mixer::get_sound_card() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for events
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue