AudioFlinger: fix set parameters on mmap streams
Bug: 63935167
Test: Verify capture from USB mic on mmap input stream
Change-Id: I416eb90ef0e9d51d54f6450c374c086ab078d288
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 1bd840e..65eccb6 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -7855,17 +7855,34 @@
{
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();
+ }
}
- status = mHalStream->setParameters(keyValuePair);
+ if (sendToHal) {
+ status = mHalStream->setParameters(keyValuePair);
+ } else {
+ status = NO_ERROR;
+ }
return false;
}