[pulseaudio-discuss] [PATCH] module-jack-sink/source: Set fixed latency correctly on creation

Maarten Lankhorst m.b.lankhorst at gmail.com
Sun Mar 25 03:59:11 PDT 2012


250 ms default fixed latency won't work well for some applications like wine.

Signed-off-by: Maarten Lankhorst <m.b.lankhorst at gmail.com>

---
diff --git a/src/modules/jack/module-jack-sink.c b/src/modules/jack/module-jack-sink.c
index ba4ea95..4270b15 100644
--- a/src/modules/jack/module-jack-sink.c
+++ b/src/modules/jack/module-jack-sink.c
@@ -296,6 +296,8 @@ int pa__init(pa_module*m) {
     unsigned i;
     const char **ports = NULL, **p;
     pa_sink_new_data data;
+    jack_nframes_t l;
+    size_t n;
 
     pa_assert(m);
 
@@ -443,6 +445,9 @@ int pa__init(pa_module*m) {
         }
     }
 
+    l = jack_port_get_total_latency(u->client, u->port[0]);
+    n = l * pa_frame_size(&u->sink->sample_spec);
+    pa_sink_set_fixed_latency(u->sink, pa_bytes_to_usec(n, &u->sink->sample_spec));
     pa_sink_put(u->sink);
 
     if (ports)
diff --git a/src/modules/jack/module-jack-source.c b/src/modules/jack/module-jack-source.c
index 13109f3..a1ec9f6 100644
--- a/src/modules/jack/module-jack-source.c
+++ b/src/modules/jack/module-jack-source.c
@@ -249,6 +249,8 @@ int pa__init(pa_module*m) {
     unsigned i;
     const char **ports = NULL, **p;
     pa_source_new_data data;
+    jack_nframes_t l;
+    size_t n;
 
     pa_assert(m);
 
@@ -388,6 +390,9 @@ int pa__init(pa_module*m) {
 
     }
 
+    l = jack_port_get_total_latency(u->client, u->port[0]);
+    n = l * pa_frame_size(&u->source->sample_spec);
+    pa_source_set_fixed_latency(u->source, pa_bytes_to_usec(n, &u->source->sample_spec));
     pa_source_put(u->source);
 
     if (ports)




More information about the pulseaudio-discuss mailing list