summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2014-05-23 13:24:12 +0200
committerSebastian Dröge <sebastian@centricular.com>2014-05-23 13:25:11 +0200
commit3564605eea4449c67b2c7896a6b368d6582ad4fb (patch)
tree391a5c4fc0a318d7b7c7a5b49f364c0bf8f2b767 /data
parent4be8ea61034efbc21c83193a5fcb423f50d01dd1 (diff)
Handle failures when failed to get cache/file directories on Android more gracefully
And clean up some local references in error cases.
Diffstat (limited to 'data')
-rw-r--r--data/ndk-build/gstreamer_android-1.0.c.in43
1 files changed, 41 insertions, 2 deletions
diff --git a/data/ndk-build/gstreamer_android-1.0.c.in b/data/ndk-build/gstreamer_android-1.0.c.in
index db46e885..af49aa77 100644
--- a/data/ndk-build/gstreamer_android-1.0.c.in
+++ b/data/ndk-build/gstreamer_android-1.0.c.in
@@ -264,29 +264,51 @@ get_application_dirs (JNIEnv * env, jobject context, gchar ** cache_dir,
(*env)->GetMethodID (env, context_class, "getFilesDir",
"()Ljava/io/File;");
if (!get_cache_dir_id || !get_files_dir_id) {
+ (*env)->DeleteLocalRef (env, context_class);
return FALSE;
}
file_class = (*env)->FindClass (env, "java/io/File");
+ if (!file_class) {
+ (*env)->DeleteLocalRef (env, context_class);
+ return FALSE;
+ }
get_absolute_path_id =
(*env)->GetMethodID (env, file_class, "getAbsolutePath",
"()Ljava/lang/String;");
if (!get_absolute_path_id) {
+ (*env)->DeleteLocalRef (env, context_class);
+ (*env)->DeleteLocalRef (env, file_class);
return FALSE;
}
dir = (*env)->CallObjectMethod (env, context, get_cache_dir_id);
if ((*env)->ExceptionCheck (env)) {
+ (*env)->ExceptionDescribe (env);
+ (*env)->ExceptionClear (env);
+ (*env)->DeleteLocalRef (env, context_class);
+ (*env)->DeleteLocalRef (env, file_class);
return FALSE;
}
if (dir) {
abs_path = (*env)->CallObjectMethod (env, dir, get_absolute_path_id);
if ((*env)->ExceptionCheck (env)) {
+ (*env)->ExceptionDescribe (env);
+ (*env)->ExceptionClear (env);
+ (*env)->DeleteLocalRef (env, dir);
+ (*env)->DeleteLocalRef (env, context_class);
+ (*env)->DeleteLocalRef (env, file_class);
return FALSE;
}
abs_path_str = (*env)->GetStringUTFChars (env, abs_path, NULL);
if ((*env)->ExceptionCheck (env)) {
+ (*env)->ExceptionDescribe (env);
+ (*env)->ExceptionClear (env);
+ (*env)->DeleteLocalRef (env, abs_path);
+ (*env)->DeleteLocalRef (env, dir);
+ (*env)->DeleteLocalRef (env, context_class);
+ (*env)->DeleteLocalRef (env, file_class);
return FALSE;
}
*cache_dir = abs_path ? g_strdup (abs_path_str) : NULL;
@@ -298,15 +320,30 @@ get_application_dirs (JNIEnv * env, jobject context, gchar ** cache_dir,
dir = (*env)->CallObjectMethod (env, context, get_files_dir_id);
if ((*env)->ExceptionCheck (env)) {
+ (*env)->ExceptionDescribe (env);
+ (*env)->ExceptionClear (env);
+ (*env)->DeleteLocalRef (env, context_class);
+ (*env)->DeleteLocalRef (env, file_class);
return FALSE;
}
if (dir) {
abs_path = (*env)->CallObjectMethod (env, dir, get_absolute_path_id);
if ((*env)->ExceptionCheck (env)) {
+ (*env)->ExceptionDescribe (env);
+ (*env)->ExceptionClear (env);
+ (*env)->DeleteLocalRef (env, dir);
+ (*env)->DeleteLocalRef (env, context_class);
+ (*env)->DeleteLocalRef (env, file_class);
return FALSE;
}
abs_path_str = (*env)->GetStringUTFChars (env, abs_path, NULL);
if ((*env)->ExceptionCheck (env)) {
+ (*env)->ExceptionDescribe (env);
+ (*env)->ExceptionClear (env);
+ (*env)->DeleteLocalRef (env, abs_path);
+ (*env)->DeleteLocalRef (env, dir);
+ (*env)->DeleteLocalRef (env, context_class);
+ (*env)->DeleteLocalRef (env, file_class);
return FALSE;
}
*files_dir = files_dir ? g_strdup (abs_path_str) : NULL;
@@ -336,8 +373,10 @@ gst_android_init (JNIEnv * env, jclass klass, jobject context)
return;
}
- if (!get_application_dirs (env, context, &cache_dir, &files_dir))
- return;
+ if (!get_application_dirs (env, context, &cache_dir, &files_dir)) {
+ __android_log_print (ANDROID_LOG_ERROR, "GStreamer",
+ "Failed to get application dirs");
+ }
if (cache_dir) {
g_setenv ("TMP", cache_dir, TRUE);