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

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

audio policy: move device_category type outside volume class



This patch prepares the removal of hard coded volume tables by
moving outside volume class the device_category enumeration.

Change-Id: Ic712377898276a39bb782ac0bc7f793cdd7fa8bd
Signed-off-by: default avatarFrançois Gaffie <francois.gaffie@intel.com>
parent 3f273d10
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -30,6 +30,17 @@ public:
    float mDBAttenuation;
};

/**
 * device categories used for volume curve management.
 */
enum device_category {
    DEVICE_CATEGORY_HEADSET,
    DEVICE_CATEGORY_SPEAKER,
    DEVICE_CATEGORY_EARPIECE,
    DEVICE_CATEGORY_EXT_MEDIA,
    DEVICE_CATEGORY_CNT
};

class Volume
{
public:
@@ -49,17 +60,6 @@ public:
        VOLCNT = 4
    };

    /**
     * device categories used for volume curve management.
     */
    enum device_category {
        DEVICE_CATEGORY_HEADSET,
        DEVICE_CATEGORY_SPEAKER,
        DEVICE_CATEGORY_EARPIECE,
        DEVICE_CATEGORY_EXT_MEDIA,
        DEVICE_CATEGORY_CNT
    };

    /**
     * extract one device relevant for volume control from multiple device selection
     *
+5 −5
Original line number Diff line number Diff line
@@ -41,14 +41,14 @@ public:

    void dump(int fd) const;

    void setVolumeCurvePoint(Volume::device_category deviceCategory, const VolumeCurvePoint *point);
    const VolumeCurvePoint *getVolumeCurvePoint(Volume::device_category deviceCategory) const
    void setVolumeCurvePoint(device_category deviceCategory, const VolumeCurvePoint *point);
    const VolumeCurvePoint *getVolumeCurvePoint(device_category deviceCategory) const
    {
        return mVolumeCurve[deviceCategory];
    }

private:
    const VolumeCurvePoint *mVolumeCurve[Volume::DEVICE_CATEGORY_CNT];
    const VolumeCurvePoint *mVolumeCurve[DEVICE_CATEGORY_CNT];
    KeyedVector<audio_devices_t, int> mIndexCur; /**< current volume index per device. */
    int mIndexMin; /**< min volume index. */
    int mIndexMax; /**< max volume index. */
@@ -71,11 +71,11 @@ public:
    status_t dump(int fd) const;

    void setVolumeCurvePoint(audio_stream_type_t stream,
                             Volume::device_category deviceCategory,
                             device_category deviceCategory,
                             const VolumeCurvePoint *point);

    const VolumeCurvePoint *getVolumeCurvePoint(audio_stream_type_t stream,
                                                Volume::device_category deviceCategory) const;
                                                device_category deviceCategory) const;

    void setVolumeIndexMin(audio_stream_type_t stream,int volIndexMin);
    void setVolumeIndexMax(audio_stream_type_t stream,int volIndexMax);
+3 −3
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ void StreamDescriptor::setVolumeIndexMax(int volIndexMax)
    mIndexMax = volIndexMax;
}

void StreamDescriptor::setVolumeCurvePoint(Volume::device_category deviceCategory,
void StreamDescriptor::setVolumeCurvePoint(device_category deviceCategory,
                                           const VolumeCurvePoint *point)
{
    mVolumeCurve[deviceCategory] = point;
@@ -121,14 +121,14 @@ void StreamDescriptorCollection::addCurrentVolumeIndex(audio_stream_type_t strea
}

void StreamDescriptorCollection::setVolumeCurvePoint(audio_stream_type_t stream,
                                                     Volume::device_category deviceCategory,
                                                     device_category deviceCategory,
                                                     const VolumeCurvePoint *point)
{
    editValueAt(stream).setVolumeCurvePoint(deviceCategory, point);
}

const VolumeCurvePoint *StreamDescriptorCollection::getVolumeCurvePoint(audio_stream_type_t stream,
                                                                        Volume::device_category deviceCategory) const
                                                                        device_category deviceCategory) const
{
    return valueAt(stream).getVolumeCurvePoint(deviceCategory);
}
+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ public:
     *
     * @return amplification value in dB matching the UI index for this given device and stream.
     */
    virtual float volIndexToDb(Volume::device_category deviceCategory, audio_stream_type_t stream,
    virtual float volIndexToDb(device_category deviceCategory, audio_stream_type_t stream,
                                 int indexInUi) = 0;

    /**
+1 −1
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ public:
     * @return true if the strategy were set correclty for this stream, false otherwise.
     */
    virtual bool setVolumeProfileForStream(const audio_stream_type_t &stream,
                                           Volume::device_category category,
                                           device_category category,
                                           const VolumeCurvePoints &points) = 0;

    /**
Loading