Re: locks for AU rendering
Re: locks for AU rendering
- Subject: Re: locks for AU rendering
- From: AJ <email@hidden>
- Date: Tue, 08 Apr 2003 14:36:21 -0700
I would say first and foremost that pthread_mutex_lock is a blocking
call. Do you really want to do this before rendering an audio slice? My
impression was that it's very important that all audio rendering be done
in a non-blocking manner to avoid glitches in your audio.
Is there any way that you can be more specific about why your hefty
state change forces you to lock? Is it possible that you can load
presets in a seperate thread, which could block reading files or
whatever, meanwhile leaving your rendering thread functional, and then
"atomically" change the DSP preset "out from under" your AU w/o
requiring any locking?
I would focus more on process architecture changes then any mutex
locking if necessary.
--aj
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).
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.
--
"Chance is the limit of the notion of evolving symmetry."
-- Iannis Xenakis
_______________________________________________
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.