static OMX_ERRORTYPE _ctx_init (cc_ctx_t * app_ctx) { check_common_context_t *p_ctx = tiz_mem_alloc (sizeof (check_common_context_t)); if (!p_ctx) { return OMX_ErrorInsufficientResources; } p_ctx->signaled = OMX_FALSE; if (tiz_mutex_init (&p_ctx->mutex)) { tiz_mem_free (p_ctx); return OMX_ErrorInsufficientResources; } if (tiz_cond_init (&p_ctx->cond)) { tiz_mutex_destroy (&p_ctx->mutex); tiz_mem_free (p_ctx); return OMX_ErrorInsufficientResources; } * app_ctx = p_ctx; return OMX_ErrorNone; }
void tiz_rcfile_destroy (tiz_rcfile_t *p_rc) { keyval_t *p_kv_lst = NULL; keyval_t *p_kvt = NULL; value_t *p_val_lst = NULL; if (NULL == p_rc) { return; } p_kv_lst = p_rc->p_keyvals; while (p_kv_lst) { value_t *p_vt = NULL; TIZ_LOG (TIZ_PRIORITY_TRACE, "Deleting Key [%s]", p_kv_lst->p_key); tiz_mem_free (p_kv_lst->p_key); p_val_lst = p_kv_lst->p_value_list; while (p_val_lst) { TIZ_LOG (TIZ_PRIORITY_TRACE, "Deleting Val [%s]", p_val_lst->p_value); p_vt = p_val_lst; p_val_lst = p_val_lst->p_next; tiz_mem_free (p_vt->p_value); tiz_mem_free (p_vt); } p_kvt = p_kv_lst; p_kv_lst = p_kv_lst->p_next; tiz_mem_free (p_kvt); } tiz_mem_free (p_rc); }
static void destroy_lst (tiz_shuffle_lst_t *ap_shuffle_lst) { if (ap_shuffle_lst) { tiz_mem_free (ap_shuffle_lst->p_lst); } tiz_mem_free (ap_shuffle_lst); }
static void teardown (void) { tiz_mem_free (pg_rmdb_path); tiz_mem_free (pg_sqlite_script); tiz_mem_free (pg_init_script); tiz_mem_free (pg_rmd_path); tiz_mem_free (pg_dump_script); }
void tiz_vector_destroy (tiz_vector_t * p_vec) { TIZ_LOG (TIZ_PRIORITY_TRACE, "Destroying vector [%p]", p_vec); if (p_vec) { utarray_free (p_vec->p_uta); tiz_mem_free (p_vec->p_icd); tiz_mem_free (p_vec); } }
static inline void dealloc_data_stores (/*@special@ */ oggdmux_prc_t * ap_prc) /*@releases ap_prc->p_aud_store_, ap_prc->p_vid_store_ @ */ /*@ensures isnull ap_prc->p_aud_store_, ap_prc->p_vid_store_ @ */ { assert (ap_prc); tiz_mem_free (ap_prc->p_aud_store_); tiz_mem_free (ap_prc->p_vid_store_); ap_prc->p_aud_store_ = NULL; ap_prc->p_vid_store_ = NULL; ap_prc->aud_store_size_ = 0; ap_prc->vid_store_size_ = 0; ap_prc->aud_store_offset_ = 0; ap_prc->vid_store_offset_ = 0; }
END_TEST START_TEST (test_vector_push_back_vector) { OMX_U32 i = 0; OMX_ERRORTYPE error = OMX_ErrorNone; int *p_item = NULL; tiz_vector_t *p_vector = NULL; tiz_vector_t *p_vector2 = NULL; TIZ_LOG (TIZ_PRIORITY_TRACE, "test_vector_push_back_vector"); error = tiz_vector_init (&p_vector, sizeof(int*)); error = tiz_vector_init (&p_vector2, sizeof(tiz_vector_t*)); fail_if (error != OMX_ErrorNone); for (i = 0; i < 10; i++) { p_item = (int *) tiz_mem_alloc (sizeof (int)); fail_if (p_item == NULL); *p_item = i; error = tiz_vector_push_back (p_vector, &p_item); fail_if (error != OMX_ErrorNone); p_item = *(int **) tiz_vector_back (p_vector); fail_if (*p_item != i); } TIZ_LOG (TIZ_PRIORITY_TRACE, "vector length %d", tiz_vector_length (p_vector)); fail_if (10 != tiz_vector_length (p_vector)); TIZ_LOG (TIZ_PRIORITY_TRACE, "pushing vector [%p] [%p]", p_vector, &p_vector); tiz_vector_push_back (p_vector2, &p_vector); p_vector = *(tiz_vector_t **) tiz_vector_back (p_vector2); TIZ_LOG (TIZ_PRIORITY_TRACE, "received vector [%p] [%p] [%p]", p_vector, &p_vector, *(tiz_vector_t **) p_vector); for (i = 0; i < 10; i++) { fail_if (10 - i != tiz_vector_length (p_vector)); p_item = * (int **) tiz_vector_back (p_vector); fail_if (*p_item != 10 - i - 1); TIZ_LOG (TIZ_PRIORITY_TRACE, "received int [%d]", *p_item); tiz_vector_pop_back (p_vector); tiz_mem_free(p_item); } fail_if (0 != tiz_vector_length (p_vector)); tiz_vector_destroy (p_vector); }
static void *httpr_mp3port_dtor (void *ap_obj) { httpr_mp3port_t *p_obj = ap_obj; assert (NULL != p_obj); tiz_mem_free (p_obj->p_stream_title_); return super_dtor (typeOf (ap_obj, "httprmp3port"), ap_obj); }
OMX_ERRORTYPE tiz_vector_init (tiz_vector_t ** app_vector, size_t a_elem_size) { tiz_vector_t * p_vec = NULL; assert (app_vector); assert (a_elem_size > 0); if (NULL == (p_vec = (tiz_vector_t *) tiz_mem_calloc (1, sizeof (tiz_vector_t)))) { return OMX_ErrorInsufficientResources; } if (NULL == (p_vec->p_icd = (UT_icd *) tiz_mem_calloc (1, sizeof (UT_icd)))) { tiz_mem_free (p_vec); return OMX_ErrorInsufficientResources; } p_vec->p_icd->sz = a_elem_size; utarray_new (p_vec->p_uta, p_vec->p_icd); *app_vector = p_vec; TIZ_LOG (TIZ_PRIORITY_TRACE, "Initializing vector [%p] with elem size [%d]", p_vec, a_elem_size); return OMX_ErrorNone; }
static inline void delete_url (cc_http_prc_t * ap_prc) { assert (ap_prc); tiz_mem_free (ap_prc->p_content_uri_); ap_prc->p_content_uri_ = NULL; }
static bool refresh_rm_db (void) { bool rv = false; /* Re-fresh the rm db */ size_t total_len = strlen (pg_init_script) + strlen (pg_sqlite_script) + strlen (pg_rmdb_path) + 4; char *p_cmd = tiz_mem_calloc (1, total_len); if (p_cmd) { snprintf(p_cmd, total_len -1, "%s %s %s", pg_init_script, pg_sqlite_script, pg_rmdb_path); if (-1 != system (p_cmd)) { TIZ_LOG(TIZ_TRACE, "Successfully run [%s] script...", p_cmd); rv = true; } else { TIZ_LOG(TIZ_TRACE, "Error while executing db init shell script..."); } tiz_mem_free (p_cmd); } return rv; }
static void pcm_port_free_hook (OMX_PTR ap_buf, OMX_PTR ap_port_priv, void *ap_args) { TIZ_LOG (TIZ_PRIORITY_TRACE, "Test Component Free Hook : ap_buf[%p]", ap_buf); assert (ap_buf); tiz_mem_free (ap_buf); }
static void check_map_free_f (OMX_PTR ap_key, OMX_PTR ap_value) { TIZ_LOG (TIZ_PRIORITY_TRACE, "key [%d] value [%d]", *((int*)ap_key), *((int*)ap_value)); tiz_mem_free (ap_key); }
static inline void delete_uri (dirble_prc_t * ap_prc) { assert (ap_prc); tiz_mem_free (ap_prc->p_uri_param_); ap_prc->p_uri_param_ = NULL; }
static bool dump_rmdb (const char * p_dest_path) { bool rv = false; /* Dump the rm db */ size_t total_len = strlen (pg_dump_script) + strlen (pg_rmdb_path) + strlen (p_dest_path) + 4; char *p_cmd = tiz_mem_calloc (1, total_len); if (p_cmd) { snprintf(p_cmd, total_len -1, "%s %s %s", pg_dump_script, pg_rmdb_path, p_dest_path); if (-1 != system (p_cmd)) { TIZ_LOG(TIZ_TRACE, "Successfully run [%s] script...", p_cmd); rv = true; } else { TIZ_LOG(TIZ_TRACE, "Error while executing db dump shell script..."); } tiz_mem_free (p_cmd); } return rv; }
END_TEST START_TEST (test_pqueue_removep) { OMX_S32 i; OMX_ERRORTYPE error = OMX_ErrorNone; tiz_pqueue_t *p_queue = NULL; OMX_PTR p_received = NULL; int *p_item = NULL; int *p_item_cat_one = NULL; TIZ_LOG (TIZ_TRACE, "test_pqueue_removep"); error = tiz_pqueue_init (&p_queue, 2, &pqueue_cmp, NULL, "tizkrn"); fail_if (error != OMX_ErrorNone); error = tiz_pqueue_first (p_queue, &p_received); fail_if (error != OMX_ErrorNoMore); for (i = 2; i >= 0; i--) { p_item = (int *) tiz_mem_alloc (sizeof (int)); fail_if (p_item == NULL); *p_item = i; error = tiz_pqueue_send (p_queue, p_item, i); fail_if (error != OMX_ErrorNone); if (1 == i) { p_item_cat_one = p_item; } } tiz_pqueue_dump (p_queue, &pqueue_dump_item); error = tiz_pqueue_removep (p_queue, p_item_cat_one, 1); fail_if (error != OMX_ErrorNone); fail_if (tiz_pqueue_length (p_queue) != 2); tiz_pqueue_dump (p_queue, &pqueue_dump_item); for (i = 0; i < 2; i++) { error = tiz_pqueue_receive (p_queue, &p_received); fail_if (error != OMX_ErrorNone); p_item = (int *) p_received; TIZ_LOG (TIZ_TRACE, "*p_item [%d]", *p_item); if (0 == i) fail_if (*p_item != 0); if (1 == i) fail_if (*p_item != 2); tiz_mem_free (p_received); } tiz_pqueue_destroy (p_queue); }
static void os_map_free_func (OMX_PTR ap_key, OMX_PTR ap_value) { /* Don't bother deleting the keys here as they are allocated from the chunk of memory provided by the small object allocator, which gets released when the component is deinited. */ tiz_mem_free (ap_value); }
static inline void dealloc_uri (/*@special@ */ oggdmux_prc_t * ap_prc) /*@releases ap_prc->p_uri_ @ */ /*@ensures isnull ap_prc->p_uri_ @ */ { assert (ap_prc); tiz_mem_free (ap_prc->p_uri_); ap_prc->p_uri_ = NULL; }
END_TEST START_TEST (test_pqueue_send_and_receive_one_group) { OMX_U32 i; OMX_PTR p_received = NULL; OMX_ERRORTYPE error = OMX_ErrorNone; int *p_item = NULL; tiz_pqueue_t *p_queue = NULL; tiz_soa_t *p_soa = NULL; TIZ_LOG (TIZ_TRACE, "test_pqueue_send_and_receive_one_group"); fail_if (tiz_soa_init (&p_soa) != OMX_ErrorNone); error = tiz_pqueue_init (&p_queue, 0, &pqueue_cmp, p_soa, "tizkrn"); fail_if (error != OMX_ErrorNone); for (i = 0; i < 10; i++) { p_item = (int *) tiz_mem_alloc (sizeof (int)); fail_if (p_item == NULL); *p_item = i; error = tiz_pqueue_send (p_queue, p_item, 0); fail_if (error != OMX_ErrorNone); } TIZ_LOG (TIZ_TRACE, "queue length %d", tiz_pqueue_length (p_queue)); fail_if (10 != tiz_pqueue_length (p_queue)); for (i = 0; i <= 10; i++) { error = tiz_pqueue_receive (p_queue, &p_received); if (i > 9) { fail_if (error != OMX_ErrorNoMore); } else { fail_if (error != OMX_ErrorNone); } fail_if (p_received == NULL); p_item = (int *) p_received; if (i < 9) { TIZ_LOG (TIZ_TRACE, "item [%d]", *p_item); fail_if (*p_item != i); tiz_mem_free (p_received); } } tiz_pqueue_destroy (p_queue); tiz_soa_destroy (p_soa); }
static OMX_ERRORTYPE _ctx_init (cc_ctx_t * app_ctx) { int i; check_common_context_t *p_ctx = tiz_mem_calloc (1, sizeof (check_common_context_t)); if (!p_ctx) { return OMX_ErrorInsufficientResources; } for (i=0 ; i < MAX_EVENTS ; i++) { p_ctx->signaled[i] = OMX_FALSE; p_ctx->event[i] = OMX_EventMax; } if (tiz_mutex_init (&p_ctx->mutex)) { tiz_mem_free (p_ctx); return OMX_ErrorInsufficientResources; } if (tiz_cond_init (&p_ctx->cond)) { tiz_mutex_destroy (&p_ctx->mutex); tiz_mem_free (p_ctx); return OMX_ErrorInsufficientResources; } p_ctx->state = OMX_StateMax; p_ctx->p_hdr = NULL; p_ctx->flags = 0; p_ctx->port = 0; p_ctx->index = 0; * app_ctx = p_ctx; return OMX_ErrorNone; }
static inline void dealloc_temp_data_store ( /*@special@ */ vorbisd_prc_t *ap_prc) /*@releases ap_prc->p_store_@ */ /*@ensures isnull ap_prc->p_store_@ */ { assert (NULL != ap_prc); tiz_mem_free (ap_prc->p_store_); ap_prc->p_store_ = NULL; ap_prc->store_size_ = 0; ap_prc->store_offset_ = 0; }
static void print_track_info (mp4dmuxflt_prc_t * ap_prc, const MP4TrackId tid) { assert (ap_prc); assert (ap_prc->mp4v2_hdl_ != MP4_INVALID_FILE_HANDLE); if (MP4_INVALID_TRACK_ID != tid) { char * p_track_nfo = MP4Info (ap_prc->mp4v2_hdl_, tid); TIZ_DEBUG (handleOf (ap_prc), "track info: ", (p_track_nfo ? p_track_nfo : "")); tiz_mem_free (p_track_nfo); } }
static bool refresh_rm_db (void) { bool rv = false; const char *p_rmdb_path = NULL; const char *p_sqlite_path = NULL; const char *p_init_path = NULL; const char *p_rmd_path = NULL; p_rmdb_path = tiz_rcfile_get_value("resource-management", "rmdb"); p_sqlite_path = tiz_rcfile_get_value("resource-management", "rmdb.sqlite_script"); p_init_path = tiz_rcfile_get_value("resource-management", "rmdb.init_script"); p_rmd_path = tiz_rcfile_get_value("resource-management", "rmd.path"); if (!p_rmdb_path || !p_sqlite_path || !p_init_path || !p_rmd_path) { TIZ_LOG(TIZ_PRIORITY_TRACE, "Test data not available..."); } else { pg_rmd_path = strndup (p_rmd_path, PATH_MAX); TIZ_LOG(TIZ_PRIORITY_TRACE, "RM daemon [%s] ...", pg_rmd_path); /* Re-fresh the rm db */ size_t total_len = strlen (p_init_path) + strlen (p_sqlite_path) + strlen (p_rmdb_path) + 4; char *p_cmd = tiz_mem_calloc (1, total_len); if (p_cmd) { snprintf(p_cmd, total_len -1, "%s %s %s", p_init_path, p_sqlite_path, p_rmdb_path); if (-1 != system (p_cmd)) { TIZ_LOG(TIZ_PRIORITY_TRACE, "Successfully run [%s] script...", p_cmd); rv = true; } else { TIZ_LOG(TIZ_PRIORITY_TRACE, "Error while executing db init shell script..."); } tiz_mem_free (p_cmd); } } return rv; }
static void teardown (void) { int error = 0; if (g_rmd_pid) { error = kill (g_rmd_pid, SIGTERM); fail_if (error == -1); } tiz_mem_free (pg_rmd_path); }
static void obtain_audio_encoding_from_headers (scloud_prc_t * ap_prc, const char * ap_header, const size_t a_size) { assert (ap_prc); assert (ap_header); { const char * p_end = ap_header + a_size; const char * p_value = (const char *) memchr (ap_header, ':', a_size); char name[64]; if (p_value && (size_t) (p_value - ap_header) < sizeof (name)) { memcpy (name, ap_header, p_value - ap_header); name[p_value - ap_header] = 0; /* skip the colon */ ++p_value; /* strip the value */ while (p_value < p_end && !is_valid_character (*p_value)) { ++p_value; } while (p_end > p_value && !is_valid_character (p_end[-1])) { --p_end; } { char * p_info = tiz_mem_calloc (1, (p_end - p_value) + 1); memcpy (p_info, p_value, p_end - p_value); p_info[(p_end - p_value)] = '\0'; TIZ_TRACE (handleOf (ap_prc), "header name : [%s]", name); TIZ_TRACE (handleOf (ap_prc), "header value : [%s]", p_info); if (strncasecmp (name, "Content-Type", 12) == 0) { obtain_coding_type (ap_prc, p_info); /* Now set the new coding type value on the output port */ (void) set_audio_coding_on_port (ap_prc); } else if (strncasecmp (name, "Content-Length", 14) == 0) { obtain_content_length (ap_prc, p_info); } tiz_mem_free (p_info); } } } }
static OMX_ERRORTYPE httpr_mp3port_SetConfig (const void *ap_obj, OMX_HANDLETYPE ap_hdl, OMX_INDEXTYPE a_index, OMX_PTR ap_struct) { httpr_mp3port_t *p_obj = (httpr_mp3port_t *)ap_obj; OMX_ERRORTYPE rc = OMX_ErrorNone; TIZ_TRACE (ap_hdl, "[%s]...", tiz_idx_to_str (a_index)); assert (NULL != p_obj); if (OMX_TizoniaIndexConfigIcecastMetadata == a_index) { OMX_TIZONIA_ICECASTMETADATATYPE *p_metadata = (OMX_TIZONIA_ICECASTMETADATATYPE *)ap_struct; OMX_U32 stream_title_len = strnlen ((char *)p_metadata->cStreamTitle, OMX_TIZONIA_MAX_SHOUTCAST_METADATA_SIZE + 1); if (stream_title_len > OMX_TIZONIA_MAX_SHOUTCAST_METADATA_SIZE) { rc = OMX_ErrorBadParameter; } else { TIZ_TRACE (ap_hdl, "stream_title_len [%d] Stream title [%s]...", stream_title_len, p_metadata->cStreamTitle); tiz_mem_free (p_obj->p_stream_title_); p_obj->p_stream_title_ = tiz_mem_calloc (1, stream_title_len + 1); if (NULL != p_obj->p_stream_title_) { strncpy (p_obj->p_stream_title_, (char *)p_metadata->cStreamTitle, stream_title_len); p_obj->p_stream_title_[stream_title_len] = '\000'; } TIZ_TRACE (ap_hdl, "stream_title_len [%d] Stream title [%s]...", stream_title_len, p_obj->p_stream_title_); } } else { /* Delegate to the base port */ rc = super_SetConfig (typeOf (ap_obj, "httprmp3port"), ap_obj, ap_hdl, a_index, ap_struct); } return rc; }
static OMX_ERRORTYPE fr_proc_deallocate_resources (void *ap_obj) { fr_prc_t *p_obj = ap_obj; assert (ap_obj); if (p_obj->p_file_) { fclose (p_obj->p_file_); p_obj->p_file_ = NULL; } tiz_mem_free (p_obj->p_uri_param_); p_obj->p_uri_param_ = NULL; return OMX_ErrorNone; }
static void * fr_proc_dtor (void *ap_obj) { fr_prc_t *p_obj = ap_obj; if (p_obj->p_file_) { fclose (p_obj->p_file_); } if (p_obj->p_uri_param_) { tiz_mem_free (p_obj->p_uri_param_); } return super_dtor (frprc, ap_obj); }
static OMX_ERRORTYPE httpr_prc_config_change (const void * ap_prc, const OMX_U32 a_pid, const OMX_INDEXTYPE a_config_idx) { const httpr_prc_t * p_prc = ap_prc; OMX_ERRORTYPE rc = OMX_ErrorNone; assert (ap_prc); if (p_prc->p_server_ && OMX_TizoniaIndexConfigIcecastMetadata == a_config_idx && ARATELIA_HTTP_RENDERER_PORT_INDEX == a_pid) { OMX_TIZONIA_ICECASTMETADATATYPE * p_metadata = (OMX_TIZONIA_ICECASTMETADATATYPE *) tiz_mem_calloc ( 1, sizeof (OMX_TIZONIA_ICECASTMETADATATYPE) + OMX_TIZONIA_MAX_SHOUTCAST_METADATA_SIZE + 1); tiz_check_null_ret_oom (p_metadata); /* Retrieve the updated icecast metadata from the input port */ TIZ_INIT_OMX_PORT_STRUCT (*p_metadata, ARATELIA_HTTP_RENDERER_PORT_INDEX); p_metadata->nSize = sizeof (OMX_TIZONIA_ICECASTMETADATATYPE) + OMX_TIZONIA_MAX_SHOUTCAST_METADATA_SIZE; if (OMX_ErrorNone != (rc = tiz_api_GetConfig ( tiz_get_krn (handleOf (p_prc)), handleOf (p_prc), OMX_TizoniaIndexConfigIcecastMetadata, p_metadata))) { TIZ_ERROR (handleOf (p_prc), "[%s] : Error retrieving " "OMX_TizoniaIndexConfigIcecastMetadata from port", tiz_err_to_str (rc)); } else { httpr_srv_set_stream_title (p_prc->p_server_, p_metadata->cStreamTitle); } tiz_mem_free (p_metadata); p_metadata = NULL; } return rc; }
END_TEST START_TEST (test_vector_push_and_pop_length_front_back_pointers) { OMX_U32 i; OMX_ERRORTYPE error = OMX_ErrorNone; int *p_item = NULL; tiz_vector_t *p_vector = NULL; TIZ_LOG (TIZ_PRIORITY_TRACE, "test_vector_push_and_pop_length_front_back_pointers"); error = tiz_vector_init (&p_vector, sizeof(int*)); fail_if (error != OMX_ErrorNone); for (i = 0; i < 10; i++) { p_item = (int *) tiz_mem_alloc (sizeof (int)); fail_if (p_item == NULL); *p_item = i; error = tiz_vector_push_back (p_vector, &p_item); fail_if (error != OMX_ErrorNone); p_item = *(int **) tiz_vector_back (p_vector); fail_if (*p_item != i); } TIZ_LOG (TIZ_PRIORITY_TRACE, "vector length %d", tiz_vector_length (p_vector)); fail_if (10 != tiz_vector_length (p_vector)); for (i = 0; i < 10; i++) { fail_if (10 - i != tiz_vector_length (p_vector)); p_item = *(int **) tiz_vector_back (p_vector); fail_if (*p_item != 10 - i - 1); tiz_vector_pop_back (p_vector); tiz_mem_free(p_item); } fail_if (0 != tiz_vector_length (p_vector)); tiz_vector_destroy (p_vector); }