Remove unused destructor/constructor block
[platform/core/api/sound-manager.git] / src / sound_manager.c
index d50c826..eabfbc5 100644 (file)
 
 #include "sound_manager.h"
 #include "sound_manager_private.h"
-#include <system_info.h>
 
-#define FEATURE_MICROPHONE          "http://tizen.org/feature/microphone"
-
-_session_interrupt_info_s g_session_interrupt_cb_table = {0, 0, NULL, NULL};
-_volume_changed_info_s g_volume_changed_cb_table = {0, NULL, NULL};
-_device_connected_info_s g_device_connected_cb_table = {0, NULL, NULL};
-_device_changed_info_s g_device_info_changed_cb_table = {0, NULL, NULL};
 _focus_watch_info_s focus_watch_info_arr[SOUND_STREAM_INFO_ARR_MAX];
 
-sound_session_type_e g_cached_session = -1;
-_session_mode_e g_cached_session_mode = -1;
-int g_cached_voip_device_id = -1;
-extern sound_stream_info_s *g_voip_stream_info;
-extern virtual_sound_stream_info_s *g_voip_vstream_h;
-
-/* These variables will be removed when session features are deprecated. */
-extern int g_stream_info_count;
-extern pthread_mutex_t g_stream_info_count_mutex;
-pthread_mutex_t g_interrupt_cb_mutex, g_device_info_cb_mutex, g_device_conn_cb_mutex, g_volume_cb_mutex;
-
 int sound_manager_get_max_volume(sound_type_e type, int *max)
 {
        const char *volume_type = NULL;
@@ -44,7 +26,7 @@ int sound_manager_get_max_volume(sound_type_e type, int *max)
        int ret = MM_ERROR_NONE;
 
        SM_NULL_ARG_CHECK(max);
-       if (type >= SOUND_TYPE_NUM || type < 0)
+       if (type >= SOUND_TYPE_NUM)
                return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
 
        ret = _convert_sound_type(type, &volume_type);
@@ -61,7 +43,7 @@ int sound_manager_set_volume(sound_type_e type, int volume)
 {
        int ret = MM_ERROR_NONE;
 
-       if (type >= SOUND_TYPE_NUM || type < 0)
+       if (type >= SOUND_TYPE_NUM)
                return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
        if (volume < 0)
                return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
@@ -77,7 +59,7 @@ int sound_manager_get_volume(sound_type_e type, int *volume)
        int ret = MM_ERROR_NONE;
        unsigned int uvolume;
 
-       if (type >= SOUND_TYPE_NUM || type < 0)
+       if (type >= SOUND_TYPE_NUM)
                return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
        if (volume == NULL)
                return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
@@ -91,98 +73,21 @@ int sound_manager_get_volume(sound_type_e type, int *volume)
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_set_current_sound_type(sound_type_e type)
-{
-       int ret = MM_ERROR_NONE;
-
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release.", __func__);
-       if (type >= SOUND_TYPE_NUM || type < 0)
-               return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
-
-       ret = mm_sound_volume_primary_type_set(type);
-
-       return _convert_sound_manager_error_code(__func__, ret);
-}
-
 int sound_manager_get_current_sound_type(sound_type_e *type)
 {
        int ret = MM_ERROR_NONE;
-       volume_type_t mm_sound_vol_type = VOLUME_TYPE_UNKNOWN;
        char *volume_type = NULL;
 
        if (type == NULL)
                return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
 
-       ret  = mm_sound_volume_primary_type_get(&mm_sound_vol_type);
-       if (ret == MM_ERROR_NONE) {
-               if (mm_sound_vol_type == VOLUME_TYPE_UNKNOWN) {
-                       /* get the volume type of the current playing stream */
-                       ret = _get_current_volume_type(DIRECTION_OUT_STR, &volume_type);
-                       if (ret == MM_ERROR_NONE)
-                               ret = _convert_sound_type_to_enum((const char*)volume_type, type);
-               } else {
-                       *type = mm_sound_vol_type;
-               }
-       }
-       LOGI("type=%d", *type);
-
-       return _convert_sound_manager_error_code(__func__, ret);
-}
-
-int sound_manager_unset_current_sound_type(void)
-{
-       int ret = MM_ERROR_NONE;
-
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release.", __func__);
-       ret = mm_sound_volume_primary_type_set(VOLUME_TYPE_UNKNOWN);
-
-       return _convert_sound_manager_error_code(__func__, ret);
-}
-
-int sound_manager_set_volume_changed_cb(sound_manager_volume_changed_cb callback, void* user_data)
-{
-       int ret = MM_ERROR_NONE;
-       unsigned int subs_id = 0;
-
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. "
-               "Use sound_manager_add_volume_changed_cb() instead.", __func__);
-
-       SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_volume_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
-       ret = mm_sound_add_volume_changed_callback((mm_sound_volume_changed_cb)callback, user_data, &subs_id);
+       /* get the volume type of the current playing stream */
+       ret = _get_current_volume_type(DIRECTION_OUT_STR, &volume_type);
        if (ret == MM_ERROR_NONE) {
-               g_volume_changed_cb_table.subs_id = subs_id;
-               g_volume_changed_cb_table.user_cb = (sound_manager_volume_changed_cb)callback;
-               g_volume_changed_cb_table.user_data = user_data;
-       }
-
-       SM_LEAVE_CRITICAL_SECTION(&g_volume_cb_mutex);
-
-       return _convert_sound_manager_error_code(__func__, ret);
-}
-
-int sound_manager_unset_volume_changed_cb(void)
-{
-       int ret = MM_ERROR_NONE;
-
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. "
-               "Use sound_manager_remove_volume_changed_cb() instead.", __func__);
-
-       SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_volume_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
-       if (g_volume_changed_cb_table.subs_id > 0) {
-               ret = mm_sound_remove_volume_changed_callback(g_volume_changed_cb_table.subs_id);
-               if (ret == MM_ERROR_NONE) {
-                       g_volume_changed_cb_table.subs_id = 0;
-                       g_volume_changed_cb_table.user_cb = NULL;
-                       g_volume_changed_cb_table.user_data = NULL;
-               }
-       } else {
-               ret = MM_ERROR_SOUND_INTERNAL;
+               ret = _convert_sound_type_to_enum((const char*)volume_type, type);
+               LOGI("type=%d", *type);
        }
 
-       SM_LEAVE_CRITICAL_SECTION(&g_volume_cb_mutex);
-
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
@@ -218,11 +123,6 @@ int sound_manager_create_stream_information(sound_stream_type_e stream_type, sou
 
        SM_NULL_ARG_CHECK(stream_info);
 
-       if (g_session_interrupt_cb_table.is_registered)
-               return _convert_sound_manager_error_code(__func__, MM_ERROR_SOUND_INTERNAL);
-
-       SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, MM_ERROR_SOUND_INTERNAL);
-
        sound_stream_info_s *stream_h = malloc(sizeof(sound_stream_info_s));
        if (!stream_h) {
                ret = MM_ERROR_OUT_OF_MEMORY;
@@ -232,19 +132,17 @@ int sound_manager_create_stream_information(sound_stream_type_e stream_type, sou
        memset(stream_h, 0, sizeof(sound_stream_info_s));
        ret = _convert_stream_type(stream_type, &stream_h->stream_type);
        if (ret == MM_ERROR_NONE) {
-               ret = _make_pa_connection_and_register_focus(stream_h, false, callback, user_data);
+               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;
-                       SM_REF_FOR_STREAM_INFO(g_stream_info_count, ret);
-                       LOGI("stream_h(%p), index(%u), user_cb(%p), cnt(%d), ret(0x%x)", stream_h, stream_h->index, stream_h->user_cb, g_stream_info_count, 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);
                }
        }
 
 LEAVE:
-       if (ret && stream_h)
-               free(stream_h);
-
-       SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex);
+       if (ret)
+               SM_SAFE_FREE(stream_h);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
@@ -258,16 +156,12 @@ int sound_manager_destroy_stream_information(sound_stream_info_h stream_info)
 
        SM_INSTANCE_CHECK(stream_h);
 
-       SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, MM_ERROR_SOUND_INTERNAL);
+       SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_state_mutex, MM_ERROR_SOUND_INTERNAL);
        ret = _destroy_pa_connection_and_unregister_focus(stream_h);
