From f811acf049b785ccce05a9fca9e01aa2031ab357 Mon Sep 17 00:00:00 2001 From: Mikhail Naganov Date: Wed, 31 May 2017 19:59:21 +0000 Subject: [PATCH] Revert "audiohal: Add diagnostics to investigate HAL call crashes" This reverts commit 6c0f76a684bc58eb10181f71d9f45c5799ca7c6a. Since the root cause of the crash has been established, there is no need to keep this code around. Bug: 36225019 Change-Id: I74e570e863a0cdec5d9029f1672e2e8066c246b5 --- audio/2.0/default/Device.cpp | 59 ++-------------------------- audio/2.0/default/Device.h | 9 ++--- audio/2.0/default/DevicesFactory.cpp | 2 +- audio/2.0/default/PrimaryDevice.cpp | 3 +- 4 files changed, 10 insertions(+), 63 deletions(-) diff --git a/audio/2.0/default/Device.cpp b/audio/2.0/default/Device.cpp index da792384eb..b696d94b8b 100644 --- a/audio/2.0/default/Device.cpp +++ b/audio/2.0/default/Device.cpp @@ -17,11 +17,9 @@ #define LOG_TAG "DeviceHAL" //#define LOG_NDEBUG 0 +#include #include #include -#include -#include -#include #include @@ -37,57 +35,8 @@ namespace audio { namespace V2_0 { namespace implementation { -namespace { - -class Diagnostics { - public: - static Diagnostics& getInstance() { - std::lock_guard _(mLock); - if (mInstance == nullptr) { - mInstance = new Diagnostics; - } - return *mInstance; - } - - void registerDevice(Device* dev) { - std::lock_guard _(mLock); - mDevices.push_back(wp(dev)); - } - - void checkForErasedHalCblk(const Device* dev) { - if (dev->version() != 0) return; // all OK - - std::ostringstream ss; - ss << "Zero HAL CB for " << dev->type() << ":" << std::hex - << dev->device() << "; Others: "; - { - std::lock_guard _(mLock); - for (auto wp : mDevices) { - sp other{wp.promote()}; - if (other.get() == nullptr || other.get() == dev) continue; - ss << other->type() << ":" << other->version() << ":" - << std::hex << other->device() << "; "; - } - } - ALOGE("%s", ss.str().c_str()); - } - - private: - Diagnostics() {} - - static std::mutex mLock; - static Diagnostics* mInstance; - std::vector> mDevices; -}; - -std::mutex Diagnostics::mLock; -Diagnostics* Diagnostics::mInstance{nullptr}; - -} // namespace - -Device::Device(audio_hw_device_t* device, const char* type) - : mDevice{device}, mType{type} { - Diagnostics::getInstance().registerDevice(this); +Device::Device(audio_hw_device_t* device) + : mDevice(device) { } Device::~Device() { @@ -119,12 +68,10 @@ void Device::closeOutputStream(audio_stream_out_t* stream) { } char* Device::halGetParameters(const char* keys) { - Diagnostics::getInstance().checkForErasedHalCblk(this); return mDevice->get_parameters(mDevice, keys); } int Device::halSetParameters(const char* keysAndValues) { - Diagnostics::getInstance().checkForErasedHalCblk(this); return mDevice->set_parameters(mDevice, keysAndValues); } diff --git a/audio/2.0/default/Device.h b/audio/2.0/default/Device.h index 55bd0ab960..7738361075 100644 --- a/audio/2.0/default/Device.h +++ b/audio/2.0/default/Device.h @@ -56,7 +56,7 @@ using ::android::hardware::hidl_string; using ::android::sp; struct Device : public IDevice, public ParametersUtil { - Device(audio_hw_device_t* device, const char* type); + explicit Device(audio_hw_device_t* device); // Methods from ::android::hardware::audio::V2_0::IDevice follow. Return initCheck() override; @@ -101,18 +101,17 @@ struct Device : public IDevice, public ParametersUtil { void closeInputStream(audio_stream_in_t* stream); void closeOutputStream(audio_stream_out_t* stream); audio_hw_device_t* device() const { return mDevice; } - const char* type() const { return mType; } - uint32_t version() const { return mDevice->common.version; } - private: + private: audio_hw_device_t *mDevice; - const char* mType; virtual ~Device(); // Methods from ParametersUtil. char* halGetParameters(const char* keys) override; int halSetParameters(const char* keysAndValues) override; + + uint32_t version() const { return mDevice->common.version; } }; } // namespace implementation diff --git a/audio/2.0/default/DevicesFactory.cpp b/audio/2.0/default/DevicesFactory.cpp index b344968dd9..b913bc799d 100644 --- a/audio/2.0/default/DevicesFactory.cpp +++ b/audio/2.0/default/DevicesFactory.cpp @@ -86,7 +86,7 @@ Return DevicesFactory::openDevice(IDevicesFactory::Device device, openDevi result = new PrimaryDevice(halDevice); } else { result = new ::android::hardware::audio::V2_0::implementation:: - Device(halDevice, moduleName); + Device(halDevice); } retval = Result::OK; } else if (halStatus == -EINVAL) { diff --git a/audio/2.0/default/PrimaryDevice.cpp b/audio/2.0/default/PrimaryDevice.cpp index af0b249f72..905203b539 100644 --- a/audio/2.0/default/PrimaryDevice.cpp +++ b/audio/2.0/default/PrimaryDevice.cpp @@ -25,7 +25,8 @@ namespace V2_0 { namespace implementation { PrimaryDevice::PrimaryDevice(audio_hw_device_t* device) - : mDevice{new Device(device, AUDIO_HARDWARE_MODULE_ID_PRIMARY)} {} + : mDevice(new Device(device)) { +} PrimaryDevice::~PrimaryDevice() {}