On Memory Management & MusicSequence
On Memory Management & MusicSequence
- Subject: On Memory Management & MusicSequence
- From: Daniel Jalkut <email@hidden>
- Date: Sat, 7 Feb 2004 14:29:22 -0800
I have recently plunged back into some CoreAudio (specifically
MusicPlayer) work I started a long time ago. Unfortunately, there are
a lot of bugs in this code, and I'm discovering that a lot of them are
mine based on a poor understanding of how CoreAudio works. Now that I
have a better grasp on the overall structure of the framework, I'm less
apt to make mistakes. Not immune, though :)
I would like to clear a few things up before I proceed with massively
redesigning the way I handle CoreAudio objects. I have determined that
a lot of my problems might be based in assumptions I've made about
CoreAudio's memory management and other implications of using "set"
type functions on CoreAudio objects.
First, is there an "formula" to the CoreAudio memory management that I
can refer to when deciding whether or not to take (or give up)
ownership of an object? I am working mostly with Objective-C wrappers
around CA objects, and I've had a few cases where it's not clear who is
responsible for disposing of an object. One particular example that
springs to mind is in the case of "MusicSequenceSetAUGraph". I created
the AUGraph and all the objects that reside in it, but I'm asking
MusicSequence to target it (or one of the devices in it). Does it take
possession of the graph? If not, do I need to do anything to tell it
"the graph is bogus now" ?
I'm also running into problems that I suspect might fall into this
"wrong sequence or left out a step" class of problems that has bitten
me with CoreAudio before. In particular what I'm curious about is
dynamically resetting the AUGraph for a MusicSequence. I have a
MusicPlayer and MusicSequence that hang out for the entire life of my
program. The only thing that changes is the device and AUGraph that
the sequence is associated with. When the device changes, I chuck the
old AUGraph and produce an entirely new graph based on the new device.
I then set it on the MusicSequence with MusicSequenceSetAUGraph. I
don't make any attempt to remind MusicPlayer who it's sequence is. Do
I need to?
All the CoreAudio examples are great, but I can't find an example of
any code that has to deal with the ramifications of "responsible
recycling and remanipulation" of CoreAudio objects. My big bug right
now is a situation where an AUGraph "goes bad" without my disposing of
it. I'm sure it has something to do with my management of peripheral
objects to the AUGraph, but I can't figure out how to right my wrongs.
Thanks!
Daniel
_______________________________________________
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.