+       SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_state_mutex);
        if (ret == MM_ERROR_NONE) {
-               free(stream_h);
-               stream_h = NULL;
-               SM_UNREF_FOR_STREAM_INFO(g_stream_info_count);
+               SM_SAFE_FREE(stream_h);
        }
-       SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex);
-
-       LOGD("cnt(%d)", g_stream_info_count);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
@@ -318,6 +212,18 @@ int sound_manager_remove_device_for_stream_routing(sound_stream_info_h stream_in
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
+int sound_manager_remove_all_devices_for_stream_routing(sound_stream_info_h stream_info)
+{
+       int ret = MM_ERROR_NONE;
+       sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
+
+       LOGI(">> enter");
+
+       ret = _remove_all_devices_for_stream_routing(stream_h);
+
+       return _convert_sound_manager_error_code(__func__, ret);
+}
+
 int sound_manager_apply_stream_routing(sound_stream_info_h stream_info)
 {
        int ret = MM_ERROR_NONE;
@@ -339,7 +245,9 @@ int sound_manager_set_focus_reacquisition(sound_stream_info_h stream_info, bool
 
        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);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
@@ -354,7 +262,9 @@ int sound_manager_get_focus_reacquisition(sound_stream_info_h stream_info, bool
        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);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
@@ -362,14 +272,19 @@ int sound_manager_get_focus_reacquisition(sound_stream_info_h stream_info, bool
 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;
+       bool is_focus_cb_thread = false;
+       bool is_focus_watch_cb_thread = false;
        sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
 
        LOGI(">> enter");
 
        SM_INSTANCE_CHECK(stream_h);
 
+       if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, &is_focus_watch_cb_thread)))
+               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);
        }
 
@@ -378,46 +293,253 @@ 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, sound_behavior, extra_info);
+       if (!is_focus_cb_thread) {
+               SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
+               SM_ENTER_CRITICAL_SECTION_WITH_UNLOCK_AND_RETURN(&stream_h->focus_state_mutex, &stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
+       } else {
+               /* If it is inside of the watch cb and if the previous request of this process has not been finished yet,
+                * the focus state mutex could be still locked. Therefore, it returns error here. */
+               if (is_focus_watch_cb_thread && stream_h->is_requesting) {
+                       LOGE("It is not allowed in watch cb thread during the previous request has not been finished yet");
+                       return _convert_sound_manager_error_code(__func__, MM_ERROR_SOUND_INVALID_OPERATION);
+               }
+               SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_state_mutex, MM_ERROR_SOUND_INTERNAL);
+       }
+
+       if (stream_h->acquired_focus & focus_mask) {
+               LOGE("invalid state: focus_mask[0x%x], acquired_focus[0x%x]", focus_mask, stream_h->acquired_focus);
+               ret = MM_ERROR_SOUND_INVALID_STATE;
+               goto LEAVE;
+       }
+
+       if (is_focus_cb_thread && ((stream_h->prev_acquired_focus & ~stream_h->acquired_focus) & focus_mask)) {
+               LOGE("just lost focus in this callback, it is not allowed to acquire the focus[0x%x] again. acquired_focus[0x%x], prev[0x%x]",
+                       focus_mask, stream_h->acquired_focus, stream_h->prev_acquired_focus);
+               ret = MM_ERROR_POLICY_INTERNAL;
+               goto LEAVE;
+       }
+
+       stream_h->is_requesting = true;
+
+       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;
-               _update_focus_status(stream_h->index, (unsigned int)stream_h->acquired_focus);
+               stream_h->prev_acquired_focus |= focus_mask;
+               _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);
+
+LEAVE:
+       stream_h->is_requesting = false;
+       SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_state_mutex);
+       if (!is_focus_cb_thread)
+               SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_cb_mutex);
+
        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, int sound_behavior, const char *extra_info)
 {
        int ret = MM_ERROR_NONE;
+       bool is_focus_cb_thread = false;
+       bool is_focus_watch_cb_thread = false;
        sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
 
        LOGI(">> enter");
 
        SM_INSTANCE_CHECK(stream_h);
 
-       ret = mm_sound_release_focus_with_option(stream_h->index, (mm_sound_focus_type_e)focus_mask, sound_behavior, extra_info);
+       if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, &is_focus_watch_cb_thread)))
+               return _convert_sound_manager_error_code(__func__, ret);
+
+       if (!is_focus_cb_thread) {
+               SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
+               SM_ENTER_CRITICAL_SECTION_WITH_UNLOCK_AND_RETURN(&stream_h->focus_state_mutex, &stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
+       } else {
+               /* If it is inside of the watch cb and if the previous request of this process has not been finished yet,
+                * the focus state mutex could be still locked. Therefore, it returns error here. */
+               if (is_focus_watch_cb_thread && stream_h->is_requesting) {
+                       LOGE("It is not allowed in watch cb thread during the previous request has not been finished yet");
+                       return _convert_sound_manager_error_code(__func__, MM_ERROR_SOUND_INVALID_OPERATION);
+               }
+               SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_state_mutex, MM_ERROR_SOUND_INTERNAL);
+       }
+
+       if (!(stream_h->acquired_focus & focus_mask)) {
+               LOGE("invalid state: focus_mask[0x%x], acquired_focus[0x%x]", focus_mask, stream_h->acquired_focus);
+               ret = MM_ERROR_SOUND_INVALID_STATE;
+               goto LEAVE;
+       }
+
+       if (is_focus_cb_thread && ((stream_h->prev_acquired_focus & stream_h->acquired_focus) != focus_mask)) {
+               LOGE("just acquired focus in this callback, it is not allowed to release the focus[0x%x] again. acquired_focus[0x%x], prev[0x%x]",
+                       focus_mask, stream_h->acquired_focus, stream_h->prev_acquired_focus);
+               ret = MM_ERROR_SOUND_INVALID_STATE;
+               goto LEAVE;
+       }
+
+       stream_h->is_requesting = true;
+
+       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;
-               _update_focus_status(stream_h->index, (unsigned int)stream_h->acquired_focus);
+               stream_h->prev_acquired_focus &= ~focus_mask;
+               _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);
+
+LEAVE:
+       stream_h->is_requesting = false;
+       SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_state_mutex);
+       if (!is_focus_cb_thread)
+               SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_cb_mutex);
+
        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 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;
+       bool is_focus_cb_thread = false;
+       bool is_focus_watch_cb_thread = false;
        sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
 
        LOGI(">> enter");
 
        SM_INSTANCE_CHECK(stream_h);
