define error code for no-mem case.
Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
* @retval #ML_ERROR_INVALID_PARAMETER Fail. The parameter is invalid.
* @retval #ML_ERROR_STREAMS_PIPE Failed to start the pipeline.
* @retval #ML_ERROR_PERMISSION_DENIED The application does not have the privilege to access to the media storage or external storage.
+ * @retval #ML_ERROR_OUT_OF_MEMORY Failed to allocate required memory.
*/
int ml_single_open (ml_single_h *single, const char *model, const ml_tensors_info_h input_info, const ml_tensors_info_h output_info, ml_nnfw_type_e nnfw, ml_nnfw_hw_e hw);
ML_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< Time out */
ML_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< The feature is not supported */
ML_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ ML_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
} ml_error_e;
/**
* @retval #ML_ERROR_INVALID_PARAMETER Given parameter is invalid. (Pipeline is not negotiated yet.)
* @retval #ML_ERROR_STREAMS_PIPE Pipeline construction is failed because of wrong parameter or initialization failure.
* @retval #ML_ERROR_PERMISSION_DENIED The application does not have the required privilege to access to the media storage, external storage, microphone, or camera.
+ * @retval #ML_ERROR_OUT_OF_MEMORY Failed to allocate required memory to construct the pipeline.
*
* @pre The pipeline state should be #ML_PIPELINE_STATE_UNKNOWN or #ML_PIPELINE_STATE_NULL.
* @post The pipeline state will be #ML_PIPELINE_STATE_PAUSED in the same thread.
* @retval #ML_ERROR_NOT_SUPPORTED Not supported.
* @retval #ML_ERROR_INVALID_PARAMETER Given parameter is invalid. (Not negotiated, sink_name is not found, or sink_name has an invalid type.)
* @retval #ML_ERROR_STREAMS_PIPE Failed to connect a signal to sink element.
+ * @retval #ML_ERROR_OUT_OF_MEMORY Failed to allocate required memory.
*
* @pre The pipeline state should be #ML_PIPELINE_STATE_PAUSED.
*/
* @retval #ML_ERROR_INVALID_PARAMETER Given parameter is invalid.
* @retval #ML_ERROR_STREAMS_PIPE Fail to get SRC element.
* @retval #ML_ERROR_TRY_AGAIN The pipeline is not ready yet.
+ * @retval #ML_ERROR_OUT_OF_MEMORY Failed to allocate required memory.
*/
int ml_pipeline_src_get_handle (ml_pipeline_h pipe, const char *src_name, ml_pipeline_src_h *src_handle);
* @retval #ML_ERROR_NONE Successful
* @retval #ML_ERROR_NOT_SUPPORTED Not supported.
* @retval #ML_ERROR_INVALID_PARAMETER Given parameter is invalid.
+ * @retval #ML_ERROR_OUT_OF_MEMORY Failed to allocate required memory.
*/
int ml_pipeline_switch_get_handle (ml_pipeline_h pipe, const char *switch_name, ml_pipeline_switch_e *switch_type, ml_pipeline_switch_h *switch_handle);
* @retval #ML_ERROR_NOT_SUPPORTED Not supported.
* @retval #ML_ERROR_INVALID_PARAMETER Given parameter is invalid.
* @retval #ML_ERROR_STREAMS_PIPE The element is not both input and output switch (Internal data inconsistency).
+ * @retval #ML_ERROR_OUT_OF_MEMORY Failed to allocate required memory.
*
* Here is an example of the usage:
* @code
* @retval #ML_ERROR_NONE Successful
* @retval #ML_ERROR_NOT_SUPPORTED Not supported.
* @retval #ML_ERROR_INVALID_PARAMETER Given parameter is invalid.
+ * @retval #ML_ERROR_OUT_OF_MEMORY Failed to allocate required memory.
*/
int ml_pipeline_valve_get_handle (ml_pipeline_h pipe, const char *valve_name, ml_pipeline_valve_h *valve_handle);
* @retval #ML_ERROR_NONE Successful
* @retval #ML_ERROR_NOT_SUPPORTED Not supported.
* @retval #ML_ERROR_INVALID_PARAMETER Given parameter is invalid.
+ * @retval #ML_ERROR_OUT_OF_MEMORY Failed to allocate required memory.
*/
int ml_tensors_info_create (ml_tensors_info_h *info);
* @retval #ML_ERROR_NOT_SUPPORTED Not supported.
* @retval #ML_ERROR_INVALID_PARAMETER Given parameter is invalid.
* @retval #ML_ERROR_STREAMS_PIPE Failed to allocate new memory.
+ * @retval #ML_ERROR_OUT_OF_MEMORY Failed to allocate required memory.
*/
int ml_tensors_data_create (const ml_tensors_info_h info, ml_tensors_data_h *data);
#define TIZEN_ERROR_TIMED_OUT (TIZEN_ERROR_UNKNOWN + 1)
#define TIZEN_ERROR_NOT_SUPPORTED (TIZEN_ERROR_UNKNOWN + 2)
#define TIZEN_ERROR_PERMISSION_DENIED (-EACCES)
+#define TIZEN_ERROR_OUT_OF_MEMORY (-ENOMEM)
#endif /* __NTZN_TIZEN_ERROR_H__ */
pipe_h = g_new0 (ml_pipeline, 1);
if (pipe_h == NULL) {
ml_loge ("Failed to allocate handle for pipeline.");
- return ML_ERROR_STREAMS_PIPE;
+ return ML_ERROR_OUT_OF_MEMORY;
}
g_mutex_init (&pipe_h->lock);
g_hash_table_insert (pipe_h->namednodes, g_strdup (name), e);
} else {
/* allocation failure */
- status = ML_ERROR_STREAMS_PIPE;
+ status = ML_ERROR_OUT_OF_MEMORY;
done = TRUE;
}
}
sink = *h = g_new0 (ml_pipeline_sink, 1);
if (sink == NULL) {
ml_loge ("Failed to allocate the sink handle for %s.", sink_name);
- ret = ML_ERROR_STREAMS_PIPE;
+ ret = ML_ERROR_OUT_OF_MEMORY;
goto unlock_return;
}
src = *h = g_new0 (ml_pipeline_src, 1);
if (src == NULL) {
ml_loge ("Failed to allocate the src handle for %s.", src_name);
- ret = ML_ERROR_STREAMS_PIPE;
+ ret = ML_ERROR_OUT_OF_MEMORY;
goto unlock_return;
}
swtc = *h = g_new0 (ml_pipeline_switch, 1);
if (swtc == NULL) {
ml_loge ("Failed to allocate the switch handle for %s.", switch_name);
- ret = ML_ERROR_STREAMS_PIPE;
+ ret = ML_ERROR_OUT_OF_MEMORY;
goto unlock_return;
}
*list = g_malloc0 (sizeof (char *) * (counter + 1));
if (*list == NULL) {
ml_loge ("Failed to allocate memory for pad list.");
- ret = ML_ERROR_STREAMS_PIPE;
+ ret = ML_ERROR_OUT_OF_MEMORY;
goto unlock_return;
}
valve = *h = g_new0 (ml_pipeline_valve, 1);
if (valve == NULL) {
ml_loge ("Failed to allocate the valve handle for %s.", valve_name);
- ret = ML_ERROR_STREAMS_PIPE;
+ ret = ML_ERROR_OUT_OF_MEMORY;
goto unlock_return;
}
single_h = g_new0 (ml_single, 1);
if (single_h == NULL) {
ml_loge ("Failed to allocate the single handle.");
- /**
- * @todo define error code (ML_ERROR_OUT_OF_MEMORY) for no-mem case in ml_error_e
- * TIZEN_ERROR_OUT_OF_MEMORY = -ENOMEM
- */
- return ML_ERROR_UNKNOWN;
+ return ML_ERROR_OUT_OF_MEMORY;
}
single_h->magic = ML_SINGLE_MAGIC;
if (single_h == NULL) {
ml_loge ("Failed to allocate the single handle.");
ml_pipeline_destroy (pipe);
- return ML_ERROR_STREAMS_PIPE;
+ return ML_ERROR_OUT_OF_MEMORY;
}
pipe_h = (ml_pipeline *) pipe;
res = g_new0 (pipeline_resource_s, 1);
if (!res) {
ml_loge ("Failed to allocate pipeline resource handle.");
+ status = ML_ERROR_OUT_OF_MEMORY;
goto rm_error;
}
mm_handle = g_new0 (tizen_mm_handle_s, 1);
if (!mm_handle) {
ml_loge ("Failed to allocate media resource handle.");
+ status = ML_ERROR_OUT_OF_MEMORY;
goto rm_error;
}
if (mm_res == NULL) {
ml_loge ("Failed to allocate media resource data.");
g_free (res_key);
+ status = ML_ERROR_OUT_OF_MEMORY;
goto rm_error;
}
return ML_ERROR_INVALID_PARAMETER;
*info = tensors_info = g_new0 (ml_tensors_info_s, 1);
+ if (tensors_info == NULL) {
+ ml_loge ("Failed to allocate the tensors info handle.");
+ return ML_ERROR_OUT_OF_MEMORY;
+ }
/* init tensors info struct */
return ml_tensors_info_initialize (tensors_info);
_data = g_new0 (ml_tensors_data_s, 1);
if (!_data) {
- ml_loge ("Failed to allocate the memory block.");
- return ML_ERROR_STREAMS_PIPE;
+ ml_loge ("Failed to allocate the tensors data handle.");
+ return ML_ERROR_OUT_OF_MEMORY;
}
_data->num_tensors = tensors_info->num_tensors;
ml_tensors_data_create (const ml_tensors_info_h info,
ml_tensors_data_h * data)
{
- gint status;
+ gint status = ML_ERROR_STREAMS_PIPE;
ml_tensors_data_s *_data = NULL;
gint i;
for (i = 0; i < _data->num_tensors; i++) {
_data->tensors[i].tensor = g_malloc0 (_data->tensors[i].size);
- if (_data->tensors[i].tensor == NULL)
+ if (_data->tensors[i].tensor == NULL) {
+ status = ML_ERROR_OUT_OF_MEMORY;
goto failed;
+ }
}
*data = _data;
g_free (_data);
ml_loge ("Failed to allocate the memory block.");
- return ML_ERROR_STREAMS_PIPE;
+ return status;
}
/**
/* allocate memory if allocate_in_invoke is FALSE */
if (priv->fw->allocate_in_invoke == FALSE) {
output[i].data = g_malloc (output[i].size);
- if (!output[i].data)
+ if (!output[i].data) {
+ g_critical ("Failed to allocate the output tensor.");
goto error;
+ }
}
}