if (audioDescription.getVersion() == 2) {
Memory soundDescriptionHandle = new Memory(Pointer.SIZE);
soundDescriptionHandle.setInt(0, QTObject.ID
(audioDescription));
This is what PointerByReference does (auto-allocates memory to hold a
pointer). So your method being called wants an *initialized* handle,
I guess.
Yes. The Handle should be a pointer to a pointer to a reallocatable piece of
memory (struct). I guess this is how Quicktime tries to be quick, by
allocating enough memory for the smallest structure a call can expect, then
reallocating it if necessary. PointerByReference doesn't drill down deep
enough. It does not allow us to alloc the memory down through the Handle
which would be realloced by the QT API call. So realloc on this address
would (and does) fail.
Remind me why you can't define the full structure?
I can, I was just in Java mode, not wanting code duplication or have to jump
through the odd hoop! Java Developer laziness I guess. I do feel I need to
get dirty and do more native work again.
You *could*, but you're basically using OO to map one instance of a
typecast, ignoring that there might be several alternate typecasts
that are equally applicable. I chose not to explicitly support
subclassing structs, because you can't do it in C so it's not clear
what the behavior should be in Java. What might be convenient for
one case might be rather annoying in another.
If the C structure defines nested structures, so should the Java
definition.
Personally I would like it more Java-like on the Java end, but I take your
point. Also, as you do far more native coding than me, you are more familiar
with the different behaviours. It's not like it's difficult to use, just
playing with things, seeing if they can be any easier.
Cheers,
Paul.