libmix: disable buffer reallocation when protected content is being played

BZ: 125789

Protected content video playback will fail if the output buffer needs to bereallocated.

Signed-off-by: Dan Liang <dan.liang@intel.com>
Change-Id: I0be4e9115a55219f6b957fd70da007f58489f871
Reviewed-on: http://android.intel.com:8080/120693
Reviewed-by: Feng, Wei <wei.feng@intel.com>
Reviewed-by: Guo, Nana N <nana.n.guo@intel.com>
Reviewed-by: Poornachandran, Rajesh <rajesh.poornachandran@intel.com>
Tested-by: Sun, Hang L <hang.l.sun@intel.com>
Reviewed-by: cactus <cactus@intel.com>
Tested-by: cactus <cactus@intel.com>
diff --git a/videodecoder/VideoDecoderAVC.cpp b/videodecoder/VideoDecoderAVC.cpp
index e3d67dd..c075e8a 100644
--- a/videodecoder/VideoDecoderAVC.cpp
+++ b/videodecoder/VideoDecoderAVC.cpp
@@ -701,21 +701,19 @@
 
     int diff = data->codec_data->num_ref_frames + 1 - mOutputWindowSize;
 
-#ifndef USE_AVC_SHORT_FORMAT
-    // The number of actual buffer needed is
-    // outputQueue + nativewindow_owned + (diff > 0 ? diff : 1) + widi_need_max + 1(available buffer)
-    // while outputQueue = DPB < 8? DPB :8
-    // and diff = Reference + 1 - ouputQueue
-    mVideoFormatInfo.actualBufferNeeded = mOutputWindowSize + 4 /* Owned by native window */
-                                          + (diff > 0 ? diff : 1)
-                                          + 6 /* WiDi maximum needs */
-                                          + 1;
-#else
-    // This is for protected video playback on Baytrail
-    mVideoFormatInfo.actualBufferNeeded = mOutputWindowSize + 2 /* Owned by native window */
-                                      + (diff > 0 ? diff : 1)
-                                      + 1;
-#endif
+    if (mConfigBuffer.flag & WANT_SURFACE_PROTECTION) {
+        mVideoFormatInfo.actualBufferNeeded = mConfigBuffer.surfaceNumber;
+    } else {
+        // The number of actual buffer needed is
+        // outputQueue + nativewindow_owned + (diff > 0 ? diff : 1) + widi_need_max + 1(available buffer)
+        // while outputQueue = DPB < 8? DPB :8
+        // and diff = Reference + 1 - ouputQueue
+        mVideoFormatInfo.actualBufferNeeded = mOutputWindowSize + 4 /* Owned by native window */
+                                              + (diff > 0 ? diff : 1)
+                                              + 6 /* WiDi maximum needs */
+                                              + 1;
+    }
+
     ITRACE("actualBufferNeeded =%d", mVideoFormatInfo.actualBufferNeeded);
 
     mVideoFormatInfo.valid = true;