Re: [LAD] Synchronizig arg update in callback and process in main function

From: Len Ovens <len@email-addr-hidden>
Date: Mon Jan 15 2018 - 18:19:16 EET

On Mon, 15 Jan 2018, Benny Alexandar wrote:

> I have registered process callback and also a pointer to data struct as arg
> parameter. 
> Whenever callback happens this arg is typecasted to data struct, and update the
> data struct.
>
> For eg every 20ms process callback happens and updated the data struct arg,
> and every 100ms  main function reads the data struct. While reading  and
> processing
> the data process callback can happen and update it.
>
> How to make sure when main function is reading data struct the process callback
> is not updated,
>
> or any other ways to synchronize these two ? Any example app for this.

Jack provides a ring buffer for this purpose. Here is an example
https://github.com/jackaudio/example-clients/blob/master/capture_client.c
Just make things clear, the ring buffer thinks in bytes and so each sample
will take more than one byte (we hope :)
http://jackaudio.org/files/docs/html/ringbuffer_8h.html

--
Len Ovens
www.ovenwerks.net

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
https://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Mon Jan 15 20:15:01 2018

This archive was generated by hypermail 2.1.8 : Mon Jan 15 2018 - 20:15:01 EET