audiohal: Add diagnostics to investigate HAL call crashes
This is intended to clarify whether surprising zeroing out of HAL
control structures happens to a particular HAL module, or to any
HAL module at random.
Unfortunately, the crash itself can't be prevented as
audioflinger can't work around a HAL outage, and needs to be
restarted anyway.
Bug: 36225019
Test: verified that the logged string contains the information
Change-Id: I5843d89b4e5385b4ce269f72b5891ccb646daeba
diff --git a/audio/2.0/default/Device.h b/audio/2.0/default/Device.h
index 7738361..55bd0ab 100644
--- a/audio/2.0/default/Device.h
+++ b/audio/2.0/default/Device.h
@@ -56,7 +56,7 @@
using ::android::sp;
struct Device : public IDevice, public ParametersUtil {
- explicit Device(audio_hw_device_t* device);
+ Device(audio_hw_device_t* device, const char* type);
// Methods from ::android::hardware::audio::V2_0::IDevice follow.
Return<Result> initCheck() override;
@@ -101,17 +101,18 @@
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