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

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

audiopolicy: engine: Add Volume Groups to common Engine



This CL adds the concept of Volume Group to the engine.
It generalizes the volume management today controled by stream types
and hard coded into AOSP.
The goal is to control the volume per attributes, being able to define
a group of attributes that follow the same volume curves.

It intends to replace the concept of aliases in AudioService.

Bug: 124767636
Test: build

Change-Id: Icd079374cc1680d074b01836eca0bceb0b0c5247
Signed-off-by: default avatarFrançois Gaffie <francois.gaffie@renault.com>
parent a666d61e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ status_t AudioAttributes::readFromParcel(const Parcel *parcel)
        strcpy(mAttributes.tags, "");
    }
    mStreamType = static_cast<audio_stream_type_t>(parcel->readInt32());
    mGroupId = parcel->readUint32();
    mGroupId = static_cast<volume_group_t>(parcel->readUint32());
    return NO_ERROR;
}

@@ -60,7 +60,7 @@ status_t AudioAttributes::writeToParcel(Parcel *parcel) const
        parcel->writeUtf8AsUtf16(mAttributes.tags);
    }
    parcel->writeInt32(static_cast<int32_t>(mStreamType));
    parcel->writeUint32(mGroupId);
    parcel->writeUint32(static_cast<uint32_t>(mGroupId));
    return NO_ERROR;
}

+4 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

#pragma once

#include <media/AudioCommonTypes.h>
#include <system/audio.h>
#include <system/audio_policy.h>
#include <binder/Parcelable.h>
@@ -28,7 +29,7 @@ class AudioAttributes : public Parcelable
public:
    AudioAttributes() = default;
    AudioAttributes(const audio_attributes_t &attributes) : mAttributes(attributes) {}
    AudioAttributes(uint32_t groupId,
    AudioAttributes(volume_group_t groupId,
                    audio_stream_type_t stream,
                    const audio_attributes_t &attributes) :
         mAttributes(attributes), mStreamType(stream), mGroupId(groupId) {}
@@ -39,7 +40,7 @@ public:
    status_t writeToParcel(Parcel *parcel) const override;

    audio_stream_type_t getStreamType() const { return mStreamType; }
    uint32_t getGroupId() const { return mGroupId; }
    volume_group_t getGroupId() const { return mGroupId; }

private:
    audio_attributes_t mAttributes = AUDIO_ATTRIBUTES_INITIALIZER;
@@ -53,7 +54,7 @@ private:
     * @brief mGroupId: for future volume management, define groups within a strategy that follows
     * the same curves of volume (extension of stream types to manage volume)
     */
    uint32_t mGroupId = 0;
    volume_group_t mGroupId = VOLUME_GROUP_NONE;
};

} // namespace android
+5 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ enum product_strategy_t : uint32_t;
const product_strategy_t PRODUCT_STRATEGY_NONE = static_cast<product_strategy_t>(-1);

using AttributesVector = std::vector<audio_attributes_t>;
using StreamTypes = std::vector<audio_stream_type_t>;
using StreamTypeVector = std::vector<audio_stream_type_t>;

constexpr bool operator==(const audio_attributes_t &lhs, const audio_attributes_t &rhs)
{
@@ -38,5 +38,9 @@ constexpr bool operator!=(const audio_attributes_t &lhs, const audio_attributes_
{
    return !(lhs==rhs);
}

enum volume_group_t : uint32_t;
static const volume_group_t VOLUME_GROUP_NONE = static_cast<volume_group_t>(-1);

} // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <math.h>

namespace android {

/**
 * VolumeSource is the discriminent for volume management on an output.
 * It used to be the stream type by legacy, it may be host volume group or a volume curves if
+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ public:
    virtual float volIndexToDb(device_category device, int indexInUi) const = 0;
    virtual bool hasVolumeIndexForDevice(audio_devices_t device) const = 0;
    virtual status_t initVolume(int indexMin, int indexMax) = 0;
    virtual std::vector<audio_attributes_t> getAttributes() const = 0;
    virtual std::vector<audio_stream_type_t> getStreamTypes() const = 0;
    virtual void dump(String8 *dst, int spaces = 0, bool curvePoints = false) const = 0;
};

Loading