Re: Calculating size for MIDIPacketListAdd
Re: Calculating size for MIDIPacketListAdd
- Subject: Re: Calculating size for MIDIPacketListAdd
- From: Doug Wyatt <email@hidden>
- Date: Thu, 19 Sep 2002 10:40:53 -0700
On Thursday, Sep 19, 2002, at 06:17 US/Pacific, email@hidden wrote:
When a MIDIPacketList is init'ed it has single MIDIPacket inside (an
array
with a single element.)
It's dangerous to think of the MIDIPacketList's MIDIPackets as array
elements. It's declared that way because it's the closest way to
express it in C. A MIDIPacketList is actually a *stream* of
variable-sized MIDIPackets and they can't be randomly accessed except
by walking through the stream/structure from the beginning.
Can/should I assume that this is how the MIDIPacketList
coming into my Read Proc is sized?
It's just a chunk of memory ... you can't make any assumptions about
how big a chunk of memory was allocated.
Question: Is MIDIPacketListInit creating a MIDIPacketList or
*blessing* a block of data
as a MIDIPacketList? I read it originally as a way to create lists but
now I think I'm wrong.
It's just initializing a buffer for use with MIDIPacketListAdd.
The problem is - if I'm adding to someone else's MIDIPacketList (like
the one I get passed
in my Read Proc) I've got no guarantee of it's maximum size - just
that it's *at least* sizeof(MIDIPacketList). That makes me think that
I shouldn't be adding my packets to someone else's packet list?
Right. That's why the incoming MIDIPacketList is declared const.
You're not supposed to alter it at all, just read from it. It won't be
someone else's data you're corrupting, if you succeed in writing to the
memory without a memory protection fault, it'll probably be a buffer in
the implementation, and the data you write could well get stomped on
when more comes in.
Doug
--
Doug Wyatt
work: email@hidden (CoreAudio)
personal: email@hidden
http://www.sonosphere.com
_______________________________________________
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.