-       if (!state_for_playback && !state_for_recording) {
-               ret = MM_ERROR_INVALID_ARGUMENT;
+
+       if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, &is_focus_watch_cb_thread)))
+               return _convert_sound_manager_error_code(__func__, ret);
+
+       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 (!is_focus_cb_thread) {
+               SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
+               SM_ENTER_CRITICAL_SECTION_WITH_UNLOCK_AND_RETURN(&stream_h->focus_state_mutex, &stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
+       } else {
+               /* If it is inside of the watch cb and if the previous request of this process has not been finished yet,
+                * the focus state mutex could be still locked. Therefore, it returns error here. */
+               if (is_focus_watch_cb_thread && stream_h->is_requesting) {
+                       LOGE("It is not allowed in watch cb thread during the previous request has not been finished yet");
+                       return _convert_sound_manager_error_code(__func__, MM_ERROR_SOUND_INVALID_OPERATION);
+               }
+               SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_state_mutex, MM_ERROR_SOUND_INTERNAL);
+       }
+
+       if (is_focus_cb_thread && (stream_h->prev_acquired_focus > stream_h->acquired_focus)) {
+               LOGE("just lost focus in this callback, it is not allowed to acquire all again. acquired_focus[0x%x], prev[0x%x]",
+                       stream_h->acquired_focus, stream_h->prev_acquired_focus);
+               ret = MM_ERROR_POLICY_INTERNAL;
+               goto LEAVE;
+       }
+
+       focus_mask = SOUND_STREAM_FOCUS_FOR_BOTH & ~(stream_h->acquired_focus);
+       if (!focus_mask) {
+               LOGI("PLAYBACK/RECORDING focuses have already been ACQUIRED");
+               ret = MM_ERROR_NONE;
+               goto LEAVE;
+       }
+
+       stream_h->is_requesting = true;
+
+       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->pa_index, (unsigned int)stream_h->acquired_focus);
+       }
+
+LEAVE:
+       stream_h->is_requesting = false;
+       SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_state_mutex);
+       if (!is_focus_cb_thread)
+               SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_cb_mutex);
+
+       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;
+       bool is_focus_cb_thread = false;
+       bool is_focus_watch_cb_thread = false;
+       sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
+
+       LOGI(">> enter");
+
+       SM_INSTANCE_CHECK(stream_h);
+
+       if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, &is_focus_watch_cb_thread)))
+               return _convert_sound_manager_error_code(__func__, ret);
+
+       if (!is_focus_cb_thread) {
+               SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
+               SM_ENTER_CRITICAL_SECTION_WITH_UNLOCK_AND_RETURN(&stream_h->focus_state_mutex, &stream_h->focus_cb_mutex, MM_ERROR_SOUND_INTERNAL);
+       } else {
+               /* If it is inside of the watch cb and if the previous request of this process has not been finished yet,
+                * the focus state mutex could be still locked. Therefore, it returns error here. */
+               if (is_focus_watch_cb_thread && stream_h->is_requesting) {
+                       LOGE("It is not allowed in watch cb thread during the previous request has not been finished yet");
+                       return _convert_sound_manager_error_code(__func__, MM_ERROR_SOUND_INVALID_OPERATION);
+               }
+               SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_state_mutex, MM_ERROR_SOUND_INTERNAL);
+       }
+
+       if (is_focus_cb_thread && (stream_h->prev_acquired_focus < stream_h->acquired_focus)) {
+               LOGE("just acquired focus in this callback, it is not allowed to release all again. acquired_focus[0x%x], prev[0x%x]",
+                       stream_h->acquired_focus, stream_h->prev_acquired_focus);
+               ret = MM_ERROR_POLICY_INTERNAL;
+               goto LEAVE;
+       }
+
+       if (!stream_h->acquired_focus) {
+               LOGI("PLAYBACK/RECORDING focuses have already been RELEASED");
+               ret = MM_ERROR_NONE;
                goto LEAVE;
        }
 
+       stream_h->is_requesting = true;
+
+       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->pa_index, (unsigned int)stream_h->acquired_focus);
+       }
+
+LEAVE:
+       stream_h->is_requesting = false;
+       SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_state_mutex);
+       if (!is_focus_cb_thread)
+               SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_cb_mutex);
+
+       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;
+       sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
+
+       LOGI(">> enter");
+
+       SM_INSTANCE_CHECK(stream_h);
+       if (!state_for_playback && !state_for_recording)
+               return SOUND_MANAGER_ERROR_INVALID_PARAMETER;
+
+       SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&stream_h->focus_state_mutex, MM_ERROR_SOUND_INTERNAL);
+
        if (state_for_playback)
                *state_for_playback = ((stream_h->acquired_focus & SOUND_STREAM_FOCUS_FOR_PLAYBACK) ? (SOUND_STREAM_FOCUS_STATE_ACQUIRED) : (SOUND_STREAM_FOCUS_STATE_RELEASED));
        if (state_for_recording)
@@ -425,7 +547,61 @@ int sound_manager_get_focus_state(sound_stream_info_h stream_info, sound_stream_
 
        LOGI("acquired_focus(0x%x)", stream_h->acquired_focus);
 
-LEAVE:
+       SM_LEAVE_CRITICAL_SECTION(&stream_h->focus_state_mutex);
+
+       return _convert_sound_manager_error_code(__func__, ret);
+}
+
+int sound_manager_deliver_focus(sound_stream_info_h source, sound_stream_info_h destination, sound_stream_focus_mask_e focus_mask)
+{
+       int ret = MM_ERROR_NONE;
+       sound_stream_info_s *src_stream_h = (sound_stream_info_s*)source;
+       sound_stream_info_s *dst_stream_h = (sound_stream_info_s*)destination;
+       bool is_focus_cb_thread = false;
+
+       LOGI(">> enter");
+
+       SM_INSTANCE_CHECK(src_stream_h);
+       SM_INSTANCE_CHECK(dst_stream_h);
+
+       if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, NULL)))
+               return _convert_sound_manager_error_code(__func__, ret);
+
+       if (is_focus_cb_thread) {
+               LOGE("not allowed calling this function in focus(watch) callback");
+               return SOUND_MANAGER_ERROR_INVALID_OPERATION;
+       }
+
+       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;
+       }
+
+       if (src_stream_h->is_focus_unavailable || dst_stream_h->is_focus_unavailable) {
+               LOGE("focus is unavailable for source(%d)/destination(%d)",
+                       src_stream_h->is_focus_unavailable, dst_stream_h->is_focus_unavailable);
+               return SOUND_MANAGER_ERROR_POLICY;
+       }
+
+       if (!(src_stream_h->acquired_focus & focus_mask) || (src_stream_h->acquired_focus < focus_mask)) {
+               LOGE("could not deliver the request focus(0x%x), current acquired focus(0x%x)",
+                       focus_mask, src_stream_h->acquired_focus);
+               return SOUND_MANAGER_ERROR_INVALID_STATE;
+       }
+
+       if (dst_stream_h->user_cb == NULL) {
+               LOGE("focus state changed callback should be set to destination handle");
+               return SOUND_MANAGER_ERROR_POLICY;
+       }
+
+       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;
+               dst_stream_h->acquired_focus |= focus_mask;
+               dst_stream_h->prev_acquired_focus |= focus_mask;
+       }
+
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
@@ -440,7 +616,7 @@ int sound_manager_is_stream_on_device(sound_stream_info_h stream_info, sound_dev
        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);
 }
@@ -471,7 +647,7 @@ int sound_manager_get_current_playback_focus(sound_stream_focus_change_reason_e
        SM_NULL_ARG_CHECK(acquired_by);
        SM_NULL_ARG_CHECK(flags);
 
-       if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread)))
+       if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, NULL)))
                return _convert_sound_manager_error_code(__func__, ret);
 
        if (is_focus_cb_thread) {
@@ -487,10 +663,10 @@ int sound_manager_get_current_playback_focus(sound_stream_focus_change_reason_e
                        LOGI("                                : reason[%d], flags[0x%x], extra_info[%s]", *acquired_by, option, extra_info_str);
                        *flags = option;
                        if (extra_info)
-                               *extra_info = extra_info_str;
-                       else
-                               free(extra_info_str);
+                               *extra_info = strdup(extra_info_str);
                }
+               SM_SAFE_FREE(stream_type_str);
+               SM_SAFE_FREE(extra_info_str);
        }
 
        return _convert_sound_manager_error_code(__func__, ret);
