1 #include "wmmixer-alsa.h"
6 if((err
=snd_mixer_open(&mixer_handle
,CARD_NUM
,MIXER_NUM
))<0)
8 fprintf(stderr
,"Mixer open failed: %s\n",snd_strerror(err
));
15 void init_elements(void)
19 memset(&elements
,0,sizeof(elements
));
20 if((err
=snd_mixer_elements(mixer_handle
,&elements
))<0)
22 fprintf(stderr
,"Elements error: %s\n",snd_strerror(err
));
25 elements
.pelements
=(snd_mixer_eid_t
*)malloc(elements
.elements_over
*sizeof(snd_mixer_eid_t
));
26 if(!elements
.pelements
)
28 fprintf(stderr
,"Elements error: Not enough memory\n");
31 elements
.elements_size
=elements
.elements_over
;
32 elements
.elements_over
=elements
.elements
=0;
33 if((err
=snd_mixer_elements(mixer_handle
,&elements
))<0)
35 fprintf(stderr
,"Elements error: %s\n",snd_strerror(err
));
38 for(i
=0;i
<elements
.elements
;i
++)
41 if(elements
.pelements
[i
].type
!=SND_MIXER_ETYPE_VOLUME1
)
43 if(snd_mixer_element_has_control(&elements
.pelements
[i
])!=1)
45 if(snd_mixer_element_has_info(&elements
.pelements
[i
])!=1)
48 e
->element
.eid
=elements
.pelements
[i
];
49 if((err
=snd_mixer_element_build(mixer_handle
,&e
->element
))<0)
51 fprintf(stderr
,"Element error: %s\n",snd_strerror(err
));
54 e
->info
.eid
=elements
.pelements
[i
];
55 if((err
=snd_mixer_element_info_build(mixer_handle
,&e
->info
))<0)
57 fprintf(stderr
,"Element info error: %s\n",snd_strerror(err
));
62 free((void *)elements
.pelements
);
66 elementinfo
*add_element(void)
70 element
=(elementinfo
*)malloc(sizeof(elementinfo
));
73 memset(&element
->info
,0,sizeof(element
->info
));
74 memset(&element
->element
,0,sizeof(element
->element
));
83 e
->next
=(elementinfo
*)malloc(sizeof(elementinfo
));
87 memset(&e
->info
,0,sizeof(e
->info
));
88 memset(&e
->element
,0,sizeof(e
->element
));