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

Commit 9ee3c5d3 authored by Android Build Prod User's avatar Android Build Prod User Committed by Android (Google) Code Review
Browse files

Merge changes from topic "fix-b-188932434-common-types-2"

* changes:
  Move common audio AIDL types to audio.media.audio.common
  Update MIME types in AidlConversion and MediaDefs
parents b57ca9b0 57bd06fe
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -168,6 +168,7 @@ cc_library {
        "libbinder",
        "framework-permission-aidl-cpp",
        "aaudio-aidl-cpp",
        "android.media.audio.common.types-V1-cpp",
        "audioclient-types-aidl-cpp",
        "libaudioclient_aidl_conversion",
    ],
@@ -246,6 +247,7 @@ aidl_interface {
        "binding/aidl/aaudio/IAAudioService.aidl",
    ],
    imports: [
        "android.media.audio.common.types",
        "audioclient-types-aidl",
        "shared-file-region-aidl",
        "framework-permission-aidl",
+3 −2
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@

using namespace aaudio;

using android::media::AudioFormatDescription;
using android::media::audio::common::AudioFormatDescription;

AAudioStreamConfiguration::AAudioStreamConfiguration(const StreamParameters& parcelable) {
    setChannelMask(parcelable.channelMask);
@@ -76,7 +76,8 @@ StreamParameters AAudioStreamConfiguration::parcelable() const {
        result.audioFormat = convAudioFormat.value();
    } else {
        result.audioFormat = AudioFormatDescription{};
        result.audioFormat.type = android::media::AudioFormatType::SYS_RESERVED_INVALID;
        result.audioFormat.type =
                android::media::audio::common::AudioFormatType::SYS_RESERVED_INVALID;
    }
    static_assert(sizeof(aaudio_direction_t) == sizeof(result.direction));
    result.direction = getDirection();
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package aaudio;

import android.media.AudioFormatDescription;
import android.media.audio.common.AudioFormatDescription;

parcelable StreamParameters {
    int                                       channelMask;  //          = AAUDIO_UNSPECIFIED;
+107 −130
Original line number Diff line number Diff line
@@ -34,6 +34,10 @@
namespace android {

using base::unexpected;
using media::audio::common::AudioChannelLayout;
using media::audio::common::AudioFormatDescription;
using media::audio::common::AudioFormatType;
using media::audio::common::PcmType;

namespace {

@@ -388,11 +392,11 @@ ConversionResult<media::AudioPortType> legacy2aidl_audio_port_type_t_AudioPortTy
namespace {

namespace detail {
using AudioChannelPair = std::pair<audio_channel_mask_t, media::AudioChannelLayout>;
using AudioChannelPair = std::pair<audio_channel_mask_t, AudioChannelLayout>;
using AudioChannelPairs = std::vector<AudioChannelPair>;
using AudioDevicePair = std::pair<audio_devices_t, media::AudioDeviceDescription>;
using AudioDevicePairs = std::vector<AudioDevicePair>;
using AudioFormatPair = std::pair<audio_format_t, media::AudioFormatDescription>;
using AudioFormatPair = std::pair<audio_format_t, AudioFormatDescription>;
using AudioFormatPairs = std::vector<AudioFormatPair>;
}

@@ -401,8 +405,8 @@ const detail::AudioChannelPairs& getInAudioChannelPairs() {
#define DEFINE_INPUT_LAYOUT(n)                                                 \
            {                                                                  \
                AUDIO_CHANNEL_IN_##n,                                          \
                media::AudioChannelLayout::make<media::AudioChannelLayout::Tag::layoutMask>( \
                        media::AudioChannelLayout::LAYOUT_##n)                               \
                AudioChannelLayout::make<AudioChannelLayout::Tag::layoutMask>( \
                        AudioChannelLayout::LAYOUT_##n)                        \
            }

        DEFINE_INPUT_LAYOUT(MONO),
@@ -424,8 +428,8 @@ const detail::AudioChannelPairs& getOutAudioChannelPairs() {
#define DEFINE_OUTPUT_LAYOUT(n)                                                \
            {                                                                  \
                AUDIO_CHANNEL_OUT_##n,                                         \
                media::AudioChannelLayout::make<media::AudioChannelLayout::Tag::layoutMask>( \
                        media::AudioChannelLayout::LAYOUT_##n)                               \
                AudioChannelLayout::make<AudioChannelLayout::Tag::layoutMask>( \
                        AudioChannelLayout::LAYOUT_##n)                        \
            }

        DEFINE_OUTPUT_LAYOUT(MONO),
@@ -467,8 +471,8 @@ const detail::AudioChannelPairs& getVoiceAudioChannelPairs() {
#define DEFINE_VOICE_LAYOUT(n)                                                 \
            {                                                                  \
                AUDIO_CHANNEL_IN_VOICE_##n,                                    \
                media::AudioChannelLayout::make<media::AudioChannelLayout::Tag::voiceMask>(  \
                        media::AudioChannelLayout::VOICE_##n)                                \
                AudioChannelLayout::make<AudioChannelLayout::Tag::voiceMask>(  \
                        AudioChannelLayout::VOICE_##n)                         \
            }
        DEFINE_VOICE_LAYOUT(UPLINK_MONO),
        DEFINE_VOICE_LAYOUT(DNLINK_MONO),
@@ -671,25 +675,25 @@ const detail::AudioDevicePairs& getAudioDevicePairs() {
    return pairs;
}

media::AudioFormatDescription make_AudioFormatDescription(media::AudioFormatType type) {
    media::AudioFormatDescription result;
AudioFormatDescription make_AudioFormatDescription(AudioFormatType type) {
    AudioFormatDescription result;
    result.type = type;
    return result;
}

media::AudioFormatDescription make_AudioFormatDescription(media::PcmType pcm) {
    auto result = make_AudioFormatDescription(media::AudioFormatType::PCM);
AudioFormatDescription make_AudioFormatDescription(PcmType pcm) {
    auto result = make_AudioFormatDescription(AudioFormatType::PCM);
    result.pcm = pcm;
    return result;
}

media::AudioFormatDescription make_AudioFormatDescription(const std::string& encoding) {
    media::AudioFormatDescription result;
AudioFormatDescription make_AudioFormatDescription(const std::string& encoding) {
    AudioFormatDescription result;
    result.encoding = encoding;
    return result;
}

media::AudioFormatDescription make_AudioFormatDescription(media::PcmType transport,
AudioFormatDescription make_AudioFormatDescription(PcmType transport,
        const std::string& encoding) {
    auto result = make_AudioFormatDescription(encoding);
    result.pcm = transport;
@@ -700,31 +704,30 @@ const detail::AudioFormatPairs& getAudioFormatPairs() {
    static const detail::AudioFormatPairs pairs = {{
        {
            AUDIO_FORMAT_INVALID,
            make_AudioFormatDescription(media::AudioFormatType::SYS_RESERVED_INVALID)
            make_AudioFormatDescription(AudioFormatType::SYS_RESERVED_INVALID)
        },
        {
            AUDIO_FORMAT_DEFAULT, media::AudioFormatDescription{}
            AUDIO_FORMAT_DEFAULT, AudioFormatDescription{}
        },
        {
            AUDIO_FORMAT_PCM_16_BIT, make_AudioFormatDescription(media::PcmType::INT_16_BIT)
            AUDIO_FORMAT_PCM_16_BIT, make_AudioFormatDescription(PcmType::INT_16_BIT)
        },
        {
            AUDIO_FORMAT_PCM_8_BIT, make_AudioFormatDescription(media::PcmType::UINT_8_BIT)
            AUDIO_FORMAT_PCM_8_BIT, make_AudioFormatDescription(PcmType::UINT_8_BIT)
        },
        {
            AUDIO_FORMAT_PCM_32_BIT, make_AudioFormatDescription(media::PcmType::INT_32_BIT)
            AUDIO_FORMAT_PCM_32_BIT, make_AudioFormatDescription(PcmType::INT_32_BIT)
        },
        {
            AUDIO_FORMAT_PCM_8_24_BIT, make_AudioFormatDescription(media::PcmType::FIXED_Q_8_24)
            AUDIO_FORMAT_PCM_8_24_BIT, make_AudioFormatDescription(PcmType::FIXED_Q_8_24)
        },
        {
            AUDIO_FORMAT_PCM_FLOAT, make_AudioFormatDescription(media::PcmType::FLOAT_32_BIT)
            AUDIO_FORMAT_PCM_FLOAT, make_AudioFormatDescription(PcmType::FLOAT_32_BIT)
        },
        {
            AUDIO_FORMAT_PCM_24_BIT_PACKED, make_AudioFormatDescription(media::PcmType::INT_24_BIT)
            AUDIO_FORMAT_PCM_24_BIT_PACKED, make_AudioFormatDescription(PcmType::INT_24_BIT)
        },
        {
            // See the comment in MediaDefs.h.
            AUDIO_FORMAT_MP3, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_MPEG)
        },
        {
@@ -734,52 +737,41 @@ const detail::AudioFormatPairs& getAudioFormatPairs() {
            AUDIO_FORMAT_AMR_WB, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AMR_WB)
        },
        {
            // Note: in MediaDefs.cpp MEDIA_MIMETYPE_AUDIO_AAC = "audio/mp4a-latm".
            AUDIO_FORMAT_AAC, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_FORMAT)
            AUDIO_FORMAT_AAC, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_MP4)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_MAIN, make_AudioFormatDescription("audio/aac.main")
            AUDIO_FORMAT_AAC_MAIN, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_MAIN)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_LC, make_AudioFormatDescription("audio/aac.lc")
            AUDIO_FORMAT_AAC_LC, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_LC)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_SSR, make_AudioFormatDescription("audio/aac.ssr")
            AUDIO_FORMAT_AAC_SSR, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_SSR)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_LTP, make_AudioFormatDescription("audio/aac.ltp")
            AUDIO_FORMAT_AAC_LTP, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_LTP)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_HE_V1, make_AudioFormatDescription("audio/aac.he.v1")
            AUDIO_FORMAT_AAC_HE_V1, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_HE_V1)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_SCALABLE, make_AudioFormatDescription("audio/aac.scalable")
            AUDIO_FORMAT_AAC_SCALABLE,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_SCALABLE)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_ERLC, make_AudioFormatDescription("audio/aac.erlc")
            AUDIO_FORMAT_AAC_ERLC, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ERLC)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_LD, make_AudioFormatDescription("audio/aac.ld")
            AUDIO_FORMAT_AAC_LD, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_LD)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_HE_V2, make_AudioFormatDescription("audio/aac.he.v2")
            AUDIO_FORMAT_AAC_HE_V2, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_HE_V2)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_ELD, make_AudioFormatDescription("audio/aac.eld")
            AUDIO_FORMAT_AAC_ELD, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ELD)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_XHE, make_AudioFormatDescription("audio/aac.xhe")
            AUDIO_FORMAT_AAC_XHE, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_XHE)
        },
        // AUDIO_FORMAT_HE_AAC_V1 and HE_AAC_V2 are removed since they were deprecated long time
        // ago.
@@ -796,7 +788,6 @@ const detail::AudioFormatPairs& getAudioFormatPairs() {
            AUDIO_FORMAT_E_AC3, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_EAC3)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_E_AC3_JOC, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_EAC3_JOC)
        },
        {
@@ -809,13 +800,12 @@ const detail::AudioFormatPairs& getAudioFormatPairs() {
        // nested AudioFormatDescriptions. The legacy 'AUDIO_FORMAT_IEC61937' type doesn't
        // specify the format of the encapsulated bitstream.
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_IEC61937,
            make_AudioFormatDescription(media::PcmType::INT_16_BIT, "audio/x-iec61937")
            make_AudioFormatDescription(PcmType::INT_16_BIT, MEDIA_MIMETYPE_AUDIO_IEC61937)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_DOLBY_TRUEHD, make_AudioFormatDescription("audio/vnd.dolby.truehd")
            AUDIO_FORMAT_DOLBY_TRUEHD,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_DOLBY_TRUEHD)
        },
        {
            AUDIO_FORMAT_EVRC, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_EVRC)
@@ -830,11 +820,9 @@ const detail::AudioFormatPairs& getAudioFormatPairs() {
            AUDIO_FORMAT_EVRCNW, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_EVRCNW)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_ADIF, make_AudioFormatDescription("audio/aac.adif")
            AUDIO_FORMAT_AAC_ADIF, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ADIF)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_WMA, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_WMA)
        },
        {
@@ -845,7 +833,6 @@ const detail::AudioFormatPairs& getAudioFormatPairs() {
            AUDIO_FORMAT_AMR_WB_PLUS, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AMR_WB_PLUS)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_MP2, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II)
        },
        {
@@ -859,7 +846,6 @@ const detail::AudioFormatPairs& getAudioFormatPairs() {
            AUDIO_FORMAT_FLAC, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_FLAC)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_ALAC, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_ALAC)
        },
        {
@@ -867,52 +853,49 @@ const detail::AudioFormatPairs& getAudioFormatPairs() {
            AUDIO_FORMAT_APE, make_AudioFormatDescription("audio/x-ape")
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_ADTS, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ADTS)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_ADTS_MAIN, make_AudioFormatDescription("audio/aac-adts.main")
            AUDIO_FORMAT_AAC_ADTS_MAIN,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ADTS_MAIN)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_ADTS_LC, make_AudioFormatDescription("audio/aac-adts.lc")
            AUDIO_FORMAT_AAC_ADTS_LC, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ADTS_LC)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_ADTS_SSR, make_AudioFormatDescription("audio/aac-adts.ssr")
            AUDIO_FORMAT_AAC_ADTS_SSR,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ADTS_SSR)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_ADTS_LTP, make_AudioFormatDescription("audio/aac-adts.ltp")
            AUDIO_FORMAT_AAC_ADTS_LTP,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ADTS_LTP)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_ADTS_HE_V1, make_AudioFormatDescription("audio/aac-adts.he.v1")
            AUDIO_FORMAT_AAC_ADTS_HE_V1,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ADTS_HE_V1)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_ADTS_SCALABLE, make_AudioFormatDescription("audio/aac-adts.scalable")
            AUDIO_FORMAT_AAC_ADTS_SCALABLE,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ADTS_SCALABLE)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_ADTS_ERLC, make_AudioFormatDescription("audio/aac-adts.erlc")
            AUDIO_FORMAT_AAC_ADTS_ERLC,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ADTS_ERLC)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_ADTS_LD, make_AudioFormatDescription("audio/aac-adts.ld")
            AUDIO_FORMAT_AAC_ADTS_LD, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ADTS_LD)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_ADTS_HE_V2, make_AudioFormatDescription("audio/aac-adts.he.v2")
            AUDIO_FORMAT_AAC_ADTS_HE_V2,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ADTS_HE_V2)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_ADTS_ELD, make_AudioFormatDescription("audio/aac-adts.eld")
            AUDIO_FORMAT_AAC_ADTS_ELD,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ADTS_ELD)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_ADTS_XHE, make_AudioFormatDescription("audio/aac-adts.xhe")
            AUDIO_FORMAT_AAC_ADTS_XHE,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ADTS_XHE)
        },
        {
            // Note: not in the IANA registry. "vnd.octel.sbc" is not BT SBC.
@@ -926,7 +909,6 @@ const detail::AudioFormatPairs& getAudioFormatPairs() {
            AUDIO_FORMAT_APTX_HD, make_AudioFormatDescription("audio/vnd.qcom.aptx.hd")
        },
        {
            // Note: not in the IANA registry. Matches MediaDefs.cpp.
            AUDIO_FORMAT_AC4, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AC4)
        },
        {
@@ -934,35 +916,36 @@ const detail::AudioFormatPairs& getAudioFormatPairs() {
            AUDIO_FORMAT_LDAC, make_AudioFormatDescription("audio/vnd.sony.ldac")
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_MAT, make_AudioFormatDescription("audio/vnd.dolby.mat")
            AUDIO_FORMAT_MAT, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_DOLBY_MAT)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_MAT_1_0, make_AudioFormatDescription("audio/vnd.dolby.mat.1.0")
            AUDIO_FORMAT_MAT_1_0,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_DOLBY_MAT + std::string(".1.0"))
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_MAT_2_0, make_AudioFormatDescription("audio/vnd.dolby.mat.2.0")
            AUDIO_FORMAT_MAT_2_0,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_DOLBY_MAT + std::string(".2.0"))
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_MAT_2_1, make_AudioFormatDescription("audio/vnd.dolby.mat.2.1")
            AUDIO_FORMAT_MAT_2_1,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_DOLBY_MAT + std::string(".2.1"))
        },
        {
            AUDIO_FORMAT_AAC_LATM, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_LATM_LC, make_AudioFormatDescription("audio/mp4a-latm.lc")
            AUDIO_FORMAT_AAC_LATM_LC, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_LATM_LC)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_LATM_HE_V1, make_AudioFormatDescription("audio/mp4a-latm.he.v1")
            AUDIO_FORMAT_AAC_LATM_HE_V1,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_LATM_HE_V1)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_AAC_LATM_HE_V2, make_AudioFormatDescription("audio/mp4a-latm.he.v2")
            AUDIO_FORMAT_AAC_LATM_HE_V2,
            make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_LATM_HE_V2)
        },
        {
            // Note: not in the IANA registry.
@@ -989,29 +972,23 @@ const detail::AudioFormatPairs& getAudioFormatPairs() {
            AUDIO_FORMAT_LC3, make_AudioFormatDescription("audio/x-lc3")
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_MPEGH, make_AudioFormatDescription("audio/x-mpegh")
            AUDIO_FORMAT_MPEGH, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_MPEGH_MHM1)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_MPEGH_BL_L3, make_AudioFormatDescription("audio/x-mpegh.bl.l3")
            AUDIO_FORMAT_MPEGH_BL_L3, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_MPEGH_BL_L3)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_MPEGH_BL_L4, make_AudioFormatDescription("audio/x-mpegh.bl.l4")
            AUDIO_FORMAT_MPEGH_BL_L4, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_MPEGH_BL_L4)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_MPEGH_LC_L3, make_AudioFormatDescription("audio/x-mpegh.lc.l3")
            AUDIO_FORMAT_MPEGH_LC_L3, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_MPEGH_LC_L3)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_MPEGH_LC_L4, make_AudioFormatDescription("audio/x-mpegh.lc.l4")
            AUDIO_FORMAT_MPEGH_LC_L4, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_MPEGH_LC_L4)
        },
        {
            // Note: not in the IANA registry.
            AUDIO_FORMAT_IEC60958,
            make_AudioFormatDescription(media::PcmType::INT_24_BIT, "audio/x-iec60958")
            make_AudioFormatDescription(PcmType::INT_24_BIT, MEDIA_MIMETYPE_AUDIO_IEC60958)
        },
        {
            AUDIO_FORMAT_DTS_UHD, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_DTS_UHD)
