Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2390b5d6 authored by Kevin Rocard's avatar Kevin Rocard
Browse files

Audio V4: Update namespace and version of 4.0 shim



Put the shim in a V4_0 namespace to comply with the ODR.
Make the include guard unique.
Split from the error prone interface adaptation change for safer review.

Patch generated with:
sed -i 's/V2_0/V4_0/g' *
sed -i "/include.*2.0/s/2\.0/4.0/" *
sed -i '/namespace android *{/anamespace V4_0 {' *
sed -Ei 's/(ifndef|define|endif)(.*)_H/\1\2_4_0_H/' *
sed -Ei 's#}(.*)namespace android$#}\1namespace V4_0\n\0#' *

Bug: 38184704
Test: Compile
Change-Id: I7d3aa46b3dfec664cbeea8a6b946456b8e8f06e3
Signed-off-by: default avatarKevin Rocard <krocard@google.com>
parent d4de2889
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -22,9 +22,10 @@

#include "ConversionHelperHidl.h"

using ::android::hardware::audio::V2_0::Result;
using ::android::hardware::audio::V4_0::Result;

namespace android {
namespace V4_0 {

// static
status_t ConversionHelperHidl::keysFromHal(const String8& keys, hidl_vec<hidl_string> *hidlKeys) {
@@ -100,4 +101,5 @@ void ConversionHelperHidl::emitError(const char* funcName, const char* descripti
    ALOGE("%s %p %s: %s (from rpc)", mClassName, this, funcName, description);
}

}  // namespace V4_0
}  // namespace android
+10 −8
Original line number Diff line number Diff line
@@ -14,19 +14,20 @@
 * limitations under the License.
 */

#ifndef ANDROID_HARDWARE_CONVERSION_HELPER_HIDL_H
#define ANDROID_HARDWARE_CONVERSION_HELPER_HIDL_H
#ifndef ANDROID_HARDWARE_CONVERSION_HELPER_HIDL_4_0_H
#define ANDROID_HARDWARE_CONVERSION_HELPER_HIDL_4_0_H

#include <android/hardware/audio/2.0/types.h>
#include <android/hardware/audio/4.0/types.h>
#include <hidl/HidlSupport.h>
#include <utils/String8.h>

using ::android::hardware::audio::V2_0::ParameterValue;
using ::android::hardware::audio::V4_0::ParameterValue;
using ::android::hardware::Return;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;

namespace android {
namespace V4_0 {

class ConversionHelperHidl {
  protected:
@@ -54,7 +55,7 @@ class ConversionHelperHidl {
        return ret.isOk() ? OK : FAILED_TRANSACTION;
    }

