Audio HAL: Simplify types updates for 'common' and 'audio' packages
Instead of importing every single type individually ("using <type>"), import entire namespaces of ::android::hardware::audio::CPP_VERSION and ::android::hardware::audio::common::CPP_VERSION inside the "implementation" namespace in the default implementation. This simplifies modifying types, as it is not needed anymore to surround "using <type>" directives with #if MAJOR_VERSION ... Note that the contents of the namespaces are imported inside the "implementation" namespace, which reduces risks of name collision Also, fixed the namespace for HidlUtils--it needs to be in 'implementation'. Test: make Change-Id: I81bbb3074b5763717ae72e747a075fd46dc36d18
This commit is contained in:
parent
315002043a
commit
543bf9cb16
16 changed files with 32 additions and 103 deletions
|
@ -19,18 +19,6 @@
|
|||
#include <common/all-versions/VersionUtils.h>
|
||||
#include <string.h>
|
||||
|
||||
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;
|
||||
|
||||
namespace android {
|
||||
|
@ -38,6 +26,9 @@ namespace hardware {
|
|||
namespace audio {
|
||||
namespace common {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
|
||||
void HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config) {
|
||||
config->sampleRateHz = halConfig.sample_rate;
|
||||
|
@ -356,6 +347,7 @@ void HidlUtils::uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid) {
|
|||
memcpy(halUuid->node, uuid.node.data(), uuid.node.size());
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace CPP_VERSION
|
||||
} // namespace common
|
||||
} // namespace audio
|
||||
|
|
|
@ -24,19 +24,15 @@
|
|||
#include <system/audio.h>
|
||||
|
||||
using ::android::hardware::hidl_vec;
|
||||
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 CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
|
||||
class HidlUtils {
|
||||
public:
|
||||
|
@ -69,6 +65,7 @@ class HidlUtils {
|
|||
static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid);
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace CPP_VERSION
|
||||
} // namespace common
|
||||
} // namespace audio
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace audio {
|
|||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
|
||||
std::string deviceAddressToHal(const DeviceAddress& address) {
|
||||
// HAL assumes that the address is NUL-terminated.
|
||||
|
|
|
@ -31,14 +31,14 @@
|
|||
|
||||
#include <android/log.h>
|
||||
|
||||
using ::android::hardware::audio::common::CPP_VERSION::HidlUtils;
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
|
||||
|
||||
Device::Device(audio_hw_device_t* device) : mDevice(device) {}
|
||||
|
||||
Device::~Device() {
|
||||
|
|
|
@ -28,15 +28,15 @@
|
|||
#include <utils/Trace.h>
|
||||
#include <memory>
|
||||
|
||||
using ::android::hardware::audio::common::CPP_VERSION::ThreadInfo;
|
||||
using ::android::hardware::audio::CPP_VERSION::MessageQueueFlagBits;
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
using namespace ::android::hardware::audio::CPP_VERSION;
|
||||
|
||||
namespace {
|
||||
|
||||
class ReadThread : public Thread {
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace audio {
|
|||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
|
||||
using namespace ::android::hardware::audio::CPP_VERSION;
|
||||
|
||||
std::string deviceAddressToHal(const DeviceAddress& address);
|
||||
|
||||
|
|
|
@ -43,30 +43,10 @@ using ::android::hardware::hidl_string;
|
|||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioConfig;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioHwSync;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioInputFlag;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioOutputFlag;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioPatchHandle;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioPort;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioPortConfig;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioInputFlagBitfield;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioOutputFlagBitfield;
|
||||
using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
|
||||
using ::android::hardware::audio::CPP_VERSION::IDevice;
|
||||
using ::android::hardware::audio::CPP_VERSION::IStreamIn;
|
||||
using ::android::hardware::audio::CPP_VERSION::IStreamOut;
|
||||
using ::android::hardware::audio::CPP_VERSION::ParameterValue;
|
||||
using ::android::hardware::audio::CPP_VERSION::Result;
|
||||
|
||||
#if MAJOR_VERSION == 4
|
||||
using ::android::hardware::audio::CPP_VERSION::SinkMetadata;
|
||||
using ::android::hardware::audio::CPP_VERSION::SourceMetadata;
|
||||
#elif MAJOR_VERSION >= 5
|
||||
using ::android::hardware::audio::common::CPP_VERSION::SinkMetadata;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::SourceMetadata;
|
||||
#endif
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
using namespace ::android::hardware::audio::CPP_VERSION;
|
||||
|
||||
struct Device : public IDevice, public ParametersUtil {
|
||||
explicit Device(audio_hw_device_t* device);
|
||||
|
|
|
@ -35,9 +35,7 @@ using ::android::hardware::hidl_string;
|
|||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::audio::CPP_VERSION::IDevice;
|
||||
using ::android::hardware::audio::CPP_VERSION::IDevicesFactory;
|
||||
using ::android::hardware::audio::CPP_VERSION::Result;
|
||||
using namespace ::android::hardware::audio::CPP_VERSION;
|
||||
|
||||
struct DevicesFactory : public IDevicesFactory {
|
||||
#if MAJOR_VERSION == 2
|
||||
|
|
|
@ -33,9 +33,7 @@ namespace implementation {
|
|||
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
|
||||
using ::android::hardware::audio::CPP_VERSION::ParameterValue;
|
||||
using ::android::hardware::audio::CPP_VERSION::Result;
|
||||
using namespace ::android::hardware::audio::CPP_VERSION;
|
||||
|
||||
class ParametersUtil {
|
||||
public:
|
||||
|
|
|
@ -36,20 +36,8 @@ using ::android::hardware::hidl_string;
|
|||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioConfig;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioInputFlag;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioMode;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioOutputFlag;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioPort;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioPortConfig;
|
||||
using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
|
||||
using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
|
||||
using ::android::hardware::audio::CPP_VERSION::IDevice;
|
||||
using ::android::hardware::audio::CPP_VERSION::IPrimaryDevice;
|
||||
using ::android::hardware::audio::CPP_VERSION::IStreamIn;
|
||||
using ::android::hardware::audio::CPP_VERSION::IStreamOut;
|
||||
using ::android::hardware::audio::CPP_VERSION::ParameterValue;
|
||||
using ::android::hardware::audio::CPP_VERSION::Result;
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
using namespace ::android::hardware::audio::CPP_VERSION;
|
||||
|
||||
struct PrimaryDevice : public IPrimaryDevice {
|
||||
explicit PrimaryDevice(audio_hw_device_t* device);
|
||||
|
|
|
@ -41,14 +41,9 @@ using ::android::hardware::hidl_string;
|
|||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
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::implementation::AudioChannelBitfield;
|
||||
using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
|
||||
using ::android::hardware::audio::CPP_VERSION::IStream;
|
||||
using ::android::hardware::audio::CPP_VERSION::ParameterValue;
|
||||
using ::android::hardware::audio::CPP_VERSION::Result;
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
using namespace ::android::hardware::audio::CPP_VERSION;
|
||||
|
||||
struct Stream : public IStream, public ParametersUtil {
|
||||
explicit Stream(audio_stream_t* stream);
|
||||
|
|
|
@ -42,15 +42,8 @@ using ::android::hardware::hidl_string;
|
|||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
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::AudioSource;
|
||||
using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
|
||||
using ::android::hardware::audio::CPP_VERSION::IStream;
|
||||
using ::android::hardware::audio::CPP_VERSION::IStreamIn;
|
||||
using ::android::hardware::audio::CPP_VERSION::ParameterValue;
|
||||
using ::android::hardware::audio::CPP_VERSION::Result;
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
using namespace ::android::hardware::audio::CPP_VERSION;
|
||||
|
||||
struct StreamIn : public IStreamIn {
|
||||
typedef MessageQueue<ReadParameters, kSynchronizedReadWrite> CommandMQ;
|
||||
|
|
|
@ -42,17 +42,8 @@ using ::android::hardware::hidl_string;
|
|||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
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::CPP_VERSION::AudioDrain;
|
||||
using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
|
||||
using ::android::hardware::audio::CPP_VERSION::IStream;
|
||||
using ::android::hardware::audio::CPP_VERSION::IStreamOut;
|
||||
using ::android::hardware::audio::CPP_VERSION::IStreamOutCallback;
|
||||
using ::android::hardware::audio::CPP_VERSION::ParameterValue;
|
||||
using ::android::hardware::audio::CPP_VERSION::Result;
|
||||
using ::android::hardware::audio::CPP_VERSION::TimeSpec;
|
||||
using namespace ::android::hardware::audio::common::CPP_VERSION;
|
||||
using namespace ::android::hardware::audio::CPP_VERSION;
|
||||
|
||||
struct StreamOut : public IStreamOut {
|
||||
typedef MessageQueue<WriteCommand, kSynchronizedReadWrite> CommandMQ;
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace audio {
|
|||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::audio::CPP_VERSION::Result;
|
||||
using namespace ::android::hardware::audio::CPP_VERSION;
|
||||
|
||||
/** @return true if gain is between 0 and 1 included. */
|
||||
constexpr bool isGainNormalized(float gain) {
|
||||
|
|
|
@ -17,14 +17,11 @@
|
|||
#include "Conversions.h"
|
||||
#include "HidlUtils.h"
|
||||
|
||||
using ::android::hardware::audio::common::CPP_VERSION::HidlUtils;
|
||||
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <common/all-versions/VersionUtils.h>
|
||||
|
||||
using ::android::hardware::audio::common::CPP_VERSION::HidlUtils;
|
||||
using ::android::hardware::audio::common::utils::EnumBitfield;
|
||||
|
||||
namespace android {
|
||||
|
@ -34,6 +31,8 @@ namespace effect {
|
|||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
|
||||
|
||||
void effectDescriptorFromHal(const effect_descriptor_t& halDescriptor,
|
||||
EffectDescriptor* descriptor) {
|
||||
HidlUtils::uuidFromHal(halDescriptor.type, &descriptor->type);
|
||||
|
|
|
@ -32,8 +32,6 @@
|
|||
#include "VisualizerEffect.h"
|
||||
#include "common/all-versions/default/EffectMap.h"
|
||||
|
||||
using ::android::hardware::audio::common::CPP_VERSION::HidlUtils;
|
||||
|
||||
#include <android/log.h>
|
||||
#include <media/EffectsFactoryApi.h>
|
||||
#include <system/audio_effects/effect_aec.h>
|
||||
|
@ -48,8 +46,6 @@ using ::android::hardware::audio::common::CPP_VERSION::HidlUtils;
|
|||
#include <system/audio_effects/effect_virtualizer.h>
|
||||
#include <system/audio_effects/effect_visualizer.h>
|
||||
|
||||
using ::android::hardware::audio::common::CPP_VERSION::HidlUtils;
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
|
@ -57,6 +53,8 @@ namespace effect {
|
|||
namespace CPP_VERSION {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
|
||||
|
||||
// static
|
||||
sp<IEffect> EffectsFactory::dispatchEffectInstanceCreation(const effect_descriptor_t& halDescriptor,
|
||||
effect_handle_t handle) {
|
||||
|
|
Loading…
Reference in a new issue