#define TBM_BUFMGR_RETURN_IF_FAIL(cond) {\
if (!(cond)) {\
TBM_ERR("'%s' failed.\n", #cond);\
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);\
_tbm_bufmgr_mutex_unlock();\
return;\
} \
#define TBM_BUFMGR_RETURN_VAL_IF_FAIL(cond, val) {\
if (!(cond)) {\
TBM_ERR("'%s' failed.\n", #cond);\
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);\
_tbm_bufmgr_mutex_unlock();\
return val;\
} \
pthread_mutex_lock(&gLock);
+ _tbm_set_last_result(TBM_ERROR_NONE);
+
if (fd >= 0) {
TBM_WRN("!!!!!WARNING:: The tbm_bufmgr_init DOSE NOT use argument fd ANYMORE.\n");
TBM_WRN("!!!!!WARNING:: IT WILL BE CHANGED like tbm_bufmgr_init(int fd) --> tbm_bufmgr_init(void).\n");
gBufMgr = calloc(1, sizeof(struct _tbm_bufmgr));
if (!gBufMgr) {
TBM_ERR("error: fail to alloc bufmgr fd(%d)\n", fd);
+ _tbm_set_last_result(TBM_ERROR_OUT_OF_MEMORY);
pthread_mutex_unlock(&gLock);
return NULL;
}
/* load bufmgr priv from env */
if (!_tbm_load_module(gBufMgr, gBufMgr->fd)) {
TBM_ERR("error : Fail to load bufmgr backend\n");
+ _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
free(gBufMgr);
gBufMgr = NULL;
pthread_mutex_unlock(&gLock);
_tbm_bufmgr_mutex_lock();
pthread_mutex_lock(&gLock);
+ _tbm_set_last_result(TBM_ERROR_NONE);
if (!gBufMgr) {
TBM_ERR("gBufmgr already destroy: bufmgr:%p\n", bufmgr);
unsigned int capabilities = TBM_BUFMGR_CAPABILITY_NONE;
_tbm_bufmgr_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_BUFMGR_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr), TBM_BUFMGR_CAPABILITY_NONE);
TBM_BUFMGR_RETURN_VAL_IF_FAIL(bufmgr == gBufMgr, TBM_BUFMGR_CAPABILITY_NONE);
tbm_error_e error;
pthread_mutex_lock(&gLock);
+ _tbm_set_last_result(TBM_ERROR_NONE);
if (!TBM_BUFMGR_IS_VALID(bufmgr) || (bufmgr != gBufMgr)) {
TBM_ERR("invalid bufmgr\n");
+ _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
pthread_mutex_unlock(&gLock);
return NULL;
}
str = malloc(len);
if (!str) {
TBM_ERR("Fail to allocate the string.\n");
+ _tbm_set_last_result(TBM_ERROR_OUT_OF_MEMORY);
pthread_mutex_unlock(&gLock);
return NULL;
}
tbm_bufmgr_debug_trace(tbm_bufmgr bufmgr, int onoff)
{
_tbm_bufmgr_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_BUFMGR_RETURN_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr));
TBM_BUFMGR_RETURN_IF_FAIL(bufmgr == gBufMgr);
tbm_bufmgr_debug_set_trace_mask(tbm_bufmgr bufmgr, tbm_bufmgr_debug_trace_mask mask, int set)
{
_tbm_bufmgr_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_BUFMGR_RETURN_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr));
TBM_BUFMGR_RETURN_IF_FAIL(bufmgr == gBufMgr);
tbm_bufmgr_debug_dump_set_scale(double scale)
{
pthread_mutex_lock(&gLock);
+ _tbm_set_last_result(TBM_ERROR_NONE);
scale_factor = scale;
pthread_mutex_unlock(&gLock);
}
int
tbm_bufmgr_debug_get_ref_count(void)
{
- return (gBufMgr) ? gBufMgr->ref_count : 0;
+ int refcnt;
+
+ pthread_mutex_lock(&gLock);
+
+ _tbm_set_last_result(TBM_ERROR_NONE);
+
+ refcnt = (gBufMgr) ? gBufMgr->ref_count : 0;
+
+ pthread_mutex_unlock(&gLock);
+
+ return refcnt;
}
int
tbm_bufmgr_debug_queue_dump(char *path, int count, int onoff)
{
pthread_mutex_lock(&gLock);
+ _tbm_set_last_result(TBM_ERROR_NONE);
if (onoff == 0) {
TBM_DBG("count=%d onoff=%d\n", count, onoff);
}
pthread_mutex_unlock(&gLock);
+
return 1;
}
int w, h, count = 0;
tbm_surface_h surface = NULL;
+ pthread_mutex_lock(&gLock);
+ _tbm_set_last_result(TBM_ERROR_NONE);
+
TBM_RETURN_VAL_IF_FAIL(path != NULL, 0);
TBM_DBG("path=%s\n", path);
- pthread_mutex_lock(&gLock);
-
count = _tbm_util_get_max_surface_size(&w, &h);
if (count == 0) {
TBM_ERR("No tbm_surface.\n");
tbm_error_e error;
_tbm_bufmgr_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_BUFMGR_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(gBufMgr), 0);
if (!bufmgr->bufmgr_func->bufmgr_bind_native_display) {
TBM_WRN("skip: tbm_bufmgr(%p) native_display(%p)\n",
bufmgr, native_display);
+ _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
_tbm_bufmgr_mutex_unlock();
return 1;
}
if (error != TBM_ERROR_NONE) {
TBM_ERR("error: tbm_bufmgr(%p) native_display(%p) error(%d)\n",
bufmgr, native_display, error);
+ _tbm_set_last_result(error);
_tbm_bufmgr_mutex_unlock();
return 0;
}
if (!bufmgr->backend->bufmgr_bind_native_display) {
TBM_WRN("skip: tbm_bufmgr(%p) native_display(%p)\n",
bufmgr, native_display);
+ _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED);
_tbm_bufmgr_mutex_unlock();
return 1;
}
if (!ret) {
TBM_ERR("error: tbm_bufmgr(%p) native_display(%p)\n",
bufmgr, native_display);
+ _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
_tbm_bufmgr_mutex_unlock();
return 0;
}
tbm_bufmgr_set_bo_lock_type(tbm_bufmgr bufmgr, tbm_bufmgr_bo_lock_type bo_lock_type)
{
_tbm_bufmgr_mutex_lock();
+ _tbm_set_last_result(TBM_ERROR_NONE);
TBM_BUFMGR_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(gBufMgr), 0);
TBM_BUFMGR_RETURN_VAL_IF_FAIL(bufmgr == gBufMgr, 0);