Re: Who owns MIDIPacketList memory supplied to MIDISend
Re: Who owns MIDIPacketList memory supplied to MIDISend
- Subject: Re: Who owns MIDIPacketList memory supplied to MIDISend
- From: Brian Willoughby <email@hidden>
- Date: Sun, 05 Jun 2011 12:07:55 -0700
I do not recall whether the data is copied or not, but the key is
that you should not allocate the data on the stack. There are many
ways to allocate the packet and packet list in Standard C, Objective
C, or C++, so just avoid the stack and you'll be fine. If you've
found sample code that allocates on the stack, then it's simply bad
sample code.
By the way, the code snippet that you excerpted could possibly work
if the context of the lines were changed, i.e. static globals or
instance variables.
Brian Willoughby
Sound Consulting
On Jun 5, 2011, at 11:51, Eric Kampman wrote:
<QUOTE>
MIDIPacketList the_packet_list ;
MIDIPacketList* packet_list = &the_packet_list ;
MIDIPacket* current_packet = MIDIPacketListInit (packet_list) ;
</UNQUOTE>
OK, I get that -- it looks like a MIDIPacket defaults to having 256
bytes available.
But the_packet_list is on the stack, and it doesn't look to me like
MIDISend is a synchronous (blocking) call (since the timestamp can
be non-zero), so ... does the MIDI data get copied? The inference I
think is that the data DOES get copied, otherwise the above code
would often behave badly.
_______________________________________________
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