Re: On Memory Management & MusicSequence
Re: On Memory Management & MusicSequence
- Subject: Re: On Memory Management & MusicSequence
- From: William Stewart <email@hidden>
- Date: Mon, 9 Feb 2004 12:42:10 -0800
First of all - there is no "under the hood" memory management in
CoreAudio. Its a C API and all allocations/releases are explicit.
On 07/02/2004, at 2:29 PM, Daniel Jalkut wrote:
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" ?
You better not dispose of a graph that is in use by a sequence. So,
you'd have to:
Stop playing the sequence
remove the sequence from the player (if you're disposing the graph, its
sequence is unplayable)
Remove the graph from the sequence
dispose the graph
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?
You can't reset a sequence's graph (or midi destinations) whilst it is
in the process of being played.
Bill
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.
You must be disposing it, removing it from the sequence or something...
its not 'just happening'
Bill
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.
--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________
__
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________
__
_______________________________________________
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.