summaryrefslogtreecommitdiff
path: root/src/control/control.c
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2009-05-12 08:05:50 +0200
committerJaroslav Kysela <perex@perex.cz>2009-05-15 14:18:15 +0200
commitecd6846c88d24f2a03895115b8ebf50679af69f3 (patch)
tree6880963798e200e7dcc3ef962e0149434bf709b1 /src/control/control.c
parent3e30007a19a0904ad7c8965b0883322639e52b82 (diff)
downloadalsa-lib-ecd6846c88d24f2a03895115b8ebf50679af69f3.tar.gz
Initial amixer implementation + ctl & hctl API mergingamixer
This patch adds new mixer API which simplifies the previous mixer API (removed mixer class). The control and hcontrol APIs were merged into one. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'src/control/control.c')
-rw-r--r--src/control/control.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/control/control.c b/src/control/control.c
index c0907973..0537ad2a 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -88,6 +88,8 @@ snd_ctl_type_t snd_ctl_type(snd_ctl_t *ctl)
int snd_ctl_close(snd_ctl_t *ctl)
{
int err;
+
+ snd_ctl_cache_free(ctl);
while (!list_empty(&ctl->async_handlers)) {
snd_async_handler_t *h = list_entry(&ctl->async_handlers.next, snd_async_handler_t, hlist);
snd_async_del_handler(h);
@@ -118,16 +120,18 @@ int snd_ctl_nonblock(snd_ctl_t *ctl, int nonblock)
}
#ifndef DOC_HIDDEN
-int snd_ctl_new(snd_ctl_t **ctlp, snd_ctl_type_t type, const char *name)
+int snd_ctl_new(snd_ctl_t **ctlp, snd_ctl_type_t type, const char *name, int mode)
{
snd_ctl_t *ctl;
ctl = calloc(1, sizeof(*ctl));
if (!ctl)
return -ENOMEM;
ctl->type = type;
+ ctl->mode = mode;
if (name)
ctl->name = strdup(name);
INIT_LIST_HEAD(&ctl->async_handlers);
+ INIT_LIST_HEAD(&ctl->elems);
*ctlp = ctl;
return 0;
}
@@ -218,7 +222,14 @@ int snd_ctl_poll_descriptors_revents(snd_ctl_t *ctl, struct pollfd *pfds, unsign
*/
int snd_ctl_subscribe_events(snd_ctl_t *ctl, int subscribe)
{
+ int err;
+
assert(ctl);
+ if (ctl->mode & SND_CTL_CACHE) {
+ err = snd_ctl_cache_load(ctl);
+ if (err < 0)
+ return err;
+ }
return ctl->ops->subscribe_events(ctl, subscribe);
}