Hi all,
I am new to JNA and I'm not c++ guru. These days I'm trying to use
dsound on windows (dsound.dll) from JNA but I have problems start
mapping the functions from it.
Can you give me some starting point, starting examples here are the
parts from the header file I'm wondering how to map and use
extern HRESULT WINAPI DirectSoundCreate(LPCGUID pcGuidDevice,
LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter);
struct IDirectSound;
DEFINE_GUID(IID_IDirectSound, 0x279AFA83, 0x4981, 0x11CE, 0xA5, 0x21,
0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
#define INTERFACE IDirectSound
DECLARE_INTERFACE_(IDirectSound, IUnknown)
{
...........
STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE;
...........
};
typedef struct IDirectSound *LPDIRECTSOUND;
I've made this :
//C++ code
typedef BOOL (CALLBACK *LPDSENUMCALLBACKA)(LPGUID, LPCSTR, LPCSTR, LPVOID);
extern HRESULT WINAPI DirectSoundEnumerateA(LPDSENUMCALLBACKA
pDSEnumCallback, LPVOID pContext);
// Java
public static class GUID
extends Structure
{
public long Data1;
public short Data2;
public short Data3;
public byte[] Data4;
public GUID(){
Data4 = new byte[4];
allocateMemory();
}
}
interface DirectSoundEnum extends Callback {
boolean callback(GUID guid, String description, String module,
int index);
}
public void DirectSoundEnumerateA(DirectSoundEnum callback);
I call It and print the params. but after the last call of the
callback there is always
JVM EXCEPTION_ACCESS_VIOLATION.
the stack shows the problem is in dsound.dll. Am I doing something
wrong and missing something ?
Thanks in advance,
damencho