

![]() | 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: |
5 messages in net.java.dev.jna.users[jna-users] Using ByReference correctly| From | Sent On | Attachments |
|---|---|---|
| Daniel Thornhill | Dec 15, 2008 5:51 am | |
| Timothy Wall | Dec 15, 2008 6:08 am | |
| Daniel Thornhill | Dec 15, 2008 6:17 am | |
| Daniel Thornhill | Dec 15, 2008 6:20 am | |
| Timothy Wall | Dec 15, 2008 6:37 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: | [jna-users] Using ByReference correctly | Actions... |
|---|---|---|
| From: | Daniel Thornhill (Dani...@validsoft.com) | |
| Date: | Dec 15, 2008 5:51:54 am | |
| List: | net.java.dev.jna.users | |
Hi,
Wondering if you could help me again! I am struggling with accessing a data
structure which should be returned as part of a Callback. I am fairly new to
C++ so...there is a good chance this is me doing something wrong.
Essentially what I am trying to do is connect to an 'Audio Provider' which then
make a Callback to a callback object registered earlier (shown below -
NotifyCallCallbackHandler). The code I do this with is just below.
final DivaIdDescriptorByReference idDescriptor =
new DivaIdDescriptor.DivaIdDescriptorByReference();
idDescriptor.Id[0] = 4;
idDescriptor.Id[1] = 2;
DivaReturnCode returnCode = mapDivaReturnCode(
DivaNativeLibrary.instance.DivaConnectAudioProvider(call.getDivaCallHandle().getValue(),
AUDIO_PROVIDER_NAME,
idDescriptor,
DivaAudioProviderMode.MODE_AUDIO_RECEIVE.getDivaValue()));
When the Callback gets made I am trying to reference the data values I set above
- e.g. idDescriptor.Id[0] = 4 and idDescriptor.Id[1] = 2;. However, these are
always returned as 0 - or a newly initalised array. Am I doing something
incorrectly whereby I cannot initialise the Structre DivaIdDescriptor from the
structure in navtive memory?
All the code I am using (or the relevant bits) are below.
Thanks again for your help.
Cheers, Dan
typedef struct { DWORD IdFormat; unsigned char Id[100]; } DivaIdDescriptor;
public class DivaIdDescriptor extends Structure {
public static class DivaIdDescriptorByReference
extends DivaIdDescriptor implements
Structure.ByReference { }
public int IdFormat; public byte[] Id = new byte[100]; }
DIVA_SERVER_API DWORD DivaConnectAudioProvider ( DivaCallHandle hSDKCall, char* Providername, DivaIdDescriptor* pDeviceId, DivaAPMode WhatToConnect );
public int DivaConnectAudioProvider(Pointer divaCallHandle, String name,
DivaIdDescriptorByReference idDescriptor, int
streamingDirection);
public class NotifyCallCallbackHandler implements DivaNotifyCallCallbackHandler
{
public NotifyCallCallbackHandler() { }
public boolean callback(Pointer audioProviderApplicationHandle, Pointer
inParams, Pointer outParams) {
System.out.println("NotifyCallCallbackHandler.callback():: " +
audioProviderApplicationHandle.hashCode());
DivaNotifyCallInParams tmp = new
DivaNotifyCallInParams(inParams);
Structure[] s = tmp.toArray(1);
DivaNotifyCallInParams tmp1 = (DivaNotifyCallInParams)s[0];
System.out.println("NotifyCallCallbackHandler.callback():: " +
tmp1.Identifier.Id[1]);
return false;
}
}
public class DivaNotifyCallInParams extends Structure { public DivaNotifyCallInParams(Pointer pointer) { super.useMemory(pointer); }
public Pointer hdCall;
public DivaIdDescriptor Identifier;
public DivaSendAudioCallbackHandler pfnSendAudio;
public DivaStopSendAudioCallbackHandler pfnStopSendAudio;
public DivaSetRecordFormatCallbackHandler pfnSetRecordAudio;
public DivaCloseAudioCallbackHandler pfnCloseAudio;
public DivaPassEventCallbackHandler pfnPassEvent; // Reserved, must be
NULL
public DivaSetVolumeCallbackHandler pfnSetVolume;
}
url: www.validsoft.com<http://www.validsoft.com/>
ValidSoft Ltd is a Private Limited Company. ValidSoft Ltd, Castle Buildings, Tara Street, Tullamore, Co Offaly, Ireland. Registration Number: 377068 Registered in Dublin.
The information in this e-mail is confidential and may be legally privileged. It
is intended solely for the addressee(s).
Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, any disclosure, copying, distribution or
any action taken or omitted to be taken in reliance on it, is prohibited and may
be unlawful.
When addressed to our clients any opinions or advice contained in this e-mail
are subject to the terms and conditions expressed in the governing ValidSoft
client terms and conditions.







