• 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: Who owns MIDIPacketList memory supplied to MIDISend
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Who owns MIDIPacketList memory supplied to MIDISend


  • Subject: Re: Who owns MIDIPacketList memory supplied to MIDISend
  • From: Roni Music <email@hidden>
  • Date: Mon, 06 Jun 2011 21:33:20 +0200

I haven't followd this thread but...

Yes, you can have
MIDIPacketList the_packet_list ;
MIDIPacketList* packet_list = &the_packet_list ;
etc
on the stack

I've done that for ages and the CoreMIDI samples does this as well
so it's copied

but what's important is that if you are on iOS (arm)
(not sure if you are?)
then you need to make sure that
MIDIPacketList (or MIDIPacket?)
is 4-byte aligned else it will crash

That took me a while to find out but it's clearly stated in the CoreMIDI headers

Maybe that's the problem?


btw, I do like this:

UInt32 buffer[256];    // force 4-byte alignment on iOS
MIDIPacketList* the_packet_list  = (MIDIPacketList*)buffer;

there are probably better ways to do it?




Message: 1
Date: Sun, 05 Jun 2011 12:07:55 -0700
From: Brian Willoughby <email@hidden>
Subject: Re: Who owns MIDIPacketList memory supplied to MIDISend
To: "email@hidden Audio"
<email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed

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
  • Prev by Date: Re: Problems with a Low Pass Filter process
  • Next by Date: Re: Who owns MIDIPacketList memory supplied to MIDISend
  • Previous by thread: Re: Who owns MIDIPacketList memory supplied to MIDISend
  • Next by thread: iOS background audio termination criteria
  • Index(es):
    • Date
    • Thread