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

Commit 660e9a4c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I118b2c04,I111b72aa,Ia5d29126

* changes:
  audio: Add support for compressed offload
  audio: Improve debug logging in the AIDL version, fix bugs
  audio: Disable the C++ backend for android.hardware.audio.core
parents 2412da08 111e0cea
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -83,6 +83,10 @@ aidl_interface {
    ],
    stability: "vintf",
    backend: {
        // The C++ backend is disabled transitively due to use of FMQ.
        cpp: {
            enabled: false,
        },
        java: {
            platform_apis: true,
        },
+2 −0
Original line number Diff line number Diff line
@@ -282,6 +282,8 @@ interface IModule {
     * @throws EX_ILLEGAL_ARGUMENT In the following cases:
     *                             - If the port config can not be found by the ID.
     *                             - If the port config is not of an output mix port.
     *                             - If the offload info is not provided for an offload
     *                               port configuration.
     * @throws EX_ILLEGAL_STATE In the following cases:
     *                          - If the port config already has a stream opened on it.
     *                          - If the limit on the open stream count for the port has
+2 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ cc_library_static {
    shared_libs: [
        "libbase",
        "libbinder_ndk",
        "libstagefright_foundation",
        "android.media.audio.common.types-V1-ndk",
        "android.hardware.audio.core-V1-ndk",
    ],
@@ -37,6 +38,7 @@ cc_binary {
    shared_libs: [
        "libbase",
        "libbinder_ndk",
        "libstagefright_foundation",
        "android.media.audio.common.types-V1-ndk",
        "android.hardware.audio.core-V1-ndk",
    ],
+40 −9
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <aidl/android/media/audio/common/AudioFormatType.h>
#include <aidl/android/media/audio/common/AudioIoFlags.h>
#include <aidl/android/media/audio/common/AudioOutputFlags.h>
#include <media/stagefright/foundation/MediaDefs.h>

#include "core-impl/Configuration.h"

@@ -42,16 +43,30 @@ using aidl::android::media::audio::common::PcmType;

namespace aidl::android::hardware::audio::core::internal {

static void fillProfile(AudioProfile* profile, const std::vector<int32_t>& channelLayouts,
                        const std::vector<int32_t>& sampleRates) {
    for (auto layout : channelLayouts) {
        profile->channelMasks.push_back(
                AudioChannelLayout::make<AudioChannelLayout::layoutMask>(layout));
    }
    profile->sampleRates.insert(profile->sampleRates.end(), sampleRates.begin(), sampleRates.end());
}

static AudioProfile createProfile(PcmType pcmType, const std::vector<int32_t>& channelLayouts,
                                  const std::vector<int32_t>& sampleRates) {
    AudioProfile profile;
    profile.format.type = AudioFormatType::PCM;
    profile.format.pcm = pcmType;
    for (auto layout : channelLayouts) {
        profile.channelMasks.push_back(
                AudioChannelLayout::make<AudioChannelLayout::layoutMask>(layout));
    fillProfile(&profile, channelLayouts, sampleRates);
    return profile;
}
    profile.sampleRates.insert(profile.sampleRates.end(), sampleRates.begin(), sampleRates.end());

static AudioProfile createProfile(const std::string& encodingType,
                                  const std::vector<int32_t>& channelLayouts,
                                  const std::vector<int32_t>& sampleRates) {
    AudioProfile profile;
    profile.format.encoding = encodingType;
    fillProfile(&profile, channelLayouts, sampleRates);
    return profile;
}

@@ -125,6 +140,8 @@ static AudioRoute createRoute(const std::vector<int32_t>& sources, int32_t sink)
//  * "primary output", PRIMARY, 1 max open, 1 max active stream
//    - profile PCM 16-bit; MONO, STEREO; 44100, 48000
//    - profile PCM 24-bit; MONO, STEREO; 44100, 48000
//  * "compressed offload", DIRECT|COMPRESS_OFFLOAD|NON_BLOCKING, 1 max open, 1 max active stream
//    - profile MP3; MONO, STEREO; 44100, 48000
//  * "loopback output", stream count unlimited
//    - profile PCM 24-bit; STEREO; 48000
//  * "primary input", 2 max open, 2 max active streams
@@ -136,8 +153,8 @@ static AudioRoute createRoute(const std::vector<int32_t>& sources, int32_t sink)
//    - profile PCM 24-bit; STEREO; 48000
//
// Routes:
//  "primary out" -> "Null"
//  "primary out" -> "USB Out"
//  "primary out", "compressed offload" -> "Null"
//  "primary out", "compressed offload" -> "USB Out"
//  "loopback out" -> "Loopback Out"
//  "Zero", "USB In" -> "primary input"
//  "Loopback In" -> "loopback input"
@@ -183,6 +200,18 @@ Configuration& getNullPrimaryConfiguration() {
                                      standardPcmAudioProfiles.end());
        c.ports.push_back(primaryOutMix);

        AudioPort compressedOffloadOutMix =
                createPort(c.nextPortId++, "compressed offload",
                           1 << static_cast<int32_t>(AudioOutputFlags::DIRECT) |
                                   1 << static_cast<int32_t>(AudioOutputFlags::COMPRESS_OFFLOAD) |
                                   1 << static_cast<int32_t>(AudioOutputFlags::NON_BLOCKING),
                           false, createPortMixExt(1, 1));
        compressedOffloadOutMix.profiles.push_back(
                createProfile(::android::MEDIA_MIMETYPE_AUDIO_MPEG,
                              {AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO},
                              {44100, 48000}));
        c.ports.push_back(compressedOffloadOutMix);

        AudioPort loopOutDevice = createPort(c.nextPortId++, "Loopback Out", 0, false,
                                             createDeviceExt(AudioDeviceType::OUT_SUBMIX, 0));
        loopOutDevice.profiles.push_back(
@@ -244,8 +273,10 @@ Configuration& getNullPrimaryConfiguration() {
        c.ports.push_back(usbInDevice);
        c.connectedProfiles[usbInDevice.id] = standardPcmAudioProfiles;

        c.routes.push_back(createRoute({primaryOutMix.id}, nullOutDevice.id));
        c.routes.push_back(createRoute({primaryOutMix.id}, usbOutDevice.id));
        c.routes.push_back(
                createRoute({primaryOutMix.id, compressedOffloadOutMix.id}, nullOutDevice.id));
        c.routes.push_back(
                createRoute({primaryOutMix.id, compressedOffloadOutMix.id}, usbOutDevice.id));
        c.routes.push_back(createRoute({loopOutMix.id}, loopOutDevice.id));
        c.routes.push_back(createRoute({zeroInDevice.id, usbInDevice.id}, primaryInMix.id));
        c.routes.push_back(createRoute({loopInDevice.id}, loopInMix.id));
+9 −0
Original line number Diff line number Diff line
@@ -405,6 +405,14 @@ ndk::ScopedAStatus Module::openOutputStream(int32_t in_portConfigId,
                   << " does not correspond to an output mix port";
        return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
    }
    if (portConfigIt->flags.has_value() &&
        ((portConfigIt->flags.value().get<AudioIoFlags::Tag::output>() &
          1 << static_cast<int32_t>(AudioOutputFlags::COMPRESS_OFFLOAD)) != 0) &&
        !in_offloadInfo.has_value()) {
        LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
                   << " has COMPRESS_OFFLOAD flag set, requires offload info";
        return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
    }
    if (mStreams.count(in_portConfigId) != 0) {
        LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
                   << " already has a stream opened on it";
@@ -424,6 +432,7 @@ ndk::ScopedAStatus Module::openOutputStream(int32_t in_portConfigId,
}

ndk::ScopedAStatus Module::setAudioPatch(const AudioPatch& in_requested, AudioPatch* _aidl_return) {
    LOG(DEBUG) << __func__ << ": requested patch " << in_requested.toString();
    if (in_requested.sourcePortConfigIds.empty()) {
        LOG(ERROR) << __func__ << ": requested patch has empty sources list";
        return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
Loading