@@ -509,7 +685,7 @@ int sound_manager_get_current_recording_focus(sound_stream_focus_change_reason_e
        SM_NULL_ARG_CHECK(acquired_by);
        SM_NULL_ARG_CHECK(flags);
 
-       if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread)))
+       if ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread, NULL)))
                return _convert_sound_manager_error_code(__func__, ret);
 
        if (is_focus_cb_thread) {
@@ -525,10 +701,10 @@ int sound_manager_get_current_recording_focus(sound_stream_focus_change_reason_e
                        LOGI("                                 : reason[%d], flags[0x%x], extra_info[%s]", *acquired_by, option, extra_info_str);
                        *flags = option;
                        if (extra_info)
-                               *extra_info = extra_info_str;
-                       else
-                               free(extra_info_str);
+                               *extra_info = strdup(extra_info_str);
                }
+               SM_SAFE_FREE(stream_type_str);
+               SM_SAFE_FREE(extra_info_str);
        }
 
        return _convert_sound_manager_error_code(__func__, ret);
@@ -543,29 +719,27 @@ int sound_manager_add_focus_state_watch_cb(sound_stream_focus_mask_e focus_mask,
 
        SM_NULL_ARG_CHECK(callback);
        SM_NULL_ARG_CHECK(id);
-       SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, SOUND_MANAGER_ERROR_INTERNAL);
 
        for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++)
                if (focus_watch_info_arr[i].id == 0)
                        break;
        if (i == SOUND_STREAM_INFO_ARR_MAX) {
+               //LCOV_EXCL_START
                LOGE("focus watch info array is full");
                ret = MM_ERROR_SOUND_INTERNAL;
                goto LEAVE;
+               //LCOV_EXCL_STOP
        }
 
-       ret = mm_sound_set_focus_watch_callback((mm_sound_focus_type_e)focus_mask, _focus_watch_callback, user_data, id);
+       ret = mm_sound_set_focus_watch_callback((mm_sound_focus_type_e)focus_mask, _focus_watch_callback, &focus_watch_info_arr[i], id);
        if (ret == MM_ERROR_NONE) {
-               SM_REF_FOR_STREAM_INFO(g_stream_info_count, ret);
                focus_watch_info_arr[i].id = *id;
                focus_watch_info_arr[i].user_data = user_data;
                focus_watch_info_arr[i].user_cb = callback;
        }
 
 LEAVE:
-       SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex);
-
-       LOGD("cnt(%d), id(%d)", g_stream_info_count, *id);
+       LOGD("id(%d)", *id);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
@@ -577,8 +751,6 @@ int sound_manager_remove_focus_state_watch_cb(int id)
 
        LOGI(">> enter");
 
-       SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
        for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++)
                if (focus_watch_info_arr[i].id == id)
                        break;
@@ -590,680 +762,291 @@ int sound_manager_remove_focus_state_watch_cb(int id)
 
        ret = mm_sound_unset_focus_watch_callback(id);
        if (ret == MM_ERROR_NONE) {
-               SM_UNREF_FOR_STREAM_INFO(g_stream_info_count);
                focus_watch_info_arr[i].id = 0;
                focus_watch_info_arr[i].user_data = NULL;
                focus_watch_info_arr[i].user_cb = NULL;
        }
 
 LEAVE:
