gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
MixerElement.H
Go to the documentation of this file.
1 /* Copyright 2000-2018 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16 */
17 #ifndef MIXERELEMENT_H_
18 #define MIXERELEMENT_H_
19 
20 #include <ALSA/ALSA.H>
21 #include <string>
22 #include <sstream>
23 
24 namespace ALSA {
25 
29  protected:
30  long volDB;
31  public:
32  long vol;
33  double dB;
34  int sw;
35  snd_mixer_selem_channel_id_t channel;
36 
37  ChannelElement(snd_mixer_selem_channel_id_t ch){
38  vol=volDB=0;
39  dB=0.;
40  channel=ch;
41  }
42 
43  virtual ~ChannelElement(){}
44 
45  double toDB(long v) const {
46  return (double)v/100.;
47  }
48 
49  long fromDB(double d) const {
50  return (long)(d*100.);
51  }
52 
53  void outputLevel(std::ostream &os){
54  os<<"{\"channel\": "<<channel<<", "<<"\"level\":"<<vol<<", \"dB\":"<<dB<<"}";
55  }
56 
57  void outputSwitch(std::ostream &os){
58  os<<"{\"channel\": "<<channel<<", "<<"\"switch\":"<<sw<<"}";
59  }
60 
61  void outputLevelAndSwitch(std::ostream &os){
62  os<<"{\"channel\": "<<channel<<", "<<"\"level\":"<<vol<<", \"dB\":"<<dB
63  <<", "<<"\"switch\":"<<sw<<"}";
64  }
65  };
66 
70  public:
71  ChannelPlaybackElement(snd_mixer_selem_channel_id_t ch) : ChannelElement(ch) {}
72 
74 
79  int getLevels(snd_mixer_elem_t *elem){
80  int err=0;
81  if ((err=snd_mixer_selem_get_playback_volume(elem, channel, &vol))<0)
82  return ALSADebug().evaluateError(ALSA_MIXER_QUERY_ERROR, "getting playback volume\n");
83  if ((err=snd_mixer_selem_get_playback_dB(elem, channel, &volDB))<0)
84  return ALSADebug().evaluateError(ALSA_MIXER_QUERY_ERROR, "getting playback dB\n");
85  dB=toDB(volDB); // convert it to a dB value
86  return 0;
87  }
88 
93  int getSwitch(snd_mixer_elem_t *elem){
94  int err=0;
95  if ((err=snd_mixer_selem_get_playback_switch(elem, channel, &sw))<0)
96  return ALSADebug().evaluateError(ALSA_MIXER_QUERY_ERROR, "getting playback switch\n");
97  return 0;
98  }
99  };
100 
104  public:
105  ChannelCaptureElement(snd_mixer_selem_channel_id_t ch) : ChannelElement(ch) {}
107 
112  int getLevels(snd_mixer_elem_t *elem){
113  int err=0;
114  if ((err=snd_mixer_selem_get_capture_volume(elem, channel, &vol))<0)
115  return ALSADebug().evaluateError(ALSA_MIXER_QUERY_ERROR, "getting capture volume\n");
116  if ((err=snd_mixer_selem_get_capture_dB(elem, channel, &volDB))<0)
117  return ALSADebug().evaluateError(ALSA_MIXER_QUERY_ERROR, "getting capture dB\n");
118  dB=toDB(volDB); // convert it to a dB value
119  return 0;
120  }
121 
126  int getSwitch(snd_mixer_elem_t *elem){
127  int err=0;
128  if ((err=snd_mixer_selem_get_capture_switch(elem, channel, &sw))<0)
129  return ALSADebug().evaluateError(ALSA_MIXER_QUERY_ERROR, "getting catpure switch\n");
130  return 0;
131  }
132  };
133 
136  class MixerElement {
137  public:
138  std::string name;
139  snd_mixer_elem_t *elem;
140  unsigned int index;
160 
161  std::vector<ChannelPlaybackElement> playbackVolumes;
162  std::vector<ChannelCaptureElement> captureVolumes;
163  public:
165  name="";
166  index=0;
167  elem=NULL;
168 
169  playbackVolMax=playbackVolMin=0;
170  playbackVolMaxDB=playbackVolMinDB=0.;
171  captureVolMax=captureVolMin=0;
172  captureVolMaxDB=captureVolMinDB=0.;
173  hasCommonVolume=false;
174  hasPlaybackVolume=false;
175  hasPlaybackVolumeJoined=false;
176  hasCaptureVolume=false;
177  hasCaptureVolumeJoined=false;
178  hasCommonSwitch=false;
179  hasPlaybackSwitch=false;
180  hasPlaybackSwitchJoined=false;
181  hasCaptureSwitch=false;
182  hasCaptureSwitchJoined=false;
183  hasCaptureSwitchExclusive=false;
184  }
185 
186  MixerElement(snd_mixer_elem_t *e){
187  elem=e;
188  name=snd_mixer_selem_get_name(elem);
189  index=snd_mixer_selem_get_index(elem);
190 
191  playbackVolMax=playbackVolMin=0;
192  playbackVolMaxDB=playbackVolMinDB=0.;
193  captureVolMax=captureVolMin=0;
194  captureVolMaxDB=captureVolMinDB=0.;
195 
196  hasCommonVolume=snd_mixer_selem_has_common_volume(elem);
197  hasPlaybackVolume=snd_mixer_selem_has_playback_volume(elem);
198  hasPlaybackVolumeJoined=snd_mixer_selem_has_playback_volume_joined(elem);
199  hasCaptureVolume=snd_mixer_selem_has_capture_volume(elem);
200  hasCaptureVolumeJoined=snd_mixer_selem_has_capture_volume_joined(elem);
201  hasCommonSwitch=snd_mixer_selem_has_common_switch(elem);
202  hasPlaybackSwitch=snd_mixer_selem_has_playback_switch(elem);
203  hasPlaybackSwitchJoined=snd_mixer_selem_has_playback_switch_joined(elem);
204  hasCaptureSwitch=snd_mixer_selem_has_capture_switch(elem);
205  hasCaptureSwitchJoined=snd_mixer_selem_has_capture_switch_joined(elem);
206  hasCaptureSwitchExclusive=snd_mixer_selem_has_capture_switch_exclusive(elem);
207 
208  unsigned long chMask=1;
209  for (int i=0; i<SND_MIXER_SCHN_LAST; i++){
210  if (snd_mixer_selem_has_playback_channel(elem, (snd_mixer_selem_channel_id_t)i)>0){
211  playbackVolumes.push_back(ChannelPlaybackElement((snd_mixer_selem_channel_id_t)i));
212  if (hasPlaybackVolume || hasPlaybackVolumeJoined)
213  playbackVolumes[playbackVolumes.size()-1].getLevels(elem);
214  if (hasCommonSwitch || hasPlaybackSwitch || hasPlaybackSwitchJoined)
215  playbackVolumes[playbackVolumes.size()-1].getSwitch(elem);
216  }
217  }
218 
219  for (int i=0; i<SND_MIXER_SCHN_LAST; i++)
220  if (snd_mixer_selem_has_capture_channel(elem, (snd_mixer_selem_channel_id_t)i)>0){
221  captureVolumes.push_back(ChannelCaptureElement((snd_mixer_selem_channel_id_t)i));
222  if (hasCaptureVolume || hasCaptureVolumeJoined)
223  captureVolumes[captureVolumes.size()-1].getLevels(elem);
224  if (hasCommonSwitch || hasCaptureSwitch || hasCaptureSwitchJoined)
225  captureVolumes[captureVolumes.size()-1].getSwitch(elem);
226  }
227 
228  if (hasPlaybackVolume || hasPlaybackVolumeJoined){
229  if (snd_mixer_selem_get_playback_volume_range(elem, &playbackVolMin, &playbackVolMax))
230  ALSADebug().evaluateError(ALSA_MIXER_QUERY_ERROR, "playback volume range");
231  long min, max;
232  if (snd_mixer_selem_get_playback_dB_range(elem, &min, &max))
233  ALSADebug().evaluateError(ALSA_MIXER_QUERY_ERROR, "playback dB range");
234  playbackVolMinDB=ChannelElement((snd_mixer_selem_channel_id_t)0).toDB(min); // dummy id
235  playbackVolMaxDB=ChannelElement((snd_mixer_selem_channel_id_t)0).toDB(max); // dummy id
236  }
237 
238  if (hasCaptureVolume || hasCaptureVolumeJoined){
239  if (snd_mixer_selem_get_capture_volume_range(elem, &captureVolMin, &captureVolMax))
240  ALSADebug().evaluateError(ALSA_MIXER_QUERY_ERROR, "capture volume range");
241  long min, max;
242  if (snd_mixer_selem_get_capture_dB_range(elem, &min, &max))
243  ALSADebug().evaluateError(ALSA_MIXER_QUERY_ERROR, "capture dB range");
244  captureVolMinDB=ChannelElement((snd_mixer_selem_channel_id_t)0).toDB(min); // dummy id
245  captureVolMaxDB=ChannelElement((snd_mixer_selem_channel_id_t)0).toDB(max); // dummy id
246  }
247  }
248 
249  virtual ~MixerElement(){
250  }
251 
256  int setPlaybackSwitch(int v){
257  int err;
258  if (!hasCommonSwitch && !hasPlaybackSwitch && !hasPlaybackSwitchJoined)
259  return ALSADebug().evaluateError(ALSA_MIXER_NO_PLAYBACK_VOL_ERROR, name+" doesn't have a playback switch and I tried to set it\n");
260  for (int i=0; i<playbackVolumes.size(); i++){
261  if ((err=snd_mixer_selem_set_playback_switch(elem, playbackVolumes[i].channel, v))<0)
262  return ALSADebug().evaluateError(err, name+" setting playback switches"+'\n');
263  if ((err=playbackVolumes[i].getSwitch(elem))<0) // refresh the playback level
264  return ALSADebug().evaluateError(err, name+" getting playback switches"+'\n');
265  }
266  return playbackVolumes[0].sw; // all channels have the same volume in this method
267  }
268 
273  long setPlaybackVol(long v){
274  int err;
275  if (!hasPlaybackVolume && !hasPlaybackVolumeJoined)
276  return ALSADebug().evaluateError(ALSA_MIXER_NO_PLAYBACK_VOL_ERROR, name+" doesn't have a playback volume and I tried to set it\n");
277  for (int i=0; i<playbackVolumes.size(); i++){
278  if ((err=snd_mixer_selem_set_playback_volume(elem, playbackVolumes[i].channel, v))<0)
279  return ALSADebug().evaluateError(err, name+" setting playback levels"+'\n');
280  if ((err=playbackVolumes[i].getLevels(elem))<0) // refresh the playback level
281  return ALSADebug().evaluateError(err, name+" getting playback levels"+'\n');
282  }
283  return playbackVolumes[0].vol; // all channels have the same volume in this method
284  }
285 
291  long setPlaybackVol(snd_mixer_selem_channel_id_t channel, long v){
292  int err;
293  if (!hasPlaybackVolume && !hasPlaybackVolumeJoined)
294  return ALSADebug().evaluateError(ALSA_MIXER_NO_PLAYBACK_VOL_ERROR, name+" doesn't have a playback volume and I tried to set it\n");
295  for (int i=0; i<playbackVolumes.size(); i++)
296  if (channel==playbackVolumes[i].channel){
297  if ((err=snd_mixer_selem_set_playback_volume (elem, playbackVolumes[i].channel, v))<0)
298  return ALSADebug().evaluateError(err, name+" setting playback level for this channel"+'\n');
299  if ((err=playbackVolumes[i].getLevels(elem))<0) // refresh the playback level
300  return ALSADebug().evaluateError(err, name+" getting playback level for this channel"+'\n');
301  return playbackVolumes[i].vol; // all channels have the same volume in this method
302  }
303  return ALSADebug().evaluateError(ALSA_MIXER_NO_CHANNEL_ERROR, name+" channel not found");
304  }
305 
310  int setPlaybackVolDB(double &dB){
311  int err;
312  if (!hasPlaybackVolume && !hasPlaybackVolumeJoined)
313  return ALSADebug().evaluateError(ALSA_MIXER_NO_PLAYBACK_VOL_ERROR, name+" doesn't have a playback volume and I tried to set it\n");
314  for (int i=0; i<playbackVolumes.size(); i++){
315  if ((err=snd_mixer_selem_set_playback_dB(elem, playbackVolumes[i].channel, ChannelElement((snd_mixer_selem_channel_id_t)0).fromDB(dB), 1))<0)
316  return ALSADebug().evaluateError(err, name+" setting playback levels"+'\n');
317  if ((err=playbackVolumes[i].getLevels(elem))<0) // refresh the playback level
318  return ALSADebug().evaluateError(err, name+" getting playback levels"+'\n');
319  dB=playbackVolumes[i].dB; // all channels have the same volume in this method
320  }
321  return 0;
322  }
323 
329  long setPlaybackVolDB(snd_mixer_selem_channel_id_t channel, double &dB){
330  int err;
331  if (!hasPlaybackVolume && !hasPlaybackVolumeJoined)
332  return ALSADebug().evaluateError(ALSA_MIXER_NO_PLAYBACK_VOL_ERROR, name+" doesn't have a playback volume and I tried to set it\n");
333  for (int i=0; i<playbackVolumes.size(); i++)
334  if (channel==playbackVolumes[i].channel){
335  if ((err=snd_mixer_selem_set_playback_dB(elem, playbackVolumes[i].channel, ChannelElement((snd_mixer_selem_channel_id_t)0).fromDB(dB),1))<0) // dummy id
336  return ALSADebug().evaluateError(err, name+" setting playback level for this channel"+'\n');
337  if ((err=playbackVolumes[i].getLevels(elem))<0) // refresh the playback level
338  return ALSADebug().evaluateError(err, name+" getting playback level for this channel"+'\n');
339  dB=playbackVolumes[i].dB; // all channels have the same volume in this method
340  return 0;
341  }
342  return ALSADebug().evaluateError(ALSA_MIXER_NO_CHANNEL_ERROR, name+" channel not found");
343  }
344 
349  int setCaptureSwitch(int v){
350  int err;
351  if (!hasCommonSwitch && !hasCaptureSwitch && !hasCaptureSwitchJoined)
352  return ALSADebug().evaluateError(ALSA_MIXER_NO_PLAYBACK_VOL_ERROR, name+" doesn't have a capture switch and I tried to set it\n");
353  for (int i=0; i<captureVolumes.size(); i++){
354  if ((err=snd_mixer_selem_set_capture_switch(elem, captureVolumes[i].channel, v))<0)
355  return ALSADebug().evaluateError(err, name+" setting capture switches"+'\n');
356  if ((err=captureVolumes[i].getSwitch(elem))<0) // refresh the capture level
357  return ALSADebug().evaluateError(err, name+" getting capture switches"+'\n');
358  }
359  return captureVolumes[0].sw; // all channels have the same volume in this method
360  }
361 
366  long setCaptureVol(long v){
367  int err;
368  if (!hasCaptureVolume && !hasCaptureVolumeJoined)
369  return ALSADebug().evaluateError(ALSA_MIXER_NO_PLAYBACK_VOL_ERROR, name+" doesn't have a capture volume and I tried to set it\n");
370  for (int i=0; i<captureVolumes.size(); i++){
371  if ((err=snd_mixer_selem_set_capture_volume(elem, captureVolumes[i].channel, v))<0)
372  return ALSADebug().evaluateError(err, name+" setting capture levels"+'\n');
373  if ((err=captureVolumes[i].getLevels(elem))<0) // refresh the capture level
374  return ALSADebug().evaluateError(err, name+" getting capture levels"+'\n');
375  }
376  return captureVolumes[0].vol; // all channels have the same volume in this method
377  }
378 
384  long setCaptureVol(snd_mixer_selem_channel_id_t channel, long v){
385  int err;
386  if (!hasCaptureVolume && !hasCaptureVolumeJoined)
387  return ALSADebug().evaluateError(ALSA_MIXER_NO_PLAYBACK_VOL_ERROR, name+" doesn't have a capture volume and I tried to set it\n");
388  for (int i=0; i<captureVolumes.size(); i++)
389  if (channel==captureVolumes[i].channel){
390  if ((err=snd_mixer_selem_set_capture_volume (elem, captureVolumes[i].channel, v))<0)
391  return ALSADebug().evaluateError(err, name+" setting capture level for this channel"+'\n');
392  if ((err=captureVolumes[i].getLevels(elem))<0) // refresh the capture level
393  return ALSADebug().evaluateError(err, name+" getting capture level for this channel"+'\n');
394  return captureVolumes[i].vol; // all channels have the same volume in this method
395  }
396  return ALSADebug().evaluateError(ALSA_MIXER_NO_CHANNEL_ERROR, name+" channel not found");
397  }
398 
403  int setCaptureVolDB(double &dB){
404  int err;
405  if (!hasCaptureVolume && !hasCaptureVolumeJoined)
406  return ALSADebug().evaluateError(ALSA_MIXER_NO_PLAYBACK_VOL_ERROR, name+" doesn't have a capture volume and I tried to set it\n");
407  for (int i=0; i<captureVolumes.size(); i++){
408  if ((err=snd_mixer_selem_set_capture_dB(elem, captureVolumes[i].channel, ChannelElement((snd_mixer_selem_channel_id_t)0).fromDB(dB), 1))<0)
409  return ALSADebug().evaluateError(err, name+" setting capture levels"+'\n');
410  if ((err=captureVolumes[i].getLevels(elem))<0) // refresh the capture level
411  return ALSADebug().evaluateError(err, name+" getting capture levels"+'\n');
412  dB=captureVolumes[i].dB; // all channels have the same volume in this method
413  }
414  return 0;
415  }
416 
422  long setCaptureVolDB(snd_mixer_selem_channel_id_t channel, double &dB){
423  int err;
424  if (!hasCaptureVolume && !hasCaptureVolumeJoined)
425  return ALSADebug().evaluateError(ALSA_MIXER_NO_PLAYBACK_VOL_ERROR, name+" doesn't have a capture volume and I tried to set it\n");
426  for (int i=0; i<captureVolumes.size(); i++)
427  if (channel==captureVolumes[i].channel){
428  if ((err=snd_mixer_selem_set_capture_dB(elem, captureVolumes[i].channel, ChannelElement((snd_mixer_selem_channel_id_t)0).fromDB(dB),1))<0) // dummy id
429  return ALSADebug().evaluateError(err, name+" setting capture level for this channel"+'\n');
430  if ((err=captureVolumes[i].getLevels(elem))<0) // refresh the capture level
431  return ALSADebug().evaluateError(err, name+" getting capture level for this channel"+'\n');
432  dB=captureVolumes[i].dB; // all channels have the same volume in this method
433  return 0;
434  }
435  return ALSADebug().evaluateError(ALSA_MIXER_NO_CHANNEL_ERROR, name+" channel not found");
436  }
437 
438  friend std::ostream &operator<<(std::ostream &os, MixerElement &me){
439  os<<"{";
440  os<<"\"name\":\""<<me.name<<"\",\n";
441  os<<"\"index\":"<<me.index<<",\n";
442  os<<"\"hasCommonVolume\":"<<me.hasCommonVolume<<",\n";
443  os<<"\"hasPlaybackVolume\":"<<me.hasPlaybackVolume<<",\n";
444  os<<"\"hasPlaybackVolumeJoined\":"<<me.hasPlaybackVolumeJoined<<",\n";
445  os<<"\"hasCaptureVolume\":"<<me.hasCaptureVolume<<",\n";
446  os<<"\"hasCaptureVolumeJoined\":"<<me.hasCaptureVolumeJoined<<",\n";
447  os<<"\"hasCommonSwitch\":"<<me.hasCommonSwitch<<",\n";
448  os<<"\"hasPlaybackSwitch\":"<<me.hasPlaybackSwitch<<",\n";
449  os<<"\"hasPlaybackSwitchJoined\":"<<me.hasPlaybackSwitchJoined<<",\n";
450  os<<"\"hasCaptureSwitch\":"<<me.hasCaptureSwitch<<",\n";
451  os<<"\"hasCaptureSwitchJoined\":"<<me.hasCaptureSwitchJoined<<",\n";
452  os<<"\"hasCaptureSwitchExclusive\":"<<me.hasCaptureSwitchExclusive<<"\n";
453 
455  os<<",\"playbackVolMax\":"<<me.playbackVolMax<<"\n";
456  os<<",\"playbackVolMin\":"<<me.playbackVolMin<<"\n";
457  os<<",\"playbackVolMaxDB\":"<<me.playbackVolMaxDB<<"\n";
458  os<<",\"playbackVolMinDB\":"<<me.playbackVolMinDB<<"\n";
459  }
460 
462  os<<",\"captureVolMax\":"<<me.captureVolMax<<"\n";
463  os<<",\"captureVolMin\":"<<me.captureVolMin<<"\n";
464  os<<",\"captureVolMaxDB\":"<<me.captureVolMaxDB<<"\n";
465  os<<",\"captureVolMinDB\":"<<me.captureVolMinDB<<"\n";
466  }
467 
469  os<<",\"playbackVolumes\":[\n";
470  for (int i=0; i<me.playbackVolumes.size(); i++){
471  me.playbackVolumes[i].outputLevelAndSwitch(os);
472  os<<((i<me.playbackVolumes.size()-1) ? ",\n" : "\n");
473  }
474  os<<"]\n";
475  } else
477  os<<",\"playbackVolumes\":[\n";
478  for (int i=0; i<me.playbackVolumes.size(); i++){
479  me.playbackVolumes[i].outputLevel(os);
480  os<<((i<me.playbackVolumes.size()-1) ? ",\n" : "\n");
481  }
482  os<<"]\n";
483  } else
485  os<<",\"playbackVolumes\":[\n";
486  for (int i=0; i<me.playbackVolumes.size(); i++){
487  me.playbackVolumes[i].outputSwitch(os);
488  os<<((i<me.playbackVolumes.size()-1) ? ",\n" : "\n");
489  }
490  os<<"]\n";
491  }
492 
494  os<<",\"captureVolumes\":[\n";
495  for (int i=0; i<me.captureVolumes.size(); i++){
496  me.captureVolumes[i].outputLevelAndSwitch(os);
497  os<<((i<me.captureVolumes.size()-1) ? ",\n" : "\n");
498  }
499  os<<"]\n";
500  } else
502  os<<",\"captureVolumes\":[\n";
503  for (int i=0; i<me.captureVolumes.size(); i++){
504  me.captureVolumes[i].outputLevel(os);
505  os<<((i<me.captureVolumes.size()-1) ? ",\n" : "\n");
506  }
507  os<<"]\n";
508  } else
510  os<<",\"captureVolumes\":[\n";
511  for (int i=0; i<me.captureVolumes.size(); i++){
512  me.captureVolumes[i].outputSwitch(os);
513  os<<((i<me.captureVolumes.size()-1) ? ",\n" : "\n");
514  }
515  os<<"]\n";
516  }
517  os<<"}";
518  return os;
519  }
520  };
521 }
522 #endif // MIXERELEMENT_H_
long setPlaybackVolDB(snd_mixer_selem_channel_id_t channel, double &dB)
Definition: MixerElement.H:329
ChannelPlaybackElement(snd_mixer_selem_channel_id_t ch)
Definition: MixerElement.H:71
bool hasPlaybackSwitch
0 if no control is present, 1 if it&#39;s present
Definition: MixerElement.H:147
virtual ~ChannelElement()
Definition: MixerElement.H:43
snd_mixer_elem_t * elem
The pointer to the element.
Definition: MixerElement.H:139
ChannelCaptureElement(snd_mixer_selem_channel_id_t ch)
Definition: MixerElement.H:105
long setCaptureVol(long v)
Definition: MixerElement.H:366
double toDB(long v) const
Definition: MixerElement.H:45
bool hasCaptureVolume
0 if no control is present, 1 if it&#39;s present
Definition: MixerElement.H:144
long setPlaybackVol(long v)
Definition: MixerElement.H:273
void outputSwitch(std::ostream &os)
Definition: MixerElement.H:57
int getLevels(snd_mixer_elem_t *elem)
Definition: MixerElement.H:112
void outputLevelAndSwitch(std::ostream &os)
Definition: MixerElement.H:61
Definition: ALSA.H:26
friend std::ostream & operator<<(std::ostream &os, MixerElement &me)
Definition: MixerElement.H:438
#define ALSA_MIXER_NO_CHANNEL_ERROR
error when we can&#39;t find the prescribed channel
Definition: ALSADebug.H:36
long setCaptureVol(snd_mixer_selem_channel_id_t channel, long v)
Definition: MixerElement.H:384
bool hasPlaybackVolume
0 if no control is present, 1 if it&#39;s present
Definition: MixerElement.H:142
int getSwitch(snd_mixer_elem_t *elem)
Definition: MixerElement.H:126
virtual int evaluateError(int errorNum)
Definition: ALSADebug.H:61
ChannelElement(snd_mixer_selem_channel_id_t ch)
Definition: MixerElement.H:37
bool hasPlaybackVolumeJoined
0 if control is separated per channel, 1 if control acts on all channels together ...
Definition: MixerElement.H:143
bool hasCaptureSwitchExclusive
0 if control is separated per element, 1 if control acts on other elements too (i.e. only one active at a time inside a group)
Definition: MixerElement.H:151
#define ALSA_MIXER_QUERY_ERROR
error when attempting to query the mixer
Definition: ALSADebug.H:33
bool hasCaptureSwitchJoined
0 if control is separated per channel, 1 if control acts on all channels together ...
Definition: MixerElement.H:150
long setPlaybackVol(snd_mixer_selem_channel_id_t channel, long v)
Definition: MixerElement.H:291
long setCaptureVolDB(snd_mixer_selem_channel_id_t channel, double &dB)
Definition: MixerElement.H:422
long vol
If the channel has a volume, this holds its state.
Definition: MixerElement.H:32
int setCaptureSwitch(int v)
Definition: MixerElement.H:349
int getSwitch(snd_mixer_elem_t *elem)
Definition: MixerElement.H:93
long fromDB(double d) const
Definition: MixerElement.H:49
snd_mixer_selem_channel_id_t channel
Definition: MixerElement.H:35
void outputLevel(std::ostream &os)
Definition: MixerElement.H:53
bool hasCaptureSwitch
0 if no control is present, 1 if it&#39;s present
Definition: MixerElement.H:149
bool hasPlaybackSwitchJoined
0 if control is separated per channel, 1 if control acts on all channels together ...
Definition: MixerElement.H:148
#define ALSA_MIXER_NO_PLAYBACK_VOL_ERROR
error this mixer element is not a playback element
Definition: ALSADebug.H:37
bool hasCaptureVolumeJoined
0 if control is separated per channel, 1 if control acts on all channels together ...
Definition: MixerElement.H:145
long volDB
If the channel has a volume, this holds its state in 100*dB.
Definition: MixerElement.H:30
int setPlaybackSwitch(int v)
Definition: MixerElement.H:256
std::vector< ChannelCaptureElement > captureVolumes
Volume setting for each capture channel in this mixer element.
Definition: MixerElement.H:162
std::vector< ChannelPlaybackElement > playbackVolumes
Volume setting for each playback channel in this mixer element.
Definition: MixerElement.H:161
double dB
If the channel has a volume, this holds its state in dB.
Definition: MixerElement.H:33
int setPlaybackVolDB(double &dB)
Definition: MixerElement.H:310
bool hasCommonVolume
element has only one volume control for both playback and capture
Definition: MixerElement.H:141
bool hasCommonSwitch
0 separated control, 1 common control
Definition: MixerElement.H:146
virtual ~MixerElement()
Definition: MixerElement.H:249
std::string name
The mixer element name.
Definition: MixerElement.H:138
int getLevels(snd_mixer_elem_t *elem)
Definition: MixerElement.H:79
MixerElement(snd_mixer_elem_t *e)
Definition: MixerElement.H:186
int setCaptureVolDB(double &dB)
Definition: MixerElement.H:403
unsigned int index
The mixer element index.
Definition: MixerElement.H:140
int sw
If the channel has a switch, this holds its state.
Definition: MixerElement.H:34
gtkIOStream: /tmp/gtkiostream/include/ALSA/MixerElement.H Source File
GTK+ IOStream  Beta