* @see sound_manager_create_stream_information()
* @see sound_manager_destroy_stream_information()
* @see sound_manager_get_focus_state()
+ * @see sound_manager_get_changed_focus_state()
* @see sound_manager_focus_get_requested_behavior()
*/
typedef void (*sound_stream_focus_state_changed_cb) (sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason, const char *extra_info, void *user_data);
* @see sound_manager_destroy_stream_information()
* @see sound_manager_acquire_focus()
* @see sound_manager_release_focus()
+ * @see sound_manager_get_changed_focus_state()
*/
int sound_manager_get_focus_state(sound_stream_info_h stream_info, sound_stream_focus_state_e *state_for_playback, sound_stream_focus_state_e *state_for_recording);
/**
+ * @brief Gets the changed focus mask and state.
+ * @since_tizen 3.0
+ *
+ * @remarks The changed focus mask and state can be obtained from this function within sound_stream_focus_state_changed_cb().\n
+ * This function differs from sound_manager_get_focus_state() in that it only gets the changed focus mask and state.\n
+ * Note that this function should be called within sound_stream_focus_state_changed_cb().
+ *
+ * @param[in] stream_info The handle of stream information
+ * @param[out] focus_mask The changed focus mask
+ * @param[out] focus_state The changed focus state
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #SOUND_MANAGER_ERROR_NONE Success
+ * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SOUND_MANAGER_ERROR_INVALID_OPERATION Invalid operation
+ * @pre Called sound_stream_focus_state_changed_cb() before calling this function.
+ * @see sound_manager_create_stream_information()
+ * @see sound_manager_acquire_focus()
+ * @see sound_manager_release_focus()
+ * @see sound_manager_get_focus_state()
+ */
+int sound_manager_get_changed_focus_state(sound_stream_info_h stream_info, sound_stream_focus_mask_e *focus_mask, sound_stream_focus_state_e *focus_state);
+
+/**
* @brief Sets auto focus reacquisition property.
* @since_tizen 3.0
*
pa_context *pa_context;
stream_conf_info_s stream_conf_info;
unsigned int acquired_focus;
+ mm_sound_focus_type_e changed_focus_type;
+ mm_sound_focus_state_e changed_focus_state;
int requesting_flags;
int requested_flags;
sound_stream_focus_state_changed_cb user_cb;
Name: capi-media-sound-manager
Summary: Sound Manager library
-Version: 0.3.73
+Version: 0.3.74
Release: 0
Group: Multimedia/API
License: Apache-2.0
return _convert_sound_manager_error_code(__func__, ret);
}
+int sound_manager_get_changed_focus_state(sound_stream_info_h stream_info, sound_stream_focus_mask_e *focus_mask, sound_stream_focus_state_e *focus_state)
+{
+ int ret = MM_ERROR_NONE;
+ sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
+ bool is_focus_cb_thread = false;
+
+ LOGI(">> enter");
+
+ SM_INSTANCE_CHECK(stream_h);
+ SM_NULL_ARG_CHECK(focus_mask);
+ SM_NULL_ARG_CHECK(focus_state);
+
+ if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread)))
+ return _convert_sound_manager_error_code(__func__, ret);
+
+ if (!is_focus_cb_thread) {
+ LOGE("this API should be called in focus state changed callback");
+ return SOUND_MANAGER_ERROR_INVALID_OPERATION;
+ }
+
+ if (stream_h->changed_focus_type == FOCUS_NONE)
+ return SOUND_MANAGER_ERROR_INVALID_OPERATION;
+
+ *focus_mask = (sound_stream_focus_mask_e)stream_h->changed_focus_type;
+ *focus_state = (sound_stream_focus_state_e)stream_h->changed_focus_state;
+
+ LOGI("changed focus(mask:0x%x, state:%d)", *focus_mask, *focus_state);
+
+ return _convert_sound_manager_error_code(__func__, ret);
+}
+
int sound_manager_focus_set_requesting_behavior(sound_stream_info_h stream_info, int flags)
{
sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
SM_NULL_ARG_CHECK(flags);
if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread)))
- _convert_sound_manager_error_code(__func__, ret);
+ return _convert_sound_manager_error_code(__func__, ret);
if (!is_focus_cb_thread) {
LOGE("this API should be called in focus state changed callback");
SM_NULL_ARG_CHECK(flags);
if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread)))
- _convert_sound_manager_error_code(__func__, ret);
+ return _convert_sound_manager_error_code(__func__, ret);
if (is_focus_cb_thread) {
LOGE("this API should not be called in focus callback");
SM_NULL_ARG_CHECK(flags);
if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread)))
- _convert_sound_manager_error_code(__func__, ret);
+ return _convert_sound_manager_error_code(__func__, ret);
if (is_focus_cb_thread) {
LOGE("this API should not be called in focus callback");
/* set flags for requested behavior */
sound_stream_info_arr[i]->requested_flags = option;
+ /* set changed focus value */
+ sound_stream_info_arr[i]->changed_focus_type = focus_type;
+ sound_stream_info_arr[i]->changed_focus_state = state;
+
LOGI("[FOCUS USER CALLBACK(%p) START]", sound_stream_info_arr[i]->user_cb);
sound_stream_info_arr[i]->user_cb((sound_stream_info_h)sound_stream_info_arr[i], change_reason, extra_info, sound_stream_info_arr[i]->user_data);
LOGI("[FOCUS USER CALLBACK(%p) END]", sound_stream_info_arr[i]->user_cb);
+ /* unset changed focus value */
+ sound_stream_info_arr[i]->changed_focus_type = FOCUS_NONE;
+
/* unset flags for requested behavior */
sound_stream_info_arr[i]->requested_flags = 0;
break;
int ret = SOUND_MANAGER_ERROR_NONE;
sound_stream_focus_state_e playback_focus_state;
sound_stream_focus_state_e recording_focus_state;
+ sound_stream_focus_state_e changed_state;
+ sound_stream_focus_mask_e changed_mask;
+
int flags = SOUND_BEHAVIOR_NONE;
g_print("\n*** FOCUS callback is called, stream_info(%p) ***\n", stream_info);
sound_manager_focus_get_requested_behavior(stream_info, &flags);
g_print(" - change_reason(%d), behavior(0x%x), extra_info(%s), user_data(%p)\n", reason, flags, extra_info, user_data);
+ ret = sound_manager_get_changed_focus_state(stream_info, &changed_mask, &changed_state);
+ if (!ret)
+ g_print(" - changed focus: mask(%x), state(%d) (0:released, 1:acquired)\n", changed_mask, changed_state);
+
ret = sound_manager_get_focus_state(stream_info, &playback_focus_state, &recording_focus_state);
if (!ret)
g_print(" - focus_state : PLAYBACK(%d), RECORDING(%d) (0:released, 1:acquired)\n", playback_focus_state, recording_focus_state);