libvideorender: CB2 disconnect timeout [1/1]

PD#SWPL-138652

Problem:
1.render_disconnect take too long time, it causes
yts timeout or crash

Solution:
1.refine disconnect logic
2.add category for log debug

Verify:
ap222

Change-Id: I1920838d8d0562df6760c78cab2db52d2c6aa126
Signed-off-by: fei.deng <fei.deng@amlogic.com>
diff --git a/drm/drm_lib_wrap.cpp b/drm/drm_lib_wrap.cpp
index a2a8388..542cb4e 100644
--- a/drm/drm_lib_wrap.cpp
+++ b/drm/drm_lib_wrap.cpp
@@ -18,102 +18,103 @@
 #include <stdlib.h>
 #include "drm_lib_wrap.h"
 #include "Logger.h"
+#include "ErrorCode.h"
 
 #define TAG "rlib:drm_lib_wrap"
 
 #define DRM_MESON_LIB_NAME "libdrm_meson.so"
 
-DrmMesonLib * drmMesonLoadLib()
+DrmMesonLib * drmMesonLoadLib(int logCategory)
 {
-    INFO("load libdrm meson so symbol");
+    INFO(logCategory, "load libdrm meson so symbol");
 
     DrmMesonLib *handle = (DrmMesonLib*)calloc( 1, sizeof(DrmMesonLib));
     if (!handle) {
-        ERROR("calloc DrmMesonLib struct fail");
+        ERROR(logCategory, "calloc DrmMesonLib struct fail");
         goto err_labal;
     }
 
     handle->libHandle = dlopen(DRM_MESON_LIB_NAME, RTLD_NOW);
     if (handle->libHandle == NULL) {
-        ERROR("unable to dlopen %s : %s",DRM_MESON_LIB_NAME, dlerror());
+        ERROR(logCategory, "unable to dlopen %s : %s",DRM_MESON_LIB_NAME, dlerror());
         goto err_labal;
     }
 
     handle->libDrmDisplayInit = (lib_drm_display_init)dlsym(handle->libHandle, "drm_display_init");
     if (handle->libDrmDisplayInit == NULL) {
-        ERROR("dlsym drm_display_init failed, err=%s \n", dlerror());
+        ERROR(logCategory,"dlsym drm_display_init failed, err=%s \n", dlerror());
         goto err_labal;
     }
 
     handle->libDrmDisplayDestroy = (lib_drm_destroy_display)dlsym(handle->libHandle, "drm_destroy_display");
     if (handle->libDrmDisplayDestroy == NULL) {
-        ERROR("dlsym drm_destroy_display failed, err=%s \n", dlerror());
+        ERROR(logCategory,"dlsym drm_destroy_display failed, err=%s \n", dlerror());
         goto err_labal;
     }
 
     handle->libDrmDisplayRegisterDonCb = (lib_drm_display_register_done_cb)dlsym(handle->libHandle, "drm_display_register_done_cb");
     if (handle->libDrmDisplayRegisterDonCb == NULL) {
-        ERROR("dlsym drm_display_register_done_cb failed, err=%s \n", dlerror());
+        ERROR(logCategory, "dlsym drm_display_register_done_cb failed, err=%s \n", dlerror());
         goto err_labal;
     }
 
     handle->libDrmDisplayRegisterResCb = (lib_drm_display_register_res_cb)dlsym(handle->libHandle, "drm_display_register_res_cb");
     if (handle->libDrmDisplayRegisterResCb == NULL) {
-        ERROR("dlsym drm_display_register_res_cb failed, err=%s \n", dlerror());
+        ERROR(logCategory,"dlsym drm_display_register_res_cb failed, err=%s \n", dlerror());
         goto err_labal;
     }
 
     handle->libDrmSetAllocOnlyFlag = (lib_drm_set_alloc_only_flag)dlsym(handle->libHandle, "drm_set_alloc_only_flag");
     if (handle->libDrmSetAllocOnlyFlag == NULL) {
-        ERROR("dlsym drm_set_alloc_only_flag failed, err=%s \n", dlerror());
+        ERROR(logCategory,"dlsym drm_set_alloc_only_flag failed, err=%s \n", dlerror());
         goto err_labal;
     }
 
     handle->libDrmAllocBufs = (lib_drm_alloc_bufs)dlsym(handle->libHandle, "drm_alloc_bufs");
     if (handle->libDrmAllocBufs == NULL) {
-        ERROR("dlsym drm_alloc_bufs failed, err=%s \n", dlerror());
+        ERROR(logCategory,"dlsym drm_alloc_bufs failed, err=%s \n", dlerror());
         goto err_labal;
     }
 
     handle->libDrmFreeBufs = (lib_drm_free_bufs)dlsym(handle->libHandle, "drm_free_bufs");
     if (handle->libDrmFreeBufs == NULL) {
-        ERROR("dlsym drm_free_bufs failed, err=%s \n", dlerror());
+        ERROR(logCategory,"dlsym drm_free_bufs failed, err=%s \n", dlerror());
         goto err_labal;
     }
 
     handle->libDrmAllocBuf = (lib_drm_alloc_buf)dlsym(handle->libHandle, "drm_alloc_buf");
     if (handle->libDrmAllocBuf == NULL) {
-        ERROR("dlsym drm_alloc_buf failed, err=%s \n", dlerror());
+        ERROR(logCategory,"dlsym drm_alloc_buf failed, err=%s \n", dlerror());
         goto err_labal;
     }
 
     handle->libDrmImportBuf = (lib_drm_import_buf)dlsym(handle->libHandle, "drm_import_buf");
     if (handle->libDrmImportBuf == NULL) {
-        ERROR("dlsym drm_import_buf failed, err=%s \n", dlerror());
+        ERROR(logCategory,"dlsym drm_import_buf failed, err=%s \n", dlerror());
         goto err_labal;
     }
 
     handle->libDrmFreeBuf = (lib_drm_free_buf)dlsym(handle->libHandle, "drm_free_buf");
     if (handle->libDrmFreeBuf == NULL) {
-        ERROR("dlsym drm_free_buf failed, err=%s \n", dlerror());
+        ERROR(logCategory,"dlsym drm_free_buf failed, err=%s \n", dlerror());
         goto err_labal;
     }
 
     handle->libDrmPostBuf = (lib_drm_post_buf)dlsym(handle->libHandle, "drm_post_buf");
     if (handle->libDrmPostBuf == NULL) {
-        ERROR("dlsym drm_post_buf failed, err=%s \n", dlerror());
+        ERROR(logCategory,"dlsym drm_post_buf failed, err=%s \n", dlerror());
         goto err_labal;
     }
 
     handle->libDrmModeAsyncAtomicCommit = (lib_drmModeAsyncAtomicCommit)dlsym(handle->libHandle, "drmModeAsyncAtomicCommit");
     if (handle->libDrmModeAsyncAtomicCommit == NULL) {
-        ERROR("dlsym drmModeAsyncAtomicCommit failed, err=%s \n", dlerror());
+        ERROR(logCategory,"dlsym drmModeAsyncAtomicCommit failed, err=%s \n", dlerror());
         goto err_labal;
     }
 
     handle->libDrmWaitVideoFence = (lib_drm_waitvideoFence)dlsym(handle->libHandle, "drm_waitvideoFence");
     if (handle->libDrmWaitVideoFence == NULL) {
-        ERROR("dlsym drm_waitvideoFence failed, err=%s \n", dlerror());
+        ERROR(logCategory,"dlsym drm_waitvideoFence failed, err=%s \n", dlerror());
         goto err_labal;
     }
 
@@ -128,14 +129,14 @@
     return NULL;
 }
 
-int drmMesonUnloadLib(DrmMesonLib *drmMesonLib)
+int drmMesonUnloadLib(int logCategory,DrmMesonLib *drmMesonLib)
 {
     if (drmMesonLib) {
         if (drmMesonLib->libHandle) {
-            INFO("dlclose libdrm meson so symbol");
+            INFO(logCategory, "dlclose libdrm meson so symbol");
             dlclose(drmMesonLib->libHandle);
         }
         free(drmMesonLib);
     }
-    return 0;
+    return NO_ERROR;
 }