Loading media/audioaidlconversion/AidlConversionCppNdk.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -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); } Loading Loading @@ -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); } Loading media/module/extractors/extractor.aconfig +1 −1 Original line number Diff line number Diff line Loading @@ -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" } media/mtp/OWNERS +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 media/utils/include/mediautils/SharedMemoryAllocator.h +50 −0 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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: Loading services/audioflinger/Threads.cpp +16 −12 Original line number Diff line number Diff line Loading @@ -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 Loading
media/audioaidlconversion/AidlConversionCppNdk.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -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); } Loading Loading @@ -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); } Loading
media/module/extractors/extractor.aconfig +1 −1 Original line number Diff line number Diff line Loading @@ -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" }
media/mtp/OWNERS +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
media/utils/include/mediautils/SharedMemoryAllocator.h +50 −0 Original line number Diff line number Diff line Loading @@ -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> Loading Loading @@ -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: Loading
services/audioflinger/Threads.cpp +16 −12 Original line number Diff line number Diff line Loading @@ -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