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

Commit d1ab2bd4 authored by François Gaffie's avatar François Gaffie Committed by Eric Laurent
Browse files

audio policy: move volume table to XML file



This patch allows to store in XML file volume tables.
The compatibility is maintained for legacy conf file.
Configurable Engine is only compatible with new XML conf.
This patch removes from configurable engine Structure / Settings the volume
table but keep the configurabllity of switching volume profiles from
one another according to criteria like phone state...
(ex: DTMF stream type is following Voice Profile in call)

Change-Id: I78c91bc3378b6c47202abe7b5c1c1e011ff62eed
Signed-off-by: default avatarFrançois Gaffie <francois.gaffie@intel.com>
parent 987f9532
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ LOCAL_C_INCLUDES := \
    $(call include-path-for, audio-utils) \
    $(TOPDIR)frameworks/av/services/audiopolicy/common/include \
    $(TOPDIR)frameworks/av/services/audiopolicy/engine/interface \
    $(TOPDIR)frameworks/av/services/audiopolicy/utilities \
    $(TOPDIR)frameworks/av/services/audiopolicy/utilities

LOCAL_SHARED_LIBRARIES := \
    libcutils \
@@ -56,8 +56,7 @@ ifneq ($(USE_LEGACY_AUDIO_POLICY), 1)

include $(CLEAR_VARS)

LOCAL_SRC_FILES:= \
    managerdefault/AudioPolicyManager.cpp \
LOCAL_SRC_FILES:= managerdefault/AudioPolicyManager.cpp

LOCAL_SHARED_LIBRARIES := \
    libcutils \
@@ -75,8 +74,7 @@ LOCAL_REQUIRED_MODULES := \
    parameter-framework.policy \
    audio_policy_criteria.conf \

LOCAL_C_INCLUDES += \
    $(TOPDIR)frameworks/av/services/audiopolicy/engineconfigurable/include
LOCAL_C_INCLUDES += $(TOPDIR)frameworks/av/services/audiopolicy/engineconfigurable/include

LOCAL_SHARED_LIBRARIES += libaudiopolicyengineconfigurable

@@ -84,7 +82,7 @@ else

LOCAL_SHARED_LIBRARIES += libaudiopolicyenginedefault

endif
endif # ifeq ($(USE_CONFIGURABLE_AUDIO_POLICY), 1)

LOCAL_C_INCLUDES += \
    $(TOPDIR)frameworks/av/services/audiopolicy/common/include \
@@ -122,7 +120,7 @@ LOCAL_STATIC_LIBRARIES := \

LOCAL_C_INCLUDES += \
    $(TOPDIR)frameworks/av/services/audiopolicy/common/include \
    $(TOPDIR)frameworks/av/services/audiopolicy/engine/interface \
    $(TOPDIR)frameworks/av/services/audiopolicy/engine/interface

LOCAL_MODULE:= libaudiopolicymanager

+9 −3
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
    src/DeviceDescriptor.cpp \
    src/AudioGain.cpp \
    src/StreamDescriptor.cpp \
    src/HwModule.cpp \
    src/IOProfile.cpp \
    src/AudioPort.cpp \
@@ -20,6 +19,7 @@ LOCAL_SRC_FILES:= \
    src/SoundTriggerSession.cpp \
    src/SessionRoute.cpp \
    src/AudioSourceDescriptor.cpp \
    src/VolumeCurve.cpp \
    src/TypeConverter.cpp \
    src/AudioSession.cpp

@@ -35,9 +35,10 @@ LOCAL_C_INCLUDES := \
    $(TOPDIR)frameworks/av/services/audiopolicy/utilities \

ifeq ($(USE_XML_AUDIO_POLICY_CONF), 1)

LOCAL_SRC_FILES += src/Serializer.cpp

LOCAL_STATIC_LIBRARIES := libxml2
LOCAL_STATIC_LIBRARIES += libxml2

LOCAL_SHARED_LIBRARIES += libicuuc

@@ -46,7 +47,12 @@ LOCAL_C_INCLUDES += \
    $(TOPDIR)external/icu/icu4c/source/common

else
LOCAL_SRC_FILES += src/ConfigParsingUtils.cpp

LOCAL_SRC_FILES += \
    src/ConfigParsingUtils.cpp \
    src/StreamDescriptor.cpp \
    src/Gains.cpp

endif #ifeq ($(USE_XML_AUDIO_POLICY_CONF), 1)

LOCAL_EXPORT_C_INCLUDE_DIRS := \
+12 −2
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@
#include <AudioPolicyMix.h>
#include <EffectDescriptor.h>
#include <SoundTriggerSession.h>
#include <StreamDescriptor.h>
#include <SessionRoute.h>

