From 08953564bb85356869a1f043b82d1f365c8729a1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 17 Sep 2004 20:43:40 +0000 Subject: add --resample-method argument git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@214 fefdeb5f-60dc-0310-8127-8f9354f1896f --- polyp/client-conf.c | 2 +- polyp/client.conf.in | 10 ++++----- polyp/cmdline.c | 22 ++++++++++--------- polyp/daemon-conf.c | 57 ++++++++++++++++++++++++++++++++---------------- polyp/daemon-conf.h | 3 +++ polyp/polyplib-context.c | 7 +++--- polyp/util.c | 2 +- 7 files changed, 64 insertions(+), 39 deletions(-) (limited to 'polyp') diff --git a/polyp/client-conf.c b/polyp/client-conf.c index d904cb49..c43788fe 100644 --- a/polyp/client-conf.c +++ b/polyp/client-conf.c @@ -57,7 +57,7 @@ struct pa_client_conf *pa_client_conf_new(void) { struct pa_client_conf *c = pa_xmemdup(&default_conf, sizeof(default_conf)); c->daemon_binary = pa_xstrdup(POLYPAUDIO_BINARY); - c->extra_arguments = pa_xstrdup("--daemonize=yes --log-target=syslog"); + c->extra_arguments = pa_xstrdup("--log-target=syslog --exit-idle-time=5"); return c; } diff --git a/polyp/client.conf.in b/polyp/client.conf.in index 7ba6549b..640e2690 100644 --- a/polyp/client.conf.in +++ b/polyp/client.conf.in @@ -21,19 +21,19 @@ ## commented out. Use either ; or # for commenting ## Path to the polypaudio daemon to run when autospawning. -; daemon_binary = @POLYPAUDIO_BINARY@ +; daemon-binary = @POLYPAUDIO_BINARY@ ## Extra arguments to pass to the polypaudio daemon -; extra_arguments = --daemonize=yes --log-target=syslog +; extra-arguments = --log-target=syslog --exit-idle-time=5 ## The default sink to connect to -; default_sink = +; default-sink = ## The default source to connect to -; default_source = +; default-source = ## The default sever to connect to -; default_server = +; default-server = ## Autospawn daemons? ; autospawn = 0 diff --git a/polyp/cmdline.c b/polyp/cmdline.c index 7f8a947b..a5bb8101 100644 --- a/polyp/cmdline.c +++ b/polyp/cmdline.c @@ -52,6 +52,7 @@ enum { ARG_LOAD, ARG_FILE, ARG_DL_SEARCH_PATH, + ARG_RESAMPLE_METHOD }; static struct option long_options[] = { @@ -71,6 +72,7 @@ static struct option long_options[] = { {"load", 1, 0, ARG_LOAD}, {"file", 1, 0, ARG_FILE}, {"dl-search-path", 1, 0, ARG_DL_SEARCH_PATH}, + {"resample-method", 1, 0, ARG_RESAMPLE_METHOD}, {NULL, 0, 0, 0} }; @@ -98,7 +100,8 @@ void pa_cmdline_help(const char *argv0) { " --module-idle-time=SECS Unload autoloaded modules when idle and this time passed\n" " --scache-idle-time=SECS Unload autoloaded samples when idle and this time passed\n" " --log-target={auto,syslog,stderr} Specify the log target\n" - " -p, --dl-search-path=PATH Set the search path for dynamic shared objects (plugins)\n\n" + " -p, --dl-search-path=PATH Set the search path for dynamic shared objects (plugins)\n" + " --resample-method=[METHOD] Use the specified resampling method\n\n" " -L, --load=\"MODULE ARGUMENTS\" Load the specified plugin module with the specified argument\n" " -F, --file=FILENAME Run the specified script\n" @@ -198,15 +201,7 @@ int pa_cmdline_parse(struct pa_daemon_conf *conf, int argc, char *const argv [], break; case ARG_LOG_TARGET: - if (!strcmp(optarg, "syslog")) { - conf->auto_log_target = 0; - conf->log_target = PA_LOG_SYSLOG; - } else if (!strcmp(optarg, "stderr")) { - conf->auto_log_target = 0; - conf->log_target = PA_LOG_STDERR; - } else if (!strcmp(optarg, "auto")) - conf->auto_log_target = 1; - else { + if (pa_daemon_conf_set_log_target(conf, optarg) < 0) { pa_log(__FILE__": Invalid log target: use either 'syslog', 'stderr' or 'auto'.\n"); goto fail; } @@ -223,6 +218,13 @@ int pa_cmdline_parse(struct pa_daemon_conf *conf, int argc, char *const argv [], case ARG_SCACHE_IDLE_TIME: conf->scache_idle_time = atoi(optarg); break; + + case ARG_RESAMPLE_METHOD: + if (pa_daemon_conf_set_resample_method(conf, optarg) < 0) { + pa_log(__FILE__": Invalid resample method '%s'.\n", optarg); + goto fail; + } + break; default: goto fail; diff --git a/polyp/daemon-conf.c b/polyp/daemon-conf.c index a3185364..6dcd540d 100644 --- a/polyp/daemon-conf.c +++ b/polyp/daemon-conf.c @@ -110,41 +110,60 @@ void pa_daemon_conf_free(struct pa_daemon_conf *c) { pa_xfree(c); } -int parse_log_target(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { - struct pa_daemon_conf *c = data; - assert(filename && lvalue && rvalue && data); - - if (!strcmp(rvalue, "auto")) +int pa_daemon_conf_set_log_target(struct pa_daemon_conf *c, const char *string) { + assert(c && string); + + if (!strcmp(string, "auto")) c->auto_log_target = 1; - else if (!strcmp(rvalue, "syslog")) { + else if (!strcmp(string, "syslog")) { c->auto_log_target = 0; c->log_target = PA_LOG_SYSLOG; - } else if (!strcmp(rvalue, "stderr")) { + } else if (!strcmp(string, "stderr")) { c->auto_log_target = 0; c->log_target = PA_LOG_STDERR; - } else { - pa_log(__FILE__": [%s:%u] Invalid log target '%s'.\n", filename, line, rvalue); + } else return -1; - } return 0; + } -int parse_resample_method(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { - struct pa_daemon_conf *c = data; - assert(filename && lvalue && rvalue && data); +int pa_daemon_conf_set_resample_method(struct pa_daemon_conf *c, const char *string) { + assert(c && string); - if (!strcmp(rvalue, "sinc-best-quality")) + if (!strcmp(string, "sinc-best-quality")) c->resample_method = SRC_SINC_BEST_QUALITY; - else if (!strcmp(rvalue, "sinc-medium-quality")) + else if (!strcmp(string, "sinc-medium-quality")) c->resample_method = SRC_SINC_MEDIUM_QUALITY; - else if (!strcmp(rvalue, "sinc-fastest")) + else if (!strcmp(string, "sinc-fastest")) c->resample_method = SRC_SINC_FASTEST; - else if (!strcmp(rvalue, "zero-order-hold")) + else if (!strcmp(string, "zero-order-hold")) c->resample_method = SRC_ZERO_ORDER_HOLD; - else if (!strcmp(rvalue, "linear")) + else if (!strcmp(string, "linear")) c->resample_method = SRC_LINEAR; - else { + else + return -1; + + return 0; +} + +int parse_log_target(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { + struct pa_daemon_conf *c = data; + assert(filename && lvalue && rvalue && data); + + if (pa_daemon_conf_set_log_target(c, rvalue) < 0) { + pa_log(__FILE__": [%s:%u] Invalid log target '%s'.\n", filename, line, rvalue); + return -1; + } + + return 0; +} + +int parse_resample_method(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) { + struct pa_daemon_conf *c = data; + assert(filename && lvalue && rvalue && data); + + if (pa_daemon_conf_set_resample_method(c, rvalue) < 0) { pa_log(__FILE__": [%s:%u] Inavalid resample method '%s'.\n", filename, line, rvalue); return -1; } diff --git a/polyp/daemon-conf.h b/polyp/daemon-conf.h index c987a6d5..8be989da 100644 --- a/polyp/daemon-conf.h +++ b/polyp/daemon-conf.h @@ -55,4 +55,7 @@ int pa_daemon_conf_load(struct pa_daemon_conf *c, const char *filename); char *pa_daemon_conf_dump(struct pa_daemon_conf *c); int pa_daemon_conf_env(struct pa_daemon_conf *c); +int pa_daemon_conf_set_log_target(struct pa_daemon_conf *c, const char *string); +int pa_daemon_conf_set_resample_method(struct pa_daemon_conf *c, const char *string); + #endif diff --git a/polyp/polyplib-context.c b/polyp/polyplib-context.c index 4ed15c4b..8f6ce6a8 100644 --- a/polyp/polyplib-context.c +++ b/polyp/polyplib-context.c @@ -432,16 +432,17 @@ static int context_connect_spawn(struct pa_context *c, const struct pa_spawn_api putenv(t); argv[n++] = c->conf->daemon_binary; - + argv[n++] = "--daemonize=yes"; + snprintf(t, sizeof(t), "-Lmodule-native-protocol-fd fd=%i", fds[1]); - argv[n++] = pa_xstrdup(t); + argv[n++] = t; while (n < MAX_ARGS) { char *a; if (!(a = pa_split_spaces(c->conf->extra_arguments, &state))) break; - + argv[n++] = a; } diff --git a/polyp/util.c b/polyp/util.c index 86f18f25..e4dcd1c9 100644 --- a/polyp/util.c +++ b/polyp/util.c @@ -396,7 +396,7 @@ char *pa_split_spaces(const char *c, const char **state) { const char *current = *state ? *state : c; size_t l; - if (*current) + if (!*current) return NULL; current += strspn(current, WHITESPACE); -- cgit