Initialize buffer manager only once
[platform/adaptation/nexell/nx-video-api.git] / src / nx_video_dec.c
index 0dddd6d..9acaebf 100644 (file)
@@ -65,6 +65,11 @@ struct NX_V4L2DEC_INFO
 
   /* For VC1 */
   int32_t iInterlace;
+
+#ifdef TIZEN_FEATURE_ARTIK530
+  /* buffer manager */
+  void *bufmgr;
+#endif
 };
 
 
@@ -647,6 +652,10 @@ NX_V4l2DecClose (NX_V4L2DEC_HANDLE hDec)
       }
     }
   }
+#ifdef TIZEN_FEATURE_ARTIK530
+    if (hDec->bufmgr)
+      tbm_bufmgr_deinit (hDec->bufmgr);
+#endif
 
   free (hDec);
 
@@ -900,13 +909,21 @@ NX_V4l2DecInit (NX_V4L2DEC_HANDLE hDec, NX_V4L2DEC_SEQ_IN * pSeqIn)
     buf.length = pSeqIn->imgPlaneNum;
     buf.memory = V4L2_MEMORY_DMABUF;
 
+#ifdef TIZEN_FEATURE_ARTIK530
+  hDec->bufmgr = tbm_bufmgr_init (-1);
+  _D ("bufmgr = %p", hDec->bufmgr);
+  if (!hDec->bufmgr) {
+    _E ("failed to initialize tbm_init");
+    return -1;
+  }
+#endif
     /* Allocate Buffer(Internal or External) */
     for (i = 0; i < imgBuffCnt; i++) {
       if (true == hDec->useExternalFrameBuffer) {
         hDec->hImage[i] = pSeqIn->pMemHandle[i];
       } else {
         hDec->hImage[i] =
-            NX_AllocateVideoMemory (pSeqIn->width, pSeqIn->height,
+            NX_AllocateVideoMemory (hDec->bufmgr, pSeqIn->width, pSeqIn->height,
             pSeqIn->imgPlaneNum, pSeqIn->imgFormat, 4096);
         if (hDec->hImage[i] == NULL) {
           _E ("Failed to allocate image buffer(%d, %d, %d)\n", i,