* @retval #SOUND_MANAGER_ERROR_INVALID_STATE Invalid state
* @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy
* @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
- * @pre Call sound_manager_create_stream_information() with its parameter for sound_stream_focus_state_changed_cb before calling this function.
+ * @pre Call sound_manager_create_stream_information() with its parameter for sound_stream_focus_state_changed_cb\n
+ * before calling this function.
* @see sound_manager_create_stream_information()
* @see sound_manager_destroy_stream_information()
+ * @see sound_manager_acquire_focus_all()
* @see sound_manager_release_focus()
+ * @see sound_manager_release_focus_all()
* @see sound_manager_get_focus_state()
*/
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.
+ * @brief Releases the acquired stream focus.
* @since_tizen 3.0
*
* @param[in] stream_info The handle of stream information
* @see sound_manager_create_stream_information()
* @see sound_manager_destroy_stream_information()
* @see sound_manager_acquire_focus()
+ * @see sound_manager_acquire_focus_all()
+ * @see sound_manager_release_focus_all()
* @see sound_manager_get_focus_state()
*/
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 Acquires all the stream focuses.
+ * @since_tizen 4.0
+ *
+ * @remarks This function does not return error even though one or all of focuses have already been acquired.\n
+ * Use sound_manager_get_focus_state() to get acquired focus state if it returns #SOUND_MANAGER_ERROR_POLICY.
+ *
+ * @param[in] stream_info The handle of stream information
+ * @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
+ * @retval #SOUND_MANAGER_ERROR_NONE Success
+ * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy
+ * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
+ * @pre Call sound_manager_create_stream_information() with its parameter for sound_stream_focus_state_changed_cb\n
+ * before calling this function.
+ * @see sound_manager_create_stream_information()
+ * @see sound_manager_destroy_stream_information()
+ * @see sound_manager_acquire_focus()
+ * @see sound_manager_release_focus()
+ * @see sound_manager_release_focus_all()
+ * @see sound_manager_get_focus_state()
+ */
+int sound_manager_acquire_focus_all(sound_stream_info_h stream_info, int sound_behavior, const char *extra_info);
+
+/**
+ * @brief Releases all the acquired stream focuses.
+ * @since_tizen 4.0
+ *
+ * @remarks This function does not return error even though one or all of focuses have already been released.
+ *
+ * @param[in] stream_info The handle of stream information
+ * @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
+ * @retval #SOUND_MANAGER_ERROR_NONE Success
+ * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy
+ * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system
+ * @pre Call sound_manager_create_stream_information(), sound_manager_acquire_focus() and sound_manager_acquire_focus_all()\n
+ * before calling this function.
+ * @see sound_manager_create_stream_information()
+ * @see sound_manager_destroy_stream_information()
+ * @see sound_manager_acquire_focus()
+ * @see sound_manager_acquire_focus_all()
+ * @see sound_manager_release_focus()
+ * @see sound_manager_get_focus_state()
+ */
+int sound_manager_release_focus_all(sound_stream_info_h stream_info, int sound_behavior, const char *extra_info);
+
/**
* @brief Gets the state of focus.
* @since_tizen 3.0
Name: capi-media-sound-manager
Summary: Sound Manager library
-Version: 0.4.7
+Version: 0.4.8
Release: 0
Group: Multimedia/API
License: Apache-2.0
return _convert_sound_manager_error_code(__func__, ret);
if (stream_h->is_focus_unavailable) {
- LOGE("acquiring focus is not allowed for this strema type(%s)", stream_h->stream_type);
+ LOGE("acquiring focus is not allowed for this stream type(%s)", stream_h->stream_type);
return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
}
return _convert_sound_manager_error_code(__func__, ret);
}
+int sound_manager_acquire_focus_all(sound_stream_info_h stream_info, int sound_behavior, const char *extra_info)
+{
+ int ret = MM_ERROR_NONE;
+ int focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH;
+ sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
+
+ LOGI(">> enter");
+
+ SM_INSTANCE_CHECK(stream_h);
+
+ if (stream_h->is_focus_unavailable) {
+ LOGE("acquiring focus is not allowed for this stream type(%s)", stream_h->stream_type);
+ return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
+ }
+
+ if (stream_h->user_cb == NULL) {
+ LOGE("focus state changed callback should be set before acquiring focus");
+ return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
+ }
+
+ if ((stream_h->acquired_focus & focus_mask) || (stream_h->prev_acquired_focus & focus_mask)) {
+ LOGE("invalid state : focus_mask[0x%x], acquired_focus[0x%x], prev[0x%x]",
+ focus_mask, stream_h->acquired_focus, stream_h->prev_acquired_focus);
+ return _convert_sound_manager_error_code(__func__, MM_ERROR_SOUND_INVALID_STATE);
+ }
+
+ focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH & ~(stream_h->acquired_focus);
+ if (!focus_mask) {
+ LOGI("PLAYBACK/RECORDING focuses have already been ACQUIRED");
+ return SOUND_MANAGER_ERROR_NONE;
+ }
+
+ 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;
+ stream_h->prev_acquired_focus |= focus_mask;
+ _update_focus_status(stream_h->index, (unsigned int)stream_h->acquired_focus);
+ }
+
+ return _convert_sound_manager_error_code(__func__, ret);
+}
+
+int sound_manager_release_focus_all(sound_stream_info_h stream_info, int sound_behavior, const char *extra_info)
+{
+ int ret = MM_ERROR_NONE;
+ sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
+
+ LOGI(">> enter");
+
+ SM_INSTANCE_CHECK(stream_h);
+
+ if (!stream_h->acquired_focus) {
+ LOGI("PLAYBACK/RECORDING focuses have already been RELEASED");
+ return SOUND_MANAGER_ERROR_NONE;
+ }
+
+ ret = mm_sound_release_focus_with_option(stream_h->index, (mm_sound_focus_type_e)stream_h->acquired_focus, sound_behavior, extra_info);
+ if (ret == MM_ERROR_NONE) {
+ stream_h->acquired_focus = 0;
+ stream_h->prev_acquired_focus = 0;
+ _update_focus_status(stream_h->index, (unsigned int)stream_h->acquired_focus);
+ }
+
+ return _convert_sound_manager_error_code(__func__, ret);
+}
+
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)
{
int ret = MM_ERROR_NONE;
CURRENT_STATUS_SET_STREAM_ROUTING_OPTION,
CURRENT_STATUS_ACQUIRE_FOCUS,
CURRENT_STATUS_RELEASE_FOCUS,
+ CURRENT_STATUS_ACQUIRE_FOCUS_ALL,
+ CURRENT_STATUS_RELEASE_FOCUS_ALL,
CURRENT_STATUS_GET_ACQUIRED_FOCUS,
CURRENT_STATUS_GET_SOUND_TYPE,
CURRENT_STATUS_DESTROY_STREAM_INFO,
g_menu_state = CURRENT_STATUS_ACQUIRE_FOCUS;
else if (strncmp(cmd, "rfc", 3) == 0)
g_menu_state = CURRENT_STATUS_RELEASE_FOCUS;
+ else if (strncmp(cmd, "afa", 3) == 0)
+ g_menu_state = CURRENT_STATUS_ACQUIRE_FOCUS_ALL;
+ else if (strncmp(cmd, "rfa", 3) == 0)
+ g_menu_state = CURRENT_STATUS_RELEASE_FOCUS_ALL;
else if (strncmp(cmd, "gfs", 3) == 0)
g_menu_state = CURRENT_STATUS_GET_ACQUIRED_FOCUS;
else if (strncmp(cmd, "gst", 3) == 0)
g_print("afc. Acquire Focus\t");
g_print("rfc. Release Focus\t");
g_print("gfs. Get Focus State\n");
+ g_print("afa. Acquire Focus All\t");
+ g_print("rfa. Release Focus All\n");
g_print("afw. Add Focus State Watch CB\t");
g_print("rfw. Remove Focus State Watch CB\n");
g_print("sfr. Set Focus Reacquisition\t");
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, 3:both+noResume, 4:both+fading)\n");
+ else if (g_menu_state == CURRENT_STATUS_ACQUIRE_FOCUS_ALL)
+ g_print("*** input behavior for acquire all (0:without behavior, 1:with noResume, 2:with fading)\n");
+ else if (g_menu_state == CURRENT_STATUS_RELEASE_FOCUS_ALL)
+ g_print("*** input behavior for release all (0:without behavior, 1:with noResume, 2:with 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)
reset_menu_state();
break;
}
+ case CURRENT_STATUS_ACQUIRE_FOCUS_ALL: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ int behavior = atoi(cmd);
+
+ switch (behavior) {
+ case 0: /* without behavior */
+ behavior = SOUND_BEHAVIOR_NONE;
+ break;
+ case 1: /* no-resumption */
+ behavior = SOUND_BEHAVIOR_NO_RESUME;
+ break;
+ case 2: /* fading */
+ behavior = SOUND_BEHAVIOR_FADING;
+ break;
+ default:
+ g_print("invalid selection(%d), keep going without behavior..\n", behavior);
+ behavior = SOUND_BEHAVIOR_NONE;
+ break;
+ }
+ ret = sound_manager_acquire_focus_all(g_stream_info_h, behavior, "sound_manager_test(acquire_focus_all)");
+ if (ret)
+ g_print("fail to sound_manager_acquire_focus_all(), ret(0x%x)\n", ret);
+
+ reset_menu_state();
+ break;
+ }
+ case CURRENT_STATUS_RELEASE_FOCUS_ALL: {
+ int ret = SOUND_MANAGER_ERROR_NONE;
+ int behavior = atoi(cmd);
+
+ switch (behavior) {
+ case 0: /* without behavior */
+ behavior = SOUND_BEHAVIOR_NONE;
+ break;
+ case 1: /* no-resumption */
+ behavior = SOUND_BEHAVIOR_NO_RESUME;
+ break;
+ case 2: /* fading */
+ behavior = SOUND_BEHAVIOR_FADING;
+ break;
+ default:
+ g_print("invalid selection(%d), keep going without behavior..\n", behavior);
+ behavior = SOUND_BEHAVIOR_NONE;
+ break;
+ }
+ ret = sound_manager_release_focus_all(g_stream_info_h, behavior, "sound_manager_test(release_focus_all)");
+ if (ret)
+ g_print("fail to sound_manager_release_focus_all(), ret(0x%x)\n", ret);
+
+ reset_menu_state();
+ break;
+ }
case CURRENT_STATUS_GET_ACQUIRED_FOCUS: {
sound_stream_focus_state_e for_playback;
sound_stream_focus_state_e for_recording;