Audio Policy: add audio.msd.disable property for MSD detour
APM checks audio.msd.disable property before reporting presence
of the MSD module to allow bypassing the MSD in tests and
for vendors to create tracks directly on the main output.
Bug: 63901775
Test: MSD prototype
Change-Id: I8ffb12fc81b3c71d810eeb8d90f54fef282e80f2
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 58acad3..f39614e 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -1070,8 +1070,17 @@
return output;
}
-sp<DeviceDescriptor> AudioPolicyManager::getMsdAudioInDevice() const {
+sp<HwModule> AudioPolicyManager::getMsdModule() const {
sp<HwModule> msdModule = mHwModules.getModuleFromName(AUDIO_HARDWARE_MODULE_ID_MSD);
+ if (msdModule != 0 && property_get_bool("audio.msd.disable", false /* default_value */)) {
+ ALOGI("use of the MSD module is disabled by audio.msd.disable property");
+ return 0;
+ }
+ return msdModule;
+}
+
+sp<DeviceDescriptor> AudioPolicyManager::getMsdAudioInDevice() const {
+ sp<HwModule> msdModule = getMsdModule();
if (msdModule != 0) {
DeviceVector msdInputDevices = mAvailableInputDevices.getDevicesFromHwModule(
msdModule->getHandle());
@@ -1081,7 +1090,7 @@
}
audio_devices_t AudioPolicyManager::getMsdAudioOutDeviceTypes() const {
- sp<HwModule> msdModule = mHwModules.getModuleFromName(AUDIO_HARDWARE_MODULE_ID_MSD);
+ sp<HwModule> msdModule = getMsdModule();
if (msdModule != 0) {
return mAvailableOutputDevices.getDeviceTypesFromHwModule(msdModule->getHandle());
}
@@ -1090,6 +1099,7 @@
const AudioPatchCollection AudioPolicyManager::getMsdPatches() const {
AudioPatchCollection msdPatches;
+ // This function ignores audio.msd.disable property to allow patch teardown.
sp<HwModule> msdModule = mHwModules.getModuleFromName(AUDIO_HARDWARE_MODULE_ID_MSD);
if (msdModule != 0) {
for (size_t i = 0; i < mAudioPatches.size(); ++i) {
@@ -1109,7 +1119,7 @@
status_t AudioPolicyManager::getBestMsdAudioProfileFor(audio_devices_t outputDevice,
bool hwAvSync, audio_port_config *sourceConfig, audio_port_config *sinkConfig) const
{
- sp<HwModule> msdModule = mHwModules.getModuleFromName(AUDIO_HARDWARE_MODULE_ID_MSD);
+ sp<HwModule> msdModule = getMsdModule();
if (msdModule == nullptr) {
ALOGE("%s() unable to get MSD module", __func__);
return NO_INIT;
@@ -4627,7 +4637,7 @@
checkOutputForAllStrategies();
if (onOutputsChecked != nullptr && onOutputsChecked()) checkA2dpSuspend();
updateDevicesAndOutputs();
- if (mHwModules.getModuleFromName(AUDIO_HARDWARE_MODULE_ID_MSD) != 0) {
+ if (getMsdModule() != 0) {
setMsdPatch();
}
}