[Android] VideoPLayerActivity: disable the hardware acceleration for TS files to avoid a crash in mediacodec

Adrien Maglo git at videolan.org
Fri Jun 13 16:08:35 CEST 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Fri Jun 13 16:06:03 2014 +0200| [6b4aaba977870724c27bf985f7c97ca229bffd39] | committer: Adrien Maglo

VideoPLayerActivity: disable the hardware acceleration for TS files to avoid a crash in mediacodec

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=6b4aaba977870724c27bf985f7c97ca229bffd39
---

 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java    |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 84c2b95..29a7507 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -35,6 +35,7 @@ import java.lang.reflect.Method;
 import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.Locale;
 import java.util.Map;
 
 import org.videolan.libvlc.EventHandler;
@@ -1866,6 +1867,17 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
 
         mSurface.setKeepScreenOn(true);
 
+        /* WARNING: hack to avoid a crash in mediacodec on KitKat.
+         * Disable the hardware acceleration the media has a ts extension. */
+        if (mLocation != null && LibVlcUtil.isKitKatOrLater()) {
+            String locationLC = mLocation.toLowerCase(Locale.ENGLISH);
+            if (locationLC.endsWith(".ts")
+                || locationLC.endsWith("tts")
+                || locationLC.endsWith(".m2t")
+                || locationLC.endsWith(".m2ts"))
+                mLibVLC.setHardwareAcceleration(LibVLC.HW_ACCELERATION_DISABLED);
+        }
+
         /* Start / resume playback */
         if(dontParse && itemPosition >= 0) {
             // Provided externally from AudioService



More information about the Android mailing list