• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Remote IO thread and concurrency
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Remote IO thread and concurrency (From: James Navarro <email@hidden>)

  • Prev by Date: Re: Remote IO thread and concurrency
  • Next by Date: problems @ AU validation with CoreAudio's kAudioChannelLayoutTag_UseChannelDescriptions tag implementation.
  • Previous by thread: Re: Remote IO thread and concurrency
  • Next by thread: problems @ AU validation with CoreAudio's kAudioChannelLayoutTag_UseChannelDescriptions tag implementation.
  • Index(es):
    • Date
    • Thread