diff options
author | Rios Kao <rioskao@google.com> | 2019-08-02 16:24:58 -0700 |
---|---|---|
committer | Rios Kao <rioskao@google.com> | 2019-08-02 16:31:39 -0700 |
commit | 5051429c2c9a6dcf3c1e152642e7f3eae5ef09a7 (patch) | |
tree | 0e468261027041502147ebda7caaea5970229f65 | |
parent | 97f14122298e02cbce28c4cdabd9f1d613ed9113 (diff) | |
download | android_hardware_knowles_athletico_sound_trigger_hal-5051429c2c9a6dcf3c1e152642e7f3eae5ef09a7.tar.gz android_hardware_knowles_athletico_sound_trigger_hal-5051429c2c9a6dcf3c1e152642e7f3eae5ef09a7.tar.bz2 android_hardware_knowles_athletico_sound_trigger_hal-5051429c2c9a6dcf3c1e152642e7f3eae5ef09a7.zip |
sthal: fix race condition of amp-ref route
note: Race condition happend during STREAM_INACTIVE and
DEVICE_INACTIVE, Application can start_reg during
this period. That will cause 48K amp-ref route
doesn't disable before enable 16K mic route.
That causes crash.
Bug:138081640
Test: manually test microphone concurrency and bargein scenario
Change-Id: Iaca6de7b1847b9b40a65ddab6398b19489a84da1
-rw-r--r-- | sound_trigger_hw_iaxxx.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/sound_trigger_hw_iaxxx.c b/sound_trigger_hw_iaxxx.c index 2f12383..268f14d 100644 --- a/sound_trigger_hw_iaxxx.c +++ b/sound_trigger_hw_iaxxx.c @@ -1382,6 +1382,12 @@ static bool do_handle_functions(struct knowles_sound_trigger_device *stdev, ALOGE("Failed to disable mic route with EXT OSC"); goto exit; } + + ret = enable_amp_ref_route(stdev->route_hdl, true, STRM_48K); + if (ret != 0) { + ALOGE("Failed to enable amp-ref route"); + goto exit; + } } else { ret = enable_mic_route(stdev->route_hdl, false, INTERNAL_OSCILLATOR); @@ -1438,6 +1444,11 @@ static bool do_handle_functions(struct knowles_sound_trigger_device *stdev, // reconfig mic if (stdev->is_mic_route_enabled == true) { if (stdev->is_bargein_route_enabled == true) { + ret = enable_amp_ref_route(stdev->route_hdl, false, STRM_48K); + if (ret != 0) { + ALOGE("Failed to disable amp-ref route"); + goto exit; + } ret = enable_mic_route(stdev->route_hdl, true, EXTERNAL_OSCILLATOR); if (ret != 0) { @@ -3552,15 +3563,6 @@ int sound_trigger_hw_call_back(audio_event_type_t event, else if (config->u.usecase.type == USECASE_TYPE_PCM_CAPTURE) stdev->is_media_recording = false; - // turn off amp-ref with 48khz before turning off main mic by media recording - if (is_mic_controlled_by_audhal(stdev) == true && - stdev->is_bargein_route_enabled == true) { - ret = enable_amp_ref_route(stdev->route_hdl, false, STRM_48K); - if (ret != 0) { - ALOGE("Failed to disable amp-ref route"); - goto exit; - } - } break; case AUDIO_EVENT_CAPTURE_DEVICE_ACTIVE: /* @@ -3599,15 +3601,6 @@ int sound_trigger_hw_call_back(audio_event_type_t event, ALOGD("%s: handle capture stream active event %d, usecase :%d", __func__, event, config->u.usecase.type); - // turn on amp-ref with 48khz after turning on main mic by media recording - if (is_mic_controlled_by_audhal(stdev) == true && - stdev->is_bargein_route_enabled == true) { - ret = enable_amp_ref_route(stdev->route_hdl, true, STRM_48K); - if (ret != 0) { - ALOGE("Failed to enable amp-ref route"); - goto exit; - } - } break; case AUDIO_EVENT_PLAYBACK_STREAM_INACTIVE: ALOGD("%s: handle playback stream inactive", __func__); |