[vlc-commits] android_window: refactor and move functions

Thomas Guillem git at videolan.org
Thu Apr 9 17:41:11 CEST 2015


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Apr  8 17:12:47 2015 +0200| [0b83473c64d328779e4db272973c058766cdbd71] | committer: Thomas Guillem

android_window: refactor and move functions

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0b83473c64d328779e4db272973c058766cdbd71
---

 modules/video_output/android/android_window.c |   53 +++++++++++++------------
 1 file changed, 27 insertions(+), 26 deletions(-)

diff --git a/modules/video_output/android/android_window.c b/modules/video_output/android/android_window.c
index 6d4f16a..5d183c0 100644
--- a/modules/video_output/android/android_window.c
+++ b/modules/video_output/android/android_window.c
@@ -327,43 +327,24 @@ static android_window *AndroidWindow_New(vout_display_sys_t *sys,
     return p_window;
 }
 
-static void AndroidWindow_Destroy(vout_display_sys_t *sys,
-                                  android_window *p_window)
-{
-    if (p_window->p_handle_priv)
-        sys->anwp.disconnect(p_window->p_handle_priv);
-    if (p_window->p_handle)
-        sys->anw.winRelease(p_window->p_handle);
-    free(p_window);
-}
-
-static int AndroidWindow_UpdateCrop(vout_display_sys_t *sys,
-                                    android_window *p_window)
-{
-    if (!p_window->p_handle_priv)
-        return -1;
-
-    return sys->anwp.setCrop(p_window->p_handle_priv,
-                             p_window->fmt.i_x_offset,
-                             p_window->fmt.i_y_offset,
-                             p_window->fmt.i_visible_width,
-                             p_window->fmt.i_visible_height);
-}
-
 static int AndroidWindow_SetSurface(vout_display_sys_t *sys,
                                     android_window *p_window,
                                     jobject jsurf)
 {
-    if (p_window->p_handle && jsurf != p_window->jsurf) {
+    if (jsurf != p_window->jsurf) {
         if (p_window->p_handle_priv) {
             sys->anwp.disconnect(p_window->p_handle_priv);
             p_window->p_handle_priv = NULL;
         }
-        sys->anw.winRelease(p_window->p_handle);
-        p_window->p_handle = NULL;
+        if (p_window->p_handle) {
+            sys->anw.winRelease(p_window->p_handle);
+            p_window->p_handle = NULL;
+        }
     }
 
     p_window->jsurf = jsurf;
+    if (!p_window->jsurf )
+        return -1;
     if (!p_window->p_handle && !p_window->b_opaque) {
         JNIEnv *p_env;
 
@@ -377,6 +358,26 @@ static int AndroidWindow_SetSurface(vout_display_sys_t *sys,
     return 0;
 }
 
+static void AndroidWindow_Destroy(vout_display_sys_t *sys,
+                                  android_window *p_window)
+{
+    AndroidWindow_SetSurface(sys, p_window, NULL);
+    free(p_window);
+}
+
+static int AndroidWindow_UpdateCrop(vout_display_sys_t *sys,
+                                    android_window *p_window)
+{
+    if (!p_window->p_handle_priv)
+        return -1;
+
+    return sys->anwp.setCrop(p_window->p_handle_priv,
+                             p_window->fmt.i_x_offset,
+                             p_window->fmt.i_y_offset,
+                             p_window->fmt.i_visible_width,
+                             p_window->fmt.i_visible_height);
+}
+
 static int AndroidWindow_SetupANWP(vout_display_sys_t *sys,
                                    android_window *p_window,
                                    bool b_java_configured)



More information about the vlc-commits mailing list