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

Commit 79c57408 authored by Kevin Rocard's avatar Kevin Rocard
Browse files

Audio V4: bitfield enum now use the bitfield class



The audio HAL has lots of enums were each value is a specific bit
pattern (usually a single bit) and are expected to be used as a
combination of value (kind of like a bitfield).

Nevertheless the 2.0 methods only had the enums themselves in their
signatures which leads the HIDL API checkers to warn that invalid values
were passed.

Currently, there are no way to express a value which is a combination
of enum values. The closest thing is the bitfield type.

Thus transition all enums combination to bitfield.

Note that AudioDevice as NOT been transition systematically
as both the enums and the combination are meaningful:
 - the enum is one device
 - the combination is a list of device.

Test: none
Bug: 38184704
Change-Id: I155cf7bc5d88fc5cf8954903d55aa8d7ca458a4b
Signed-off-by: default avatarKevin Rocard <krocard@google.com>
parent fd64afb0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ interface IDevice {
            AudioIoHandle ioHandle,
            DeviceAddress device,
            AudioConfig config,
            AudioOutputFlag flags) generates (
            bitfield<AudioOutputFlag> flags) generates (
                    Result retval,
                    IStreamOut outStream,
                    AudioConfig suggestedConfig);
@@ -140,7 +140,7 @@ interface IDevice {
            AudioIoHandle ioHandle,
            DeviceAddress device,
            AudioConfig config,
            AudioInputFlag flags,
            bitfield<AudioInputFlag> flags,
            AudioSource source) generates (
                    Result retval,
                    IStreamIn inStream,
+5 −5
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ interface IStream {
     *
     * @return mask channel mask.
     */
    getChannelMask() generates (AudioChannelMask mask);
    getChannelMask() generates (bitfield<AudioChannelMask> mask);

    /**
     * Return supported channel masks of the stream. Calling this method is
@@ -101,7 +101,7 @@ interface IStream {
     * @return masks supported audio masks.
     */
    getSupportedChannelMasks(AudioFormat format)
            generates (Result retval, vec<AudioChannelMask> masks);
            generates (Result retval, vec<bitfield<AudioChannelMask>> masks);

    /**
     * Sets the channel mask of the stream. Calling this method is equivalent to
@@ -111,7 +111,7 @@ interface IStream {
     * @param format audio format.
     * @return retval operation completion status.
     */
    setChannelMask(AudioChannelMask mask) generates (Result retval);
    setChannelMask(bitfield<AudioChannelMask> mask) generates (Result retval);

    /**
     * Return the audio format of the stream.
@@ -148,7 +148,7 @@ interface IStream {
     * @return format audio format.
     */
    getAudioProperties() generates (
            uint32_t sampleRateHz, AudioChannelMask mask, AudioFormat format);
            uint32_t sampleRateHz, bitfield<AudioChannelMask> mask, AudioFormat format);

    /**
     * Applies audio effect to the stream.
@@ -183,7 +183,7 @@ interface IStream {
     * @return retval operation completion status: OK or NOT_SUPPORTED.
     * @return device set of device(s) which this stream is connected to.
     */
    getDevice() generates (Result retval, AudioDevice device);
    getDevice() generates (Result retval, bitfield<AudioDevice> device);

    /**
     * Connects the stream to the device.
+7 −7
Original line number Diff line number Diff line
@@ -678,7 +678,7 @@ enum AudioUsage : int32_t {
 */
struct AudioOffloadInfo {
    uint32_t sampleRateHz;
    AudioChannelMask channelMask;
    bitfield<AudioChannelMask> channelMask;
    AudioFormat format;
    AudioStreamType streamType;
    uint32_t bitRatePerSecond;
@@ -695,7 +695,7 @@ struct AudioOffloadInfo {
 */
struct AudioConfig {
    uint32_t sampleRateHz;
    AudioChannelMask channelMask;
    bitfield<AudioChannelMask> channelMask;
    AudioFormat format;
    AudioOffloadInfo offloadInfo;
    uint64_t frameCount;
@@ -723,8 +723,8 @@ enum AudioGainMode : uint32_t {
 * A gain stage is always attached to an audio port.
 */
struct AudioGain {
    AudioGainMode mode;
    AudioChannelMask channelMask; // channels which gain an be controlled
    bitfield<AudioGainMode> mode;
    bitfield<AudioChannelMask> channelMask; // channels which gain an be controlled
    int32_t minValue;     // minimum gain value in millibels
    int32_t maxValue;     // maximum gain value in millibels
    int32_t defaultValue; // default gain value in millibels
@@ -822,9 +822,9 @@ enum AudioPortConfigMask : uint32_t {
 */
struct AudioPortConfig {
    AudioPortHandle id;
    AudioPortConfigMask configMask;
    bitfield<AudioPortConfigMask> configMask;
    uint32_t sampleRateHz;
    AudioChannelMask channelMask;
    bitfield<AudioChannelMask> channelMask;
    AudioFormat format;
    AudioGainConfig gain;
    AudioPortType type;  // type is used as a discriminator for Ext union
@@ -879,7 +879,7 @@ struct AudioPort {
    AudioPortRole role;
    string name;
    vec<uint32_t> sampleRates;
    vec<AudioChannelMask> channelMasks;
    vec<bitfield<AudioChannelMask>> channelMasks;
    vec<AudioFormat> formats;
    vec<AudioGain> gains;
    AudioPortConfig activeConfig; // current audio port configuration
+2 −2
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ interface IEffect {
     * @return retval operation completion status.
     */
    @callflow(next={"*"})
    setDevice(AudioDevice device) generates (Result retval);
    setDevice(bitfield<AudioDevice> device) generates (Result retval);

    /**
     * Set and get volume. Used by audio framework to delegate volume control to
@@ -155,7 +155,7 @@ interface IEffect {
     * @return retval operation completion status.
     */
    @callflow(next={"*"})
    setInputDevice(AudioDevice device) generates (Result retval);
    setInputDevice(bitfield<AudioDevice> device) generates (Result retval);

    /**
     * Read audio parameters configurations for input and output buffers.
+3 −2
Original line number Diff line number Diff line
@@ -47,7 +47,8 @@ interface IVirtualizerEffect extends IEffect {
    getStrength() generates (Result retval, uint16_t strength);

    struct SpeakerAngle {
        AudioChannelMask mask; // speaker channel mask (1 bit set).
        /** Speaker channel mask */
        bitfield<AudioChannelMask> mask;
        // all angles are expressed in degrees and
        // are relative to the listener.
        int16_t azimuth; // 0 is the direction the listener faces
@@ -60,7 +61,7 @@ interface IVirtualizerEffect extends IEffect {
     * Retrieves virtual speaker angles for the given channel mask on the
     * specified device.
     */
    getVirtualSpeakerAngles(AudioChannelMask mask, AudioDevice device)
    getVirtualSpeakerAngles(bitfield<AudioChannelMask> mask, AudioDevice device)
            generates (Result retval, vec<SpeakerAngle> speakerAngles);

    /**
Loading