-       SM_LEAVE_CRITICAL_SECTION(&g_stream_info_count_mutex);
-
-       LOGD("cnt(%d)", g_stream_info_count);
-
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_set_session_type(sound_session_type_e type)
+int sound_manager_get_device_list(int device_mask, sound_device_list_h *device_list)
 {
        int ret = MM_ERROR_NONE;
-       int cur_session = -1;
-       int new_session = MM_SESSION_TYPE_MEDIA;
-       bool mic_enable = false;
-
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
-       LOGI(">> enter : type=%d", type);
-
-       if (type < SOUND_SESSION_TYPE_MEDIA || type >  SOUND_SESSION_TYPE_VOIP)
-               return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
-
-       /* If session type is VOIP but MIC is not enabled, return false */
-       if (type == SOUND_SESSION_TYPE_VOIP) {
-               ret = system_info_get_platform_bool(FEATURE_MICROPHONE, &mic_enable);
-               LOGI("system_info_platform [%s]=[%d], ret[%d]", FEATURE_MICROPHONE, mic_enable, ret);
-               if (ret != SYSTEM_INFO_ERROR_NONE || !mic_enable)
-                       return _convert_sound_manager_error_code(__func__, MM_ERROR_NOT_SUPPORT_API);
-       }
-
-       /* it is not supported both session and stream feature at the same time */
-       if (g_stream_info_count) {
-               LOGE("Could not set this type(%d) because of being used stream feature", type);
-               return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
-       }
-
-       switch (type) {
-       case SOUND_SESSION_TYPE_MEDIA:
-               new_session = MM_SESSION_TYPE_MEDIA;
-               break;
-       case SOUND_SESSION_TYPE_ALARM:
-               new_session = MM_SESSION_TYPE_ALARM;
-               break;
-       case SOUND_SESSION_TYPE_NOTIFICATION:
-               new_session = MM_SESSION_TYPE_NOTIFY;
-               break;
-       case SOUND_SESSION_TYPE_EMERGENCY:
-               new_session = MM_SESSION_TYPE_EMERGENCY;
-               break;
-       case SOUND_SESSION_TYPE_VOIP:
-               new_session = MM_SESSION_TYPE_VOIP;
-               break;
-       }
-
-       /* valid session check */
-       ret = mm_session_get_current_type(&cur_session);
-       if (ret == MM_ERROR_NONE) {
-               if (cur_session == MM_SESSION_TYPE_MEDIA_RECORD) {
-                       if (type > SOUND_SESSION_TYPE_MEDIA) {
-                               LOGE("Could not set this type(%d) during camera/recorder/audio-io(in)/radio", type);
-                               return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
-                       }
-               }
-       }
 
-       if (g_session_interrupt_cb_table.is_registered) {
-               if (new_session == cur_session ||
-                       ((new_session == SOUND_SESSION_TYPE_MEDIA) && (cur_session == MM_SESSION_TYPE_MEDIA_RECORD))) {
-                       LOGI("already set type=%d, ret=0x%x", type, ret);
-                       return SOUND_MANAGER_ERROR_NONE;
-               } else {
-                       ret = mm_session_finish();
-                       if (ret != MM_ERROR_NONE)
-                               return _convert_sound_manager_error_code(__func__, ret);
-
-                       g_session_interrupt_cb_table.is_registered = 0;
-                       if (cur_session == MM_SESSION_TYPE_VOIP) {
-                               g_cached_session_mode = -1;
-                               g_cached_voip_device_id = -1;
-                               if (g_voip_vstream_h) {
-                                       _stop_virtual_stream(g_voip_vstream_h);
-                                       _destroy_virtual_stream(g_voip_vstream_h);
-                                       g_voip_vstream_h = NULL;
-                               }
-                               /*voip stream destruction*/
-                               if (g_voip_stream_info) {
-                                       ret = _destroy_pa_connection_and_unregister_focus(g_voip_stream_info);
-                                       free(g_voip_stream_info);
-                                       g_voip_stream_info = NULL;
-                                       if (ret != MM_ERROR_NONE)
-                                               return _convert_sound_manager_error_code(__func__, ret);
-                               }
-                       }
-               }
-       }
-       ret = mm_session_init(new_session);
-       if (ret == MM_ERROR_NONE)
-               g_session_interrupt_cb_table.is_registered = 1;
-
-       LOGI("type=%d", type);
+       ret = mm_sound_get_device_list(device_mask, device_list);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_get_session_type(sound_session_type_e *type)
+int sound_manager_free_device_list(sound_device_list_h device_list)
 {
        int ret = MM_ERROR_NONE;
-       int cur_session;
-
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release.", __func__);
-       if (type == NULL)
-               return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
-
-       ret = mm_session_get_current_type(&cur_session);
-       if (ret != MM_ERROR_NONE) {
-               LOGW("session hasn't been set, setting default session");
-               cur_session = SOUND_SESSION_TYPE_DEFAULT;
-               ret = mm_session_init(cur_session);
-               if (ret == MM_ERROR_NONE)
-                       g_session_interrupt_cb_table.is_registered = 1;
-       }
-       if ((cur_session > MM_SESSION_TYPE_EMERGENCY) &&
-                       (cur_session != MM_SESSION_TYPE_VOIP)) {
-               if (g_cached_session != -1)
-                       cur_session = g_cached_session;
-               else /* will be never reached here. just prevent code */
-                       cur_session = SOUND_SESSION_TYPE_DEFAULT;
-       }
 
-       switch (cur_session) {
-       case MM_SESSION_TYPE_MEDIA:
-       case MM_SESSION_TYPE_MEDIA_RECORD:
-               *type = SOUND_SESSION_TYPE_MEDIA;
-               break;
-       case MM_SESSION_TYPE_ALARM:
-               *type = SOUND_SESSION_TYPE_ALARM;
-               break;
-       case MM_SESSION_TYPE_NOTIFY:
-               *type = SOUND_SESSION_TYPE_NOTIFICATION;
-               break;
-       case MM_SESSION_TYPE_EMERGENCY:
-               *type = SOUND_SESSION_TYPE_EMERGENCY;
-               break;
-       case MM_SESSION_TYPE_VOIP:
-               *type = SOUND_SESSION_TYPE_VOIP;
-               break;
-       default:
-               *type = cur_session;
-               break;
-       }
-
-       LOGI("type=%d", *type);
+       ret = mm_sound_free_device_list(device_list);
 
-       return SOUND_MANAGER_ERROR_NONE;
+       return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_set_media_session_option(sound_session_option_for_starting_e s_option, sound_session_option_for_during_play_e d_option)
+int sound_manager_get_next_device(sound_device_list_h device_list, sound_device_h *device)
 {
        int ret = MM_ERROR_NONE;
-       int session = 0;
-       int session_option = 0;
-       int updated = 0;
-
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
-       LOGI(">> enter : option for starting=%d, for during play=%d", s_option, d_option);
-
-       if (s_option < 0 || s_option >  SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START)
-               return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
-       if (d_option < 0 || d_option >  SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY)
-               return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
-
-       ret = mm_session_get_current_information(&session, &session_option);
-       if (ret != 0 || !g_session_interrupt_cb_table.is_registered) {
-               LOGW("session hasn't been set, setting default session");
-               ret = mm_session_init(MM_SESSION_TYPE_MEDIA);
-               if (ret == 0)
-                       g_session_interrupt_cb_table.is_registered = 1;
-
-       } else if (ret == 0 && session > MM_SESSION_TYPE_MEDIA) {
-               if (session == MM_SESSION_TYPE_MEDIA_RECORD) {
-                       if (!g_session_interrupt_cb_table.is_registered) {
-                               LOGE("Already set by camera/recorder/audio-io(in)/radio API, but need to set session to Media first");
-                               return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
-                       }
-               } else {
-                       return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
-               }
-       }
-
-       switch (s_option) {
-       case SOUND_SESSION_OPTION_MIX_WITH_OTHERS_WHEN_START:
-               if (session_option & MM_SESSION_OPTION_PAUSE_OTHERS) {
-                       ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_REMOVE, MM_SESSION_OPTION_PAUSE_OTHERS);
-                       if (ret)
-                               return _convert_sound_manager_error_code(__func__, ret);
-
-                       updated = 1;
-               }
-               break;
-       case SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START:
-               if (!(session_option & MM_SESSION_OPTION_PAUSE_OTHERS)) {
-                       ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_ADD, MM_SESSION_OPTION_PAUSE_OTHERS);
-                       if (ret)
-                               return _convert_sound_manager_error_code(__func__, ret);
-
-                       updated = 1;
-               }
-               break;
-       }
-
-       switch (d_option) {
-       case SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY:
-               if (session_option & MM_SESSION_OPTION_UNINTERRUPTIBLE) {
-                       ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_REMOVE, MM_SESSION_OPTION_UNINTERRUPTIBLE);
-                       if (ret)
-                               return _convert_sound_manager_error_code(__func__, ret);
-
-                       updated = 1;
-               }
-               break;
-       case SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY:
-               if (!(session_option & MM_SESSION_OPTION_UNINTERRUPTIBLE)) {
-                       ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_ADD, MM_SESSION_OPTION_UNINTERRUPTIBLE);
-                       if (ret)
-                               return _convert_sound_manager_error_code(__func__, ret);
-
-                       updated = 1;
-               }
-               break;
-       }
 
