audio policy: support platforms with no audio devices
Remove requirement to declare an AUDIO_DEVICE_OUT_SPEAKER device
for platforms without audio output.
By convention:
- platforms without audio output should declare a single output
device of type AUDIO_DEVICE_OUT_STUB also declared as default
output device
- platforms without audio input should declare a single input
device of type AUDIO_DEVICE_IN_STUB
Platforms with no audio at all can use stub audio policy configuration
file and audio HAL with the following instructions in device.mk file:
USE_XML_AUDIO_POLICY_CONF := 1
PRODUCT_PACKAGES += \
audio.stub.default
PRODUCT_COPY_FILES += \
frameworks/av/services/audiopolicy/config/audio_policy_configuration_stub.xml:system/etc/audio_policy_configuration.xml
Bug: 25075342
Change-Id: Id700978559427edd3c7cc38d98f2fd52928367ed
diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp
index f2224fd..d31429c 100755
--- a/services/audiopolicy/enginedefault/src/Engine.cpp
+++ b/services/audiopolicy/enginedefault/src/Engine.cpp
@@ -254,10 +254,6 @@
case STRATEGY_TRANSMITTED_THROUGH_SPEAKER:
device = availableOutputDevicesType & AUDIO_DEVICE_OUT_SPEAKER;
- if (!device) {
- ALOGE("getDeviceForStrategy() no device found for "\
- "STRATEGY_TRANSMITTED_THROUGH_SPEAKER");
- }
break;
case STRATEGY_SONIFICATION_RESPECTFUL:
@@ -373,11 +369,6 @@
if (device) break;
}
device = availableOutputDevicesType & AUDIO_DEVICE_OUT_EARPIECE;
- if (device) break;
- device = mApmObserver->getDefaultOutputDevice()->type();
- if (device == AUDIO_DEVICE_NONE) {
- ALOGE("getDeviceForStrategy() no device found for STRATEGY_PHONE");
- }
break;
case AUDIO_POLICY_FORCE_SPEAKER:
@@ -402,11 +393,6 @@
if (device) break;
}
device = availableOutputDevicesType & AUDIO_DEVICE_OUT_SPEAKER;
- if (device) break;
- device = mApmObserver->getDefaultOutputDevice()->type();
- if (device == AUDIO_DEVICE_NONE) {
- ALOGE("getDeviceForStrategy() no device found for STRATEGY_PHONE, FORCE_SPEAKER");
- }
break;
}
break;
@@ -431,9 +417,6 @@
if ((strategy == STRATEGY_SONIFICATION) ||
(mForceUse[AUDIO_POLICY_FORCE_FOR_SYSTEM] == AUDIO_POLICY_FORCE_SYSTEM_ENFORCED)) {
device = availableOutputDevicesType & AUDIO_DEVICE_OUT_SPEAKER;
- if (device == AUDIO_DEVICE_NONE) {
- ALOGE("getDeviceForStrategy() speaker device not found for STRATEGY_SONIFICATION");
- }
}
// The second device used for sonification is the same as the device used by media strategy
// FALL THROUGH
@@ -545,12 +528,6 @@
AUDIO_POLICY_FORCE_HDMI_SYSTEM_AUDIO_ENFORCED)) {
device &= ~AUDIO_DEVICE_OUT_SPEAKER;
}
-
- if (device) break;
- device = mApmObserver->getDefaultOutputDevice()->type();
- if (device == AUDIO_DEVICE_NONE) {
- ALOGE("getDeviceForStrategy() no device found for STRATEGY_MEDIA");
- }
} break;
default:
@@ -558,6 +535,12 @@
break;
}
+ if (device == AUDIO_DEVICE_NONE) {
+ ALOGV("getDeviceForStrategy() no device found for strategy %d", strategy);
+ device = mApmObserver->getDefaultOutputDevice()->type();
+ ALOGE_IF(device == AUDIO_DEVICE_NONE,
+ "getDeviceForStrategy() no default device defined");
+ }
ALOGVV("getDeviceForStrategy() strategy %d, device %x", strategy, device);
return device;
}
@@ -677,6 +660,14 @@
ALOGW("getDeviceForInputSource() invalid input source %d", inputSource);
break;
}
+ if (device == AUDIO_DEVICE_NONE) {
+ ALOGV("getDeviceForInputSource() no device found for source %d", inputSource);
+ if (availableDeviceTypes & AUDIO_DEVICE_IN_STUB) {
+ device = AUDIO_DEVICE_IN_STUB;
+ }
+ ALOGE_IF(device == AUDIO_DEVICE_NONE,
+ "getDeviceForInputSource() no default device defined");
+ }
ALOGV("getDeviceForInputSource()input source %d, device %08x", inputSource, device);
return device;
}