

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
8 messages in net.java.dev.jna.usersRe: [jna-users] getting at a structur...| From | Sent On | Attachments |
|---|---|---|
| Paul Loy | Jan 23, 2008 10:34 am | |
| Timothy Wall | Jan 23, 2008 11:04 am | |
| Paul Loy | Jan 24, 2008 5:29 am | |
| Paul Loy | Jan 24, 2008 5:30 am | |
| Timothy Wall | Jan 24, 2008 5:38 am | |
| Paul Loy | Jan 25, 2008 5:24 am | |
| Timothy Wall | Jan 25, 2008 5:58 am | |
| Paul Loy | Jan 25, 2008 6:50 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] getting at a structure with unknown structure size | Actions... |
|---|---|---|
| From: | Paul Loy (pa...@keteracel.com) | |
| Date: | Jan 24, 2008 5:30:34 am | |
| List: | net.java.dev.jna.users | |
Thanks Tim, I was using PointerByReference, but I now know the problem. As the SampleDescriptionHandle can be a variety of sizes it needs to be a "reallocatable block". Apple's docs for NewHandle specifically says:
"Do not try to manufacture your own handles without this function [NewHandle] by simply assigning the address of a variable of type Handle. The resulting 'fake handle' would not reference a relocatable block and would cause a system crash."
Now, while it doesn't always cause a system crash (in fact very rarely does it for me), it is not able to change this memory (due to it not being relocatable) and so I get garbage results. So I think I'm going to workaround, but just thought I'd let you know in case you can think of a way to handle (no pun intended) this in JNA.
On Jan 23, 2008 7:04 PM, Timothy Wall <twal...@dev.java.net> wrote:
On Jan 23, 2008, at 1:34 PM, Paul Loy wrote:
Hi All,
I am wanting to use the QT native call:
void GetMediaSampleDescription(Media theMedia, long index, SampleDescriptionHandle descH);
Media is basically an int (it's actually a the native pointer for a QTJ object, which we obtain be using the static QTObject.ID(QTObject object))
SampleDescritionHandle is a SampleDescriptionPtr *
SampleDescriptionPtr is a SampleDescription *
and Sample Description is:
struct SampleDescription { long descSize; long dataFormat; long resvd1; short resvd2; short dataRefIndex; }
So, essentially our native call boils down to:
void GetMediaSampleDescription(int mediaObjectId, long index, SampleDescription ** desc);
You're obtaining a pointer here, so you use PointerByReference to get started. From there, you can pass the pointer to your structure ctor and let it figure out its own size by reading from the pointer at the appropriate offsets.
The descSize field tells us the actual size of the structure as this depends upon the media that it is describing. So, at the time this function is called, we have no idea of the size of the structure (or a narrow range of different sized structures based on the media type if we know that).
My question is: How does one map this function in Java with JNA?
--
--------------------------------------------- Paul Loy pa...@keteracel.com http://www.keteracel.com/paul







