1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/*
* Created on Saturday, July 10 2010 17:08
*/
package jogamp.openal;
import com.jogamp.common.nio.Buffers;
import com.jogamp.openal.ALCConstants;
import com.jogamp.openal.ALException;
import com.jogamp.openal.ALCdevice;
import com.jogamp.openal.util.ALHelpers;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
/**
* ALC implementation.
* @author Michael Bien
*/
public class ALCImpl extends ALCAbstractImpl {
public boolean aclEnumerationExtIsPresent() {
return alcIsExtensionPresent(null, ALHelpers.ALC_ENUMERATION_EXT);
}
public boolean aclEnumerateAllExtIsPresent() {
return alcIsExtensionPresent(null, ALHelpers.ALC_ENUMERATE_ALL_EXT);
}
public boolean alcIsDoubleNullTerminatedString(final ALCdevice device, final int param) {
return dispatch_alcIsDoubleNullTerminatedString(((device == null) ? null : device.getBuffer()), param);
}
public native boolean dispatch_alcIsDoubleNullTerminatedString(ByteBuffer deviceBuffer, int param);
public String alcGetString(final ALCdevice device, final int param) {
if (alcIsDoubleNullTerminatedString(device, param)) {
throw new ALException("Call alcGetString to get double null terminated string");
}
final ByteBuffer buf = alcGetStringImpl(device, param);
if (buf == null) {
return null;
}
final byte[] res = new byte[buf.capacity()];
buf.get(res);
try {
return new String(res, "US-ASCII");
} catch (final UnsupportedEncodingException e) {
throw new ALException(e);
}
}
/** Entry point (through function pointer) to C language function: <br> <code> const ALCchar * alcGetString(ALCdevice * device, ALCenum param); </code> */
public ByteBuffer alcGetStringImpl(final ALCdevice device, final int param) {
final long __addr_ = getALCProcAddressTable()._addressof_alcGetString;
if (__addr_ == 0) {
throw new UnsupportedOperationException("Method \"alcGetStringImpl\" not available");
}
ByteBuffer _res;
_res = dispatch_alcGetStringImpl1(((device == null) ? null : device.getBuffer()), param, __addr_);
if (_res == null) {
return null;
}
Buffers.nativeOrder(_res);
return _res;
}
private native java.nio.ByteBuffer dispatch_alcGetStringImpl1(ByteBuffer deviceBuffer, int param, long addr);
public String[] alcGetDeviceSpecifiers() {
return alcGetStringAsDoubleNullTerminatedString(null, ALC_DEVICE_SPECIFIER);
}
public String[] alcGetCaptureDeviceSpecifiers() {
return alcGetStringAsDoubleNullTerminatedString(null, ALC_CAPTURE_DEVICE_SPECIFIER);
}
public String[] alcGetAllDeviceSpecifiers() {
return alcGetStringAsDoubleNullTerminatedString(null, ALC_ALL_DEVICES_SPECIFIER);
}
public String[] alcGetStringAsDoubleNullTerminatedString(final ALCdevice device, final int param) {
if (!alcIsDoubleNullTerminatedString(device, param)) {
throw new ALException("Call alcGetString to get string");
}
final ByteBuffer buf = alcGetStringImpl(device, param);
if (buf == null) {
return null;
}
final byte[] bytes = new byte[buf.capacity()];
buf.get(bytes);
try {
final ArrayList/*<String>*/ res = new ArrayList/*<String>*/();
int i = 0;
while (i < bytes.length) {
final 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[res.size()]);
} catch (final UnsupportedEncodingException e) {
throw new ALException(e);
}
}
}
|