MusicPlayer/MusicSequence
MusicPlayer/MusicSequence
- Subject: MusicPlayer/MusicSequence
- From: Bill Stewart <email@hidden>
- Date: Thu, 3 Jul 2003 01:06:22 -0700
Recently there was a post on the list about some problems with the DLS
Music Device and some malloc/free warnings...
We believe that we've fixed all of these problems now, as we can't
reproduce these ourselves by trying the reported methods... If people
have the Panther seed and see any problems in this area, please let us
know.
I've a comment or two about some code that was posted to reproduce this
using the MusicPlayer and Sequence. Here's the original code:
status = NewMusicPlayer(&player);
// start loop
status = NewMusicSequence(&sequence);
status = MusicPlayerSetSequence (player, sequence);
status = MusicSequenceNewTrack(sequence,&track);
status = MusicPlayerPreroll (player);
status = MusicPlayerStart (player);
status = MusicSequenceDisposeTrack(sequence,track)
status = DisposeMusicSequence(sequence)
//end loop
I'm not sure if this code is really being used as it was posted - so
I'm not pointing fingers here! (the code was grafted from a larger
app), but I wanted to make a couple of points about this and some
changes that you will see with Panther.
There are three things that should not be done whilst a player is
playing.
Reset the Sequence a player is playing
Dispose the Sequence a player is playing
Remove a Track from a sequence that is being played
All of these actions will in the next release(!) return the error:
kAudioToolboxErr_CannotDoInCurrentContext = -10863
None of these actions return errors (in fact these actions will be
done) in a current Jaguar version of the AudioToolbox - which is bad
and should not have been allowed to occur! (Thus the new result code -
and the action won't be allowed to proceed of course)
So - I think there are a couple of things worth noting (and I'll make
sure this is added to the documentation we are busily pushing through!)
Basically, the track state (including nodes/endpoint destinations) are
established for the player in the MusicPlayerPreroll call. Because of
numerous bugs in this, we'd strongly advise developers not to call
Preroll in a 1.2.x version of AudioToolbox.framework (and rather let
the MusicPlayerStart call do the preroll). These issues have been fixed
and will be available on a Jaguar system update of the AudioToolbox at
some later date (don't ask me when!)
The way this will work going forward:
Preroll establishes, based on the current state of the Sequence, a set
of playing objects that are used by the player to know how it should
play the sequence.
If the application changes either the destination of a sequence to a
different node (AU) or endpoint (MIDI), then the player should be
explicitly prerolled again.
If the application adds or removes tracks (and of course the player
hasn't played yet:) - then the application should explicitly preroll
the player again.
If the application doesn't do either of these actions after prerolling
a player, then the player can just be started.
Prerolling can do a lot of work - so it is good to do this before you
really need to start a sequence if you want that start to be
"immediate" - so apologies that this doesn't work as it should in
Jaguar as it is today!
Finally, remove a Track from a sequence that is being played... In a
current system the behaviour is very undefined... I can't imagine this
is working very well for anyone doing this... The desired result (ie.
don't have the track's events played) - can be achieved by muting the
track (there's no runtime overhead for the playback to have a muted
track lying around). Then when you stop the player, remove the track
(or replace the sequence for that matter) as you will.
Thanks
Billl
_______________________________________________
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.