Re: occasional crash in AudioQueueStop()
Re: occasional crash in AudioQueueStop()
- Subject: Re: occasional crash in AudioQueueStop()
- From: Brian Willoughby <email@hidden>
- Date: Sat, 18 Oct 2008 03:07:55 -0700
On Oct 17, 2008, at 20:25, Mark Kieling wrote:
Well the retain release pattern in the callback was clearly a bad
idea. Always do less work in the callback and assume all references
good. At the same time I agree, the recommended pattern is that
children not retain references to parents (delegates can be
considered parents). The code that set up the delegate relationship
should nil the delegate in the child when the delegate is deleted
and that will resolve issues with the bad reference. I always set
up properties so that rather than release the ivar I set the
property to nil - the synthetic setter will take care of releasing
when you set a property to nil.
Agreed. The only statement I would alter is that *sometimes*
delegates can be considered parents. Not always.
I almost always write my custom classes to be their own delegates, or
to be delegates of multiple objects. In fact, it's quite often the
delegate of the Application object which controls my entire program.
Document-based programs move this from NSApp to NSDocument. I've
never had a cyclic reference except when working with the ObjC-Java
bridge in WebObjects.
But I only mention this as a hint to CoreAudio developers who are
dealing with Cocoa. If you follow the advice to retain before
setting up your callback, and release after tearing down your
callback, but you're still getting errors due to messages to freed
objects, then you might take what I've said above as a hint: The
delegate does not always have to be a separate object - it can be
anything. Breaking the cycling retain loop could be as easy as
moving a few methods from one class to another and changing the
setDelegate: parameter.
Brian
_______________________________________________
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