Loading media/libaudiofoundation/Android.bp 0 → 100644 +33 −0 Original line number Diff line number Diff line cc_library_headers { name: "libaudiofoundation_headers", vendor_available: true, export_include_dirs: ["include"], } cc_library_shared { name: "libaudiofoundation", vendor_available: true, srcs: [ "AudioGain.cpp", ], shared_libs: [ "libbase", "libbinder", "liblog", "libutils", ], header_libs: [ "libaudio_system_headers", "libaudiofoundation_headers", ], export_header_lib_headers: ["libaudiofoundation_headers"], cflags: [ "-Werror", "-Wall", ], } services/audiopolicy/common/managerdefinitions/src/AudioGain.cpp→media/libaudiofoundation/AudioGain.cpp +13 −13 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. */ #define LOG_TAG "APM::AudioGain" #define LOG_TAG "AudioGain" //#define LOG_NDEBUG 0 //#define VERY_VERBOSE_LOGGING Loading @@ -24,9 +24,9 @@ #define ALOGVV(a...) do { } while(0) #endif #include "AudioGain.h" #include <android-base/stringprintf.h> #include <media/AudioGain.h> #include <utils/Log.h> #include <utils/String8.h> #include <math.h> Loading Loading @@ -98,17 +98,17 @@ status_t AudioGain::checkConfig(const struct audio_gain_config *config) return NO_ERROR; } void AudioGain::dump(String8 *dst, int spaces, int index) const void AudioGain::dump(std::string *dst, int spaces, int index) const { dst->appendFormat("%*sGain %d:\n", spaces, "", index+1); dst->appendFormat("%*s- mode: %08x\n", spaces, "", mGain.mode); dst->appendFormat("%*s- channel_mask: %08x\n", spaces, "", mGain.channel_mask); dst->appendFormat("%*s- min_value: %d mB\n", spaces, "", mGain.min_value); dst->appendFormat("%*s- max_value: %d mB\n", spaces, "", mGain.max_value); dst->appendFormat("%*s- default_value: %d mB\n", spaces, "", mGain.default_value); dst->appendFormat("%*s- step_value: %d mB\n", spaces, "", mGain.step_value); dst->appendFormat("%*s- min_ramp_ms: %d ms\n", spaces, "", mGain.min_ramp_ms); dst->appendFormat("%*s- max_ramp_ms: %d ms\n", spaces, "", mGain.max_ramp_ms); dst->append(base::StringPrintf("%*sGain %d:\n", spaces, "", index+1)); dst->append(base::StringPrintf("%*s- mode: %08x\n", spaces, "", mGain.mode)); dst->append(base::StringPrintf("%*s- channel_mask: %08x\n", spaces, "", mGain.channel_mask)); dst->append(base::StringPrintf("%*s- min_value: %d mB\n", spaces, "", mGain.min_value)); dst->append(base::StringPrintf("%*s- max_value: %d mB\n", spaces, "", mGain.max_value)); dst->append(base::StringPrintf("%*s- default_value: %d mB\n", spaces, "", mGain.default_value)); dst->append(base::StringPrintf("%*s- step_value: %d mB\n", spaces, "", mGain.step_value)); dst->append(base::StringPrintf("%*s- min_ramp_ms: %d ms\n", spaces, "", mGain.min_ramp_ms)); dst->append(base::StringPrintf("%*s- max_ramp_ms: %d ms\n", spaces, "", mGain.max_ramp_ms)); } } // namespace android media/libaudiofoundation/include/media/AudioContainers.h 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <set> #include <vector> #include <system/audio.h> namespace android { using ChannelMaskSet = std::set<audio_channel_mask_t>; using FormatSet = std::set<audio_format_t>; using SampleRateSet = std::set<uint32_t>; using FormatVector = std::vector<audio_format_t>; static inline ChannelMaskSet asInMask(const ChannelMaskSet& channelMasks) { ChannelMaskSet inMaskSet; for (const auto &channel : channelMasks) { if (audio_channel_mask_out_to_in(channel) != AUDIO_CHANNEL_INVALID) { inMaskSet.insert(audio_channel_mask_out_to_in(channel)); } } return inMaskSet; } static inline ChannelMaskSet asOutMask(const ChannelMaskSet& channelMasks) { ChannelMaskSet outMaskSet; for (const auto &channel : channelMasks) { if (audio_channel_mask_in_to_out(channel) != AUDIO_CHANNEL_INVALID) { outMaskSet.insert(audio_channel_mask_in_to_out(channel)); } } return outMaskSet; } } // namespace android No newline at end of file services/audiopolicy/common/managerdefinitions/include/AudioGain.h→media/libaudiofoundation/include/media/AudioGain.h +2 −2 Original line number Diff line number Diff line Loading @@ -18,8 +18,8 @@ #include <utils/Errors.h> #include <utils/RefBase.h> #include <utils/String8.h> #include <system/audio.h> #include <string> #include <vector> namespace android { Loading Loading @@ -55,7 +55,7 @@ public: int getMaxRampInMs() const { return mGain.max_ramp_ms; } // TODO: remove dump from here (split serialization) void dump(String8 *dst, int spaces, int index) const; void dump(std::string *dst, int spaces, int index) const; void getDefaultConfig(struct audio_gain_config *config); status_t checkConfig(const struct audio_gain_config *config); Loading media/libmedia/include/media/TypeConverter.h +11 −17 Original line number Diff line number Diff line Loading @@ -17,10 +17,11 @@ #ifndef ANDROID_TYPE_CONVERTER_H_ #define ANDROID_TYPE_CONVERTER_H_ #include <set> #include <string> #include <string.h> #include <vector> #include <system/audio.h> #include <utils/Log.h> #include <utils/Vector.h> Loading @@ -42,37 +43,37 @@ struct DefaultTraits } }; template <typename T> struct VectorTraits struct SortedVectorTraits { typedef T Type; typedef Vector<Type> Collection; typedef SortedVector<Type> Collection; static void add(Collection &collection, Type value) { collection.add(value); } }; template <typename T> struct SortedVectorTraits struct SetTraits { typedef T Type; typedef SortedVector<Type> Collection; typedef std::set<Type> Collection; static void add(Collection &collection, Type value) { collection.add(value); collection.insert(value); } }; using SampleRateTraits = SortedVectorTraits<uint32_t>; using SampleRateTraits = SetTraits<uint32_t>; using DeviceTraits = DefaultTraits<audio_devices_t>; struct OutputDeviceTraits : public DeviceTraits {}; struct InputDeviceTraits : public DeviceTraits {}; using ChannelTraits = SortedVectorTraits<audio_channel_mask_t>; using ChannelTraits = SetTraits<audio_channel_mask_t>; struct OutputChannelTraits : public ChannelTraits {}; struct InputChannelTraits : public ChannelTraits {}; struct ChannelIndexTraits : public ChannelTraits {}; using InputFlagTraits = DefaultTraits<audio_input_flags_t>; using OutputFlagTraits = DefaultTraits<audio_output_flags_t>; using FormatTraits = VectorTraits<audio_format_t>; using FormatTraits = DefaultTraits<audio_format_t>; using GainModeTraits = DefaultTraits<audio_gain_mode_t>; using StreamTraits = DefaultTraits<audio_stream_type_t>; using AudioModeTraits = DefaultTraits<audio_mode_t>; Loading Loading @@ -259,6 +260,7 @@ template <typename T, std::enable_if_t<std::is_same<T, audio_content_type_t>::va || std::is_same<T, audio_source_t>::value || std::is_same<T, audio_stream_type_t>::value || std::is_same<T, audio_usage_t>::value || std::is_same<T, audio_format_t>::value , int> = 0> static inline std::string toString(const T& value) { Loading Loading @@ -291,14 +293,6 @@ static inline std::string toString(const audio_devices_t& devices) return result; } // TODO: Remove when FormatTraits uses DefaultTraits. static inline std::string toString(const audio_format_t& format) { std::string result; return TypeConverter<VectorTraits<audio_format_t>>::toString(format, result) ? result : std::to_string(static_cast<int>(format)); } static inline std::string toString(const audio_attributes_t& attributes) { std::ostringstream result; Loading Loading
media/libaudiofoundation/Android.bp 0 → 100644 +33 −0 Original line number Diff line number Diff line cc_library_headers { name: "libaudiofoundation_headers", vendor_available: true, export_include_dirs: ["include"], } cc_library_shared { name: "libaudiofoundation", vendor_available: true, srcs: [ "AudioGain.cpp", ], shared_libs: [ "libbase", "libbinder", "liblog", "libutils", ], header_libs: [ "libaudio_system_headers", "libaudiofoundation_headers", ], export_header_lib_headers: ["libaudiofoundation_headers"], cflags: [ "-Werror", "-Wall", ], }
services/audiopolicy/common/managerdefinitions/src/AudioGain.cpp→media/libaudiofoundation/AudioGain.cpp +13 −13 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. */ #define LOG_TAG "APM::AudioGain" #define LOG_TAG "AudioGain" //#define LOG_NDEBUG 0 //#define VERY_VERBOSE_LOGGING Loading @@ -24,9 +24,9 @@ #define ALOGVV(a...) do { } while(0) #endif #include "AudioGain.h" #include <android-base/stringprintf.h> #include <media/AudioGain.h> #include <utils/Log.h> #include <utils/String8.h> #include <math.h> Loading Loading @@ -98,17 +98,17 @@ status_t AudioGain::checkConfig(const struct audio_gain_config *config) return NO_ERROR; } void AudioGain::dump(String8 *dst, int spaces, int index) const void AudioGain::dump(std::string *dst, int spaces, int index) const { dst->appendFormat("%*sGain %d:\n", spaces, "", index+1); dst->appendFormat("%*s- mode: %08x\n", spaces, "", mGain.mode); dst->appendFormat("%*s- channel_mask: %08x\n", spaces, "", mGain.channel_mask); dst->appendFormat("%*s- min_value: %d mB\n", spaces, "", mGain.min_value); dst->appendFormat("%*s- max_value: %d mB\n", spaces, "", mGain.max_value); dst->appendFormat("%*s- default_value: %d mB\n", spaces, "", mGain.default_value); dst->appendFormat("%*s- step_value: %d mB\n", spaces, "", mGain.step_value); dst->appendFormat("%*s- min_ramp_ms: %d ms\n", spaces, "", mGain.min_ramp_ms); dst->appendFormat("%*s- max_ramp_ms: %d ms\n", spaces, "", mGain.max_ramp_ms); dst->append(base::StringPrintf("%*sGain %d:\n", spaces, "", index+1)); dst->append(base::StringPrintf("%*s- mode: %08x\n", spaces, "", mGain.mode)); dst->append(base::StringPrintf("%*s- channel_mask: %08x\n", spaces, "", mGain.channel_mask)); dst->append(base::StringPrintf("%*s- min_value: %d mB\n", spaces, "", mGain.min_value)); dst->append(base::StringPrintf("%*s- max_value: %d mB\n", spaces, "", mGain.max_value)); dst->append(base::StringPrintf("%*s- default_value: %d mB\n", spaces, "", mGain.default_value)); dst->append(base::StringPrintf("%*s- step_value: %d mB\n", spaces, "", mGain.step_value)); dst->append(base::StringPrintf("%*s- min_ramp_ms: %d ms\n", spaces, "", mGain.min_ramp_ms)); dst->append(base::StringPrintf("%*s- max_ramp_ms: %d ms\n", spaces, "", mGain.max_ramp_ms)); } } // namespace android
media/libaudiofoundation/include/media/AudioContainers.h 0 → 100644 +52 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <set> #include <vector> #include <system/audio.h> namespace android { using ChannelMaskSet = std::set<audio_channel_mask_t>; using FormatSet = std::set<audio_format_t>; using SampleRateSet = std::set<uint32_t>; using FormatVector = std::vector<audio_format_t>; static inline ChannelMaskSet asInMask(const ChannelMaskSet& channelMasks) { ChannelMaskSet inMaskSet; for (const auto &channel : channelMasks) { if (audio_channel_mask_out_to_in(channel) != AUDIO_CHANNEL_INVALID) { inMaskSet.insert(audio_channel_mask_out_to_in(channel)); } } return inMaskSet; } static inline ChannelMaskSet asOutMask(const ChannelMaskSet& channelMasks) { ChannelMaskSet outMaskSet; for (const auto &channel : channelMasks) { if (audio_channel_mask_in_to_out(channel) != AUDIO_CHANNEL_INVALID) { outMaskSet.insert(audio_channel_mask_in_to_out(channel)); } } return outMaskSet; } } // namespace android No newline at end of file
services/audiopolicy/common/managerdefinitions/include/AudioGain.h→media/libaudiofoundation/include/media/AudioGain.h +2 −2 Original line number Diff line number Diff line Loading @@ -18,8 +18,8 @@ #include <utils/Errors.h> #include <utils/RefBase.h> #include <utils/String8.h> #include <system/audio.h> #include <string> #include <vector> namespace android { Loading Loading @@ -55,7 +55,7 @@ public: int getMaxRampInMs() const { return mGain.max_ramp_ms; } // TODO: remove dump from here (split serialization) void dump(String8 *dst, int spaces, int index) const; void dump(std::string *dst, int spaces, int index) const; void getDefaultConfig(struct audio_gain_config *config); status_t checkConfig(const struct audio_gain_config *config); Loading
media/libmedia/include/media/TypeConverter.h +11 −17 Original line number Diff line number Diff line Loading @@ -17,10 +17,11 @@ #ifndef ANDROID_TYPE_CONVERTER_H_ #define ANDROID_TYPE_CONVERTER_H_ #include <set> #include <string> #include <string.h> #include <vector> #include <system/audio.h> #include <utils/Log.h> #include <utils/Vector.h> Loading @@ -42,37 +43,37 @@ struct DefaultTraits } }; template <typename T> struct VectorTraits struct SortedVectorTraits { typedef T Type; typedef Vector<Type> Collection; typedef SortedVector<Type> Collection; static void add(Collection &collection, Type value) { collection.add(value); } }; template <typename T> struct SortedVectorTraits struct SetTraits { typedef T Type; typedef SortedVector<Type> Collection; typedef std::set<Type> Collection; static void add(Collection &collection, Type value) { collection.add(value); collection.insert(value); } }; using SampleRateTraits = SortedVectorTraits<uint32_t>; using SampleRateTraits = SetTraits<uint32_t>; using DeviceTraits = DefaultTraits<audio_devices_t>; struct OutputDeviceTraits : public DeviceTraits {}; struct InputDeviceTraits : public DeviceTraits {}; using ChannelTraits = SortedVectorTraits<audio_channel_mask_t>; using ChannelTraits = SetTraits<audio_channel_mask_t>; struct OutputChannelTraits : public ChannelTraits {}; struct InputChannelTraits : public ChannelTraits {}; struct ChannelIndexTraits : public ChannelTraits {}; using InputFlagTraits = DefaultTraits<audio_input_flags_t>; using OutputFlagTraits = DefaultTraits<audio_output_flags_t>; using FormatTraits = VectorTraits<audio_format_t>; using FormatTraits = DefaultTraits<audio_format_t>; using GainModeTraits = DefaultTraits<audio_gain_mode_t>; using StreamTraits = DefaultTraits<audio_stream_type_t>; using AudioModeTraits = DefaultTraits<audio_mode_t>; Loading Loading @@ -259,6 +260,7 @@ template <typename T, std::enable_if_t<std::is_same<T, audio_content_type_t>::va || std::is_same<T, audio_source_t>::value || std::is_same<T, audio_stream_type_t>::value || std::is_same<T, audio_usage_t>::value || std::is_same<T, audio_format_t>::value , int> = 0> static inline std::string toString(const T& value) { Loading Loading @@ -291,14 +293,6 @@ static inline std::string toString(const audio_devices_t& devices) return result; } // TODO: Remove when FormatTraits uses DefaultTraits. static inline std::string toString(const audio_format_t& format) { std::string result; return TypeConverter<VectorTraits<audio_format_t>>::toString(format, result) ? result : std::to_string(static_cast<int>(format)); } static inline std::string toString(const audio_attributes_t& attributes) { std::ostringstream result; Loading