Merge "audio: Make IConfig.getSurroundSound default implementation more robust" into main am: 58d953e4be

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2723318

Change-Id: Ic9027ee666526f077b2402a0c7ccab8bd75f6775
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2023-08-23 23:09:18 +00:00 committed by Automerger Merge Worker
commit cc476475f8
2 changed files with 18 additions and 12 deletions

View file

@ -27,12 +27,11 @@ using aidl::android::media::audio::common::AudioHalEngineConfig;
namespace aidl::android::hardware::audio::core {
ndk::ScopedAStatus Config::getSurroundSoundConfig(SurroundSoundConfig* _aidl_return) {
static const auto& func = __func__;
static const SurroundSoundConfig surroundSoundConfig = [this]() {
SurroundSoundConfig surroundCfg;
if (mAudioPolicyConverter.getStatus() == ::android::OK) {
surroundCfg = mAudioPolicyConverter.getSurroundSoundConfig();
} else {
LOG(WARNING) << __func__ << mAudioPolicyConverter.getError();
SurroundSoundConfig surroundCfg = mAudioPolicyConverter.getSurroundSoundConfig();
if (mAudioPolicyConverter.getStatus() != ::android::OK) {
LOG(WARNING) << func << ": " << mAudioPolicyConverter.getError();
}
return surroundCfg;
}();
@ -42,21 +41,22 @@ ndk::ScopedAStatus Config::getSurroundSoundConfig(SurroundSoundConfig* _aidl_ret
}
ndk::ScopedAStatus Config::getEngineConfig(AudioHalEngineConfig* _aidl_return) {
static const auto& func = __func__;
static const AudioHalEngineConfig returnEngCfg = [this]() {
AudioHalEngineConfig engConfig;
if (mEngConfigConverter.getStatus() == ::android::OK) {
engConfig = mEngConfigConverter.getAidlEngineConfig();
} else {
LOG(INFO) << __func__ << mEngConfigConverter.getError();
LOG(INFO) << func << ": " << mEngConfigConverter.getError();
if (mAudioPolicyConverter.getStatus() == ::android::OK) {
engConfig = mAudioPolicyConverter.getAidlEngineConfig();
} else {
LOG(WARNING) << __func__ << mAudioPolicyConverter.getError();
LOG(WARNING) << func << ": " << mAudioPolicyConverter.getError();
}
}
// Logging full contents of the config is an overkill, just provide statistics.
LOG(DEBUG) << "getEngineConfig: number of strategies parsed: "
<< engConfig.productStrategies.size()
LOG(DEBUG) << func
<< ": number of strategies parsed: " << engConfig.productStrategies.size()
<< ", default strategy: " << engConfig.defaultProductStrategyId
<< ", number of volume groups parsed: " << engConfig.volumeGroups.size();
return engConfig;

View file

@ -53,10 +53,16 @@ class XmlConverter {
const ::android::status_t& status) {
std::string errorMessage;
if (status != ::android::OK) {
if (!isReadableConfigFile) {
errorMessage = "Could not read requested config file:" + configFilePath;
if (configFilePath.empty()) {
errorMessage = "No audio configuration files found";
} else if (!isReadableConfigFile) {
errorMessage = std::string("Could not read requested XML config file: \"")
.append(configFilePath)
.append("\"");
} else {
errorMessage = "Invalid config file: " + configFilePath;
errorMessage = std::string("Invalid XML config file: \"")
.append(configFilePath)
.append("\"");
}
}
return errorMessage;