mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 16:08:51 +00:00
ext/alsa/gstalsamixer.c: Use snd_mixer_selem_set_{playback|capture}_volume_all() if the volume is the same for all ch...
Original commit message from CVS: Patch by: Bastien Nocera <hadess at hadess net> * ext/alsa/gstalsamixer.c: (gst_alsa_mixer_get_volume), (check_if_volumes_are_the_same), (gst_alsa_mixer_set_volume): Use snd_mixer_selem_set_{playback|capture}_volume_all() if the volume is the same for all channels. This works around some problem in alsa that leaves us with inconsistent state for some reason (#486840).
This commit is contained in:
parent
06b3dec499
commit
97456dac3d
2 changed files with 49 additions and 7 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2008-01-07 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
|
Patch by: Bastien Nocera <hadess at hadess net>
|
||||||
|
|
||||||
|
* ext/alsa/gstalsamixer.c: (gst_alsa_mixer_get_volume),
|
||||||
|
(check_if_volumes_are_the_same), (gst_alsa_mixer_set_volume):
|
||||||
|
Use snd_mixer_selem_set_{playback|capture}_volume_all() if
|
||||||
|
the volume is the same for all channels. This works around
|
||||||
|
some problem in alsa that leaves us with inconsistent state
|
||||||
|
for some reason (#486840).
|
||||||
|
|
||||||
2008-01-07 Tim-Philipp Müller <tim at centricular dot net>
|
2008-01-07 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
Patch by: Jerone Young <jerone at gmail com>
|
Patch by: Jerone Young <jerone at gmail com>
|
||||||
|
|
|
@ -591,6 +591,22 @@ gst_alsa_mixer_get_volume (GstAlsaMixer * mixer, GstMixerTrack * track,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
check_if_volumes_are_the_same (guint num_channels, gint * volumes)
|
||||||
|
{
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
if (num_channels <= 1)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
for (i = 1; i < num_channels; i++) {
|
||||||
|
if (volumes[i] != volumes[0])
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_alsa_mixer_set_volume (GstAlsaMixer * mixer, GstMixerTrack * track,
|
gst_alsa_mixer_set_volume (GstAlsaMixer * mixer, GstMixerTrack * track,
|
||||||
gint * volumes)
|
gint * volumes)
|
||||||
|
@ -609,6 +625,12 @@ gst_alsa_mixer_set_volume (GstAlsaMixer * mixer, GstMixerTrack * track,
|
||||||
!(alsa_track->alsa_flags & GST_ALSA_MIXER_TRACK_PSWITCH)) {
|
!(alsa_track->alsa_flags & GST_ALSA_MIXER_TRACK_PSWITCH)) {
|
||||||
for (i = 0; i < track->num_channels; i++)
|
for (i = 0; i < track->num_channels; i++)
|
||||||
alsa_track->volumes[i] = volumes[i];
|
alsa_track->volumes[i] = volumes[i];
|
||||||
|
} else {
|
||||||
|
if (check_if_volumes_are_the_same (track->num_channels, volumes)) {
|
||||||
|
snd_mixer_selem_set_playback_volume_all (alsa_track->element,
|
||||||
|
volumes[0]);
|
||||||
|
for (i = 0; i < track->num_channels; i++)
|
||||||
|
alsa_track->volumes[i] = volumes[0];
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < track->num_channels; i++) {
|
for (i = 0; i < track->num_channels; i++) {
|
||||||
alsa_track->volumes[i] = volumes[i];
|
alsa_track->volumes[i] = volumes[i];
|
||||||
|
@ -616,15 +638,24 @@ gst_alsa_mixer_set_volume (GstAlsaMixer * mixer, GstMixerTrack * track,
|
||||||
volumes[i]);
|
volumes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if (track->flags & GST_MIXER_TRACK_INPUT) {
|
} else if (track->flags & GST_MIXER_TRACK_INPUT) {
|
||||||
|
|
||||||
/* Is emulated record flag activated? */
|
/* Is emulated record flag activated? */
|
||||||
if (track->flags & GST_MIXER_TRACK_RECORD ||
|
if (track->flags & GST_MIXER_TRACK_RECORD ||
|
||||||
alsa_track->alsa_flags & GST_ALSA_MIXER_TRACK_CSWITCH) {
|
alsa_track->alsa_flags & GST_ALSA_MIXER_TRACK_CSWITCH) {
|
||||||
|
if (check_if_volumes_are_the_same (track->num_channels, volumes)) {
|
||||||
|
snd_mixer_selem_set_capture_volume_all (alsa_track->element,
|
||||||
|
volumes[0]);
|
||||||
|
for (i = 0; i < track->num_channels; i++)
|
||||||
|
alsa_track->volumes[i] = volumes[0];
|
||||||
|
} else {
|
||||||
for (i = 0; i < track->num_channels; i++) {
|
for (i = 0; i < track->num_channels; i++) {
|
||||||
alsa_track->volumes[i] = volumes[i];
|
alsa_track->volumes[i] = volumes[i];
|
||||||
snd_mixer_selem_set_capture_volume (alsa_track->element, i, volumes[i]);
|
snd_mixer_selem_set_capture_volume (alsa_track->element, i,
|
||||||
|
volumes[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < track->num_channels; i++)
|
for (i = 0; i < track->num_channels; i++)
|
||||||
|
|
Loading…
Reference in a new issue