Audio V4: Make common helper version independent
The implementation uses the version provided by macro.
Bug: 38184704
Test: compile
Change-Id: Ib5565bdf77ed9e42fc8271a4317eb88681aefcd5
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
new file mode 100644
index 0000000..c111476
--- /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 0000000..9b617bb
--- /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 <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
new file mode 100644
index 0000000..3d39933
--- /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 <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/all-versions/default/Android.bp b/audio/common/all-versions/default/Android.bp
index 82b38c0..8f6b74c 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 @@
},
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 703b91c..7f8da1e 100644
--- a/audio/common/all-versions/default/EffectMap.cpp
+++ b/audio/common/all-versions/default/EffectMap.cpp
@@ -16,7 +16,7 @@
#include <atomic>
-#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 355b635..547c6d5 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 <mutex>
@@ -43,4 +43,4 @@
} // 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 09ed288..1654ac6 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 <memory>
-#include <android/hardware/audio/common/2.0/types.h>
#include <system/audio.h>
-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 @@
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 a74fb89..935f307 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 <string.h>
-#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 @@
memcpy(halUuid->node, uuid.node.data(), uuid.node.size());
}
+} // namespace AUDIO_HAL_VERSION
+} // namespace common
+} // namespace audio
+} // namespace hardware
} // namespace android