From 5af75610f2c7b86dbd4fe856172341ad8140c94b Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 24 Aug 2005 10:41:16 +0000 Subject: [PATCH] mixer API - extend simple enumerated controls for direction tests Added snd_mixer_selem_is_enum_playback() and snd_mixer_selem_is_enum_capture() functions. --- include/mixer.h | 2 ++ include/mixer_abst.h | 3 ++- src/Versions | 2 ++ src/mixer/simple.c | 26 +++++++++++++++++++++++++- src/mixer/simple_none.c | 8 +++++++- 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/include/mixer.h b/include/mixer.h index 219461f1..16311386 100644 --- a/include/mixer.h +++ b/include/mixer.h @@ -282,6 +282,8 @@ int snd_mixer_selem_set_capture_volume_range(snd_mixer_elem_t *elem, long min, long max); int snd_mixer_selem_is_enumerated(snd_mixer_elem_t *elem); +int snd_mixer_selem_is_enum_playback(snd_mixer_elem_t *elem); +int snd_mixer_selem_is_enum_capture(snd_mixer_elem_t *elem); int snd_mixer_selem_get_enum_items(snd_mixer_elem_t *elem); int snd_mixer_selem_get_enum_item_name(snd_mixer_elem_t *elem, unsigned int idx, size_t maxlen, char *str); int snd_mixer_selem_get_enum_item(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, unsigned int *idxp); diff --git a/include/mixer_abst.h b/include/mixer_abst.h index c1f05705..e538d08e 100644 --- a/include/mixer_abst.h +++ b/include/mixer_abst.h @@ -50,7 +50,8 @@ extern "C" { #define SM_CAP_CSWITCH (1<<9) #define SM_CAP_CSWITCH_JOIN (1<<10) #define SM_CAP_CSWITCH_EXCL (1<<11) -#define SM_CAP_ENUM (1<<12) +#define SM_CAP_PENUM (1<<12) +#define SM_CAP_CENUM (1<<13) /* SM_CAP_* 24-31 => private for module use */ #define SM_OPS_IS_ACTIVE 0 diff --git a/src/Versions b/src/Versions index c85c246c..02e86ba4 100644 --- a/src/Versions +++ b/src/Versions @@ -254,6 +254,8 @@ ALSA_1.0.10 { snd_mixer_selem_set_playback_dB_all; snd_mixer_selem_set_capture_dB_all; + snd_mixer_selem_is_enum_playback; + snd_mixer_selem_is_enum_capture; snd_mixer_selem_compare; snd_mixer_sbasic_info; snd_mixer_sbasic_get_private; diff --git a/src/mixer/simple.c b/src/mixer/simple.c index 29c273e8..621ab219 100644 --- a/src/mixer/simple.c +++ b/src/mixer/simple.c @@ -102,7 +102,7 @@ int snd_mixer_selem_register(snd_mixer_t *mixer, } #define CHECK_ENUM(xelem) \ - if (!((sm_selem_t *)(elem)->private_data)->caps & SM_CAP_ENUM) \ + if (!((sm_selem_t *)(elem)->private_data)->caps & (SM_CAP_PENUM|SM_CAP_CENUM)) \ return -EINVAL; #define COND_CAPS(xelem, what) \ @@ -821,6 +821,30 @@ int snd_mixer_selem_is_enumerated(snd_mixer_elem_t *elem) return sm_selem_ops(elem)->is(elem, SM_PLAY, SM_OPS_IS_ENUMERATED, 0); } +/** + * \brief Return true if mixer simple enumerated element belongs to the playback direction + * \param elem Mixer simple element handle + * \return 0 no playback direction, 1 playback direction + */ +int snd_mixer_selem_is_enum_playback(snd_mixer_elem_t *elem) +{ + CHECK_BASIC(elem); + CHECK_ENUM(elem); + return sm_selem_ops(elem)->is(elem, SM_PLAY, SM_OPS_IS_ENUMERATED, 1); +} + +/** + * \brief Return true if mixer simple enumerated element belongs to the capture direction + * \param elem Mixer simple element handle + * \return 0 no capture direction, 1 capture direction + */ +int snd_mixer_selem_is_enum_capture(snd_mixer_elem_t *elem) +{ + CHECK_BASIC(elem); + CHECK_ENUM(elem); + return sm_selem_ops(elem)->is(elem, SM_CAPT, SM_OPS_IS_ENUMERATED, 1); +} + /** * \brief Return the number of enumerated items of the given mixer simple element * \param elem Mixer simple element handle diff --git a/src/mixer/simple_none.c b/src/mixer/simple_none.c index 88724b29..eed8f5df 100644 --- a/src/mixer/simple_none.c +++ b/src/mixer/simple_none.c @@ -721,7 +721,8 @@ static int simple_update(snd_mixer_elem_t *melem) if (ctl->elem) { if (pchannels < ctl->values) pchannels = ctl->values; - caps |= SM_CAP_ENUM; + /* FIXME: differentiate some controls */ + caps |= SM_CAP_PENUM|SM_CAP_CENUM; } if (pchannels > 32) pchannels = 32; @@ -910,6 +911,11 @@ static int is_ops(snd_mixer_elem_t *elem, int dir, int cmd, int val) return (unsigned int) val < s->str[dir].channels; case SM_OPS_IS_ENUMERATED: + if (val == 1) { + if (dir == SM_PLAY && (s->selem.caps & SM_CAP_PENUM)) + return 1; + return !!(s->selem.caps & SM_CAP_CENUM); + } return s->ctls[CTL_ENUMLIST].elem != 0; case SM_OPS_IS_ENUMCNT: -- 2.47.1