What OSX headers hold the TrackProperty and ChannelDescription
definitions?
On Jan 14, 2008, at 11:56 AM, Paul Loy wrote:
Hi Tim,
I built the latest code from SVN and this allows me to call
TrackProperty.size() without a NPE if both the TrackProperty and
ChannelDescription are ByReference.
By calling TrackProperty.size(), for 2 channels I get 12 when the
actual size of this struct is 36 (2xChannelDescription+4). This makes
the native call fail. If I botch it and send the 'correct' size, the
call passes, although I guess I can't be sure it's writing to the
correct memory. If I set ChannelDescription to be ByValue, I get a
"Cannot inline ChannelDescription" exception.
Nested structures are by value by default, as are nested structure
arrays. Your struct def should look something like this:
public class TrackProperty extends Structure {
public ChannelDescription[] channels = new ChannelDescription[1];
public TrackProperty(int count) {
// only required if you need to tweak the structures before a call;
otherwise
// the array elements are auto-generated
channels = (ChannelDescription[])new ChannelDescription().toArray
(count);
}
}
I think the .toArray version may fail, since the array's memory is
not properly synched to the enclosing struct's memory.
So I think that we need a way to inline the memory for the
ChannelDescriptions inside the TrackProperty as this is what the
Native API is expecting.
PS: I think JNA is great BTW. I've been using it for a couple of
months now, and for everything up to this point it has worked
perfectly first-time. JNA has drastically simplified our build and
enables us to try things out much much more quickly. Thank you!
Thanks for the feedback!