From 5ce37d84217fe94a57e810558b2e92d736452a14 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Fri, 14 Apr 2017 11:49:40 +0900 Subject: [PATCH] Fix to release internal focus of voip session when getting back to another session from the voip session focus state watch callback will be called if the voip session is changed to another session [Version] 0.3.111 [Profile] Common [Issue Type] Bug fix Change-Id: I9c3dbd1372360e4d302dc9c8e87a80260b8e609d Signed-off-by: Sangchul Lee --- include/sound_manager_private.h | 2 + packaging/capi-media-sound-manager.spec | 2 +- src/sound_manager.c | 67 ++++++++++++++++++--------------- src/sound_manager_private.c | 1 - 4 files changed, 40 insertions(+), 32 deletions(-) diff --git a/include/sound_manager_private.h b/include/sound_manager_private.h index 979f58b..dbe5cd9 100644 --- a/include/sound_manager_private.h +++ b/include/sound_manager_private.h @@ -128,6 +128,8 @@ if (pthread_mutex_unlock(x_mutex)) { \ #define DIRECTION_OUT_STR "out" #define SOUND_TYPE_MASTER_STR "master" +#define EXT_INFO_VOIP_SESSION "for voip session" + typedef enum _sound_stream_direction { SOUND_STREAM_DIRECTION_OUTPUT = 1, SOUND_STREAM_DIRECTION_INPUT diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index 062dfe9..d3d5116 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.110 +Version: 0.3.111 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/sound_manager.c b/src/sound_manager.c index 8f5ebde..872453a 100644 --- a/src/sound_manager.c +++ b/src/sound_manager.c @@ -675,37 +675,44 @@ int sound_manager_set_session_type(sound_session_type_e type) ((new_session == SOUND_SESSION_TYPE_MEDIA) && (cur_session == MM_SESSION_TYPE_MEDIA_RECORD))) { LOGI("already set type=%d, ret=0x%x", type, ret); goto LEAVE; - } else { - ret = mm_session_finish(); - if (ret != MM_ERROR_NONE) - goto LEAVE; + } + + ret = mm_session_finish(); + if (ret != MM_ERROR_NONE) + goto LEAVE; - g_session_interrupt_cb_table.is_registered = 0; - if (cur_session == MM_SESSION_TYPE_VOIP) { - /* De-initialize regarding VoIP session */ - g_cached_session_mode = -1; - g_cached_voip_device_id = -1; - g_cached_voip_device_id2 = -1; - if (g_voip_vstream_h) { - _stop_progress_virtual_stream(g_voip_vstream_h); - g_voip_vstream_h = NULL; - } - if (g_voip_ringtone_vstream_h) { - _stop_progress_virtual_stream(g_voip_ringtone_vstream_h); - g_voip_ringtone_vstream_h = NULL; - } - if (g_voip_stream_info) { - ret = _destroy_pa_connection_and_unregister_focus(g_voip_stream_info); - SM_SAFE_FREE(g_voip_stream_info); - if (ret != MM_ERROR_NONE) - goto LEAVE; - } - if (g_voip_ringtone_stream_info) { - ret = _destroy_pa_connection_and_unregister_focus(g_voip_ringtone_stream_info); - SM_SAFE_FREE(g_voip_ringtone_stream_info); - if (ret != MM_ERROR_NONE) - goto LEAVE; - } + g_session_interrupt_cb_table.is_registered = 0; + if (cur_session == MM_SESSION_TYPE_VOIP) { + /* De-initialize regarding VoIP session */ + g_cached_session_mode = -1; + g_cached_voip_device_id = -1; + g_cached_voip_device_id2 = -1; + if (g_voip_vstream_h) { + _stop_progress_virtual_stream(g_voip_vstream_h); + g_voip_vstream_h = NULL; + } + if (g_voip_ringtone_vstream_h) { + _stop_progress_virtual_stream(g_voip_ringtone_vstream_h); + g_voip_ringtone_vstream_h = NULL; + } + if (g_voip_ringtone_stream_info) { + if ((ret = mm_sound_release_focus(g_voip_ringtone_stream_info->index, g_voip_ringtone_stream_info->acquired_focus, EXT_INFO_VOIP_SESSION))) + LOGE("failed to release focus for ringtone-voip stream info, ret(0x%x)", ret); + } else if (g_voip_stream_info) { + if ((ret = mm_sound_release_focus(g_voip_stream_info->index, g_voip_stream_info->acquired_focus, EXT_INFO_VOIP_SESSION))) + LOGE("failed to release focus for voip stream info, ret(0x%x)", ret); + } + if (g_voip_stream_info) { + ret = _destroy_pa_connection_and_unregister_focus(g_voip_stream_info); + SM_SAFE_FREE(g_voip_stream_info); + if (ret != MM_ERROR_NONE) + goto LEAVE; + } + if (g_voip_ringtone_stream_info) { + ret = _destroy_pa_connection_and_unregister_focus(g_voip_ringtone_stream_info); + SM_SAFE_FREE(g_voip_ringtone_stream_info); + if (ret != MM_ERROR_NONE) + goto LEAVE; } } } diff --git a/src/sound_manager_private.c b/src/sound_manager_private.c index a35ba58..ce8139e 100644 --- a/src/sound_manager_private.c +++ b/src/sound_manager_private.c @@ -33,7 +33,6 @@ #define PA_STREAM_MANAGER_METHOD_NAME_UPDATE_FOCUS_STATUS "UpdateFocusStatus" #define VCONF_PATH_PREFIX_VOLUME "file/private/sound/volume/" #define VCONF_PATH_MAX 64 -#define EXT_INFO_VOIP_SESSION "for voip session" #define CHECK_AND_SET_DEVICE(x_dst_device1, x_dst_device2, x_src_device) \ do { \ -- 2.7.4