}
#ifdef _MMCAMCORDER_MURPHY_SUPPORT
+ /* set camcorder handle */
+ hcamcorder->resource_manager.id = MM_CAMCORDER_RESOURCE_ID_MAIN;
+ hcamcorder->resource_manager.hcamcorder = hcamcorder;
+ hcamcorder->resource_manager_sub.id = MM_CAMCORDER_RESOURCE_ID_SUB;
+ hcamcorder->resource_manager_sub.hcamcorder = hcamcorder;
+
/* initialize resource manager */
- ret = _mmcamcorder_resource_manager_init(&hcamcorder->resource_manager, (void *)hcamcorder);
+ ret = _mmcamcorder_resource_manager_init(&hcamcorder->resource_manager);
if (ret != MM_ERROR_NONE) {
_mmcam_dbg_err("failed to initialize resource manager");
ret = MM_ERROR_CAMCORDER_INTERNAL;
goto _ERR_DEFAULT_VALUE_INIT;
}
+
+ ret = _mmcamcorder_resource_manager_init(&hcamcorder->resource_manager_sub);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("failed to initialize resource manager sub");
+ ret = MM_ERROR_CAMCORDER_INTERNAL;
+ goto _ERR_DEFAULT_VALUE_INIT;
+ }
#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
} else {
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
#ifdef _MMCAMCORDER_MURPHY_SUPPORT
if (info->videodev_type != MM_VIDEO_DEVICE_NONE) {
- ret = _mmcamcorder_resource_wait_for_connection(&hcamcorder->resource_manager, (void *)hcamcorder);
+ ret = _mmcamcorder_resource_wait_for_connection(&hcamcorder->resource_manager);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("failed to connect resource manager");
+ goto _ERR_DEFAULT_VALUE_INIT;
+ }
+
+ ret = _mmcamcorder_resource_wait_for_connection(&hcamcorder->resource_manager_sub);
if (ret != MM_ERROR_NONE) {
_mmcam_dbg_err("failed to connect resource manager");
goto _ERR_DEFAULT_VALUE_INIT;
_ERR_DEFAULT_VALUE_INIT:
#ifdef _MMCAMCORDER_MURPHY_SUPPORT
/* de-initialize resource manager */
+ _mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager_sub);
_mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager);
#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
if (ret != MM_ERROR_NONE)
_mmcam_dbg_err("failed to de-initialize resource manager 0x%x", ret);
+ ret = _mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager_sub);
+ if (ret != MM_ERROR_NONE)
+ _mmcam_dbg_err("failed to de-initialize resource manager sub 0x%x", ret);
+
_MMCAMCORDER_UNLOCK_RESOURCE(hcamcorder);
#endif /* _MMCAMCORDER_MURPHY_SUPPORT */
int app_pid = 0;
int resource_count = 0;
#endif /* _MMCAMCORDER_RM_SUPPORT */
+ char *stream_type = NULL;
+ char *ext_info = NULL;
+ int option = 0;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
/* acquire sound focus */
_mmcam_dbg_log("PAUSE_OTHERS - acquire sound focus");
- ret_sound = mm_sound_acquire_focus(hcamcorder->sound_focus_id, FOCUS_FOR_BOTH, NULL);
+ ret_sound = mm_sound_acquire_focus(hcamcorder->sound_focus_id, FOCUS_FOR_BOTH, "mm-camcorder acquire focus");
if (ret_sound != MM_ERROR_NONE) {
_mmcam_dbg_err("mm_sound_acquire_focus failed [0x%x]", ret_sound);
/* do nothing */
_mmcam_dbg_log("SESSION_UNINTERRUPTIBLE - do nothing for sound focus");
} else {
+ /* check previous acquired focus */
+ ret = mm_sound_get_stream_type_of_acquired_focus(FOCUS_FOR_BOTH, &stream_type, &option, &ext_info);
+ if (ret == MM_ERROR_NONE && stream_type) {
+ if (!strcmp(stream_type, "alarm") ||
+ !strcmp(stream_type, "ringtone-voip") ||
+ !strcmp(stream_type, "ringtone-call") ||
+ !strcmp(stream_type, "voip") ||
+ !strcmp(stream_type, "call-voice") ||
+ !strcmp(stream_type, "call-video")) {
+ _mmcam_dbg_err("Blocked by session policy, stream_type [%s]", stream_type);
+ ret = MM_ERROR_POLICY_BLOCKED;
+ }
+ } else {
+ _mmcam_dbg_warn("get stream type failed 0x%x, stream type %s, but ignore it",
+ ret, stream_type ? stream_type : "NULL");
+ ret = MM_ERROR_NONE;
+ }
+
+ if (stream_type) {
+ free(stream_type);
+ stream_type = NULL;
+ }
+
+ if (ext_info) {
+ free(ext_info);
+ ext_info = NULL;
+ }
+
+ if (ret != MM_ERROR_NONE)
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+
/* unset remained watch cb */
if (hcamcorder->sound_focus_watch_id > 0) {
mm_sound_unset_focus_watch_callback(hcamcorder->sound_focus_watch_id);
#ifdef _MMCAMCORDER_MURPHY_SUPPORT
/* check connection */
- if (hcamcorder->resource_manager.is_connected == FALSE) {
- _mmcam_dbg_warn("resource manager disconnected before, try to reconnect");
-
- /* release remained resource */
- _mmcamcorder_resource_manager_deinit(&hcamcorder->resource_manager);
-
- /* init resource manager and wait for connection */
- ret = _mmcamcorder_resource_manager_init(&hcamcorder->resource_manager, (void *)hcamcorder);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("failed to initialize resource manager");
- ret = MM_ERROR_CAMCORDER_INTERNAL;
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
-
- ret = _mmcamcorder_resource_wait_for_connection(&hcamcorder->resource_manager, (void *)hcamcorder);
- if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("failed to connect resource manager");
- goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
- }
- }
+ ret = _mmcamcorder_resource_check_connection(&hcamcorder->resource_manager);
+ if (ret != MM_ERROR_NONE)
+ goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
+ /* create resource set */
ret = _mmcamcorder_resource_create_resource_set(&hcamcorder->resource_manager);
if (ret != MM_ERROR_NONE) {
goto _ERR_CAMCORDER_CMD_PRECON_AFTER_LOCK;
}
if (hcamcorder->acquired_focus > 0) {
- mm_sound_release_focus(hcamcorder->sound_focus_id, hcamcorder->acquired_focus, NULL);
+ mm_sound_release_focus(hcamcorder->sound_focus_id, hcamcorder->acquired_focus, "mm-camcorder release focus");
_mmcam_dbg_warn("release sound focus [focus %d] done", hcamcorder->acquired_focus);
hcamcorder->acquired_focus = 0;
}
}
#ifdef _MMCAMCORDER_MURPHY_SUPPORT
- _mmcam_dbg_warn("lock resource - cb calling %d", hcamcorder->resource_release_cb_calling);
+ _mmcam_dbg_warn("lock resource - cb calling %d", hcamcorder->resource_manager.is_release_cb_calling);
_MMCAMCORDER_LOCK_RESOURCE(hcamcorder);
if (hcamcorder->type == MM_CAMCORDER_MODE_VIDEO_CAPTURE &&
hcamcorder->state_change_by_system != _MMCAMCORDER_STATE_CHANGE_BY_RM &&
- hcamcorder->resource_release_cb_calling == FALSE) {
+ hcamcorder->resource_manager.is_release_cb_calling == FALSE) {
gint64 end_time = 0;
/* release resource */
}
if (hcamcorder->acquired_focus > 0) {
- mm_sound_release_focus(hcamcorder->sound_focus_id, hcamcorder->acquired_focus, NULL);
+ mm_sound_release_focus(hcamcorder->sound_focus_id, hcamcorder->acquired_focus, "mm-camcorder release focus");
_mmcam_dbg_warn("release sound focus [focus %d] done", hcamcorder->acquired_focus);
hcamcorder->acquired_focus = 0;
}
int dpm_mic_state = DPM_ALLOWED;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+ _MMCamcorderSubContext *sc = NULL;
_mmcam_dbg_log("");
- if (!hcamcorder) {
+ if (!hcamcorder || !MMF_CAMCORDER_SUBCONTEXT(hcamcorder)) {
_mmcam_dbg_err("Not initialized");
ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
return ret;
}
+ sc = MMF_CAMCORDER_SUBCONTEXT(handle);
+
if (!_MMCAMCORDER_TRYLOCK_CMD(hcamcorder)) {
_mmcam_dbg_err("Another command is running.");
ret = MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
/* initialize error code */
hcamcorder->error_code = MM_ERROR_NONE;
+ /* get audio disable */
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_AUDIO_DISABLE, &sc->audio_disable,
+ NULL);
+
+ sc->audio_disable |= sc->is_modified_rate;
+
/* check mic policy from DPM */
- if (hcamcorder->dpm_handle) {
+ if (hcamcorder->dpm_handle && sc->audio_disable == FALSE) {
if (dpm_restriction_get_microphone_state(hcamcorder->dpm_handle, &dpm_mic_state) == DPM_ERROR_NONE) {
_mmcam_dbg_log("DPM mic state %d", dpm_mic_state);
if (dpm_mic_state == DPM_DISALLOWED) {
_mmcam_dbg_err("get DPM mic state failed, keep going...");
}
} else {
- _mmcam_dbg_warn("NULL dpm_handle");
+ _mmcam_dbg_warn("skip dpm check - handle %p, audio disable %d",
+ hcamcorder->dpm_handle, sc->audio_disable);
}
ret = hcamcorder->command((MMHandleType)hcamcorder, _MMCamcorder_CMD_RECORD);
if (callback == NULL)
_mmcam_dbg_warn("Video Stream Callback is disabled, because application sets it to NULL");
- if (!_MMCAMCORDER_TRYLOCK_VSTREAM_CALLBACK(hcamcorder)) {
- _mmcam_dbg_warn("Application's video stream callback is running now");
- return MM_ERROR_CAMCORDER_INVALID_CONDITION;
- }
+ _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(hcamcorder);
hcamcorder->vstream_cb = callback;
hcamcorder->vstream_cb_param = user_data;
} else if (focus_state == FOCUS_IS_ACQUIRED) {
_MMCamcorderMsgItem msg;
- hcamcorder->acquired_focus |= focus_type;
-
- _mmcam_dbg_warn("FOCUS is acquired [type %d, new focus %d]",
+ _mmcam_dbg_warn("FOCUS is ready to acquired [type %d, current %d]",
focus_type, hcamcorder->acquired_focus);
msg.id = MM_MESSAGE_READY_TO_RESUME;
/* unregister focus related callback */
if (hcamcorder->sound_focus_id > 0) {
if (hcamcorder->acquired_focus > 0) {
- mm_sound_release_focus(hcamcorder->sound_focus_id, hcamcorder->acquired_focus, NULL);
+ mm_sound_release_focus(hcamcorder->sound_focus_id, hcamcorder->acquired_focus, "mm-camcorder release focus");
_mmcam_dbg_warn("release acquired focus [focus %d] done", hcamcorder->acquired_focus);
hcamcorder->acquired_focus = 0;
}
int result = MM_ERROR_NONE;
int cmd_try_count = 0;
int current_state = MM_CAMCORDER_STATE_NONE;
+ _MMCamcorderMsgItem msg;
mmf_return_if_fail(hcamcorder);
/* set state_change_by_system for state change message */
hcamcorder->state_change_by_system = state_change_by_system;
+ if (current_state >= MM_CAMCORDER_STATE_READY) {
+ _mmcam_dbg_warn("send state change started message to notify");
+
+ memset(&msg, 0x0, sizeof(_MMCamcorderMsgItem));
+
+ switch (state_change_by_system) {
+ case _MMCAMCORDER_STATE_CHANGE_BY_FOCUS:
+ msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGE_STARTED_BY_ASM;
+ break;
+ case _MMCAMCORDER_STATE_CHANGE_BY_RM:
+ msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGE_STARTED_BY_RM;
+ break;
+ case _MMCAMCORDER_STATE_CHANGE_BY_DPM:
+ msg.id = MM_MESSAGE_CAMCORDER_STATE_CHANGE_STARTED_BY_SECURITY;
+ break;
+ default:
+ break;
+ }
+
+ if (msg.id != 0) {
+ msg.param.state.code = hcamcorder->interrupt_code;
+ _mmcamcorder_send_message((MMHandleType)hcamcorder, &msg);
+ } else {
+ _mmcam_dbg_err("should not be reached here %d", state_change_by_system);
+ }
+ }
+
for (loop = 0 ; current_state > MM_CAMCORDER_STATE_NULL && loop < __MMCAMCORDER_CMD_ITERATE_MAX * 3 ; loop++) {
itr_cnt = __MMCAMCORDER_CMD_ITERATE_MAX;
switch (current_state) {