• 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: locks for AU rendering
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: locks for AU rendering


  • Subject: Re: locks for AU rendering
  • From: Bill Stewart <email@hidden>
  • Date: Tue, 8 Apr 2003 17:08:40 -0700

On Tuesday, April 8, 2003, at 02:00 PM, Marc Poirier wrote:

Hi. I am working on an AU that performs pretty hefty state change on the
DSP settings when loading presets, so I've decided that I would be better
off adding locks to my AU for thread safety. But I'm not very educated on
the different lock APIs in Mac OS X and their performance issues (which of
course are important with realtime audio).

One way to do this is using a safe mode of swapping out a pointer to the data you need to read

Thus, when you write you first write to another piece of memory, then when you are done just swap the pointer around that your read from.

That way you don't need to take locks in your render thread...

Bill


My needs are pretty simple, though. I have data that I write to when a
preset is loaded and that I read from while rendering audio. So I need to
lock the data before each of those operations and unlock it afterwords. I
can't really use time-outs because these things need to happen, so I'm
using thread-blocking locks.

Currently I'm using pthread mutexes. I have one of these in my AU effect
component class:
pthread_mutex_t pmut;
and then in my plugin's constructor I do this:
pthread_mutex_init(&pmut, NULL);
and then in the destructor I do this:
pthread_mutex_destroy(&pmut);
and then before loading a preset or rendering an audio slice I do this:
pthread_mutex_lock(&pmut);
and then, after either of those things are finished, I do this:
pthread_mutex_unlock(&pmut);

Is this considered to be an okay way to go about this? Or should I be
taking another strategy? Any advice is very welcome. This is something
with which I don't have a lot of experience.

Thanks,
Marc
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.


-- mailto:email@hidden
tel: +1 408 974 4056

________________________________________________________________________ __
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________ __
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: locks for AU rendering
      • From: Marc Poirier <email@hidden>
  • Prev by Date: Re: AU logo
  • Next by Date: Re: AU logo
  • Previous by thread: locks for AU rendering
  • Next by thread: Re: locks for AU rendering
  • Index(es):
    • Date
    • Thread