vlc | branch: master | Thomas Guillem <tho...@gllm.fr> | Fri Feb  2 16:57:08 
2018 +0100| [9763dbf8dacae7a80fae8ec899904e68a3425a6f] | committer: Thomas 
Guillem

vout: android: remove ANW private API usage

It's not legal to use it since Android 5.0 and we prefer the gles2 vout.

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

 modules/video_output/android/display.c          | 169 ++--------
 modules/video_output/android/nativewindowpriv.c | 426 ------------------------
 modules/video_output/android/utils.c            |  31 --
 modules/video_output/android/utils.h            |  32 --
 4 files changed, 24 insertions(+), 634 deletions(-)

diff --git a/modules/video_output/android/display.c 
b/modules/video_output/android/display.c
index f7c71b4439..9824a417e8 100644
--- a/modules/video_output/android/display.c
+++ b/modules/video_output/android/display.c
@@ -96,13 +96,11 @@ struct android_window
     unsigned int i_angle;
     unsigned int i_pic_count;
     unsigned int i_min_undequeued;
-    bool b_use_priv;
     bool b_opaque;
 
     enum AWindow_ID id;
     ANativeWindow *p_surface;
     jobject       *p_jsurface;
-    native_window_priv *p_surface_priv;
 };
 
 typedef struct buffer_bounds buffer_bounds;
@@ -122,8 +120,6 @@ struct vout_display_sys_t
 
     AWindowHandler *p_awh;
     native_window_api_t *anw;
-    native_window_priv_api_t anwp;
-    bool b_has_anwp;
 
     android_window *p_window;
     android_window *p_sub_window;
@@ -160,8 +156,7 @@ static inline int ChromaToAndroidHal(vlc_fourcc_t i_chroma)
     }
 }
 
