summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/PatchPanel.cpp
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2015-04-03 12:13:24 -0700
committerEric Laurent <elaurent@google.com>2015-04-08 12:38:08 -0700
commit3bcf8597189c592713675ec58326ecbef0ac4ae9 (patch)
tree5656987c2e9d6fe9c99bb632865318489432fe36 /services/audioflinger/PatchPanel.cpp
parent322b4d25387a04c9afebe998326d005bbdf17ede (diff)
downloadframeworks_av-3bcf8597189c592713675ec58326ecbef0ac4ae9.zip
frameworks_av-3bcf8597189c592713675ec58326ecbef0ac4ae9.tar.gz
frameworks_av-3bcf8597189c592713675ec58326ecbef0ac4ae9.tar.bz2
audio flinger: improve device to device audio patches
Allow creation of audio patches between input and output devices managed by the same audio HW module. Change-Id: I4b83268a4d5c41f3d5905d7581202cf5193efd32
Diffstat (limited to 'services/audioflinger/PatchPanel.cpp')
-rw-r--r--services/audioflinger/PatchPanel.cpp38
1 files changed, 17 insertions, 21 deletions
diff --git a/services/audioflinger/PatchPanel.cpp b/services/audioflinger/PatchPanel.cpp
index efbdcff..834947f 100644
--- a/services/audioflinger/PatchPanel.cpp
+++ b/services/audioflinger/PatchPanel.cpp
@@ -200,26 +200,17 @@ status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *pa
status = BAD_VALUE;
goto exit;
}
- // limit to connections between devices and input streams for HAL before 3.0
- if (patch->sinks[i].ext.mix.hw_module == srcModule &&
- (audioHwDevice->version() < AUDIO_DEVICE_API_VERSION_3_0) &&
- (patch->sinks[i].type != AUDIO_PORT_TYPE_MIX)) {
- ALOGW("createAudioPatch() invalid sink type %d for device source",
- patch->sinks[i].type);
- status = BAD_VALUE;
- goto exit;
- }
}
- if (patch->sinks[0].ext.device.hw_module != srcModule) {
- // limit to device to device connection if not on same hw module
- if (patch->sinks[0].type != AUDIO_PORT_TYPE_DEVICE) {
- ALOGW("createAudioPatch() invalid sink type for cross hw module");
- status = INVALID_OPERATION;
- goto exit;
- }
- // special case num sources == 2 -=> reuse an exiting output mix to connect to the
- // sink
+ // manage patches requiring a software bridge
+ // - Device to device AND
+ // - source HW module != destination HW module OR
+ // - audio HAL version < 3.0
+ // - special patch request with 2 sources (reuse one existing output mix)
+ if ((patch->sinks[0].type == AUDIO_PORT_TYPE_DEVICE) &&
+ ((patch->sinks[0].ext.device.hw_module != srcModule) ||
+ (audioHwDevice->version() < AUDIO_DEVICE_API_VERSION_3_0) ||
+ (patch->num_sources == 2))) {
if (patch->num_sources == 2) {
if (patch->sources[1].type != AUDIO_PORT_TYPE_MIX ||
patch->sinks[0].ext.device.hw_module !=
@@ -304,6 +295,11 @@ status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *pa
&halHandle);
}
} else {
+ if (patch->sinks[0].type != AUDIO_PORT_TYPE_MIX) {
+ status = INVALID_OPERATION;
+ goto exit;
+ }
+
sp<ThreadBase> thread = audioflinger->checkRecordThread_l(
patch->sinks[0].ext.mix.handle);
if (thread == 0) {
@@ -472,6 +468,7 @@ status_t AudioFlinger::PatchPanel::createPatchConnections(Patch *patch,
// this track is given the same buffer as the PatchRecord buffer
patch->mPatchTrack = new PlaybackThread::PatchTrack(
patch->mPlaybackThread.get(),
+ audioPatch->sources[1].ext.mix.usecase.stream,
sampleRate,
outChannelMask,
format,
@@ -578,8 +575,8 @@ status_t AudioFlinger::PatchPanel::releaseAudioPatch(audio_patch_handle_t handle
break;
}
- if (patch->sinks[0].type == AUDIO_PORT_TYPE_DEVICE &&
- patch->sinks[0].ext.device.hw_module != srcModule) {
+ if (removedPatch->mRecordPatchHandle != AUDIO_PATCH_HANDLE_NONE ||
+ removedPatch->mPlaybackPatchHandle != AUDIO_PATCH_HANDLE_NONE) {
clearPatchConnections(removedPatch);
break;
}
@@ -693,5 +690,4 @@ status_t AudioFlinger::PatchPanel::setAudioPortConfig(const struct audio_port_co
return NO_ERROR;
}
-
} // namespace android