/*LOGD("get recorder msg %s, event %d", recv_msg, event);*/
+ g_mutex_lock(&cb_info->user_cb_mutex[event]);
+
if (cb_info->user_cb[event] == NULL) {
- LOGW("user callback for event %d is not set", event);
- return;
+ if (event != MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM &&
+ event != MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM) {
+ g_mutex_unlock(&cb_info->user_cb_mutex[event]);
+ LOGW("NULL callback for event %d, return here", event);
+ return;
+ } else {
+ LOGW("NULL callback for event %d, NOT return here", event);
+ }
}
switch (event) {
break;
}
- if (!_recorder_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
- LOGE("tbm key %d import failed", tbm_key);
- break;
- }
+ if (cb_info->user_cb[event]) {
+ if (_recorder_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
+ muse_recorder_msg_get(size, recv_msg);
+ muse_recorder_msg_get(format, recv_msg);
+ muse_recorder_msg_get(channel, recv_msg);
+ muse_recorder_msg_get(timestamp, recv_msg);
- muse_recorder_msg_get(size, recv_msg);
- muse_recorder_msg_get(format, recv_msg);
- muse_recorder_msg_get(channel, recv_msg);
- muse_recorder_msg_get(timestamp, recv_msg);
-
- ((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]);
+ ((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]);
- /* release imported bo */
- _recorder_release_imported_bo(&bo);
+ /* release imported bo */
+ _recorder_release_imported_bo(&bo);
+ } else {
+ LOGE("tbm key %d import failed", tbm_key);
+ }
+ }
/* return buffer */
send_msg = muse_core_msg_new(MUSE_RECORDER_API_RETURN_BUFFER,
break;
}
- if (!_recorder_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
- LOGE("tbm key %d import failed", tbm_key);
- break;
- }
+ if (cb_info->user_cb[event]) {
+ if (_recorder_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
+ muse_recorder_msg_get(size, recv_msg);
+ muse_recorder_msg_get(offset, recv_msg);
- muse_recorder_msg_get(size, recv_msg);
- muse_recorder_msg_get(offset, recv_msg);
+ ((recorder_muxed_stream_cb)cb_info->user_cb[event])((void *)bo_handle.ptr,
+ size, (unsigned long long)offset, cb_info->user_data[event]);
- ((recorder_muxed_stream_cb)cb_info->user_cb[event])((void *)bo_handle.ptr,
- size, (unsigned long long)offset, cb_info->user_data[event]);
-
- /* release imported bo */
- _recorder_release_imported_bo(&bo);
+ /* release imported bo */
+ _recorder_release_imported_bo(&bo);
+ } else {
+ LOGE("tbm key %d import failed", tbm_key);
+ }
+ }
/* return buffer */
send_msg = muse_core_msg_new(MUSE_RECORDER_API_RETURN_BUFFER,
}
}
+ g_mutex_unlock(&cb_info->user_cb_mutex[event]);
+
return;
}
g_mutex_init(&cb_info->idle_event_mutex);
g_cond_init(&cb_info->idle_event_cond);
+ for (i = 0 ; i < MUSE_RECORDER_EVENT_TYPE_NUM ; i++)
+ g_mutex_init(&cb_info->user_cb_mutex[i]);
+
/* message handler thread */
if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
_RECORDER_MESSAGE_HANDLER_TYPE_GENERAL, "recorder_msg_handler", cb_info)) {
__destroy_msg_handler_thread(&cb_info->audio_stream_cb_info);
__destroy_msg_handler_thread(&cb_info->muxed_stream_cb_info);
+ for (i = 0 ; i < MUSE_RECORDER_EVENT_TYPE_NUM ; i++)
+ g_mutex_clear(&cb_info->user_cb_mutex[i]);
+
g_mutex_clear(&cb_info->idle_event_mutex);
g_cond_clear(&cb_info->idle_event_cond);
__destroy_msg_handler_thread(&cb_info->audio_stream_cb_info);
__destroy_msg_handler_thread(&cb_info->muxed_stream_cb_info);
+ for (i = 0 ; i < MUSE_RECORDER_EVENT_TYPE_NUM ; i++)
+ g_mutex_clear(&cb_info->user_cb_mutex[i]);
+
g_mutex_clear(&cb_info->idle_event_mutex);
g_cond_clear(&cb_info->idle_event_cond);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = callback;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]);
}
LOGD("ret : 0x%x", ret);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]);
}
LOGD("ret : 0x%x", ret);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = callback;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]);
}
LOGD("ret : 0x%x", ret);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = NULL;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]);
}
LOGD("ret : 0x%x", ret);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = callback;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]);
}
LOGD("ret : 0x%x", ret);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]);
}
LOGD("ret : 0x%x", ret);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = callback;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]);
}
LOGD("ret : 0x%x", ret);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = NULL;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]);
}
LOGD("ret : 0x%x", ret);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = callback;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]);
}
LOGD("ret : 0x%x", ret);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = NULL;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]);
}
LOGD("ret : 0x%x", ret);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_ERROR] = callback;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]);
}
LOGD("ret : 0x%x", ret);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_ERROR] = NULL;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]);
}
LOGD("ret : 0x%x", ret);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = callback;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]);
}
LOGD("ret : 0x%x", ret);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = NULL;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]);
}
LOGD("ret : 0x%x", ret);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = callback;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
}
LOGD("ret : 0x%x", ret);
_recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = NULL;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
}
LOGD("ret : 0x%x", ret);