44 if ((err = snd_mixer_open(&handle, 0)) < 0) {
57 if ((err = snd_mixer_close(handle)) < 0) {
72 if ((err = snd_mixer_attach(handle, card.c_str())) < 0) {
73 snd_mixer_close(handle);
74 std::string msg=
"Mixer attach "; msg+=card;
86 if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0) {
87 snd_mixer_close(handle);
99 if ((err = snd_mixer_load(handle)) < 0) {
100 snd_mixer_close(handle);
133 mixerElements.resize(0);
134 for (snd_mixer_elem_t *elem = snd_mixer_first_elem(handle); elem; elem = snd_mixer_elem_next(elem)){
154 std::ostringstream oss;
165 std::ostringstream oss;
169 oss<<mixerElements[i];
176 for (
int i=0; i<mixerElements.size(); i++)
177 if (name.compare(mixerElements[i].name)==0)
191 return mixerElements[i].setPlaybackVol(v);
204 return mixerElements[i].setPlaybackVol(channel, v);
214 std::ostringstream ret;
216 ret<<
"{\"name\":\""<<name<<
"\",\"error\":"<< val <<
"}";
218 ret<<
"{\"name\":\""<<name<<
"\",\"val\":"<<val<<
"}";
230 std::ostringstream ret;
232 ret<<
"{\"name\":\""<<name<<
"\",\"channel\":"<< channel<<
",\"error\":"<< val <<
"}";
234 ret<<
"{\"name\":\""<<name<<
"\",\"channel\":"<< channel<<
",\"val\":"<<val<<
"}";
257 return mixerElements[i].setPlaybackVolDB(dB);
270 return mixerElements[i].setPlaybackVolDB(channel, dB);
280 std::ostringstream ret;
282 ret<<
"{\"name\":\""<<name<<
"\",\"error\":"<< err <<
"}";
284 ret<<
"{\"name\":\""<<name<<
"\",\"val\":"<< dB <<
"}";
296 std::ostringstream ret;
298 ret<<
"{\"name\":\""<<name<<
"\",\"channel\":"<< channel<<
",\"error\":"<< err <<
"}";
300 ret<<
"{\"name\":\""<<name<<
"\",\"channel\":"<< channel<<
",\"val\":"<< dB <<
"}";
323 return mixerElements[i].setPlaybackSwitch(v);
333 std::ostringstream ret;
335 ret<<
"{\"name\":\""<<name<<
"\",\"error\":"<< err <<
"}";
337 ret<<
"{\"name\":\""<<name<<
"\",\"switch\":"<< err <<
"}";
350 return mixerElements[i].setCaptureVol(v);
359 long setCaptureVol(std::string name, snd_mixer_selem_channel_id_t channel,
long v){
363 return mixerElements[i].setCaptureVol(channel, v);
373 std::ostringstream ret;
375 ret<<
"{\"name\":\""<<name<<
"\",\"error\":"<< val <<
"}";
377 ret<<
"{\"name\":\""<<name<<
"\",\"val\":"<<val<<
"}";
389 std::ostringstream ret;
391 ret<<
"{\"name\":\""<<name<<
"\",\"channel\":"<< channel<<
",\"error\":"<< val <<
"}";
393 ret<<
"{\"name\":\""<<name<<
"\",\"channel\":"<< channel<<
",\"val\":"<<val<<
"}";
416 return mixerElements[i].setCaptureVolDB(dB);
429 return mixerElements[i].setCaptureVolDB(channel, dB);
439 std::ostringstream ret;
441 ret<<
"{\"name\":\""<<name<<
"\",\"error\":"<< err <<
"}";
443 ret<<
"{\"name\":\""<<name<<
"\",\"val\":"<< dB <<
"}";
455 std::ostringstream ret;
457 ret<<
"{\"name\":\""<<name<<
"\",\"channel\":"<< channel<<
",\"error\":"<< err <<
"}";
459 ret<<
"{\"name\":\""<<name<<
"\",\"channel\":"<< channel<<
",\"val\":"<< dB <<
"}";
481 return mixerElements[i].setCaptureSwitch(v);
491 std::ostringstream ret;
493 ret<<
"{\"name\":\""<<name<<
"\",\"error\":"<< err <<
"}";
495 ret<<
"{\"name\":\""<<name<<
"\",\"switch\":"<< err <<
"}";
long setPlaybackVol(std::string name, long v)
long setCaptureVol(std::string name, long v)
#define ALSA_MIXER_NOT_OPEN_ERROR
error when mixer pointer is null
std::vector< MixerElement > mixerElements
The vector of all mixer elements.
int setPlaybackVolDB(std::string name, double &dB)
int openCard(std::string card)
#define MIXER_NOT_OPEN_CHECK(handle)
std::string setPlaybackChVolJSON(std::string name, int channel, long v)
std::string setCaptureChVolDBJSON(std::string name, snd_mixer_selem_channel_id_t channel, double dB)
int setCaptureChVolDB(std::string name, snd_mixer_selem_channel_id_t channel, double &dB)
virtual int evaluateError(int errorNum)
std::string setPlaybackChVolDBJSON(std::string name, snd_mixer_selem_channel_id_t channel, double dB)
std::string setPlaybackChVolJSON(std::string name, snd_mixer_selem_channel_id_t channel, long v)
std::string setPlaybackVolDBJSON(std::string name, double dB)
int setCaptureVolDB(std::string name, double &dB)
int getElementIndex(std::string name)
long setCaptureVol(std::string name, snd_mixer_selem_channel_id_t channel, long v)
std::string setCaptureChVolDBJSON(std::string name, int channel, double dB)
#define ALSA_MIXER_FIND_ELEMENT_ERROR
error when trying to find a mixer element
long setPlaybackChVol(std::string name, snd_mixer_selem_channel_id_t channel, long v)
std::string setCaptureChVolJSON(std::string name, snd_mixer_selem_channel_id_t channel, long v)
friend std::ostream & operator<<(std::ostream &os, Mixer &m)
std::string setPlaybackVolJSON(std::string name, long v)
int setPlaybackChVolDB(std::string name, snd_mixer_selem_channel_id_t channel, double &dB)
std::string setCaptureSwitchJSON(std::string name, int v)
int setCaptureSwitch(std::string name, int v)
int attach(std::string card)
std::string setPlaybackChVolDBJSON(std::string name, int channel, double dB)
std::string setPlaybackSwitchJSON(std::string name, int v)
std::string setCaptureVolJSON(std::string name, long v)
std::string setCaptureChVolJSON(std::string name, int channel, long v)
int setPlaybackSwitch(std::string name, int v)
std::string setCaptureVolDBJSON(std::string name, double dB)
std::string getElementState(std::string name)