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-cli.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 src/modules/module-cli.c (limited to 'src/modules/module-cli.c') diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c new file mode 100644 index 00000000..c782ff8d --- /dev/null +++ b/src/modules/module-cli.c @@ -0,0 +1,88 @@ +/* $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 "module-cli-symdef.h" + +PA_MODULE_AUTHOR("Lennart Poettering") +PA_MODULE_DESCRIPTION("Command line interface") +PA_MODULE_VERSION(PACKAGE_VERSION) +PA_MODULE_USAGE("No arguments") + +static void eof_cb(pa_cli*c, void *userdata) { + pa_module *m = userdata; + assert(c && m); + + pa_module_unload_request(m); +} + +int pa__init(pa_core *c, pa_module*m) { + pa_iochannel *io; + assert(c && m); + + if (c->running_as_daemon) { + pa_log_info(__FILE__": Running as daemon so won't load this module.\n"); + return 0; + } + + if (m->argument) { + pa_log(__FILE__": module doesn't accept arguments.\n"); + return -1; + } + + if (pa_stdio_acquire() < 0) { + pa_log(__FILE__": STDIN/STDUSE already in use.\n"); + return -1; + } + + io = pa_iochannel_new(c->mainloop, STDIN_FILENO, STDOUT_FILENO); + assert(io); + pa_iochannel_set_noclose(io, 1); + + m->userdata = pa_cli_new(c, io, m); + assert(m->userdata); + + pa_cli_set_eof_callback(m->userdata, eof_cb, m); + + return 0; +} + +void pa__done(pa_core *c, pa_module*m) { + assert(c && m); + + if (c->running_as_daemon == 0) { + pa_cli_free(m->userdata); + pa_stdio_release(); + } +} -- 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-cli.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/modules/module-cli.c') diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c index c782ff8d..41e33c7f 100644 --- a/src/modules/module-cli.c +++ b/src/modules/module-cli.c @@ -52,17 +52,17 @@ int pa__init(pa_core *c, pa_module*m) { assert(c && m); if (c->running_as_daemon) { - pa_log_info(__FILE__": Running as daemon so won't load this module.\n"); + pa_log_info(__FILE__": Running as daemon so won't load this module."); return 0; } if (m->argument) { - pa_log(__FILE__": module doesn't accept arguments.\n"); + pa_log(__FILE__": module doesn't accept arguments."); return -1; } if (pa_stdio_acquire() < 0) { - pa_log(__FILE__": STDIN/STDUSE already in use.\n"); + pa_log(__FILE__": STDIN/STDUSE already in use."); return -1; } -- cgit From bd432f0590bdda2c42887f1d6da07ff0bb571013 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 18 Jun 2006 11:10:45 +0000 Subject: * add new argument 'exit_on_eof' to module-cli and make use of it if "-C" is passed to the daemon git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1026 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-cli.c | 58 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 11 deletions(-) (limited to 'src/modules/module-cli.c') diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c index 41e33c7f..ce50a46b 100644 --- a/src/modules/module-cli.c +++ b/src/modules/module-cli.c @@ -32,38 +32,64 @@ #include #include #include +#include #include "module-cli-symdef.h" PA_MODULE_AUTHOR("Lennart Poettering") PA_MODULE_DESCRIPTION("Command line interface") PA_MODULE_VERSION(PACKAGE_VERSION) -PA_MODULE_USAGE("No arguments") +PA_MODULE_USAGE("exit_on_eof=") -static void eof_cb(pa_cli*c, void *userdata) { +static const char* const valid_modargs[] = { + "exit_on_eof", + NULL +}; + +static void eof_and_unload_cb(pa_cli*c, void *userdata) { pa_module *m = userdata; - assert(c && m); + + assert(c); + assert(m); pa_module_unload_request(m); } +static void eof_and_exit_cb(pa_cli*c, void *userdata) { + pa_module *m = userdata; + + assert(c); + assert(m); + + m->core->mainloop->quit(m->core->mainloop, 0); +} + int pa__init(pa_core *c, pa_module*m) { pa_iochannel *io; - assert(c && m); + pa_modargs *ma; + int exit_on_eof = 0; + + assert(c); + assert(m); if (c->running_as_daemon) { - pa_log_info(__FILE__": Running as daemon so won't load this module."); + pa_log_info(__FILE__": Running as daemon, refusing to load this module."); return 0; } - if (m->argument) { - pa_log(__FILE__": module doesn't accept arguments."); - return -1; + if (!(ma = pa_modargs_new(m->argument, valid_modargs))) { + pa_log(__FILE__": failed to parse module arguments."); + goto fail; } + if (pa_modargs_get_value_boolean(ma, "exit_on_eof", &exit_on_eof) < 0) { + pa_log(__FILE__": exit_on_eof= expects boolean argument."); + goto fail; + } + if (pa_stdio_acquire() < 0) { pa_log(__FILE__": STDIN/STDUSE already in use."); - return -1; + goto fail; } io = pa_iochannel_new(c->mainloop, STDIN_FILENO, STDOUT_FILENO); @@ -73,13 +99,23 @@ int pa__init(pa_core *c, pa_module*m) { m->userdata = pa_cli_new(c, io, m); assert(m->userdata); - pa_cli_set_eof_callback(m->userdata, eof_cb, m); + pa_cli_set_eof_callback(m->userdata, exit_on_eof ? eof_and_exit_cb : eof_and_unload_cb, 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) { - assert(c && m); + assert(c); + assert(m); if (c->running_as_daemon == 0) { pa_cli_free(m->userdata); -- 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-cli.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/modules/module-cli.c') diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c index ce50a46b..2eef5c46 100644 --- a/src/modules/module-cli.c +++ b/src/modules/module-cli.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. ***/ @@ -27,12 +27,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "module-cli-symdef.h" -- 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-cli.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/modules/module-cli.c') diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c index 2eef5c46..d5374838 100644 --- a/src/modules/module-cli.c +++ b/src/modules/module-cli.c @@ -73,22 +73,22 @@ int pa__init(pa_core *c, pa_module*m) { assert(m); if (c->running_as_daemon) { - pa_log_info(__FILE__": Running as daemon, refusing to load this module."); + pa_log_info("Running as daemon, refusing to load this module."); return 0; } 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, "exit_on_eof", &exit_on_eof) < 0) { - pa_log(__FILE__": exit_on_eof= expects boolean argument."); + pa_log("exit_on_eof= expects boolean argument."); goto fail; } if (pa_stdio_acquire() < 0) { - pa_log(__FILE__": STDIN/STDUSE already in use."); + pa_log("STDIN/STDUSE already in use."); goto fail; } -- 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-cli.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/modules/module-cli.c') diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c index d5374838..b5c27299 100644 --- a/src/modules/module-cli.c +++ b/src/modules/module-cli.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 @@ -48,7 +48,7 @@ static const char* const valid_modargs[] = { static void eof_and_unload_cb(pa_cli*c, void *userdata) { pa_module *m = userdata; - + assert(c); assert(m); @@ -68,7 +68,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_iochannel *io; pa_modargs *ma; int exit_on_eof = 0; - + assert(c); assert(m); @@ -81,7 +81,7 @@ 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, "exit_on_eof", &exit_on_eof) < 0) { pa_log("exit_on_eof= expects boolean argument."); goto fail; @@ -102,7 +102,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_cli_set_eof_callback(m->userdata, exit_on_eof ? eof_and_exit_cb : eof_and_unload_cb, m); pa_modargs_free(ma); - + return 0; fail: -- 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-cli.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/modules/module-cli.c') diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c index b5c27299..19ac0c26 100644 --- a/src/modules/module-cli.c +++ b/src/modules/module-cli.c @@ -3,6 +3,8 @@ /*** This file is part of PulseAudio. + Copyright 2004-2006 Lennart Poettering + 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-cli.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'src/modules/module-cli.c') diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c index 19ac0c26..84125214 100644 --- a/src/modules/module-cli.c +++ b/src/modules/module-cli.c @@ -26,7 +26,6 @@ #endif #include -#include #include #include @@ -35,6 +34,7 @@ #include #include #include +#include #include "module-cli-symdef.h" @@ -51,8 +51,8 @@ static const char* const valid_modargs[] = { static void eof_and_unload_cb(pa_cli*c, void *userdata) { pa_module *m = userdata; - assert(c); - assert(m); + pa_assert(c); + pa_assert(m); pa_module_unload_request(m); } @@ -60,21 +60,20 @@ static void eof_and_unload_cb(pa_cli*c, void *userdata) { static void eof_and_exit_cb(pa_cli*c, void *userdata) { pa_module *m = userdata; - assert(c); - assert(m); + pa_assert(c); + pa_assert(m); m->core->mainloop->quit(m->core->mainloop, 0); } -int pa__init(pa_core *c, pa_module*m) { +int pa__init(pa_module*m) { pa_iochannel *io; pa_modargs *ma; int exit_on_eof = 0; - assert(c); - assert(m); + pa_assert(m); - if (c->running_as_daemon) { + if (m->core->running_as_daemon) { pa_log_info("Running as daemon, refusing to load this module."); return 0; } @@ -94,12 +93,10 @@ int pa__init(pa_core *c, pa_module*m) { goto fail; } - io = pa_iochannel_new(c->mainloop, STDIN_FILENO, STDOUT_FILENO); - assert(io); + io = pa_iochannel_new(m->core->mainloop, STDIN_FILENO, STDOUT_FILENO); pa_iochannel_set_noclose(io, 1); - m->userdata = pa_cli_new(c, io, m); - assert(m->userdata); + m->userdata = pa_cli_new(m->core, io, m); pa_cli_set_eof_callback(m->userdata, exit_on_eof ? eof_and_exit_cb : eof_and_unload_cb, m); @@ -115,11 +112,10 @@ fail: return -1; } -void pa__done(pa_core *c, pa_module*m) { - assert(c); - assert(m); +void pa__done(pa_module*m) { + pa_assert(m); - if (c->running_as_daemon == 0) { + if (m->core->running_as_daemon == 0) { pa_cli_free(m->userdata); pa_stdio_release(); } -- 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-cli.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/modules/module-cli.c') diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c index 84125214..71df5a0f 100644 --- a/src/modules/module-cli.c +++ b/src/modules/module-cli.c @@ -38,10 +38,11 @@ #include "module-cli-symdef.h" -PA_MODULE_AUTHOR("Lennart Poettering") -PA_MODULE_DESCRIPTION("Command line interface") -PA_MODULE_VERSION(PACKAGE_VERSION) -PA_MODULE_USAGE("exit_on_eof=") +PA_MODULE_AUTHOR("Lennart Poettering"); +PA_MODULE_DESCRIPTION("Command line interface"); +PA_MODULE_VERSION(PACKAGE_VERSION); +PA_MODULE_LOAD_ONCE(TRUE); +PA_MODULE_USAGE("exit_on_eof="); static const char* const valid_modargs[] = { "exit_on_eof", -- 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-cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules/module-cli.c') diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c index 71df5a0f..ab311a82 100644 --- a/src/modules/module-cli.c +++ b/src/modules/module-cli.c @@ -70,7 +70,7 @@ static void eof_and_exit_cb(pa_cli*c, void *userdata) { int pa__init(pa_module*m) { pa_iochannel *io; pa_modargs *ma; - int exit_on_eof = 0; + pa_bool_t exit_on_eof = FALSE; pa_assert(m); -- cgit