exp/audio/al: call log.Fatalf for a dlsym failure.

Change-Id: I197e101f2b93c2aa9dc69cb697afa68a69142783
Reviewed-on: https://go-review.googlesource.com/11537
Reviewed-by: Burcu Dogan <jbd@google.com>
This commit is contained in:
Nigel Tao 2015-06-26 16:08:46 +10:00
parent d1958fa5cf
commit b6ec031d27
1 changed files with 11 additions and 5 deletions

View File

@ -30,11 +30,13 @@ void* al_init(void* vm, void* context) {
case JNI_EDETACHED:
if ((*current_vm)->AttachCurrentThread(current_vm, &env, 0) != 0) {
LOG_FATAL("cannot attach JVM");
return 0;
}
attached = 1;
break;
case JNI_EVERSION:
LOG_FATAL("bad JNI version");
return 0;
}
jclass android_content_Context = (*env)->FindClass(env, "android/content/Context");
@ -47,12 +49,13 @@ void* al_init(void* vm, void* context) {
strlcat(lib_path, "/lib/libopenal.so", sizeof(lib_path));
void* handle = dlopen(lib_path, RTLD_LAZY);
(*env)->ReleaseStringUTFChars(env, package_name, cpackage_name);
if (!handle) {
LOG_FATAL("cannot load libopenal.so");
}
if (attached) {
(*current_vm)->DetachCurrentThread(current_vm);
}
if (!handle) {
LOG_FATAL("cannot load libopenal.so");
return 0;
}
return handle;
}
@ -297,8 +300,11 @@ func fn(fname string) unsafe.Pointer {
name := C.CString(fname)
defer C.free(unsafe.Pointer(name))
// TODO(jbd): Handle dlsym error and panic.
return C.dlsym(alHandle, name)
p := C.dlsym(alHandle, name)
if uintptr(p) == 0 {
log.Fatalf("al: couldn't dlsym %q (alHandle=%p)", fname, alHandle)
}
return p
}
func alEnable(capability int32) {