From 6a94d69dc4f32abb53c466a96f905bb199be6417 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Tue, 20 May 2014 11:18:06 -0700 Subject: audio policy: implement routing control Add implementation of audio routing control via AudioSystem APIs. The following APIs are implemented: - listAudioPorts(): return a list of devices and output/input mixers ports that can be used as sources or sinks for audio patches. - createAudioPatch()/releaseAudioPatch(): create/release a connection patch between two audio ports (e.g. to connect input from an HDMI device to a speaker output device). Only one client application can own a patch from a given source. When an audio port (device or mix) is part of an application created patch, its routing cannot not be changed by a policy decision. - listAudioPatches(): return a list of existing patches. Each audio port addition/removal and each audio patch creation/release increments a generation count. This generation count is used to ensure consistency betwen calls to listAudioPorts() and listAudioPatches(). Bug: 14815883. Change-Id: I022b638c2f5f0bb41543c7cfca7488fb45cfdd80 --- services/audioflinger/PatchPanel.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'services/audioflinger/PatchPanel.cpp') diff --git a/services/audioflinger/PatchPanel.cpp b/services/audioflinger/PatchPanel.cpp index eee74b3..9680a9a 100644 --- a/services/audioflinger/PatchPanel.cpp +++ b/services/audioflinger/PatchPanel.cpp @@ -179,11 +179,11 @@ status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *pa ALOGW("createAudioPatch() bad src hw module %d", src_module); return BAD_VALUE; } + AudioHwDevice *audioHwDevice = audioflinger->mAudioHwDevs.valueAt(index); for (unsigned int i = 0; i < patch->num_sinks; i++) { - // limit to connections between devices and output streams - if (patch->sinks[i].type != AUDIO_PORT_TYPE_MIX) { - ALOGW("createAudioPatch() invalid sink type %d for device source", - patch->sinks[i].type); + // reject connection to different sink types + if (patch->sinks[i].type != patch->sinks[0].type) { + ALOGW("createAudioPatch() different sink types in same patch not supported"); return BAD_VALUE; } // limit to connections between sinks and sources on same HW module @@ -192,9 +192,16 @@ status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *pa "sink on module %d", src_module, patch->sinks[i].ext.mix.hw_module); return BAD_VALUE; } + + // limit to connections between devices and output streams for HAL before 3.0 + if ((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); + return BAD_VALUE; + } } - AudioHwDevice *audioHwDevice = audioflinger->mAudioHwDevs.valueAt(index); if (audioHwDevice->version() >= AUDIO_DEVICE_API_VERSION_3_0) { if (patch->sinks[0].type == AUDIO_PORT_TYPE_MIX) { sp thread = audioflinger->checkRecordThread_l( -- cgit v1.1