policy_hal: Fix check for direct pcm
-mediaplayer now opens a sink with DIRECT_PCM flag for eligible
playbacks, now if setPlayback rate api is triggered for
mediaplayer object,fall back to deep buffer output should happen.
But as the DIRECT_PCM flag is not removed from the requested flags,
the same direct output gets selected.
-Ensure that DIRECT_PCM flag is removed always if present,
before query for output, otherwise even when no direct output
is required, might end up with one.
Change-Id: Ie27e90851a0de4a6a6c2dc205a8ed9e281663626
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index 089efc5..3396054 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -1409,6 +1409,7 @@
{
bool playerDirectPCM = false; // Output request for Track created by mediaplayer
bool trackDirectPCM = false; // Output request for track created by other apps
+ bool offloadDisabled = property_get_bool("audio.offload.disable", false);
// Direct PCM is allowed only if
// In case of mediaPlayer playback
@@ -1417,6 +1418,10 @@
// In case of AudioTracks created by apps
// track offload is enabled and FLAG requested is FLAG_NONE.
+ if (offloadDisabled) {
+ ALOGI("offload disabled by audio.offload.disable=%d", offloadDisabled);
+ }
+
if (*flags == AUDIO_OUTPUT_FLAG_DIRECT_PCM) {
if (bitWidth == 24 || bitWidth == 32)
playerDirectPCM =
@@ -1431,8 +1436,10 @@
trackDirectPCM = property_get_bool("audio.offload.track.enable", true);
}
- ALOGI("%s for Direct PCM",trackDirectPCM || playerDirectPCM?"Check":"Dont check");
- return trackDirectPCM || playerDirectPCM;
+ ALOGI("Direct PCM %s for this request",
+ (!offloadDisabled && (trackDirectPCM || playerDirectPCM))?"can be enabled":"is disabled");
+
+ return (!offloadDisabled && (trackDirectPCM || playerDirectPCM));
}
status_t AudioPolicyManagerCustom::getOutputForAttr(const audio_attributes_t *attr,
@@ -1449,15 +1456,11 @@
{
audio_offload_info_t tOffloadInfo = AUDIO_INFO_INITIALIZER;
- bool offloadDisabled = property_get_bool("audio.offload.disable", false);
uint32_t bitWidth = (audio_bytes_per_sample(format) * 8);
- if (offloadDisabled) {
- ALOGI("offload disabled by audio.offload.disable=%d", offloadDisabled);
- }
- if (!offloadDisabled && (offloadInfo == NULL) &&
- tryForDirectPCM(bitWidth, &flags)) {
+ if (tryForDirectPCM(bitWidth, &flags) &&
+ (offloadInfo == NULL)) {
tOffloadInfo.sample_rate = samplingRate;
tOffloadInfo.channel_mask = channelMask;