Prefer mixer controls with volumes over switches
This commit is contained in:
parent
c322aed742
commit
88919111e3
157
pulseaudio-0.9.14-mixer-select.patch
Normal file
157
pulseaudio-0.9.14-mixer-select.patch
Normal file
@ -0,0 +1,157 @@
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Thu, 8 Jan 2009 00:03:42 +0000 (+0100)
|
||||
Subject: Prefer mixer controls with volumes over switches
|
||||
X-Git-Url: http://git.0pointer.de/?p=pulseaudio.git;a=commitdiff_plain;h=c2450501af82d1c9d1994e4f4ce80d506d3c90ae
|
||||
|
||||
Prefer mixer controls with volumes over switches
|
||||
|
||||
When we look for a mixer control prefer controls that have both volume
|
||||
and a mute switch over those that have only a volume switch over those
|
||||
that only have a mute switch.
|
||||
|
||||
Originally pointed out by Adel Gadllah.
|
||||
---
|
||||
|
||||
diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c
|
||||
index 75b84c4..ff3af19 100644
|
||||
--- a/src/modules/alsa-util.c
|
||||
+++ b/src/modules/alsa-util.c
|
||||
@@ -760,8 +760,32 @@ int pa_alsa_prepare_mixer(snd_mixer_t *mixer, const char *dev) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
-snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const char *fallback) {
|
||||
- snd_mixer_elem_t *elem;
|
||||
+static pa_bool_t elem_has_volume(snd_mixer_elem_t *elem, pa_bool_t playback) {
|
||||
+ pa_assert(elem);
|
||||
+
|
||||
+ if (playback && snd_mixer_selem_has_playback_volume(elem))
|
||||
+ return TRUE;
|
||||
+
|
||||
+ if (!playback && snd_mixer_selem_has_capture_volume(elem))
|
||||
+ return TRUE;
|
||||
+
|
||||
+ return FALSE;
|
||||
+}
|
||||
+
|
||||
+static pa_bool_t elem_has_switch(snd_mixer_elem_t *elem, pa_bool_t playback) {
|
||||
+ pa_assert(elem);
|
||||
+
|
||||
+ if (playback && snd_mixer_selem_has_playback_switch(elem))
|
||||
+ return TRUE;
|
||||
+
|
||||
+ if (!playback && snd_mixer_selem_has_capture_switch(elem))
|
||||
+ return TRUE;
|
||||
+
|
||||
+ return FALSE;
|
||||
+}
|
||||
+
|
||||
+snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const char *fallback, pa_bool_t playback) {
|
||||
+ snd_mixer_elem_t *elem = NULL, *fallback_elem = NULL;
|
||||
snd_mixer_selem_id_t *sid = NULL;
|
||||
|
||||
snd_mixer_selem_id_alloca(&sid);
|
||||
@@ -771,17 +795,57 @@ snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const
|
||||
|
||||
snd_mixer_selem_id_set_name(sid, name);
|
||||
|
||||
- if (!(elem = snd_mixer_find_selem(mixer, sid))) {
|
||||
- pa_log_info("Cannot find mixer control \"%s\".", snd_mixer_selem_id_get_name(sid));
|
||||
+ if ((elem = snd_mixer_find_selem(mixer, sid))) {
|
||||
+
|
||||
+ if (elem_has_volume(elem, playback) &&
|
||||
+ elem_has_switch(elem, playback))
|
||||
+ goto success;
|
||||
+
|
||||
+ if (!elem_has_volume(elem, playback) &&
|
||||
+ !elem_has_switch(elem, playback))
|
||||
+ elem = NULL;
|
||||
+ }
|
||||
+
|
||||
+ pa_log_info("Cannot find mixer control \"%s\" or mixer control is no combination of switch/volume.", snd_mixer_selem_id_get_name(sid));
|
||||
+
|
||||
+ if (fallback) {
|
||||
+ snd_mixer_selem_id_set_name(sid, fallback);
|
||||
+
|
||||
+ if ((fallback_elem = snd_mixer_find_selem(mixer, sid))) {
|
||||
+
|
||||
+ if (elem_has_volume(fallback_elem, playback) &&
|
||||
+ elem_has_switch(fallback_elem, playback)) {
|
||||
+ elem = fallback_elem;
|
||||
+ goto success;
|
||||
+ }
|
||||
+
|
||||
+ if (!elem_has_volume(fallback_elem, playback) &&
|
||||
+ !elem_has_switch(fallback_elem, playback))
|
||||
+ fallback_elem = NULL;
|
||||
+ }
|
||||
+
|
||||
+ pa_log_warn("Cannot find fallback mixer control \"%s\" or mixer control is no combination of switch/volume.", snd_mixer_selem_id_get_name(sid));
|
||||
+ }
|
||||
+
|
||||
+ if (elem && fallback_elem) {
|
||||
|
||||
- if (fallback) {
|
||||
- snd_mixer_selem_id_set_name(sid, fallback);
|
||||
+ /* Hmm, so we have both elements, but neither has both mute
|
||||
+ * and volume. Let's prefer the one with the volume */
|
||||
|
||||
- if (!(elem = snd_mixer_find_selem(mixer, sid)))
|
||||
- pa_log_warn("Cannot find fallback mixer control \"%s\".", snd_mixer_selem_id_get_name(sid));
|
||||
+ if (elem_has_volume(elem, playback))
|
||||
+ goto success;
|
||||
+
|
||||
+ if (elem_has_volume(fallback_elem, playback)) {
|
||||
+ elem = fallback_elem;
|
||||
+ goto success;
|
||||
}
|
||||
}
|
||||
|
||||
+ if (!elem && fallback_elem)
|
||||
+ elem = fallback_elem;
|
||||
+
|
||||
+success:
|
||||
+
|
||||
if (elem)
|
||||
pa_log_info("Using mixer control \"%s\".", snd_mixer_selem_id_get_name(sid));
|
||||
|
||||
diff --git a/src/modules/alsa-util.h b/src/modules/alsa-util.h
|
||||
index aaa01c7..95bb983 100644
|
||||
--- a/src/modules/alsa-util.h
|
||||
+++ b/src/modules/alsa-util.h
|
||||
@@ -52,7 +52,7 @@ int pa_alsa_set_hw_params(
|
||||
int pa_alsa_set_sw_params(snd_pcm_t *pcm, snd_pcm_uframes_t avail_min);
|
||||
|
||||
int pa_alsa_prepare_mixer(snd_mixer_t *mixer, const char *dev);
|
||||
-snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const char *fallback);
|
||||
+snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const char *fallback, pa_bool_t playback);
|
||||
|
||||
snd_pcm_t *pa_alsa_open_by_device_id(
|
||||
const char *dev_id,
|
||||
diff --git a/src/modules/module-alsa-sink.c b/src/modules/module-alsa-sink.c
|
||||
index 6dea172..95a8c97 100644
|
||||
--- a/src/modules/module-alsa-sink.c
|
||||
+++ b/src/modules/module-alsa-sink.c
|
||||
@@ -1409,7 +1409,7 @@ int pa__init(pa_module*m) {
|
||||
}
|
||||
|
||||
if (found)
|
||||
- if (!(u->mixer_elem = pa_alsa_find_elem(u->mixer_handle, "Master", "PCM")))
|
||||
+ if (!(u->mixer_elem = pa_alsa_find_elem(u->mixer_handle, "Master", "PCM", TRUE)))
|
||||
found = FALSE;
|
||||
|
||||
if (!found) {
|
||||
diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c
|
||||
index f796ef1..b6c6ed1 100644
|
||||
--- a/src/modules/module-alsa-source.c
|
||||
+++ b/src/modules/module-alsa-source.c
|
||||
@@ -1236,7 +1236,7 @@ int pa__init(pa_module*m) {
|
||||
}
|
||||
|
||||
if (found)
|
||||
- if (!(u->mixer_elem = pa_alsa_find_elem(u->mixer_handle, "Capture", "Mic")))
|
||||
+ if (!(u->mixer_elem = pa_alsa_find_elem(u->mixer_handle, "Capture", "Mic", FALSE)))
|
||||
found = FALSE;
|
||||
|
||||
if (!found) {
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
Name: pulseaudio
|
||||
Summary: Improved Linux sound server
|
||||
Version: 0.9.14
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
License: GPLv2+
|
||||
Group: System Environment/Daemons
|
||||
Source0: http://0pointer.de/lennart/projects/pulseaudio/pulseaudio-%{version}.tar.gz
|
||||
@ -26,6 +26,8 @@ BuildRequires: libasyncns-devel
|
||||
BuildRequires: intltool
|
||||
Requires: %{name}-core-libs = %{version}-%{release}
|
||||
Obsoletes: pulseaudio-devel
|
||||
#upstream commit c245050
|
||||
Patch1: pulseaudio-0.9.14-mixer-select.patch
|
||||
|
||||
%description
|
||||
PulseAudio is a sound server for Linux and other Unix like operating
|
||||
@ -163,6 +165,7 @@ This package contains command line utilities for the PulseAudio sound server.
|
||||
|
||||
%prep
|
||||
%setup -q -T -b0
|
||||
%patch1 -p1 -b .mixer-select
|
||||
|
||||
%build
|
||||
CFLAGS="-ggdb" %configure --disable-ltdl-install --disable-static --disable-rpath --with-system-user=pulse --with-system-group=pulse --with-realtime-group=pulse-rt --with-access-group=pulse-access
|
||||
@ -394,6 +397,9 @@ groupadd -r pulse-access &>/dev/null || :
|
||||
%{_mandir}/man1/pax11publish.1.gz
|
||||
|
||||
%changelog
|
||||
* Tue Jan 13 2009 Adel Gadllah <adel.gadllah@gmail.com> 0.9.14-2
|
||||
- Prefer mixer controls with volumes over switches
|
||||
|
||||
* Tue Jan 13 2009 Lennart Poettering <lpoetter@redhat.com> 0.9.14-1
|
||||
- New release
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user