mixer API - extend simple enumerated controls for direction tests

Added snd_mixer_selem_is_enum_playback() and
snd_mixer_selem_is_enum_capture() functions.
This commit is contained in:
Jaroslav Kysela 2005-08-24 10:41:16 +00:00
parent d9be3e3556
commit 5af75610f2
5 changed files with 38 additions and 3 deletions

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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: