mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-01 13:08:49 +00:00
androidmedia: First try to get symbols from the current program, then load libdvm
If the application is using the new ART runtime it will otherwise load dalvik and start a dalvik VM next to the ART VM. Does not work very well obviously.
This commit is contained in:
parent
22c0464aa6
commit
158caf952d
1 changed files with 32 additions and 17 deletions
|
@ -151,11 +151,9 @@ gst_amc_get_jni_env (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
initialize_java_vm (void)
|
load_java_module (const gchar * name)
|
||||||
{
|
{
|
||||||
jsize n_vms;
|
java_module = g_module_open (name, G_MODULE_BIND_LOCAL);
|
||||||
|
|
||||||
java_module = g_module_open ("libdvm", G_MODULE_BIND_LOCAL);
|
|
||||||
if (!java_module)
|
if (!java_module)
|
||||||
goto load_failed;
|
goto load_failed;
|
||||||
|
|
||||||
|
@ -167,6 +165,34 @@ initialize_java_vm (void)
|
||||||
(gpointer *) & get_created_java_vms))
|
(gpointer *) & get_created_java_vms))
|
||||||
goto symbol_error;
|
goto symbol_error;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
load_failed:
|
||||||
|
{
|
||||||
|
GST_ERROR ("Failed to load Java module '%s': %s", GST_STR_NULL (name),
|
||||||
|
g_module_error ());
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
symbol_error:
|
||||||
|
{
|
||||||
|
GST_ERROR ("Failed to locate required JNI symbols in '%s': %s",
|
||||||
|
GST_STR_NULL (name), g_module_error ());
|
||||||
|
g_module_close (java_module);
|
||||||
|
java_module = NULL;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
initialize_java_vm (void)
|
||||||
|
{
|
||||||
|
jsize n_vms;
|
||||||
|
|
||||||
|
if (!load_java_module (NULL)) {
|
||||||
|
if (!load_java_module ("libdvm"))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
n_vms = 0;
|
n_vms = 0;
|
||||||
if (get_created_java_vms (&java_vm, 1, &n_vms) < 0)
|
if (get_created_java_vms (&java_vm, 1, &n_vms) < 0)
|
||||||
goto get_created_failed;
|
goto get_created_failed;
|
||||||
|
@ -178,6 +204,8 @@ initialize_java_vm (void)
|
||||||
JavaVMInitArgs vm_args;
|
JavaVMInitArgs vm_args;
|
||||||
JavaVMOption options[4];
|
JavaVMOption options[4];
|
||||||
|
|
||||||
|
GST_DEBUG ("Found no existing Java VM, trying to start one");
|
||||||
|
|
||||||
options[0].optionString = "-verbose:jni";
|
options[0].optionString = "-verbose:jni";
|
||||||
options[1].optionString = "-verbose:gc";
|
options[1].optionString = "-verbose:gc";
|
||||||
options[2].optionString = "-Xcheck:jni";
|
options[2].optionString = "-Xcheck:jni";
|
||||||
|
@ -196,19 +224,6 @@ initialize_java_vm (void)
|
||||||
|
|
||||||
return java_vm != NULL;
|
return java_vm != NULL;
|
||||||
|
|
||||||
load_failed:
|
|
||||||
{
|
|
||||||
GST_ERROR ("Failed to load libdvm: %s", g_module_error ());
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
symbol_error:
|
|
||||||
{
|
|
||||||
GST_ERROR ("Failed to locate required JNI symbols in libdvm: %s",
|
|
||||||
g_module_error ());
|
|
||||||
g_module_close (java_module);
|
|
||||||
java_module = NULL;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
get_created_failed:
|
get_created_failed:
|
||||||
{
|
{
|
||||||
GST_ERROR ("Failed to get already created VMs");
|
GST_ERROR ("Failed to get already created VMs");
|
||||||
|
|
Loading…
Reference in a new issue