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

Commit 595caa3b authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

Audio HAL: Simplify types updates for 'common' and 'effect' packages

Instead of importing every single type individually ("using <type>"),
import entire namespaces of
::android::hardware::audio::common::CPP_VERSION and
::android::hardware::audio::effect::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

Enclosed EffectHalHidl and supporting classes into 'effect' namespace
because importing namespaces of ::a::h::audio::effect::CPP_VERSION and
::a::h::audio::CPP_VERSION into the same namespace, as it happens
for StreamHalHidl.cpp module, causes name conflicts.

Test: make
Change-Id: Ia37d672605c7541b19ee40fc1b58eabaa9ed8e17
parent 80175771
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -25,13 +25,13 @@ namespace android {
// static
// static
sp<EffectsFactoryHalInterface> EffectsFactoryHalInterface::create() {
sp<EffectsFactoryHalInterface> EffectsFactoryHalInterface::create() {
    if (hardware::audio::effect::V5_0::IEffectsFactory::getService() != nullptr) {
    if (hardware::audio::effect::V5_0::IEffectsFactory::getService() != nullptr) {
        return V5_0::createEffectsFactoryHal();
        return effect::V5_0::createEffectsFactoryHal();
    }
    }
    if (hardware::audio::effect::V4_0::IEffectsFactory::getService() != nullptr) {
    if (hardware::audio::effect::V4_0::IEffectsFactory::getService() != nullptr) {
        return V4_0::createEffectsFactoryHal();
        return effect::V4_0::createEffectsFactoryHal();
    }
    }
    if (hardware::audio::effect::V2_0::IEffectsFactory::getService() != nullptr) {
    if (hardware::audio::effect::V2_0::IEffectsFactory::getService() != nullptr) {
        return V2_0::createEffectsFactoryHal();
        return effect::V2_0::createEffectsFactoryHal();
    }
    }
    return nullptr;
    return nullptr;
}
}
+2 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@ using ::android::hardware::Return;
using ::android::hidl::allocator::V1_0::IAllocator;
using ::android::hidl::allocator::V1_0::IAllocator;


namespace android {
namespace android {
namespace effect {
namespace CPP_VERSION {
namespace CPP_VERSION {


// static
// static
@@ -142,5 +143,6 @@ void EffectBufferHalHidl::commit(size_t size) {
    memcpy(mExternalData, mAudioBuffer.raw, size);
    memcpy(mExternalData, mAudioBuffer.raw, size);
}
}


} // namespace effect
} // namespace CPP_VERSION
} // namespace CPP_VERSION
} // namespace android
} // namespace android
+4 −1
Original line number Original line Diff line number Diff line
@@ -23,13 +23,15 @@
#include <media/audiohal/EffectBufferHalInterface.h>
#include <media/audiohal/EffectBufferHalInterface.h>
#include <system/audio_effect.h>
#include <system/audio_effect.h>


using android::hardware::audio::effect::CPP_VERSION::AudioBuffer;
using android::hardware::hidl_memory;
using android::hardware::hidl_memory;
using android::hidl::memory::V1_0::IMemory;
using android::hidl::memory::V1_0::IMemory;


namespace android {
namespace android {
namespace effect {
namespace CPP_VERSION {
namespace CPP_VERSION {


using namespace ::android::hardware::audio::effect::CPP_VERSION;

class EffectBufferHalHidl : public EffectBufferHalInterface
class EffectBufferHalHidl : public EffectBufferHalInterface
{
{
  public:
  public:
@@ -73,6 +75,7 @@ class EffectBufferHalHidl : public EffectBufferHalInterface
};
};


} // namespace CPP_VERSION
} // namespace CPP_VERSION
} // namespace effect
} // namespace android
} // namespace android


#endif // ANDROID_HARDWARE_EFFECT_BUFFER_HAL_HIDL_H
#endif // ANDROID_HARDWARE_EFFECT_BUFFER_HAL_HIDL_H
+3 −5
Original line number Original line Diff line number Diff line
@@ -26,11 +26,6 @@
#include "EffectHalHidl.h"
#include "EffectHalHidl.h"
#include "HidlUtils.h"
#include "HidlUtils.h"


using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer;
using ::android::hardware::audio::effect::CPP_VERSION::EffectBufferAccess;
using ::android::hardware::audio::effect::CPP_VERSION::EffectConfigParameters;
using ::android::hardware::audio::effect::CPP_VERSION::MessageQueueFlagBits;
using ::android::hardware::audio::effect::CPP_VERSION::Result;
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
using ::android::hardware::audio::common::utils::EnumBitfield;
using ::android::hardware::audio::common::utils::EnumBitfield;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_vec;
@@ -38,9 +33,11 @@ using ::android::hardware::MQDescriptorSync;
using ::android::hardware::Return;
using ::android::hardware::Return;


namespace android {
namespace android {
namespace effect {
namespace CPP_VERSION {
namespace CPP_VERSION {


using namespace ::android::hardware::audio::common::CPP_VERSION;
using namespace ::android::hardware::audio::common::CPP_VERSION;
using namespace ::android::hardware::audio::effect::CPP_VERSION;


EffectHalHidl::EffectHalHidl(const sp<IEffect>& effect, uint64_t effectId)
EffectHalHidl::EffectHalHidl(const sp<IEffect>& effect, uint64_t effectId)
        : mEffect(effect), mEffectId(effectId), mBuffersChanged(true), mEfGroup(nullptr) {
        : mEffect(effect), mEffectId(effectId), mBuffersChanged(true), mEfGroup(nullptr) {
@@ -338,4 +335,5 @@ status_t EffectHalHidl::setConfigImpl(
}
}


} // namespace CPP_VERSION
} // namespace CPP_VERSION
} // namespace effect
} // namespace android
} // namespace android
+6 −7
Original line number Original line Diff line number Diff line
@@ -23,17 +23,15 @@
#include <fmq/MessageQueue.h>
#include <fmq/MessageQueue.h>
#include <system/audio_effect.h>
#include <system/audio_effect.h>


using ::android::hardware::audio::effect::CPP_VERSION::EffectBufferConfig;
using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig;
using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor;
using ::android::hardware::audio::effect::CPP_VERSION::IEffect;
using EffectResult = ::android::hardware::audio::effect::CPP_VERSION::Result;
using ::android::hardware::EventFlag;
using ::android::hardware::EventFlag;
using ::android::hardware::MessageQueue;
using ::android::hardware::MessageQueue;


namespace android {
namespace android {
namespace effect {
namespace CPP_VERSION {
namespace CPP_VERSION {


using namespace ::android::hardware::audio::effect::CPP_VERSION;

class EffectHalHidl : public EffectHalInterface
class EffectHalHidl : public EffectHalInterface
{
{
  public:
  public:
@@ -70,7 +68,7 @@ class EffectHalHidl : public EffectHalInterface


  private:
  private:
    friend class EffectsFactoryHalHidl;
    friend class EffectsFactoryHalHidl;
    typedef MessageQueue<EffectResult, hardware::kSynchronizedReadWrite> StatusMQ;
    typedef MessageQueue<Result, hardware::kSynchronizedReadWrite> StatusMQ;


    sp<IEffect> mEffect;
    sp<IEffect> mEffect;
    const uint64_t mEffectId;
    const uint64_t mEffectId;
@@ -80,7 +78,7 @@ class EffectHalHidl : public EffectHalInterface
    std::unique_ptr<StatusMQ> mStatusMQ;
    std::unique_ptr<StatusMQ> mStatusMQ;
    EventFlag* mEfGroup;
    EventFlag* mEfGroup;


    static status_t analyzeResult(const EffectResult& result);
    static status_t analyzeResult(const Result& result);
    static void effectBufferConfigFromHal(
    static void effectBufferConfigFromHal(
            const buffer_config_t& halConfig, EffectBufferConfig* config);
            const buffer_config_t& halConfig, EffectBufferConfig* config);
    static void effectBufferConfigToHal(
    static void effectBufferConfigToHal(
@@ -105,6 +103,7 @@ class EffectHalHidl : public EffectHalInterface
};
};


} // namespace CPP_VERSION
} // namespace CPP_VERSION
} // namespace effect
} // namespace android
} // namespace android


#endif // ANDROID_HARDWARE_EFFECT_HAL_HIDL_H
#endif // ANDROID_HARDWARE_EFFECT_HAL_HIDL_H
Loading