Fixed Brian's bugs
This commit is contained in:
parent
5ac3ea26e8
commit
f08389fdd2
|
@ -74,38 +74,36 @@ public abstract class BaseAL {
|
||||||
*/
|
*/
|
||||||
public void create() throws Exception {
|
public void create() throws Exception {
|
||||||
if (created) {
|
if (created) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// need to pass path of possible locations of OAL to native side
|
||||||
// need to pass path of possible locations of OAL to native side
|
String libpath = System.getProperty("java.library.path");
|
||||||
String libpath = System.getProperty("java.library.path");
|
String seperator = System.getProperty("path.separator");
|
||||||
String seperator = System.getProperty("path.separator");
|
String libname;
|
||||||
String libname;
|
|
||||||
|
// libname is hardcoded atm - this will change in a near future...
|
||||||
// libname is hardcoded atm - this will change in a near future...
|
libname = (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1)
|
||||||
libname = (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1)
|
? "libopenal.so"
|
||||||
? "libopenal.so"
|
: "OpenAL32.dll";
|
||||||
: "OpenAL32.dll";
|
|
||||||
|
StringTokenizer st = new StringTokenizer(libpath, seperator);
|
||||||
StringTokenizer st = new StringTokenizer(libpath, seperator);
|
|
||||||
|
//create needed string array
|
||||||
//create needed string array
|
String[] oalPaths = new String[st.countTokens()+1];
|
||||||
String[] oalPaths = new String[st.countTokens()+1];
|
|
||||||
|
//build paths
|
||||||
//build paths
|
for(int i=0;i<oalPaths.length - 1;i++) {
|
||||||
for(int i=0;i<st.countTokens();i++) {
|
oalPaths[i] = st.nextToken() + File.separator + libname;
|
||||||
oalPaths[i] = st.nextToken() + File.separator + libname;
|
}
|
||||||
}
|
|
||||||
|
//add cwd path
|
||||||
//add cwd path
|
oalPaths[oalPaths.length-1] = libname;
|
||||||
oalPaths[oalPaths.length-1] = libname;
|
|
||||||
|
|
||||||
if (!nCreate(oalPaths)) {
|
if (!nCreate(oalPaths)) {
|
||||||
throw new Exception("AL instance could not be created.");
|
throw new Exception("AL instance could not be created.");
|
||||||
}
|
}
|
||||||
created = true;
|
created = true;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,4 +128,4 @@ public abstract class BaseAL {
|
||||||
* Native method the destroy the AL
|
* Native method the destroy the AL
|
||||||
*/
|
*/
|
||||||
protected native void nDestroy();
|
protected native void nDestroy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,6 +298,10 @@ public class ALTest extends BasicTest {
|
||||||
// Initialize Open AL manually
|
// Initialize Open AL manually
|
||||||
//Open device
|
//Open device
|
||||||
device = alc.openDevice(null);
|
device = alc.openDevice(null);
|
||||||
|
if (device == null) {
|
||||||
|
System.out.println("Could not create ALC device");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
//Create context(s)
|
//Create context(s)
|
||||||
context = alc.createContext(device, 0);
|
context = alc.createContext(device, 0);
|
||||||
//Set active context
|
//Set active context
|
||||||
|
|
|
@ -168,30 +168,26 @@ void LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
printf("Found %d OpenAL paths\n", pathcount);
|
printf("Found %d OpenAL paths\n", pathcount);
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WIN32
|
|
||||||
for(int i=0;i<pathcount;i++) {
|
for(int i=0;i<pathcount;i++) {
|
||||||
jstring path = (jstring) env->GetObjectArrayElement(oalPaths, i);
|
jstring path = (jstring) env->GetObjectArrayElement(oalPaths, i);
|
||||||
|
const char *path_str = env->GetStringUTFChars(path, NULL);
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
printf("Testing '%s'\n", env->GetStringUTFChars(path, NULL));
|
printf("Testing '%s'\n", path_str);
|
||||||
#endif
|
#endif
|
||||||
handleOAL = LoadLibrary(env->GetStringUTFChars(path, NULL));
|
#ifdef _WIN32
|
||||||
if (handleOAL != NULL) {
|
handleOAL = LoadLibrary(path_str);
|
||||||
#ifdef _DEBUG
|
|
||||||
printf("Found OpenAL at '%s'\n", env->GetStringUTFChars(path, NULL));
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef _X11
|
#ifdef _X11
|
||||||
for(int i=0;i<pathcount;i++) {
|
handleOAL = dlopen(path_str, RTLD_LAZY);
|
||||||
jstring path = (jstring) env->GetObjectArrayElement(oalPaths, i);
|
#endif
|
||||||
handleOAL = dlopen(env->GetStringUTFChars(path, NULL), RTLD_LAZY);
|
|
||||||
if (handleOAL != NULL) {
|
if (handleOAL != NULL) {
|
||||||
|
#ifdef _DEBUG
|
||||||
|
printf("Found OpenAL at '%s'\n", path_str);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
env->ReleaseStringUTFChars(path, path_str);
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -199,10 +195,10 @@ void LoadOpenAL(JNIEnv *env, jobjectArray oalPaths) {
|
||||||
*/
|
*/
|
||||||
void UnLoadOpenAL() {
|
void UnLoadOpenAL() {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
//FreeLibrary(handleOAL);
|
FreeLibrary(handleOAL);
|
||||||
#endif
|
#endif
|
||||||
#ifdef _X11
|
#ifdef _X11
|
||||||
dlclose(handleOAL);
|
dlclose(handleOAL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -387,4 +387,4 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_openal_ALC_getEnumValue (JNIEnv *env, jobj
|
||||||
|
|
||||||
CHECK_ALC_ERROR
|
CHECK_ALC_ERROR
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue