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;
}