From 4d2382fb27378bfaec938f5c747fe68500f5c499 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Thu, 31 Aug 2017 18:56:37 +1000 Subject: [PATCH] amc: actually use the provided application class loader For the camera and sensor Fixes a couple of ClassNotFound java exceptions when initializing GStreamer off the main thread. --- sys/androidmedia/gst-android-hardware-camera.c | 4 ++-- sys/androidmedia/gst-android-hardware-sensor.c | 4 ++-- sys/androidmedia/gstjniutils.c | 9 ++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sys/androidmedia/gst-android-hardware-camera.c b/sys/androidmedia/gst-android-hardware-camera.c index aa574bd2be..639e0240f1 100644 --- a/sys/androidmedia/gst-android-hardware-camera.c +++ b/sys/androidmedia/gst-android-hardware-camera.c @@ -1590,8 +1590,8 @@ _init_classes (void) if (!org_freedesktop_gstreamer_androidmedia_gstahccallback.klass) { org_freedesktop_gstreamer_androidmedia_gstahccallback.klass = - gst_amc_jni_get_class (env, &err, - "org/freedesktop/gstreamer/androidmedia/GstAhcCallback"); + gst_amc_jni_get_application_class (env, + "org/freedesktop/gstreamer/androidmedia/GstAhcCallback", &err); } if (!org_freedesktop_gstreamer_androidmedia_gstahccallback.klass) goto failed; diff --git a/sys/androidmedia/gst-android-hardware-sensor.c b/sys/androidmedia/gst-android-hardware-sensor.c index d4fd71caf1..d5a68b5475 100644 --- a/sys/androidmedia/gst-android-hardware-sensor.c +++ b/sys/androidmedia/gst-android-hardware-sensor.c @@ -569,8 +569,8 @@ _init_classes (void) /* org.freedesktop.gstreamer.androidmedia.GstAhsCallback */ if (!org_freedesktop_gstreamer_androidmedia_gstahscallback.klass) { org_freedesktop_gstreamer_androidmedia_gstahscallback.klass = - gst_amc_jni_get_class (env, &err, - "org/freedesktop/gstreamer/androidmedia/GstAhsCallback"); + gst_amc_jni_get_application_class (env, + "org/freedesktop/gstreamer/androidmedia/GstAhsCallback", &err); } if (!org_freedesktop_gstreamer_androidmedia_gstahscallback.klass) goto failed; diff --git a/sys/androidmedia/gstjniutils.c b/sys/androidmedia/gstjniutils.c index a5b8e0d721..0f2efc2d40 100644 --- a/sys/androidmedia/gstjniutils.c +++ b/sys/androidmedia/gstjniutils.c @@ -869,6 +869,13 @@ gst_amc_jni_get_application_class (JNIEnv * env, const gchar * name, jclass class_loader_cls = NULL; jmethodID load_class_id = 0; + GST_LOG ("attempting to retrieve class %s", name); + + if (!get_class_loader) { + g_set_error (err, GST_LIBRARY_ERROR, GST_LIBRARY_ERROR_FAILED, + "Could not retreive application class loader function"); + goto done; + } class_loader = get_class_loader (); if (!class_loader) { @@ -887,7 +894,7 @@ gst_amc_jni_get_application_class (JNIEnv * env, const gchar * name, load_class_id = gst_amc_jni_get_method_id (env, err, class_loader_cls, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;"); - if (!class_loader_cls) { + if (!load_class_id) { goto done; } -- 2.34.1