ext/alsa/gstalsamixer.c: Try harder to guess which mixer track is the master mixer track (instead of just taking the ...

Original commit message from CVS:
* ext/alsa/gstalsamixer.c: (gst_alsa_mixer_find_master_mixer),
(gst_alsa_mixer_ensure_track_list):
Try harder to guess which mixer track is the master mixer
track (instead of just taking the first one that has a pvolume).
Fixes #342228.
This commit is contained in:
Tim-Philipp Müller 2006-09-17 20:14:43 +00:00
parent f2fbfdc124
commit b1fd3431ae
2 changed files with 67 additions and 7 deletions

View file

@ -1,3 +1,11 @@
2006-09-17 Tim-Philipp Müller <tim at centricular dot net>
* ext/alsa/gstalsamixer.c: (gst_alsa_mixer_find_master_mixer),
(gst_alsa_mixer_ensure_track_list):
Try harder to guess which mixer track is the master mixer
track (instead of just taking the first one that has a pvolume).
Fixes #342228.
2006-09-17 Stefan Kost <ensonic@users.sf.net>
* gst/audioconvert/gstaudioconvert.c: (set_structure_widths),

View file

@ -118,18 +118,70 @@ error:
}
}
static snd_mixer_elem_t *
gst_alsa_mixer_find_master_mixer (GstAlsaMixer * mixer, snd_mixer_t * handle)
{
snd_mixer_elem_t *element;
gint i, count;
count = snd_mixer_get_count (handle);
/* Check if we have a playback mixer labelled as 'Master' */
element = snd_mixer_first_elem (handle);
for (i = 0; i < count; i++) {
if (snd_mixer_selem_has_playback_volume (element) &&
strcmp (snd_mixer_selem_get_name (element), "Master") == 0) {
return element;
}
element = snd_mixer_elem_next (element);
}
/* If not, check if we have a playback mixer labelled as 'Front' */
element = snd_mixer_first_elem (handle);
for (i = 0; i < count; i++) {
if (snd_mixer_selem_has_playback_volume (element) &&
strcmp (snd_mixer_selem_get_name (element), "Front") == 0) {
return element;
}
element = snd_mixer_elem_next (element);
}
/* If not, check if we have a playback mixer with both volume and switch */
element = snd_mixer_first_elem (handle);
for (i = 0; i < count; i++) {
if (snd_mixer_selem_has_playback_volume (element) &&
snd_mixer_selem_has_playback_switch (element)) {
return element;
}
element = snd_mixer_elem_next (element);
}
/* If not, take any playback mixer with a volume control */
element = snd_mixer_first_elem (handle);
for (i = 0; i < count; i++) {
if (snd_mixer_selem_has_playback_volume (element)) {
return element;
}
element = snd_mixer_elem_next (element);
}
/* Looks like we're out of luck ... */
return NULL;
}
static void
gst_alsa_mixer_ensure_track_list (GstAlsaMixer * mixer)
{
gint i, count;
snd_mixer_elem_t *element;
gboolean first = TRUE;
snd_mixer_elem_t *element, *master;
g_return_if_fail (mixer->handle != NULL);
if (mixer->tracklist)
return;
master = gst_alsa_mixer_find_master_mixer (mixer, mixer->handle);
count = snd_mixer_get_count (mixer->handle);
element = snd_mixer_first_elem (mixer->handle);
@ -169,16 +221,16 @@ gst_alsa_mixer_ensure_track_list (GstAlsaMixer * mixer)
has_playback_switch = snd_mixer_selem_has_playback_switch (element);
has_playback_volume = snd_mixer_selem_has_playback_volume (element);
GST_LOG ("[%s] PLAYBACK: has_playback_volume=%d, has_playback_switch=%d",
name, has_playback_volume, has_playback_switch);
GST_LOG ("[%s] PLAYBACK: has_playback_volume=%d, has_playback_switch=%d"
"%s", name, has_playback_volume, has_playback_switch,
(element == master) ? " MASTER" : "");
if (has_playback_volume) {
gint flags = GST_MIXER_TRACK_OUTPUT;
if (first) {
first = FALSE;
if (element == master)
flags |= GST_MIXER_TRACK_MASTER;
}
play_track = gst_alsa_mixer_track_new (element, samename, i,
flags, FALSE, NULL, FALSE);