videorender: CB1 VC1 video fails to play on NTFS USB [2/2]
PD#SWPL-176588
Problem:
Fork NTFS USB process,causing dmabuf fd to be inherited,
VC1 source playback failed.
Solution:
add FD_CLOEXEC when creating buf fd.
Verify:
AP232
Change-Id: I34641b55086a0872f02c658d4d58680191fab912
Signed-off-by: dehong.chen <dehong.chen@amlogic.com>
diff --git a/drm/drm_display.cpp b/drm/drm_display.cpp
index 363e4cb..4731348 100644
--- a/drm/drm_display.cpp
+++ b/drm/drm_display.cpp
@@ -25,6 +25,7 @@
#include "drm_framepost.h"
#include "drm_framerecycle.h"
#include "ErrorCode.h"
+#include <fcntl.h>
using namespace Tls;
@@ -337,6 +338,7 @@
FrameEntity* frame = NULL;
struct drm_buf * drmBuf = NULL;
int displayWidth = 0, displayHeight = 0;
+ int r_flags = -1;
frame = (FrameEntity*)calloc(1, sizeof(FrameEntity));
if (!frame) {
@@ -377,6 +379,10 @@
if not dup buf fd, fd will be double free*/
for (int i = 0; i < buf->dma.planeCnt; i++) {
info.fd[i] = dup(buf->dma.fd[i]);
+ // FD_CLOEXEC
+ r_flags = fcntl(info.fd[i], F_GETFD);
+ r_flags |= FD_CLOEXEC;
+ fcntl(info.fd[i], F_SETFD, r_flags);
TRACE(mLogCategory,"dup fd[%d]:%d->%d",i,buf->dma.fd[i],info.fd[i]);
}