}
if (fd < 0) {
-#ifdef HAVE_X11
- fd = tbm_bufmgr_get_drm_fd_x11();
-#elif HAVE_WAYLAND
- fd = tbm_bufmgr_get_drm_fd_wayland();
-#endif
- if (fd < 0) {
- _tbm_set_last_result(TBM_BO_ERROR_GET_FD_FAILED);
- TBM_LOG("[libtbm:%d] Fail get drm fd\n",
- getpid());
- pthread_mutex_unlock(&gLock);
- return NULL;
- }
fd_flag = 1;
}
gBufMgr = calloc(1, sizeof(struct _tbm_bufmgr));
if (!gBufMgr) {
_tbm_set_last_result(TBM_BO_ERROR_HEAP_ALLOC_FAILED);
- if (fd_flag)
- close(fd);
-
pthread_mutex_unlock(&gLock);
return NULL;
}
gBufMgr->fd_flag = fd_flag;
if (fd_flag) {
- gBufMgr->fd = fd;
+ gBufMgr->fd = -1;
} else {
gBufMgr->fd = dup(fd);
if (gBufMgr->fd < 0) {
if (!_tbm_load_module(gBufMgr, gBufMgr->fd)) {
_tbm_set_last_result(TBM_BO_ERROR_LOAD_MODULE_FAILED);
TBM_LOG("[libtbm:%d] " "error : Fail to load bufmgr backend\n", getpid());
- close(gBufMgr->fd);
+
+ if (gBufMgr->fd > 0)
+ close(gBufMgr->fd);
+
free(gBufMgr);
gBufMgr = NULL;
pthread_mutex_unlock(&gLock);
gBufMgr->backend->bufmgr_deinit(gBufMgr->backend->priv);
tbm_backend_free(gBufMgr->backend);
dlclose(gBufMgr->module_data);
- close(gBufMgr->fd);
+
+ if (gBufMgr->fd > 0)
+ close(gBufMgr->fd);
+
free(gBufMgr);
gBufMgr = NULL;
pthread_mutex_unlock(&gLock);
tbm_backend_free(gBufMgr->backend);
pthread_mutex_destroy(&gBufMgr->lock);
dlclose(gBufMgr->module_data);
- close(gBufMgr->fd);
+
+ if (gBufMgr->fd > 0)
+ close(gBufMgr->fd);
+
free(gBufMgr);
gBufMgr = NULL;
pthread_mutex_unlock(&gLock);
dlclose(bufmgr->module_data);
- close(bufmgr->fd);
+ if (bufmgr->fd > 0)
+ close(bufmgr->fd);
free(bufmgr);
bufmgr = NULL;
return bo;
}
-unsigned int tbm_bo_export(tbm_bo bo)
+tbm_key tbm_bo_export(tbm_bo bo)
{
TBM_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0);
tbm_bufmgr bufmgr;
- int ret;
+ tbm_key ret;
bufmgr = bo->bufmgr;
pthread_mutex_lock(&gLock);
+ TBM_DEBUG("\n");
_tbm_util_get_appname_from_pid(getpid(), app_name);
_tbm_util_get_appname_brief(app_name);
TBM_DEBUG("============TBM DEBUG: %s(%d)===========================\n", app_name, getpid());
app_name);
for (i = 0; i < surf->num_bos; i++) {
- TBM_DEBUG(" bo:%-11p(key:%2d) %-26d%-10d\n",
+ TBM_DEBUG(" bo:%-12p(key:%2d) %-26d%-10d\n",
surf->bos[i],
surf->bos[i]->tgl_key,
surf->bos[i]->ref_cnt,