Fixing crash in surround sound settings which occurs
due to API getSurroundSound.
Bug: 178800104
Test: Tested manually
Change-Id: Ib0a13dfcdfa177676e8625703e9ddb2ce79e5d0e
diff --git a/media/libaudioclient/AudioSystem.cpp b/media/libaudioclient/AudioSystem.cpp
index 14578d6..f1fa7f5 100644
--- a/media/libaudioclient/AudioSystem.cpp
+++ b/media/libaudioclient/AudioSystem.cpp
@@ -1849,19 +1849,22 @@
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;
+ std::vector<bool> surroundFormatsEnabledAidl;
RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
- aps->getSurroundFormats(reported, &numSurroundFormatsAidl, &surroundFormatsAidl,
- surroundFormatsEnabled)));
+ aps->getSurroundFormats(reported, &numSurroundFormatsAidl,
+ &surroundFormatsAidl, &surroundFormatsEnabledAidl)));
+
*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));
+ std::copy(surroundFormatsEnabledAidl.begin(), surroundFormatsEnabledAidl.end(),
+ surroundFormatsEnabled);
return OK;
}
diff --git a/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl b/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl
index 75dfc36..c8ab0ae 100644
--- a/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl
+++ b/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl
@@ -272,16 +272,17 @@
float getStreamVolumeDB(AudioStreamType stream, int index, int /* audio_devices_t */ device);
/**
- * Returns whether surround formats are enabled.
+ * Populates supported surround formats and their enabled state in formats and formatsEnabled.
*
* On input, count represents the maximum length of the returned array.
* On output, count is the total number of elements, which may be larger than the array size.
* Passing '0' on input and inspecting the value on output is a common way of determining the
* number of elements without actually retrieving them.
*/
- boolean getSurroundFormats(boolean reported,
- inout Int count,
- out AudioFormat[] formats);
+ void getSurroundFormats(boolean reported,
+ inout Int count,
+ out AudioFormat[] formats,
+ out boolean[] formatsEnabled);
AudioFormat[] getHwOffloadEncodingFormatsSupportedForA2DP();