[Android] Media: refactor FDObject_GetInt

Thomas Guillem git at videolan.org
Fri Aug 24 10:48:30 CEST 2018


vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Aug 24 09:19:46 2018 +0200| [7d9ad8785537de95f976cf617e89c2a60319ec35] | committer: Thomas Guillem

Media: refactor FDObject_GetInt

> https://code.videolan.org/videolan/vlc-android/commit/7d9ad8785537de95f976cf617e89c2a60319ec35
---

 libvlc/jni/libvlcjni-media.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/libvlc/jni/libvlcjni-media.c b/libvlc/jni/libvlcjni-media.c
index 8d56d75e5..f15fede05 100644
--- a/libvlc/jni/libvlcjni-media.c
+++ b/libvlc/jni/libvlcjni-media.c
@@ -161,11 +161,9 @@ Java_org_videolan_libvlc_Media_nativeNewFromLocation(JNIEnv *env, jobject thiz,
                           libvlc_media_new_location);
 }
 
-void
-Java_org_videolan_libvlc_Media_nativeNewFromFd(JNIEnv *env, jobject thiz,
-                                               jobject libVlc, jobject jfd)
+static int
+FDObject_getInt(JNIEnv *env, jobject jfd)
 {
-    vlcjni_object *p_obj;
     int fd = (*env)->GetIntField(env, jfd, fields.FileDescriptor.descriptorID);
 
     if ((*env)->ExceptionOccurred(env))
@@ -176,8 +174,19 @@ Java_org_videolan_libvlc_Media_nativeNewFromFd(JNIEnv *env, jobject thiz,
     if (fd == -1)
     {
         throw_Exception(env, VLCJNI_EX_ILLEGAL_ARGUMENT, "fd invalid");
-        return;
+        return -1;
     }
+    return fd;
+}
+
+void
+Java_org_videolan_libvlc_Media_nativeNewFromFd(JNIEnv *env, jobject thiz,
+                                               jobject libVlc, jobject jfd)
+{
+    vlcjni_object *p_obj;
+    int fd = FDObject_getInt(env, jfd);
+    if (fd == -1)
+        return;
 
     p_obj = VLCJniObject_newFromJavaLibVlc(env, thiz, libVlc);
     if (!p_obj)



More information about the Android mailing list