Skip to content

Commit

Permalink
Bug 1021: OVR GlueGen Mapping: Handle non-existent native oculusvr li…
Browse files Browse the repository at this point in the history
…b gracefully

- query isAvailable() in ovr_Initialize(), ovrHmd_Create(..) and ovrHmd_CreateDebug(..)
  and return appropriate values.
  • Loading branch information
sgothel committed Jun 25, 2014
1 parent 008b351 commit 08649ae
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
4 changes: 4 additions & 0 deletions make/config/oculusvr/oculusvr-common.cfg
Expand Up @@ -42,6 +42,10 @@ ReturnedArrayLength ovrDistortionMesh.pIndexData getIndexCount()
ReturnValueCapacity ovrHmd_Create sizeof(ovrHmd)
ReturnValueCapacity ovrHmd_CreateDebug sizeof(ovrHmd)

JavaPrologue ovr_Initialize if( !isAvailable() ) { return false; }
JavaPrologue ovrHmd_Create if( !isAvailable() ) { return null; }
JavaPrologue ovrHmd_CreateDebug if( !isAvailable() ) { return null; }

ArgumentIsString ovrHmd_GetFloat 1
ArgumentIsString ovrHmd_SetFloat 1
ArgumentIsString ovrHmd_GetFloatArray 1
Expand Down
51 changes: 31 additions & 20 deletions make/config/oculusvr/oculusvr-ovr-CustomJavaCode.java
@@ -1,22 +1,33 @@

static {
AccessController.doPrivileged(new PrivilegedAction<DynamicLibraryBundle>() {
public DynamicLibraryBundle run() {
final DynamicLibraryBundle bundle = new DynamicLibraryBundle(new OVRDynamicLibraryBundleInfo());
if(null==bundle) {
throw new RuntimeException("Null DynamicLibraryBundle");
}
/** No native tool library to load
if(!bundle.isToolLibLoaded()) {
throw new RuntimeException("Couln't load native OVR library");
} */
if(!bundle.isLibComplete()) {
throw new RuntimeException("Couln't load native OVR/JNI glue library");
}
if( !initializeImpl() ) {
throw new RuntimeException("Initialization failure");
}
return bundle;
} } );
}
static final DynamicLibraryBundle dynamicLookupHelper;

static {
dynamicLookupHelper = AccessController.doPrivileged(new PrivilegedAction<DynamicLibraryBundle>() {
public DynamicLibraryBundle run() {
final DynamicLibraryBundle bundle = new DynamicLibraryBundle(new OVRDynamicLibraryBundleInfo());
if(null==bundle) {
throw new RuntimeException("Null DynamicLibraryBundle");
}
/** No native tool library to load
if(!bundle.isToolLibLoaded()) {
System.err.println("Couln't load native OVR/JNI glue library");
return null;
} */
if(!bundle.isLibComplete()) {
System.err.println("Couln't load native OVR/JNI glue library");
return null;
}
if( !initializeImpl() ) {
System.err.println("Native initialization failure of OVR/JNI glue library");
return null;
}
return bundle;
} } );
}

/**
* Accessor.
* @returns true if OVR library is available on this machine.
*/
public static boolean isAvailable() { return dynamicLookupHelper != null; }

0 comments on commit 08649ae

Please sign in to comment.