fix record from default input source
Commit caf7f48a0e broke capture from default
input source on some devices: the input source is now specified as part of
the audio attributes and the default source was not remapped to mic source.
Bug: 18736417.
Change-Id: I3f5da33cdb56f959aaef68ed1952342babc63aa0
diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp
index 8d1b3bb..0349327 100644
--- a/services/audiopolicy/AudioPolicyManager.cpp
+++ b/services/audiopolicy/AudioPolicyManager.cpp
@@ -1440,10 +1440,16 @@
// handle legacy remote submix case where the address was not always specified
String8 address = String8("");
bool isSoundTrigger = false;
- audio_source_t halInputSource = attr->source;
+ audio_source_t inputSource = attr->source;
+ audio_source_t halInputSource;
AudioMix *policyMix = NULL;
- if (attr->source == AUDIO_SOURCE_REMOTE_SUBMIX &&
+ if (inputSource == AUDIO_SOURCE_DEFAULT) {
+ inputSource = AUDIO_SOURCE_MIC;
+ }
+ halInputSource = inputSource;
+
+ if (inputSource == AUDIO_SOURCE_REMOTE_SUBMIX &&
strncmp(attr->tags, "addr=", strlen("addr=")) == 0) {
device = AUDIO_DEVICE_IN_REMOTE_SUBMIX;
address = String8(attr->tags + strlen("addr="));
@@ -1459,9 +1465,9 @@
policyMix = &mPolicyMixes[index]->mMix;
*inputType = API_INPUT_MIX_EXT_POLICY_REROUTE;
} else {
- device = getDeviceAndMixForInputSource(attr->source, &policyMix);
+ device = getDeviceAndMixForInputSource(inputSource, &policyMix);
if (device == AUDIO_DEVICE_NONE) {
- ALOGW("getInputForAttr() could not find device for source %d", attr->source);
+ ALOGW("getInputForAttr() could not find device for source %d", inputSource);
return BAD_VALUE;
}
if (policyMix != NULL) {
@@ -1483,7 +1489,7 @@
*inputType = API_INPUT_LEGACY;
}
// adapt channel selection to input source
- switch (attr->source) {
+ switch (inputSource) {
case AUDIO_SOURCE_VOICE_UPLINK:
channelMask = AUDIO_CHANNEL_IN_VOICE_UPLINK;
break;
@@ -1496,7 +1502,7 @@
default:
break;
}
- if (attr->source == AUDIO_SOURCE_HOTWORD) {
+ if (inputSource == AUDIO_SOURCE_HOTWORD) {
ssize_t index = mSoundTriggerSessions.indexOfKey(session);
if (index >= 0) {
*input = mSoundTriggerSessions.valueFor(session);
@@ -1559,7 +1565,7 @@
}
sp<AudioInputDescriptor> inputDesc = new AudioInputDescriptor(profile);
- inputDesc->mInputSource = attr->source;
+ inputDesc->mInputSource = inputSource;
inputDesc->mRefCount = 0;
inputDesc->mOpenRefCount = 1;
inputDesc->mSamplingRate = samplingRate;