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

Commit 7a961cd9 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12602378 from 38f018ec to 25Q1-release

Change-Id: If72f906d6f9d2c6e5feb5fa9a2437bf9e4b84566
parents aff74001 38f018ec
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1802,6 +1802,8 @@ aidl2legacy_AudioUsage_audio_usage_t(AudioUsage aidl) {
            return AUDIO_USAGE_VEHICLE_STATUS;
        case AudioUsage::ANNOUNCEMENT:
            return AUDIO_USAGE_ANNOUNCEMENT;
        case AudioUsage::SPEAKER_CLEANUP:
            return AUDIO_USAGE_SPEAKER_CLEANUP;
    }
    return unexpected(BAD_VALUE);
}
@@ -1853,6 +1855,8 @@ legacy2aidl_audio_usage_t_AudioUsage(audio_usage_t legacy) {
            return AudioUsage::VEHICLE_STATUS;
        case AUDIO_USAGE_ANNOUNCEMENT:
            return AudioUsage::ANNOUNCEMENT;
        case AUDIO_USAGE_SPEAKER_CLEANUP:
            return AudioUsage::SPEAKER_CLEANUP;
    }
    return unexpected(BAD_VALUE);
}
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ flag {
    name: "extractor_sniff_midi_optimizations"
    is_exported: true
    is_fixed_read_only: true
    namespace: "media_extractor"
    namespace: "media_solutions"
    description: "Enable SniffMidi optimizations."
    bug: "359920208"
}
+3 −4
Original line number Diff line number Diff line
set noparent

aprasath@google.com
anothermark@google.com
kumarashishg@google.com
sarup@google.com
febinthattil@google.com
aprasath@google.com
jsharkey@android.com
jameswei@google.com
rmojumder@google.com
kumarashishg@google.com
 No newline at end of file
+50 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include <type_traits>
#include <unordered_map>

#include <android-base/thread_annotations.h>
#include <binder/MemoryBase.h>
#include <binder/MemoryHeapBase.h>
#include <log/log_main.h>
@@ -425,8 +426,57 @@ class FallbackAllocator {
    [[no_unique_address]] SecondaryAllocator mSecondary;
};

// Wrap an allocator with a lock if backs multiple allocators through indirection
template <typename Allocator>
class LockedAllocator {
  public:
    static size_t alignment() { return Allocator::alignment(); }

    explicit LockedAllocator(Allocator allocator) : mAllocator(allocator) {}

    LockedAllocator() = default;

    template <typename T>
    AllocationType allocate(T&& request) {
        static_assert(std::is_base_of_v<android::mediautils::BasicAllocRequest, std::decay_t<T>>);
        std::lock_guard l_{mMutex};
        return mAllocator.allocate(std::forward<T>(request));
    }

    void deallocate(const AllocationType& allocation) {
        std::lock_guard l_{mMutex};
        mAllocator.deallocate(allocation);
    }

    template <typename Enable = void>
    auto deallocate_all()
            -> std::enable_if_t<shared_allocator_impl::has_deallocate_all<Allocator>, Enable> {
        std::lock_guard l_{mMutex};
        mAllocator.deallocate_all();
    }

    template <typename Enable = bool>
    auto owns(const AllocationType& allocation) const
            -> std::enable_if_t<shared_allocator_impl::has_owns<Allocator>, Enable> {
        std::lock_guard l_{mMutex};
        return mAllocator.owns(allocation);
    }

    template <typename Enable = std::string>
    auto dump() const -> std::enable_if_t<shared_allocator_impl::has_dump<Allocator>, Enable> {
        std::lock_guard l_{mMutex};
        return mAllocator.dump();
    }

  private:
    std::mutex mMutex;
    [[no_unique_address]] Allocator mAllocator GUARDED_BY(mMutex);
};

// An allocator which is backed by a shared_ptr to an allocator, so multiple
// allocators can share the same backing allocator (and thus the same state).
// When the same backing allocator is used by multiple higher level allocators,
// locking at the sharing level is necessary.
template <typename Allocator>
class IndirectAllocator {
  public:
+16 −12
Original line number Diff line number Diff line
@@ -338,28 +338,32 @@ std::string IAfThreadBase::formatToString(audio_format_t format) {
// under  #ifdef __cplusplus #endif
static std::string patchSinksToString(const struct audio_patch *patch)
{
    std::stringstream ss;
    std::string s;
    for (size_t i = 0; i < patch->num_sinks; ++i) {
        if (i > 0) {
            ss << "|";
        if (i > 0) s.append("|");
        if (patch->sinks[i].ext.device.address[0]) {
            s.append("(").append(toString(patch->sinks[i].ext.device.type))
                    .append(", ").append(patch->sinks[i].ext.device.address).append(")");
        } else {
            s.append(toString(patch->sinks[i].ext.device.type));
        }
        ss << "(" << toString(patch->sinks[i].ext.device.type)
            << ", " << patch->sinks[i].ext.device.address << ")";
    }
    return ss.str();
    return s;
}

static std::string patchSourcesToString(const struct audio_patch *patch)
{
    std::stringstream ss;
    std::string s;
    for (size_t i = 0; i < patch->num_sources; ++i) {
        if (i > 0) {
            ss << "|";
        if (i > 0) s.append("|");
        if (patch->sources[i].ext.device.address[0]) {
            s.append("(").append(toString(patch->sources[i].ext.device.type))
                    .append(", ").append(patch->sources[i].ext.device.address).append(")");
        } else {
            s.append(toString(patch->sources[i].ext.device.type));
        }
        ss << "(" << toString(patch->sources[i].ext.device.type)
            << ", " << patch->sources[i].ext.device.address << ")";
    }
    return ss.str();
    return s;
}

static std::string toString(audio_latency_mode_t mode) {
Loading