From faa60168cb4ac9d7b3be69d31f143b8eacd7ef71 Mon Sep 17 00:00:00 2001 From: "Christopher N. Hesse" Date: Fri, 9 Mar 2018 23:20:55 +0100 Subject: [PATCH] audio: Use audio_route_{apply/reset}_and_update_path We don't need to handle the mixer updates here anymore. Change-Id: Id60759e31a6501e4772bbd7377505197c932545a --- audio/audio_hw.c | 54 +++++++++++++++--------------------------------- 1 file changed, 17 insertions(+), 37 deletions(-) diff --git a/audio/audio_hw.c b/audio/audio_hw.c index 5879316..8daeb6a 100644 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -919,8 +919,7 @@ static int64_t render_latency(audio_usecase_t usecase) static int enable_snd_device(struct audio_device *adev, struct audio_usecase *uc_info, - snd_device_t snd_device, - bool update_mixer) + snd_device_t snd_device) { struct mixer_card *mixer_card; struct listnode *node; @@ -935,8 +934,8 @@ static int enable_snd_device(struct audio_device *adev, if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES) { ALOGV("Request to enable combo device: enable individual devices\n"); - enable_snd_device(adev, uc_info, SND_DEVICE_OUT_SPEAKER, update_mixer); - enable_snd_device(adev, uc_info, SND_DEVICE_OUT_HEADPHONES, update_mixer); + enable_snd_device(adev, uc_info, SND_DEVICE_OUT_SPEAKER); + enable_snd_device(adev, uc_info, SND_DEVICE_OUT_HEADPHONES); return 0; } adev->snd_dev_ref_cnt[snd_device]++; @@ -964,15 +963,11 @@ static int enable_snd_device(struct audio_device *adev, usleep(DSP_POWEROFF_DELAY - elapsed_usec); } } - update_mixer = true; #endif /* DSP_POWEROFF_DELAY */ amplifier_enable_devices(snd_device, true); - audio_route_apply_path(mixer_card->audio_route, snd_device_name); - if (update_mixer) { - audio_route_update_mixer(mixer_card->audio_route); - } + audio_route_apply_and_update_path(mixer_card->audio_route, snd_device_name); } return 0; @@ -980,8 +975,7 @@ static int enable_snd_device(struct audio_device *adev, int disable_snd_device(struct audio_device *adev, struct audio_usecase *uc_info, - snd_device_t snd_device, - bool update_mixer) + snd_device_t snd_device) { struct mixer_card *mixer_card; struct listnode *node; @@ -994,8 +988,8 @@ int disable_snd_device(struct audio_device *adev, if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES) { ALOGV("Request to disable combo device: disable individual devices\n"); - disable_snd_device(adev, uc_info, SND_DEVICE_OUT_SPEAKER, update_mixer); - disable_snd_device(adev, uc_info, SND_DEVICE_OUT_HEADPHONES, update_mixer); + disable_snd_device(adev, uc_info, SND_DEVICE_OUT_SPEAKER); + disable_snd_device(adev, uc_info, SND_DEVICE_OUT_HEADPHONES); return 0; } @@ -1009,10 +1003,7 @@ int disable_snd_device(struct audio_device *adev, snd_device, snd_device_name); list_for_each(node, &uc_info->mixer_list) { mixer_card = node_to_item(node, struct mixer_card, uc_list_node[uc_info->id]); -#ifdef DSP_POWEROFF_DELAY - update_mixer = true; -#endif /* DSP_POWEROFF_DELAY */ - audio_route_reset_path(mixer_card->audio_route, snd_device_name); + audio_route_reset_and_update_path(mixer_card->audio_route, snd_device_name); if (snd_device > SND_DEVICE_IN_BEGIN && out_uc_info != NULL) { /* * Cycle the rx device to eliminate routing conflicts. @@ -1020,11 +1011,7 @@ int disable_snd_device(struct audio_device *adev, * route. */ out_snd_device_name = get_snd_device_name(out_uc_info->out_snd_device); - audio_route_apply_path(mixer_card->audio_route, out_snd_device_name); - update_mixer = true; - } - if (update_mixer) { - audio_route_update_mixer(mixer_card->audio_route); + audio_route_apply_and_update_path(mixer_card->audio_route, out_snd_device_name); } amplifier_enable_devices(snd_device, false); @@ -1043,10 +1030,8 @@ static int select_devices(struct audio_device *adev, snd_device_t in_snd_device = SND_DEVICE_NONE; struct audio_usecase *usecase = NULL; struct audio_usecase *vc_usecase = NULL; - struct listnode *node; struct stream_in *active_input = NULL; struct stream_out *active_out; - struct mixer_card *mixer_card; ALOGV("%s: usecase(%d)", __func__, uc_id); @@ -1126,11 +1111,11 @@ static int select_devices(struct audio_device *adev, /* Disable current sound devices */ if (usecase->out_snd_device != SND_DEVICE_NONE) { - disable_snd_device(adev, usecase, usecase->out_snd_device, false); + disable_snd_device(adev, usecase, usecase->out_snd_device); } if (usecase->in_snd_device != SND_DEVICE_NONE) { - disable_snd_device(adev, usecase, usecase->in_snd_device, false); + disable_snd_device(adev, usecase, usecase->in_snd_device); } /* Enable new sound devices */ @@ -1140,16 +1125,11 @@ static int select_devices(struct audio_device *adev, set_voice_session_audio_path(adev->voice.session); } - enable_snd_device(adev, usecase, out_snd_device, false); + enable_snd_device(adev, usecase, out_snd_device); } if (in_snd_device != SND_DEVICE_NONE) { - enable_snd_device(adev, usecase, in_snd_device, false); - } - - list_for_each(node, &usecase->mixer_list) { - mixer_card = node_to_item(node, struct mixer_card, uc_list_node[usecase->id]); - audio_route_update_mixer(mixer_card->audio_route); + enable_snd_device(adev, usecase, in_snd_device); } usecase->in_snd_device = in_snd_device; @@ -2166,7 +2146,7 @@ static int stop_input_stream(struct stream_in *in) } /* Disable the tx device */ - disable_snd_device(adev, uc_info, uc_info->in_snd_device, true); + disable_snd_device(adev, uc_info, uc_info->in_snd_device); list_remove(&uc_info->adev_list_node); free(uc_info); @@ -2529,7 +2509,7 @@ int disable_output_path_l(struct stream_out *out) __func__, out->usecase); return -EINVAL; } - disable_snd_device(adev, uc_info, uc_info->out_snd_device, true); + disable_snd_device(adev, uc_info, uc_info->out_snd_device); uc_release_pcm_devices(uc_info); list_remove(&uc_info->adev_list_node); free(uc_info); @@ -2642,8 +2622,8 @@ int stop_voice_call(struct audio_device *adev) return -EINVAL; } - disable_snd_device(adev, uc_info, uc_info->out_snd_device, false); - disable_snd_device(adev, uc_info, uc_info->in_snd_device, true); + disable_snd_device(adev, uc_info, uc_info->out_snd_device); + disable_snd_device(adev, uc_info, uc_info->in_snd_device); list_remove(&uc_info->adev_list_node); free(uc_info); -- 2.20.1