-static int UpdateVideoSize(vout_display_sys_t *sys, video_format_t *p_fmt,
-                           bool b_cropped)
+static int UpdateVideoSize(vout_display_sys_t *sys, video_format_t *p_fmt)
 {
     unsigned int i_width, i_height;
     unsigned int i_sar_num = 1, i_sar_den = 1;
@@ -173,13 +168,8 @@ static int UpdateVideoSize(vout_display_sys_t *sys, 
video_format_t *p_fmt,
         i_sar_num = rot_fmt.i_sar_num;
         i_sar_den = rot_fmt.i_sar_den;
     }
-    if (b_cropped) {
-        i_width = rot_fmt.i_visible_width;
-        i_height = rot_fmt.i_visible_height;
-    } else {
-        i_width = rot_fmt.i_width;
-        i_height = rot_fmt.i_height;
-    }
+    i_width = rot_fmt.i_width;
+    i_height = rot_fmt.i_height;
 
     AWindowHandler_setVideoLayout(sys->p_awh, i_width, i_height,
                                   rot_fmt.i_visible_width,
@@ -323,10 +313,6 @@ static void SetupPictureYV12(picture_t *p_picture, 
uint32_t i_in_stride)
 static void AndroidWindow_DisconnectSurface(vout_display_sys_t *sys,
                                             android_window *p_window)
 {
-    if (p_window->p_surface_priv) {
-        sys->anwp.disconnect(p_window->p_surface_priv);
-        p_window->p_surface_priv = NULL;
-    }
     if (p_window->p_surface) {
         AWindowHandler_releaseANativeWindow(sys->p_awh, p_window->id);
         p_window->p_surface = NULL;
@@ -351,8 +337,7 @@ static int AndroidWindow_ConnectSurface(vout_display_sys_t 
*sys,
 
 static android_window *AndroidWindow_New(vout_display_t *vd,
                                          video_format_t *p_fmt,
-                                         enum AWindow_ID id,
-                                         bool b_use_priv)
+                                         enum AWindow_ID id)
 {
     vout_display_sys_t *sys = vd->sys;
     android_window *p_window = NULL;
@@ -364,8 +349,6 @@ static android_window *AndroidWindow_New(vout_display_t *vd,
     p_window->id = id;
     p_window->b_opaque = p_fmt->i_chroma == VLC_CODEC_ANDROID_OPAQUE;
     if (!p_window->b_opaque) {
-        p_window->b_use_priv = sys->b_has_anwp && b_use_priv;
-
         p_window->i_android_hal = ChromaToAndroidHal(p_fmt->i_chroma);
         if (p_window->i_android_hal == -1)
             goto error;
@@ -385,10 +368,7 @@ static android_window *AndroidWindow_New(vout_display_t 
*vd,
         default:
             p_window->i_angle = 0;
     }
-    if (p_window->b_use_priv)
-        p_window->fmt = *p_fmt;
-    else
-        video_format_ApplyRotation(&p_window->fmt, p_fmt);
+    video_format_ApplyRotation(&p_window->fmt, p_fmt);
     p_window->i_pic_count = 1;
 
     if (AndroidWindow_ConnectSurface(sys, p_window) != 0)
@@ -413,73 +393,6 @@ static void AndroidWindow_Destroy(vout_display_t *vd,
     free(p_window);
 }
 
-static int AndroidWindow_UpdateCrop(vout_display_sys_t *sys,
-                                    android_window *p_window)
-{
-    if (!p_window->p_surface_priv)
-        return -1;
-
-    return sys->anwp.setCrop(p_window->p_surface_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)
-{
-    unsigned int i_max_buffer_count = 0;
-
-    if (!p_window->p_surface_priv)
-        p_window->p_surface_priv = sys->anwp.connect(p_window->p_surface);
-
-    if (!p_window->p_surface_priv)
-        goto error;
-
-    if (sys->anwp.setUsage(p_window->p_surface_priv, false, 0) != 0)
-        goto error;
-
-    if (!b_java_configured
-        && sys->anwp.setBuffersGeometry(p_window->p_surface_priv,
-                                        p_window->fmt.i_width,
-                                        p_window->fmt.i_height,
-                                        p_window->i_android_hal) != 0)
-        goto error;
-
-    sys->anwp.getMinUndequeued(p_window->p_surface_priv,
-                               &p_window->i_min_undequeued);
-
-    sys->anwp.getMaxBufferCount(p_window->p_surface_priv, &i_max_buffer_count);
-
-    if ((p_window->i_min_undequeued + p_window->i_pic_count) >
-         i_max_buffer_count)
-        p_window->i_pic_count = i_max_buffer_count - 
p_window->i_min_undequeued;
-
-    if (sys->anwp.setBufferCount(p_window->p_surface_priv,
-                                 p_window->i_pic_count +
-                                 p_window->i_min_undequeued) != 0)
-        goto error;
-
-    if (sys->anwp.setOrientation(p_window->p_surface_priv,
-                                 p_window->i_angle) != 0)
-        goto error;
-
-    AndroidWindow_UpdateCrop(sys, p_window);
-
-    return 0;
-error:
-    if (p_window->p_surface_priv) {
-        sys->anwp.disconnect(p_window->p_surface_priv);
-        p_window->p_surface_priv = NULL;
-    }
-    p_window->b_use_priv = false;
-    if (p_window->i_angle != 0)
-        video_format_TransformTo(&p_window->fmt, ORIENT_NORMAL);
-    return -1;
-}
-
 static int AndroidWindow_ConfigureJavaSurface(vout_display_sys_t *sys,
                                               android_window *p_window,
                                               bool *p_java_configured)
@@ -544,11 +457,8 @@ static int AndroidWindow_Setup(vout_display_sys_t *sys,
                                                &b_java_configured) != 0)
             return -1;
 
-        if (!p_window->b_use_priv
-            || AndroidWindow_SetupANWP(sys, p_window, b_java_configured) != 0) 
{
-            if (AndroidWindow_SetupANW(sys, p_window, b_java_configured) != 0)
-                return -1;
-        }
+        if (AndroidWindow_SetupANW(sys, p_window, b_java_configured) != 0)
+            return -1;
     } else {
         sys->p_window->i_pic_count = 31; // TODO
         sys->p_window->i_min_undequeued = 0;
@@ -559,21 +469,14 @@ static int AndroidWindow_Setup(vout_display_sys_t *sys,
 
 static void AndroidWindow_UnlockPicture(vout_display_sys_t *sys,
                                         android_window *p_window,
-                                        picture_t *p_pic,
-                                        bool b_render)
+                                        picture_t *p_pic)
 {
     picture_sys_t *p_picsys = p_pic->p_sys;
 
     if (!p_picsys->b_locked)
         return;
 
-    if (p_window->b_use_priv) {
-        void *p_handle = p_picsys->sw.p_handle;
-
-        if (p_handle != NULL)
-            sys->anwp.unlockData(p_window->p_surface_priv, p_handle, b_render);
-    } else
-        sys->anw->unlockAndPost(p_window->p_surface);
+    sys->anw->unlockAndPost(p_window->p_surface);
 
     p_picsys->b_locked = false;
 }
@@ -587,27 +490,17 @@ static int AndroidWindow_LockPicture(vout_display_sys_t 
*sys,
     if (p_picsys->b_locked)
         return -1;
 
-    if (p_window->b_use_priv) {
-        void *p_handle;
-        int err;
+    if (sys->anw->winLock(p_window->p_surface,
+                          &p_picsys->sw.buf, NULL) != 0)
+        return -1;
 
-        err = sys->anwp.lockData(p_window->p_surface_priv,
-                                 &p_handle, &p_picsys->sw.buf);
-        if (err != 0)
-            return -1;
-        p_picsys->sw.p_handle = p_handle;
-    } else {
-        if (sys->anw->winLock(p_window->p_surface,
-                              &p_picsys->sw.buf, NULL) != 0)
-            return -1;
-    }
     if (p_picsys->sw.buf.width < 0 ||
         p_picsys->sw.buf.height < 0 ||
         (unsigned)p_picsys->sw.buf.width < p_window->fmt.i_width ||
         (unsigned)p_picsys->sw.buf.height < p_window->fmt.i_height)
     {
         p_picsys->b_locked = true;
-        AndroidWindow_UnlockPicture(sys, p_window, p_pic, false);
+        AndroidWindow_UnlockPicture(sys, p_window, p_pic);
         return -1;
     }
 
@@ -681,12 +574,6 @@ static int OpenCommon(vout_display_t *vd)
     sys->p_awh = p_awh;
     sys->anw = AWindowHandler_getANativeWindowAPI(sys->p_awh);
 
-#ifdef USE_ANWP
-    sys->b_has_anwp = android_loadNativeWindowPrivApi(&sys->anwp) == 0;
-    if (!sys->b_has_anwp)
-        msg_Warn(vd, "Could not initialize NativeWindow Priv API.");
-#endif
-
     sys->i_display_width = vd->cfg->display.width;
     sys->i_display_height = vd->cfg->display.height;
 
@@ -717,25 +604,24 @@ static int OpenCommon(vout_display_t *vd)
         }
     }
 
-    sys->p_window = AndroidWindow_New(vd, &vd->fmt, AWindow_Video, true);
+    sys->p_window = AndroidWindow_New(vd, &vd->fmt, AWindow_Video);
     if (!sys->p_window)
         goto error;
 
     if (AndroidWindow_Setup(sys, sys->p_window, 0) != 0)
         goto error;
 
-    /* use software rotation if we don't use private anw */
-    if (!sys->p_window->b_opaque && !sys->p_window->b_use_priv)
+    /* use software rotation if we don't do opaque */
+    if (!sys->p_window->b_opaque)
         video_format_TransformTo(&vd->fmt, ORIENT_NORMAL);
 
-    msg_Dbg(vd, "using %s", sys->p_window->b_opaque ? "opaque" :
-            (sys->p_window->b_use_priv ? "ANWP" : "ANW"));
+    msg_Dbg(vd, "using %s", sys->p_window->b_opaque ? "opaque" : "ANW");
 
     video_format_ApplyRotation(&sub_fmt, &vd->fmt);
     sub_fmt.i_chroma = subpicture_chromas[0];
     SetRGBMask(&sub_fmt);
     video_format_FixRgb(&sub_fmt);
-    sys->p_sub_window = AndroidWindow_New(vd, &sub_fmt, AWindow_Subtitles, 
false);
+    sys->p_sub_window = AndroidWindow_New(vd, &sub_fmt, AWindow_Subtitles);
     if (sys->p_sub_window) {
 
         FixSubtitleFormat(sys);
@@ -823,11 +709,6 @@ end:
         android_window *p_window = sys->p_window;
         ANativeWindow_Buffer buf;
 
-        if (p_window->p_surface_priv) {
-            sys->anwp.disconnect(p_window->p_surface_priv);
-            p_window->p_surface_priv = NULL;
-        }
-
         if (sys->anw->setBuffersGeometry(p_window->p_surface, 1, 1,
                                          WINDOW_FORMAT_RGB_565) == 0
           && sys->anw->winLock(p_window->p_surface, &buf, NULL) == 0)
@@ -849,7 +730,7 @@ static void Close(vlc_object_t *p_this)
     if (sys->b_has_subpictures)
     {
         SubpicturePrepare(vd, NULL);
-        AndroidWindow_UnlockPicture(sys, sys->p_sub_window, sys->p_sub_pic, 
true);
+        AndroidWindow_UnlockPicture(sys, sys->p_sub_window, sys->p_sub_pic);
     }
 
     if (sys->pool)
@@ -895,7 +776,7 @@ static void PoolUnlockPicture(picture_t *p_pic)
     picture_sys_t *p_picsys = p_pic->p_sys;
     vout_display_sys_t *sys = p_picsys->sw.p_vd_sys;
 
-    AndroidWindow_UnlockPicture(sys, sys->p_window, p_pic, false);
+    AndroidWindow_UnlockPicture(sys, sys->p_window, p_pic);
 }
 
 static int PoolLockOpaquePicture(picture_t *p_pic)
@@ -927,7 +808,7 @@ static picture_pool_t *PoolAlloc(vout_display_t *vd, 
unsigned requested_count)
     requested_count = sys->p_window->i_pic_count;
     msg_Dbg(vd, "PoolAlloc: got %d frames", requested_count);
 
-    UpdateVideoSize(sys, &sys->p_window->fmt, sys->p_window->b_use_priv);
+    UpdateVideoSize(sys, &sys->p_window->fmt);
 
     pp_pics = calloc(requested_count, sizeof(picture_t));
 
@@ -1162,13 +1043,12 @@ static void Display(vout_display_t *vd, picture_t 
*picture,
     if (sys->p_window->b_opaque)
         AndroidOpaquePicture_Release(picture->p_sys, true);
     else
-        AndroidWindow_UnlockPicture(sys, sys->p_window, picture, true);
+        AndroidWindow_UnlockPicture(sys, sys->p_window, picture);
 
     picture_Release(picture);
 
     if (sys->p_sub_pic)
-        AndroidWindow_UnlockPicture(sys, sys->p_sub_window, sys->p_sub_pic,
-                                    true);
+        AndroidWindow_UnlockPicture(sys, sys->p_sub_window, sys->p_sub_pic);
 
     if (subpicture)
         subpicture_Delete(subpicture);
@@ -1195,11 +1075,10 @@ static int Control(vout_display_t *vd, int query, 
va_list args)
 
         if (query == VOUT_DISPLAY_CHANGE_SOURCE_CROP) {
             video_format_CopyCrop(&sys->p_window->fmt, &vd->source);
-            AndroidWindow_UpdateCrop(sys, sys->p_window);
         } else
             CopySourceAspect(&sys->p_window->fmt, &vd->source);
 
-        UpdateVideoSize(sys, &sys->p_window->fmt, sys->p_window->b_use_priv);
+        UpdateVideoSize(sys, &sys->p_window->fmt);
         FixSubtitleFormat(sys);
         return VLC_SUCCESS;
     }
diff --git a/modules/video_output/android/nativewindowpriv.c 
b/modules/video_output/android/nativewindowpriv.c
deleted file mode 100644
index e035b145b6..0000000000
--- a/modules/video_output/android/nativewindowpriv.c
+++ /dev/null
@@ -1,426 +0,0 @@
-/*****************************************************************************
- * nativewindowpriv.c: Wrapper to android native window private api
- *****************************************************************************
- * Copyright (C) 2011 VLC authors and VideoLAN
- *
- * Authors: Thomas Guillem <guil...@archos.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-/*****************************************************************************
- * Preamble
- *****************************************************************************/
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-
-#include <android/native_window.h>
-
-#define ANDROID_HC_OR_LATER (ANDROID_API >= 11)
-#define ANDROID_ICS_OR_LATER (ANDROID_API >= 14)
-#define ANDROID_JBMR2_OR_LATER (ANDROID_API >= 18)
-
-#if ANDROID_JBMR2_OR_LATER
-/* for waiting for fence_fd returned by dequeueBuffer */
-#include <linux/ioctl.h>
-#include <linux/types.h>
-#define SYNC_IOC_MAGIC '>'
-#define SYNC_IOC_WAIT _IOW(SYNC_IOC_MAGIC, 0, __s32)
-#endif
-
-#if ANDROID_ICS_OR_LATER
-#include <system/window.h>
-#else
-#include <ui/android_native_buffer.h>
-#include <ui/egl/android_natives.h>
-#endif
-
-#include <hardware/gralloc.h>
-
-#include <android/log.h>
-
-#define NO_ERROR 0
-typedef int32_t status_t;
-
-#if !ANDROID_ICS_OR_LATER
-typedef android_native_buffer_t ANativeWindowBuffer_t;
-#endif
-typedef struct native_window_priv native_window_priv;
-
-struct native_window_priv
-{
-    ANativeWindow *anw;
-    gralloc_module_t const* gralloc;
-    int usage;
-};
-
-#define LOG_TAG "VLC/ANW"
-
-#define LOGD(...) __android_log_print( ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__ 
)
-#define LOGE(...) __android_log_print( ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__ 
)
-
-#define CHECK_ERR() do {\
-    if( err != NO_ERROR ) {\
-        LOGE( "error %d in %s  line %d\n", err, __FUNCTION__, __LINE__  );\
-        return err;\
-    }\
-} while (0)
-
-#define CHECK_ANB() do {\
-    if( anb->common.magic != ANDROID_NATIVE_BUFFER_MAGIC &&\
-            anb->common.version != sizeof(ANativeWindowBuffer_t) ) {\
-        LOGE( "error, buffer not valid\n"  );\
-        return -EINVAL;\
-    }\
-} while (0)
-
-static int window_connect( ANativeWindow *anw )
-{
-#if ANDROID_ICS_OR_LATER
-    return native_window_api_connect( anw, NATIVE_WINDOW_API_MEDIA );
-#else
-    return 0;
-#endif
-}
-
-static int window_disconnect( ANativeWindow *anw )
-{
-#if ANDROID_ICS_OR_LATER
-    return native_window_api_disconnect( anw, NATIVE_WINDOW_API_MEDIA );
-#else
-    return 0;
-#endif
-}
-
-native_window_priv *ANativeWindowPriv_connect( void *window )
-{
-    native_window_priv *priv;
-    hw_module_t const* module;
-    ANativeWindow *anw = (ANativeWindow *)window;
-
-    if( anw->common.magic != ANDROID_NATIVE_WINDOW_MAGIC &&
-            anw->common.version != sizeof(ANativeWindow) ) {
-        LOGE( "error, window not valid\n"  );
-        return NULL;
-    }
-
-    if ( hw_get_module( GRALLOC_HARDWARE_MODULE_ID,
-                        &module ) != 0 )
-        return NULL;
-
-    if( window_connect( anw ) != 0 ) {
-        LOGE( "native_window_api_connect FAIL"  );
-        return NULL;
-    }
-
-    priv = calloc( 1, sizeof(native_window_priv) );
-
-    if( !priv ) {
-        window_disconnect( anw );
-        return NULL;
-    }
-    priv->anw = anw;
-    priv->gralloc = (gralloc_module_t const *) module;
-
-    return priv;
-}
-
-int ANativeWindowPriv_disconnect( native_window_priv *priv )
-{
-    window_disconnect( priv->anw );
-    free(priv);
-
-    return 0;
-}
-
-int ANativeWindowPriv_setUsage( native_window_priv *priv,  bool is_hw, int 
hw_usage )
-{
-    status_t err;
-
-    LOGD( "setUsage: %p, %d %X\n", (void *)priv->anw, is_hw, hw_usage );
-
-    if( is_hw )
-    {
-        priv->usage = hw_usage | GRALLOC_USAGE_HW_RENDER | 
GRALLOC_USAGE_HW_TEXTURE;
-#if ANDROID_HC_OR_LATER
-        priv->usage |= GRALLOC_USAGE_EXTERNAL_DISP;
-#endif
-    }
-    else
-        priv->usage = GRALLOC_USAGE_SW_READ_NEVER | 
GRALLOC_USAGE_SW_WRITE_OFTEN;
-
-    err = native_window_set_usage( priv->anw, priv->usage );
-    CHECK_ERR();
-
-    return 0;
-}
-
-int ANativeWindowPriv_setBuffersGeometry( native_window_priv *priv, int w, int 
h, int hal_format )
-{
-    status_t err;
-
-    LOGD( "setBuffersGeometry: %p, %d, %d", (void *)priv->anw, w, h );
-
-#if ANDROID_ICS_OR_LATER
-    err = native_window_set_buffers_format( priv->anw, hal_format );
-    CHECK_ERR();
-
-#if ANDROID_JBMR2_OR_LATER
-    err = native_window_set_buffers_user_dimensions( priv->anw, w, h );
-#else
-    err = native_window_set_buffers_dimensions( priv->anw, w, h );
-#endif
-    CHECK_ERR();
-
-    err = native_window_set_scaling_mode( priv->anw, 
NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW );
-    CHECK_ERR();
-#else
-    err = native_window_set_buffers_geometry( priv->anw, w, h, hal_format );
-    CHECK_ERR();
-#endif
-
-    return 0;
-}
-
-int ANativeWindowPriv_getMinUndequeued( native_window_priv *priv, unsigned int 
*min_undequeued )
-{
-    status_t err;
-
-#if ANDROID_HC_OR_LATER
-    int query;
-    err = priv->anw->query( priv->anw, NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, 
&query );
-    CHECK_ERR();
-    if( query < 0 )
-        return -1;
-    *min_undequeued = query;
-#endif
-    /* set a minimum value of min_undequeued in case query fails */
-    if( *min_undequeued == 0 )
-        *min_undequeued = 1;
-
-    LOGD( "getMinUndequeued: %p %u", (void *)priv->anw, *min_undequeued );
-
-    return 0;
-}
-
-int ANativeWindowPriv_getMaxBufferCount( native_window_priv *priv, unsigned 
int *max_buffer_count )
-{
-#if ANDROID_ICS_OR_LATER
-    *max_buffer_count = 32;
-#else
-    *max_buffer_count = 15;
-#endif
-    return 0;
-}
-
-int ANativeWindowPriv_setBufferCount(native_window_priv *priv, unsigned int 
count )
-{
-    status_t err;
-
-    LOGD( "setBufferCount: %p %u", (void *)priv->anw, count );
-
-    err = native_window_set_buffer_count( priv->anw, count );
-    CHECK_ERR();
-
-    return 0;
-}
-
-int ANativeWindowPriv_setCrop( native_window_priv *priv, int ofs_x, int ofs_y, 
int w, int h )
-{
-    android_native_rect_t crop;
-
-    crop.left = ofs_x;
-    crop.top = ofs_y;
-    crop.right = ofs_x + w;
-    crop.bottom = ofs_y + h;
-    return native_window_set_crop( priv->anw, &crop );
-}
-
-static int dequeue_fence( native_window_priv *priv, void **pp_handle,
-                          int *p_fence_fd )
-{
-    ANativeWindowBuffer_t *anb;
-    status_t err = NO_ERROR;
-    int i_fence_fd = -1;
-
-#if ANDROID_JBMR2_OR_LATER
-    err = priv->anw->dequeueBuffer( priv->anw, &anb, &i_fence_fd );
-    CHECK_ERR();
-    if( !p_fence_fd && i_fence_fd != -1 )
-    {
-        __s32 timeout = 5000;
-        if( ioctl( i_fence_fd, SYNC_IOC_WAIT, &timeout ) != 0 )
-        {
-            priv->anw->queueBuffer( priv->anw, anb, i_fence_fd );
-            return -1;
-        }
-        close( i_fence_fd );
-        i_fence_fd = -1;
-    }
-#else
-    err = priv->anw->dequeueBuffer( priv->anw, &anb );
-    CHECK_ERR();
-#endif
-
-    if( p_fence_fd )
-        *p_fence_fd = i_fence_fd;
-    *pp_handle = anb;
-
-    return 0;
-}
-
-int ANativeWindowPriv_dequeue( native_window_priv *priv, void **pp_handle )
-{
-    return dequeue_fence( priv, pp_handle, NULL );
-}
-
-int ANativeWindowPriv_lock( native_window_priv *priv, void *p_handle )
-{
-#if !ANDROID_JBMR2_OR_LATER
-    ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle;
-    status_t err = NO_ERROR;
-
-    CHECK_ANB();
-
-    err = priv->anw->lockBuffer( priv->anw, anb );
-    CHECK_ERR();
-
-#endif
-    return 0;
-}
-
-static int queue_fence( native_window_priv *priv, void *p_handle,
-                        int i_fence_fd )
-{
-    ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle;
-    status_t err = NO_ERROR;
-
-    CHECK_ANB();
-
-#if ANDROID_JBMR2_OR_LATER
-    err = priv->anw->queueBuffer( priv->anw, anb, i_fence_fd );
-#else
-    err = priv->anw->queueBuffer( priv->anw, anb );
-#endif
-    CHECK_ERR();
-
-    return 0;
-}
-
-int ANativeWindowPriv_queue( native_window_priv *priv, void *p_handle )
-{
-    return queue_fence( priv, p_handle, -1 );
-}
-
-static int cancel_fence( native_window_priv *priv, void *p_handle,
-                         int i_fence_fd )
-{
-    ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle;
-    status_t err = NO_ERROR;
-
-    CHECK_ANB();
-
-#if ANDROID_JBMR2_OR_LATER
-    err = priv->anw->cancelBuffer( priv->anw, anb, i_fence_fd );
-#else
-    err = priv->anw->cancelBuffer( priv->anw, anb );
-#endif
-    CHECK_ERR();
-
-    return 0;
-}
-
-int ANativeWindowPriv_cancel( native_window_priv *priv, void *p_handle )
-{
-    return cancel_fence( priv, p_handle, -1 );
-}
-
-int ANativeWindowPriv_lockData( native_window_priv *priv, void **pp_handle,
-                                ANativeWindow_Buffer *p_out_anb )
-{
-    ANativeWindowBuffer_t *anb;
-    status_t err = NO_ERROR;
-    void *p_data;
-
-    err = dequeue_fence( priv, pp_handle, NULL );
-    CHECK_ERR();
-
-    anb = (ANativeWindowBuffer_t *)*pp_handle;
-    CHECK_ANB();
-
-    err = ANativeWindowPriv_lock( priv, *pp_handle );
-    CHECK_ERR();
-
-    err = priv->gralloc->lock( priv->gralloc, anb->handle, priv->usage,
-                               0, 0, anb->width, anb->height, &p_data );
-    CHECK_ERR();
-    if( p_out_anb ) {
-        p_out_anb->bits = p_data;
-        p_out_anb->width = anb->width;
-        p_out_anb->height = anb->height;
-        p_out_anb->stride = anb->stride;
-        p_out_anb->format = anb->format;
-    }
-
-    return 0;
-}
-
-int ANativeWindowPriv_unlockData( native_window_priv *priv, void *p_handle,
-                                  bool b_render )
-{
-    ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle;
-    status_t err = NO_ERROR;
-
-    CHECK_ANB();
-
-    err = priv->gralloc->unlock( priv->gralloc, anb->handle );
-    CHECK_ERR();
-
-    if( b_render )
-        queue_fence( priv, p_handle, -1 );
-    else
-        cancel_fence( priv, p_handle, -1 );
-
-    return 0;
-}
-
-int ANativeWindowPriv_setOrientation( native_window_priv *priv, int 
orientation )
-{
-    status_t err = NO_ERROR;
-    int transform;
-
-    switch( orientation )
-    {
-        case 90:
-            transform = NATIVE_WINDOW_TRANSFORM_ROT_90;
-            break;
-        case 180:
-            transform = NATIVE_WINDOW_TRANSFORM_ROT_180;
-            break;
-        case 270:
-            transform = NATIVE_WINDOW_TRANSFORM_ROT_270;
-            break;
-        default:
-            transform = 0;
-    }
-
-    err = native_window_set_buffers_transform( priv->anw, transform );
-    CHECK_ERR();
-
-    return 0;
-}
diff --git a/modules/video_output/android/utils.c 
b/modules/video_output/android/utils.c
index d944e499ba..b59035ef89 100644
--- a/modules/video_output/android/utils.c
+++ b/modules/video_output/android/utils.c
@@ -45,7 +45,6 @@ struct AWindowHandler
     ptr_ANativeWindow_fromSurface pf_winFromSurface;
     ptr_ANativeWindow_release pf_winRelease;
     native_window_api_t anw_api;
-    native_window_priv_api_t anwpriv_api;
 
     struct {
         awh_events_t cb;
@@ -298,36 +297,6 @@ LoadNativeWindowAPI(AWindowHandler *p_awh)
 }
 
 /*
- * Android private NativeWindow (post android 2.3)
- */
-
-int
-android_loadNativeWindowPrivApi(native_window_priv_api_t *native)
-{
-#define LOAD(symbol) do { \
-if ((native->symbol = dlsym(RTLD_DEFAULT, "ANativeWindowPriv_" #symbol)) == 
NULL) \
-    return -1; \
-} while(0)
-    LOAD(connect);
-    LOAD(disconnect);
-    LOAD(setUsage);
-    LOAD(setBuffersGeometry);
-    LOAD(getMinUndequeued);
-    LOAD(getMaxBufferCount);
-    LOAD(setBufferCount);
-    LOAD(setCrop);
-    LOAD(dequeue);
-    LOAD(lock);
-    LOAD(lockData);
-    LOAD(unlockData);
-    LOAD(queue);
-    LOAD(cancel);
-    LOAD(setOrientation);
-    return 0;
-#undef LOAD
-}
-
-/*
  * Andoid JNIEnv helper
  */
 
diff --git a/modules/video_output/android/utils.h 
b/modules/video_output/android/utils.h
index 87b0d9cc67..3684cd4eca 100644
--- a/modules/video_output/android/utils.h
+++ b/modules/video_output/android/utils.h
@@ -52,29 +52,6 @@ typedef struct
     int32_t (*setBuffersGeometry)(ANativeWindow*, int32_t, int32_t, int32_t); 
/* can be NULL */
 } native_window_api_t;
 
-/**
- * native_window_priv_api_t. See system/core/include/system/window.h in AOSP.
- */
-typedef struct native_window_priv native_window_priv;
-typedef struct
-{
-    native_window_priv *(*connect)(ANativeWindow *);
-    int (*disconnect) (native_window_priv *);
-    int (*setUsage) (native_window_priv *, bool, int );
-    int (*setBuffersGeometry) (native_window_priv *, int, int, int );
-    int (*getMinUndequeued) (native_window_priv *, unsigned int *);
-    int (*getMaxBufferCount) (native_window_priv *, unsigned int *);
-    int (*setBufferCount) (native_window_priv *, unsigned int );
-    int (*setCrop) (native_window_priv *, int, int, int, int);
-    int (*dequeue) (native_window_priv *, void **);
-    int (*lock) (native_window_priv *, void *);
-    int (*queue) (native_window_priv *, void *);
-    int (*cancel) (native_window_priv *, void *);
-    int (*lockData) (native_window_priv *, void **, ANativeWindow_Buffer *);
-    int (*unlockData) (native_window_priv *, void *, bool b_render);
-    int (*setOrientation) (native_window_priv *, int);
-} native_window_priv_api_t;
-
 struct awh_mouse_coords
 {
     int i_action;
@@ -92,15 +69,6 @@ typedef struct
 } awh_events_t;
 
 /**
- * Load a private native window API
- *
- * This can be used to access the private ANativeWindow API.
- * \param api doesn't need to be released
- * \return 0 on success, -1 on error.
- */
-int android_loadNativeWindowPrivApi(native_window_priv_api_t *api);
-
-/**
  * Attach or get a JNIEnv*
  *
  * The returned JNIEnv* is created from the android JavaVM attached to the VLC

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to