Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c951bc11 authored by Mikhail Naganov's avatar Mikhail Naganov Committed by Automerger Merge Worker
Browse files

APM: Fix config de-serialization am: 8916ae92

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/1612012

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I6bbbbd04b46d92dfb096780f8a4c6635d8345bec
parents 3a55dfac 8916ae92
Loading
Loading
Loading
Loading
+25 −6
Original line number Diff line number Diff line
@@ -33,6 +33,15 @@

namespace android {

// This class gathers together various bits of AudioPolicyManager
// configuration, which are usually filled out as a result of parsing
// the audio_policy_configuration.xml file.
//
// Note that AudioPolicyConfig doesn't own some of the data,
// it simply proxies access to the fields of AudioPolicyManager
// class. Be careful about the fields that are references,
// e.g. 'mOutputDevices'. This also means that it's impossible
// to implement "deep copying" of this class without re-designing it.
class AudioPolicyConfig
{
public:
@@ -40,14 +49,24 @@ public:
                      DeviceVector &outputDevices,
                      DeviceVector &inputDevices,
                      sp<DeviceDescriptor> &defaultOutputDevice)
        : mEngineLibraryNameSuffix(kDefaultEngineLibraryNameSuffix),
          mHwModules(hwModules),
        : mHwModules(hwModules),
          mOutputDevices(outputDevices),
          mInputDevices(inputDevices),
          mDefaultOutputDevice(defaultOutputDevice),
          mIsSpeakerDrcEnabled(false),
          mIsCallScreenModeSupported(false)
    {}
          mDefaultOutputDevice(defaultOutputDevice) {
        clear();
    }

    void clear() {
        mSource = {};
        mEngineLibraryNameSuffix = kDefaultEngineLibraryNameSuffix;
        mHwModules.clear();
        mOutputDevices.clear();
        mInputDevices.clear();
        mDefaultOutputDevice.clear();
        mIsSpeakerDrcEnabled = false;
        mIsCallScreenModeSupported = false;
        mSurroundFormats.clear();
    }

    const std::string& getSource() const {
        return mSource;
+4 −3
Original line number Diff line number Diff line
@@ -253,9 +253,8 @@ template <class T>
constexpr void (*xmlDeleter)(T* t);
template <>
constexpr auto xmlDeleter<xmlDoc> = xmlFreeDoc;
// http://b/111067277 - Add back constexpr when we switch to C++17.
template <>
auto xmlDeleter<xmlChar> = [](xmlChar *s) { xmlFree(s); };
constexpr auto xmlDeleter<xmlChar> = [](xmlChar *s) { xmlFree(s); };

/** @return a unique_ptr with the correct deleter for the libxml2 object. */
template <class T>
@@ -841,7 +840,9 @@ status_t PolicySerializer::deserialize(const char *configFile, AudioPolicyConfig
status_t deserializeAudioPolicyFile(const char *fileName, AudioPolicyConfig *config)
{
    PolicySerializer serializer;
    return serializer.deserialize(fileName, config);
    status_t status = serializer.deserialize(fileName, config);
    if (status != OK) config->clear();
    return status;
}

} // namespace android
+0 −1
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@

#include "EngineBase.h"
#include "EngineDefaultConfig.h"
#include "../include/EngineBase.h"
#include <TypeConverter.h>

namespace android {
+7 −0
Original line number Diff line number Diff line
{
  "presubmit": [
    {
       "name": "audiopolicy_engineconfig_tests"
    }
  ]
}
+2 −0
Original line number Diff line number Diff line
@@ -111,6 +111,8 @@ struct ParsingResult {
 */
ParsingResult parse(const char* path = DEFAULT_PATH);
android::status_t parseLegacyVolumes(VolumeGroups &volumeGroups);
// Exposed for testing.
android::status_t parseLegacyVolumeFile(const char* path, VolumeGroups &volumeGroups);

} // namespace engineConfig
} // namespace android
Loading