Split getSurroundSound method in 2 methods.
Split getSurroundSound in:
getSurroundSound for formats supported by source android device
getReportedSurroundSound for formats reported by any connected sound
device like soundbar etc.
Bug: 177990551
Test: atest AudioPolicyManagerTestForHdmi
Change-Id: Iac811315049f0598c930afd75f069f058080dad4
diff --git a/media/libaudioclient/AudioSystem.cpp b/media/libaudioclient/AudioSystem.cpp
index 74258a1..8edfef0 100644
--- a/media/libaudioclient/AudioSystem.cpp
+++ b/media/libaudioclient/AudioSystem.cpp
@@ -1839,8 +1839,7 @@
status_t AudioSystem::getSurroundFormats(unsigned int* numSurroundFormats,
audio_format_t* surroundFormats,
- bool* surroundFormatsEnabled,
- bool reported) {
+ bool* surroundFormatsEnabled) {
if (numSurroundFormats == nullptr || (*numSurroundFormats != 0 &&
(surroundFormats == nullptr ||
surroundFormatsEnabled == nullptr))) {
@@ -1855,8 +1854,8 @@
std::vector<media::audio::common::AudioFormat> surroundFormatsAidl;
std::vector<bool> surroundFormatsEnabledAidl;
RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
- aps->getSurroundFormats(reported, &numSurroundFormatsAidl,
- &surroundFormatsAidl, &surroundFormatsEnabledAidl)));
+ aps->getSurroundFormats(&numSurroundFormatsAidl, &surroundFormatsAidl,
+ &surroundFormatsEnabledAidl)));
*numSurroundFormats = VALUE_OR_RETURN_STATUS(
convertIntegral<unsigned int>(numSurroundFormatsAidl.value));
@@ -1868,6 +1867,29 @@
return OK;
}
+status_t AudioSystem::getReportedSurroundFormats(unsigned int* numSurroundFormats,
+ audio_format_t* surroundFormats) {
+ if (numSurroundFormats == nullptr || (*numSurroundFormats != 0 && surroundFormats == nullptr)) {
+ return BAD_VALUE;
+ }
+
+ const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
+ if (aps == 0) return PERMISSION_DENIED;
+ media::Int numSurroundFormatsAidl;
+ numSurroundFormatsAidl.value =
+ VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(*numSurroundFormats));
+ std::vector<media::audio::common::AudioFormat> surroundFormatsAidl;
+ RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
+ aps->getReportedSurroundFormats(&numSurroundFormatsAidl, &surroundFormatsAidl)));
+
+ *numSurroundFormats = VALUE_OR_RETURN_STATUS(
+ convertIntegral<unsigned int>(numSurroundFormatsAidl.value));
+ RETURN_STATUS_IF_ERROR(
+ convertRange(surroundFormatsAidl.begin(), surroundFormatsAidl.end(), surroundFormats,
+ aidl2legacy_AudioFormat_audio_format_t));
+ return OK;
+}
+
status_t AudioSystem::setSurroundFormatEnabled(audio_format_t audioFormat, bool enabled) {
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return PERMISSION_DENIED;