Home | History | Annotate | Download | only in tinyalsa

Lines Matching refs:mixer

0 /* mixer.c
48 struct mixer *mixer;
53 struct mixer {
61 void mixer_close(struct mixer *mixer)
65 if (!mixer)
68 if (mixer->fd >= 0)
69 close(mixer->fd);
71 if (mixer->ctl) {
72 for (n = 0; n < mixer->count; n++) {
73 if (mixer->ctl[n].ename) {
74 unsigned int max = mixer->ctl[n].info->value.enumerated.items;
76 free(mixer->ctl[n].ename[m]);
77 free(mixer->ctl[n].ename);
80 free(mixer->ctl);
83 if (mixer->elem_info)
84 free(mixer->elem_info);
86 free(mixer);
91 struct mixer *mixer_open(unsigned int card)
96 struct mixer *mixer = NULL;
110 mixer = calloc(1, sizeof(*mixer));
111 if (!mixer)
114 mixer->ctl = calloc(elist.count, sizeof(struct mixer_ctl));
115 mixer->elem_info = calloc(elist.count, sizeof(struct snd_ctl_elem_info));
116 if (!mixer->ctl || !mixer->elem_info)
119 if (ioctl(fd, SNDRV_CTL_IOCTL_CARD_INFO, &mixer->card_info) < 0)
126 mixer->count = elist.count;
127 mixer->fd = fd;
128 elist.space = mixer->count;
133 for (n = 0; n < mixer->count; n++) {
134 struct snd_ctl_elem_info *ei = mixer->elem_info + n;
138 mixer->ctl[n].info = ei;
139 mixer->ctl[n].mixer = mixer;
144 mixer->ctl[n].ename = enames;
159 return mixer;
165 if (mixer)
166 mixer_close(mixer);
172 const char *mixer_get_name(struct mixer *mixer)
174 return (const char *)mixer->card_info.name;
177 unsigned int mixer_get_num_ctls(struct mixer *mixer)
179 if (!mixer)
182 return mixer->count;
185 struct mixer_ctl *mixer_get_ctl(struct mixer *mixer, unsigned int id)
187 if (mixer && (id < mixer->count))
188 return mixer->ctl + id;
193 struct mixer_ctl *mixer_get_ctl_by_name(struct mixer *mixer, const char *name)
197 if (!mixer)
200 for (n = 0; n < mixer->count; n++)
201 if (!strcmp(name, (char*) mixer->elem_info[n].id.name))
202 return mixer->ctl + n;
209 ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_INFO, ctl->info);
310 ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_READ, &ev);
347 ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_READ, &ev);
382 ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_READ, &ev);
403 return ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev);
436 return ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev);
488 ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev);