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

Commit 5fccbdc7 authored by Andy Hung's avatar Andy Hung Committed by Gerrit Code Review
Browse files

Merge "AudioFlinger: Add datapath subproject"

parents 7f840ed0 1ef7738c
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -148,13 +148,10 @@ cc_library_shared {

    srcs: [
        "AudioFlinger.cpp",
        "AudioHwDevice.cpp",
        "AudioStreamOut.cpp",
        "DeviceEffectManager.cpp",
        "Effects.cpp",
        "PatchPanel.cpp",
        "PropertyUtils.cpp",
        "SpdifStreamOut.cpp",
        "Threads.cpp",
        "Tracks.cpp",
    ],
@@ -170,6 +167,7 @@ cc_library_shared {
        "av-types-aidl-cpp",
        "effect-aidl-cpp",
        "libaudioclient_aidl_conversion",
        "libaudioflinger_datapath",
        "libaudioflinger_fastpath",
        "libaudioflinger_timing",
        "libaudioflinger_utils",
+6 −5
Original line number Diff line number Diff line
@@ -91,14 +91,15 @@
#include <timing/SyncEvent.h>
#include <timing/SynchronizedRecordState.h>

#include <datapath/AudioHwDevice.h>
#include <datapath/AudioStreamOut.h>
#include <datapath/SpdifStreamOut.h>
#include <datapath/ThreadMetrics.h>
#include <datapath/TrackMetrics.h>
#include <fastpath/FastCapture.h>
#include <fastpath/FastMixer.h>
#include <media/nbaio/NBAIO.h>
#include "AudioStreamOut.h"
#include "SpdifStreamOut.h"
#include "AudioHwDevice.h"
#include "ThreadMetrics.h"
#include "TrackMetrics.h"


#include <android/os/IPowerManager.h>

+64 −0
Original line number Diff line number Diff line
package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_base_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_av_services_audioflinger_license"],
}

audioflinger_datapath_tidy_errors = audioflinger_base_tidy_errors + [
    "modernize-avoid-c-arrays",
    "modernize-deprecated-headers",
    "modernize-pass-by-value",
    "modernize-use-auto",
    "modernize-use-nodiscard",

    // TODO(b/275642749) Reenable these warnings
    "-misc-non-private-member-variables-in-classes",
]

// Eventually use common tidy defaults
cc_defaults {
    name: "audioflinger_datapath_flags_defaults",
    // https://clang.llvm.org/docs/UsersManual.html#command-line-options
    // https://clang.llvm.org/docs/DiagnosticsReference.html
    cflags: audioflinger_base_cflags,
    // https://clang.llvm.org/extra/clang-tidy/
    tidy: true,
    tidy_checks: audioflinger_datapath_tidy_errors,
    tidy_checks_as_errors: audioflinger_datapath_tidy_errors,
    tidy_flags: [
      "-format-style=file",
    ],
}

cc_library {
    name: "libaudioflinger_datapath",

    defaults: [
        "audioflinger_datapath_flags_defaults",
        "latest_android_media_audio_common_types_cpp_shared",
    ],

    srcs: [
        "AudioHwDevice.cpp",
        "AudioStreamOut.cpp",
        "SpdifStreamOut.cpp",
    ],

    header_libs: [
        "libaudiohal_headers",
        "liberror_headers",
    ],

    shared_libs: [
        "audioclient-types-aidl-cpp",
        "av-types-aidl-cpp",
        "libaudiospdif",
        "libaudioutils",
        "libbase",
        "liblog",
        "libutils", // refbase
    ],
}
+4 −4
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ status_t AudioHwDevice::openOutputStream(
{

    struct audio_config originalConfig = *config;
    AudioStreamOut *outputStream = new AudioStreamOut(this, flags);
    auto outputStream = new AudioStreamOut(this, flags);

    // Try to open the HAL first using the current format.
    ALOGV("openOutputStream(), try "
@@ -57,7 +57,7 @@ status_t AudioHwDevice::openOutputStream(

    if (status != NO_ERROR) {
        delete outputStream;
        outputStream = NULL;
        outputStream = nullptr;

        // FIXME Look at any modification to the config.
        // The HAL might modify the config to suggest a wrapped format.
@@ -71,7 +71,7 @@ status_t AudioHwDevice::openOutputStream(
            status);

        // If the data is encoded then try again using wrapped PCM.
        bool wrapperNeeded = !audio_has_proportional_frames(originalConfig.format)
        const bool wrapperNeeded = !audio_has_proportional_frames(originalConfig.format)
                && ((flags & AUDIO_OUTPUT_FLAG_DIRECT) != 0)
                && ((flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) == 0);

@@ -83,7 +83,7 @@ status_t AudioHwDevice::openOutputStream(
                    ALOGE("ERROR - openOutputStream(), SPDIF open returned %d",
                        status);
                    delete outputStream;
                    outputStream = NULL;
                    outputStream = nullptr;
                }
            } else {
                ALOGE("ERROR - openOutputStream(), SPDIFEncoder does not support format 0x%08x",
+12 −12
Original line number Diff line number Diff line
@@ -54,25 +54,25 @@ public:
        , mFlags(flags) { }
    virtual ~AudioHwDevice() { free((void *)mModuleName); }

    bool canSetMasterVolume() const {
    [[nodiscard]] bool canSetMasterVolume() const {
        return (0 != (mFlags & AHWD_CAN_SET_MASTER_VOLUME));
    }

    bool canSetMasterMute() const {
    [[nodiscard]] bool canSetMasterMute() const {
        return (0 != (mFlags & AHWD_CAN_SET_MASTER_MUTE));
    }

    bool isInsert() const {
    [[nodiscard]] bool isInsert() const {
        return (0 != (mFlags & AHWD_IS_INSERT));
    }

    bool supportsBluetoothVariableLatency() const {
    [[nodiscard]] bool supportsBluetoothVariableLatency() const {
        return (0 != (mFlags & AHWD_SUPPORTS_BT_LATENCY_MODES));
    }

    audio_module_handle_t handle() const { return mHandle; }
    const char *moduleName() const { return mModuleName; }
    sp<DeviceHalInterface> hwDevice() const { return mHwDevice; }
   [[nodiscard]] audio_module_handle_t handle() const { return mHandle; }
   [[nodiscard]] const char *moduleName() const { return mModuleName; }
   [[nodiscard]] sp<DeviceHalInterface> hwDevice() const { return mHwDevice; }

    /** This method creates and opens the audio hardware output stream.
     * The "address" parameter qualifies the "devices" audio device type if needed.
@@ -89,17 +89,17 @@ public:
            struct audio_config *config,
            const char *address);

    bool supportsAudioPatches() const;
    [[nodiscard]] bool supportsAudioPatches() const;

    status_t getAudioPort(struct audio_port_v7 *port) const;
    [[nodiscard]] status_t getAudioPort(struct audio_port_v7 *port) const;

    status_t getMmapPolicyInfos(
    [[nodiscard]] status_t getMmapPolicyInfos(
            media::audio::common::AudioMMapPolicyType policyType,
            std::vector<media::audio::common::AudioMMapPolicyInfo> *policyInfos) const;

    int32_t getAAudioMixerBurstCount() const;
    [[nodiscard]] int32_t getAAudioMixerBurstCount() const;

    int32_t getAAudioHardwareBurstMinUsec() const;
    [[nodiscard]] int32_t getAAudioHardwareBurstMinUsec() const;

private:
    const audio_module_handle_t mHandle;
Loading