droid: change mediacodec to a whitelist for devices that can surface render
authordavilla <davilla@4pi.com>
Thu, 17 Oct 2013 23:13:19 +0000 (19:13 -0400)
committerdavilla <davilla@4pi.com>
Thu, 17 Oct 2013 23:22:35 +0000 (19:22 -0400)
xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp

index c9047e4..4db95bb 100644 (file)
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 
+static bool CanSurfaceRenderWhiteList(const std::string &name)
+{
+  // All devices 'should' be capiable of surface rendering
+  // but that seems to be hit or miss as most odd name devices
+  // cannot surface render.
+    static const char *cansurfacerender_decoders[] = {
+      "OMX.Nvidia",
+      NULL
+    };
+    for (const char **ptr = cansurfacerender_decoders; *ptr; ptr++)
+    {
+      if (!strcmp(*ptr, name.c_str()))
+        return true;
+    }
+    return false;
+}
+
 /*****************************************************************************/
 /*****************************************************************************/
 class CNULL_Listener : public CJNISurfaceTextureOnFrameAvailableListener
@@ -303,12 +320,6 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio
       break;
   }
 
-  // odroid platform throws trying to updateTexImage with a 'error creating EGLImage' and
-  // 'unsupported native buffer format (0x13)', sw render them until we figure out why.
-  if (!m_render_sw)
-    m_render_sw = g_cpuInfo.getCPUHardware().find("ODROID") != std::string::npos;
-
-
   // CJNIMediaCodec::createDecoderByXXX doesn't handle errors nicely,
   // it crashes if the codec isn't found. This is fixed in latest AOSP,
   // but not in current 4.1 devices. So 1st search for a matching codec, then create it.
@@ -357,6 +368,9 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio
     return false;
   }
 
+  // whitelist of devices that can surface render.
+  m_render_sw = CanSurfaceRenderWhiteList(m_codecname);
+
   ConfigureMediaCodec();
 
   // setup a YUV420P DVDVideoPicture buffer.
@@ -740,10 +754,10 @@ int CDVDVideoCodecAndroidMediaCodec::GetOutputPicture(void)
         src_ptr += offset;
 
         int loop_end = 0;
-        if (m_videobuffer.format == RENDER_FMT_YUV420P)
-          loop_end = 3;
-        else if (m_videobuffer.format == RENDER_FMT_NV12)
+        if (m_videobuffer.format == RENDER_FMT_NV12)
           loop_end = 2;
+        else if (m_videobuffer.format == RENDER_FMT_YUV420P)
+          loop_end = 3;
 
         for (int i = 0; i < loop_end; i++)
         {