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

Commit 14dbb1ed authored by Kevin Rocard's avatar Kevin Rocard
Browse files

Audio V4: Forward tracks attributes to the hal



Forward to the HAL the audio usage, audio content types and volume
of playback tracks to the stream out they are playing to.

Forward to the HAL the audio source and volume of record tracks
to the stream in they are playing to.

This will allow the HAL to better tune its effects and remove the need
to inject a fake effect (volume listener) to get the tracks volume.

Bug: 38184704
Test: none
Change-Id: Iede0f7aa518608c3b3ce1497f059f672aac109b2
Signed-off-by: default avatarKevin Rocard <krocard@google.com>
parent 0fd5bc2d
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -109,6 +109,8 @@ interface IDevice {
     * @param device device type and (if needed) address.
     * @param config stream configuration.
     * @param flags additional flags.
     * @param sourceMetadata Description of the audio that will be played.
                             May be used by implementations to configure hardware effects.
     * @return retval operation completion status.
     * @return outStream created output stream.
     * @return suggestedConfig in case of invalid parameters, suggested config.
@@ -117,7 +119,8 @@ interface IDevice {
            AudioIoHandle ioHandle,
            DeviceAddress device,
            AudioConfig config,
            bitfield<AudioOutputFlag> flags) generates (
            bitfield<AudioOutputFlag> flags,
            SourceMetadata sourceMetadata) generates (
                    Result retval,
                    IStreamOut outStream,
                    AudioConfig suggestedConfig);
@@ -132,6 +135,8 @@ interface IDevice {
     * @param config stream configuration.
     * @param flags additional flags.
     * @param source source specification.
     * @param sinkMetadata Description of the audio that is suggested by the client.
     *                     May be used by implementations to configure hardware effects.
     * @return retval operation completion status.
     * @return inStream in case of success, created input stream.
     * @return suggestedConfig in case of invalid parameters, suggested config.
@@ -141,7 +146,7 @@ interface IDevice {
            DeviceAddress device,
            AudioConfig config,
            bitfield<AudioInputFlag> flags,
            AudioSource source) generates (
            SinkMetadata sinkMetadata) generates (
                    Result retval,
                    IStreamIn inStream,
                    AudioConfig suggestedConfig);
+6 −0
Original line number Diff line number Diff line
@@ -83,6 +83,12 @@ interface IStreamIn extends IStream {
        } reply;
    };

    /**
     * Called when the metadata of the stream's sink has been changed.
     * @param sinkMetadata Description of the audio that is suggested by the clients.
     */
    updateSinkMetadata(SinkMetadata sinkMetadata);

    /**
     * Set up required transports for receiving audio buffers from the driver.
     *
+6 −0
Original line number Diff line number Diff line
@@ -77,6 +77,12 @@ interface IStreamOut extends IStream {
        } reply;
    };

    /**
     * Called when the metadata of the stream's source has been changed.
     * @param sourceMetadata Description of the audio that is played by the clients.
     */
    updateSourceMetadata(SourceMetadata sourceMetadata);

    /**
     * Set up required transports for passing audio buffers to the driver.
     *
+33 −0
Original line number Diff line number Diff line
@@ -117,3 +117,36 @@ enum MessageQueueFlagBits : uint32_t {
    NOT_EMPTY = 1 << 0,
    NOT_FULL = 1 << 1
};

/** Metadata of a playback track for a StreamOut. */
struct PlaybackTrackMetadata {
    AudioUsage usage;
    AudioContentType contentType;
    /**
     * Positive linear gain applied to the track samples. 0 being muted and 1 is no attenuation,
     * 2 means double amplification...
     * Must not be negative.
     */
    float gain;
};

/** Metadatas of the source of a StreamOut. */
struct SourceMetadata {
    vec<PlaybackTrackMetadata> tracks;
};

/** Metadata of a record track for a StreamIn. */
struct RecordTrackMetadata {
    AudioSource source;
    /**
     * Positive linear gain applied to the track samples. 0 being muted and 1 is no attenuation,
     * 2 means double amplification...
     * Must not be negative.
     */
    float gain;
};

/** Metadatas of the source of a StreamIn. */
struct SinkMetadata {
    vec<RecordTrackMetadata> tracks;
};
+10 −0
Original line number Diff line number Diff line
@@ -671,6 +671,16 @@ enum AudioUsage : int32_t {
    ASSISTANT                          = 16,
};

/** Type of audio generated by an application. */
@export(name="audio_content_type_t", value_prefix="AUDIO_CONTENT_TYPE_")
enum AudioContentType : uint32_t {
    UNKNOWN      = 0,
    SPEECH       = 1,
    MUSIC        = 2,
    MOVIE        = 3,
    SONIFICATION = 4,
};

/**
 * Additional information about the stream passed to hardware decoders.
 */