Commit a71c0d3a authored by Felix Abecassis's avatar Felix Abecassis

Implement an event for LibVLC indicating VideoPlayerActivity was started

This event is necessary in order to know if it is safe to use
MediaCodec opaque direct rendering. If VideoPlayerActivity is not
started, no surface will be attached to LibVLC and thus the decoder
will wait forever.
parent b2f09c84
......@@ -32,6 +32,7 @@ static void *vout_android_surf = NULL;
static void *vout_android_gui = NULL;
static jobject vout_android_java_surf = NULL;
static jobject vout_android_subtitles_surf = NULL;
static bool vout_video_player_activity_created = false;
void *jni_LockAndGetSubtitlesSurface() {
......@@ -97,6 +98,19 @@ void jni_SetAndroidSurfaceSize(int width, int height, int visible_width, int vis
(*myVm)->DetachCurrentThread (myVm);
bool jni_IsVideoPlayerActivityCreated() {
bool result = vout_video_player_activity_created;
return result;
void Java_org_videolan_libvlc_LibVLC_eventVideoPlayerActivityCreated(JNIEnv *env, jobject thiz, jboolean created) {
vout_video_player_activity_created = created;
void Java_org_videolan_libvlc_LibVLC_attachSurface(JNIEnv *env, jobject thiz, jobject surf, jobject gui) {
jclass clz;
......@@ -84,6 +84,8 @@ public class LibVLC {
public native void attachSubtitlesSurface(Surface surface);
public native void detachSubtitlesSurface();
public native void eventVideoPlayerActivityCreated(boolean created);
/* Load library before object instantiation */
static {
try {
......@@ -335,6 +335,9 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
/* Only show the subtitles surface when using "Full Acceleration" mode */
if (mLibVLC.getHardwareAcceleration() == 2)
// Signal to LibVLC that the videoPlayerActivity was created, thus the
// SurfaceView is now available for MediaCodec direct rendering.
EventHandler em = EventHandler.getInstance();
......@@ -457,6 +460,8 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
EventHandler em = EventHandler.getInstance();
// MediaCodec opaque direct rendering should not be used anymore since there is no surface to attach.
// HW acceleration was temporarily disabled because of an error, restore the previous value.
if (mDisabledHardwareAcceleration)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment