[pulseaudio-commits] 3 commits - src/Makefile.am src/modules src/tests
David Henningsson
diwic at kemper.freedesktop.org
Mon Mar 25 00:42:18 PDT 2013
src/Makefile.am | 8
src/modules/alsa/alsa-mixer.c | 1
src/modules/alsa/mixer/paths/analog-input-dock-mic.conf | 5
src/modules/alsa/mixer/paths/analog-input-front-mic.conf | 5
src/modules/alsa/mixer/paths/analog-input-headset-mic.conf | 99 +++++++++++
src/modules/alsa/mixer/paths/analog-input-linein.conf | 5
src/modules/alsa/mixer/paths/analog-input-mic.conf | 5
src/modules/alsa/mixer/paths/analog-input-rear-mic.conf | 5
src/modules/alsa/mixer/paths/analog-output-headphones.conf | 10 +
src/modules/alsa/mixer/profile-sets/default.conf | 4
src/modules/alsa/mixer/profile-sets/extra-hdmi.conf | 4
src/tests/alsa-mixer-path-test.c | 111 +++++++++++++
12 files changed, 258 insertions(+), 4 deletions(-)
New commits:
commit c6806efb093b94a65f22475b720c5073e1e4a654
Author: David Henningsson <david.henningsson at canonical.com>
Date: Fri Mar 22 15:22:26 2013 +0100
tests: Add tests for alsa-mixer paths
It checks all files in the mixer/paths directory and checks
- that the file can be parsed without errors
- that the file is actually shipped in the makefile
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
diff --git a/src/Makefile.am b/src/Makefile.am
index e02aaf8..079083e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -297,6 +297,8 @@ endif
if HAVE_ALSA
TESTS_norun += \
alsa-time-test
+TESTS_default += \
+ alsa-mixer-path-test
endif
if HAVE_TESTS
@@ -545,6 +547,11 @@ alsa_time_test_LDADD = $(AM_LDADD) $(ASOUNDLIB_LIBS)
alsa_time_test_CFLAGS = $(AM_CFLAGS) $(ASOUNDLIB_CFLAGS)
alsa_time_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
+alsa_mixer_path_test_SOURCES = tests/alsa-mixer-path-test.c
+alsa_mixer_path_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS) $(ASOUNDLIB_CFLAGS)
+alsa_mixer_path_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINOR@.la libpulse.la libpulsecommon- at PA_MAJORMINOR@.la libalsa-util.la
+alsa_mixer_path_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
+
usergroup_test_SOURCES = tests/usergroup-test.c
usergroup_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINOR@.la libpulse.la libpulsecommon- at PA_MAJORMINOR@.la
usergroup_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
diff --git a/src/tests/alsa-mixer-path-test.c b/src/tests/alsa-mixer-path-test.c
new file mode 100644
index 0000000..1ad06ee
--- /dev/null
+++ b/src/tests/alsa-mixer-path-test.c
@@ -0,0 +1,111 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <check.h>
+#include <dirent.h>
+#include <stdbool.h>
+#include <stdio.h>
+
+#include <pulse/pulseaudio.h>
+#include <pulsecore/log.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/strlist.h>
+#include <modules/alsa/alsa-mixer.h>
+
+/* This function was copied from alsa-mixer.c */
+static const char *get_default_paths_dir(void) {
+ if (pa_run_from_build_tree())
+ return PA_BUILDDIR "/modules/alsa/mixer/paths/";
+ else
+ return PA_ALSA_PATHS_DIR;
+}
+
+static pa_strlist *load_makefile() {
+ FILE *f;
+ bool lookforfiles = false;
+ char buf[2048];
+ pa_strlist *result = NULL;
+ const char *Makefile = PA_BUILDDIR "/Makefile";
+
+ f = pa_fopen_cloexec(Makefile, "r");
+ fail_unless(f != NULL); /* Consider skipping this test instead of failing if Makefile not found? */
+ while (!feof(f)) {
+ if (!fgets(buf, sizeof(buf), f)) {
+ fail_unless(feof(f));
+ break;
+ }
+ if (strstr(buf, "dist_alsapaths_DATA = \\") != NULL) {
+ lookforfiles = true;
+ continue;
+ }
+ if (!lookforfiles)
+ continue;
+ if (!strstr(buf, "\\"))
+ lookforfiles = false;
+ else
+ strstr(buf, "\\")[0] = '\0';
+ pa_strip(buf);
+ pa_log_debug("Shipping file '%s'", pa_path_get_filename(buf));
+ result = pa_strlist_prepend(result, pa_path_get_filename(buf));
+ }
+ fclose(f);
+ return result;
+}
+
+
+START_TEST (mixer_path_test) {
+ DIR *dir;
+ struct dirent *ent;
+ pa_strlist *ship = load_makefile();
+ const char *pathsdir = get_default_paths_dir();
+ pa_log_debug("Analyzing directory: '%s'", pathsdir);
+
+ dir = opendir(pathsdir);
+ fail_unless(dir != NULL);
+ while ((ent = readdir(dir)) != NULL) {
+ pa_alsa_path *path;
+ if (pa_streq(ent->d_name, ".") || pa_streq(ent->d_name, ".."))
+ continue;
+ pa_log_debug("Analyzing file: '%s'", ent->d_name);
+
+ /* Can the file be parsed? */
+ path = pa_alsa_path_new(pathsdir, ent->d_name, PA_ALSA_DIRECTION_ANY);
+ fail_unless(path != NULL);
+
+ /* Is the file shipped? */
+ if (ship) {
+ pa_strlist *n;
+ bool found = false;
+ for (n = ship; n; n = pa_strlist_next(n))
+ found |= pa_streq(ent->d_name, pa_strlist_data(n));
+ fail_unless(found);
+ }
+ }
+ closedir(dir);
+ pa_strlist_free(ship);
+}
+END_TEST
+
+int main(int argc, char *argv[]) {
+ int failed = 0;
+ Suite *s;
+ TCase *tc;
+ SRunner *sr;
+
+ if (!getenv("MAKE_CHECK"))
+ pa_log_set_level(PA_LOG_DEBUG);
+
+ s = suite_create("Alsa-mixer-path");
+ tc = tcase_create("alsa-mixer-path");
+ tcase_add_test(tc, mixer_path_test);
+ tcase_set_timeout(tc, 30);
+ suite_add_tcase(s, tc);
+
+ sr = srunner_create(s);
+ srunner_run_all(sr, CK_NORMAL);
+ failed = srunner_ntests_failed(sr);
+ srunner_free(sr);
+
+ return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
commit 1a3f8007995ab87887989a6b1d05d0fdcff17783
Author: David Henningsson <david.henningsson at canonical.com>
Date: Thu Mar 21 19:28:49 2013 +0100
alsa-mixer: Support more phantom jacks
It's fairly uncommon, but it happens that jack detection is enabled
for some reason, e g hardware design. In that case, we cannot use
jack detection, but we can still use the hint to pick up that there
is a path.
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
diff --git a/src/modules/alsa/mixer/paths/analog-input-dock-mic.conf b/src/modules/alsa/mixer/paths/analog-input-dock-mic.conf
index 240b5f0..f6ea94b 100644
--- a/src/modules/alsa/mixer/paths/analog-input-dock-mic.conf
+++ b/src/modules/alsa/mixer/paths/analog-input-dock-mic.conf
@@ -25,6 +25,11 @@ name = analog-input-microphone-dock
[Jack Dock Mic]
required-any = any
+[Jack Dock Mic Phantom]
+state.plugged = unknown
+state.unplugged = unknown
+required-any = any
+
[Element Dock Mic Boost]
required-any = any
switch = select
diff --git a/src/modules/alsa/mixer/paths/analog-input-front-mic.conf b/src/modules/alsa/mixer/paths/analog-input-front-mic.conf
index 0b069f9..bb2e806 100644
--- a/src/modules/alsa/mixer/paths/analog-input-front-mic.conf
+++ b/src/modules/alsa/mixer/paths/analog-input-front-mic.conf
@@ -25,6 +25,11 @@ name = analog-input-microphone-front
[Jack Front Mic]
required-any = any
+[Jack Front Mic Phantom]
+required-any = any
+state.plugged = unknown
+state.unplugged = unknown
+
[Element Front Mic Boost]
required-any = any
switch = select
diff --git a/src/modules/alsa/mixer/paths/analog-input-linein.conf b/src/modules/alsa/mixer/paths/analog-input-linein.conf
index 3bcf436..3a8c2a0 100644
--- a/src/modules/alsa/mixer/paths/analog-input-linein.conf
+++ b/src/modules/alsa/mixer/paths/analog-input-linein.conf
@@ -24,6 +24,11 @@ priority = 81
[Jack Line]
required-any = any
+[Jack Line Phantom]
+required-any = any
+state.plugged = unknown
+state.unplugged = unknown
+
[Element Capture]
switch = mute
volume = merge
diff --git a/src/modules/alsa/mixer/paths/analog-input-mic.conf b/src/modules/alsa/mixer/paths/analog-input-mic.conf
index 8aaf0cb..9e5f044 100644
--- a/src/modules/alsa/mixer/paths/analog-input-mic.conf
+++ b/src/modules/alsa/mixer/paths/analog-input-mic.conf
@@ -25,6 +25,11 @@ name = analog-input-microphone
[Jack Mic]
required-any = any
+[Jack Mic Phantom]
+required-any = any
+state.plugged = unknown
+state.unplugged = unknown
+
[Element Mic Boost]
required-any = any
switch = select
diff --git a/src/modules/alsa/mixer/paths/analog-input-rear-mic.conf b/src/modules/alsa/mixer/paths/analog-input-rear-mic.conf
index 1e6fa57..397efba 100644
--- a/src/modules/alsa/mixer/paths/analog-input-rear-mic.conf
+++ b/src/modules/alsa/mixer/paths/analog-input-rear-mic.conf
@@ -25,6 +25,11 @@ name = analog-input-microphone-rear
[Jack Rear Mic]
required-any = any
+[Jack Rear Mic Phantom]
+required-any = any
+state.plugged = unknown
+state.unplugged = unknown
+
[Element Rear Mic Boost]
required-any = any
switch = select
diff --git a/src/modules/alsa/mixer/paths/analog-output-headphones.conf b/src/modules/alsa/mixer/paths/analog-output-headphones.conf
index df0f198..b878dc7 100644
--- a/src/modules/alsa/mixer/paths/analog-output-headphones.conf
+++ b/src/modules/alsa/mixer/paths/analog-output-headphones.conf
@@ -28,9 +28,19 @@ device.icon_name = audio-headphones
[Jack Front Headphone]
required-any = any
+[Jack Front Headphone Phantom]
+required-any = any
+state.plugged = unknown
+state.unplugged = unknown
+
[Jack Headphone]
required-any = any
+[Jack Headphone Phantom]
+required-any = any
+state.plugged = unknown
+state.unplugged = unknown
+
# This jack can be either a headphone *or* a mic. Used on some ASUS netbooks.
[Jack Headphone Mic]
required-any = any
commit 560ce5ece08201312cadad1d70af133d526d3280
Author: David Henningsson <david.henningsson at canonical.com>
Date: Thu Mar 14 09:14:34 2013 +0100
alsa-mixer: Add path for Headset Microphone
In kernel 3.10, some devices will have the "Headset Microphone" name
to indicate that the mic is part of a mic + headphone combo, i e, a headset.
diff --git a/src/Makefile.am b/src/Makefile.am
index 649cbc5..e02aaf8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1193,6 +1193,7 @@ dist_alsapaths_DATA = \
modules/alsa/mixer/paths/analog-input-dock-mic.conf \
modules/alsa/mixer/paths/analog-input-front-mic.conf \
modules/alsa/mixer/paths/analog-input-headphone-mic.conf \
+ modules/alsa/mixer/paths/analog-input-headset-mic.conf \
modules/alsa/mixer/paths/analog-input-internal-mic.conf \
modules/alsa/mixer/paths/analog-input-internal-mic-always.conf \
modules/alsa/mixer/paths/analog-input-rear-mic.conf \
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index 137c9eb..2814add 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -2336,6 +2336,7 @@ static int path_verify(pa_alsa_path *p) {
{ "analog-input-microphone-rear", N_("Rear Microphone") },
{ "analog-input-microphone-dock", N_("Dock Microphone") },
{ "analog-input-microphone-internal", N_("Internal Microphone") },
+ { "analog-input-microphone-headset", N_("Headset Microphone") },
{ "analog-input-linein", N_("Line In") },
{ "analog-input-radio", N_("Radio") },
{ "analog-input-video", N_("Video") },
diff --git a/src/modules/alsa/mixer/paths/analog-input-headset-mic.conf b/src/modules/alsa/mixer/paths/analog-input-headset-mic.conf
new file mode 100644
index 0000000..c5aff1c
--- /dev/null
+++ b/src/modules/alsa/mixer/paths/analog-input-headset-mic.conf
@@ -0,0 +1,99 @@
+# This file is part of PulseAudio.
+#
+# PulseAudio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of the
+# License, or (at your option) any later version.
+#
+# PulseAudio is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with PulseAudio; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+
+; For devices where a 'Headset Mic' or 'Headset Mic Boost' element exists
+;
+; See analog-output.conf.common for an explanation on the directives
+
+[General]
+priority = 87
+name = analog-input-microphone-headset
+
+[Jack Headset Mic]
+required-any = any
+
+[Jack Headset Mic Phantom]
+state.plugged = unknown
+state.unplugged = unknown
+required-any = any
+
+[Element Headset Mic Boost]
+required-any = any
+switch = select
+volume = merge
+override-map.1 = all
+override-map.2 = all-left,all-right
+
+[Element Headset Mic]
+required-any = any
+switch = mute
+volume = merge
+override-map.1 = all
+override-map.2 = all-left,all-right
+
+[Element Capture]
+switch = mute
+volume = merge
+override-map.1 = all
+override-map.2 = all-left,all-right
+
+[Element Input Source]
+enumeration = select
+
+[Option Input Source:Headset Mic]
+name = Headset Microphone
+required-any = any
+
+[Element Capture Source]
+enumeration = select
+
+[Option Capture Source:Headset Mic]
+name = Headset Microphone
+required-any = any
+
+[Element Front Mic]
+switch = off
+volume = off
+
+[Element Internal Mic]
+switch = off
+volume = off
+
+[Element Rear Mic]
+switch = off
+volume = off
+
+[Element Dock Mic]
+switch = off
+volume = off
+
+[Element Dock Mic Boost]
+switch = off
+volume = off
+
+[Element Internal Mic Boost]
+switch = off
+volume = off
+
+[Element Front Mic Boost]
+switch = off
+volume = off
+
+[Element Rear Mic Boost]
+switch = off
+volume = off
+
+.include analog-input-mic.conf.common
diff --git a/src/modules/alsa/mixer/profile-sets/default.conf b/src/modules/alsa/mixer/profile-sets/default.conf
index b040036..c805d36 100644
--- a/src/modules/alsa/mixer/profile-sets/default.conf
+++ b/src/modules/alsa/mixer/profile-sets/default.conf
@@ -102,14 +102,14 @@ auto-profiles = yes
device-strings = hw:%f
channel-map = mono
paths-output = analog-output analog-output-speaker analog-output-desktop-speaker analog-output-headphones analog-output-headphones-2 analog-output-mono
-paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line
+paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line analog-input-headset-mic
priority = 1
[Mapping analog-stereo]
device-strings = front:%f hw:%f
channel-map = left,right
paths-output = analog-output analog-output-speaker analog-output-desktop-speaker analog-output-headphones analog-output-headphones-2 analog-output-mono
-paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line analog-input-headphone-mic
+paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line analog-input-headphone-mic analog-input-headset-mic
priority = 10
[Mapping analog-surround-40]
diff --git a/src/modules/alsa/mixer/profile-sets/extra-hdmi.conf b/src/modules/alsa/mixer/profile-sets/extra-hdmi.conf
index 7075314..aaf4d91 100644
--- a/src/modules/alsa/mixer/profile-sets/extra-hdmi.conf
+++ b/src/modules/alsa/mixer/profile-sets/extra-hdmi.conf
@@ -28,14 +28,14 @@ auto-profiles = yes
device-strings = hw:%f
channel-map = mono
paths-output = analog-output analog-output-speaker analog-output-desktop-speaker analog-output-headphones analog-output-headphones-2 analog-output-mono
-paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line
+paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line analog-input-headset-mic
priority = 1
[Mapping analog-stereo]
device-strings = front:%f hw:%f
channel-map = left,right
paths-output = analog-output analog-output-speaker analog-output-desktop-speaker analog-output-headphones analog-output-headphones-2 analog-output-mono
-paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line analog-input-headphone-mic
+paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line analog-input-headphone-mic analog-input-headset-mic
priority = 10
[Mapping analog-surround-40]
More information about the pulseaudio-commits
mailing list