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

Commit c658e452 authored by jiabin's avatar jiabin
Browse files

Support bit-perfect PCM playback.

This is part of USB audio improvement. Bit-perfect PCM playback
indicates that the PCM data will be sent as is down to the audio HAL.
When the track is bit-perfect, there will not be volume control
applied in the audio mixer. Only effects without processing or hw
accelerated effects will be allowed to attach to bit-perfect tracks.

Bug: 239435816
Test: manually
Test: atest audiopolicy_tests
Change-Id: I0bad4d7d78d4eaf741754d01bc5422ba15374782
parent ec61814a
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1021,7 +1021,8 @@ status_t AudioSystem::getOutputForAttr(audio_attributes_t* attr,
                                       audio_port_handle_t* selectedDeviceId,
                                       audio_port_handle_t* portId,
                                       std::vector<audio_io_handle_t>* secondaryOutputs,
                                       bool *isSpatialized) {
                                       bool *isSpatialized,
                                       bool *isBitPerfect) {
    if (attr == nullptr) {
        ALOGE("%s NULL audio attributes", __func__);
        return BAD_VALUE;
@@ -1084,6 +1085,7 @@ status_t AudioSystem::getOutputForAttr(audio_attributes_t* attr,
    *secondaryOutputs = VALUE_OR_RETURN_STATUS(convertContainer<std::vector<audio_io_handle_t>>(
            responseAidl.secondaryOutputs, aidl2legacy_int32_t_audio_io_handle_t));
    *isSpatialized = responseAidl.isSpatialized;
    *isBitPerfect = responseAidl.isBitPerfect;

    return OK;
}
+4 −0
Original line number Diff line number Diff line
@@ -477,6 +477,8 @@ aidl2legacy_AudioMixerBehavior_audio_mixer_behavior_t(media::AudioMixerBehavior
    switch (aidl) {
        case media::AudioMixerBehavior::DEFAULT:
            return AUDIO_MIXER_BEHAVIOR_DEFAULT;
        case media::AudioMixerBehavior::BIT_PERFECT:
            return AUDIO_MIXER_BEHAVIOR_BIT_PERFECT;
        case media::AudioMixerBehavior::INVALID:
            return AUDIO_MIXER_BEHAVIOR_INVALID;
    }
@@ -487,6 +489,8 @@ legacy2aidl_audio_mixer_behavior_t_AudioMixerBehavior(audio_mixer_behavior_t leg
    switch (legacy) {
        case AUDIO_MIXER_BEHAVIOR_DEFAULT:
            return media::AudioMixerBehavior::DEFAULT;
        case AUDIO_MIXER_BEHAVIOR_BIT_PERFECT:
            return media::AudioMixerBehavior::BIT_PERFECT;
        case AUDIO_MIXER_BEHAVIOR_INVALID:
            return media::AudioMixerBehavior::INVALID;
    }
+4 −0
Original line number Diff line number Diff line
@@ -30,4 +30,8 @@ enum AudioMixerBehavior {
     * different sources.
     */
    DEFAULT = 0,
    /**
     * The audio data in the mixer will be bit-perfect as long as possible.
     */
    BIT_PERFECT = 1,
}
+1 −0
Original line number Diff line number Diff line
@@ -36,4 +36,5 @@ parcelable GetOutputForAttrResponse {
    boolean isSpatialized;
    /** The suggested audio config if fails to get an output. **/
    AudioConfigBase configBase;
    boolean isBitPerfect;
}
+3 −1
Original line number Diff line number Diff line
@@ -300,6 +300,7 @@ public:
     * @param[out] portId the generated port id to identify the client
     * @param[out] secondaryOutputs collection of io handle for secondary outputs
     * @param[out] isSpatialized true if the playback will be spatialized
     * @param[out] isBitPerfect true if the playback will be bit-perfect
     * @return if the call is successful or not
     */
    static status_t getOutputForAttr(audio_attributes_t *attr,
@@ -312,7 +313,8 @@ public:
                                     audio_port_handle_t *selectedDeviceId,
                                     audio_port_handle_t *portId,
                                     std::vector<audio_io_handle_t> *secondaryOutputs,
                                     bool *isSpatialized);
                                     bool *isSpatialized,
                                     bool *isBitPerfect);
    static status_t startOutput(audio_port_handle_t portId);
    static status_t stopOutput(audio_port_handle_t portId);
    static void releaseOutput(audio_port_handle_t portId);
Loading