some functions of libmm-sound regarding focus was changed.
[Version] 0.5.6
[Issue Type] API changes of dependency module
Change-Id: Ifd561d5155b652abda2f4b412766b510c765074f
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
} manual_route_info_s;
typedef struct _sound_stream_info_s {
- unsigned int index;
+ unsigned int pa_index;
+ int focus_id;
char *stream_type;
bool is_focus_unavailable;
pa_threaded_mainloop *pa_mainloop;
Name: capi-media-sound-manager
Summary: Sound Manager library
-Version: 0.5.5
+Version: 0.5.6
Release: 0
Group: Multimedia/API
License: Apache-2.0
ret = _make_pa_connection_and_register_focus(stream_h, callback, user_data);
if (ret == MM_ERROR_NONE) {
*stream_info = (sound_stream_info_h)stream_h;
- LOGI("stream_h(%p), index(%u), user_cb(%p), ret(0x%x)", stream_h, stream_h->index, stream_h->user_cb, ret);
+ LOGI("stream_h(%p), pa_index(%u), focus_id(%d), user_cb(%p), ret(0x%x)",
+ stream_h, stream_h->pa_index, stream_h->focus_id, stream_h->user_cb, ret);
}
}
SM_INSTANCE_CHECK(stream_h);
- ret = mm_sound_set_focus_reacquisition(stream_h->index, enable);
+ ret = mm_sound_set_focus_reacquisition(stream_h->focus_id, enable);
LOGI("enable(%d)", enable);
SM_INSTANCE_CHECK(stream_h);
SM_NULL_ARG_CHECK(enabled);
- ret = mm_sound_get_focus_reacquisition(stream_h->index, enabled);
+ ret = mm_sound_get_focus_reacquisition(stream_h->focus_id, enabled);
LOGI("enabled(%d)", *enabled);
goto LEAVE;
}
- ret = mm_sound_acquire_focus_with_option(stream_h->index, (mm_sound_focus_type_e)focus_mask, sound_behavior, extra_info);
+ ret = mm_sound_acquire_focus_with_option(stream_h->focus_id, (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);
+ _update_focus_status(stream_h->pa_index, (unsigned int)stream_h->acquired_focus);
}
LOGI("acquired_focus[0x%x], prev[0x%x]", stream_h->acquired_focus, stream_h->prev_acquired_focus);
goto LEAVE;
}
- ret = mm_sound_release_focus_with_option(stream_h->index, (mm_sound_focus_type_e)focus_mask, sound_behavior, extra_info);
+ ret = mm_sound_release_focus_with_option(stream_h->focus_id, (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);
+ _update_focus_status(stream_h->pa_index, (unsigned int)stream_h->acquired_focus);
}
LOGI("acquired_focus[0x%x], prev[0x%x]", stream_h->acquired_focus, stream_h->prev_acquired_focus);
goto LEAVE;
}
- ret = mm_sound_acquire_focus_with_option(stream_h->index, (mm_sound_focus_type_e)focus_mask, sound_behavior, extra_info);
+ ret = mm_sound_acquire_focus_with_option(stream_h->focus_id, (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);
+ _update_focus_status(stream_h->pa_index, (unsigned int)stream_h->acquired_focus);
}
LEAVE:
goto LEAVE;
}
- ret = mm_sound_release_focus_with_option(stream_h->index, (mm_sound_focus_type_e)stream_h->acquired_focus, sound_behavior, extra_info);
+ ret = mm_sound_release_focus_with_option(stream_h->focus_id, (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);
+ _update_focus_status(stream_h->pa_index, (unsigned int)stream_h->acquired_focus);
}
LEAVE:
return SOUND_MANAGER_ERROR_INVALID_OPERATION;
}
- if (src_stream_h->index == dst_stream_h->index) {
- LOGE("not allowed because both handles have same index(%u)", src_stream_h->index);
+ if (src_stream_h->focus_id == dst_stream_h->focus_id) {
+ LOGE("not allowed because both handles have same id(%u)", src_stream_h->focus_id);
return SOUND_MANAGER_ERROR_INVALID_PARAMETER;
}
return SOUND_MANAGER_ERROR_POLICY;
}
- ret = mm_sound_deliver_focus(src_stream_h->index, dst_stream_h->index, (mm_sound_focus_type_e)focus_mask);
+ ret = mm_sound_deliver_focus(src_stream_h->focus_id, dst_stream_h->focus_id, (mm_sound_focus_type_e)focus_mask);
if (ret == MM_ERROR_NONE) {
src_stream_h->acquired_focus &= ~focus_mask;
src_stream_h->prev_acquired_focus &= ~focus_mask;
SM_NULL_ARG_CHECK(device);
SM_NULL_ARG_CHECK(is_on);
- ret = mm_sound_is_stream_on_device(stream_h->index, device, is_on);
+ ret = mm_sound_is_stream_on_device(stream_h->pa_index, device, is_on);
return _convert_sound_manager_error_code(__func__, ret);
}
ret = _make_pa_connection_and_register_focus(stream_h, callback, user_data);
if (!ret) {
*stream_info = (sound_stream_info_h)stream_h;
- LOGI("stream_h(%p), index(%u), user_cb(%p), ret(0x%x)", stream_h, stream_h->index, stream_h->user_cb, ret);
+ LOGI("stream_h(%p), pa_index(%u), focus_id(%d), user_cb(%p), ret(0x%x)",
+ stream_h, stream_h->pa_index, stream_h->focus_id, stream_h->user_cb, ret);
}
}
SM_INSTANCE_CHECK(stream_h);
SM_NULL_ARG_CHECK(name);
- ret = _set_route_option(stream_h->index, name, value);
+ ret = _set_route_option(stream_h->pa_index, name, value);
return _convert_sound_manager_error_code(__func__, ret);
}
SM_INSTANCE_CHECK(stream_h);
SM_NULL_ARG_CHECK(index);
- *index = stream_h->index;
- LOGI("stream_index[%d]", stream_h->index);
+ *index = stream_h->pa_index;
+ LOGI("stream_index[%u]", stream_h->pa_index);
return _convert_sound_manager_error_code(__func__, ret);
}
}
stream_info = (sound_stream_info_s *)user_data;
- if (stream_info->index != index) {
- LOGE("index is not valid, (%d, %d)", stream_info->index, index);
+ if (stream_info->focus_id != index) {
+ LOGE("index is not valid, (%d, %d)", stream_info->focus_id, index);
goto LEAVE;
}
stream_info->acquired_focus |= focus_type;
if (state == FOCUS_IS_ACQUIRED)
- _update_focus_status(stream_info->index, (unsigned int)stream_info->acquired_focus);
+ _update_focus_status(stream_info->pa_index, (unsigned int)stream_info->acquired_focus);
LOGI("[FOCUS USER CALLBACK(%p) START]", stream_info->user_cb);
stream_info->user_cb((sound_stream_info_h)stream_info, focus_type, state, change_reason,
LOGI("[FOCUS USER CALLBACK(%p) END]", stream_info->user_cb);
if (state == FOCUS_IS_RELEASED)
- _update_focus_status(stream_info->index, (unsigned int)stream_info->acquired_focus);
+ _update_focus_status(stream_info->pa_index, (unsigned int)stream_info->acquired_focus);
if (state == FOCUS_IS_RELEASED)
stream_info->prev_acquired_focus &= ~focus_type;
}
/* get index of this context */
- stream_h->index = pa_context_get_index(stream_h->pa_context);
+ stream_h->pa_index = pa_context_get_index(stream_h->pa_context);
pa_threaded_mainloop_unlock(stream_h->pa_mainloop);
/* register focus */
if (!stream_h->is_focus_unavailable) {
- ret = mm_sound_register_focus(stream_h->index, stream_h->stream_type, _focus_state_change_callback, stream_h);
+ ret = mm_sound_register_focus(stream_h->stream_type, _focus_state_change_callback, stream_h, &stream_h->focus_id);
if (ret == MM_ERROR_NONE) {
stream_h->user_cb = callback;
stream_h->user_data = user_data;
/* unregister focus */
if (!stream_h->is_focus_unavailable) {
- ret = mm_sound_unregister_focus(stream_h->index);
+ ret = mm_sound_unregister_focus(stream_h->focus_id);
if (ret)
LOGE("failed to unregister focus, ret(0x%x)", ret);
}
SM_INSTANCE_CHECK_FOR_PRIV(stream_info);
if (stream_info->stream_conf_info.route_type != STREAM_ROUTE_TYPE_MANUAL &&
- stream_info->stream_conf_info.route_type != STREAM_ROUTE_TYPE_MANUAL_EXT) {
+ stream_info->stream_conf_info.route_type != STREAM_ROUTE_TYPE_MANUAL_EXT) {
LOGE("route type is not manual or manual-ext");
/* Differ from others, it uses SOUND_INTERNAL error.
* ACR process is required prior to changing error value. */
for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
if (stream_info->manual_route_info.route_in_devices[i] ||
stream_info->manual_route_info.route_out_devices[i])
- return _set_manual_route_info(stream_info->index, &stream_info->manual_route_info);
+ return _set_manual_route_info(stream_info->pa_index, &stream_info->manual_route_info);
}
return MM_ERROR_SOUND_INVALID_STATE;
(*virtual_stream)->pa_context = stream_info->pa_context;
(*virtual_stream)->pa_proplist = pa_proplist_new();
pa_proplist_sets((*virtual_stream)->pa_proplist, PA_PROP_MEDIA_ROLE, (*virtual_stream)->stream_type);
- pa_proplist_setf((*virtual_stream)->pa_proplist, PA_PROP_MEDIA_PARENT_ID, "%u", stream_info->index);
+ pa_proplist_setf((*virtual_stream)->pa_proplist, PA_PROP_MEDIA_PARENT_ID, "%u", stream_info->pa_index);
(*virtual_stream)->state = _VSTREAM_STATE_READY;
(*virtual_stream)->stream_info = stream_info;
g_print("*** FOCUS callback is ended, stream_info(%p) ****\n\n", stream_info);
+#if 0 /* test for complicated scenario */
+ if (focus_state == SOUND_STREAM_FOCUS_STATE_RELEASED && recording_focus_state == SOUND_STREAM_FOCUS_STATE_ACQUIRED) {
+ g_print("### try to acquire playback focus now..\n");
+ ret = sound_manager_acquire_focus(stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, "in callback thread");
+ if (ret)
+ g_print("failed to acquire focus..ret:0x%x\n", ret);
+ g_print("### try to release recording focus now..\n");
+ ret = sound_manager_release_focus(stream_info, SOUND_STREAM_FOCUS_FOR_RECORDING, SOUND_BEHAVIOR_NONE, "in callback thread");
+ if (ret)
+ g_print("failed to release focus..ret:0x%x\n", ret);
+ }
+
+ if (focus_state == SOUND_STREAM_FOCUS_STATE_ACQUIRED && playback_focus_state == SOUND_STREAM_FOCUS_STATE_ACQUIRED) {
+ g_print("### try to release playback focus now..\n");
+ ret = sound_manager_release_focus(stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, "in callback thread");
+ if (ret)
+ g_print("failed to release focus..ret:0x%x\n", ret);
+ g_print("### try to acquire recording focus now..\n");
+ ret = sound_manager_acquire_focus(stream_info, SOUND_STREAM_FOCUS_FOR_RECORDING, SOUND_BEHAVIOR_NONE, "in callback thread");
+ if (ret)
+ g_print("failed to acquire focus..ret:0x%x\n", ret);
+ }
+#endif
+
return;
}