audio policy: fix call audio over 24 bit USB device
Take into account voice RX source device properties when
configuring the audio patch bridging the voice RX device
to the USB output device.
Bug: 25643110
Change-Id: I06f282d3cc12493f21500bf9ab35a3ceb93f14af
diff --git a/services/audioflinger/PatchPanel.cpp b/services/audioflinger/PatchPanel.cpp
index d85ac87..89de68e 100644
--- a/services/audioflinger/PatchPanel.cpp
+++ b/services/audioflinger/PatchPanel.cpp
@@ -248,14 +248,27 @@
goto exit;
}
}
- uint32_t channelCount = newPatch->mPlaybackThread->channelCount();
audio_devices_t device = patch->sources[0].ext.device.type;
String8 address = String8(patch->sources[0].ext.device.address);
audio_config_t config = AUDIO_CONFIG_INITIALIZER;
- audio_channel_mask_t inChannelMask = audio_channel_in_mask_from_count(channelCount);
- config.sample_rate = newPatch->mPlaybackThread->sampleRate();
- config.channel_mask = inChannelMask;
- config.format = newPatch->mPlaybackThread->format();
+ // open input stream with source device audio properties if provided or
+ // default to peer output stream properties otherwise.
+ if (patch->sources[0].config_mask & AUDIO_PORT_CONFIG_SAMPLE_RATE) {
+ config.sample_rate = patch->sources[0].sample_rate;
+ } else {
+ config.sample_rate = newPatch->mPlaybackThread->sampleRate();
+ }
+ if (patch->sources[0].config_mask & AUDIO_PORT_CONFIG_CHANNEL_MASK) {
+ config.channel_mask = patch->sources[0].channel_mask;
+ } else {
+ config.channel_mask =
+ audio_channel_in_mask_from_count(newPatch->mPlaybackThread->channelCount());
+ }
+ if (patch->sources[0].config_mask & AUDIO_PORT_CONFIG_FORMAT) {
+ config.format = patch->sources[0].format;
+ } else {
+ config.format = newPatch->mPlaybackThread->format();
+ }
audio_io_handle_t input = AUDIO_IO_HANDLE_NONE;
newPatch->mRecordThread = audioflinger->openInput_l(srcModule,
&input,
@@ -265,7 +278,7 @@
AUDIO_SOURCE_MIC,
AUDIO_INPUT_FLAG_NONE);
ALOGV("audioflinger->openInput_l() returned %p inChannelMask %08x",
- newPatch->mRecordThread.get(), inChannelMask);
+ newPatch->mRecordThread.get(), config.channel_mask);
if (newPatch->mRecordThread == 0) {
status = NO_MEMORY;
goto exit;
diff --git a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
index fe03429..44f380a 100644
--- a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
@@ -228,7 +228,17 @@
void DeviceDescriptor::toAudioPortConfig(struct audio_port_config *dstConfig,
const struct audio_port_config *srcConfig) const
{
- dstConfig->config_mask = AUDIO_PORT_CONFIG_CHANNEL_MASK|AUDIO_PORT_CONFIG_GAIN;
+ dstConfig->config_mask = AUDIO_PORT_CONFIG_GAIN;
+ if (mSamplingRate != 0) {
+ dstConfig->config_mask |= AUDIO_PORT_CONFIG_SAMPLE_RATE;
+ }
+ if (mChannelMask != AUDIO_CHANNEL_NONE) {
+ dstConfig->config_mask |= AUDIO_PORT_CONFIG_CHANNEL_MASK;
+ }
+ if (mFormat != AUDIO_FORMAT_INVALID) {
+ dstConfig->config_mask |= AUDIO_PORT_CONFIG_FORMAT;
+ }
+
if (srcConfig != NULL) {
dstConfig->config_mask |= srcConfig->config_mask;
}
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 07c470d..fe2f9a6 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -309,9 +309,6 @@
void AudioPolicyManager::updateCallRouting(audio_devices_t rxDevice, int delayMs)
{
bool createTxPatch = false;
- struct audio_patch patch;
- patch.num_sources = 1;
- patch.num_sinks = 1;
status_t status;
audio_patch_handle_t afPatchHandle;
DeviceVector deviceList;
@@ -344,8 +341,11 @@
== AUDIO_DEVICE_NONE) {
createTxPatch = true;
}
- } else {
- // create RX path audio patch
+ } else { // create RX path audio patch
+ struct audio_patch patch;
+
+ patch.num_sources = 1;
+ patch.num_sinks = 1;
deviceList = mAvailableOutputDevices.getDevicesFromType(rxDevice);
ALOG_ASSERT(!deviceList.isEmpty(),
"updateCallRouting() selected device not in output device list");
@@ -384,9 +384,9 @@
}
createTxPatch = true;
}
- if (createTxPatch) {
-
+ if (createTxPatch) { // create TX path audio patch
struct audio_patch patch;
+
patch.num_sources = 1;
patch.num_sinks = 1;
deviceList = mAvailableInputDevices.getDevicesFromType(txDevice);