    status_t processReturn(const char* funcName, const Return<hardware::audio::V2_0::Result>& ret) {
    status_t processReturn(const char* funcName, const Return<hardware::audio::V4_0::Result>& ret) {
        if (!ret.isOk()) {
            emitError(funcName, ret.description().c_str());
        }
@@ -63,7 +64,7 @@ class ConversionHelperHidl {

    template<typename T>
    status_t processReturn(
            const char* funcName, const Return<T>& ret, hardware::audio::V2_0::Result retval) {
            const char* funcName, const Return<T>& ret, hardware::audio::V4_0::Result retval) {
        if (!ret.isOk()) {
            emitError(funcName, ret.description().c_str());
        }
@@ -73,11 +74,12 @@ class ConversionHelperHidl {
  private:
    const char* mClassName;

    static status_t analyzeResult(const hardware::audio::V2_0::Result& result);
    static status_t analyzeResult(const hardware::audio::V4_0::Result& result);

    void emitError(const char* funcName, const char* description);
};

}  // namespace V4_0
}  // namespace android

#endif // ANDROID_HARDWARE_CONVERSION_HELPER_HIDL_H
#endif // ANDROID_HARDWARE_CONVERSION_HELPER_HIDL_4_0_H
+17 −15
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@
#define LOG_TAG "DeviceHalHidl"
//#define LOG_NDEBUG 0

#include <android/hardware/audio/2.0/IPrimaryDevice.h>
#include <android/hardware/audio/4.0/IPrimaryDevice.h>
#include <cutils/native_handle.h>
#include <hwbinder/IPCThreadState.h>
#include <utils/Log.h>
@@ -28,24 +28,25 @@
#include "HidlUtils.h"
#include "StreamHalHidl.h"

using ::android::hardware::audio::common::V2_0::AudioConfig;
using ::android::hardware::audio::common::V2_0::AudioDevice;
using ::android::hardware::audio::common::V2_0::AudioInputFlag;
using ::android::hardware::audio::common::V2_0::AudioOutputFlag;
using ::android::hardware::audio::common::V2_0::AudioPatchHandle;
using ::android::hardware::audio::common::V2_0::AudioPort;
using ::android::hardware::audio::common::V2_0::AudioPortConfig;
using ::android::hardware::audio::common::V2_0::AudioMode;
using ::android::hardware::audio::common::V2_0::AudioSource;
using ::android::hardware::audio::common::V2_0::HidlUtils;
using ::android::hardware::audio::V2_0::DeviceAddress;
using ::android::hardware::audio::V2_0::IPrimaryDevice;
using ::android::hardware::audio::V2_0::ParameterValue;
using ::android::hardware::audio::V2_0::Result;
using ::android::hardware::audio::common::V4_0::AudioConfig;
using ::android::hardware::audio::common::V4_0::AudioDevice;
using ::android::hardware::audio::common::V4_0::AudioInputFlag;
using ::android::hardware::audio::common::V4_0::AudioOutputFlag;
using ::android::hardware::audio::common::V4_0::AudioPatchHandle;
using ::android::hardware::audio::common::V4_0::AudioPort;
using ::android::hardware::audio::common::V4_0::AudioPortConfig;
using ::android::hardware::audio::common::V4_0::AudioMode;
using ::android::hardware::audio::common::V4_0::AudioSource;
using ::android::hardware::audio::common::V4_0::HidlUtils;
using ::android::hardware::audio::V4_0::DeviceAddress;
using ::android::hardware::audio::V4_0::IPrimaryDevice;
using ::android::hardware::audio::V4_0::ParameterValue;
using ::android::hardware::audio::V4_0::Result;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;

namespace android {
namespace V4_0 {

namespace {

@@ -355,4 +356,5 @@ status_t DeviceHalHidl::dump(int fd) {
    return processReturn("dump", ret);
}

} // namespace V4_0
} // namespace android
+9 −7
Original line number Diff line number Diff line
@@ -14,20 +14,21 @@
 * limitations under the License.
 */

#ifndef ANDROID_HARDWARE_DEVICE_HAL_HIDL_H
#define ANDROID_HARDWARE_DEVICE_HAL_HIDL_H
#ifndef ANDROID_HARDWARE_DEVICE_HAL_HIDL_4_0_H
#define ANDROID_HARDWARE_DEVICE_HAL_HIDL_4_0_H

#include <android/hardware/audio/2.0/IDevice.h>
#include <android/hardware/audio/2.0/IPrimaryDevice.h>
#include <android/hardware/audio/4.0/IDevice.h>
#include <android/hardware/audio/4.0/IPrimaryDevice.h>
#include <media/audiohal/DeviceHalInterface.h>

#include "ConversionHelperHidl.h"

using ::android::hardware::audio::V2_0::IDevice;
using ::android::hardware::audio::V2_0::IPrimaryDevice;
using ::android::hardware::audio::V4_0::IDevice;
using ::android::hardware::audio::V4_0::IPrimaryDevice;
using ::android::hardware::Return;

namespace android {
namespace V4_0 {

class DeviceHalHidl : public DeviceHalInterface, public ConversionHelperHidl
{
@@ -121,6 +122,7 @@ class DeviceHalHidl : public DeviceHalInterface, public ConversionHelperHidl
    virtual ~DeviceHalHidl();
};

} // namespace V4_0
} // namespace android

#endif // ANDROID_HARDWARE_DEVICE_HAL_HIDL_H
#endif // ANDROID_HARDWARE_DEVICE_HAL_HIDL_4_0_H
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include "StreamHalLocal.h"

namespace android {
namespace V4_0 {

DeviceHalLocal::DeviceHalLocal(audio_hw_device_t *dev)
        : mDev(dev) {
@@ -196,4 +197,5 @@ void DeviceHalLocal::closeInputStream(struct audio_stream_in *stream_in) {
    mDev->close_input_stream(mDev, stream_in);
}

} // namespace V4_0
} // namespace android
Loading