Re: Remote IO thread and concurrency
Re: Remote IO thread and concurrency
- Subject: Re: Remote IO thread and concurrency
- From: Ross Bencina <email@hidden>
- Date: Thu, 08 Oct 2015 11:55:53 +1100
On 8/10/2015 8:44 AM, James Navarro wrote:
> This method needs to play float samples, by copying them from a buffer.
>
> The problem is, that buffer needs to be released by the user
sometimes. I cannot find a safe way to do this
Your description is not entirely clear. When is the buffer allocated,
and when does it need to be freed?
Note that not only can you not use locks/mutexes etc, you should not
call any memory allocation functions (new/delete, malloc()/free() etc)
in your RemoteIO callback.
If you have a producer/consumer situation where the buffer is generated
in a non-real-time thread and then played by the RemoteIO thread, you
can set up a couple of lock-free queues and pass the buffer pointer back
and forth between NRT and RT thusly:
in NRT:
allocate buffer
generate buffer
pass to RT via queue A
in RT:
use buffer in RT
pass buffer to NRT queue B
in NRT:
free buffer
Hope that helps.
Ross.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden