index 7419d3f0e28e93128b0051ee25b763fd0780c4e7..8a0add01c2823b856751c2f9c8016382f776eefa 100644 (file)
--- a/mixer.c
+++ b/mixer.c
struct mixer {
int fd;
- struct snd_ctl_elem_info *info;
+ struct snd_ctl_card_info card_info;
+ struct snd_ctl_elem_info *elem_info;
struct mixer_ctl *ctl;
unsigned int count;
};
free(mixer->ctl);
}
- if (mixer->info)
- free(mixer->info);
+ if (mixer->elem_info)
+ free(mixer->elem_info);
free(mixer);
goto fail;
mixer->ctl = calloc(elist.count, sizeof(struct mixer_ctl));
- mixer->info = calloc(elist.count, sizeof(struct snd_ctl_elem_info));
- if (!mixer->ctl || !mixer->info)
+ mixer->elem_info = calloc(elist.count, sizeof(struct snd_ctl_elem_info));
+ if (!mixer->ctl || !mixer->elem_info)
+ goto fail;
+
+ if (ioctl(fd, SNDRV_CTL_IOCTL_CARD_INFO, &mixer->card_info) < 0)
goto fail;
eid = calloc(elist.count, sizeof(struct snd_ctl_elem_id));
goto fail;
for (n = 0; n < mixer->count; n++) {
- struct snd_ctl_elem_info *ei = mixer->info + n;
+ struct snd_ctl_elem_info *ei = mixer->elem_info + n;
ei->id.numid = eid[n].numid;
if (ioctl(fd, SNDRV_CTL_IOCTL_ELEM_INFO, ei) < 0)
goto fail;
return 0;
}
+const char *mixer_get_name(struct mixer *mixer)
+{
+ return (const char *)mixer->card_info.name;
+}
+
unsigned int mixer_get_num_ctls(struct mixer *mixer)
{
if (!mixer)
@@ -189,12 +198,17 @@ struct mixer_ctl *mixer_get_ctl_by_name(struct mixer *mixer, const char *name)
return NULL;
for (n = 0; n < mixer->count; n++)
- if (!strcmp(name, (char*) mixer->info[n].id.name))
+ if (!strcmp(name, (char*) mixer->elem_info[n].id.name))
return mixer->ctl + n;
return NULL;
}
+void mixer_ctl_update(struct mixer_ctl *ctl)
+{
+ ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_INFO, ctl->info);
+}
+
const char *mixer_ctl_get_name(struct mixer_ctl *ctl)
{
if (!ctl)
return -EINVAL;
}
+#ifdef OMAP_ENHANCEMENT
+int mixer_get_card_name(int card, char *str, size_t strlen)
+{
+ struct snd_ctl_card_info info;
+ char fn[256];
+ int fd;
+ int ret;
+
+ if (card > MAX_CARD_COUNT)
+ return -EINVAL;
+
+ if (!str)
+ return -EINVAL;
+
+ snprintf(fn, sizeof(fn), "/dev/snd/controlC%u", card);
+ fd = open(fn, O_RDWR);
+ if (fd < 0)
+ return -ENODEV;
+
+ ret = ioctl(fd, SNDRV_CTL_IOCTL_CARD_INFO, &info);
+ if (ret < 0) {
+ close(fd);
+ return ret;
+ }
+
+ strncpy(str, (char *)info.id, strlen);
+
+ close(fd);
+
+ return 0;
+}
+#endif