Release version 0.10.15
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_attribute.c
index 51914ee..980e298 100644 (file)
@@ -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)) {