The null-source currently reports the negative of the correct latency.
Also the memchunk passed to pa_source_post() is not initialized with
silence.

This patch fixes both issues.
---
 src/modules/module-null-source.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/modules/module-null-source.c b/src/modules/module-null-source.c
index 41f17bd9..6310bda9 100644
--- a/src/modules/module-null-source.c
+++ b/src/modules/module-null-source.c
@@ -100,7 +100,7 @@ static int source_process_msg(pa_msgobject *o, int code, 
void *data, int64_t off
             pa_usec_t now;
 
             now = pa_rtclock_now();
-            *((int64_t*) data) = (int64_t)u->timestamp - (int64_t)now;
+            *((int64_t*) data) = (int64_t)now - (int64_t)u->timestamp;
 
             return 0;
         }
@@ -142,8 +142,9 @@ static void thread_func(void *userdata) {
 
             if ((chunk.length = pa_usec_to_bytes(now - u->timestamp, 
&u->source->sample_spec)) > 0) {
 
-                chunk.memblock = pa_memblock_new(u->core->mempool, (size_t) 
-1); /* or chunk.length? */
+                chunk.memblock = pa_memblock_new(u->core->mempool, 
chunk.length);
                 chunk.index = 0;
+                pa_silence_memchunk(&chunk, &u->source->sample_spec);
                 pa_source_post(u->source, &chunk);
                 pa_memblock_unref(chunk.memblock);
 
-- 
2.14.1

_______________________________________________
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss

Reply via email to