#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <inttypes.h>
#include <camera_internal.h>
#include <recorder.h>
#include <sound_manager.h>
#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;
int64_t cb_elapsed_time = 0;
int64_t cb_file_size = 0;
- muse_recorder_msg_get(cb_elapsed_time, recv_msg);
- muse_recorder_msg_get(cb_file_size, recv_msg);
+ muse_recorder_msg_get_int64(cb_elapsed_time, recv_msg);
+ muse_recorder_msg_get_int64(cb_file_size, recv_msg);
((recorder_recording_status_cb)cb_info->user_cb[event])((unsigned long long)cb_elapsed_time,
(unsigned long long)cb_file_size,
muse_recorder_msg_get(channel, recv_msg);
muse_recorder_msg_get(timestamp, recv_msg);
+ LOGD("%p, size %d, format %d, channel %d, timestamp %d",
+ bo_handle.ptr, size, format, channel, timestamp);
+
((recorder_audio_stream_cb)cb_info->user_cb[event])((void *)bo_handle.ptr,
size, (audio_sample_type_e)format, channel,
(unsigned int)timestamp, cb_info->user_data[event]);
+ LOGD("returned");
+
/* release imported bo */
_recorder_release_imported_bo(&bo);
} else {
if (cb_info->user_cb[event]) {
if (_recorder_import_tbm_fd(cb_info->bufmgr, tfd, &bo, &bo_handle)) {
muse_recorder_msg_get(size, recv_msg);
- muse_recorder_msg_get(offset, recv_msg);
+ muse_recorder_msg_get_int64(offset, recv_msg);
+
+ LOGD("%p, size %d, offset %"PRId64, bo_handle.ptr, size, offset);
((recorder_muxed_stream_cb)cb_info->user_cb[event])((void *)bo_handle.ptr,
size, (unsigned long long)offset, cb_info->user_data[event]);
+ LOGD("returned");
+
/* release imported bo */
_recorder_release_imported_bo(&bo);
} else {
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 {
rec_idle_event->event = rec_msg->event;
rec_idle_event->cb_info = cb_info;
- strncpy(rec_idle_event->recv_msg, rec_msg->recv_msg, sizeof(rec_idle_event->recv_msg) - 1);
+ strncpy(rec_idle_event->recv_msg, rec_msg->recv_msg, sizeof(rec_idle_event->recv_msg));
/*LOGD("add recorder event[%d, %p] to IDLE", rec_msg->event, rec_idle_event);*/
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;
}
}
-static int _recorder_storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data)
+static bool _recorder_storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data)
{
char **root_directory = (char **)user_data;