add --resample-method argument
authorLennart Poettering <lennart@poettering.net>
Fri, 17 Sep 2004 20:43:40 +0000 (20:43 +0000)
committerLennart Poettering <lennart@poettering.net>
Fri, 17 Sep 2004 20:43:40 +0000 (20:43 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@214 fefdeb5f-60dc-0310-8127-8f9354f1896f

doc/todo
polyp/client-conf.c
polyp/client.conf.in
polyp/cmdline.c
polyp/daemon-conf.c
polyp/daemon-conf.h
polyp/polyplib-context.c
polyp/util.c

index fe06df7..53d4ca5 100644 (file)
--- a/doc/todo
+++ b/doc/todo
@@ -2,10 +2,7 @@
 
 *** 0.5 ***
 - more complete pactl/parec
-- fix tcp/native in regard to latencies
-- add client config file
-- remove autospawn stuff in conf.c
-- make resampler configurable
+- fix tcp/native in regard to latencies (i.e. latency interpolation)
 
 *** 0.6 ****
 - per-channel volume
index d904cb4..c43788f 100644 (file)
@@ -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;
 }
index 7ba6549..640e269 100644 (file)
 ## 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
index 7f8a947..a5bb810 100644 (file)
@@ -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;
index a318536..6dcd540 100644 (file)
@@ -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;
     }
index c987a6d..8be989d 100644 (file)
@@ -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
index 4ed15c4..8f6ce6a 100644 (file)
@@ -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;
         }
 
index 86f18f2..e4dcd1c 100644 (file)
@@ -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);