Added range specification to simple mixer. Fixes to alsamixer. Added mixer support to alsa-oss

This commit is contained in:
Abramo Bagnara 2001-02-18 17:56:37 +00:00
parent ab819d2edd
commit 0c7637393f
4 changed files with 62 additions and 7 deletions

View file

@ -105,6 +105,8 @@ int snd_mixer_selem_register(snd_mixer_t *mixer, void *arg,
snd_mixer_class_t **classp); snd_mixer_class_t **classp);
void snd_mixer_selem_get_id(snd_mixer_elem_t *element, void snd_mixer_selem_get_id(snd_mixer_elem_t *element,
snd_mixer_selem_id_t *id); snd_mixer_selem_id_t *id);
const char *snd_mixer_selem_get_name(snd_mixer_elem_t *elem);
unsigned int snd_mixer_selem_get_index(snd_mixer_elem_t *elem);
snd_mixer_elem_t *snd_mixer_find_selem(snd_mixer_t *mixer, snd_mixer_elem_t *snd_mixer_find_selem(snd_mixer_t *mixer,
const snd_mixer_selem_id_t *id); const snd_mixer_selem_id_t *id);
@ -141,7 +143,10 @@ int snd_mixer_selem_set_playback_switch(snd_mixer_elem_t *elem, snd_mixer_selem_
int snd_mixer_selem_set_capture_switch(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, int value); int snd_mixer_selem_set_capture_switch(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, int value);
int snd_mixer_selem_set_playback_switch_all(snd_mixer_elem_t *elem, int value); int snd_mixer_selem_set_playback_switch_all(snd_mixer_elem_t *elem, int value);
int snd_mixer_selem_set_capture_switch_all(snd_mixer_elem_t *elem, int value); int snd_mixer_selem_set_capture_switch_all(snd_mixer_elem_t *elem, int value);
void snd_mixer_selem_set_playback_volume_range(snd_mixer_elem_t *elem,
long min, long max);
void snd_mixer_selem_set_capture_volume_range(snd_mixer_elem_t *elem,
long min, long max);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -216,6 +216,7 @@ int snd_pcm_open(snd_pcm_t **pcm, const char *name,
snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm); snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm);
int snd_pcm_close(snd_pcm_t *pcm); int snd_pcm_close(snd_pcm_t *pcm);
int snd_pcm_poll_descriptors_count(snd_pcm_t *pcm, unsigned int *count);
int snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space); int snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space);
int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock); int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock);
int snd_pcm_async(snd_pcm_t *pcm, int sig, pid_t pid); int snd_pcm_async(snd_pcm_t *pcm, int sig, pid_t pid);

View file

@ -75,6 +75,7 @@ typedef struct _selem {
unsigned int capture_group; unsigned int capture_group;
unsigned int caps; unsigned int caps;
struct { struct {
unsigned int range: 1; /* Forced range */
long min, max; long min, max;
unsigned int channels; unsigned int channels;
long vol[32]; long vol[32];
@ -593,11 +594,15 @@ static int simple_update(snd_mixer_elem_t *melem)
} }
simple->caps = caps; simple->caps = caps;
simple->str[PLAY].channels = pchannels; simple->str[PLAY].channels = pchannels;
simple->str[PLAY].min = pmin; if (!simple->str[PLAY].range) {
simple->str[PLAY].max = pmax; simple->str[PLAY].min = pmin;
simple->str[PLAY].max = pmax;
}
simple->str[CAPT].channels = cchannels; simple->str[CAPT].channels = cchannels;
simple->str[CAPT].min = cmin; if (!simple->str[CAPT].range) {
simple->str[CAPT].max = cmax; simple->str[CAPT].min = cmin;
simple->str[CAPT].max = cmax;
}
return 0; return 0;
} }
@ -900,6 +905,24 @@ void snd_mixer_selem_get_id(snd_mixer_elem_t *elem,
*id = s->id; *id = s->id;
} }
const char *snd_mixer_selem_get_name(snd_mixer_elem_t *elem)
{
selem_t *s;
assert(elem);
assert(elem->type == SND_MIXER_ELEM_SIMPLE);
s = elem->private_data;
return s->id.name;
}
unsigned int snd_mixer_selem_get_index(snd_mixer_elem_t *elem)
{
selem_t *s;
assert(elem);
assert(elem->type == SND_MIXER_ELEM_SIMPLE);
s = elem->private_data;
return s->id.index;
}
int snd_mixer_selem_is_playback_mono(snd_mixer_elem_t *elem) int snd_mixer_selem_is_playback_mono(snd_mixer_elem_t *elem)
{ {
selem_t *s; selem_t *s;
@ -1367,3 +1390,29 @@ const char *snd_mixer_selem_channel_name(snd_mixer_selem_channel_id_t channel)
return p; return p;
} }
void snd_mixer_selem_set_playback_volume_range(snd_mixer_elem_t *elem,
long min, long max)
{
selem_t *s;
assert(elem);
assert(elem->type == SND_MIXER_ELEM_SIMPLE);
s = elem->private_data;
assert(min != max);
s->str[PLAY].range = 1;
s->str[PLAY].min = min;
s->str[PLAY].max = max;
}
void snd_mixer_selem_set_capture_volume_range(snd_mixer_elem_t *elem,
long min, long max)
{
selem_t *s;
assert(elem);
assert(elem->type == SND_MIXER_ELEM_SIMPLE);
s = elem->private_data;
assert(min != max);
s->str[CAPT].range = 1;
s->str[CAPT].min = min;
s->str[CAPT].max = max;
}

View file

@ -338,7 +338,7 @@ static snd_pcm_uframes_t _snd_pcm_share_slave_missing(snd_pcm_share_slave_t *sla
return missing; return missing;
} }
void *snd_pcm_share_slave_thread(void *data) void *snd_pcm_share_thread(void *data)
{ {
snd_pcm_share_slave_t *slave = data; snd_pcm_share_slave_t *slave = data;
snd_pcm_t *spcm = slave->pcm; snd_pcm_t *spcm = slave->pcm;
@ -1303,7 +1303,7 @@ int snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, const char *sname,
pthread_cond_init(&slave->poll_cond, NULL); pthread_cond_init(&slave->poll_cond, NULL);
list_add_tail(&slave->list, &slaves); list_add_tail(&slave->list, &slaves);
Pthread_mutex_lock(&slave->mutex); Pthread_mutex_lock(&slave->mutex);
err = pthread_create(&slave->thread, NULL, snd_pcm_share_slave_thread, slave); err = pthread_create(&slave->thread, NULL, snd_pcm_share_thread, slave);
assert(err == 0); assert(err == 0);
Pthread_mutex_unlock(&slaves_mutex); Pthread_mutex_unlock(&slaves_mutex);
} else { } else {