diff options
author | Kevin Rocard <krocard@google.com> | 2018-04-17 11:00:58 -0700 |
---|---|---|
committer | Kevin Rocard <krocard@google.com> | 2018-04-20 17:05:15 -0700 |
commit | 147a454bb2a952d34ee6a66a80245ab54f53e510 (patch) | |
tree | 99184172b367fe0ba9faa2ca73eb5204f097469e /audio/core | |
parent | 3c50fab04876f7fc3c6a02f42b718be27944c0fc (diff) | |
download | android_hardware_interfaces-147a454bb2a952d34ee6a66a80245ab54f53e510.tar.gz android_hardware_interfaces-147a454bb2a952d34ee6a66a80245ab54f53e510.tar.bz2 android_hardware_interfaces-147a454bb2a952d34ee6a66a80245ab54f53e510.zip |
Audio: make core/4.0/default/Util.h version dependant
This patch does not have any functional change.
It refactors Util.h to make it version dependant.
This is needed in the next patch to add a helper
that uses HIDL types.
This patch is the fixed first half of
I41204c0807d2bd4675e941771cbc9a43d7d14855
that was reverted due to a merge conflict.
Bug: 72873273
Bug: 69811500
Bug: 69010523
Test: playback and record for media and voice call
Original-Change-Id: I41204c0807d2bd4675e941771cbc9a43d7d14855
Change-Id: Ie543519fa0dca62486b75f42bb0c8a93d6cad3c3
Signed-off-by: Kevin Rocard <krocard@google.com>
Diffstat (limited to 'audio/core')
19 files changed, 76 insertions, 20 deletions
diff --git a/audio/core/2.0/default/Device.cpp b/audio/core/2.0/default/Device.cpp index 221ea5c0e..b67203d50 100644 --- a/audio/core/2.0/default/Device.cpp +++ b/audio/core/2.0/default/Device.cpp @@ -21,7 +21,7 @@ #include "core/2.0/default/Conversions.h" #include "core/2.0/default/StreamIn.h" #include "core/2.0/default/StreamOut.h" -#include "core/all-versions/default/Util.h" +#include "core/2.0/default/Util.h" #define AUDIO_HAL_VERSION V2_0 #include <core/all-versions/default/Device.impl.h> diff --git a/audio/core/2.0/default/ParametersUtil.cpp b/audio/core/2.0/default/ParametersUtil.cpp index 33a3ad9b7..963e291de 100644 --- a/audio/core/2.0/default/ParametersUtil.cpp +++ b/audio/core/2.0/default/ParametersUtil.cpp @@ -15,6 +15,7 @@ */ #include "core/2.0/default/ParametersUtil.h" +#include "core/2.0/default/Util.h" #define AUDIO_HAL_VERSION V2_0 #include <core/all-versions/default/ParametersUtil.impl.h> diff --git a/audio/core/2.0/default/PrimaryDevice.cpp b/audio/core/2.0/default/PrimaryDevice.cpp index ce5740386..decaa1465 100644 --- a/audio/core/2.0/default/PrimaryDevice.cpp +++ b/audio/core/2.0/default/PrimaryDevice.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "PrimaryDeviceHAL" #include "core/2.0/default/PrimaryDevice.h" -#include "core/all-versions/default/Util.h" +#include "core/2.0/default/Util.h" #define AUDIO_HAL_VERSION V2_0 #include <core/all-versions/default/PrimaryDevice.impl.h> diff --git a/audio/core/2.0/default/Stream.cpp b/audio/core/2.0/default/Stream.cpp index 69ee65981..0863a7c39 100644 --- a/audio/core/2.0/default/Stream.cpp +++ b/audio/core/2.0/default/Stream.cpp @@ -19,6 +19,7 @@ #include "core/2.0/default/Stream.h" #include "common/all-versions/default/EffectMap.h" #include "core/2.0/default/Conversions.h" +#include "core/2.0/default/Util.h" #define AUDIO_HAL_VERSION V2_0 #include <core/all-versions/default/Stream.impl.h> diff --git a/audio/core/2.0/default/StreamIn.cpp b/audio/core/2.0/default/StreamIn.cpp index 6b8776ebe..2021df1c4 100644 --- a/audio/core/2.0/default/StreamIn.cpp +++ b/audio/core/2.0/default/StreamIn.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "StreamInHAL" #include "core/2.0/default/StreamIn.h" -#include "core/all-versions/default/Util.h" +#include "core/2.0/default/Util.h" #define AUDIO_HAL_VERSION V2_0 #include <core/all-versions/default/StreamIn.impl.h> diff --git a/audio/core/2.0/default/StreamOut.cpp b/audio/core/2.0/default/StreamOut.cpp index 7f1461ac7..940a25127 100644 --- a/audio/core/2.0/default/StreamOut.cpp +++ b/audio/core/2.0/default/StreamOut.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "StreamOutHAL" #include "core/2.0/default/StreamOut.h" -#include "core/all-versions/default/Util.h" +#include "core/2.0/default/Util.h" #define AUDIO_HAL_VERSION V2_0 #include <core/all-versions/default/StreamOut.impl.h> diff --git a/audio/core/2.0/default/include/core/2.0/default/Util.h b/audio/core/2.0/default/include/core/2.0/default/Util.h new file mode 100644 index 000000000..1f0e284d0 --- /dev/null +++ b/audio/core/2.0/default/include/core/2.0/default/Util.h @@ -0,0 +1,26 @@ +/* + * 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_V2_0_UTIL_H +#define ANDROID_HARDWARE_AUDIO_V2_0_UTIL_H + +#include <android/hardware/audio/2.0/types.h> + +#define AUDIO_HAL_VERSION V2_0 +#include <core/all-versions/default/Util.h> +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_V2_0_UTIL_H diff --git a/audio/core/4.0/default/Device.cpp b/audio/core/4.0/default/Device.cpp index 26f9ab4a7..b33434ecf 100644 --- a/audio/core/4.0/default/Device.cpp +++ b/audio/core/4.0/default/Device.cpp @@ -21,7 +21,7 @@ #include "core/4.0/default/Conversions.h" #include "core/4.0/default/StreamIn.h" #include "core/4.0/default/StreamOut.h" -#include "core/all-versions/default/Util.h" +#include "core/4.0/default/Util.h" #define AUDIO_HAL_VERSION V4_0 #include <core/all-versions/default/Device.impl.h> diff --git a/audio/core/4.0/default/ParametersUtil.cpp b/audio/core/4.0/default/ParametersUtil.cpp index 5c1b1c4b1..2cc9fb56a 100644 --- a/audio/core/4.0/default/ParametersUtil.cpp +++ b/audio/core/4.0/default/ParametersUtil.cpp @@ -15,6 +15,7 @@ */ #include "core/4.0/default/ParametersUtil.h" +#include "core/4.0/default/Util.h" #define AUDIO_HAL_VERSION V4_0 #include <core/all-versions/default/ParametersUtil.impl.h> diff --git a/audio/core/4.0/default/PrimaryDevice.cpp b/audio/core/4.0/default/PrimaryDevice.cpp index 0294b4d0d..e3e49768d 100644 --- a/audio/core/4.0/default/PrimaryDevice.cpp +++ b/audio/core/4.0/default/PrimaryDevice.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "PrimaryDeviceHAL" #include "core/4.0/default/PrimaryDevice.h" -#include "core/all-versions/default/Util.h" +#include "core/4.0/default/Util.h" #define AUDIO_HAL_VERSION V4_0 #include <core/all-versions/default/PrimaryDevice.impl.h> diff --git a/audio/core/4.0/default/Stream.cpp b/audio/core/4.0/default/Stream.cpp index 30b34544d..b8c71de7b 100644 --- a/audio/core/4.0/default/Stream.cpp +++ b/audio/core/4.0/default/Stream.cpp @@ -19,6 +19,7 @@ #include "core/4.0/default/Stream.h" #include "common/all-versions/default/EffectMap.h" #include "core/4.0/default/Conversions.h" +#include "core/4.0/default/Util.h" #define AUDIO_HAL_VERSION V4_0 #include <core/all-versions/default/Stream.impl.h> diff --git a/audio/core/4.0/default/StreamIn.cpp b/audio/core/4.0/default/StreamIn.cpp index 18719b5da..718bd25a6 100644 --- a/audio/core/4.0/default/StreamIn.cpp +++ b/audio/core/4.0/default/StreamIn.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "StreamInHAL" #include "core/4.0/default/StreamIn.h" -#include "core/all-versions/default/Util.h" +#include "core/4.0/default/Util.h" #define AUDIO_HAL_VERSION V4_0 #include <core/all-versions/default/StreamIn.impl.h> diff --git a/audio/core/4.0/default/StreamOut.cpp b/audio/core/4.0/default/StreamOut.cpp index 11c8fde66..db88e401d 100644 --- a/audio/core/4.0/default/StreamOut.cpp +++ b/audio/core/4.0/default/StreamOut.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "StreamOutHAL" #include "core/4.0/default/StreamOut.h" -#include "core/all-versions/default/Util.h" +#include "core/4.0/default/Util.h" #define AUDIO_HAL_VERSION V4_0 #include <core/all-versions/default/StreamOut.impl.h> diff --git a/audio/core/4.0/default/include/core/4.0/default/Util.h b/audio/core/4.0/default/include/core/4.0/default/Util.h new file mode 100644 index 000000000..ce31e6f7f --- /dev/null +++ b/audio/core/4.0/default/include/core/4.0/default/Util.h @@ -0,0 +1,26 @@ +/* + * 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_UTIL_H +#define ANDROID_HARDWARE_AUDIO_V4_0_UTIL_H + +#include <android/hardware/audio/4.0/types.h> + +#define AUDIO_HAL_VERSION V4_0 +#include <core/all-versions/default/Util.h> +#undef AUDIO_HAL_VERSION + +#endif // ANDROID_HARDWARE_AUDIO_V4_0_UTIL_H diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Device.impl.h b/audio/core/all-versions/default/include/core/all-versions/default/Device.impl.h index 581e1dcce..37b7124a2 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/Device.impl.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/Device.impl.h @@ -25,7 +25,6 @@ #include <android/log.h> using ::android::hardware::audio::common::AUDIO_HAL_VERSION::HidlUtils; -using ::android::hardware::audio::all_versions::implementation::isGainNormalized; namespace android { namespace hardware { diff --git a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h b/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h index 9b39d9c9e..61ffbe00c 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h @@ -160,7 +160,7 @@ Return<Result> PrimaryDevice::setConnectedState(const DeviceAddress& address, bo // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IPrimaryDevice follow. Return<Result> PrimaryDevice::setVoiceVolume(float volume) { - if (!all_versions::implementation::isGainNormalized(volume)) { + if (!isGainNormalized(volume)) { ALOGW("Can not set a voice volume (%f) outside [0,1]", volume); return Result::INVALID_ARGUMENTS; } @@ -248,7 +248,7 @@ Return<Result> PrimaryDevice::setBtHfpSampleRate(uint32_t sampleRateHz) { return mDevice->setParam(AUDIO_PARAMETER_KEY_HFP_SET_SAMPLING_RATE, int(sampleRateHz)); } Return<Result> PrimaryDevice::setBtHfpVolume(float volume) { - if (!all_versions::implementation::isGainNormalized(volume)) { + if (!isGainNormalized(volume)) { ALOGW("Can not set BT HFP volume (%f) outside [0,1]", volume); return Result::INVALID_ARGUMENTS; } diff --git a/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.impl.h b/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.impl.h index 8774be904..64c85ab5f 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.impl.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.impl.h @@ -25,9 +25,7 @@ #include <memory> using ::android::hardware::audio::AUDIO_HAL_VERSION::MessageQueueFlagBits; -using ::android::hardware::audio::all_versions::implementation::isGainNormalized; #include "Conversions.h" -#include "Util.h" namespace android { namespace hardware { diff --git a/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.impl.h b/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.impl.h index 77098a816..6fb157f7d 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.impl.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.impl.h @@ -32,7 +32,6 @@ namespace AUDIO_HAL_VERSION { namespace implementation { using ::android::hardware::audio::common::AUDIO_HAL_VERSION::ThreadInfo; -using ::android::hardware::audio::all_versions::implementation::isGainNormalized; namespace { diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Util.h b/audio/core/all-versions/default/include/core/all-versions/default/Util.h index 39d9dbde0..5dea28625 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/Util.h +++ b/audio/core/all-versions/default/include/core/all-versions/default/Util.h @@ -14,24 +14,28 @@ * limitations under the License. */ -#ifndef ANDROID_HARDWARE_AUDIO_DEVICE_ALL_VERSIONS_UTIL_H -#define ANDROID_HARDWARE_AUDIO_DEVICE_ALL_VERSIONS_UTIL_H +#include <common/all-versions/IncludeGuard.h> + +#include <algorithm> +#include <vector> + +#include <system/audio.h> namespace android { namespace hardware { namespace audio { -namespace all_versions { +namespace AUDIO_HAL_VERSION { namespace implementation { +using ::android::hardware::audio::AUDIO_HAL_VERSION::Result; + /** @return true if gain is between 0 and 1 included. */ constexpr bool isGainNormalized(float gain) { return gain >= 0.0 && gain <= 1.0; } } // namespace implementation -} // namespace all_versions +} // namespace AUDIO_HAL_VERSION } // namespace audio } // namespace hardware } // namespace android - -#endif // ANDROID_HARDWARE_AUDIO_DEVICE_ALL_VERSIONS_UTIL_H |