• 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: occasional crash in AudioQueueStop()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >occasional crash in AudioQueueStop() (From: John Zorko <email@hidden>)
 >Re: occasional crash in AudioQueueStop() (From: Christopher Liscio <email@hidden>)
 >Re: occasional crash in AudioQueueStop() (From: Brian Willoughby <email@hidden>)
 >Re: occasional crash in AudioQueueStop() (From: Christopher Liscio <email@hidden>)
 >Re: occasional crash in AudioQueueStop() (From: Brian Willoughby <email@hidden>)
 >Re: occasional crash in AudioQueueStop() (From: Christopher Liscio <email@hidden>)
 >Re: occasional crash in AudioQueueStop() (From: Mark Kieling <email@hidden>)

  • Prev by Date: Re: occasional crash in AudioQueueStop()
  • Next by Date: rtp midi
  • Previous by thread: Re: occasional crash in AudioQueueStop()
  • Next by thread: NSSlider correct event handling in Audio Unit with Cocoa GUI
  • Index(es):
    • Date
    • Thread