From 7fb0fafed2a5f2c48ad183683a8aa39e2b61d4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 28 Mar 2015 15:48:28 +0100 Subject: amc: Allow creating global and local references of objects --- sys/androidmedia/gstjniutils.c | 31 ++++++++++++++++++++----------- sys/androidmedia/gstjniutils.h | 3 +++ 2 files changed, 23 insertions(+), 11 deletions(-) (limited to 'sys') diff --git a/sys/androidmedia/gstjniutils.c b/sys/androidmedia/gstjniutils.c index 3f32dc364..02bc3a821 100644 --- a/sys/androidmedia/gstjniutils.c +++ b/sys/androidmedia/gstjniutils.c @@ -128,8 +128,8 @@ gst_amc_jni_get_static_field_id (JNIEnv * env, GError ** err, jclass klass, } jobject -gst_amc_jni_new_object (JNIEnv * env, GError ** err, jclass klass, - jmethodID constructor, ...) +gst_amc_jni_new_object (JNIEnv * env, GError ** err, gboolean global, + jclass klass, jmethodID constructor, ...) { jobject tmp; va_list args; @@ -144,12 +144,15 @@ gst_amc_jni_new_object (JNIEnv * env, GError ** err, jclass klass, return NULL; } - return gst_amc_jni_object_make_global (env, tmp); + if (global) + return gst_amc_jni_object_make_global (env, tmp); + else + return tmp; } jobject -gst_amc_jni_new_object_from_static (JNIEnv * env, GError ** err, jclass klass, - jmethodID method, ...) +gst_amc_jni_new_object_from_static (JNIEnv * env, GError ** err, + gboolean global, jclass klass, jmethodID method, ...) { jobject tmp; va_list args; @@ -164,7 +167,10 @@ gst_amc_jni_new_object_from_static (JNIEnv * env, GError ** err, jclass klass, return NULL; } - return gst_amc_jni_object_make_global (env, tmp); + if (global) + return gst_amc_jni_object_make_global (env, tmp); + else + return tmp; } jobject @@ -207,18 +213,21 @@ gst_amc_jni_object_local_unref (JNIEnv * env, jobject object) jstring gst_amc_jni_string_from_gchar (JNIEnv * env, GError ** err, - const gchar * string) + gboolean global, const gchar * string) { - jstring ret; + jstring tmp; - ret = (*env)->NewStringUTF (env, string); + tmp = (*env)->NewStringUTF (env, string); if ((*env)->ExceptionCheck (env)) { gst_amc_jni_set_error (env, err, GST_LIBRARY_ERROR, GST_LIBRARY_ERROR_FAILED, "Failed to call Java method"); - ret = NULL; + tmp = NULL; } - return ret; + if (global) + return gst_amc_jni_object_make_global (env, tmp); + else + return tmp; } gchar * diff --git a/sys/androidmedia/gstjniutils.h b/sys/androidmedia/gstjniutils.h index f3736db54..0b25daa7f 100644 --- a/sys/androidmedia/gstjniutils.h +++ b/sys/androidmedia/gstjniutils.h @@ -59,12 +59,14 @@ jfieldID gst_amc_jni_get_static_field_id (JNIEnv * env, jobject gst_amc_jni_new_object (JNIEnv * env, GError ** err, + gboolean global, jclass klass, jmethodID constructor, ...); jobject gst_amc_jni_new_object_from_static (JNIEnv * env, GError ** err, + gboolean global, jclass klass, jmethodID constructor, ...); @@ -87,6 +89,7 @@ gchar *gst_amc_jni_string_to_gchar (JNIEnv * env, jstring gst_amc_jni_string_from_gchar (JNIEnv * env, GError ** error, + gboolean global, const gchar * string); G_GNUC_PRINTF (5, 6) -- cgit v1.2.1