[PATCH] null-source: correct latency report and silence memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/15/2018 12:03 AM, Georg Chini wrote:
> 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);

I think you need to change the next line too:
 
-                u->timestamp = now;
+                u->timestamp += pa_bytes_to_usec(chunk.length, &u->source->sample_spec);
             }

to make silence generator more stable


>  
> 

--
Raman


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux