audio: Cleanup and fix voicecall preparation

* if (usecase == NULL) should actually be if (vc_usecase == NULL)
 * Avoid unnecessary if-block indentation by updating the control
   flow

Change-Id: If00ac405a1eac429862b953580e8614227015134
tirimbino
Christopher N. Hesse 8 years ago committed by Andreas Schneider
parent 8794541f19
commit 130da9f065
  1. 20
      audio/audio_hw.c

@ -905,28 +905,29 @@ static int select_devices(struct audio_device *adev,
}
active_out = (struct stream_out *)usecase->stream;
if (usecase->type == VOICE_CALL) {
out_snd_device = get_output_snd_device(adev, active_out->devices);
prepare_voice_session(adev->voice.session, active_out->devices);
in_snd_device = get_input_snd_device(adev, active_out->devices);
usecase->devices = active_out->devices;
} else {
/*
* If the voice call is active, use the sound devices of voice call usecase
* so that it would not result any device switch. All the usecases will
* be switched to new device when select_devices() is called for voice call
* usecase.
*/
if (adev->voice.in_call) {
if (usecase->type != VOICE_CALL && adev->voice.in_call) {
vc_usecase = get_usecase_from_id(adev, USECASE_VOICE_CALL);
if (usecase == NULL) {
if (vc_usecase == NULL) {
ALOGE("%s: Could not find the voice call usecase", __func__);
} else {
in_snd_device = vc_usecase->in_snd_device;
out_snd_device = vc_usecase->out_snd_device;
}
}
if (usecase->type == PCM_PLAYBACK) {
if (usecase->type == VOICE_CALL) {
usecase->devices = active_out->devices;
prepare_voice_session(adev->voice.session, active_out->devices);
out_snd_device = get_output_snd_device(adev, active_out->devices);
in_snd_device = get_input_snd_device(adev, active_out->devices);
} else if (usecase->type == PCM_PLAYBACK) {
usecase->devices = active_out->devices;
in_snd_device = SND_DEVICE_NONE;
if (out_snd_device == SND_DEVICE_NONE) {
@ -949,7 +950,6 @@ static int select_devices(struct audio_device *adev,
}
}
}
}
if (out_snd_device == usecase->out_snd_device &&
in_snd_device == usecase->in_snd_device) {

Loading…
Cancel
Save