mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:46:13 +00:00
androidmedia: Actively request the Java VM from the application
This is more consistent with how we already request the application class loader and other application resources elsewhere.
This commit is contained in:
parent
e31714691a
commit
eca6c35601
1 changed files with 29 additions and 0 deletions
|
@ -497,6 +497,29 @@ gst_amc_jni_detach_current_thread (void *env)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static JavaVM *
|
||||||
|
get_application_java_vm (void)
|
||||||
|
{
|
||||||
|
GModule *module = NULL;
|
||||||
|
JavaVM *(*get_java_vm) (void);
|
||||||
|
JavaVM *vm = NULL;
|
||||||
|
|
||||||
|
module = g_module_open (NULL, G_MODULE_BIND_LOCAL);
|
||||||
|
|
||||||
|
if (!module) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_module_symbol (module, "gst_android_get_java_vm",
|
||||||
|
(gpointer *) & get_java_vm) && get_java_vm) {
|
||||||
|
vm = get_java_vm ();
|
||||||
|
}
|
||||||
|
|
||||||
|
g_module_close (module);
|
||||||
|
|
||||||
|
return vm;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
check_nativehelper (void)
|
check_nativehelper (void)
|
||||||
{
|
{
|
||||||
|
@ -663,6 +686,12 @@ gst_amc_jni_initialize_java_vm (void)
|
||||||
return initialize_classes ();
|
return initialize_classes ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
java_vm = get_application_java_vm ();
|
||||||
|
if (java_vm) {
|
||||||
|
GST_DEBUG ("Java VM successfully requested from the application");
|
||||||
|
return initialize_classes ();
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns TRUE if we can safely
|
/* Returns TRUE if we can safely
|
||||||
* a) get the current VMs and
|
* a) get the current VMs and
|
||||||
* b) start a VM if none is started yet
|
* b) start a VM if none is started yet
|
||||||
|
|
Loading…
Reference in a new issue