add tbm_error_e for the fails of bo_map and bo_lock. 32/32732/2
authorSooChan Lim <sc1.lim@samsung.com>
Mon, 22 Dec 2014 11:26:13 +0000 (20:26 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Wed, 24 Dec 2014 04:00:16 +0000 (13:00 +0900)
Change-Id: I0191a4538c03a2bddc175c056d61c0af82a36fa0

src/tbm_bufmgr.c [changed mode: 0644->0755]
src/tbm_bufmgr.h

old mode 100644 (file)
new mode 100755 (executable)
index b9ac45d..014aa53
@@ -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;
     }
index d8e18db..041776e 100755 (executable)
@@ -34,6 +34,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include <tbm_type.h>
 #include <stdint.h>
+#include <tizen_error.h>
+
+
+/* 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 ();
+      ...
+   }
 
    ...