Add extra info to some focus APIs for backward compatibility
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_internal.c
index 76193cf..61343a1 100644 (file)
@@ -896,7 +896,7 @@ int _mmcamcorder_realize(MMHandleType 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);
 
@@ -1425,7 +1425,7 @@ int _mmcamcorder_unrealize(MMHandleType handle)
                }
 
                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;
                }
@@ -3322,9 +3322,7 @@ void _mmcamcorder_sound_focus_cb(int id, mm_sound_focus_type_e focus_type,
        } 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;
@@ -4316,3 +4314,57 @@ rm_cb_result _mmcamcorder_rm_callback(int handle, rm_callback_type event_src,
        return cb_res;
 }
 #endif /* _MMCAMCORDER_RM_SUPPORT */
+
+
+int _mmcamcorder_manage_external_storage_state(MMHandleType handle, int storage_state)
+{
+       int ret = MM_ERROR_NONE;
+       int current_state = MM_CAMCORDER_STATE_NONE;
+       mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+       _MMCamcorderMsgItem msg;
+
+       mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+
+       _mmcam_dbg_warn("storage state %d", storage_state);
+
+       /* check storage state */
+       if (storage_state != STORAGE_STATE_UNMOUNTABLE &&
+               storage_state != STORAGE_STATE_REMOVED) {
+               _mmcam_dbg_warn("nothing to do");
+               return MM_ERROR_NONE;
+       }
+
+       _MMCAMCORDER_LOCK_ASM(hcamcorder);
+
+       /* check recording state */
+       current_state = _mmcamcorder_get_state(handle);
+
+       _mmcam_dbg_warn("current_state %d", current_state);
+
+       if (current_state < MM_CAMCORDER_STATE_RECORDING) {
+               _mmcam_dbg_warn("no recording now");
+               goto _MANAGE_DONE;
+       }
+
+       /* check storage type */
+       if (hcamcorder->storage_info.type != STORAGE_TYPE_EXTERNAL) {
+               _mmcam_dbg_warn("external storage is not used");
+               goto _MANAGE_DONE;
+       }
+
+       /* cancel recording */
+       ret = _mmcamcorder_cancel(handle);
+
+       /* send error message */
+       msg.id = MM_MESSAGE_CAMCORDER_ERROR;
+       msg.param.code = MM_ERROR_OUT_OF_STORAGE;
+
+       _mmcamcorder_send_message(handle, &msg);
+
+_MANAGE_DONE:
+       _MMCAMCORDER_UNLOCK_ASM(hcamcorder);
+
+       _mmcam_dbg_warn("done - ret 0x%x", ret);
+
+       return ret;
+}