From: Jeongmo Yang Date: Mon, 26 Oct 2015 05:43:47 +0000 (+0900) Subject: Release version 0.10.15 X-Git-Tag: accepted/tizen/mobile/20151029.041244~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fmultimedia%2Flibmm-camcorder.git;a=commitdiff_plain;h=3172867195b49aac750a67a2fc46030cd147dc6f Release version 0.10.15 1. Update code for sound focus Change-Id: I2a77603cc0cad414794deb2e3bc4ec4f6edd7821 Signed-off-by: Jeongmo Yang --- diff --git a/packaging/libmm-camcorder.spec b/packaging/libmm-camcorder.spec index 8b57e14..cad4822 100644 --- a/packaging/libmm-camcorder.spec +++ b/packaging/libmm-camcorder.spec @@ -2,7 +2,7 @@ Name: libmm-camcorder Summary: Camera and recorder library -Version: 0.10.14 +Version: 0.10.15 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/include/mm_camcorder_internal.h b/src/include/mm_camcorder_internal.h index 373c893..d186afc 100644 --- a/src/include/mm_camcorder_internal.h +++ b/src/include/mm_camcorder_internal.h @@ -672,6 +672,7 @@ typedef struct mmf_camcorder { int sound_focus_register; /**< Use sound focus internally */ int sound_focus_id; /**< id for sound focus */ int sound_focus_watch_id; /**< id for sound focus watch */ + int acquired_focus; /**< Current acquired focus */ int session_type; /**< Session type */ int session_flags; /**< Session flags */ diff --git a/src/mm_camcorder_attribute.c b/src/mm_camcorder_attribute.c index 51914ee..980e298 100644 --- a/src/mm_camcorder_attribute.c +++ b/src/mm_camcorder_attribute.c @@ -3991,9 +3991,7 @@ bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const mmf_val bool _mmcamcorder_commit_pid_for_sound_focus(MMHandleType handle, int attr_idx, const mmf_value_t *value) { - bool bret = FALSE; - int pid_current = 0; - int pid_new = 0; + int new_pid = 0; int current_state = MM_CAMCORDER_STATE_NONE; mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); @@ -4009,37 +4007,25 @@ bool _mmcamcorder_commit_pid_for_sound_focus(MMHandleType handle, int attr_idx, return FALSE; } - pid_new = value->value.i_val; + new_pid = value->value.i_val; - mm_camcorder_get_attributes(handle, NULL, - MMCAM_PID_FOR_SOUND_FOCUS, &pid_current, - NULL); - - _mmcam_dbg_log("Commit : pid_for_sound_focus - pid new %dm current %d", pid_new, pid_current); + _mmcam_dbg_log("Commit : pid %d, current sound_focus_register %d, sound_focus_id %d", + new_pid, hcamcorder->sound_focus_register, hcamcorder->sound_focus_id); /* unregister sound focus before set new one */ - if (pid_current > 0) { - if (hcamcorder->sound_focus_register) { - if (MM_ERROR_NONE != mm_sound_unregister_focus(hcamcorder->sound_focus_id)) { - _mmcam_dbg_err("mm_sound_unregister_focus[id %d] failed", hcamcorder->sound_focus_id); - } else { - _mmcam_dbg_log("mm_sound_unregister_focus[id %d] done", hcamcorder->sound_focus_id); - } + if (hcamcorder->sound_focus_register && hcamcorder->sound_focus_id > 0) { + if (MM_ERROR_NONE != mm_sound_unregister_focus(hcamcorder->sound_focus_id)) { + _mmcam_dbg_err("mm_sound_unregister_focus[id %d] failed", hcamcorder->sound_focus_id); } else { - _mmcam_dbg_log("no need to unregister sound focus"); + _mmcam_dbg_log("mm_sound_unregister_focus[id %d] done", hcamcorder->sound_focus_id); } - } - - /* register sound focus */ - if (MM_ERROR_NONE == _mm_session_util_read_information(-1, &hcamcorder->session_type, &hcamcorder->session_flags)) { - _mmcam_dbg_log("use sound focus function."); - hcamcorder->sound_focus_register = TRUE; } else { - _mmcam_dbg_log("_mm_session_util_read_information failed. skip sound focus function."); - hcamcorder->sound_focus_register = FALSE; + _mmcam_dbg_log("no need to unregister sound focus"); } + /* register sound focus */ if (hcamcorder->sound_focus_register) { + hcamcorder->sound_focus_id = 0; if (MM_ERROR_NONE != mm_sound_focus_get_id(&hcamcorder->sound_focus_id)) { _mmcam_dbg_err("mm_sound_focus_get_uniq failed"); hcamcorder->error_code = MM_ERROR_POLICY_BLOCKED; @@ -4047,7 +4033,7 @@ bool _mmcamcorder_commit_pid_for_sound_focus(MMHandleType handle, int attr_idx, } if (MM_ERROR_NONE != mm_sound_register_focus_for_session(hcamcorder->sound_focus_id, - pid_new, + new_pid, "media", _mmcamcorder_sound_focus_cb, hcamcorder)) { diff --git a/src/mm_camcorder_internal.c b/src/mm_camcorder_internal.c index 513cd44..37e41c9 100644 --- a/src/mm_camcorder_internal.c +++ b/src/mm_camcorder_internal.c @@ -261,6 +261,33 @@ int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info) hcamcorder->device_type = info->videodev_type; _mmcam_dbg_warn("Device Type : %d", hcamcorder->device_type); + if (MM_ERROR_NONE == _mm_session_util_read_information(-1, &hcamcorder->session_type, &hcamcorder->session_flags)) { + _mmcam_dbg_log("use sound focus function."); + hcamcorder->sound_focus_register = TRUE; + + if (MM_ERROR_NONE != mm_sound_focus_get_id(&hcamcorder->sound_focus_id)) { + _mmcam_dbg_err("mm_sound_focus_get_uniq failed"); + ret = MM_ERROR_POLICY_BLOCKED; + goto _ERR_DEFAULT_VALUE_INIT; + } + + if (MM_ERROR_NONE != mm_sound_register_focus_for_session(hcamcorder->sound_focus_id, + getpid(), + "media", + _mmcamcorder_sound_focus_cb, + hcamcorder)) { + _mmcam_dbg_err("mm_sound_register_focus failed"); + ret = MM_ERROR_POLICY_BLOCKED; + goto _ERR_DEFAULT_VALUE_INIT; + } + + _mmcam_dbg_log("mm_sound_register_focus done - id %d, session type %d, flags 0x%x", + hcamcorder->sound_focus_id, hcamcorder->session_type, hcamcorder->session_flags); + } else { + _mmcam_dbg_log("_mm_session_util_read_information failed. skip sound focus function."); + hcamcorder->sound_focus_register = FALSE; + } + /* Get Camera Configure information from Camcorder INI file */ _mmcamcorder_conf_get_info((MMHandleType)hcamcorder, CONFIGURE_TYPE_MAIN, CONFIGURE_MAIN_FILE, &hcamcorder->conf_main); @@ -540,6 +567,18 @@ int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info) return MM_ERROR_NONE; _ERR_DEFAULT_VALUE_INIT: + /* unregister sound focus */ + if (hcamcorder->sound_focus_register && hcamcorder->sound_focus_id > 0) { + if (MM_ERROR_NONE != mm_sound_unregister_focus(hcamcorder->sound_focus_id)) { + _mmcam_dbg_err("mm_sound_unregister_focus[id %d] failed", hcamcorder->sound_focus_id); + } else { + _mmcam_dbg_log("mm_sound_unregister_focus[id %d] done", hcamcorder->sound_focus_id); + } + } else { + _mmcam_dbg_warn("no need to unregister sound focus[%d, id %d]", + hcamcorder->sound_focus_register, hcamcorder->sound_focus_id); + } + /* Remove attributes */ if (hcamcorder->attributes) { _mmcamcorder_dealloc_attribute((MMHandleType)hcamcorder, hcamcorder->attributes); @@ -725,10 +764,17 @@ int _mmcamcorder_destroy(MMHandleType handle) _mmcamcorder_remove_message_all(handle); /* unregister sound focus */ - if(hcamcorder->sound_focus_register) { - if (MM_ERROR_NONE != mm_sound_unregister_focus(hcamcorder->sound_focus_id)) { - _mmcam_dbg_err("mm_sound_unregister_focus[id %d] failed", hcamcorder->sound_focus_id); + if (hcamcorder->sound_focus_register && hcamcorder->sound_focus_id > 0) { + if (mm_sound_unregister_focus(hcamcorder->sound_focus_id) != MM_ERROR_NONE) { + _mmcam_dbg_err("mm_sound_unregister_focus[id %d] failed", + hcamcorder->sound_focus_id); + } else { + _mmcam_dbg_log("mm_sound_unregister_focus[id %d] done", + hcamcorder->sound_focus_id); } + } else { + _mmcam_dbg_log("no need to unregister sound focus.[%d, id %d]", + hcamcorder->sound_focus_register, hcamcorder->sound_focus_id); } /* release model_name */ @@ -837,7 +883,6 @@ int _mmcamcorder_realize(MMHandleType handle) mm_camcorder_get_attributes(handle, NULL, MMCAM_DISPLAY_SURFACE, &display_surface_type, MMCAM_CAMERA_RECORDING_MOTION_RATE, &motion_rate, - MMCAM_PID_FOR_SOUND_FOCUS, &pid_for_sound_focus, MMCAM_DISPLAY_SHM_SOCKET_PATH, &socket_path, &socket_path_len, NULL); @@ -873,8 +918,21 @@ int _mmcamcorder_realize(MMHandleType handle) vconf_recorder_state, VCONFKEY_RECORDER_STATE_CREATED); } - /* acquire sound focus or set sound focus watch callback */ - if(hcamcorder->sound_focus_register) { + /* sound focus */ + if (hcamcorder->sound_focus_register) { + mm_camcorder_get_attributes(handle, NULL, + MMCAM_PID_FOR_SOUND_FOCUS, &pid_for_sound_focus, + NULL); + + if (pid_for_sound_focus == 0) { + pid_for_sound_focus = getpid(); + _mmcam_dbg_warn("pid for sound focus is not set, use my pid %d", pid_for_sound_focus); + } + + /* acquire sound focus or set sound focus watch callback */ + hcamcorder->acquired_focus = 0; + hcamcorder->sound_focus_watch_id = 0; + /* check session flags */ if (hcamcorder->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS) { /* acquire sound focus */ @@ -886,39 +944,37 @@ int _mmcamcorder_realize(MMHandleType handle) /* TODO: MM_ERROR_POLICY_BLOCKED_BY_CALL, MM_ERROR_POLICY_BLOCKED_BY_ALARM*/ ret = MM_ERROR_POLICY_BLOCKED; - goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK; } + + hcamcorder->acquired_focus = FOCUS_FOR_BOTH; } else if (hcamcorder->session_flags & MM_SESSION_OPTION_UNINTERRUPTIBLE) { /* do nothing */ _mmcam_dbg_log("SESSION_UNINTERRUPTIBLE - do nothing for sound focus"); } else { /* set sound focus watch callback */ - if (pid_for_sound_focus == 0) { - _mmcam_dbg_warn("pid for sound focus is not set, so call getpid"); - pid_for_sound_focus = getpid(); - } - _mmcam_dbg_log("ETC - set sound focus watch callback - pid %d", pid_for_sound_focus); ret_sound = mm_sound_set_focus_watch_callback_for_session(pid_for_sound_focus, - FOCUS_FOR_BOTH, - (mm_sound_focus_changed_watch_cb)_mmcamcorder_sound_focus_watch_cb, - hcamcorder, - &hcamcorder->sound_focus_watch_id); + FOCUS_FOR_BOTH, + (mm_sound_focus_changed_watch_cb)_mmcamcorder_sound_focus_watch_cb, + hcamcorder, + &hcamcorder->sound_focus_watch_id); if (ret_sound != MM_ERROR_NONE) { _mmcam_dbg_err("mm_sound_set_focus_watch_callback failed [0x%x]", ret_sound); /* TODO: MM_ERROR_POLICY_BLOCKED_BY_CALL, MM_ERROR_POLICY_BLOCKED_BY_ALARM*/ ret = MM_ERROR_POLICY_BLOCKED; - goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK; } _mmcam_dbg_log("sound focus watch cb id %d", hcamcorder->sound_focus_watch_id); } + } else { + _mmcam_dbg_log("no need to register sound focus"); } + /* alloc sub context */ hcamcorder->sub_context = _mmcamcorder_alloc_subcontext(hcamcorder->type); if(!hcamcorder->sub_context) { @@ -1057,13 +1113,26 @@ _ERR_CAMCORDER_CMD: _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK: _MMCAMCORDER_UNLOCK_CMD(hcamcorder); - if (hcamcorder->sound_focus_watch_id > 0) { - ret_sound = mm_sound_unset_focus_watch_callback(hcamcorder->sound_focus_watch_id); - if (ret_sound != MM_ERROR_NONE) { - _mmcam_dbg_warn("mm_sound_unset_focus_watch_callback failed [0x%x]", ret_sound); + if (hcamcorder->sound_focus_register) { + if (hcamcorder->sound_focus_watch_id > 0) { + if (mm_sound_unset_focus_watch_callback(hcamcorder->sound_focus_watch_id) != MM_ERROR_NONE) { + _mmcam_dbg_warn("mm_sound_unset_focus_watch_callback[id %d] failed", + hcamcorder->sound_focus_watch_id); + } else { + _mmcam_dbg_warn("mm_sound_unset_focus_watch_callback[id %d] done", + hcamcorder->sound_focus_watch_id); + } } - hcamcorder->sound_focus_watch_id = 0; + if (hcamcorder->acquired_focus > 0) { + if (mm_sound_release_focus(0, hcamcorder->acquired_focus, NULL) != MM_ERROR_NONE) { + _mmcam_dbg_err("mm_sound_release_focus[focus %d] failed", + hcamcorder->acquired_focus); + } else { + _mmcam_dbg_err("mm_sound_release_focus[focus %d] done", + hcamcorder->acquired_focus); + } + } } _ERR_CAMCORDER_CMD_PRECON: @@ -1116,39 +1185,42 @@ int _mmcamcorder_unrealize(MMHandleType handle) /* Deinitialize main context member */ hcamcorder->command = NULL; - /* check who calls unrealize. it's no need to do nothing if caller is sound focus callback */ - if (hcamcorder->state_change_by_system != _MMCAMCORDER_STATE_CHANGE_BY_ASM) { - /* release sound focus or unset sound focus watch callback */ - if(hcamcorder->sound_focus_register) { - int ret_sound = MM_ERROR_NONE; + _mmcam_dbg_log("focus register %d, session flag 0x%x, state_change_by_system %d", + hcamcorder->sound_focus_register, hcamcorder->session_flags, hcamcorder->state_change_by_system); - /* check session flags */ - if (hcamcorder->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS) { - /* release sound focus */ - _mmcam_dbg_log("PAUSE_OTHERS - release sound focus"); + /* release sound focus or unset sound focus watch callback */ + if (hcamcorder->sound_focus_register) { + int ret_sound = MM_ERROR_NONE; - ret_sound = mm_sound_release_focus(0, FOCUS_FOR_BOTH, NULL); - if (ret_sound != MM_ERROR_NONE) { - _mmcam_dbg_warn("mm_sound_release_focus failed [0x%x]", ret_sound); - } - } else if (hcamcorder->session_flags & MM_SESSION_OPTION_UNINTERRUPTIBLE) { - /* do nothing */ - _mmcam_dbg_log("SESSION_UNINTERRUPTIBLE - do nothing for sound focus"); - } else { - /* unset sound focus watch callback */ - _mmcam_dbg_log("ETC - unset sound focus watch callback - id %d", hcamcorder->sound_focus_watch_id); + _mmcam_dbg_log("state_change_by_system %d, session flag 0x%x, acquired_focus %d, sound_focus_id %d, sound_focus_watch_id %d", + hcamcorder->state_change_by_system, hcamcorder->session_flags, hcamcorder->acquired_focus, + hcamcorder->sound_focus_id, hcamcorder->sound_focus_watch_id); - if (hcamcorder->sound_focus_watch_id > 0) { - ret_sound = mm_sound_unset_focus_watch_callback(hcamcorder->sound_focus_watch_id); - if (ret_sound != MM_ERROR_NONE) { - _mmcam_dbg_warn("mm_sound_unset_focus_watch_callback failed [0x%x]", ret_sound); - } - } else { - _mmcam_dbg_warn("invalid sound focus id %d", hcamcorder->sound_focus_watch_id); - } + if (hcamcorder->state_change_by_system != _MMCAMCORDER_STATE_CHANGE_BY_ASM && + hcamcorder->sound_focus_watch_id > 0) { + ret_sound = mm_sound_unset_focus_watch_callback(hcamcorder->sound_focus_watch_id); + if (ret_sound != MM_ERROR_NONE) { + _mmcam_dbg_warn("mm_sound_unset_focus_watch_callback failed [0x%x]", + ret_sound); + } else { + _mmcam_dbg_warn("mm_sound_unset_focus_watch_callback done"); + } + } else { + _mmcam_dbg_warn("no need to unset watch callback.[state_change_by_system %d, sound_focus_watch_id %d]", + hcamcorder->state_change_by_system, hcamcorder->sound_focus_watch_id); + } - hcamcorder->sound_focus_watch_id = 0; + if (hcamcorder->acquired_focus > 0) { + ret_sound = mm_sound_release_focus(0, hcamcorder->acquired_focus, NULL); + if (ret_sound != MM_ERROR_NONE) { + _mmcam_dbg_warn("mm_sound_release_focus failed [0x%x]", + ret_sound); + } else { + _mmcam_dbg_log("mm_sound_release_focus done"); } + } else { + _mmcam_dbg_warn("no need to release focus - current acquired focus %d", + hcamcorder->acquired_focus); } } @@ -3043,7 +3115,10 @@ void _mmcamcorder_sound_focus_cb(int id, mm_sound_focus_type_e focus_type, _MMCAMCORDER_LOCK_ASM(hcamcorder); if (focus_state == FOCUS_IS_RELEASED) { - _mmcam_dbg_log("FOCUS is released : Stop pipeline[state:%d]", current_state); + hcamcorder->acquired_focus &= ~focus_type; + + _mmcam_dbg_log("FOCUS is released [type %d, remained focus %d] : Stop pipeline[state:%d]", + focus_type, hcamcorder->acquired_focus, current_state); __mmcamcorder_force_stop(hcamcorder); @@ -3051,7 +3126,10 @@ void _mmcamcorder_sound_focus_cb(int id, mm_sound_focus_type_e focus_type, } else if (focus_state == FOCUS_IS_ACQUIRED) { _MMCamcorderMsgItem msg; - _mmcam_dbg_log("FOCUS is acquired"); + hcamcorder->acquired_focus |= focus_type; + + _mmcam_dbg_log("FOCUS is acquired [type %d, new focus %d]", + focus_type, hcamcorder->acquired_focus); msg.id = MM_MESSAGE_READY_TO_RESUME; _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);