From 28acdc46968fbb073b78b1a4245df17c5beb0b45 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 22 Dec 2014 20:26:13 +0900 Subject: [PATCH] add tbm_error_e for the fails of bo_map and bo_lock. Change-Id: I0191a4538c03a2bddc175c056d61c0af82a36fa0 --- src/tbm_bufmgr.c | 7 ++++++- src/tbm_bufmgr.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) mode change 100644 => 100755 src/tbm_bufmgr.c diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c old mode 100644 new mode 100755 index b9ac45d..014aa53 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -1289,7 +1289,9 @@ tbm_bo_map (tbm_bo bo, int device, int opt) TBM_LOG ("[libtbm:%d] " "error %s:%d fail to lock bo:%p)\n", getpid(), __FUNCTION__, __LINE__, bo); - +#ifdef HAVE_CAPI_0_1_1 + set_last_result (TBM_ERROR_BO_LOCK_FAILED); +#endif pthread_mutex_unlock (&bufmgr->lock); return (tbm_bo_handle)NULL; } @@ -1302,6 +1304,9 @@ tbm_bo_map (tbm_bo bo, int device, int opt) getpid(), __FUNCTION__, __LINE__, bo); _tbm_bo_unlock(bo); +#ifdef HAVE_CAPI_0_1_1 + set_last_result (TBM_ERROR_BO_MAP_FAILED); +#endif pthread_mutex_unlock (&bufmgr->lock); return (tbm_bo_handle)NULL; } diff --git a/src/tbm_bufmgr.h b/src/tbm_bufmgr.h index d8e18db..041776e 100755 --- a/src/tbm_bufmgr.h +++ b/src/tbm_bufmgr.h @@ -34,6 +34,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include +#include + + +/* this define will be removed when the capi-common is the version 0.1.1 */ +#ifndef TIZEN_ERROR_TBM +#define TIZEN_ERROR_TBM -0x02830000 +#endif /** * \file tbm_bufmgr.h @@ -146,6 +153,19 @@ enum TBM_BO_FLAGS TBM_BO_VENDOR = (0xffff0000), /**< vendor specific memory: it depends on the backend */ }; + +/** + * @brief Enumeration for tbm error type. + * @since_tizen 2.4 + */ +typedef enum +{ + TBM_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + TBM_ERROR_BO_LOCK_FAILED = TIZEN_ERROR_TBM|0x0101, /**< tbm_bo lock failed */ + TBM_ERROR_BO_MAP_FAILED = TIZEN_ERROR_TBM|0x0102, /**< tbm_bo map failed */ +} tbm_error_e; + + #ifdef __cplusplus extern "C" { #endif @@ -318,6 +338,9 @@ void tbm_bo_unref (tbm_bo bo); * @param[in] device : the device type to get a handle * @param[in] opt : the option to access the buffer object * @return the handle of the buffer object + * @exception #TBM_ERROR_NONE Success + * @exception #TBM_ERROR_BO_LOCK_FAILED tbm_bo lock failed + * @exception #TBM_ERROR_BO_MAP_FAILED tbm_bo map failed * @retval #tbm_bo * @see tbm_bo_unmap() * @par Example @@ -328,6 +351,7 @@ void tbm_bo_unref (tbm_bo bo); tbm_bufmgr bufmgr; tbm_bo bo; tbm_bo_handle handle; + tbm_error_e error; bufmgr = tbm_bufmgr_init (bufmgr_fd); bo = tbm_bo_alloc (bufmgr, 128 * 128, TBM_BO_DEFAULT); @@ -335,6 +359,11 @@ void tbm_bo_unref (tbm_bo bo); ... handle = tbm_bo_map (bo, TBM_DEVICE_2D, TBM_OPTION_READ|TBM_OPTION_WRITE); + if (handle.ptr == NULL) + { + error = get_last_result (); + ... + } ... -- 2.7.4