• 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: Eric Kampman <email@hidden>
  • Date: Sun, 05 Jun 2011 12:40:30 -0700

Thanks Brian,

But the issue is still unresolved, because
1) if the data is copied, it doesn't matter where the "copied from" location is, stack or heap,
2) if I use a global or some other more "permanant" memory, then if the data is NOT copied then I must ensure that I don't overwrite the data before it goes out the door.

Another active thread here has to do with modifying MIDI data that's already been submitted, and a statement was made that once CoreMIDI has it it can't be modified, which also makes me believe it's copied.

So I'd still like to know the answer. I'll keep fishing on the list archive too.
Thanks,
Eric


On Jun 5, 2011, at 12:07 PM, Brian Willoughby wrote:

> 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

  • Follow-Ups:
    • Re: Who owns MIDIPacketList memory supplied to MIDISend
      • From: philippe wicker <email@hidden>
References: 
 >Who owns MIDIPacketList memory supplied to MIDISend (From: Eric Kampman <email@hidden>)
 >Re: Who owns MIDIPacketList memory supplied to MIDISend (From: Brian Willoughby <email@hidden>)

  • Prev by Date: Re: Who owns MIDIPacketList memory supplied to MIDISend
  • Next by Date: Re: Create MIDI device programmaticly without a MIDIDriver bundle
  • Previous by thread: Re: Who owns MIDIPacketList memory supplied to MIDISend
  • Next by thread: Re: Who owns MIDIPacketList memory supplied to MIDISend
  • Index(es):
    • Date
    • Thread