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

Commit edc0ae1e authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

audio: Centralize audio configuration paths specification

The list of possible paths for the audio configuration
files is now retrieved using audio_get_configuration_paths()
function. All duplicated lists of known configuration
directories have been removed.

Bug: 153680356
Test: test audio on built image working
      atest VtsHalAudioV5_0TargetTest VtsHalAudioPolicyV1_0TargetTest
Change-Id: I8c369442f5ca7baa17df95e6a001396fc9de5681
parent 04f759bf
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@ cc_library {
        "libtinyxml2",
        "libtinyxml2",
        "libutils",
        "libutils",
        "libmedia_helper",
        "libmedia_helper",
        "libcutils",
    ],
    ],


    header_libs: ["libaudio_system_headers"],
    header_libs: ["libaudio_system_headers"],
+0 −5
Original line number Original line Diff line number Diff line
@@ -35,11 +35,6 @@ namespace effectsConfig {
/** Default path of effect configuration file. Relative to DEFAULT_LOCATIONS. */
/** Default path of effect configuration file. Relative to DEFAULT_LOCATIONS. */
constexpr const char* DEFAULT_NAME = "audio_effects.xml";
constexpr const char* DEFAULT_NAME = "audio_effects.xml";


/** Default path of effect configuration file.
 * The /vendor partition is the recommended one, the others are deprecated.
 */
constexpr const char* DEFAULT_LOCATIONS[] = {"/odm/etc", "/vendor/etc", "/system/etc"};

/** Directories where the effect libraries will be search for. */
/** Directories where the effect libraries will be search for. */
constexpr const char* LD_EFFECT_LIBRARY_PATH[] =
constexpr const char* LD_EFFECT_LIBRARY_PATH[] =
#ifdef __LP64__
#ifdef __LP64__
+2 −1
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@


#include <media/EffectsConfig.h>
#include <media/EffectsConfig.h>
#include <media/TypeConverter.h>
#include <media/TypeConverter.h>
#include <system/audio_config.h>


using namespace tinyxml2;
using namespace tinyxml2;


@@ -338,7 +339,7 @@ ParsingResult parse(const char* path) {
        return parseWithPath(path);
        return parseWithPath(path);
    }
    }


    for (const std::string& location : DEFAULT_LOCATIONS) {
    for (const std::string& location : audio_get_configuration_paths()) {
        std::string defaultPath = location + '/' + DEFAULT_NAME;
        std::string defaultPath = location + '/' + DEFAULT_NAME;
        if (access(defaultPath.c_str(), R_OK) != 0) {
        if (access(defaultPath.c_str(), R_OK) != 0) {
            continue;
            continue;
+0 −3
Original line number Original line Diff line number Diff line
@@ -31,9 +31,6 @@ namespace engineConfig {
/** Default path of audio policy usages configuration file. */
/** Default path of audio policy usages configuration file. */
constexpr char DEFAULT_PATH[] = "/vendor/etc/audio_policy_engine_configuration.xml";
constexpr char DEFAULT_PATH[] = "/vendor/etc/audio_policy_engine_configuration.xml";


/** Directories where the effect libraries will be search for. */
constexpr const char* POLICY_USAGE_LIBRARY_PATH[] = {"/odm/etc/", "/vendor/etc/", "/system/etc/"};

using AttributesVector = std::vector<audio_attributes_t>;
using AttributesVector = std::vector<audio_attributes_t>;
using StreamVector = std::vector<audio_stream_type_t>;
using StreamVector = std::vector<audio_stream_type_t>;


+3 −5
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@
#include <cutils/properties.h>
#include <cutils/properties.h>
#include <media/TypeConverter.h>
#include <media/TypeConverter.h>
#include <media/convert.h>
#include <media/convert.h>
#include <system/audio_config.h>
#include <utils/Log.h>
#include <utils/Log.h>
#include <libxml/parser.h>
#include <libxml/parser.h>
#include <libxml/xinclude.h>
#include <libxml/xinclude.h>
@@ -693,9 +694,6 @@ android::status_t parseLegacyVolumeFile(const char* path, VolumeGroups &volumeGr
    return deserializeLegacyVolumeCollection(doc, cur, volumeGroups, nbSkippedElements);
    return deserializeLegacyVolumeCollection(doc, cur, volumeGroups, nbSkippedElements);
}
}


static const char *kConfigLocationList[] = {"/odm/etc", "/vendor/etc", "/system/etc"};
static const int kConfigLocationListSize =
        (sizeof(kConfigLocationList) / sizeof(kConfigLocationList[0]));
static const int gApmXmlConfigFilePathMaxLength = 128;
static const int gApmXmlConfigFilePathMaxLength = 128;


static constexpr const char *apmXmlConfigFileName = "audio_policy_configuration.xml";
static constexpr const char *apmXmlConfigFileName = "audio_policy_configuration.xml";
@@ -715,9 +713,9 @@ android::status_t parseLegacyVolumes(VolumeGroups &volumeGroups) {
    fileNames.push_back(apmXmlConfigFileName);
    fileNames.push_back(apmXmlConfigFileName);


    for (const char* fileName : fileNames) {
    for (const char* fileName : fileNames) {
        for (int i = 0; i < kConfigLocationListSize; i++) {
        for (const auto& path : audio_get_configuration_paths()) {
            snprintf(audioPolicyXmlConfigFile, sizeof(audioPolicyXmlConfigFile),
            snprintf(audioPolicyXmlConfigFile, sizeof(audioPolicyXmlConfigFile),
                     "%s/%s", kConfigLocationList[i], fileName);
                     "%s/%s", path.c_str(), fileName);
            ret = parseLegacyVolumeFile(audioPolicyXmlConfigFile, volumeGroups);
            ret = parseLegacyVolumeFile(audioPolicyXmlConfigFile, volumeGroups);
            if (ret == NO_ERROR) {
            if (ret == NO_ERROR) {
                return ret;
                return ret;
Loading