Fix segfault in Primary audio hal hidl wrapper getDevice
Test: run the corresponding vts test
Test: vts-tradefed r vts-hal-hidl -m VtsHalAudioV2_0Target
Bug: 34170075
Change-Id: I0652f1bf748de99a8a2594630daf5ea2acec8934
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/audio/2.0/default/Stream.cpp b/audio/2.0/default/Stream.cpp
index c16a956..29946fe 100644
--- a/audio/2.0/default/Stream.cpp
+++ b/audio/2.0/default/Stream.cpp
@@ -189,7 +189,9 @@
}
Return<AudioDevice> Stream::getDevice() {
- return AudioDevice(mStream->get_device(mStream));
+ int device;
+ Result retval = getParam(AudioParameter::keyRouting, &device);
+ return retval == Result::OK ? static_cast<AudioDevice>(device) : AudioDevice::NONE;
}
Return<Result> Stream::setDevice(const DeviceAddress& address) {