namespace android {
@@ -40,14 +39,24 @@ public:
                      DeviceVector &availableOutputDevices,
                      DeviceVector &availableInputDevices,
                      sp<DeviceDescriptor> &defaultOutputDevices,
                      bool &isSpeakerDrcEnabled)
                      bool &isSpeakerDrcEnabled,
                      VolumeCurvesCollection *volumes = nullptr)
        : mHwModules(hwModules),
          mAvailableOutputDevices(availableOutputDevices),
          mAvailableInputDevices(availableInputDevices),
          mDefaultOutputDevices(defaultOutputDevices),
          mVolumeCurves(volumes),
          mIsSpeakerDrcEnabled(isSpeakerDrcEnabled)
    {}

    void setVolumes(const VolumeCurvesCollection &volumes)
    {
        if (mVolumeCurves != nullptr) {
            *mVolumeCurves = volumes;
            mVolumeCurves->setDefaultCurves();
        }
    }

    void setHwModules(const HwModuleCollection &hwModules)
    {
        mHwModules = hwModules;
@@ -131,6 +140,7 @@ private:
    DeviceVector &mAvailableOutputDevices;
    DeviceVector &mAvailableInputDevices;
    sp<DeviceDescriptor> &mDefaultOutputDevices;
    VolumeCurvesCollection *mVolumeCurves;
    bool &mIsSpeakerDrcEnabled;
};

+1 −6
Original line number Diff line number Diff line
@@ -29,12 +29,7 @@ class StreamDescriptor;
class Gains
{
public :
    static float volIndexToAmpl(device_category deviceCategory,
                                const StreamDescriptor& streamDesc,
                                int indexInUi);

    static float volIndexToDb(device_category deviceCategory,
                              const StreamDescriptor& streamDesc,
    static float volIndexToDb(const VolumeCurvePoint *point, int indexMin, int indexMax,
                              int indexInUi);

    // default volume curve
+52 −0
Original line number Diff line number Diff line
@@ -16,49 +16,37 @@

#pragma once

#include "FormattedSubsystemObject.h"
#include "InstanceConfigurableElement.h"
#include "MappingContext.h"
#include <system/audio.h>
#include <Volume.h>
#include <AudioPolicyPluginInterface.h>
#include <string>
#include <utils/Errors.h>

class PolicySubsystem;
namespace android {

class VolumeProfile : public CFormattedSubsystemObject
class IVolumeCurvesCollection
{
private:
    struct Point
public:
    virtual void clearCurrentVolumeIndex(audio_stream_type_t stream) = 0;
    virtual void addCurrentVolumeIndex(audio_stream_type_t stream, audio_devices_t device,
                                       int index) = 0;
    virtual bool canBeMuted(audio_stream_type_t stream) = 0;
    virtual int getVolumeIndexMin(audio_stream_type_t stream) const = 0;
    virtual int getVolumeIndex(audio_stream_type_t stream, audio_devices_t device) = 0;
    virtual int getVolumeIndexMax(audio_stream_type_t stream) const = 0;
    virtual float volIndexToDb(audio_stream_type_t stream, device_category device,
                               int indexInUi) const = 0;
    virtual status_t initStreamVolume(audio_stream_type_t stream, int indexMin, int indexMax) = 0;

    virtual void initializeVolumeCurves(bool /*isSpeakerDrcEnabled*/) {}
    virtual void switchVolumeCurve(audio_stream_type_t src, audio_stream_type_t dst) = 0;
    virtual void restoreOriginVolumeCurve(audio_stream_type_t stream)
    {
        int index;
        /** Volume is using FixedPointParameter until float parameters are available. */
        int16_t dbAttenuation;
    } __attribute__((packed));
        switchVolumeCurve(stream, stream);
    }

public:
    VolumeProfile(const std::string &mappingValue,
                  CInstanceConfigurableElement *instanceConfigurableElement,
                  const CMappingContext &context);
    virtual status_t dump(int fd) const = 0;

protected:
    virtual bool receiveFromHW(std::string &error);
    virtual bool sendToHW(std::string &error);

private:
    const PolicySubsystem *mPolicySubsystem; /**< Route subsytem plugin. */

    /**
     * Interface to communicate with Audio Policy Engine.
     */
    android::AudioPolicyPluginInterface *mPolicyPluginInterface;

    /**
     * volume profile identifier,  which is in fact a stream type to link with audio.h.
     */
    audio_stream_type_t mId;

    size_t mPoints;
    device_category mCategory;

    static const uint32_t gFractional = 8; /**< Beware to align with the structure. */
    virtual ~IVolumeCurvesCollection() {}
};

}; // namespace android
Loading