Loading hal/audio_extn/utils.c +5 −7 Original line number Diff line number Diff line /* * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved. * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. * Not a Contribution. * * Copyright (C) 2014 The Android Open Source Project Loading Loading @@ -1159,9 +1159,6 @@ int audio_extn_utils_get_app_sample_rate_for_device( if (usecase->id == USECASE_AUDIO_PLAYBACK_VOIP) { usecase->stream.out->app_type_cfg.sample_rate = usecase->stream.out->sample_rate; } else if (compare_device_type(&usecase->stream.out->device_list, AUDIO_DEVICE_OUT_SPEAKER)) { usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE; } else if ((snd_device == SND_DEVICE_OUT_HDMI || snd_device == SND_DEVICE_OUT_USB_HEADSET || snd_device == SND_DEVICE_OUT_DISPLAY_PORT) && Loading @@ -1180,9 +1177,7 @@ int audio_extn_utils_get_app_sample_rate_for_device( (usecase->stream.out->sample_rate < OUTPUT_SAMPLING_RATE_44100)) { /* Reset to default if no native stream is active*/ usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE; } else if (usecase->out_snd_device == SND_DEVICE_OUT_BT_A2DP || usecase->out_snd_device == SND_DEVICE_OUT_SPEAKER_AND_BT_A2DP || usecase->out_snd_device == SND_DEVICE_OUT_SPEAKER_SAFE_AND_BT_A2DP) { } else if (snd_device == SND_DEVICE_OUT_BT_A2DP) { /* * For a2dp playback get encoder sampling rate and set copp sampling rate, * for bit width use the stream param only. Loading @@ -1190,6 +1185,9 @@ int audio_extn_utils_get_app_sample_rate_for_device( audio_extn_a2dp_get_enc_sample_rate(&usecase->stream.out->app_type_cfg.sample_rate); ALOGI("%s using %d sample rate rate for A2DP CoPP", __func__, usecase->stream.out->app_type_cfg.sample_rate); } else if (compare_device_type(&usecase->stream.out->device_list, AUDIO_DEVICE_OUT_SPEAKER)) { usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE; } audio_extn_btsco_get_sample_rate(snd_device, &usecase->stream.out->app_type_cfg.sample_rate); sample_rate = usecase->stream.out->app_type_cfg.sample_rate; Loading hal/audio_hw.c +58 −23 Original line number Diff line number Diff line Loading @@ -3157,7 +3157,7 @@ int start_input_stream(struct stream_in *in) } if (is_sco_in_device_type(&in->device_list)) { if (!adev->bt_sco_on) { if (!adev->bt_sco_on || audio_extn_a2dp_source_is_ready()) { ALOGE("%s: SCO profile is not ready, return error", __func__); ret = -EIO; goto error_config; Loading Loading @@ -8747,7 +8747,30 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs) /* When set to false, HAL should disable EC and NS */ if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0){ adev->bt_sco_on = true; } else { /* * When ever BT_SCO=ON arrives, make sure to route * all use cases to SCO device, otherwise due to delay in * BT_SCO=ON and lack of synchronization with create audio patch * request for SCO device, some times use case not routed properly to * SCO device */ struct audio_usecase *usecase; struct listnode *node; list_for_each(node, &adev->usecase_list) { usecase = node_to_item(node, struct audio_usecase, list); if (usecase->stream.in && (usecase->type == PCM_CAPTURE) && (!is_btsco_device(SND_DEVICE_NONE, usecase->in_snd_device))) { ALOGD("BT_SCO ON, switch all in use case to it"); select_devices(adev, usecase->id); } if (usecase->stream.out && (usecase->type == PCM_PLAYBACK) && (!is_btsco_device(usecase->out_snd_device, SND_DEVICE_NONE))) { ALOGD("BT_SCO ON, switch all out use case to it"); select_devices(adev, usecase->id); } } } else { adev->bt_sco_on = false; audio_extn_sco_reset_configuration(); } Loading Loading @@ -9560,6 +9583,10 @@ static int adev_open_input_stream(struct audio_hw_device *dev, in->config.period_count = VOIP_CAPTURE_PERIOD_COUNT; in->config.rate = config->sample_rate; in->af_period_multiplier = 1; } else if (in->realtime) { in->config = pcm_config_audio_capture_rt; in->config.format = pcm_format_from_audio_format(config->format); in->af_period_multiplier = af_period_multiplier; } else { int ret_val; pthread_mutex_lock(&adev->lock); Loading Loading @@ -10365,9 +10392,9 @@ static void adev_snd_mon_cb(void *cookie, struct str_parms *parms) int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *out, bool restore) { struct audio_usecase *uc_info; float left_p; float right_p; struct audio_usecase *usecase; struct listnode devices; struct listnode *node; uc_info = get_usecase_from_list(adev, out->usecase); if (uc_info == NULL) { Loading Loading @@ -10403,11 +10430,18 @@ int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *out, bool pthread_mutex_lock(&out->latch_lock); // mute stream and switch to speaker if suspended if (!out->a2dp_muted && !out->standby) { ALOGD("%s: selecting speaker and muting stream", __func__); assign_devices(&devices, &out->device_list); reassign_device_list(&out->device_list, AUDIO_DEVICE_OUT_SPEAKER, ""); left_p = out->volume_l; right_p = out->volume_r; list_for_each(node, &adev->usecase_list) { usecase = node_to_item(node, struct audio_usecase, list); if ((usecase != uc_info) && platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, usecase->out_snd_device)) { assign_devices(&out->device_list, &usecase->stream.out->device_list); break; } } if (uc_info->out_snd_device == SND_DEVICE_OUT_BT_A2DP) { out->a2dp_muted = true; if (is_offload_usecase(out->usecase)) { if (out->offload_state == OFFLOAD_STATE_PLAYING) Loading @@ -10423,14 +10457,15 @@ int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *out, bool (out->config.rate); usleep(latency * 1000); } } select_devices(adev, out->usecase); ALOGD("%s: switched to device:%s and stream muted:%d", __func__, platform_get_snd_device_name(uc_info->out_snd_device), out->a2dp_muted); if (is_offload_usecase(out->usecase)) { if (out->offload_state == OFFLOAD_STATE_PLAYING) compress_resume(out->compr); } assign_devices(&out->device_list, &devices); out->volume_l = left_p; out->volume_r = right_p; } pthread_mutex_unlock(&out->latch_lock); } Loading Loading
hal/audio_extn/utils.c +5 −7 Original line number Diff line number Diff line /* * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved. * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. * Not a Contribution. * * Copyright (C) 2014 The Android Open Source Project Loading Loading @@ -1159,9 +1159,6 @@ int audio_extn_utils_get_app_sample_rate_for_device( if (usecase->id == USECASE_AUDIO_PLAYBACK_VOIP) { usecase->stream.out->app_type_cfg.sample_rate = usecase->stream.out->sample_rate; } else if (compare_device_type(&usecase->stream.out->device_list, AUDIO_DEVICE_OUT_SPEAKER)) { usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE; } else if ((snd_device == SND_DEVICE_OUT_HDMI || snd_device == SND_DEVICE_OUT_USB_HEADSET || snd_device == SND_DEVICE_OUT_DISPLAY_PORT) && Loading @@ -1180,9 +1177,7 @@ int audio_extn_utils_get_app_sample_rate_for_device( (usecase->stream.out->sample_rate < OUTPUT_SAMPLING_RATE_44100)) { /* Reset to default if no native stream is active*/ usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE; } else if (usecase->out_snd_device == SND_DEVICE_OUT_BT_A2DP || usecase->out_snd_device == SND_DEVICE_OUT_SPEAKER_AND_BT_A2DP || usecase->out_snd_device == SND_DEVICE_OUT_SPEAKER_SAFE_AND_BT_A2DP) { } else if (snd_device == SND_DEVICE_OUT_BT_A2DP) { /* * For a2dp playback get encoder sampling rate and set copp sampling rate, * for bit width use the stream param only. Loading @@ -1190,6 +1185,9 @@ int audio_extn_utils_get_app_sample_rate_for_device( audio_extn_a2dp_get_enc_sample_rate(&usecase->stream.out->app_type_cfg.sample_rate); ALOGI("%s using %d sample rate rate for A2DP CoPP", __func__, usecase->stream.out->app_type_cfg.sample_rate); } else if (compare_device_type(&usecase->stream.out->device_list, AUDIO_DEVICE_OUT_SPEAKER)) { usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE; } audio_extn_btsco_get_sample_rate(snd_device, &usecase->stream.out->app_type_cfg.sample_rate); sample_rate = usecase->stream.out->app_type_cfg.sample_rate; Loading
hal/audio_hw.c +58 −23 Original line number Diff line number Diff line Loading @@ -3157,7 +3157,7 @@ int start_input_stream(struct stream_in *in) } if (is_sco_in_device_type(&in->device_list)) { if (!adev->bt_sco_on) { if (!adev->bt_sco_on || audio_extn_a2dp_source_is_ready()) { ALOGE("%s: SCO profile is not ready, return error", __func__); ret = -EIO; goto error_config; Loading Loading @@ -8747,7 +8747,30 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs) /* When set to false, HAL should disable EC and NS */ if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0){ adev->bt_sco_on = true; } else { /* * When ever BT_SCO=ON arrives, make sure to route * all use cases to SCO device, otherwise due to delay in * BT_SCO=ON and lack of synchronization with create audio patch * request for SCO device, some times use case not routed properly to * SCO device */ struct audio_usecase *usecase; struct listnode *node; list_for_each(node, &adev->usecase_list) { usecase = node_to_item(node, struct audio_usecase, list); if (usecase->stream.in && (usecase->type == PCM_CAPTURE) && (!is_btsco_device(SND_DEVICE_NONE, usecase->in_snd_device))) { ALOGD("BT_SCO ON, switch all in use case to it"); select_devices(adev, usecase->id); } if (usecase->stream.out && (usecase->type == PCM_PLAYBACK) && (!is_btsco_device(usecase->out_snd_device, SND_DEVICE_NONE))) { ALOGD("BT_SCO ON, switch all out use case to it"); select_devices(adev, usecase->id); } } } else { adev->bt_sco_on = false; audio_extn_sco_reset_configuration(); } Loading Loading @@ -9560,6 +9583,10 @@ static int adev_open_input_stream(struct audio_hw_device *dev, in->config.period_count = VOIP_CAPTURE_PERIOD_COUNT; in->config.rate = config->sample_rate; in->af_period_multiplier = 1; } else if (in->realtime) { in->config = pcm_config_audio_capture_rt; in->config.format = pcm_format_from_audio_format(config->format); in->af_period_multiplier = af_period_multiplier; } else { int ret_val; pthread_mutex_lock(&adev->lock); Loading Loading @@ -10365,9 +10392,9 @@ static void adev_snd_mon_cb(void *cookie, struct str_parms *parms) int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *out, bool restore) { struct audio_usecase *uc_info; float left_p; float right_p; struct audio_usecase *usecase; struct listnode devices; struct listnode *node; uc_info = get_usecase_from_list(adev, out->usecase); if (uc_info == NULL) { Loading Loading @@ -10403,11 +10430,18 @@ int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *out, bool pthread_mutex_lock(&out->latch_lock); // mute stream and switch to speaker if suspended if (!out->a2dp_muted && !out->standby) { ALOGD("%s: selecting speaker and muting stream", __func__); assign_devices(&devices, &out->device_list); reassign_device_list(&out->device_list, AUDIO_DEVICE_OUT_SPEAKER, ""); left_p = out->volume_l; right_p = out->volume_r; list_for_each(node, &adev->usecase_list) { usecase = node_to_item(node, struct audio_usecase, list); if ((usecase != uc_info) && platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, usecase->out_snd_device)) { assign_devices(&out->device_list, &usecase->stream.out->device_list); break; } } if (uc_info->out_snd_device == SND_DEVICE_OUT_BT_A2DP) { out->a2dp_muted = true; if (is_offload_usecase(out->usecase)) { if (out->offload_state == OFFLOAD_STATE_PLAYING) Loading @@ -10423,14 +10457,15 @@ int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *out, bool (out->config.rate); usleep(latency * 1000); } } select_devices(adev, out->usecase); ALOGD("%s: switched to device:%s and stream muted:%d", __func__, platform_get_snd_device_name(uc_info->out_snd_device), out->a2dp_muted); if (is_offload_usecase(out->usecase)) { if (out->offload_state == OFFLOAD_STATE_PLAYING) compress_resume(out->compr); } assign_devices(&out->device_list, &devices); out->volume_l = left_p; out->volume_r = right_p; } pthread_mutex_unlock(&out->latch_lock); } Loading