mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
AHAL: fix StreamUsb crash. am: fdee322c96
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2504016 Change-Id: Ie5fdfc0f5e1f3094ef62b66f10c9aace2b6af98b Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -56,7 +56,7 @@ class DriverUsb : public DriverInterface {
|
||||
std::vector<::aidl::android::media::audio::common::AudioDeviceAddress> mConnectedDevices
|
||||
GUARDED_BY(mLock);
|
||||
std::vector<std::shared_ptr<alsa_device_proxy>> mAlsaDeviceProxies GUARDED_BY(mLock);
|
||||
bool mIsStandby = false;
|
||||
bool mIsStandby = true;
|
||||
};
|
||||
|
||||
class StreamInUsb final : public StreamIn {
|
||||
|
||||
@@ -107,10 +107,13 @@ DriverUsb::DriverUsb(const StreamContext& context, bool isInput)
|
||||
::android::status_t DriverUsb::transfer(void* buffer, size_t frameCount, size_t* actualFrameCount,
|
||||
int32_t* latencyMs) {
|
||||
if (!mConfig.has_value() || mConnectedDevices.empty()) {
|
||||
LOG(ERROR) << __func__ << ": failed, has config: " << mConfig.has_value()
|
||||
<< ", has connected devices: " << mConnectedDevices.empty();
|
||||
return ::android::NO_INIT;
|
||||
}
|
||||
if (mIsStandby) {
|
||||
if (::android::status_t status = exitStandby(); status != ::android::OK) {
|
||||
LOG(ERROR) << __func__ << ": failed to exit standby, status=" << status;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@@ -151,6 +154,7 @@ DriverUsb::DriverUsb(const StreamContext& context, bool isInput)
|
||||
std::vector<std::shared_ptr<alsa_device_proxy>> alsaDeviceProxies;
|
||||
for (const auto& device : connectedDevices) {
|
||||
alsa_device_profile profile;
|
||||
profile_init(&profile, mIsInput ? PCM_IN : PCM_OUT);
|
||||
profile.card = device.get<AudioDeviceAddress::alsa>()[0];
|
||||
profile.device = device.get<AudioDeviceAddress::alsa>()[1];
|
||||
if (!profile_read_device_info(&profile)) {
|
||||
@@ -174,6 +178,11 @@ DriverUsb::DriverUsb(const StreamContext& context, bool isInput)
|
||||
<< " error=" << err;
|
||||
return ::android::UNKNOWN_ERROR;
|
||||
}
|
||||
if (int err = proxy_open(proxy.get()); err != 0) {
|
||||
LOG(ERROR) << __func__ << ": failed to open device, address=" << device.toString()
|
||||
<< " error=" << err;
|
||||
return ::android::UNKNOWN_ERROR;
|
||||
}
|
||||
alsaDeviceProxies.push_back(std::move(proxy));
|
||||
}
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user