Remove unused destructor/constructor block
[platform/core/api/sound-manager.git] / src / sound_manager.c
index c33de4c..eabfbc5 100644 (file)
@@ -135,7 +135,8 @@ int sound_manager_create_stream_information(sound_stream_type_e stream_type, sou
                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);
                }
        }
 
@@ -244,7 +245,7 @@ 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);
 
@@ -261,7 +262,7 @@ 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);
 
@@ -272,13 +273,14 @@ int sound_manager_acquire_focus(sound_stream_info_h stream_info, sound_stream_fo
 {
        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)))
+       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) {
@@ -295,6 +297,12 @@ int sound_manager_acquire_focus(sound_stream_info_h stream_info, sound_stream_fo
                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);
        }
 
@@ -311,16 +319,19 @@ int sound_manager_acquire_focus(sound_stream_info_h stream_info, sound_stream_fo
                goto LEAVE;
        }
 
-       ret = mm_sound_acquire_focus_with_option(stream_h->index, (mm_sound_focus_type_e)focus_mask, sound_behavior, extra_info);
+       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->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);
 
 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);
@@ -332,19 +343,26 @@ int sound_manager_release_focus(sound_stream_info_h stream_info, sound_stream_fo
 {
        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)))
+       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);
        }
 
@@ -361,16 +379,19 @@ int sound_manager_release_focus(sound_stream_info_h stream_info, sound_stream_fo
                goto LEAVE;
        }
 
-       ret = mm_sound_release_focus_with_option(stream_h->index, (mm_sound_focus_type_e)focus_mask, sound_behavior, extra_info);
+       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;
                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);
 
 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);
@@ -383,13 +404,14 @@ int sound_manager_acquire_focus_all(sound_stream_info_h stream_info, int sound_b
        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 ((ret = mm_sound_focus_is_cb_thread(&is_focus_cb_thread)))
+       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) {
@@ -406,6 +428,12 @@ int sound_manager_acquire_focus_all(sound_stream_info_h stream_info, int sound_b
                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);
        }
 
@@ -423,14 +451,17 @@ int sound_manager_acquire_focus_all(sound_stream_info_h stream_info, int sound_b
                goto LEAVE;
        }
 
-       ret = mm_sound_acquire_focus_with_option(stream_h->index, (mm_sound_focus_type_e)focus_mask, sound_behavior, extra_info);
+       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->index, (unsigned int)stream_h->acquired_focus);
+               _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);
@@ -442,19 +473,26 @@ int sound_manager_release_focus_all(sound_stream_info_h stream_info, int sound_b
 {
        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)))
+       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);
        }
 
@@ -471,14 +509,17 @@ int sound_manager_release_focus_all(sound_stream_info_h stream_info, int sound_b
                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);
+       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->index, (unsigned int)stream_h->acquired_focus);
+               _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);
@@ -523,7 +564,7 @@ int sound_manager_deliver_focus(sound_stream_info_h source, sound_stream_info_h
        SM_INSTANCE_CHECK(src_stream_h);
        SM_INSTANCE_CHECK(dst_stream_h);
 
-       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) {
@@ -531,8 +572,8 @@ int sound_manager_deliver_focus(sound_stream_info_h source, sound_stream_info_h
                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;
        }
 
@@ -553,7 +594,7 @@ int sound_manager_deliver_focus(sound_stream_info_h source, sound_stream_info_h
                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;
@@ -575,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);
 }
@@ -606,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) {
@@ -622,11 +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
-                               SM_SAFE_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);
@@ -645,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) {
@@ -661,11 +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
-                               SM_SAFE_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);
@@ -834,6 +873,174 @@ int sound_manager_get_device_state(sound_device_h device, sound_device_state_e *
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
+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;
+
+       SM_INSTANCE_CHECK(device);
+       SM_NULL_ARG_CHECK(formats);
+       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_formats(device_id, formats, num_of_elems);
+
+       return _convert_sound_manager_error_code(__func__, ret);
+}
+
+int sound_manager_set_sample_format(sound_device_h device, sound_sample_format_e format)
+{
+       int ret = MM_ERROR_NONE;
+       int device_id;
+
+       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_format(device_id, format);
+
+       return _convert_sound_manager_error_code(__func__, ret);
+}
+
+int sound_manager_get_sample_format(sound_device_h device, sound_sample_format_e *format)
+{
+       int ret = MM_ERROR_NONE;
+       int device_id;
+
+       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_supported_sample_rates(sound_device_h device, sound_sample_rate_e **rates, unsigned int *num_of_elems)
+{
+       int ret = MM_ERROR_NONE;
+       int device_id;
+
+       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_set_sample_rate(sound_device_h device, sound_sample_rate_e rate)
+{
+       int ret = MM_ERROR_NONE;
+       int device_id;
+
+       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_sample_rate(sound_device_h device, sound_sample_rate_e *rate)
+{
+       int ret = MM_ERROR_NONE;
+       int 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_set_avoid_resampling(sound_device_h device, bool enable)
+{
+       int ret = MM_ERROR_NONE;
+       int device_id;
+
+       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_avoid_resampling(sound_device_h device, bool *enabled)
+{
+       int ret = MM_ERROR_NONE;
+       int device_id;
+
+       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_media_stream_only(sound_device_h device, bool enable)
+{
+       int ret = MM_ERROR_NONE;
+       int device_id;
+
+       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_media_stream_only(device_id, enable);
+
+       return _convert_sound_manager_error_code(__func__, ret);
+}
+
+int sound_manager_get_media_stream_only(sound_device_h device, bool *enabled)
+{
+       int ret = MM_ERROR_NONE;
+       int device_id;
+
+       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_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_connection_changed_cb callback, void *user_data, int *id)
 {
        int ret = MM_ERROR_NONE;
@@ -908,14 +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)
-{
-
-}
-
-__attribute__ ((constructor))
-void __sound_manager_initialize(void)
-{
-
-}