handle->set_resize = FALSE;
handle->set_rotate = FALSE;
+ /*These are a communicator for thread*/
+ if (!handle->queue)
+ handle->queue = g_async_queue_new();
+
+ if (handle->queue == NULL) {
+ mm_util_error("g_async_queue_new failed");
+ return MM_UTIL_ERROR_INVALID_OPERATION;
+ }
+
return ret;
}
{
mm_util_s *handle = (mm_util_s *) data;
int ret = MM_UTIL_ERROR_NONE;
- gint64 end_time = 0;
+ media_packet_h pop_data = NULL;
if (!handle) {
mm_util_error("[ERROR] - handle");
}
while (!handle->is_finish) {
- end_time = g_get_monotonic_time() + 1 * G_TIME_SPAN_SECOND;
mm_util_debug("waiting...");
- g_mutex_lock(&(handle->thread_mutex));
- if (!g_cond_wait_until(&(handle->thread_cond), &(handle->thread_mutex), end_time)) {
- mm_util_debug("exit loop");
- g_mutex_unlock(&(handle->thread_mutex));
- break;
- }
- mm_util_debug("<=== get run transform thread signal");
- g_mutex_unlock(&(handle->thread_mutex));
+ pop_data = (media_packet_h) g_async_queue_timeout_pop(handle->queue, 300 * G_TIME_SPAN_MILLISECOND);
+ mm_util_debug("get from data or timeout");
- if (handle->is_finish) {
- mm_util_debug("exit loop");
- break;
+ if (pop_data == NULL) {
+ mm_util_error("The data is null");
+ continue;
}
- media_packet_h pop_data = (media_packet_h) g_async_queue_try_pop(handle->queue);
-
- if (!pop_data) {
- mm_util_error("[NULL] Queue data");
- } else {
- ret = __mm_util_transform_exec(handle, pop_data); /* Need to block */
- if (ret == MM_UTIL_ERROR_NONE)
- mm_util_debug("Success - transform_exec");
- else
- mm_util_error("Error - transform_exec");
-
- if (handle->_util_cb->completed_cb) {
- mm_util_debug("completed_cb");
- handle->_util_cb->completed_cb(&handle->dst_packet, ret, handle->_util_cb->user_data);
- mm_util_debug("completed_cb %p", &handle->dst);
- }
+ ret = __mm_util_transform_exec(handle, pop_data); /* Need to block */
+ if (ret == MM_UTIL_ERROR_NONE)
+ mm_util_debug("Success - transform_exec");
+ else
+ mm_util_error("Error - transform_exec");
- __mm_util_handle_refresh(handle);
+ if (handle->_util_cb->completed_cb) {
+ mm_util_debug("completed_cb");
+ handle->_util_cb->completed_cb(&handle->dst_packet, ret, handle->_util_cb->user_data);
+ mm_util_debug("completed_cb %p", &handle->dst);
}
+ __mm_util_handle_refresh(handle);
}
mm_util_debug("exit thread");
+ handle->thread = NULL;
return NULL;
}
return MM_UTIL_ERROR_INVALID_PARAMETER;
}
- g_mutex_init(&(handle->thread_mutex));
-
- /*These are a communicator for thread*/
- if (!handle->queue)
- handle->queue = g_async_queue_new();
- else
- mm_util_error("ERROR - async queue is already created");
-
- g_cond_init(&(handle->thread_cond));
+ if (handle->thread) {
+ mm_util_error("Thread is already created");
+ return MM_UTIL_ERROR_NONE;
+ }
/*create threads*/
handle->thread = g_thread_new("transform_thread", (GThreadFunc)_mm_util_thread_repeate, (gpointer)handle);
return MM_UTIL_ERROR_INVALID_OPERATION;
}
+ mm_util_debug("New thread is created");
+
return ret;
}
/* g_thread_exit(handle->thread); */
if (handle->thread) {
handle->is_finish = TRUE;
- g_mutex_lock(&(handle->thread_mutex));
- g_cond_signal(&(handle->thread_cond));
- mm_util_debug("===> send signal(finish) to transform_thread");
- g_mutex_unlock(&(handle->thread_mutex));
-
g_thread_join(handle->thread);
}
handle->queue = NULL;
}
- g_mutex_clear(&(handle->thread_mutex));
-
- g_cond_clear(&(handle->thread_cond));
-
mm_util_debug("Success - Finalize Handle");
return ret;
return ret;
}
- ret = __mm_util_create_thread(handle);
- if (ret != MM_UTIL_ERROR_NONE) {
- mm_util_error("ERROR - Create thread");
- IMGP_FREE(handle);
- TTRACE_END();
- return ret;
- } else {
- mm_util_debug("Success -__mm_util_create_thread");
- }
-
*imgp_handle = (mm_util_imgp_h)handle;
TTRACE_END();
if (handle->queue) {
mm_util_debug("g_async_queue_push");
g_async_queue_push(handle->queue, GINT_TO_POINTER(src_packet));
- g_mutex_lock(&(handle->thread_mutex));
- g_cond_signal(&(handle->thread_cond));
- mm_util_debug("===> send signal to transform_thread");
- g_mutex_unlock(&(handle->thread_mutex));
+ ret = __mm_util_create_thread(handle);
+ if (ret != MM_UTIL_ERROR_NONE) {
+ mm_util_error("ERROR - Create thread");
+ TTRACE_END();
+ return ret;
+ } else {
+ mm_util_debug("Success -__mm_util_create_thread");
+ }
}
TTRACE_END();
mm_util_s *handle = (mm_util_s *) imgp_handle;
TTRACE_BEGIN("MM_UTILITY:IMGP:DESTROY");
+ mm_util_debug("enter");
if (!handle) {
mm_util_error("[ERROR] - handle");