

![]() | 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: |
12 messages in net.java.dev.jna.usersRe: [jna-users] Structure| From | Sent On | Attachments |
|---|---|---|
| Paul Loy | Jan 10, 2008 8:29 am | .java |
| Paul Loy | Jan 10, 2008 9:31 am | .java |
| Paul Loy | Jan 10, 2008 9:47 am | .java |
| Timothy Wall | Jan 14, 2008 5:08 am | |
| Timothy Wall | Jan 14, 2008 5:23 am | |
| Paul Loy | Jan 14, 2008 5:46 am | |
| Paul Loy | Jan 14, 2008 8:56 am | |
| Paul Loy | Jan 14, 2008 9:21 am | |
| Timothy Wall | Jan 14, 2008 9:57 am | |
| Timothy Wall | Jan 14, 2008 11:32 am | |
| Paul Loy | Jan 15, 2008 2:05 am | |
| Timothy Wall | Jan 15, 2008 5:41 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] Structure | Actions... |
|---|---|---|
| From: | Paul Loy (kete...@gmail.com) | |
| Date: | Jan 15, 2008 2:05:54 am | |
| List: | net.java.dev.jna.users | |
Hi Tim,
the calls I want to make are:
extern OSStatus AudioFormatGetProperty( AudioFormatPropertyID inPropertyID, UInt32 inSpecifierSize, void* inSpecifier, UInt32* ioPropertyDataSize, void* outPropertyData );
OSErr QTSetTrackProperty ( Track inTrack, QTPropertyClass inPropClass, QTPropertyID inPropID, ByteCount inPropValueSize, ConstQTPropertyValuePtr inPropValueAddress );
defined in AudioFormat.h in the QuickTime framework (MacOSX). Below is a native example of use:
AudioChannelLayout* layout = nil; int channels = 4;
UInt32 size = ((size_t) &((AudioChannelLayout *) 0)->mChannelDescriptions[channels]); layout = (AudioChannelLayout*)calloc(size);
(*layout).mChannelLayoutTag = kAudioChannelLayoutTag_UseChannelDescriptions; (*layout).mChannelBitmap = 0; (*layout).mNumberChannelDescriptions = channels;
int i; for (i = 0; i < channels; i++) { if (channelBitmap & (1 << i)) { (*layout).mChannelDescriptions[i].mChannelLabel = (0 == i % 2) ? kAudioChannelLabel_Left : kAudioChannelLabel_Right; } else { (*layout).mChannelDescriptions[i].mChannelLabel = kAudioChannelLabel_Unused; } } // see if this layout can be made into a tag if ((*layout).mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelDescriptions) { UInt32 tag; UInt32 propSize = sizeof(tag); if (noErr == AudioFormatGetProperty( kAudioFormatProperty_TagForChannelLayout, size, layout, &propSize, &tag)) { (*layout).mChannelLayoutTag = tag; } } error = QTSetTrackProperty(track, kQTPropertyClass_Audio,kQTAudioPropertyID_ChannelLayout,size,layout);
I am going to try using the latest drop you committed last night to see if I can do this using Structure or keep using Memory.
Paul.
On Jan 14, 2008 7:32 PM, Timothy Wall <twal...@dev.java.net> wrote:
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.
Paul.
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!
--
--------------------------------------------- Paul Loy pa...@keteracel.com http://www.keteracel.com/paul








.java