sound_manager_private: Fix policy to set echo cancellation reference device 70/275270/2
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 19 May 2022 06:11:33 +0000 (15:11 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 19 May 2022 07:42:06 +0000 (16:42 +0900)
Previously, to set the reference device, it has to be one of avail-out-
devices of the stream info. But considering that this stream info handle
is for a capture API(for example, audio-io, recorder and so on), this
restriction should be removed. Rather, the reference device could be any
of playback devices. It is fixed now.

It is also added to return policy error when the stream info handle is
only for the playback stream.

[Version] 0.6.48
[Issue Type] Bug fix

Change-Id: I3c160f679731865b5d1c2e6a711b1956b8e44146
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-sound-manager.spec
src/sound_manager_private.c

index b7a3089..9780249 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-sound-manager
 Summary:    Sound Manager library
-Version:    0.6.47
+Version:    0.6.48
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index a2b2548..4adc4dd 100644 (file)
@@ -2483,45 +2483,29 @@ int _set_remote_permission(int id, bool allowed)
 
 int _set_echo_cancel_reference_device(sound_stream_info_s *stream_info, sound_device_h device)
 {
-       mm_sound_device_type_e mm_sound_device_type;
-       sound_device_type_e device_type;
+       int ret;
        int device_id;
-       char *device_type_str = NULL;
-       char *avail_device_item = NULL;
-       bool found = false;
-       int ret, i;
+       char *device_name;
 
        SM_ARG_CHECK(stream_info);
        SM_ARG_CHECK(device);
 
-       if ((ret = mm_sound_get_device_type(device, &mm_sound_device_type)) != MM_ERROR_NONE)
-               return _convert_sound_manager_error_code(__func__, ret);
+       if (!stream_info->stream_conf_info.avail_in_devices[0]) {
+               LOGE("stream_info[%p, %s] does not support any input devices", stream_info, stream_info->stream_type);
+               return SOUND_MANAGER_ERROR_POLICY;
+       }
 
+       /* FIXME: check if the PA sink supports to pump the reference data to AEC module */
        if ((ret = mm_sound_get_device_id(device, &device_id)) != MM_ERROR_NONE)
                return _convert_sound_manager_error_code(__func__, ret);
 
-       if ((ret = _convert_device_type(mm_sound_device_type, &device_type)) != SOUND_MANAGER_ERROR_NONE)
-               return ret;
-
-       if ((ret = _convert_device_type_enum_to_str(device_type, &device_type_str)) != SOUND_MANAGER_ERROR_NONE)
-               return ret;
-
-       for (i = 0; i < AVAIL_DEVICES_MAX; i++) {
-               if (!(avail_device_item = stream_info->stream_conf_info.avail_out_devices[i]))
-                       break;
-
-               if (!strncmp(avail_device_item, device_type_str, strlen(device_type_str)))
-                       found = true;
-       }
-
-       if (!found) {
-               LOGE("not supported device[type:%s, id:%d]", device_type_str, device_id);
-               return SOUND_MANAGER_ERROR_POLICY;
-       }
+       if ((ret = mm_sound_get_device_name(device, &device_name)) != MM_ERROR_NONE)
+               return _convert_sound_manager_error_code(__func__, ret);
 
        stream_info->echo_cancel_reference_device = device_id;
-       LOGI("stream_info[%p, %s] reference device_id[%d]",
-               stream_info, stream_info->stream_type, device_id);
+
+       LOGI("stream_info[%p, %s] EC reference device[id:%d, name:%s]",
+               stream_info, stream_info->stream_type, device_id, device_name);
 
        return SOUND_MANAGER_ERROR_NONE;
 }