From e205b25d65ccb380fa158711e24d55b6de5d9bc1 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 16 Feb 2006 19:19:58 +0000 Subject: Reorganised the source tree. We now have src/ with a couple of subdirs: * daemon/ - Contains the files specific to the polypaudio daemon. * modules/ - All loadable modules. * polyp/ - Files that are part of the public, application interface or are only used in libpolyp. * polypcore/ - All other shared files. * tests/ - Test programs. * utils/ - Utility programs. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@487 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 227 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100644 src/modules/module-detect.c (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c new file mode 100644 index 00000000..e325b22c --- /dev/null +++ b/src/modules/module-detect.c @@ -0,0 +1,227 @@ +/* $Id$ */ + +/*** + This file is part of polypaudio. + + polypaudio 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 of the License, + or (at your option) any later version. + + polypaudio 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 polypaudio; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "module-detect-symdef.h" + +PA_MODULE_AUTHOR("Lennart Poettering") +PA_MODULE_DESCRIPTION("Detect available audio hardware and load matching drivers") +PA_MODULE_VERSION(PACKAGE_VERSION) +PA_MODULE_USAGE("just-one=") + +static const char *endswith(const char *haystack, const char *needle) { + size_t l, m; + const char *p; + + if ((l = strlen(haystack)) < (m = strlen(needle))) + return NULL; + + if (strcmp(p = haystack + l - m, needle)) + return NULL; + + return p; +} + +#ifdef HAVE_ALSA +static int detect_alsa(pa_core *c, int just_one) { + FILE *f; + int n = 0, n_sink = 0, n_source = 0; + + if (!(f = fopen("/proc/asound/devices", "r"))) { + + if (errno != ENOENT) + pa_log_error(__FILE__": open(\"/proc/asound/devices\") failed: %s\n", strerror(errno)); + + return -1; + } + + while (!feof(f)) { + char line[64], args[64]; + unsigned device, subdevice; + int is_sink; + + if (!fgets(line, sizeof(line), f)) + break; + + line[strcspn(line, "\r\n")] = 0; + + if (endswith(line, "digital audio playback")) + is_sink = 1; + else if (endswith(line, "digital audio capture")) + is_sink = 0; + else + continue; + + if (just_one && is_sink && n_sink >= 1) + continue; + + if (just_one && !is_sink && n_source >= 1) + continue; + + if (sscanf(line, " %*i: [%u- %u]: ", &device, &subdevice) != 2) + continue; + + /* Only one sink per device */ + if (subdevice != 0) + continue; + + snprintf(args, sizeof(args), "device=hw:%u,0", device); + if (!pa_module_load(c, is_sink ? "module-alsa-sink" : "module-alsa-source", args)) + continue; + + n++; + + if (is_sink) + n_sink++; + else + n_source++; + } + + fclose(f); + + return n; +} +#endif + +#ifdef HAVE_OSS +static int detect_oss(pa_core *c, int just_one) { + FILE *f; + int n = 0, b = 0; + + if (!(f = fopen("/dev/sndstat", "r")) && + !(f = fopen("/proc/sndstat", "r")) && + !(f = fopen("/proc/asound/oss/sndstat", "r"))) { + + if (errno != ENOENT) + pa_log_error(__FILE__": failed to open OSS sndstat device: %s\n", strerror(errno)); + + return -1; + } + + while (!feof(f)) { + char line[64], args[64]; + unsigned device; + + if (!fgets(line, sizeof(line), f)) + break; + + line[strcspn(line, "\r\n")] = 0; + + if (!b) { + b = strcmp(line, "Audio devices:") == 0; + continue; + } + + if (line[0] == 0) + break; + + if (sscanf(line, "%u: ", &device) != 1) + continue; + + if (device == 0) + snprintf(args, sizeof(args), "device=/dev/dsp"); + else + snprintf(args, sizeof(args), "device=/dev/dsp%u", device); + + if (!pa_module_load(c, "module-oss", args)) + continue; + + n++; + + if (just_one) + break; + } + + fclose(f); + return n; +} +#endif + +int pa__init(pa_core *c, pa_module*m) { + int just_one = 0, n = 0; + pa_modargs *ma; + + static const char* const valid_modargs[] = { + "just-one", + NULL + }; + + assert(c); + assert(m); + + if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { + pa_log(__FILE__": Failed to parse module arguments\n"); + goto fail; + } + + if (pa_modargs_get_value_boolean(ma, "just-one", &just_one) < 0) { + pa_log(__FILE__": just_one= expects a boolean argument.\n"); + goto fail; + } + +#if HAVE_ALSA + if ((n = detect_alsa(c, just_one)) <= 0) +#endif +#if HAVE_OSS + if ((n = detect_oss(c, just_one)) <= 0) +#endif + { + pa_log_warn(__FILE__": failed to detect any sound hardware.\n"); + goto fail; + } + + pa_log_info(__FILE__": loaded %i modules.\n", n); + + /* We were successful and can unload ourselves now. */ + pa_module_unload_request(m); + + pa_modargs_free(ma); + + return 0; + +fail: + if (ma) + pa_modargs_free(ma); + + return -1; +} + + +void pa__done(pa_core *c, pa_module*m) { + /* NOP */ +} + -- cgit From d1bc972e6955601836c476093cb07ba961e51738 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 20 Feb 2006 12:42:28 +0000 Subject: Detect support for Solaris (/dev/audio). git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@516 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index e325b22c..4c0cdb4b 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -171,6 +171,34 @@ static int detect_oss(pa_core *c, int just_one) { } #endif +#ifdef HAVE_SOLARIS +static int detect_solaris(pa_core *c, int just_one) { + struct stat s; + const char *dev; + char args[64]; + + dev = getenv("AUDIODEV"); + if (!dev) + dev = "/dev/audio"; + + if (stat(dev, &s) < 0) { + if (errno != ENOENT) + pa_log_error(__FILE__": failed to open device %s: %s\n", dev, strerror(errno)); + return -1; + } + + if (!S_ISCHR(s)) + return 0; + + snprintf(args, sizeof(args), "device=%s", dev); + + if (!pa_module_load(c, "module-solaris", args)) + return 0; + + return 1; +} +#endif + int pa__init(pa_core *c, pa_module*m) { int just_one = 0, n = 0; pa_modargs *ma; @@ -198,6 +226,9 @@ int pa__init(pa_core *c, pa_module*m) { #endif #if HAVE_OSS if ((n = detect_oss(c, just_one)) <= 0) +#endif +#if HAVE_SOLARIS + if ((n = detect_solaris(c, just_one)) <= 0) #endif { pa_log_warn(__FILE__": failed to detect any sound hardware.\n"); -- cgit From 6c2d414e5879dccff78ebf1cb155fd1809fc785a Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 20 Feb 2006 12:47:03 +0000 Subject: Detect support for Windows' waveout. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@517 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 4c0cdb4b..718b2eb4 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -199,6 +199,19 @@ static int detect_solaris(pa_core *c, int just_one) { } #endif +#ifdef OS_IS_WIN32 +static int detect_waveout(pa_core *c, int just_one) { + /* + * FIXME: No point in enumerating devices until the plugin supports + * selecting anything but the first. + */ + if (!pa_module_load(c, "module-waveout", "")) + return 0; + + return 1; +} +#endif + int pa__init(pa_core *c, pa_module*m) { int just_one = 0, n = 0; pa_modargs *ma; @@ -229,6 +242,9 @@ int pa__init(pa_core *c, pa_module*m) { #endif #if HAVE_SOLARIS if ((n = detect_solaris(c, just_one)) <= 0) +#endif +#if OS_IS_WIN32 + if ((n = detect_waveout(c, just_one)) <= 0) #endif { pa_log_warn(__FILE__": failed to detect any sound hardware.\n"); -- cgit From f2292aeeff200e45b46929c9d02e5d4a91fe0124 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 20 Feb 2006 13:59:42 +0000 Subject: Fixes for the Solaris detection. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@519 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 718b2eb4..18e22de6 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -187,7 +189,7 @@ static int detect_solaris(pa_core *c, int just_one) { return -1; } - if (!S_ISCHR(s)) + if (!S_ISCHR(s.st_mode)) return 0; snprintf(args, sizeof(args), "device=%s", dev); -- cgit From 4a64b0d1167e980d81b798d813f35209895f0674 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 23 Feb 2006 02:27:19 +0000 Subject: change pa_log() and friends to not require a trailing \n on all logged strings git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@574 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 18e22de6..b24d838b 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -66,7 +66,7 @@ static int detect_alsa(pa_core *c, int just_one) { if (!(f = fopen("/proc/asound/devices", "r"))) { if (errno != ENOENT) - pa_log_error(__FILE__": open(\"/proc/asound/devices\") failed: %s\n", strerror(errno)); + pa_log_error(__FILE__": open(\"/proc/asound/devices\") failed: %s", strerror(errno)); return -1; } @@ -129,7 +129,7 @@ static int detect_oss(pa_core *c, int just_one) { !(f = fopen("/proc/asound/oss/sndstat", "r"))) { if (errno != ENOENT) - pa_log_error(__FILE__": failed to open OSS sndstat device: %s\n", strerror(errno)); + pa_log_error(__FILE__": failed to open OSS sndstat device: %s", strerror(errno)); return -1; } @@ -185,7 +185,7 @@ static int detect_solaris(pa_core *c, int just_one) { if (stat(dev, &s) < 0) { if (errno != ENOENT) - pa_log_error(__FILE__": failed to open device %s: %s\n", dev, strerror(errno)); + pa_log_error(__FILE__": failed to open device %s: %s", dev, strerror(errno)); return -1; } @@ -227,12 +227,12 @@ int pa__init(pa_core *c, pa_module*m) { assert(m); if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { - pa_log(__FILE__": Failed to parse module arguments\n"); + pa_log(__FILE__": Failed to parse module arguments"); goto fail; } if (pa_modargs_get_value_boolean(ma, "just-one", &just_one) < 0) { - pa_log(__FILE__": just_one= expects a boolean argument.\n"); + pa_log(__FILE__": just_one= expects a boolean argument."); goto fail; } @@ -249,11 +249,11 @@ int pa__init(pa_core *c, pa_module*m) { if ((n = detect_waveout(c, just_one)) <= 0) #endif { - pa_log_warn(__FILE__": failed to detect any sound hardware.\n"); + pa_log_warn(__FILE__": failed to detect any sound hardware."); goto fail; } - pa_log_info(__FILE__": loaded %i modules.\n", n); + pa_log_info(__FILE__": loaded %i modules.", n); /* We were successful and can unload ourselves now. */ pa_module_unload_request(m); -- cgit From 998affc9842f59bd637cafa2e2361a8000bddc7c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 16 Apr 2006 09:13:41 +0000 Subject: replace homegrown endswith() with pa_endswith() from util.h git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@720 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index b24d838b..6b2e2742 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "module-detect-symdef.h" @@ -45,20 +46,8 @@ PA_MODULE_DESCRIPTION("Detect available audio hardware and load matching drivers PA_MODULE_VERSION(PACKAGE_VERSION) PA_MODULE_USAGE("just-one=") -static const char *endswith(const char *haystack, const char *needle) { - size_t l, m; - const char *p; - - if ((l = strlen(haystack)) < (m = strlen(needle))) - return NULL; - - if (strcmp(p = haystack + l - m, needle)) - return NULL; - - return p; -} - #ifdef HAVE_ALSA + static int detect_alsa(pa_core *c, int just_one) { FILE *f; int n = 0, n_sink = 0, n_source = 0; @@ -81,9 +70,9 @@ static int detect_alsa(pa_core *c, int just_one) { line[strcspn(line, "\r\n")] = 0; - if (endswith(line, "digital audio playback")) + if (pa_endswith(line, "digital audio playback")) is_sink = 1; - else if (endswith(line, "digital audio capture")) + else if (pa_endswith(line, "digital audio capture")) is_sink = 0; else continue; -- cgit From 746adcfed5dc396bc4820724b2e951369fc63aeb Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 18 Apr 2006 19:31:50 +0000 Subject: fix a couple of issues I found when compiling polypaudio with gcc 2.95 git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@754 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 6b2e2742..9cc13e81 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -259,7 +259,7 @@ fail: } -void pa__done(pa_core *c, pa_module*m) { +void pa__done(PA_GCC_UNUSED pa_core *c, PA_GCC_UNUSED pa_module*m) { /* NOP */ } -- cgit From d9cc2cfcb97c1b0449bcbfb6ab0301a58d77bd55 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 17 May 2006 16:34:18 +0000 Subject: Move xmalloc to the public side (libpolyp). git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@908 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 9cc13e81..ea14e68f 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -33,9 +33,10 @@ #include #include +#include + #include #include -#include #include #include -- cgit From c47e937011f00eebab7230cedb58fd59f16487b4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 17 May 2006 20:09:57 +0000 Subject: split polypcore/util.[ch] into polypcore/core-util.[ch] and polyp/util.[ch] git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@917 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index ea14e68f..2edbea5e 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include "module-detect-symdef.h" -- cgit From 4e3dc7ce68561c16254712d713b2ccd472b8afe7 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 22 May 2006 15:20:46 +0000 Subject: Wrap strerror() in a function that makes it thread safe and converts the output to UTF-8. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@945 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 2edbea5e..e4f2e3f9 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -56,7 +57,7 @@ static int detect_alsa(pa_core *c, int just_one) { if (!(f = fopen("/proc/asound/devices", "r"))) { if (errno != ENOENT) - pa_log_error(__FILE__": open(\"/proc/asound/devices\") failed: %s", strerror(errno)); + pa_log_error(__FILE__": open(\"/proc/asound/devices\") failed: %s", pa_cstrerror(errno)); return -1; } @@ -119,7 +120,7 @@ static int detect_oss(pa_core *c, int just_one) { !(f = fopen("/proc/asound/oss/sndstat", "r"))) { if (errno != ENOENT) - pa_log_error(__FILE__": failed to open OSS sndstat device: %s", strerror(errno)); + pa_log_error(__FILE__": failed to open OSS sndstat device: %s", pa_cstrerror(errno)); return -1; } @@ -175,7 +176,7 @@ static int detect_solaris(pa_core *c, int just_one) { if (stat(dev, &s) < 0) { if (errno != ENOENT) - pa_log_error(__FILE__": failed to open device %s: %s", dev, strerror(errno)); + pa_log_error(__FILE__": failed to open device %s: %s", dev, pa_cstrerror(errno)); return -1; } -- cgit From 4413b89d7a45587b545a31463ad2196767f45563 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 25 May 2006 17:16:55 +0000 Subject: * split pa_cstrerror() into its own file polypcore/core-error.[ch] * fix building of padsp * remove a warning when compiling padsp.c git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@972 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index e4f2e3f9..d0a37733 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -33,9 +33,9 @@ #include #include -#include #include +#include #include #include #include -- cgit From 73eedcbaaec8ff6bbdde2b55eec3a83092044527 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 30 May 2006 12:23:37 +0000 Subject: load alsa modules with device string hw:0 instead of hw:0,0 git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@990 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index d0a37733..3512e31c 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -92,7 +92,7 @@ static int detect_alsa(pa_core *c, int just_one) { if (subdevice != 0) continue; - snprintf(args, sizeof(args), "device=hw:%u,0", device); + snprintf(args, sizeof(args), "device=hw:%u", device); if (!pa_module_load(c, is_sink ? "module-alsa-sink" : "module-alsa-source", args)) continue; -- cgit From f44ba092651aa75055e109e04b4164ea92ae7fdc Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 19 Jun 2006 21:53:48 +0000 Subject: big s/polyp/pulse/g git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1033 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 3512e31c..3e4d2bf6 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -1,20 +1,20 @@ /* $Id$ */ /*** - This file is part of polypaudio. + This file is part of PulseAudio. - polypaudio is free software; you can redistribute it and/or modify + 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 of the License, or (at your option) any later version. - polypaudio is distributed in the hope that it will be useful, but + 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 polypaudio; if not, write to the Free Software + along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ***/ @@ -33,13 +33,13 @@ #include #include -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "module-detect-symdef.h" -- cgit From f4ec7d47fd15465b86056266983f8d15ce5b8d68 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 18 Jul 2006 19:19:52 +0000 Subject: fix module-detect on FreeBSD (patch from Diego "Flameeyes" Pettenó) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1102 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 3e4d2bf6..ebafa10d 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -135,23 +135,29 @@ static int detect_oss(pa_core *c, int just_one) { line[strcspn(line, "\r\n")] = 0; if (!b) { - b = strcmp(line, "Audio devices:") == 0; + b = strcmp(line, "Audio devices:") == 0 || strcmp(line, "Installed devices:") == 0; continue; } if (line[0] == 0) break; - if (sscanf(line, "%u: ", &device) != 1) - continue; - - if (device == 0) - snprintf(args, sizeof(args), "device=/dev/dsp"); - else - snprintf(args, sizeof(args), "device=/dev/dsp%u", device); - - if (!pa_module_load(c, "module-oss", args)) - continue; + if (sscanf(line, "%u: ", &device) == 1) { + if (device == 0) + snprintf(args, sizeof(args), "device=/dev/dsp"); + else + snprintf(args, sizeof(args), "device=/dev/dsp%u", device); + + if (!pa_module_load(c, "module-oss", args)) + continue; + + } else if (sscanf(line, "pcm%u: ", &device) == 1) { + /* FreeBSD support, the devices are named /dev/dsp0.0, dsp0.1 and so on */ + snprintf(args, sizeof(args), "device=/dev/dsp%u.0", device); + + if (!pa_module_load(c, "module-oss", args)) + continue; + } n++; -- cgit From e385d93e5aad6a6fce754c00c804ff1d6a6746d4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Aug 2006 21:38:40 +0000 Subject: remove all occurences of pa_logXXX(__FILE__": and replace them by pa_logXXX(" git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1272 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index ebafa10d..84ccd14c 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -57,7 +57,7 @@ static int detect_alsa(pa_core *c, int just_one) { if (!(f = fopen("/proc/asound/devices", "r"))) { if (errno != ENOENT) - pa_log_error(__FILE__": open(\"/proc/asound/devices\") failed: %s", pa_cstrerror(errno)); + pa_log_error("open(\"/proc/asound/devices\") failed: %s", pa_cstrerror(errno)); return -1; } @@ -120,7 +120,7 @@ static int detect_oss(pa_core *c, int just_one) { !(f = fopen("/proc/asound/oss/sndstat", "r"))) { if (errno != ENOENT) - pa_log_error(__FILE__": failed to open OSS sndstat device: %s", pa_cstrerror(errno)); + pa_log_error("failed to open OSS sndstat device: %s", pa_cstrerror(errno)); return -1; } @@ -182,7 +182,7 @@ static int detect_solaris(pa_core *c, int just_one) { if (stat(dev, &s) < 0) { if (errno != ENOENT) - pa_log_error(__FILE__": failed to open device %s: %s", dev, pa_cstrerror(errno)); + pa_log_error("failed to open device %s: %s", dev, pa_cstrerror(errno)); return -1; } @@ -224,12 +224,12 @@ int pa__init(pa_core *c, pa_module*m) { assert(m); if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { - pa_log(__FILE__": Failed to parse module arguments"); + pa_log("Failed to parse module arguments"); goto fail; } if (pa_modargs_get_value_boolean(ma, "just-one", &just_one) < 0) { - pa_log(__FILE__": just_one= expects a boolean argument."); + pa_log("just_one= expects a boolean argument."); goto fail; } @@ -246,11 +246,11 @@ int pa__init(pa_core *c, pa_module*m) { if ((n = detect_waveout(c, just_one)) <= 0) #endif { - pa_log_warn(__FILE__": failed to detect any sound hardware."); + pa_log_warn("failed to detect any sound hardware."); goto fail; } - pa_log_info(__FILE__": loaded %i modules.", n); + pa_log_info("loaded %i modules.", n); /* We were successful and can unload ourselves now. */ pa_module_unload_request(m); -- cgit From 521daf6f0ac4fa6a2fbfb5d523c0c743342dca2b Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 4 Jan 2007 13:43:45 +0000 Subject: Huge trailing whitespace cleanup. Let's keep the tree pure from here on, mmmkay? git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1418 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 84ccd14c..3057f70d 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -2,17 +2,17 @@ /*** 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 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 @@ -58,7 +58,7 @@ static int detect_alsa(pa_core *c, int just_one) { if (errno != ENOENT) pa_log_error("open(\"/proc/asound/devices\") failed: %s", pa_cstrerror(errno)); - + return -1; } @@ -66,7 +66,7 @@ static int detect_alsa(pa_core *c, int just_one) { char line[64], args[64]; unsigned device, subdevice; int is_sink; - + if (!fgets(line, sizeof(line), f)) break; @@ -81,7 +81,7 @@ static int detect_alsa(pa_core *c, int just_one) { if (just_one && is_sink && n_sink >= 1) continue; - + if (just_one && !is_sink && n_source >= 1) continue; @@ -105,7 +105,7 @@ static int detect_alsa(pa_core *c, int just_one) { } fclose(f); - + return n; } #endif @@ -114,7 +114,7 @@ static int detect_alsa(pa_core *c, int just_one) { static int detect_oss(pa_core *c, int just_one) { FILE *f; int n = 0, b = 0; - + if (!(f = fopen("/dev/sndstat", "r")) && !(f = fopen("/proc/sndstat", "r")) && !(f = fopen("/proc/asound/oss/sndstat", "r"))) { @@ -128,7 +128,7 @@ static int detect_oss(pa_core *c, int just_one) { while (!feof(f)) { char line[64], args[64]; unsigned device; - + if (!fgets(line, sizeof(line), f)) break; @@ -141,20 +141,20 @@ static int detect_oss(pa_core *c, int just_one) { if (line[0] == 0) break; - + if (sscanf(line, "%u: ", &device) == 1) { if (device == 0) snprintf(args, sizeof(args), "device=/dev/dsp"); else snprintf(args, sizeof(args), "device=/dev/dsp%u", device); - + if (!pa_module_load(c, "module-oss", args)) continue; - + } else if (sscanf(line, "pcm%u: ", &device) == 1) { /* FreeBSD support, the devices are named /dev/dsp0.0, dsp0.1 and so on */ snprintf(args, sizeof(args), "device=/dev/dsp%u.0", device); - + if (!pa_module_load(c, "module-oss", args)) continue; } @@ -219,7 +219,7 @@ int pa__init(pa_core *c, pa_module*m) { "just-one", NULL }; - + assert(c); assert(m); @@ -227,14 +227,14 @@ int pa__init(pa_core *c, pa_module*m) { pa_log("Failed to parse module arguments"); goto fail; } - + if (pa_modargs_get_value_boolean(ma, "just-one", &just_one) < 0) { pa_log("just_one= expects a boolean argument."); goto fail; } #if HAVE_ALSA - if ((n = detect_alsa(c, just_one)) <= 0) + if ((n = detect_alsa(c, just_one)) <= 0) #endif #if HAVE_OSS if ((n = detect_oss(c, just_one)) <= 0) @@ -251,7 +251,7 @@ int pa__init(pa_core *c, pa_module*m) { } pa_log_info("loaded %i modules.", n); - + /* We were successful and can unload ourselves now. */ pa_module_unload_request(m); @@ -262,7 +262,7 @@ int pa__init(pa_core *c, pa_module*m) { fail: if (ma) pa_modargs_free(ma); - + return -1; } -- cgit From 06211b7c8fd329137ae9003818543912a87d9898 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 13 Feb 2007 15:35:19 +0000 Subject: Add copyright notices to all relevant files. (based on svn log) git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1426 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 3057f70d..41b68ac3 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -3,6 +3,10 @@ /*** This file is part of PulseAudio. + Copyright 2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + Copyright 2006 Diego Pettenò + 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 of the License, -- cgit From a67c21f093202f142438689d3f7cfbdf4ea82eea Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 28 Oct 2007 19:13:50 +0000 Subject: merge 'lennart' branch back into trunk. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1971 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 47 +++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 41b68ac3..7dc25243 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -28,7 +28,6 @@ #endif #include -#include #include #include #include @@ -44,6 +43,7 @@ #include #include #include +#include #include "module-detect-symdef.h" @@ -52,6 +52,11 @@ PA_MODULE_DESCRIPTION("Detect available audio hardware and load matching drivers PA_MODULE_VERSION(PACKAGE_VERSION) PA_MODULE_USAGE("just-one=") +static const char* const valid_modargs[] = { + "just-one", + NULL +}; + #ifdef HAVE_ALSA static int detect_alsa(pa_core *c, int just_one) { @@ -96,7 +101,7 @@ static int detect_alsa(pa_core *c, int just_one) { if (subdevice != 0) continue; - snprintf(args, sizeof(args), "device=hw:%u", device); + pa_snprintf(args, sizeof(args), "device=hw:%u", device); if (!pa_module_load(c, is_sink ? "module-alsa-sink" : "module-alsa-source", args)) continue; @@ -139,7 +144,7 @@ static int detect_oss(pa_core *c, int just_one) { line[strcspn(line, "\r\n")] = 0; if (!b) { - b = strcmp(line, "Audio devices:") == 0 || strcmp(line, "Installed devices:") == 0; + b = strcmp(line, "Audio devices:") == 0 || strcmp(line, "Installed devices:") == 0; continue; } @@ -148,20 +153,20 @@ static int detect_oss(pa_core *c, int just_one) { if (sscanf(line, "%u: ", &device) == 1) { if (device == 0) - snprintf(args, sizeof(args), "device=/dev/dsp"); + pa_snprintf(args, sizeof(args), "device=/dev/dsp"); else - snprintf(args, sizeof(args), "device=/dev/dsp%u", device); + pa_snprintf(args, sizeof(args), "device=/dev/dsp%u", device); if (!pa_module_load(c, "module-oss", args)) continue; - } else if (sscanf(line, "pcm%u: ", &device) == 1) { + } else if (sscanf(line, "pcm%u: ", &device) == 1) { /* FreeBSD support, the devices are named /dev/dsp0.0, dsp0.1 and so on */ - snprintf(args, sizeof(args), "device=/dev/dsp%u.0", device); + pa_snprintf(args, sizeof(args), "device=/dev/dsp%u.0", device); if (!pa_module_load(c, "module-oss", args)) continue; - } + } n++; @@ -193,7 +198,7 @@ static int detect_solaris(pa_core *c, int just_one) { if (!S_ISCHR(s.st_mode)) return 0; - snprintf(args, sizeof(args), "device=%s", dev); + pa_snprintf(args, sizeof(args), "device=%s", dev); if (!pa_module_load(c, "module-solaris", args)) return 0; @@ -215,17 +220,11 @@ static int detect_waveout(pa_core *c, int just_one) { } #endif -int pa__init(pa_core *c, pa_module*m) { +int pa__init(pa_module*m) { int just_one = 0, n = 0; pa_modargs *ma; - static const char* const valid_modargs[] = { - "just-one", - NULL - }; - - assert(c); - assert(m); + pa_assert(m); if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { pa_log("Failed to parse module arguments"); @@ -238,16 +237,16 @@ int pa__init(pa_core *c, pa_module*m) { } #if HAVE_ALSA - if ((n = detect_alsa(c, just_one)) <= 0) + if ((n = detect_alsa(m->core, just_one)) <= 0) #endif #if HAVE_OSS - if ((n = detect_oss(c, just_one)) <= 0) + if ((n = detect_oss(m->core, just_one)) <= 0) #endif #if HAVE_SOLARIS - if ((n = detect_solaris(c, just_one)) <= 0) + if ((n = detect_solaris(m->core, just_one)) <= 0) #endif #if OS_IS_WIN32 - if ((n = detect_waveout(c, just_one)) <= 0) + if ((n = detect_waveout(m->core, just_one)) <= 0) #endif { pa_log_warn("failed to detect any sound hardware."); @@ -269,9 +268,3 @@ fail: return -1; } - - -void pa__done(PA_GCC_UNUSED pa_core *c, PA_GCC_UNUSED pa_module*m) { - /* NOP */ -} - -- cgit From e313fe1b3d0d9f9945c41c151d72edbe9cf1ec54 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 9 Nov 2007 18:25:40 +0000 Subject: tag modules that may only be loaded once at most especially, and enforce that in the module loader git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2043 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 7dc25243..95665931 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -47,10 +47,11 @@ #include "module-detect-symdef.h" -PA_MODULE_AUTHOR("Lennart Poettering") -PA_MODULE_DESCRIPTION("Detect available audio hardware and load matching drivers") -PA_MODULE_VERSION(PACKAGE_VERSION) -PA_MODULE_USAGE("just-one=") +PA_MODULE_AUTHOR("Lennart Poettering"); +PA_MODULE_DESCRIPTION("Detect available audio hardware and load matching drivers"); +PA_MODULE_VERSION(PACKAGE_VERSION); +PA_MODULE_LOAD_ONCE(TRUE); +PA_MODULE_USAGE("just-one="); static const char* const valid_modargs[] = { "just-one", -- cgit From d17bb53d3ebfbd7046719400264bd87830c140d8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 13 Nov 2007 17:37:44 +0000 Subject: Completely rework ALSA device selection code: choose the device to open depending on the requested number of channels and channel map. In most cases it will now suffice to set default-channels=6 to enable 5.1 sound for all devices that support it git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2050 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-detect.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/modules/module-detect.c') diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c index 95665931..ee650dfd 100644 --- a/src/modules/module-detect.c +++ b/src/modules/module-detect.c @@ -222,7 +222,8 @@ static int detect_waveout(pa_core *c, int just_one) { #endif int pa__init(pa_module*m) { - int just_one = 0, n = 0; + pa_bool_t just_one = FALSE; + int n = 0; pa_modargs *ma; pa_assert(m); -- cgit