-       if (updated)
-               LOGI("updated");
-       else
-               LOGI("already set same option(%x), skip it", session_option);
+       ret = mm_sound_get_next_device(device_list, device);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_get_media_session_option(sound_session_option_for_starting_e *s_option, sound_session_option_for_during_play_e *d_option)
+int sound_manager_get_prev_device(sound_device_list_h device_list, sound_device_h *device)
 {
        int ret = MM_ERROR_NONE;
-       int session = 0;
-       int session_options = 0;
-
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
-       LOGI(">> enter");
-
-       if (s_option == NULL || d_option == NULL)
-               return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
 
-       ret = mm_session_get_current_information(&session, &session_options);
-       if (ret != 0) {
-               ret = mm_session_init(MM_SESSION_TYPE_MEDIA);
-               if (ret == 0)
-                       g_session_interrupt_cb_table.is_registered = 1;
-
-       } else if (session > SOUND_SESSION_TYPE_MEDIA) {
-               if (session == MM_SESSION_TYPE_MEDIA_RECORD) {
-                       if (!g_session_interrupt_cb_table.is_registered) {
-                               LOGE("Already set by camera/recorder/audio-io(in)/radio API, but need to set session to Media first");
-                               return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
-                       }
-               } else
-                       return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
-       }
-       /* get option */
-       if (session_options & MM_SESSION_OPTION_PAUSE_OTHERS)
-               *s_option = SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START;
-       else
-               *s_option = SOUND_SESSION_OPTION_MIX_WITH_OTHERS_WHEN_START;
-
-       if (session_options & MM_SESSION_OPTION_UNINTERRUPTIBLE)
-               *d_option = SOUND_SESSION_OPTION_UNINTERRUPTIBLE_DURING_PLAY;
-       else
-               *d_option = SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY;
-
-       LOGI(" option for starting=%d, for during play=%d", *s_option, *d_option);
+       ret = mm_sound_get_prev_device(device_list, device);
 
-       return SOUND_MANAGER_ERROR_NONE;
+       return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_set_media_session_resumption_option(sound_session_option_for_resumption_e option)
+int sound_manager_get_device_type(sound_device_h device, sound_device_type_e *type)
 {
        int ret = MM_ERROR_NONE;
-       int session = 0;
-       int session_option = 0;
-       int updated = 0;
-
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
-       LOGI(">> enter : option for resumption=%d (0:by system, 1:by system or media paused)", option);
-
-       if (option < SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM || option > SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED)
-               return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
-
-       ret = mm_session_get_current_information(&session, &session_option);
-       if (ret != 0 || !g_session_interrupt_cb_table.is_registered) {
-               LOGW("session hasn't been set, setting default session");
-               ret = mm_session_init(MM_SESSION_TYPE_MEDIA);
-               if (ret == 0)
-                       g_session_interrupt_cb_table.is_registered = 1;
-
-       } else if (ret == 0 && session > MM_SESSION_TYPE_MEDIA) {
-               if (session == MM_SESSION_TYPE_MEDIA_RECORD) {
-                       if (!g_session_interrupt_cb_table.is_registered) {
-                               LOGE("Already set by camera/recorder/audio-io(in)/radio API, but need to set session to Media first");
-                               return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
-                       }
-               } else
-                       return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
-
-       }
-
-       switch (option) {
-       case SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM:
-               if (session_option & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED) {
-                       ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_REMOVE, MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED);
-                       if (ret)
-                               return _convert_sound_manager_error_code(__func__, ret);
-
-                       updated = 1;
-               }
-               break;
-       case SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED:
-               if (!(session_option & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED)) {
-                       ret = mm_session_update_option(MM_SESSION_UPDATE_TYPE_ADD, MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED);
-                       if (ret)
-                               return _convert_sound_manager_error_code(__func__, ret);
-
-                       updated = 1;
-               }
-               break;
-       }
+       mm_sound_device_type_e mm_sound_device_type;
 
-       if (updated)
-               LOGI("updated");
-       else
-               LOGI("already set same option(0x%x), skip it", session_option);
+       ret = mm_sound_get_device_type(device, &mm_sound_device_type);
+       if (ret == MM_ERROR_NONE)
+               ret = _convert_device_type(mm_sound_device_type, type);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_get_media_session_resumption_option(sound_session_option_for_resumption_e *option)
+int sound_manager_get_device_io_direction(sound_device_h device, sound_device_io_direction_e *io_direction)
 {
        int ret = MM_ERROR_NONE;
-       int session = 0;
-       int session_options = 0;
-
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
-       LOGI(">> enter");
-
-       if (option == NULL)
-               return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
-
-       ret = mm_session_get_current_information(&session, &session_options);
-       if (ret != 0) {
-               LOGW("session hasn't been set, setting default session");
-               ret = mm_session_init(MM_SESSION_TYPE_MEDIA);
-               if (ret == 0)
-                       g_session_interrupt_cb_table.is_registered = 1;
-
-       } else if (session > SOUND_SESSION_TYPE_MEDIA) {
-               if (session == MM_SESSION_TYPE_MEDIA_RECORD) {
-                       if (!g_session_interrupt_cb_table.is_registered) {
-                               LOGE("Already set by camera/recorder/audio-io(in)/radio API, but need to set session to Media first");
-                               return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
-                       }
-               } else
-                       return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL);
-       }
-       /* get option */
-       if (session_options & MM_SESSION_OPTION_RESUME_BY_SYSTEM_OR_MEDIA_PAUSED)
-               *option = SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM_OR_MEDIA_PAUSED;
-       else
-               *option = SOUND_SESSION_OPTION_RESUMPTION_BY_SYSTEM;
+       mm_sound_device_io_direction_e mm_sound_io_direction;
 
-       LOGI("option for resumption=%d (0:by system, 1:by system or media paused)", *option);
+       ret = mm_sound_get_device_io_direction(device, &mm_sound_io_direction);
+       if (ret == MM_ERROR_NONE)
+               ret = _convert_device_io_direction(mm_sound_io_direction, io_direction);
 
-       return SOUND_MANAGER_ERROR_NONE;
+       return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_set_voip_session_mode(sound_session_voip_mode_e mode)
+int sound_manager_get_device_id(sound_device_h device, int *id)
 {
        int ret = MM_ERROR_NONE;
-       int session = 0;
-       int session_options = 0;
-
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
-       LOGI(">> enter : mode=%d", mode);
-
-       ret = mm_session_get_current_information(&session, &session_options);
-       if (ret != MM_ERROR_NONE)
-               goto LEAVE;
-
-       if (session != MM_SESSION_TYPE_VOIP) {
-               ret = MM_ERROR_POLICY_INTERNAL;
-               goto LEAVE;
-       }
-
-       if (mode < SOUND_SESSION_VOIP_MODE_RINGTONE || mode > SOUND_SESSION_VOIP_MODE_VOICE_WITH_BLUETOOTH) {
-               ret = MM_ERROR_INVALID_ARGUMENT;
-               goto LEAVE;
-       }
 
-       ret = _set_session_mode((_session_mode_e)mode);
-
-       LOGI("session=%d, mode=%d", session, mode);
+       ret = mm_sound_get_device_id(device, id);
 
-LEAVE:
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_get_voip_session_mode(sound_session_voip_mode_e *mode)
+int sound_manager_get_device_name(sound_device_h device, char **name)
 {
        int ret = MM_ERROR_NONE;
-       int session = 0;
-       int session_options = 0;
-
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
-       if (mode == NULL) {
-               LOGE("mode is null");
-               ret = MM_ERROR_INVALID_ARGUMENT;
-               goto LEAVE;
-       }
-
-       ret = mm_session_get_current_information(&session, &session_options);
-       if (ret != MM_ERROR_NONE) {
-               LOGI("session = %d, option = %d", session, session_options);
-               goto LEAVE;
-       }
-
-       if (session != MM_SESSION_TYPE_VOIP || g_cached_session_mode == -1) {
-               ret = MM_ERROR_POLICY_INTERNAL;
-               goto LEAVE;
-       }
-
-       *mode = (sound_session_voip_mode_e)g_cached_session_mode;
 
-       LOGI("session=%d, mode=%d", session, *mode);
+       ret = mm_sound_get_device_name(device, name);
 
-LEAVE:
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_set_session_interrupted_cb(sound_session_interrupted_cb callback, void *user_data)
+int sound_manager_is_device_running(sound_device_h device, bool *is_running)
 {
        int ret = MM_ERROR_NONE;
-       unsigned int subs_id = 0;
 
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_create_stream_information() instead.", __func__);
-       SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_interrupt_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
+       LOGI(">> enter");
 
-       if (callback == NULL) {
-               ret = MM_ERROR_INVALID_ARGUMENT;
-               goto LEAVE;
-       }
+       SM_INSTANCE_CHECK(device);
+       SM_NULL_ARG_CHECK(is_running);
 
-       /* it is not supported both session and stream feature at the same time */
-       if (g_stream_info_count) {
-               ret =  MM_ERROR_POLICY_INTERNAL;
-               goto LEAVE;
-       }
-
-       if (g_session_interrupt_cb_table.user_cb == NULL) {
-               ret = mm_sound_add_device_connected_callback(SOUND_DEVICE_ALL_MASK, (mm_sound_device_connected_cb)_device_connected_cb, NULL, &subs_id);
-               if (ret)
-                       goto LEAVE;
-               ret = mm_sound_focus_set_session_interrupt_callback((mm_sound_focus_session_interrupt_cb)_focus_session_interrupt_cb, NULL);
-               if (ret) {
-                       if (mm_sound_remove_device_connected_callback(subs_id) != MM_ERROR_NONE)
-                               LOGW("mm_sound_remove_device_connected_callback failed");
-                       goto LEAVE;
-               }
-               g_session_interrupt_cb_table.subs_id = subs_id;
-       }
-       g_session_interrupt_cb_table.user_cb = (sound_session_interrupted_cb)callback;
-       g_session_interrupt_cb_table.user_data = user_data;
-
-LEAVE:
-       SM_LEAVE_CRITICAL_SECTION(&g_interrupt_cb_mutex);
+       ret = mm_sound_is_device_running(device, is_running);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_unset_session_interrupted_cb(void)
+int sound_manager_get_device_state(sound_device_h device, sound_device_state_e *state)
 {
        int ret = MM_ERROR_NONE;
 
        LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release.", __func__);
-       SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_interrupt_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
-       if (!g_session_interrupt_cb_table.user_cb) {
-               ret = MM_ERROR_SOUND_INTERNAL;
-               goto LEAVE;
-       }
-
-       ret = mm_sound_focus_unset_session_interrupt_callback();
-       if (ret) {
-               if (mm_sound_remove_device_connected_callback(g_session_interrupt_cb_table.subs_id) != MM_ERROR_NONE)
-                       LOGW("mm_sound_remove_device_connected_callback failed");
-               goto LEAVE;
-       }
-
-       ret = mm_sound_remove_device_connected_callback(g_session_interrupt_cb_table.subs_id);
-       if (ret)
-               goto LEAVE;
-
-       g_session_interrupt_cb_table.subs_id = 0;
-       g_session_interrupt_cb_table.user_cb = NULL;
-       g_session_interrupt_cb_table.user_data = NULL;
-
-LEAVE:
-       SM_LEAVE_CRITICAL_SECTION(&g_interrupt_cb_mutex);
+       ret = mm_sound_get_device_state(device, (mm_sound_device_state_e*)state);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_get_current_device_list(sound_device_mask_e device_mask, sound_device_list_h *device_list)
+int sound_manager_get_supported_sample_formats(sound_device_h device, sound_sample_format_e **formats, unsigned int *num_of_elems)
 {
        int ret = MM_ERROR_NONE;
+       int device_id;
 
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. Use sound_manager_get_device_list() instead.", __func__);
-       ret = mm_sound_get_current_device_list(device_mask, device_list);
-
-       return _convert_sound_manager_error_code(__func__, ret);
-}
+       SM_INSTANCE_CHECK(device);
+       SM_NULL_ARG_CHECK(formats);
+       SM_NULL_ARG_CHECK(num_of_elems);
 
-int sound_manager_get_device_list(int device_mask, sound_device_list_h *device_list)
-{
-       int ret = MM_ERROR_NONE;
+       if ((ret = _return_val_if_not_usb_device(device, SOUND_MANAGER_ERROR_INVALID_OPERATION)))
+               return ret;
 
-       ret = mm_sound_get_device_list(device_mask, device_list);
+       if (!(ret = mm_sound_get_device_id(device, &device_id)))
+               ret = _get_supported_sample_formats(device_id, formats, num_of_elems);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_free_device_list(sound_device_list_h device_list)
+int sound_manager_set_sample_format(sound_device_h device, sound_sample_format_e format)
 {
        int ret = MM_ERROR_NONE;
+       int device_id;
 
-       ret = mm_sound_free_device_list(device_list);
-
-       return _convert_sound_manager_error_code(__func__, ret);
-}
+       SM_INSTANCE_CHECK(device);
 
-int sound_manager_get_next_device(sound_device_list_h device_list, sound_device_h *device)
-{
-       int ret = MM_ERROR_NONE;
+       if ((ret = _return_val_if_not_usb_device(device, SOUND_MANAGER_ERROR_INVALID_OPERATION)))
+               return ret;
 
-       ret = mm_sound_get_next_device(device_list, device);
+       if (!(ret = mm_sound_get_device_id(device, &device_id)))
+               ret = _set_sample_format(device_id, format);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_get_prev_device(sound_device_list_h device_list, sound_device_h *device)
+int sound_manager_get_sample_format(sound_device_h device, sound_sample_format_e *format)
 {
        int ret = MM_ERROR_NONE;
+       int device_id;
 
-       ret = mm_sound_get_prev_device(device_list, device);
+       SM_INSTANCE_CHECK(device);
+       SM_NULL_ARG_CHECK(format);
+
+       if ((ret = _return_val_if_not_usb_device(device, SOUND_MANAGER_ERROR_INVALID_OPERATION)))
+               return ret;
+
+       if (!(ret = mm_sound_get_device_id(device, &device_id)))
+               ret = _get_sample_format(device_id, format);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_get_device_type(sound_device_h device, sound_device_type_e *type)
+int sound_manager_get_supported_sample_rates(sound_device_h device, sound_sample_rate_e **rates, unsigned int *num_of_elems)
 {
        int ret = MM_ERROR_NONE;
-       mm_sound_device_type_e mm_sound_device_type;
+       int device_id;
 
-       ret = mm_sound_get_device_type(device, &mm_sound_device_type);
-       if (ret == MM_ERROR_NONE)
-               _convert_device_type(mm_sound_device_type, type);
+       SM_INSTANCE_CHECK(device);
+       SM_NULL_ARG_CHECK(rates);
+       SM_NULL_ARG_CHECK(num_of_elems);
+
+       if ((ret = _return_val_if_not_usb_device(device, SOUND_MANAGER_ERROR_INVALID_OPERATION)))
+               return ret;
+
+       if (!(ret = mm_sound_get_device_id(device, &device_id)))
+               ret = _get_supported_sample_rates(device_id, rates, num_of_elems);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_get_device_io_direction(sound_device_h device, sound_device_io_direction_e *io_direction)
+int sound_manager_set_sample_rate(sound_device_h device, sound_sample_rate_e rate)
 {
        int ret = MM_ERROR_NONE;
-       mm_sound_device_io_direction_e mm_sound_io_direction;
+       int device_id;
 
-       ret = mm_sound_get_device_io_direction(device, &mm_sound_io_direction);
-       if (ret == MM_ERROR_NONE)
-               ret = _convert_device_io_direction(mm_sound_io_direction, io_direction);
+       SM_INSTANCE_CHECK(device);
+
+       if ((ret = _return_val_if_not_usb_device(device, SOUND_MANAGER_ERROR_INVALID_OPERATION)))
+               return ret;
+
+       if (!(ret = mm_sound_get_device_id(device, &device_id)))
+               ret = _set_sample_rate(device_id, rate);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_get_device_id(sound_device_h device, int *id)
+int sound_manager_get_sample_rate(sound_device_h device, sound_sample_rate_e *rate)
 {
        int ret = MM_ERROR_NONE;
+       int device_id;
 
-       ret = mm_sound_get_device_id(device, id);
+       SM_INSTANCE_CHECK(device);
+       SM_NULL_ARG_CHECK(rate);
+
+       if ((ret = _return_val_if_not_usb_device(device, SOUND_MANAGER_ERROR_INVALID_OPERATION)))
+               return ret;
+
+       if (!(ret = mm_sound_get_device_id(device, &device_id)))
+               ret = _get_sample_rate(device_id, rate);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_get_device_name(sound_device_h device, char **name)
+int sound_manager_set_avoid_resampling(sound_device_h device, bool enable)
 {
        int ret = MM_ERROR_NONE;
+       int device_id;
 
-       ret = mm_sound_get_device_name(device, name);
+       SM_INSTANCE_CHECK(device);
+
+       if ((ret = _return_val_if_not_usb_device(device, SOUND_MANAGER_ERROR_INVALID_OPERATION)))
+               return ret;
+
+       if (!(ret = mm_sound_get_device_id(device, &device_id)))
+               ret = _set_avoid_resampling(device_id, enable);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_get_device_state(sound_device_h device, sound_device_state_e *state)
+int sound_manager_get_avoid_resampling(sound_device_h device, bool *enabled)
 {
        int ret = MM_ERROR_NONE;
+       int device_id;
 
-       ret = mm_sound_get_device_state(device, (mm_sound_device_state_e*)state);
+       SM_INSTANCE_CHECK(device);
+       SM_NULL_ARG_CHECK(enabled);
+
+       if ((ret = _return_val_if_not_usb_device(device, SOUND_MANAGER_ERROR_INVALID_OPERATION)))
+               return ret;
+
+       if (!(ret = mm_sound_get_device_id(device, &device_id)))
+               ret = _get_avoid_resampling(device_id, enabled);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_set_device_connected_cb(sound_device_mask_e device_mask, sound_device_connected_cb callback, void *user_data)
+int sound_manager_set_media_stream_only(sound_device_h device, bool enable)
 {
        int ret = MM_ERROR_NONE;
-       unsigned int subs_id = 0;
-
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. "
-               "Use sound_manager_add_device_connection_changed_cb() instead.", __func__);
+       int device_id;
 
-       SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_conn_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
+       SM_INSTANCE_CHECK(device);
 
-       ret = mm_sound_add_device_connected_callback((mm_sound_device_flags_e)device_mask, (mm_sound_device_connected_cb)callback, user_data, &subs_id);
-       if (ret == MM_ERROR_NONE) {
-               g_device_connected_cb_table.subs_id = subs_id;
-               g_device_connected_cb_table.user_cb = (sound_device_connected_cb)callback;
-               g_device_connected_cb_table.user_data = user_data;
-       }
+       if ((ret = _return_val_if_not_usb_device(device, SOUND_MANAGER_ERROR_INVALID_OPERATION)))
+               return ret;
 
-       SM_LEAVE_CRITICAL_SECTION(&g_device_conn_cb_mutex);
+       if (!(ret = mm_sound_get_device_id(device, &device_id)))
+               ret = _set_media_stream_only(device_id, enable);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_unset_device_connected_cb(void)
+int sound_manager_get_media_stream_only(sound_device_h device, bool *enabled)
 {
        int ret = MM_ERROR_NONE;
+       int device_id;
 
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. "
-               "Use sound_manager_remove_device_connection_changed_cb() instead.", __func__);
-
-       SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_conn_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
-       if (g_device_connected_cb_table.subs_id == 0) {
-               ret = MM_ERROR_SOUND_INTERNAL;
-               goto LEAVE;
-       }
+       SM_INSTANCE_CHECK(device);
+       SM_NULL_ARG_CHECK(enabled);
 
-       ret = mm_sound_remove_device_connected_callback(g_device_connected_cb_table.subs_id);
-       if (ret == MM_ERROR_NONE) {
-               g_device_connected_cb_table.subs_id = 0;
-               g_device_connected_cb_table.user_cb = NULL;
-               g_device_connected_cb_table.user_data = NULL;
-       }
+       if ((ret = _return_val_if_not_usb_device(device, SOUND_MANAGER_ERROR_INVALID_OPERATION)))
+               return ret;
 
-LEAVE:
-       SM_LEAVE_CRITICAL_SECTION(&g_device_conn_cb_mutex);
+       if (!(ret = mm_sound_get_device_id(device, &device_id)))
+               ret = _get_media_stream_only(device_id, enabled);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_add_device_connection_changed_cb(int device_mask, sound_device_connected_cb callback, void *user_data, int *id)
+int sound_manager_add_device_connection_changed_cb(int device_mask, sound_device_connection_changed_cb callback, void *user_data, int *id)
 {
        int ret = MM_ERROR_NONE;
 
-       if (!callback || !id)
-               return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
+       SM_NULL_ARG_CHECK(callback);
+       SM_NULL_ARG_CHECK(id);
 
        ret = mm_sound_add_device_connected_callback((mm_sound_device_flags_e)device_mask, (mm_sound_device_connected_cb)callback, user_data, (unsigned int*)id);
 
@@ -1282,49 +1065,26 @@ int sound_manager_remove_device_connection_changed_cb(int id)
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_set_device_information_changed_cb(sound_device_mask_e device_mask, sound_device_information_changed_cb callback, void *user_data)
+int sound_manager_add_device_running_changed_cb(int device_mask, sound_device_running_changed_cb callback, void *user_data, int *id)
 {
        int ret = MM_ERROR_NONE;
-       unsigned int subs_id = 0;
-
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. "
-               "Use sound_manager_add_device_state_changed_cb() instead.", __func__);
-       SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_info_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
 
-       ret = mm_sound_add_device_information_changed_callback((mm_sound_device_flags_e)device_mask, (mm_sound_device_info_changed_cb)callback, user_data, &subs_id);
-       if (ret == MM_ERROR_NONE) {
-               g_device_info_changed_cb_table.subs_id = subs_id;
-               g_device_info_changed_cb_table.user_cb = (sound_device_information_changed_cb)callback;
-               g_device_info_changed_cb_table.user_data = user_data;
-       }
+       SM_NULL_ARG_CHECK(callback);
+       SM_NULL_ARG_CHECK(id);
 
-       SM_LEAVE_CRITICAL_SECTION(&g_device_info_cb_mutex);
+       ret = mm_sound_add_device_running_changed_callback(device_mask, (mm_sound_device_running_changed_cb)callback, user_data, (unsigned int*)id);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-int sound_manager_unset_device_information_changed_cb(void)
+int sound_manager_remove_device_running_changed_cb(int id)
 {
        int ret = MM_ERROR_NONE;
 
-       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release. "
-               "Use sound_manager_remove_device_state_changed_cb() instead.", __func__);
-       SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_device_info_cb_mutex, SOUND_MANAGER_ERROR_INTERNAL);
-
-       if (g_device_info_changed_cb_table.subs_id == 0) {
-               ret = MM_ERROR_SOUND_INTERNAL;
-               goto LEAVE;
-       }
-
-       ret = mm_sound_remove_device_information_changed_callback(g_device_info_changed_cb_table.subs_id);
-       if (ret == MM_ERROR_NONE) {
-               g_device_info_changed_cb_table.subs_id = 0;
-               g_device_info_changed_cb_table.user_cb = NULL;
-               g_device_info_changed_cb_table.user_data = NULL;
-       }
+       if (id < 0)
+               return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
 
-LEAVE:
-       SM_LEAVE_CRITICAL_SECTION(&g_device_info_cb_mutex);
+       ret = mm_sound_remove_device_running_changed_callback((unsigned int)id);
 
        return _convert_sound_manager_error_code(__func__, ret);
 }
@@ -1333,8 +1093,9 @@ int sound_manager_add_device_state_changed_cb(int device_mask, sound_device_stat
 {
        int ret = MM_ERROR_NONE;
 
-       if (!callback || !id)
-               return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
+       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release.", __func__);
+       SM_NULL_ARG_CHECK(callback);
+       SM_NULL_ARG_CHECK(id);
 
        ret = mm_sound_add_device_state_changed_callback(device_mask, (mm_sound_device_state_changed_cb)callback, user_data, (unsigned int*)id);
 
@@ -1345,6 +1106,7 @@ int sound_manager_remove_device_state_changed_cb(int id)
 {
        int ret = MM_ERROR_NONE;
 
+       LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed from next release.", __func__);
        if (id < 0)
                return _convert_sound_manager_error_code(__func__, MM_ERROR_INVALID_ARGUMENT);
 
@@ -1353,24 +1115,3 @@ int sound_manager_remove_device_state_changed_cb(int id)
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
-__attribute__ ((destructor))
-void __sound_manager_finalize(void)
-{
-       int ret = MM_ERROR_NONE;
-
-       if (g_session_interrupt_cb_table.is_registered) {
-               LOGI("<ENTER>");
-               ret = mm_session_finish();
-               if (ret != MM_ERROR_NONE)
-                       LOGE("[%s] failed to mm_session_finish(), ret(0x%x)", __func__, ret);
-
-               g_session_interrupt_cb_table.is_registered = 0;
-               LOGI("<LEAVE>");
-       }
-}
-
-__attribute__ ((constructor))
-void __sound_manager_initialize(void)
-{
-
-}