From e6e9a4811dc43e5c393b2c45eca64d1f1608e8d0 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Tue, 25 Jul 2017 19:26:02 -0700 Subject: [PATCH] AudioFlinger: fix set parameters on mmap streams Bug: 63935167 Test: Verify capture from USB mic on mmap input stream Change-Id: I416eb90ef0e9d51d54f6450c374c086ab078d288 --- services/audioflinger/Threads.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index 1bd840e15f..65eccb6db4 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -7855,17 +7855,34 @@ bool AudioFlinger::MmapThread::checkForNewParameter_l(const String8& keyValuePai { AudioParameter param = AudioParameter(keyValuePair); int value; + bool sendToHal = true; if (param.getInt(String8(AudioParameter::keyRouting), value) == NO_ERROR) { + audio_devices_t device = (audio_devices_t)value; // forward device change to effects that have requested to be // aware of attached audio device. - if (value != AUDIO_DEVICE_NONE) { - mOutDevice = value; + if (device != AUDIO_DEVICE_NONE) { for (size_t i = 0; i < mEffectChains.size(); i++) { - mEffectChains[i]->setDevice_l(mOutDevice); + mEffectChains[i]->setDevice_l(device); } } + if (audio_is_output_devices(device)) { + mOutDevice = device; + if (!isOutput()) { + sendToHal = false; + } + } else { + mInDevice = device; + if (device != AUDIO_DEVICE_NONE) { + mPrevInDevice = value; + } + // TODO: implement and call checkBtNrec_l(); + } + } + if (sendToHal) { + status = mHalStream->setParameters(keyValuePair); + } else { + status = NO_ERROR; } - status = mHalStream->setParameters(keyValuePair); return false; }