#ifdef LOG_TAG
#undef LOG_TAG
#endif
-#define LOG_TAG "TIZEN_N_RECORDER"
-#define MODULE_NAME "recorder"
+#define LOG_TAG "TIZEN_N_RECORDER"
+#define MODULE_NAME "recorder"
/* for device changed callback */
static GMutex g_rec_dev_state_changed_cb_lock;
if (cb_info->api_waiting[api] > 0) {
cb_info->api_ret[api] = ret;
- cb_info->api_activating[api] = 1;
+ cb_info->api_activating[api] = TRUE;
g_cond_signal(&cb_info->api_cond[api]);
} else {
if (muse_recorder_msg_get(ret, rec_msg->recv_msg)) {
if (cb_info->api_waiting[api] > 0) {
cb_info->api_ret[api] = ret;
- cb_info->api_activating[api] = 1;
+ cb_info->api_activating[api] = TRUE;
- /*LOGD("recorder api %d - return 0x%x", ret);*/
+ /*LOGD("recorder api %d - return 0x%x", api, ret);*/
g_cond_signal(&cb_info->api_cond[api]);
} else {
g_mutex_lock(&(cb_info->api_mutex[api]));
- if (cb_info->api_activating[api] == 0) {
+ LOGD("api [%d], timeout [%d sec]", api, time_out);
+
+ end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
+
+ while (!cb_info->api_activating[api]) {
if (time_out == RECORDER_CB_NO_TIMEOUT) {
- LOGW("wait for api %d", api);
g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
- ret = cb_info->api_ret[api];
- cb_info->api_activating[api] = 0;
- LOGW("api %d returned 0x%x", api, ret);
- } else {
- end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
- if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
- ret = cb_info->api_ret[api];
- cb_info->api_activating[api] = 0;
- /*LOGD("return value : 0x%x", ret);*/
- } else {
- ret = RECORDER_ERROR_INVALID_OPERATION;
- LOGE("api %d was TIMED OUT!", api);
- }
+ LOGW("api %d returned 0x%x", api, cb_info->api_ret[api]);
+ } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
+ LOGE("api %d was TIMED OUT!", api);
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _CB_RETURN_END;
}
- } else {
- ret = cb_info->api_ret[api];
- cb_info->api_activating[api] = 0;
- /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
+ if (!cb_info->api_activating[api])
+ LOGW("invalid signal received, wait again...");
}
- if (ret != RECORDER_ERROR_NONE)
- LOGE("ERROR : api %d - ret 0x%x", api, ret);
+ ret = cb_info->api_ret[api];
+ cb_info->api_activating[api] = FALSE;
+_CB_RETURN_END:
g_mutex_unlock(&(cb_info->api_mutex[api]));
+ if (ret != RECORDER_ERROR_NONE)
+ LOGE("ERROR : api %d - ret 0x%x", api, ret);
+
return ret;
}