tewilove/faplayer — Issue #26: Android 4.0 video output module
Author: tewilove
Created: 2011-11-29 12:25:06+00:00
State: open

Possible patch.
diff --git a/modules/video_output/androidsurface.c b/modules/video_output/androidsurface.c
index 143d2d7..9112901 100644
--- a/modules/video_output/androidsurface.c
+++ b/modules/video_output/androidsurface.c
@@ -33,8 +33,11 @@

#include

+#ifndef ANDROID_SYM_S_LOCK_FALLBACK
+# define ANDROID_SYM_S_LOCK_FALLBACK "_ZN7android7Surface4lockEPNS0_11SurfaceInfoEb"
+#endif
#ifndef ANDROID_SYM_S_LOCK
-# define ANDROID_SYM_S_LOCK "_ZN7android7Surface4lockEPNS0_11SurfaceInfoEb"
+# define ANDROID_SYM_S_LOCK "_ZN7android7Surface4lockEPNS0_11SurfaceInfoEPNS_6RegionE"
#endif
#ifndef ANDROID_SYM_S_UNLOCK
# define ANDROID_SYM_S_UNLOCK "_ZN7android7Surface13unlockAndPostEv"
@@ -66,7 +69,9 @@ typedef void (*jni_UnlockAndroidSurface_t)(vlc_object_t *);
typedef void (*jni_SetAndroidSurfaceSize_t)(vlc_object_t *, int, int);

// _ZN7android7Surface4lockEPNS0_11SurfaceInfoEb
-typedef void (*Surface_lock)(void *, void *, int);
+typedef void (*Surface_lock_fallback)(void *, void *, int);
+// _ZN7android7Surface4lockEPNS0_11SurfaceInfoEPNS_6RegionE
+typedef void (*Surface_lock)(void *, void *, void *);
// _ZN7android7Surface13unlockAndPostEv
typedef void (*Surface_unlockAndPost)(void *);

@@ -82,13 +87,14 @@ static int Control(vout_display_t *, int, va_list);
struct vout_display_sys_t {
picture_pool_t *pool;
void *p_library;
+ Surface_lock s_lock_fallback;
Surface_lock s_lock;
Surface_unlockAndPost s_unlockAndPost;
void *p_jni;
jni_LockAndGetAndroidSurface_t jni_LockAndGetAndroidSurface;
jni_UnlockAndroidSurface_t jni_UnlockAndroidSurface;
jni_SetAndroidSurfaceSize_t jni_SetAndroidSurfaceSize;
-	vlc_object_t *p_vout;
+ vlc_object_t *p_vout;
picture_resource_t resource;
};

@@ -129,10 +135,11 @@ static inline void *LoadJNI(const char *psz_lib, vout_display_sys_t *sys) {
static inline void *LoadSurface(const char *psz_lib, vout_display_sys_t *sys) {
void *p_library = dlopen(psz_lib, RTLD_NOW);
if (p_library) {
+ sys->s_lock_fallback = (Surface_lock_fallback)(dlsym(p_library, ANDROID_SYM_S_LOCK_FALLBACK));
sys->s_lock = (Surface_lock)(dlsym(p_library, ANDROID_SYM_S_LOCK));
sys->s_unlockAndPost =
(Surface_unlockAndPost)(dlsym(p_library, ANDROID_SYM_S_UNLOCK));
- if (sys->s_lock && sys->s_unlockAndPost) {
+ if ((sys->s_lock || sys->s_lock_fallback) && sys->s_unlockAndPost) {
return p_library;
}
dlclose(p_library);
@@ -146,6 +153,8 @@ static void *InitJNI(vout_display_sys_t *sys) {

static void *InitLibrary(vout_display_sys_t *sys) {
void *p_library;
+ if ((p_library = LoadSurface("libgui.so", sys)))
+ return p_library;
if ((p_library = LoadSurface("libsurfaceflinger_client.so", sys)))
return p_library;
return LoadSurface("libui.so", sys);
@@ -175,7 +184,7 @@ static int Open(vlc_object_t *p_this) {
if (!p_library) {
free(sys);
dlclose(p_jni);
- msg_Err(vd, "Could not initialize libui.so/libsurfaceflinger_client.so!");
+ msg_Err(vd, "Could not initialize libui.so/libsurfaceflinger_client.so/libgui.so!");
return VLC_EGENERIC;
}

@@ -274,7 +283,10 @@ static int AndroidLockSurface(picture_t *picture) {
return VLC_EGENERIC;
}

- sys->s_lock(surf, info, 1);
+ if (sys->s_lock)
+ sys->s_lock(surf, info, NULL);
+ else
+ sys->s_lock_fallback(surf, info, 1);

// input size doesn't match the surface size,
// request a resize