Audio HAL: Factorize V2 and V4 like libaudiohal
Use the same technique developed for the simpler libaudiohal to
factorize the audio HAL impl.
Generated with script:
set -euo pipefail
cd hardware/interfaces/audio
# Make 2.0 and 4.0 files mostly identical by removing all 2.0, V4.0...
# and replacing it by CPP_VERSION and FILE_VERSION
# This allow both implementation to be mostly identical, except for code difference
# Also remove IncludeGuard.h as it will be included from compiler flag
# Also update license to 2018
find -name *.cpp -o -name *h |
grep -v -e service.cpp |
xargs sed -Ei \
-e 's/(#.*)V[42]_0_(.*_H_?)$/\1\2/' \
-e 's/(LOG_TAG.*)[24]_0/\1/' \
-e '/#ifndef AUDIO_HAL_VERSION/,/#endif/d' \
-e '/^#.*def.*AUDIO_HAL_VERSION\b/d' \
-e's/V[42]_0/CPP_VERSION/' \
-e 's/(#include ).(android.*)[24].0(.*).$/\1PATH(\2FILE_VERSION\3)/' \
-e 's|(#include) .(.*)[24].0/(default/.*).$|\1 "\2\3"|' \
-e 's/\bAUDIO_HAL_VERSION\b/CPP_VERSION/' \
-e '/IncludeGuard.h/d' \
-e 's/(Copyright .C. 201)./\18/'
# set MAJOR_VERSION instead of having a different macro for each version
# this allow to do preprocessor arithmetic (eg: MAJOR_VERSION >= 4)
for v in 2 4; do
find -ipath '*/'$v'.0/*/Android.bp' |
xargs sed -i -e '/cflags:/,/^$/d' -e '/vndk/{:a;/}/!{N;ba};d}' -e '$i\
cflags: [\
"-DMAJOR_VERSION='$v'",\
"-DMINOR_VERSION=0",\
"-include common/all-versions/VersionMacro.h",\
]'; done
# replace# ifdef VERSION_X by #if MAJOR_VERSION == X
find -path *all-versions/*.h |
xargs sed -Ei -e 's/def.*AUDIO_HAL_VERSION_([24])_0.*/ MAJOR_VERSION == \1/' \
-e 'T;s/ +/ /'
# copy all-versions impl in each version impl
find -path '*/[24].0/*.[hc]*' |
grep -ve all-versions -e test |
xargs -P99 -n4 sed -i -Ee '/include <.*all-versions.default/!b' \
-e 's#.*<#find -path */#' -e 's/>$/|xargs tail -n +16/' -e e
# remove all-versions impl
rm -r {core,effect}/all-versions/
# merge version impl into a single all-version
for dir in core/*.0/vts/functional/*.0/ ;do
dest=$(echo $dir | sed 's#/..0/#/all-versions/#')
mkdir -p $dest
mv -T $dir $dest
done
find -mindepth 3 -path '*/2.0/*' -a \( -name '*cpp' -o -name '*h' \) |
grep -v 'all-versions' |
sed -E 'h;s/2/4/g;H;s/4.0/all-versions/;s/4.0//;H;g;s/\n/ /g;'|
xargs -P99 -L1 sh -c '
set -euo pipefail
mkdir -p $(dirname $2);
diff --old-group-format="#if MAJOR_VERSION == 2
%<#endif
" \
--new-group-format="#if MAJOR_VERSION == 4
%>#endif
" $0 $1 > $2 || true;
rm $0 $1'
# merge the X.0 Android.bp & OWNERS in the all-versions
for dir in common effect core; do
for sub in default vts/functional; do
test -f $dir/2.0/$sub/Android.bp || continue
awk 1 $dir/*.0/$sub/Android.bp >> $dir/all-versions/$sub/Android.bp
# delete licenses except for the first one and add whitelines
sed -i -e '/^}$/{N;/^}\n$/!s/\n/&\n/}' $dir/all-versions/$sub/Android.bp
sed -i -e '1,17b;/^\/\//,/^$/{d}' $dir/all-versions/$sub/Android.bp
done
for sub in default vts; do
test -d $dir/2.0/$sub || continue
test -f $dir/2.0/$sub/OWNERS &&
awk 1 $dir/*.0/$sub/OWNERS | sort -u > $dir/all-versions/$sub/OWNERS ||
true
rm -r $dir/*.0/$sub
done
done
# delete all-versions-impl dependencies
find -name 'Android.bp' | xargs sed -i -e '/all-versions-impl/d'
# cleanup unused files
rm common/all-versions/default/include/common/all-versions/default/HidlUtils*
rm common/all-versions/util/include/common/all-versions/IncludeGuard.h
find -depth -type d -empty -delete
# Clamp consecutive number of empty lines to 2
find -name *.cpp -o -name *h | xargs sed -Ei ':a;/^\n*$/{N;ba};s/\n\n+/\n\n/'
# transform #endif\n#if to #elif
find -name *.cpp -o -name *h | xargs sed -i '/^#endif/{N;s/.*\n#if/#elif/}'
# remove leftover include guard in cpp
find -name *.cpp |xargs sed -Ei '/^#.*_H_?$/d'
# apply clang-format
find -name *cpp -o -name *h |
xargs ../../../prebuilts/clang/host/linux-x86/clang-stable/bin/clang-format --style file -i
# clang format breaks PATH(a/b) to PATH(a / b), remove the space surrounding /
find -name *cpp -o -name *h | xargs sed -i "/#include PATH/s# / #/#g"
Test: compile
Bug: 118203066
Change-Id: I3692a444307afc5f71064fe0b9e6b8af3c9ff1dd
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/audio/common/2.0/default/Android.bp b/audio/common/2.0/default/Android.bp
deleted file mode 100644
index ac66479..0000000
--- a/audio/common/2.0/default/Android.bp
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// Copyright (C) 2016 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
deleted file mode 100644
index 9771b7b..0000000
--- a/audio/common/2.0/default/HidlUtils.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2016 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 <common/all-versions/default/HidlUtils.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/common/2.0/default/HidlUtils.h b/audio/common/2.0/default/HidlUtils.h
deleted file mode 100644
index 24543b1..0000000
--- a/audio/common/2.0/default/HidlUtils.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2016 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 <android/hardware/audio/common/2.0/types.h>
-
-#define AUDIO_HAL_VERSION V2_0
-#include <common/all-versions/default/HidlUtils.h>
-#undef AUDIO_HAL_VERSION
-
-#endif // android_hardware_audio_V2_0_Hidl_Utils_H_
diff --git a/audio/common/2.0/default/VersionUtils.h b/audio/common/2.0/default/VersionUtils.h
deleted file mode 100644
index 60d1f9c..0000000
--- a/audio/common/2.0/default/VersionUtils.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2018 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_EFFECT_VERSION_UTILS_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
-
-#include <android/hardware/audio/common/2.0/types.h>
-
-namespace android {
-namespace hardware {
-namespace audio {
-namespace common {
-namespace V2_0 {
-namespace implementation {
-
-typedef common::V2_0::AudioDevice AudioDeviceBitfield;
-typedef common::V2_0::AudioChannelMask AudioChannelBitfield;
-typedef common::V2_0::AudioOutputFlag AudioOutputFlagBitfield;
-typedef common::V2_0::AudioInputFlag AudioInputFlagBitfield;
-
-} // namespace implementation
-} // namespace V2_0
-} // namespace common
-} // namespace audio
-} // namespace hardware
-} // namespace android
-
-#endif // ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
diff --git a/audio/common/4.0/default/Android.bp b/audio/common/4.0/default/Android.bp
deleted file mode 100644
index 57b2e01..0000000
--- a/audio/common/4.0/default/Android.bp
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// Copyright (C) 2018 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@4.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@4.0",
- ],
- export_shared_lib_headers: [
- "android.hardware.audio.common-util"
- ],
-
- header_libs: [
- "libaudio_system_headers",
- "libhardware_headers",
- ],
-}
diff --git a/audio/common/4.0/default/HidlUtils.cpp b/audio/common/4.0/default/HidlUtils.cpp
deleted file mode 100644
index b66eff9..0000000
--- a/audio/common/4.0/default/HidlUtils.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2018 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 V4_0
-#include <common/all-versions/default/HidlUtils.impl.h>
-#undef AUDIO_HAL_VERSION
diff --git a/audio/common/4.0/default/HidlUtils.h b/audio/common/4.0/default/HidlUtils.h
deleted file mode 100644
index 91e6a9e..0000000
--- a/audio/common/4.0/default/HidlUtils.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2018 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_V4_0_Hidl_Utils_H_
-#define android_hardware_audio_V4_0_Hidl_Utils_H_
-
-#include <android/hardware/audio/common/4.0/types.h>
-
-#define AUDIO_HAL_VERSION V4_0
-#include <common/all-versions/default/HidlUtils.h>
-#undef AUDIO_HAL_VERSION
-
-#endif // android_hardware_audio_V4_0_Hidl_Utils_H_
diff --git a/audio/common/4.0/default/OWNERS b/audio/common/4.0/default/OWNERS
deleted file mode 100644
index 6fdc97c..0000000
--- a/audio/common/4.0/default/OWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-elaurent@google.com
-krocard@google.com
-mnaganov@google.com
diff --git a/audio/common/4.0/default/VersionUtils.h b/audio/common/4.0/default/VersionUtils.h
deleted file mode 100644
index b7f2aec..0000000
--- a/audio/common/4.0/default/VersionUtils.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2018 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_EFFECT_VERSION_UTILS_H
-#define ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
-
-#include <android/hardware/audio/common/4.0/types.h>
-
-namespace android {
-namespace hardware {
-namespace audio {
-namespace common {
-namespace V4_0 {
-namespace implementation {
-
-typedef hidl_bitfield<common::V4_0::AudioDevice> AudioDeviceBitfield;
-typedef hidl_bitfield<common::V4_0::AudioChannelMask> AudioChannelBitfield;
-typedef hidl_bitfield<common::V4_0::AudioOutputFlag> AudioOutputFlagBitfield;
-typedef hidl_bitfield<common::V4_0::AudioInputFlag> AudioInputFlagBitfield;
-
-} // namespace implementation
-} // namespace V4_0
-} // namespace common
-} // namespace audio
-} // namespace hardware
-} // namespace android
-
-#endif // ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
diff --git a/audio/common/all-versions/default/Android.bp b/audio/common/all-versions/default/Android.bp
index c24f4b0..6b09d54 100644
--- a/audio/common/all-versions/default/Android.bp
+++ b/audio/common/all-versions/default/Android.bp
@@ -38,3 +38,73 @@
"android.hardware.audio.common.util@all-versions",
]
}
+
+cc_library_shared {
+ name: "android.hardware.audio.common@2.0-util",
+ defaults: ["hidl_defaults"],
+ vendor_available: 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",
+ ],
+ cflags: [
+ "-DMAJOR_VERSION=2",
+ "-DMINOR_VERSION=0",
+ "-include common/all-versions/VersionMacro.h",
+ ]
+}
+
+cc_library_shared {
+ name: "android.hardware.audio.common@4.0-util",
+ defaults: ["hidl_defaults"],
+ vendor_available: true,
+ srcs: [
+ "HidlUtils.cpp",
+ ],
+
+ export_include_dirs: ["."],
+
+ static_libs: [
+ ],
+
+ shared_libs: [
+ "liblog",
+ "libutils",
+ "libhidlbase",
+ "android.hardware.audio.common-util",
+ "android.hardware.audio.common@4.0",
+ ],
+ export_shared_lib_headers: [
+ "android.hardware.audio.common-util"
+ ],
+
+ header_libs: [
+ "libaudio_system_headers",
+ "libhardware_headers",
+ ],
+ cflags: [
+ "-DMAJOR_VERSION=4",
+ "-DMINOR_VERSION=0",
+ "-include common/all-versions/VersionMacro.h",
+ ]
+}
diff --git a/audio/common/all-versions/default/EffectMap.cpp b/audio/common/all-versions/default/EffectMap.cpp
index 7f8da1e..cb3e3d5 100644
--- a/audio/common/all-versions/default/EffectMap.cpp
+++ b/audio/common/all-versions/default/EffectMap.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
diff --git a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h b/audio/common/all-versions/default/HidlUtils.cpp
similarity index 92%
rename from audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h
rename to audio/common/all-versions/default/HidlUtils.cpp
index 03b50b5..5ed059c 100644
--- a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h
+++ b/audio/common/all-versions/default/HidlUtils.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,24 +14,22 @@
* limitations under the License.
*/
-#ifndef AUDIO_HAL_VERSION
-#error "AUDIO_HAL_VERSION must be set before including this file."
-#endif
+#include "HidlUtils.h"
#include <common/all-versions/VersionUtils.h>
#include <string.h>
-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;
+using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask;
+using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
+using ::android::hardware::audio::common::CPP_VERSION::AudioFormat;
+using ::android::hardware::audio::common::CPP_VERSION::AudioGainMode;
+using ::android::hardware::audio::common::CPP_VERSION::AudioMixLatencyClass;
+using ::android::hardware::audio::common::CPP_VERSION::AudioPortConfigMask;
+using ::android::hardware::audio::common::CPP_VERSION::AudioPortRole;
+using ::android::hardware::audio::common::CPP_VERSION::AudioPortType;
+using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
+using ::android::hardware::audio::common::CPP_VERSION::AudioStreamType;
+using ::android::hardware::audio::common::CPP_VERSION::AudioUsage;
using ::android::hardware::audio::common::utils::EnumBitfield;
@@ -39,7 +37,7 @@
namespace hardware {
namespace audio {
namespace common {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
void HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config) {
config->sampleRateHz = halConfig.sample_rate;
@@ -358,7 +356,7 @@
memcpy(halUuid->node, uuid.node.data(), uuid.node.size());
}
-} // namespace AUDIO_HAL_VERSION
+} // namespace CPP_VERSION
} // namespace common
} // namespace audio
} // namespace hardware
diff --git a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.h b/audio/common/all-versions/default/HidlUtils.h
similarity index 78%
rename from audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.h
rename to audio/common/all-versions/default/HidlUtils.h
index 48fa545..77c8b89 100644
--- a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.h
+++ b/audio/common/all-versions/default/HidlUtils.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,28 +14,29 @@
* limitations under the License.
*/
-#ifndef AUDIO_HAL_VERSION
-#error "AUDIO_HAL_VERSION must be set before including this file."
-#endif
+#ifndef android_hardware_audio_Hidl_Utils_H_
+#define android_hardware_audio_Hidl_Utils_H_
+
+#include PATH(android/hardware/audio/common/FILE_VERSION/types.h)
#include <memory>
#include <system/audio.h>
using ::android::hardware::hidl_vec;
-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::audio::common::CPP_VERSION::AudioConfig;
+using ::android::hardware::audio::common::CPP_VERSION::AudioGain;
+using ::android::hardware::audio::common::CPP_VERSION::AudioGainConfig;
+using ::android::hardware::audio::common::CPP_VERSION::AudioOffloadInfo;
+using ::android::hardware::audio::common::CPP_VERSION::AudioPort;
+using ::android::hardware::audio::common::CPP_VERSION::AudioPortConfig;
+using ::android::hardware::audio::common::CPP_VERSION::Uuid;
namespace android {
namespace hardware {
namespace audio {
namespace common {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
class HidlUtils {
public:
@@ -68,8 +69,10 @@
static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid);
};
-} // namespace AUDIO_HAL_VERSION
+} // namespace CPP_VERSION
} // namespace common
} // namespace audio
} // namespace hardware
} // namespace android
+
+#endif // android_hardware_audio_Hidl_Utils_H_
diff --git a/audio/common/2.0/default/OWNERS b/audio/common/all-versions/default/OWNERS
similarity index 100%
rename from audio/common/2.0/default/OWNERS
rename to audio/common/all-versions/default/OWNERS
diff --git a/audio/common/all-versions/default/VersionUtils.h b/audio/common/all-versions/default/VersionUtils.h
new file mode 100644
index 0000000..4726b5b
--- /dev/null
+++ b/audio/common/all-versions/default/VersionUtils.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2018 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_EFFECT_VERSION_UTILS_H
+#define ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
+
+#include PATH(android/hardware/audio/common/FILE_VERSION/types.h)
+
+namespace android {
+namespace hardware {
+namespace audio {
+namespace common {
+namespace CPP_VERSION {
+namespace implementation {
+
+#if MAJOR_VERSION == 2
+typedef common::CPP_VERSION::AudioDevice AudioDeviceBitfield;
+typedef common::CPP_VERSION::AudioChannelMask AudioChannelBitfield;
+typedef common::CPP_VERSION::AudioOutputFlag AudioOutputFlagBitfield;
+typedef common::CPP_VERSION::AudioInputFlag AudioInputFlagBitfield;
+#elif MAJOR_VERSION == 4
+typedef hidl_bitfield<common::CPP_VERSION::AudioDevice> AudioDeviceBitfield;
+typedef hidl_bitfield<common::CPP_VERSION::AudioChannelMask> AudioChannelBitfield;
+typedef hidl_bitfield<common::CPP_VERSION::AudioOutputFlag> AudioOutputFlagBitfield;
+typedef hidl_bitfield<common::CPP_VERSION::AudioInputFlag> AudioInputFlagBitfield;
+#endif
+
+} // namespace implementation
+} // namespace CPP_VERSION
+} // namespace common
+} // namespace audio
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H
diff --git a/audio/common/all-versions/default/include/common/all-versions/default/EffectMap.h b/audio/common/all-versions/default/include/common/all-versions/default/EffectMap.h
index 547c6d5..7f630bf 100644
--- a/audio/common/all-versions/default/include/common/all-versions/default/EffectMap.h
+++ b/audio/common/all-versions/default/include/common/all-versions/default/EffectMap.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
diff --git a/audio/common/all-versions/test/utility/include/utility/AssertOk.h b/audio/common/all-versions/test/utility/include/utility/AssertOk.h
index 11e1c24..5ac2fdc 100644
--- a/audio/common/all-versions/test/utility/include/utility/AssertOk.h
+++ b/audio/common/all-versions/test/utility/include/utility/AssertOk.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
diff --git a/audio/common/all-versions/test/utility/include/utility/Documentation.h b/audio/common/all-versions/test/utility/include/utility/Documentation.h
index e10cf79..1b555b9 100644
--- a/audio/common/all-versions/test/utility/include/utility/Documentation.h
+++ b/audio/common/all-versions/test/utility/include/utility/Documentation.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
diff --git a/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h b/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h
index 7a08a54..0e416f3 100644
--- a/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h
+++ b/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
diff --git a/audio/common/all-versions/test/utility/include/utility/PrettyPrintAudioTypes.h b/audio/common/all-versions/test/utility/include/utility/PrettyPrintAudioTypes.h
index abc2ff5..3833fd0 100644
--- a/audio/common/all-versions/test/utility/include/utility/PrettyPrintAudioTypes.h
+++ b/audio/common/all-versions/test/utility/include/utility/PrettyPrintAudioTypes.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -14,10 +14,6 @@
* limitations under the License.
*/
-#ifndef AUDIO_HAL_VERSION
-#error "AUDIO_HAL_VERSION must be set before including this file."
-#endif
-
#ifndef ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_PRETTY_PRINT_AUDIO_TYPES_H
#define ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_PRETTY_PRINT_AUDIO_TYPES_H
@@ -40,19 +36,19 @@
#define DEFINE_GTEST_PRINT_TO(T) \
inline void PrintTo(const T& val, ::std::ostream* os) { *os << toString(val); }
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
DEFINE_GTEST_PRINT_TO(IPrimaryDevice::TtyMode)
DEFINE_GTEST_PRINT_TO(Result)
-} // namespace AUDIO_HAL_VERSION
+} // namespace CPP_VERSION
namespace common {
-namespace AUDIO_HAL_VERSION {
+namespace CPP_VERSION {
DEFINE_GTEST_PRINT_TO(AudioConfig)
DEFINE_GTEST_PRINT_TO(AudioMode)
DEFINE_GTEST_PRINT_TO(AudioDevice)
DEFINE_GTEST_PRINT_TO(AudioFormat)
DEFINE_GTEST_PRINT_TO(AudioChannelMask)
-} // namespace AUDIO_HAL_VERSION
+} // namespace CPP_VERSION
} // namespace common
#undef DEFINE_GTEST_PRINT_TO
diff --git a/audio/common/all-versions/test/utility/include/utility/ReturnIn.h b/audio/common/all-versions/test/utility/include/utility/ReturnIn.h
index 7fd0d4a..de16809 100644
--- a/audio/common/all-versions/test/utility/include/utility/ReturnIn.h
+++ b/audio/common/all-versions/test/utility/include/utility/ReturnIn.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
diff --git a/audio/common/all-versions/test/utility/include/utility/ValidateXml.h b/audio/common/all-versions/test/utility/include/utility/ValidateXml.h
index 91adfc1..ee206f7 100644
--- a/audio/common/all-versions/test/utility/include/utility/ValidateXml.h
+++ b/audio/common/all-versions/test/utility/include/utility/ValidateXml.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
diff --git a/audio/common/all-versions/test/utility/src/ValidateXml.cpp b/audio/common/all-versions/test/utility/src/ValidateXml.cpp
index 1a906d6..e54914d 100644
--- a/audio/common/all-versions/test/utility/src/ValidateXml.cpp
+++ b/audio/common/all-versions/test/utility/src/ValidateXml.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2018 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.
diff --git a/audio/common/all-versions/util/include/common/all-versions/IncludeGuard.h b/audio/common/all-versions/util/include/common/all-versions/IncludeGuard.h
deleted file mode 100644
index 2d54816..0000000
--- a/audio/common/all-versions/util/include/common/all-versions/IncludeGuard.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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 AUDIO_HAL_VERSION
-#error "AUDIO_HAL_VERSION must be set before including this file."
-#endif