diff options
author | kbr <[email protected]> | 2006-02-20 01:34:37 +0000 |
---|---|---|
committer | kbr <[email protected]> | 2006-02-20 01:34:37 +0000 |
commit | 68a842cc62f12e6372c804708690e31169368c30 (patch) | |
tree | bfe6c1310f5caa115251964d6b0ee2a53852cbba /make/joal-alc-impl-CustomJavaCode.java | |
parent | 48e6e34ebc8747ef80a4c74c18679f027a8172f0 (diff) |
Added alcGetDeviceSpecifiers to support alcGetString(null, ALC_DEVICE_SPECIFIER);
rewrote alcGetString to use same underlying routine
git-svn-id: file:///home/mbien/NetBeansProjects/JOGAMP/joal-sync/git-svn/../svn-server-sync/joal/trunk@113 03bf7f67-59de-4072-a415-9a990d468a3f
Diffstat (limited to 'make/joal-alc-impl-CustomJavaCode.java')
-rwxr-xr-x | make/joal-alc-impl-CustomJavaCode.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/make/joal-alc-impl-CustomJavaCode.java b/make/joal-alc-impl-CustomJavaCode.java new file mode 100755 index 0000000..a2f23c9 --- /dev/null +++ b/make/joal-alc-impl-CustomJavaCode.java @@ -0,0 +1,42 @@ +public java.lang.String alcGetString(ALCdevice device, int param) { + if (device == null && param == ALC_DEVICE_SPECIFIER) { + throw new ALException("Call alcGetDeviceSpecifiers to fetch all available device names"); + } + + ByteBuffer buf = alcGetStringImpl(device, param); + if (buf == null) { + return null; + } + byte[] res = new byte[buf.capacity()]; + buf.get(res); + try { + return new String(res, "US-ASCII"); + } catch (UnsupportedEncodingException e) { + throw new ALException(e); + } +} + +/** Fetches the names of the available ALC device specifiers. + Equivalent to the C call alcGetString(NULL, ALC_DEVICE_SPECIFIER). */ +public java.lang.String[] alcGetDeviceSpecifiers() { + ByteBuffer buf = alcGetStringImpl(null, ALC_DEVICE_SPECIFIER); + if (buf == null) { + return null; + } + byte[] bytes = new byte[buf.capacity()]; + buf.get(bytes); + try { + ArrayList/*<String>*/ res = new ArrayList/*<String>*/(); + int i = 0; + while (i < bytes.length) { + int startIndex = i; + while ((i < bytes.length) && (bytes[i] != 0)) + i++; + res.add(new String(bytes, startIndex, i - startIndex, "US-ASCII")); + i++; + } + return (String[]) res.toArray(new String[0]); + } catch (UnsupportedEncodingException e) { + throw new ALException(e); + } +} |