@@ -1055,14 +1032,14 @@ std::unordered_map<T, S> make_ReverseMap(const std::vector<std::pair<S, T>>& v)
}  // namespace

ConversionResult<audio_channel_mask_t> aidl2legacy_AudioChannelLayout_audio_channel_mask_t(
        const media::AudioChannelLayout& aidl, bool isInput) {
    using ReverseMap = std::unordered_map<media::AudioChannelLayout, audio_channel_mask_t>;
    using Tag = media::AudioChannelLayout::Tag;
        const AudioChannelLayout& aidl, bool isInput) {
    using ReverseMap = std::unordered_map<AudioChannelLayout, audio_channel_mask_t>;
    using Tag = AudioChannelLayout::Tag;
    static const ReverseMap mIn = make_ReverseMap(getInAudioChannelPairs());
    static const ReverseMap mOut = make_ReverseMap(getOutAudioChannelPairs());
    static const ReverseMap mVoice = make_ReverseMap(getVoiceAudioChannelPairs());

    auto convert = [](const media::AudioChannelLayout& aidl, const ReverseMap& m,
    auto convert = [](const AudioChannelLayout& aidl, const ReverseMap& m,
            const char* func, const char* type) -> ConversionResult<audio_channel_mask_t> {
        if (auto it = m.find(aidl); it != m.end()) {
            return it->second;
@@ -1100,16 +1077,16 @@ ConversionResult<audio_channel_mask_t> aidl2legacy_AudioChannelLayout_audio_chan
    return unexpected(BAD_VALUE);
}

ConversionResult<media::AudioChannelLayout> legacy2aidl_audio_channel_mask_t_AudioChannelLayout(
ConversionResult<AudioChannelLayout> legacy2aidl_audio_channel_mask_t_AudioChannelLayout(
        audio_channel_mask_t legacy, bool isInput) {
    using DirectMap = std::unordered_map<audio_channel_mask_t, media::AudioChannelLayout>;
    using Tag = media::AudioChannelLayout::Tag;
    using DirectMap = std::unordered_map<audio_channel_mask_t, AudioChannelLayout>;
    using Tag = AudioChannelLayout::Tag;
    static const DirectMap mInAndVoice = make_DirectMap(
            getInAudioChannelPairs(), getVoiceAudioChannelPairs());
    static const DirectMap mOut = make_DirectMap(getOutAudioChannelPairs());

    auto convert = [](const audio_channel_mask_t legacy, const DirectMap& m,
            const char* func, const char* type) -> ConversionResult<media::AudioChannelLayout> {
            const char* func, const char* type) -> ConversionResult<AudioChannelLayout> {
        if (auto it = m.find(legacy); it != m.end()) {
            return it->second;
        } else {
@@ -1120,9 +1097,9 @@ ConversionResult<media::AudioChannelLayout> legacy2aidl_audio_channel_mask_t_Aud
    };

    if (legacy == AUDIO_CHANNEL_NONE) {
        return media::AudioChannelLayout{};
        return AudioChannelLayout{};
    } else if (legacy == AUDIO_CHANNEL_INVALID) {
        return media::AudioChannelLayout::make<Tag::invalid>(0);
        return AudioChannelLayout::make<Tag::invalid>(0);
    }

    const audio_channel_representation_t repr = audio_channel_mask_get_representation(legacy);
@@ -1130,7 +1107,7 @@ ConversionResult<media::AudioChannelLayout> legacy2aidl_audio_channel_mask_t_Aud
        if (audio_channel_mask_is_valid(legacy)) {
            const int indexMask = VALUE_OR_RETURN(
                    convertIntegral<int>(audio_channel_mask_get_bits(legacy)));
            return media::AudioChannelLayout::make<Tag::indexMask>(indexMask);
            return AudioChannelLayout::make<Tag::indexMask>(indexMask);
        } else {
            ALOGE("%s: legacy audio_channel_mask_t value 0x%x is invalid", __func__, legacy);
            return unexpected(BAD_VALUE);
@@ -1171,8 +1148,8 @@ ConversionResult<media::AudioDeviceDescription> legacy2aidl_audio_devices_t_Audi
}

ConversionResult<audio_format_t> aidl2legacy_AudioFormatDescription_audio_format_t(
        const media::AudioFormatDescription& aidl) {
    static const std::unordered_map<media::AudioFormatDescription, audio_format_t> m =
        const AudioFormatDescription& aidl) {
    static const std::unordered_map<AudioFormatDescription, audio_format_t> m =
            make_ReverseMap(getAudioFormatPairs());
    if (auto it = m.find(aidl); it != m.end()) {
        return it->second;
@@ -1182,9 +1159,9 @@ ConversionResult<audio_format_t> aidl2legacy_AudioFormatDescription_audio_format
    }
}

ConversionResult<media::AudioFormatDescription> legacy2aidl_audio_format_t_AudioFormatDescription(
ConversionResult<AudioFormatDescription> legacy2aidl_audio_format_t_AudioFormatDescription(
        audio_format_t legacy) {
    static const std::unordered_map<audio_format_t, media::AudioFormatDescription> m =
    static const std::unordered_map<audio_format_t, AudioFormatDescription> m =
            make_DirectMap(getAudioFormatPairs());
    if (auto it = m.find(legacy); it != m.end()) {
        return it->second;
@@ -2711,7 +2688,7 @@ aidl2legacy_AudioProfile_audio_profile(const media::AudioProfile& aidl, bool isI
    }
    RETURN_IF_ERROR(
            convertRange(aidl.channelMasks.begin(), aidl.channelMasks.end(), legacy.channel_masks,
                    [isInput](const media::AudioChannelLayout& l) {
                    [isInput](const AudioChannelLayout& l) {
                        return aidl2legacy_AudioChannelLayout_audio_channel_mask_t(l, isInput);
                    }));
    legacy.num_channel_masks = aidl.channelMasks.size();
Loading