diff --git a/audio/2.0/default/Android.mk b/audio/2.0/default/Android.mk index 7f42abe03e..ccf3c1c42f 100644 --- a/audio/2.0/default/Android.mk +++ b/audio/2.0/default/Android.mk @@ -44,6 +44,7 @@ LOCAL_SHARED_LIBRARIES := \ android.hardware.audio@2.0 \ android.hardware.audio.common@2.0 \ android.hardware.audio.common@2.0-util \ + android.hardware.audio.common-util \ LOCAL_HEADER_LIBRARIES := \ libaudioclient_headers \ diff --git a/audio/2.0/default/Device.cpp b/audio/2.0/default/Device.cpp index 3727966279..c392f65ada 100644 --- a/audio/2.0/default/Device.cpp +++ b/audio/2.0/default/Device.cpp @@ -30,6 +30,8 @@ #include "StreamOut.h" #include "Util.h" +using ::android::hardware::audio::common::V2_0::HidlUtils; + namespace android { namespace hardware { namespace audio { diff --git a/audio/2.0/default/Stream.cpp b/audio/2.0/default/Stream.cpp index effdd28507..2fb47ef7fd 100644 --- a/audio/2.0/default/Stream.cpp +++ b/audio/2.0/default/Stream.cpp @@ -26,8 +26,8 @@ #include #include "Conversions.h" -#include "EffectMap.h" #include "Stream.h" +#include "common/all-versions/default/EffectMap.h" namespace android { namespace hardware { diff --git a/audio/common/2.0/default/Android.bp b/audio/common/2.0/default/Android.bp new file mode 100644 index 0000000000..c1114764b2 --- /dev/null +++ b/audio/common/2.0/default/Android.bp @@ -0,0 +1,47 @@ +// +// Copyright (C) 2017 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. + +cc_library_shared { + name: "android.hardware.audio.common@2.0-util", + defaults: ["hidl_defaults"], + vendor_available: true, + vndk: { + enabled: true, + }, + srcs: [ + "HidlUtils.cpp", + ], + + export_include_dirs: ["."], + + static_libs: [ + ], + + shared_libs: [ + "liblog", + "libutils", + "libhidlbase", + "android.hardware.audio.common-util", + "android.hardware.audio.common@2.0", + ], + export_shared_lib_headers: [ + "android.hardware.audio.common-util" + ], + + header_libs: [ + "libaudio_system_headers", + "libhardware_headers", + ], +} diff --git a/audio/common/2.0/default/HidlUtils.cpp b/audio/common/2.0/default/HidlUtils.cpp new file mode 100644 index 0000000000..9b617bb96f --- /dev/null +++ b/audio/common/2.0/default/HidlUtils.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2017 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. + */ + +#include "HidlUtils.h" + +#define AUDIO_HAL_VERSION V2_0 +#include +#undef AUDIO_HAL_VERSION diff --git a/audio/common/2.0/default/HidlUtils.h b/audio/common/2.0/default/HidlUtils.h new file mode 100644 index 0000000000..3d39933e3b --- /dev/null +++ b/audio/common/2.0/default/HidlUtils.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2017 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. + */ + +#ifndef android_hardware_audio_V2_0_Hidl_Utils_H_ +#define android_hardware_audio_V2_0_Hidl_Utils_H_ + +#include + +#define AUDIO_HAL_VERSION V2_0 +#include +#undef AUDIO_HAL_VERSION + +#endif // android_hardware_audio_V2_0_Hidl_Utils_H_ diff --git a/audio/common/all-versions/default/Android.bp b/audio/common/all-versions/default/Android.bp index 82b38c0877..8f6b74c96e 100644 --- a/audio/common/all-versions/default/Android.bp +++ b/audio/common/all-versions/default/Android.bp @@ -14,7 +14,7 @@ // limitations under the License. cc_library_shared { - name: "android.hardware.audio.common@2.0-util", + name: "android.hardware.audio.common-util", defaults: ["hidl_defaults"], vendor_available: true, vndk: { @@ -22,16 +22,14 @@ cc_library_shared { }, srcs: [ "EffectMap.cpp", - "HidlUtils.cpp", ], - export_include_dirs: ["."], + export_include_dirs: ["include"], shared_libs: [ "liblog", "libutils", "libhidlbase", - "android.hardware.audio.common@2.0", ], header_libs: [ diff --git a/audio/common/all-versions/default/EffectMap.cpp b/audio/common/all-versions/default/EffectMap.cpp index 703b91cfec..7f8da1e2ab 100644 --- a/audio/common/all-versions/default/EffectMap.cpp +++ b/audio/common/all-versions/default/EffectMap.cpp @@ -16,7 +16,7 @@ #include -#include "EffectMap.h" +#include "common/all-versions/default/EffectMap.h" namespace android { diff --git a/audio/common/all-versions/default/EffectMap.h b/audio/common/all-versions/default/include/common/all-versions/default/EffectMap.h similarity index 88% rename from audio/common/all-versions/default/EffectMap.h rename to audio/common/all-versions/default/include/common/all-versions/default/EffectMap.h index 355b635281..547c6d5a9f 100644 --- a/audio/common/all-versions/default/EffectMap.h +++ b/audio/common/all-versions/default/include/common/all-versions/default/EffectMap.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef android_hardware_audio_V2_0_EffectMap_H_ -#define android_hardware_audio_V2_0_EffectMap_H_ +#ifndef android_hardware_audio_common_EffectMap_H_ +#define android_hardware_audio_common_EffectMap_H_ #include @@ -43,4 +43,4 @@ class EffectMap : public Singleton { } // namespace android -#endif // android_hardware_audio_V2_0_EffectMap_H_ +#endif // android_hardware_audio_common_EffectMap_H_ diff --git a/audio/common/all-versions/default/HidlUtils.h b/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.h similarity index 76% rename from audio/common/all-versions/default/HidlUtils.h rename to audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.h index 09ed288fea..1654ac6e34 100644 --- a/audio/common/all-versions/default/HidlUtils.h +++ b/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.h @@ -14,24 +14,28 @@ * limitations under the License. */ -#ifndef android_hardware_audio_V2_0_Hidl_Utils_H_ -#define android_hardware_audio_V2_0_Hidl_Utils_H_ +#ifndef AUDIO_HAL_VERSION +#error "AUDIO_HAL_VERSION must be set before including this file." +#endif #include -#include #include -using ::android::hardware::audio::common::V2_0::AudioConfig; -using ::android::hardware::audio::common::V2_0::AudioGain; -using ::android::hardware::audio::common::V2_0::AudioGainConfig; -using ::android::hardware::audio::common::V2_0::AudioOffloadInfo; -using ::android::hardware::audio::common::V2_0::AudioPort; -using ::android::hardware::audio::common::V2_0::AudioPortConfig; -using ::android::hardware::audio::common::V2_0::Uuid; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioConfig; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioGain; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioGainConfig; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioOffloadInfo; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPort; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortConfig; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::Uuid; using ::android::hardware::hidl_vec; namespace android { +namespace hardware { +namespace audio { +namespace common { +namespace AUDIO_HAL_VERSION { class HidlUtils { public: @@ -62,6 +66,8 @@ class HidlUtils { static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid); }; +} // namespace AUDIO_HAL_VERSION +} // namespace common +} // namespace audio +} // namespace hardware } // namespace android - -#endif // android_hardware_audio_V2_0_Hidl_Utils_H_ diff --git a/audio/common/all-versions/default/HidlUtils.cpp b/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h similarity index 92% rename from audio/common/all-versions/default/HidlUtils.cpp rename to audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h index a74fb89403..935f307cdc 100644 --- a/audio/common/all-versions/default/HidlUtils.cpp +++ b/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h @@ -14,23 +14,29 @@ * limitations under the License. */ +#ifndef AUDIO_HAL_VERSION +#error "AUDIO_HAL_VERSION must be set before including this file." +#endif + #include -#include "HidlUtils.h" - -using ::android::hardware::audio::common::V2_0::AudioChannelMask; -using ::android::hardware::audio::common::V2_0::AudioDevice; -using ::android::hardware::audio::common::V2_0::AudioFormat; -using ::android::hardware::audio::common::V2_0::AudioGainMode; -using ::android::hardware::audio::common::V2_0::AudioMixLatencyClass; -using ::android::hardware::audio::common::V2_0::AudioPortConfigMask; -using ::android::hardware::audio::common::V2_0::AudioPortRole; -using ::android::hardware::audio::common::V2_0::AudioPortType; -using ::android::hardware::audio::common::V2_0::AudioSource; -using ::android::hardware::audio::common::V2_0::AudioStreamType; -using ::android::hardware::audio::common::V2_0::AudioUsage; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioFormat; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioGainMode; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMixLatencyClass; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortConfigMask; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortRole; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortType; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioStreamType; +using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioUsage; namespace android { +namespace hardware { +namespace audio { +namespace common { +namespace AUDIO_HAL_VERSION { void HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config) { config->sampleRateHz = halConfig.sample_rate; @@ -333,4 +339,8 @@ void HidlUtils::uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid) { memcpy(halUuid->node, uuid.node.data(), uuid.node.size()); } +} // namespace AUDIO_HAL_VERSION +} // namespace common +} // namespace audio +} // namespace hardware } // namespace android diff --git a/audio/effect/2.0/default/Android.bp b/audio/effect/2.0/default/Android.bp index e1072b466d..f2b36d3492 100644 --- a/audio/effect/2.0/default/Android.bp +++ b/audio/effect/2.0/default/Android.bp @@ -31,6 +31,7 @@ cc_library_shared { "libhidltransport", "liblog", "libutils", + "android.hardware.audio.common-util", "android.hardware.audio.common@2.0", "android.hardware.audio.common@2.0-util", "android.hardware.audio.effect@2.0", diff --git a/audio/effect/2.0/default/Conversions.cpp b/audio/effect/2.0/default/Conversions.cpp index e7d4c46388..e839288e9d 100644 --- a/audio/effect/2.0/default/Conversions.cpp +++ b/audio/effect/2.0/default/Conversions.cpp @@ -20,6 +20,8 @@ #include "Conversions.h" #include "HidlUtils.h" +using ::android::hardware::audio::common::V2_0::HidlUtils; + namespace android { namespace hardware { namespace audio { diff --git a/audio/effect/2.0/default/Effect.cpp b/audio/effect/2.0/default/Effect.cpp index 184607e5df..4026cf27e3 100644 --- a/audio/effect/2.0/default/Effect.cpp +++ b/audio/effect/2.0/default/Effect.cpp @@ -25,7 +25,7 @@ #include "Conversions.h" #include "Effect.h" -#include "EffectMap.h" +#include "common/all-versions/default/EffectMap.h" namespace android { namespace hardware { diff --git a/audio/effect/2.0/default/EffectsFactory.cpp b/audio/effect/2.0/default/EffectsFactory.cpp index 922a922182..c4ac6ae0c2 100644 --- a/audio/effect/2.0/default/EffectsFactory.cpp +++ b/audio/effect/2.0/default/EffectsFactory.cpp @@ -34,17 +34,19 @@ #include "BassBoostEffect.h" #include "Conversions.h" #include "DownmixEffect.h" -#include "EffectsFactory.h" -#include "HidlUtils.h" #include "Effect.h" -#include "EffectMap.h" +#include "EffectsFactory.h" #include "EnvironmentalReverbEffect.h" #include "EqualizerEffect.h" +#include "HidlUtils.h" #include "LoudnessEnhancerEffect.h" #include "NoiseSuppressionEffect.h" #include "PresetReverbEffect.h" #include "VirtualizerEffect.h" #include "VisualizerEffect.h" +#include "common/all-versions/default/EffectMap.h" + +using ::android::hardware::audio::common::V2_0::HidlUtils; namespace android { namespace hardware {