From: Seungbae Shin Date: Mon, 21 Nov 2016 04:18:22 +0000 (+0900) Subject: Modification of stream focus APIs X-Git-Tag: submit/tizen/20161202.035430^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3c335ae98bf7fc9bc4228c6e11c59a58e835b105;p=platform%2Fcore%2Fapi%2Fsound-manager.git Modification of stream focus APIs - Add parameters in sound_stream_focus_state_changed_cb() prototype - Add parameter in sound_manager_acquire/release_focus() - remove following APIs sound_manager_focus_set_requesting_behavior() sound_manager_focus_get_requesting_behavior() sound_manager_focus_get_requested_behavior() [Version] 0.3.81 [Profile] Common [Issue Type] Revise API (MPR-865) Change-Id: Icecfae40c8ed2ff77f3085599dc88ed9eaa35f92 --- diff --git a/include/sound_manager.h b/include/sound_manager.h index 30a5c47..ab91f22 100644 --- a/include/sound_manager.h +++ b/include/sound_manager.h @@ -145,9 +145,6 @@ typedef enum { * @brief Enumeration for sound behavior. * @since_tizen 3.0 * @remarks These values can be combined with bitwise 'or'. - * @see sound_manager_focus_set_requesting_behavior() - * @see sound_manager_focus_get_requesting_behavior() - * @see sound_manager_focus_get_requested_behavior() * @see sound_manager_get_current_playback_focus() * @see sound_manager_get_current_recording_focus() */ @@ -230,7 +227,7 @@ typedef enum { typedef enum { SOUND_SESSION_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed*/ SOUND_SESSION_INTERRUPTED_BY_MEDIA, /**< Interrupted by media application*/ - SOUND_SESSION_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call*/ + SOUND_SESSION_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call*/ SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphones*/ SOUND_SESSION_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by a resource conflict*/ SOUND_SESSION_INTERRUPTED_BY_ALARM, /**< Interrupted by an alarm*/ @@ -371,21 +368,24 @@ typedef void (*sound_manager_volume_changed_cb) (sound_type_e type, unsigned int * Therefore it is recommended not to call UI update function in this function. * * @param[in] stream_info The handle of stream information + * @param[in] focus_mask The changed focus mask + * @param[in] focus_state The changed focus state * @param[in] reason The reason for state change of the focus + * @param[in] sound_behavior The requested sound behavior that should be followed, values of #sound_behavior_e combined with bitwise 'or' * @param[in] extra_info The extra information * @param[in] user_data The user data passed from the callback registration function * @pre You should register this callback using sound_manager_create_stream_information(). - * @post Use sound_manager_get_focus_state() in this callback to figure out how the focus state of\n - * the @a stream_info has been changed.\n - * Use sound_manager_focus_get_requested_behavior() in this callback to check the recommended sound behavior\n - * that should be followed to enhance the sound experience. * @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); +typedef void (*sound_stream_focus_state_changed_cb) (sound_stream_info_h stream_info, + sound_stream_focus_mask_e focus_mask, + sound_stream_focus_state_e focus_state, + sound_stream_focus_change_reason_e reason, + int sound_behavior, + const char *extra_info, + void *user_data); /** * @brief Called when the focus state for each sound stream type is changed regardless of the process. @@ -746,6 +746,7 @@ int sound_manager_apply_stream_routing(sound_stream_info_h stream_info); * * @param[in] stream_info The handle of stream information * @param[in] focus_mask The focus mask that user wants to acquire + * @param[in] sound_behavior The requesting sound behavior, values of #sound_behavior_e combined with bitwise 'or' * @param[in] extra_info The extra information for this request (optional, this can be NULL) * @return @c 0 on success, * otherwise a negative error value @@ -761,7 +762,7 @@ int sound_manager_apply_stream_routing(sound_stream_info_h stream_info); * @see sound_manager_release_focus() * @see sound_manager_get_focus_state() */ -int sound_manager_acquire_focus(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, const char *extra_info); +int sound_manager_acquire_focus(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, int sound_behavior, const char *extra_info); /** * @brief Releases the acquired focus. @@ -772,6 +773,7 @@ int sound_manager_acquire_focus(sound_stream_info_h stream_info, sound_stream_fo * * @param[in] stream_info The handle of stream information * @param[in] focus_mask The focus mask that user wants to release + * @param[in] sound_behavior The requesting sound behavior, values of #sound_behavior_e combined with bitwise 'or' * @param[in] extra_info The extra information for this request (optional, this can be NULL) * @return @c 0 on success, * otherwise a negative error value @@ -786,7 +788,7 @@ int sound_manager_acquire_focus(sound_stream_info_h stream_info, sound_stream_fo * @see sound_manager_acquire_focus() * @see sound_manager_get_focus_state() */ -int sound_manager_release_focus(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, const char *extra_info); +int sound_manager_release_focus(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, int sound_behavior, const char *extra_info); /** * @brief Gets the state of focus. @@ -804,34 +806,9 @@ int sound_manager_release_focus(sound_stream_info_h stream_info, sound_stream_fo * @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 @@ -867,78 +844,6 @@ int sound_manager_set_focus_reacquisition(sound_stream_info_h stream_info, bool */ int sound_manager_get_focus_reacquisition(sound_stream_info_h stream_info, bool *enabled); -/** - * @brief Sets sound behavior to be passed to handles that will be affected by acquiring or releasing the stream focus of this handle. - * @since_tizen 3.0 - * - * @remarks This function's purpose is to set the sound behavior to be applied by other handles when acquiring or\n - * releasing the stream focus. Other handles affected by this handle can get this information by using\n - * sound_manager_focus_get_requested_behavior() after sound_stream_focus_state_changed_cb() is called. - * - * @param[in] stream_info The handle of stream information - * @param[in] flags The requesting sound behavior, values of #sound_behavior_e combined with bitwise 'or' - * @return @c 0 on success, - * otherwise a negative error value - * @retval #SOUND_MANAGER_ERROR_NONE Success - * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @pre Call sound_manager_create_stream_information() before calling this function. - * @post It will be passed to the other handle right after calling sound_manager_acquire_focus() or sound_manager_release_focus(). - * @see sound_manager_create_stream_information() - * @see sound_manager_acquire_focus() - * @see sound_manager_release_focus() - * @see sound_manager_focus_get_requesting_behavior() - * @see sound_manager_focus_get_requested_behavior() - */ -int sound_manager_focus_set_requesting_behavior(sound_stream_info_h stream_info, int flags); - -/** - * @brief Gets sound behavior to be passed to handles that will be affected by acquiring or releasing the stream focus of this handle. - * @since_tizen 3.0 - * - * @remarks This function's purpose is to get the sound behavior to be applied by other handles when acquiring or\n - * releasing the stream focus. Other handles affected by this handle can get this information by using\n - * sound_manager_focus_get_requested_behavior() after sound_stream_focus_state_changed_cb() is called. - * - * @param[in] stream_info The handle of stream information - * @param[out] flags The requesting sound behavior, values of #sound_behavior_e combined with bitwise 'or' - * @return @c 0 on success, - * otherwise a negative error value - * @retval #SOUND_MANAGER_ERROR_NONE Success - * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @pre Call sound_manager_create_stream_information() before calling this function. - * @post It will be passed to other handles right after calling sound_manager_acquire_focus() or sound_manager_release_focus(). - * @see sound_manager_create_stream_information() - * @see sound_manager_acquire_focus() - * @see sound_manager_release_focus() - * @see sound_manager_focus_set_requesting_behavior() - * @see sound_manager_focus_get_requested_behavior() - */ -int sound_manager_focus_get_requesting_behavior(sound_stream_info_h stream_info, int *flags); - -/** - * @brief Gets the requested sound behavior. - * @since_tizen 3.0 - * - * @remarks The flags can be used as a guide to how to change the sound behavior right after getting\n - * sound_stream_focus_state_changed_cb(). It is highly recommended to follow this sound behavior information\n - * for the enhanced sound experience. 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] flags The requested sound behavior that should be followed, values of #sound_behavior_e combined with bitwise 'or' - * @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_focus_set_requesting_behavior() - * @see sound_manager_focus_get_requesting_behavior() - * @see sound_manager_acquire_focus() - * @see sound_manager_release_focus() - */ -int sound_manager_focus_get_requested_behavior(sound_stream_info_h stream_info, int *flags); - /** * @brief Gets the reason for the current acquired playback focus. * @since_tizen 3.0 @@ -949,7 +854,7 @@ int sound_manager_focus_get_requested_behavior(sound_stream_info_h stream_info, * The @a extra_info should be released using free(). * * @param[out] acquired_by The reason for the current acquired playback focus - * @param[out] flags The requested sound behavior that should be followed, values of #sound_behavior_e combined with bitwise 'or' + * @param[out] sound_behavior The requested sound behavior that should be followed, values of #sound_behavior_e combined with bitwise 'or' * @param[out] extra_info The extra information of the acquired playback focus (optional, this can be NULL) * @return @c 0 on success, * otherwise a negative error value @@ -959,7 +864,7 @@ int sound_manager_focus_get_requested_behavior(sound_stream_info_h stream_info, * @retval #SOUND_MANAGER_ERROR_NO_DATA No data * @see sound_manager_get_current_recording_focus() */ -int sound_manager_get_current_playback_focus(sound_stream_focus_change_reason_e *acquired_by, int *flags, char **extra_info); +int sound_manager_get_current_playback_focus(sound_stream_focus_change_reason_e *acquired_by, int *sound_behavior, char **extra_info); /** * @brief Gets the reason for the current acquired recording focus. @@ -971,7 +876,7 @@ int sound_manager_get_current_playback_focus(sound_stream_focus_change_reason_e * The @a extra_info should be released using free(). * * @param[out] acquired_by The reason for the current acquired recording focus - * @param[out] flags The requested sound behavior that should be followed, values of #sound_behavior_e combined with bitwise 'or' + * @param[out] sound_behavior The requested sound behavior that should be followed, values of #sound_behavior_e combined with bitwise 'or' * @param[out] extra_info The extra information of the acquired recording focus (optional, this can be NULL) * @return @c 0 on success, * otherwise a negative error value @@ -981,7 +886,7 @@ int sound_manager_get_current_playback_focus(sound_stream_focus_change_reason_e * @retval #SOUND_MANAGER_ERROR_NO_DATA No data * @see sound_manager_get_current_playback_focus() */ -int sound_manager_get_current_recording_focus(sound_stream_focus_change_reason_e *acquired_by, int *flags, char **extra_info); +int sound_manager_get_current_recording_focus(sound_stream_focus_change_reason_e *acquired_by, int *sound_behavior, char **extra_info); /** * @brief Registers the watch callback function to be invoked when the focus state for each sound stream type is changed regardless of the process. diff --git a/include/sound_manager_private.h b/include/sound_manager_private.h index fbaaee7..e55dded 100644 --- a/include/sound_manager_private.h +++ b/include/sound_manager_private.h @@ -160,10 +160,6 @@ typedef struct _sound_stream_info_s { 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; void *user_data; manual_route_info_s manual_route_info; @@ -225,7 +221,9 @@ typedef struct { void _focus_session_interrupt_cb(mm_sound_focus_state_e state, const char *reason, bool is_wcb, void *user_data); -void _voip_focus_state_change_callback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason, const char *extra_info, void *user_data); +void _voip_focus_state_change_callback(sound_stream_info_h stream_info, + sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, + sound_stream_focus_change_reason_e reason, int sound_behavior, const char *extra_info, void *user_data); void _device_connected_cb(sound_device_h device, bool is_connected, void *user_data); diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index cc44a0b..aaa0776 100755 --- a/packaging/capi-media-sound-manager.spec +++ b/packaging/capi-media-sound-manager.spec @@ -1,6 +1,6 @@ Name: capi-media-sound-manager Summary: Sound Manager library -Version: 0.3.80 +Version: 0.3.81 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/sound_manager.c b/src/sound_manager.c index 628f7df..ff00fcb 100644 --- a/src/sound_manager.c +++ b/src/sound_manager.c @@ -329,7 +329,7 @@ int sound_manager_get_focus_reacquisition(sound_stream_info_h stream_info, bool return _convert_sound_manager_error_code(__func__, ret); } -int sound_manager_acquire_focus(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, const char *extra_info) +int sound_manager_acquire_focus(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, int sound_behavior, const char *extra_info) { int ret = MM_ERROR_NONE; sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info; @@ -348,7 +348,7 @@ int sound_manager_acquire_focus(sound_stream_info_h stream_info, sound_stream_fo return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL); } - ret = mm_sound_acquire_focus_with_option(stream_h->index, (mm_sound_focus_type_e)focus_mask, stream_h->requesting_flags, extra_info); + ret = mm_sound_acquire_focus_with_option(stream_h->index, (mm_sound_focus_type_e)focus_mask, sound_behavior, extra_info); if (ret == MM_ERROR_NONE) { stream_h->acquired_focus |= focus_mask; _update_focus_status(stream_h->index, (unsigned int)stream_h->acquired_focus); @@ -357,7 +357,7 @@ int sound_manager_acquire_focus(sound_stream_info_h stream_info, sound_stream_fo return _convert_sound_manager_error_code(__func__, ret); } -int sound_manager_release_focus(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, const char *extra_info) +int sound_manager_release_focus(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, int sound_behavior, const char *extra_info) { int ret = MM_ERROR_NONE; sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info; @@ -366,7 +366,7 @@ int sound_manager_release_focus(sound_stream_info_h stream_info, sound_stream_fo SM_INSTANCE_CHECK(stream_h); - ret = mm_sound_release_focus_with_option(stream_h->index, (mm_sound_focus_type_e)focus_mask, stream_h->requesting_flags, extra_info); + ret = mm_sound_release_focus_with_option(stream_h->index, (mm_sound_focus_type_e)focus_mask, sound_behavior, extra_info); if (ret == MM_ERROR_NONE) { stream_h->acquired_focus &= ~focus_mask; _update_focus_status(stream_h->index, (unsigned int)stream_h->acquired_focus); @@ -399,97 +399,6 @@ LEAVE: 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; - - LOGI(">> enter"); - - SM_INSTANCE_CHECK(stream_h); - SM_RANGE_ARG_CHECK(flags, - SOUND_BEHAVIOR_NONE, - (SOUND_BEHAVIOR_NO_RESUME|SOUND_BEHAVIOR_FADING)); - - stream_h->requesting_flags = flags; - - LOGI("the requesting sound behavior(0x%x) is set", stream_h->requesting_flags); - - return SOUND_MANAGER_ERROR_NONE; -} - -int sound_manager_focus_get_requesting_behavior(sound_stream_info_h stream_info, int *flags) -{ - sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info; - - LOGI(">> enter"); - - SM_INSTANCE_CHECK(stream_h); - SM_NULL_ARG_CHECK(flags); - - *flags = stream_h->requesting_flags; - - LOGI("the requesting sound behavior is (0x%x)", stream_h->requesting_flags); - - return SOUND_MANAGER_ERROR_NONE; -} - -int sound_manager_focus_get_requested_behavior(sound_stream_info_h stream_info, int *flags) -{ - 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(flags); - - 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; - } - - *flags = stream_h->requested_flags; - - LOGI("requested sound behavior is (0x%x)", stream_h->requested_flags); - - return SOUND_MANAGER_ERROR_NONE; -} - int sound_manager_get_current_playback_focus(sound_stream_focus_change_reason_e *acquired_by, int *flags, char **extra_info) { int ret = MM_ERROR_NONE; diff --git a/src/sound_manager_private.c b/src/sound_manager_private.c index 59d2131..010549b 100644 --- a/src/sound_manager_private.c +++ b/src/sound_manager_private.c @@ -492,22 +492,11 @@ void _focus_state_change_callback(int index, mm_sound_focus_type_e focus_type, m else if (state == FOCUS_IS_ACQUIRED) sound_stream_info_arr[i]->acquired_focus |= focus_type; - /* 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); + sound_stream_info_arr[i]->user_cb((sound_stream_info_h)sound_stream_info_arr[i], + focus_type, state, change_reason, option, 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; } } @@ -1164,10 +1153,12 @@ void _device_connected_cb(sound_device_h device, bool is_connected, void *user_d } /* This is an internal callback for the VOIP SESSION */ -void _voip_focus_state_change_callback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason, const char *extra_info, void *user_data) +void _voip_focus_state_change_callback(sound_stream_info_h stream_info, + sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, + sound_stream_focus_change_reason_e reason, int sound_behavior, const char *extra_info, void *user_data) { sound_stream_info_s *info = (sound_stream_info_s *)stream_info; - LOGI(">> enter, stream_info(%p), change_reason(%d), extra_info(%s)", stream_info, reason, extra_info); + LOGI(">> enter, stream_info(%p), change_reason(%d), sound_behavior(0x%x), extra_info(%s)", stream_info, reason, sound_behavior, extra_info); if (!info) { LOGE("stream info is null"); diff --git a/test/sound_manager_test.c b/test/sound_manager_test.c index 33d2308..9e1224d 100644 --- a/test/sound_manager_test.c +++ b/test/sound_manager_test.c @@ -76,9 +76,6 @@ enum { CURRENT_STATUS_REMOVE_FOCUS_WATCH_CB, CURRENT_STATUS_SET_FOCUS_REACQUISITION, CURRENT_STATUS_GET_FOCUS_REACQUISITION, - CURRENT_STATUS_SET_REQUESTING_BEHAVIOR, - CURRENT_STATUS_GET_REQUESTING_BEHAVIOR, - CURRENT_STATUS_GET_REQUESTED_BEHAVIOR, CURRENT_STATUS_GET_REASON_FOR_P_FOCUS, CURRENT_STATUS_GET_REASON_FOR_R_FOCUS, CURRENT_STATUS_CREATE_VIRTUAL_STREAM, @@ -109,24 +106,22 @@ static const char *g_device_avail_modes_str[] = { [SOUND_DEVICE_BLUETOOTH_MODE_MEDIA | SOUND_DEVICE_BLUETOOTH_MODE_VOICE] = "Media & Voice" }; -void focus_callback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason, const char *extra_info, void *user_data) +void focus_callback(sound_stream_info_h stream_info, + sound_stream_focus_mask_e focus_mask, + sound_stream_focus_state_e focus_state, + sound_stream_focus_change_reason_e reason, + int sound_behavior, + const char *extra_info, + void *user_data) { 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); + g_print(" - changed focus: mask(%x), state(%d) (0:released, 1:acquired)\n", focus_mask, focus_state); + g_print(" - change_reason(%d), behavior(0x%x), extra_info(%s), user_data(%p)\n", reason, sound_behavior, extra_info, user_data); ret = sound_manager_get_focus_state(stream_info, &playback_focus_state, &recording_focus_state); if (!ret) @@ -242,12 +237,6 @@ void _interpret_main_menu(char *cmd) g_menu_state = CURRENT_STATUS_SET_FOCUS_REACQUISITION; else if (strncmp(cmd, "gfr", 3) == 0) g_menu_state = CURRENT_STATUS_GET_FOCUS_REACQUISITION; - else if (strncmp(cmd, "srb", 3) == 0) - g_menu_state = CURRENT_STATUS_SET_REQUESTING_BEHAVIOR; - else if (strncmp(cmd, "grb", 3) == 0) - g_menu_state = CURRENT_STATUS_GET_REQUESTING_BEHAVIOR; - else if (strncmp(cmd, "grd", 3) == 0) - g_menu_state = CURRENT_STATUS_GET_REQUESTED_BEHAVIOR; else if (strncmp(cmd, "grp", 3) == 0) g_menu_state = CURRENT_STATUS_GET_REASON_FOR_P_FOCUS; else if (strncmp(cmd, "grr", 3) == 0) @@ -342,9 +331,6 @@ void display_sub_basic() g_print("rfw. Remove Focus State Watch CB\n"); g_print("sfr. Set Focus Reacquisition\t"); g_print("gfr. Get Focus Reacquisition\n"); - g_print("srb. Set Requesting Sound Behavior\t"); - g_print("grb. Get Requesting Sound Behavior\t"); - g_print("grd. Get Requested Sound Behavior\n"); g_print("grp. Get Reason for Current Acquired Playback Focus\t"); g_print("grr. Get Reason for Current Acquired Recording Focus\n"); g_print("sso. *Set option for stream routing\n"); @@ -441,9 +427,9 @@ static void displaymenu() else if (g_menu_state == CURRENT_STATUS_SET_STREAM_ROUTING_OPTION) g_print("*** input option(name/value) for routing (0:option_1/0, 1:option_1/1, 2:option_2/0, 3:option_2:1)\n"); else if (g_menu_state == CURRENT_STATUS_ACQUIRE_FOCUS) - g_print("*** input focus type to acquire (0:playback, 1:recording, 2:both)\n"); + g_print("*** input focus type to acquire (0:playback, 1:recording, 2:both, 3:both+noResume, 4:both+fading)\n"); else if (g_menu_state == CURRENT_STATUS_RELEASE_FOCUS) - g_print("*** input focus type to release (0:playback, 1:recording, 2:both)\n"); + g_print("*** input focus type to release (0:playback, 1:recording, 2:both, 3:both+noResume, 4:both+fading)\n"); else if (g_menu_state == CURRENT_STATUS_GET_ACQUIRED_FOCUS) g_print("*** press enter to get focus state\n"); else if (g_menu_state == CURRENT_STATUS_GET_SOUND_TYPE) @@ -458,12 +444,6 @@ static void displaymenu() g_print("*** input focus reacquisition property (1:enable, 2:disable)\n"); else if (g_menu_state == CURRENT_STATUS_GET_FOCUS_REACQUISITION) g_print("*** press enter to get focus reacquisition property\n"); - else if (g_menu_state == CURRENT_STATUS_SET_REQUESTING_BEHAVIOR) - g_print("*** input flags for requesting audio behavior (0:none, 1:no_resume, 2:fading, 3:no_resume+fading)\n"); - else if (g_menu_state == CURRENT_STATUS_GET_REQUESTING_BEHAVIOR) - g_print("*** press enter to get requesting audio behavior (0:none, 1:no_resume, 2:fading, 3:no_resume+fading)\n"); - else if (g_menu_state == CURRENT_STATUS_GET_REQUESTED_BEHAVIOR) - g_print("*** press enter to get the requested audio behavior\n"); else if (g_menu_state == CURRENT_STATUS_GET_REASON_FOR_P_FOCUS) g_print("*** press enter to get reason for current playback focus\n"); else if (g_menu_state == CURRENT_STATUS_GET_REASON_FOR_R_FOCUS) @@ -1337,6 +1317,7 @@ static void interpret(char *cmd) int ret = SOUND_MANAGER_ERROR_NONE; int focus_type = 0; sound_stream_focus_mask_e focus_mask; + int behavior = SOUND_BEHAVIOR_NONE; focus_type = atoi(cmd); switch (focus_type) { @@ -1346,14 +1327,25 @@ static void interpret(char *cmd) case 1: /* recording */ focus_mask = SOUND_STREAM_FOCUS_FOR_RECORDING; break; - case 2: /* all */ + case 2: /* both */ + focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH; + break; + case 3: /* both + no-resumption */ focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH; + behavior = SOUND_BEHAVIOR_NO_RESUME; + break; + case 4: /* both + fading */ + focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH; + behavior = SOUND_BEHAVIOR_FADING; break; default: + g_print("invalid selection(%d), keep going with PLAYBACK focus..\n", focus_type); focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK; break; } - ret = sound_manager_acquire_focus(g_stream_info_h, focus_mask, "sound_manager_test(acquire_focus)"); + ret = sound_manager_acquire_focus(g_stream_info_h, focus_mask, + behavior, + "sound_manager_test(acquire_focus)"); if (ret) g_print("fail to sound_manager_acquire_focus(), ret(0x%x)\n", ret); @@ -1364,6 +1356,7 @@ static void interpret(char *cmd) int ret = SOUND_MANAGER_ERROR_NONE; int focus_type = 0; sound_stream_focus_mask_e focus_mask; + int behavior = SOUND_BEHAVIOR_NONE; focus_type = atoi(cmd); switch (focus_type) { @@ -1376,11 +1369,22 @@ static void interpret(char *cmd) case 2: /* both */ focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH; break; + case 3: /* both + no-resumption */ + focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH; + behavior = SOUND_BEHAVIOR_NO_RESUME; + break; + case 4: /* both + fading */ + focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH; + behavior = SOUND_BEHAVIOR_FADING; + break; default: + g_print("invalid selection(%d), keep going with PLAYBACK focus..\n", focus_type); focus_mask = SOUND_STREAM_FOCUS_FOR_PLAYBACK; break; } - ret = sound_manager_release_focus(g_stream_info_h, focus_mask, "sound_manager_test(release_focus)"); + ret = sound_manager_release_focus(g_stream_info_h, focus_mask, + behavior, + "sound_manager_test(release_focus)"); if (ret) g_print("fail to sound_manager_release_focus(), ret(0x%x)\n", ret); @@ -1507,72 +1511,17 @@ static void interpret(char *cmd) reset_menu_state(); break; } - case CURRENT_STATUS_SET_REQUESTING_BEHAVIOR: { - int ret = SOUND_MANAGER_ERROR_NONE; - int flags; - - switch (atoi(cmd)) { - case 0: /* none */ - flags = SOUND_BEHAVIOR_NONE; - break; - case 1: /* no resumption */ - flags = SOUND_BEHAVIOR_NO_RESUME; - break; - case 2: /* fading effect */ - flags = SOUND_BEHAVIOR_FADING; - break; - case 3: /* no resumption + fading effect */ - flags = SOUND_BEHAVIOR_NO_RESUME | SOUND_BEHAVIOR_FADING; - break; - default: - flags = SOUND_BEHAVIOR_NONE; - break; - } - - ret = sound_manager_focus_set_requesting_behavior(g_stream_info_h, flags); - if (ret) - g_print("fail to sound_manager_focus_set_requesting_behavior, ret(0x%x)\n", ret); - - reset_menu_state(); - break; - } - case CURRENT_STATUS_GET_REQUESTING_BEHAVIOR: { - int ret = SOUND_MANAGER_ERROR_NONE; - int flags; - - ret = sound_manager_focus_get_requesting_behavior(g_stream_info_h, &flags); - if (ret) - g_print("fail to sound_manager_focus_get_requesting_behavior, ret(0x%x)\n", ret); - else - g_print("requesting behavior is (0x%x)\n", flags); - - reset_menu_state(); - break; - } - case CURRENT_STATUS_GET_REQUESTED_BEHAVIOR: { - int ret = SOUND_MANAGER_ERROR_NONE; - int flags; - - ret = sound_manager_focus_get_requested_behavior(g_stream_info_h, &flags); - if (ret) - g_print("fail to sound_manager_focus_get_requested_behavior, ret(0x%x)\n", ret); - else - g_print("requested behavior is (0x%x)\n", flags); - - reset_menu_state(); - break; - } case CURRENT_STATUS_GET_REASON_FOR_P_FOCUS: { int ret = SOUND_MANAGER_ERROR_NONE; char *extra_info = NULL; sound_stream_focus_change_reason_e reason; - int flags; + int sound_behavior; - ret = sound_manager_get_current_playback_focus(&reason, &flags, &extra_info); + ret = sound_manager_get_current_playback_focus(&reason, &sound_behavior, &extra_info); if (ret) g_print("fail to sound_manager_get_current_playback_focus, ret(0x%x)\n", ret); else - g_print("reason(%d), flags(0x%x), extra_info(%s)\n", reason, flags, extra_info); + g_print("reason(%d), sound_behavior(0x%x, 0x0:none 0x1:no_resume 0x2:fading), extra_info(%s)\n", reason, sound_behavior, extra_info); free(extra_info); reset_menu_state(); @@ -1582,13 +1531,13 @@ static void interpret(char *cmd) int ret = SOUND_MANAGER_ERROR_NONE; char *extra_info = NULL; sound_stream_focus_change_reason_e reason; - int flags; + int sound_behavior; - ret = sound_manager_get_current_recording_focus(&reason, &flags, &extra_info); + ret = sound_manager_get_current_recording_focus(&reason, &sound_behavior, &extra_info); if (ret) g_print("fail to sound_manager_get_current_recording_focus, ret(0x%x)\n", ret); else - g_print("reason(%d), flags(0x%x), extra_info(%s)\n", reason, flags, extra_info); + g_print("reason(%d), sound_behavior(0x%x, 0x0:none 0x1:no_resume 0x2:fading), extra_info(%s)\n", reason, sound_behavior, extra_info); free(extra_info); reset_menu_state();