Fixing crash in surround sound settings which occurs
due to API getSurroundSound.
Bug: 178800104
Test: Tested manually
Change-Id: Ib0a13dfcdfa177676e8625703e9ddb2ce79e5d0e
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
index caf7309..399dfea 100644
--- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
@@ -1804,7 +1804,7 @@
Status AudioPolicyService::getSurroundFormats(
bool reported, media::Int* count,
std::vector<media::audio::common::AudioFormat>* formats,
- bool* _aidl_return) {
+ std::vector<bool>* formatsEnabled) {
unsigned int numSurroundFormats = VALUE_OR_RETURN_BINDER_STATUS(
convertIntegral<unsigned int>(count->value));
if (numSurroundFormats > MAX_ITEMS_PER_LIST) {
@@ -1812,6 +1812,7 @@
}
unsigned int numSurroundFormatsReq = numSurroundFormats;
std::unique_ptr<audio_format_t[]>surroundFormats(new audio_format_t[numSurroundFormats]);
+ std::unique_ptr<bool[]>surroundFormatsEnabled(new bool[numSurroundFormats]);
if (mAudioPolicyManager == NULL) {
return binderStatusFromStatusT(NO_INIT);
@@ -1820,11 +1821,15 @@
AutoCallerClear acc;
RETURN_IF_BINDER_ERROR(binderStatusFromStatusT(
mAudioPolicyManager->getSurroundFormats(&numSurroundFormats, surroundFormats.get(),
- _aidl_return, reported)));
+ surroundFormatsEnabled.get(), reported)));
numSurroundFormatsReq = std::min(numSurroundFormats, numSurroundFormatsReq);
RETURN_IF_BINDER_ERROR(binderStatusFromStatusT(
convertRange(surroundFormats.get(), surroundFormats.get() + numSurroundFormatsReq,
std::back_inserter(*formats), legacy2aidl_audio_format_t_AudioFormat)));
+ formatsEnabled->insert(
+ formatsEnabled->begin(),
+ surroundFormatsEnabled.get(),
+ surroundFormatsEnabled.get() + numSurroundFormatsReq);
count->value = VALUE_OR_RETURN_BINDER_STATUS(convertIntegral<uint32_t>(numSurroundFormats));
return Status::ok();
}
diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h
index 72d8f28..110beca 100644
--- a/services/audiopolicy/service/AudioPolicyService.h
+++ b/services/audiopolicy/service/AudioPolicyService.h
@@ -185,7 +185,7 @@
float* _aidl_return) override;
binder::Status getSurroundFormats(bool reported, media::Int* count,
std::vector<media::audio::common::AudioFormat>* formats,
- bool* _aidl_return) override;
+ std::vector<bool>* formatsEnabled) override;
binder::Status getHwOffloadEncodingFormatsSupportedForA2DP(
std::vector<media::audio::common::AudioFormat>* _aidl_return) override;
binder::Status setSurroundFormatEnabled(media::audio::common::AudioFormat audioFormat,