From 312d5427c0fb1f24bdbfc33a92a6bdec29a9bdf8 Mon Sep 17 00:00:00 2001 From: Mikhail Naganov Date: Tue, 18 Jul 2023 10:31:37 -0700 Subject: [PATCH] audioserver: Improve logging / dumping for encoded formats The "encoded formats" field of device ports was lacking from the APM dump. In the audio flinger, log the encoded format used to find a module for a device type. Bug: 291543025 Test: adb shell dumpsys media.audio_policy Change-Id: Ic02dddc474b2f8a069467fc72733a268a14fb995 --- media/libaudiofoundation/DeviceDescriptorBase.cpp | 9 +++++++++ .../common/managerdefinitions/src/HwModule.cpp | 14 ++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/media/libaudiofoundation/DeviceDescriptorBase.cpp b/media/libaudiofoundation/DeviceDescriptorBase.cpp index 9ffc75ba12..824bfce8c8 100644 --- a/media/libaudiofoundation/DeviceDescriptorBase.cpp +++ b/media/libaudiofoundation/DeviceDescriptorBase.cpp @@ -125,6 +125,15 @@ void DeviceDescriptorBase::dump(std::string *dst, int spaces, dst->append(base::StringPrintf( "%*sEncapsulation modes: %u, metadata types: %u\n", spaces, "", mEncapsulationModes, mEncapsulationMetadataTypes)); + if (!mEncodedFormats.empty()) { + std::string s; + for (const auto& format : mEncodedFormats) { + if (!s.empty()) s.append(", "); + s.append(audio_format_to_string(format)); + } + dst->append(base::StringPrintf( + "%*sEncoded formats: %s\n", spaces, "", s.c_str())); + } AudioPort::dump(dst, spaces, nullptr, verbose); } diff --git a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp index 5f14ee4623..95f8d141c4 100644 --- a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp +++ b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp @@ -383,8 +383,8 @@ sp HwModuleCollection::getDeviceDescriptor(const audio_devices } } if (!allowToCreate) { - ALOGV("%s: could not find HW module for device %s %04x address %s", __FUNCTION__, - name, deviceType, address); + ALOGW("%s: could not find HW module for device %s (%s, %08x) address %s", __FUNCTION__, + name, audio_device_to_string(deviceType), deviceType, address); return nullptr; } return createDevice(deviceType, address, name, encodedFormat); @@ -398,8 +398,14 @@ sp HwModuleCollection::createDevice(const audio_devices_t type std::string tagName = {}; sp hwModule = getModuleForDeviceType(type, encodedFormat, &tagName); if (hwModule == 0) { - ALOGE("%s: could not find HW module for device %04x address %s", __FUNCTION__, type, - address); + if (encodedFormat == AUDIO_FORMAT_DEFAULT) { + ALOGE("%s: could not find HW module for device type '%s' (%08x)", + __FUNCTION__, audio_device_to_string(type), type); + } else { + ALOGE("%s: could not find HW module for device type '%s' (%08x), " + "encoded format '%s'", __FUNCTION__, audio_device_to_string(type), type, + audio_format_to_string(encodedFormat)); + } return nullptr; } -- GitLab