[pulseaudio-commits] src/modules

Tanu Kaskinen tanuk at kemper.freedesktop.org
Wed Mar 13 04:48:56 PDT 2013


 src/modules/module-udev-detect.c |   59 +++++++++++++++++++++++++++------------
 1 file changed, 41 insertions(+), 18 deletions(-)

New commits:
commit 56199172077b00a963b8fe1db6e0eed179b207b0
Author: Tanu Kaskinen <tanuk at iki.fi>
Date:   Sat Feb 16 17:29:58 2013 +0200

    udev: Add tsched_buffer_size module argument
    
    This makes it easier to configure the buffer size.

diff --git a/src/modules/module-udev-detect.c b/src/modules/module-udev-detect.c
index 76cab90..4f7a90d 100644
--- a/src/modules/module-udev-detect.c
+++ b/src/modules/module-udev-detect.c
@@ -36,6 +36,7 @@
 #include <pulsecore/core-util.h>
 #include <pulsecore/namereg.h>
 #include <pulsecore/ratelimit.h>
+#include <pulsecore/strbuf.h>
 
 #include "module-udev-detect-symdef.h"
 
@@ -45,6 +46,7 @@ PA_MODULE_VERSION(PACKAGE_VERSION);
 PA_MODULE_LOAD_ONCE(TRUE);
 PA_MODULE_USAGE(
         "tsched=<enable system timer based scheduling mode?> "
+        "tsched_buffer_size=<buffer size when using timer based scheduling> "
         "fixed_latency_range=<disable latency range changes on underrun?> "
         "ignore_dB=<ignore dB information from the device?> "
         "deferred_volume=<syncronize sw and hw volume changes in IO-thread?> "
@@ -64,11 +66,14 @@ struct userdata {
     pa_hashmap *devices;
 
     pa_bool_t use_tsched:1;
+    bool tsched_buffer_size_valid:1;
     pa_bool_t fixed_latency_range:1;
     pa_bool_t ignore_dB:1;
     pa_bool_t deferred_volume:1;
     bool use_ucm:1;
 
+    uint32_t tsched_buffer_size;
+
     struct udev* udev;
     struct udev_monitor *monitor;
     pa_io_event *udev_io;
@@ -79,6 +84,7 @@ struct userdata {
 
 static const char* const valid_modargs[] = {
     "tsched",
+    "tsched_buffer_size",
     "fixed_latency_range",
     "ignore_dB",
     "deferred_volume",
@@ -365,6 +371,7 @@ static void card_changed(struct userdata *u, struct udev_device *dev) {
     const char *path;
     const char *t;
     char *n;
+    pa_strbuf *args_buf;
 
     pa_assert(u);
     pa_assert(dev);
@@ -391,26 +398,33 @@ static void card_changed(struct userdata *u, struct udev_device *dev) {
 
     n = pa_namereg_make_valid_name(t);
     d->card_name = pa_sprintf_malloc("alsa_card.%s", n);
-    d->args = pa_sprintf_malloc("device_id=\"%s\" "
-                                "name=\"%s\" "
-                                "card_name=\"%s\" "
-                                "namereg_fail=false "
-                                "tsched=%s "
-                                "fixed_latency_range=%s "
-                                "ignore_dB=%s "
-                                "deferred_volume=%s "
-                                "use_ucm=%s "
-                                "card_properties=\"module-udev-detect.discovered=1\"",
-                                path_get_card_id(path),
-                                n,
-                                d->card_name,
-                                pa_yes_no(u->use_tsched),
-                                pa_yes_no(u->fixed_latency_range),
-                                pa_yes_no(u->ignore_dB),
-                                pa_yes_no(u->deferred_volume),
-                                pa_yes_no(u->use_ucm));
+    args_buf = pa_strbuf_new();
+    pa_strbuf_printf(args_buf,
+                     "device_id=\"%s\" "
+                     "name=\"%s\" "
+                     "card_name=\"%s\" "
+                     "namereg_fail=false "
+                     "tsched=%s "
+                     "fixed_latency_range=%s "
+                     "ignore_dB=%s "
+                     "deferred_volume=%s "
+                     "use_ucm=%s "
+                     "card_properties=\"module-udev-detect.discovered=1\"",
+                     path_get_card_id(path),
+                     n,
+                     d->card_name,
+                     pa_yes_no(u->use_tsched),
+                     pa_yes_no(u->fixed_latency_range),
+                     pa_yes_no(u->ignore_dB),
+                     pa_yes_no(u->deferred_volume),
+                     pa_yes_no(u->use_ucm));
     pa_xfree(n);
 
+    if (u->tsched_buffer_size_valid)
+        pa_strbuf_printf(args_buf, " tsched_buffer_size=%" PRIu32, u->tsched_buffer_size);
+
+    d->args = pa_strbuf_tostring_free(args_buf);
+
     pa_hashmap_put(u->devices, d->path, d);
 
     verify_access(u, d);
@@ -695,6 +709,15 @@ int pa__init(pa_module *m) {
     }
     u->use_tsched = use_tsched;
 
+    if (pa_modargs_get_value(ma, "tsched_buffer_size", NULL)) {
+        if (pa_modargs_get_value_u32(ma, "tsched_buffer_size", &u->tsched_buffer_size) < 0) {
+            pa_log("Failed to parse tsched_buffer_size= argument.");
+            goto fail;
+        }
+
+        u->tsched_buffer_size_valid = true;
+    }
+
     if (pa_modargs_get_value_boolean(ma, "fixed_latency_range", &fixed_latency_range) < 0) {
         pa_log("Failed to parse fixed_latency_range= argument.");
         goto fail;



More information about the pulseaudio-commits mailing list