Re: Objective-C in a Time Constraint Thread
Re: Objective-C in a Time Constraint Thread
- Subject: Re: Objective-C in a Time Constraint Thread
- From: john <email@hidden>
- Date: Mon, 27 Feb 2006 17:30:35 -0500
Hi Sekhar,
I would be surprised if making a method call from a CoreAudio ioproc
would cause an audio glitch even on slow computers. I had various
levels of processing loads in CoreAudio ioprocs when I first started
with CoreAudio and have gradually changed some things to lessen the
load, but back I never experienced any audio glitches (even on a
500mhz G3).
It's best to plan most efficiently, but I don't think a handful of
method calls is going to cause any problems.
-- John
I'm trying to get a better understanding of issues that may arise
when using Objective-C inside of a CoreAudio IOProc.
The CoreAudio Hardware Abstraction Layer calls clients to produce
audio on a time-constraint thread. Thus, audio generating functions
are discouraged from invoking functions that may block the thread
or take "a long time" to return (e.g., locking mutexes, allocating
memory, reading from disk) [1].
On the CoreAudio list, it was pointed out that "... ObjC message
sends are treated as an opportunity for the ObjC runtime to re-
evaluate its world, and thus can not only involve locks, but also
memory allocations" [2].
I looked at the source for objc_msgSend <http://
darwinsource.opendarwin.org/10.3/objc4-235/runtime/
Messengers.subproj/objc-msg-ppc.s> and, sure enough, there is a
comment before the macro LockCache:
; The collecting cache mechanism precludes the need for a cache lock
; in objc_msgSend. The cost of the collecting cache is small: a few
; K of memory for uncollected caches, and less than 1 ms per
collection.
; A large app will only run collection a few times.
I'm assuming this is what was being referred to in the ca-api list
post.
Is this comment still accurate? If so, calling objc_msgSend in an
IOProc is certainly risking audio glitches. Are there ways to
decrease the probability of having the cache collected or is there
any way to avoid it altogether? For example, will caching the IMP
and invoking that directly help?
Thanks.
- sekhar
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden