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

Commit 145313ed authored by Jaideep Sharma's avatar Jaideep Sharma Committed by Mikhail Naganov
Browse files

libaudiohal: Modify logging in DeviceHalAidl/Hal2AidlMapper/StreamHalAidl

DeviceHalAidl API can be used for different modules. Modify the logging pattern to include the module names in DeviceHalAidl/Hal2AidlMapper for better information.

Use function name, instance name information embedded in a macro to maintain consistency in the logs.

Similarly, for Stream classes use ioHandle to identify the stream in use.

Test: run CoreAudioHalAidlTest

Bug: 356310696

Change-Id: I4d96408fb984d37f4ac609a9ee3a6adf8411bd89
parent b75aa6a8
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -25,6 +25,32 @@

namespace android {

/*
 * Helper macro to add instance name, function name in logs
 * classes should provide getInstanceName and getClassName API to use these macros.
 * print function names along with instance name.
 *
 * Usage:
 *  AUGMENT_LOG(I, "hello!");
 *  AUGMENT_LOG(W, "value: %d", value);
 *
 * AUGMENT_LOG_IF(D, value < 0, "negative");
 * AUGMENT_LOG_IF(E, value < 0, "bad value: %d", value);
 */

#define AUGMENT_LOG(level, ...)                                                              \
    ALOG##level("[%s] %s: " __android_second(0, __VA_ARGS__, ""), getInstanceName().c_str(), \
                __func__ __android_rest(__VA_ARGS__))

#define AUGMENT_LOG_IF(level, cond, ...)                                     \
    ALOG##level##_IF(cond, "[%s] %s: " __android_second(0, __VA_ARGS__, ""), \
                     getInstanceName().c_str(), __func__ __android_rest(__VA_ARGS__))
// Used to register an entry into the function
#define LOG_ENTRY() ALOGD("[%s] %s", getInstanceName().c_str(), __func__)

// entry logging as verbose level
#define LOG_ENTRY_V() ALOGV("[%s] %s", getInstanceName().c_str(), __func__)

class HalDeathHandler {
  public:
    static HalDeathHandler& getInstance();
+6 −4
Original line number Diff line number Diff line
@@ -49,13 +49,15 @@ class Args {

class ConversionHelperAidl {
  protected:
    ConversionHelperAidl(std::string_view className) : mClassName(className) {}
    ConversionHelperAidl(std::string_view className, std::string_view instanceName)
        : mClassName(className), mInstanceName(instanceName) {}

    const std::string& getClassName() const {
        return mClassName;
    }
    const std::string& getClassName() const { return mClassName; }

    const std::string& getInstanceName() const { return mInstanceName; }

    const std::string mClassName;
    const std::string mInstanceName;
};

// 'action' must accept a value of type 'T' and return 'status_t'.
+376 −303

File changed.

Preview size limit exceeded, changes collapsed.

+0 −1
Original line number Diff line number Diff line
@@ -235,7 +235,6 @@ class DeviceHalAidl : public DeviceHalInterface, public ConversionHelperAidl,
    // MicrophoneInfoProvider implementation
    MicrophoneInfoProvider::Info const* getMicrophoneInfo() override;

    const std::string mInstance;
    const std::shared_ptr<::aidl::android::hardware::audio::core::IModule> mModule;
    const std::shared_ptr<::aidl::android::media::audio::IHalAdapterVendorExtension> mVendorExt;
    const std::shared_ptr<::aidl::android::hardware::audio::core::ITelephony> mTelephony;
+82 −83

File changed.

Preview size limit exceeded, changes collapsed.

Loading