Merge "audio:aidl: Use module type in log prints" into main
diff --git a/audio/aidl/default/Module.cpp b/audio/aidl/default/Module.cpp
index 6bbdb1a..d48729f 100644
--- a/audio/aidl/default/Module.cpp
+++ b/audio/aidl/default/Module.cpp
@@ -173,7 +173,8 @@
         std::shared_ptr<IStreamCallback> asyncCallback,
         std::shared_ptr<IStreamOutEventCallback> outEventCallback, StreamContext* out_context) {
     if (in_bufferSizeFrames <= 0) {
-        LOG(ERROR) << __func__ << ": non-positive buffer size " << in_bufferSizeFrames;
+        LOG(ERROR) << __func__ << ": " << mType << ": non-positive buffer size "
+                   << in_bufferSizeFrames;
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     auto& configs = getConfig().portConfigs;
@@ -184,20 +185,21 @@
     const int32_t minimumStreamBufferSizeFrames =
             calculateBufferSizeFrames(nominalLatencyMs, portConfigIt->sampleRate.value().value);
     if (in_bufferSizeFrames < minimumStreamBufferSizeFrames) {
-        LOG(ERROR) << __func__ << ": insufficient buffer size " << in_bufferSizeFrames
-                   << ", must be at least " << minimumStreamBufferSizeFrames;
+        LOG(ERROR) << __func__ << ": " << mType << ": insufficient buffer size "
+                   << in_bufferSizeFrames << ", must be at least " << minimumStreamBufferSizeFrames;
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     const size_t frameSize =
             getFrameSizeInBytes(portConfigIt->format.value(), portConfigIt->channelMask.value());
     if (frameSize == 0) {
-        LOG(ERROR) << __func__ << ": could not calculate frame size for port config "
+        LOG(ERROR) << __func__ << ": " << mType
+                   << ": could not calculate frame size for port config "
                    << portConfigIt->toString();
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
-    LOG(DEBUG) << __func__ << ": frame size " << frameSize << " bytes";
+    LOG(DEBUG) << __func__ << ": " << mType << ": frame size " << frameSize << " bytes";
     if (frameSize > static_cast<size_t>(kMaximumStreamBufferSizeBytes / in_bufferSizeFrames)) {
-        LOG(ERROR) << __func__ << ": buffer size " << in_bufferSizeFrames
+        LOG(ERROR) << __func__ << ": " << mType << ": buffer size " << in_bufferSizeFrames
                    << " frames is too large, maximum size is "
                    << kMaximumStreamBufferSizeBytes / frameSize;
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
@@ -256,7 +258,8 @@
     for (auto it = patchIdsRange.first; it != patchIdsRange.second; ++it) {
         auto patchIt = findById<AudioPatch>(patches, it->second);
         if (patchIt == patches.end()) {
-            LOG(FATAL) << __func__ << ": patch with id " << it->second << " taken from mPatches "
+            LOG(FATAL) << __func__ << ": " << mType << ": patch with id " << it->second
+                       << " taken from mPatches "
                        << "not found in the configuration";
         }
         if (std::find(patchIt->sourcePortConfigIds.begin(), patchIt->sourcePortConfigIds.end(),
@@ -273,7 +276,8 @@
     auto& configs = getConfig().portConfigs;
     auto portConfigIt = findById<AudioPortConfig>(configs, in_portConfigId);
     if (portConfigIt == configs.end()) {
-        LOG(ERROR) << __func__ << ": existing port config id " << in_portConfigId << " not found";
+        LOG(ERROR) << __func__ << ": " << mType << ": existing port config id " << in_portConfigId
+                   << " not found";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     const int32_t portId = portConfigIt->portId;
@@ -282,23 +286,23 @@
     auto& ports = getConfig().ports;
     auto portIt = findById<AudioPort>(ports, portId);
     if (portIt == ports.end()) {
-        LOG(ERROR) << __func__ << ": port id " << portId << " used by port config id "
-                   << in_portConfigId << " not found";
+        LOG(ERROR) << __func__ << ": " << mType << ": port id " << portId
+                   << " used by port config id " << in_portConfigId << " not found";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     if (mStreams.count(in_portConfigId) != 0) {
-        LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
+        LOG(ERROR) << __func__ << ": " << mType << ": port config id " << in_portConfigId
                    << " already has a stream opened on it";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
     }
     if (portIt->ext.getTag() != AudioPortExt::Tag::mix) {
-        LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
+        LOG(ERROR) << __func__ << ": " << mType << ": port config id " << in_portConfigId
                    << " does not correspond to a mix port";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     const size_t maxOpenStreamCount = portIt->ext.get<AudioPortExt::Tag::mix>().maxOpenStreamCount;
     if (maxOpenStreamCount != 0 && mStreams.count(portId) >= maxOpenStreamCount) {
-        LOG(ERROR) << __func__ << ": port id " << portId
+        LOG(ERROR) << __func__ << ": " << mType << ": port id " << portId
                    << " has already reached maximum allowed opened stream count: "
                    << maxOpenStreamCount;
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
@@ -326,7 +330,7 @@
         config->ext = port.ext;
         return true;
     }
-    LOG(ERROR) << __func__ << ": port " << port.id << " only has dynamic profiles";
+    LOG(ERROR) << __func__ << ": " << mType << ": port " << port.id << " only has dynamic profiles";
     return false;
 }
 
@@ -493,7 +497,8 @@
         }
     });
     if (!maybeFailure.isOk()) {
-        LOG(WARNING) << __func__ << ": Due to a failure, disconnecting streams on port config ids "
+        LOG(WARNING) << __func__ << ": " << mType
+                     << ": Due to a failure, disconnecting streams on port config ids "
                      << ::android::internal::ToString(idsToDisconnectOnFailure);
         std::for_each(idsToDisconnectOnFailure.begin(), idsToDisconnectOnFailure.end(),
                       [&](const auto& portConfigId) {
@@ -512,7 +517,8 @@
     if (mDebug.simulateDeviceConnections != in_debug.simulateDeviceConnections &&
         !mConnectedDevicePorts.empty()) {
         LOG(ERROR) << __func__ << ": " << mType
-                   << ": attempting to change device connections simulation while having external "
+                   << ": attempting to change device connections simulation while "
+                      "having external "
                    << "devices connected";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
     }
@@ -527,25 +533,25 @@
 
 ndk::ScopedAStatus Module::getTelephony(std::shared_ptr<ITelephony>* _aidl_return) {
     *_aidl_return = nullptr;
-    LOG(DEBUG) << __func__ << ": returning null";
+    LOG(DEBUG) << __func__ << ": " << mType << ": returning null";
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::getBluetooth(std::shared_ptr<IBluetooth>* _aidl_return) {
     *_aidl_return = nullptr;
-    LOG(DEBUG) << __func__ << ": returning null";
+    LOG(DEBUG) << __func__ << ": " << mType << ": returning null";
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::getBluetoothA2dp(std::shared_ptr<IBluetoothA2dp>* _aidl_return) {
     *_aidl_return = nullptr;
-    LOG(DEBUG) << __func__ << ": returning null";
+    LOG(DEBUG) << __func__ << ": " << mType << ": returning null";
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::getBluetoothLe(std::shared_ptr<IBluetoothLe>* _aidl_return) {
     *_aidl_return = nullptr;
-    LOG(DEBUG) << __func__ << ": returning null";
+    LOG(DEBUG) << __func__ << ": " << mType << ": returning null";
     return ndk::ScopedAStatus::ok();
 }
 
@@ -557,20 +563,23 @@
     {  // Scope the template port so that we don't accidentally modify it.
         auto templateIt = findById<AudioPort>(ports, templateId);
         if (templateIt == ports.end()) {
-            LOG(ERROR) << __func__ << ": port id " << templateId << " not found";
+            LOG(ERROR) << __func__ << ": " << mType << ": port id " << templateId << " not found";
             return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
         }
         if (templateIt->ext.getTag() != AudioPortExt::Tag::device) {
-            LOG(ERROR) << __func__ << ": port id " << templateId << " is not a device port";
+            LOG(ERROR) << __func__ << ": " << mType << ": port id " << templateId
+                       << " is not a device port";
             return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
         }
         auto& templateDevicePort = templateIt->ext.get<AudioPortExt::Tag::device>();
         if (templateDevicePort.device.type.connection.empty()) {
-            LOG(ERROR) << __func__ << ": port id " << templateId << " is permanently attached";
+            LOG(ERROR) << __func__ << ": " << mType << ": port id " << templateId
+                       << " is permanently attached";
             return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
         }
         if (mConnectedDevicePorts.find(templateId) != mConnectedDevicePorts.end()) {
-            LOG(ERROR) << __func__ << ": port id " << templateId << " is a connected device port";
+            LOG(ERROR) << __func__ << ": " << mType << ": port id " << templateId
+                       << " is a connected device port";
             return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
         }
         // Postpone id allocation until we ensure that there are no client errors.
@@ -580,14 +589,16 @@
                 in_templateIdAndAdditionalData.ext.get<AudioPortExt::Tag::device>();
         auto& connectedDevicePort = connectedPort.ext.get<AudioPortExt::Tag::device>();
         connectedDevicePort.device.address = inputDevicePort.device.address;
-        LOG(DEBUG) << __func__ << ": device port " << connectedPort.id << " device set to "
-                   << connectedDevicePort.device.toString();
+        LOG(DEBUG) << __func__ << ": " << mType << ": device port " << connectedPort.id
+                   << " device set to " << connectedDevicePort.device.toString();
         // Check if there is already a connected port with for the same external device.
+
         for (auto connectedPortPair : mConnectedDevicePorts) {
             auto connectedPortIt = findById<AudioPort>(ports, connectedPortPair.first);
             if (connectedPortIt->ext.get<AudioPortExt::Tag::device>().device ==
                 connectedDevicePort.device) {
-                LOG(ERROR) << __func__ << ": device " << connectedDevicePort.device.toString()
+                LOG(ERROR) << __func__ << ": " << mType << ": device "
+                           << connectedDevicePort.device.toString()
                            << " is already connected at the device port id "
                            << connectedPortPair.first;
                 return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
@@ -639,7 +650,8 @@
                                                             hasDynamicProfilesOnly(p.profiles);
                                                  });
             dynamicMixPortIt != ports.end()) {
-            LOG(ERROR) << __func__ << ": connected port only has dynamic profiles after connecting "
+            LOG(ERROR) << __func__ << ": " << mType
+                       << ": connected port only has dynamic profiles after connecting "
                        << "external device " << connectedPort.toString() << ", and there exist "
                        << "a routable mix port with dynamic profiles: "
                        << dynamicMixPortIt->toString();
@@ -650,7 +662,8 @@
     connectedPort.id = nextPortId;
     auto [connectedPortsIt, _] =
             mConnectedDevicePorts.insert(std::pair(connectedPort.id, std::set<int32_t>()));
-    LOG(DEBUG) << __func__ << ": template port " << templateId << " external device connected, "
+    LOG(DEBUG) << __func__ << ": " << mType << ": template port " << templateId
+               << " external device connected, "
                << "connected port ID " << connectedPort.id;
     ports.push_back(connectedPort);
     onExternalDeviceConnectionChanged(connectedPort, true /*connected*/);
@@ -700,16 +713,18 @@
     auto& ports = getConfig().ports;
     auto portIt = findById<AudioPort>(ports, in_portId);
     if (portIt == ports.end()) {
-        LOG(ERROR) << __func__ << ": port id " << in_portId << " not found";
+        LOG(ERROR) << __func__ << ": " << mType << ": port id " << in_portId << " not found";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     if (portIt->ext.getTag() != AudioPortExt::Tag::device) {
-        LOG(ERROR) << __func__ << ": port id " << in_portId << " is not a device port";
+        LOG(ERROR) << __func__ << ": " << mType << ": port id " << in_portId
+                   << " is not a device port";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     auto connectedPortsIt = mConnectedDevicePorts.find(in_portId);
     if (connectedPortsIt == mConnectedDevicePorts.end()) {
-        LOG(ERROR) << __func__ << ": port id " << in_portId << " is not a connected device port";
+        LOG(ERROR) << __func__ << ": " << mType << ": port id " << in_portId
+                   << " is not a connected device port";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     auto& configs = getConfig().portConfigs;
@@ -723,13 +738,14 @@
         return false;
     });
     if (configIt != configs.end()) {
-        LOG(ERROR) << __func__ << ": port id " << in_portId << " has a non-default config with id "
-                   << configIt->id;
+        LOG(ERROR) << __func__ << ": " << mType << ": port id " << in_portId
+                   << " has a non-default config with id " << configIt->id;
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
     }
     onExternalDeviceConnectionChanged(*portIt, false /*connected*/);
     ports.erase(portIt);
-    LOG(DEBUG) << __func__ << ": connected device port " << in_portId << " released";
+    LOG(DEBUG) << __func__ << ": " << mType << ": connected device port " << in_portId
+               << " released";
 
     auto& routes = getConfig().routes;
     for (auto routesIt = routes.begin(); routesIt != routes.end();) {
@@ -765,16 +781,18 @@
     auto& ports = getConfig().ports;
     auto portIt = findById<AudioPort>(ports, in_portId);
     if (portIt == ports.end()) {
-        LOG(ERROR) << __func__ << ": port id " << in_portId << " not found";
+        LOG(ERROR) << __func__ << ": " << mType << ": port id " << in_portId << " not found";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     if (portIt->ext.getTag() != AudioPortExt::Tag::device) {
-        LOG(ERROR) << __func__ << ": port id " << in_portId << " is not a device port";
+        LOG(ERROR) << __func__ << ": " << mType << ": port id " << in_portId
+                   << " is not a device port";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     auto connectedPortsIt = mConnectedDevicePorts.find(in_portId);
     if (connectedPortsIt == mConnectedDevicePorts.end()) {
-        LOG(ERROR) << __func__ << ": port id " << in_portId << " is not a connected device port";
+        LOG(ERROR) << __func__ << ": " << mType << ": port id " << in_portId
+                   << " is not a connected device port";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
 
@@ -785,7 +803,7 @@
 
 ndk::ScopedAStatus Module::getAudioPatches(std::vector<AudioPatch>* _aidl_return) {
     *_aidl_return = getConfig().patches;
-    LOG(DEBUG) << __func__ << ": returning " << _aidl_return->size() << " patches";
+    LOG(DEBUG) << __func__ << ": " << mType << ": returning " << _aidl_return->size() << " patches";
     return ndk::ScopedAStatus::ok();
 }
 
@@ -794,28 +812,29 @@
     auto portIt = findById<AudioPort>(ports, in_portId);
     if (portIt != ports.end()) {
         *_aidl_return = *portIt;
-        LOG(DEBUG) << __func__ << ": returning port by id " << in_portId;
+        LOG(DEBUG) << __func__ << ": " << mType << ": returning port by id " << in_portId;
         return ndk::ScopedAStatus::ok();
     }
-    LOG(ERROR) << __func__ << ": port id " << in_portId << " not found";
+    LOG(ERROR) << __func__ << ": " << mType << ": port id " << in_portId << " not found";
     return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
 }
 
 ndk::ScopedAStatus Module::getAudioPortConfigs(std::vector<AudioPortConfig>* _aidl_return) {
     *_aidl_return = getConfig().portConfigs;
-    LOG(DEBUG) << __func__ << ": returning " << _aidl_return->size() << " port configs";
+    LOG(DEBUG) << __func__ << ": " << mType << ": returning " << _aidl_return->size()
+               << " port configs";
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::getAudioPorts(std::vector<AudioPort>* _aidl_return) {
     *_aidl_return = getConfig().ports;
-    LOG(DEBUG) << __func__ << ": returning " << _aidl_return->size() << " ports";
+    LOG(DEBUG) << __func__ << ": " << mType << ": returning " << _aidl_return->size() << " ports";
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::getAudioRoutes(std::vector<AudioRoute>* _aidl_return) {
     *_aidl_return = getConfig().routes;
-    LOG(DEBUG) << __func__ << ": returning " << _aidl_return->size() << " routes";
+    LOG(DEBUG) << __func__ << ": " << mType << ": returning " << _aidl_return->size() << " routes";
     return ndk::ScopedAStatus::ok();
 }
 
@@ -823,7 +842,7 @@
                                                       std::vector<AudioRoute>* _aidl_return) {
     auto& ports = getConfig().ports;
     if (auto portIt = findById<AudioPort>(ports, in_portId); portIt == ports.end()) {
-        LOG(ERROR) << __func__ << ": port id " << in_portId << " not found";
+        LOG(ERROR) << __func__ << ": " << mType << ": port id " << in_portId << " not found";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     std::vector<AudioRoute*> routes = getAudioRoutesForAudioPortImpl(in_portId);
@@ -834,12 +853,12 @@
 
 ndk::ScopedAStatus Module::openInputStream(const OpenInputStreamArguments& in_args,
                                            OpenInputStreamReturn* _aidl_return) {
-    LOG(DEBUG) << __func__ << ": port config id " << in_args.portConfigId << ", buffer size "
-               << in_args.bufferSizeFrames << " frames";
+    LOG(DEBUG) << __func__ << ": " << mType << ": port config id " << in_args.portConfigId
+               << ", buffer size " << in_args.bufferSizeFrames << " frames";
     AudioPort* port = nullptr;
     RETURN_STATUS_IF_ERROR(findPortIdForNewStream(in_args.portConfigId, &port));
     if (port->flags.getTag() != AudioIoFlags::Tag::input) {
-        LOG(ERROR) << __func__ << ": port config id " << in_args.portConfigId
+        LOG(ERROR) << __func__ << ": " << mType << ": port config id " << in_args.portConfigId
                    << " does not correspond to an input mix port";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
@@ -864,27 +883,27 @@
 
 ndk::ScopedAStatus Module::openOutputStream(const OpenOutputStreamArguments& in_args,
                                             OpenOutputStreamReturn* _aidl_return) {
-    LOG(DEBUG) << __func__ << ": port config id " << in_args.portConfigId << ", has offload info? "
-               << (in_args.offloadInfo.has_value()) << ", buffer size " << in_args.bufferSizeFrames
-               << " frames";
+    LOG(DEBUG) << __func__ << ": " << mType << ": port config id " << in_args.portConfigId
+               << ", has offload info? " << (in_args.offloadInfo.has_value()) << ", buffer size "
+               << in_args.bufferSizeFrames << " frames";
     AudioPort* port = nullptr;
     RETURN_STATUS_IF_ERROR(findPortIdForNewStream(in_args.portConfigId, &port));
     if (port->flags.getTag() != AudioIoFlags::Tag::output) {
-        LOG(ERROR) << __func__ << ": port config id " << in_args.portConfigId
+        LOG(ERROR) << __func__ << ": " << mType << ": port config id " << in_args.portConfigId
                    << " does not correspond to an output mix port";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     const bool isOffload = isBitPositionFlagSet(port->flags.get<AudioIoFlags::Tag::output>(),
                                                 AudioOutputFlags::COMPRESS_OFFLOAD);
     if (isOffload && !in_args.offloadInfo.has_value()) {
-        LOG(ERROR) << __func__ << ": port id " << port->id
+        LOG(ERROR) << __func__ << ": " << mType << ": port id " << port->id
                    << " has COMPRESS_OFFLOAD flag set, requires offload info";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     const bool isNonBlocking = isBitPositionFlagSet(port->flags.get<AudioIoFlags::Tag::output>(),
                                                     AudioOutputFlags::NON_BLOCKING);
     if (isNonBlocking && in_args.callback == nullptr) {
-        LOG(ERROR) << __func__ << ": port id " << port->id
+        LOG(ERROR) << __func__ << ": " << mType << ": port id " << port->id
                    << " has NON_BLOCKING flag set, requires async callback";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
@@ -910,27 +929,29 @@
 
 ndk::ScopedAStatus Module::getSupportedPlaybackRateFactors(
         SupportedPlaybackRateFactors* _aidl_return) {
-    LOG(DEBUG) << __func__;
+    LOG(DEBUG) << __func__ << ": " << mType;
     (void)_aidl_return;
     return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
 }
 
 ndk::ScopedAStatus Module::setAudioPatch(const AudioPatch& in_requested, AudioPatch* _aidl_return) {
-    LOG(DEBUG) << __func__ << ": requested patch " << in_requested.toString();
+    LOG(DEBUG) << __func__ << ": " << mType << ": requested patch " << in_requested.toString();
     if (in_requested.sourcePortConfigIds.empty()) {
-        LOG(ERROR) << __func__ << ": requested patch has empty sources list";
+        LOG(ERROR) << __func__ << ": " << mType << ": requested patch has empty sources list";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     if (!all_unique<int32_t>(in_requested.sourcePortConfigIds)) {
-        LOG(ERROR) << __func__ << ": requested patch has duplicate ids in the sources list";
+        LOG(ERROR) << __func__ << ": " << mType
+                   << ": requested patch has duplicate ids in the sources list";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     if (in_requested.sinkPortConfigIds.empty()) {
-        LOG(ERROR) << __func__ << ": requested patch has empty sinks list";
+        LOG(ERROR) << __func__ << ": " << mType << ": requested patch has empty sinks list";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     if (!all_unique<int32_t>(in_requested.sinkPortConfigIds)) {
-        LOG(ERROR) << __func__ << ": requested patch has duplicate ids in the sinks list";
+        LOG(ERROR) << __func__ << ": " << mType
+                   << ": requested patch has duplicate ids in the sinks list";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
 
@@ -939,13 +960,13 @@
     auto sources =
             selectByIds<AudioPortConfig>(configs, in_requested.sourcePortConfigIds, &missingIds);
     if (!missingIds.empty()) {
-        LOG(ERROR) << __func__ << ": following source port config ids not found: "
+        LOG(ERROR) << __func__ << ": " << mType << ": following source port config ids not found: "
                    << ::android::internal::ToString(missingIds);
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     auto sinks = selectByIds<AudioPortConfig>(configs, in_requested.sinkPortConfigIds, &missingIds);
     if (!missingIds.empty()) {
-        LOG(ERROR) << __func__ << ": following sink port config ids not found: "
+        LOG(ERROR) << __func__ << ": " << mType << ": following sink port config ids not found: "
                    << ::android::internal::ToString(missingIds);
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
@@ -966,7 +987,8 @@
     }
     for (auto sink : sinks) {
         if (allowedSinkPorts.count(sink->portId) == 0) {
-            LOG(ERROR) << __func__ << ": there is no route to the sink port id " << sink->portId;
+            LOG(ERROR) << __func__ << ": " << mType << ": there is no route to the sink port id "
+                       << sink->portId;
             return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
         }
     }
@@ -981,14 +1003,15 @@
             patchesBackup = mPatches;
             cleanUpPatch(existing->id);
         } else {
-            LOG(ERROR) << __func__ << ": not found existing patch id " << in_requested.id;
+            LOG(ERROR) << __func__ << ": " << mType << ": not found existing patch id "
+                       << in_requested.id;
             return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
         }
     }
     // Validate the requested patch.
     for (const auto& [sinkPortId, nonExclusive] : allowedSinkPorts) {
         if (!nonExclusive && mPatches.count(sinkPortId) != 0) {
-            LOG(ERROR) << __func__ << ": sink port id " << sinkPortId
+            LOG(ERROR) << __func__ << ": " << mType << ": sink port id " << sinkPortId
                        << "is exclusive and is already used by some other patch";
             if (patchesBackup.has_value()) {
                 mPatches = std::move(*patchesBackup);
@@ -1031,8 +1054,8 @@
         return status;
     }
 
-    LOG(DEBUG) << __func__ << ": " << (oldPatch.id == 0 ? "created" : "updated") << " patch "
-               << _aidl_return->toString();
+    LOG(DEBUG) << __func__ << ": " << mType << ": " << (oldPatch.id == 0 ? "created" : "updated")
+               << " patch " << _aidl_return->toString();
     return ndk::ScopedAStatus::ok();
 }
 
@@ -1050,28 +1073,29 @@
                                  ::aidl::android::media::audio::common::AudioPortConfig* config)>&
                 fillPortConfig,
         AudioPortConfig* out_suggested, bool* applied) {
-    LOG(DEBUG) << __func__ << ": requested " << in_requested.toString();
+    LOG(DEBUG) << __func__ << ": " << mType << ": requested " << in_requested.toString();
     auto& configs = getConfig().portConfigs;
     auto existing = configs.end();
     if (in_requested.id != 0) {
         if (existing = findById<AudioPortConfig>(configs, in_requested.id);
             existing == configs.end()) {
-            LOG(ERROR) << __func__ << ": existing port config id " << in_requested.id
-                       << " not found";
+            LOG(ERROR) << __func__ << ": " << mType << ": existing port config id "
+                       << in_requested.id << " not found";
             return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
         }
     }
 
     const int portId = existing != configs.end() ? existing->portId : in_requested.portId;
     if (portId == 0) {
-        LOG(ERROR) << __func__ << ": requested port config does not specify portId";
+        LOG(ERROR) << __func__ << ": " << mType
+                   << ": requested port config does not specify portId";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     auto& ports = getConfig().ports;
     auto portIt = findById<AudioPort>(ports, portId);
     if (portIt == ports.end()) {
-        LOG(ERROR) << __func__ << ": requested port config points to non-existent portId "
-                   << portId;
+        LOG(ERROR) << __func__ << ": " << mType
+                   << ": requested port config points to non-existent portId " << portId;
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     if (existing != configs.end()) {
@@ -1082,7 +1106,8 @@
         if (fillPortConfig(*portIt, &newConfig)) {
             *out_suggested = newConfig;
         } else {
-            LOG(ERROR) << __func__ << ": unable generate a default config for port " << portId;
+            LOG(ERROR) << __func__ << ": " << mType
+                       << ": unable generate a default config for port " << portId;
             return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
         }
     }
@@ -1099,7 +1124,7 @@
     AudioIoFlags portFlags = portIt->flags;
     if (in_requested.flags.has_value()) {
         if (in_requested.flags.value() != portFlags) {
-            LOG(WARNING) << __func__ << ": requested flags "
+            LOG(WARNING) << __func__ << ": " << mType << ": requested flags "
                          << in_requested.flags.value().toString() << " do not match port's "
                          << portId << " flags " << portFlags.toString();
             requestedIsValid = false;
@@ -1115,7 +1140,7 @@
             findAudioProfile(*portIt, format, &portProfile)) {
             out_suggested->format = format;
         } else {
-            LOG(WARNING) << __func__ << ": requested format " << format.toString()
+            LOG(WARNING) << __func__ << ": " << mType << ": requested format " << format.toString()
                          << " is not found in the profiles of port " << portId;
             requestedIsValid = false;
         }
@@ -1124,8 +1149,9 @@
     }
     if (!(out_suggested->format.value() == AudioFormatDescription{} && allowDynamicConfig) &&
         !findAudioProfile(*portIt, out_suggested->format.value(), &portProfile)) {
-        LOG(ERROR) << __func__ << ": port " << portId << " does not support format "
-                   << out_suggested->format.value().toString() << " anymore";
+        LOG(ERROR) << __func__ << ": " << mType << ": port " << portId
+                   << " does not support format " << out_suggested->format.value().toString()
+                   << " anymore";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
 
@@ -1136,9 +1162,9 @@
                     portProfile.channelMasks.end()) {
             out_suggested->channelMask = channelMask;
         } else {
-            LOG(WARNING) << __func__ << ": requested channel mask " << channelMask.toString()
-                         << " is not supported for the format " << portProfile.format.toString()
-                         << " by the port " << portId;
+            LOG(WARNING) << __func__ << ": " << mType << ": requested channel mask "
+                         << channelMask.toString() << " is not supported for the format "
+                         << portProfile.format.toString() << " by the port " << portId;
             requestedIsValid = false;
         }
     } else {
@@ -1152,9 +1178,9 @@
                  sampleRate.value) != portProfile.sampleRates.end()) {
             out_suggested->sampleRate = sampleRate;
         } else {
-            LOG(WARNING) << __func__ << ": requested sample rate " << sampleRate.value
-                         << " is not supported for the format " << portProfile.format.toString()
-                         << " by the port " << portId;
+            LOG(WARNING) << __func__ << ": " << mType << ": requested sample rate "
+                         << sampleRate.value << " is not supported for the format "
+                         << portProfile.format.toString() << " by the port " << portId;
             requestedIsValid = false;
         }
     } else {
@@ -1177,7 +1203,7 @@
                 dst.usecase = src.usecase;
             }
         } else {
-            LOG(WARNING) << __func__ << ": requested ext tag "
+            LOG(WARNING) << __func__ << ": " << mType << ": requested ext tag "
                          << toString(in_requested.ext.getTag()) << " do not match port's tag "
                          << toString(out_suggested->ext.getTag());
             requestedIsValid = false;
@@ -1188,15 +1214,17 @@
         out_suggested->id = getConfig().nextPortId++;
         configs.push_back(*out_suggested);
         *applied = true;
-        LOG(DEBUG) << __func__ << ": created new port config " << out_suggested->toString();
+        LOG(DEBUG) << __func__ << ": " << mType << ": created new port config "
+                   << out_suggested->toString();
     } else if (existing != configs.end() && requestedIsValid) {
         *existing = *out_suggested;
         *applied = true;
-        LOG(DEBUG) << __func__ << ": updated port config " << out_suggested->toString();
+        LOG(DEBUG) << __func__ << ": " << mType << ": updated port config "
+                   << out_suggested->toString();
     } else {
-        LOG(DEBUG) << __func__ << ": not applied; existing config ? " << (existing != configs.end())
-                   << "; requested is valid? " << requestedIsValid << ", fully specified? "
-                   << requestedIsFullySpecified;
+        LOG(DEBUG) << __func__ << ": " << mType << ": not applied; existing config ? "
+                   << (existing != configs.end()) << "; requested is valid? " << requestedIsValid
+                   << ", fully specified? " << requestedIsFullySpecified;
         *applied = false;
     }
     return ndk::ScopedAStatus::ok();
@@ -1213,10 +1241,10 @@
             return status;
         }
         patches.erase(patchIt);
-        LOG(DEBUG) << __func__ << ": erased patch " << in_patchId;
+        LOG(DEBUG) << __func__ << ": " << mType << ": erased patch " << in_patchId;
         return ndk::ScopedAStatus::ok();
     }
-    LOG(ERROR) << __func__ << ": patch id " << in_patchId << " not found";
+    LOG(ERROR) << __func__ << ": " << mType << ": patch id " << in_patchId << " not found";
     return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
 }
 
@@ -1225,13 +1253,13 @@
     auto configIt = findById<AudioPortConfig>(configs, in_portConfigId);
     if (configIt != configs.end()) {
         if (mStreams.count(in_portConfigId) != 0) {
-            LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
+            LOG(ERROR) << __func__ << ": " << mType << ": port config id " << in_portConfigId
                        << " has a stream opened on it";
             return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
         }
         auto patchIt = mPatches.find(in_portConfigId);
         if (patchIt != mPatches.end()) {
-            LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
+            LOG(ERROR) << __func__ << ": " << mType << ": port config id " << in_portConfigId
                        << " is used by the patch with id " << patchIt->second;
             return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
         }
@@ -1239,32 +1267,33 @@
         auto initialIt = findById<AudioPortConfig>(initials, in_portConfigId);
         if (initialIt == initials.end()) {
             configs.erase(configIt);
-            LOG(DEBUG) << __func__ << ": erased port config " << in_portConfigId;
+            LOG(DEBUG) << __func__ << ": " << mType << ": erased port config " << in_portConfigId;
         } else if (*configIt != *initialIt) {
             *configIt = *initialIt;
-            LOG(DEBUG) << __func__ << ": reset port config " << in_portConfigId;
+            LOG(DEBUG) << __func__ << ": " << mType << ": reset port config " << in_portConfigId;
         }
         return ndk::ScopedAStatus::ok();
     }
-    LOG(ERROR) << __func__ << ": port config id " << in_portConfigId << " not found";
+    LOG(ERROR) << __func__ << ": " << mType << ": port config id " << in_portConfigId
+               << " not found";
     return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
 }
 
 ndk::ScopedAStatus Module::getMasterMute(bool* _aidl_return) {
     *_aidl_return = mMasterMute;
-    LOG(DEBUG) << __func__ << ": returning " << *_aidl_return;
+    LOG(DEBUG) << __func__ << ": " << mType << ": returning " << *_aidl_return;
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::setMasterMute(bool in_mute) {
-    LOG(DEBUG) << __func__ << ": " << in_mute;
+    LOG(DEBUG) << __func__ << ": " << mType << ": " << in_mute;
     auto result = mDebug.simulateDeviceConnections ? ndk::ScopedAStatus::ok()
                                                    : onMasterMuteChanged(in_mute);
     if (result.isOk()) {
         mMasterMute = in_mute;
     } else {
-        LOG(ERROR) << __func__ << ": failed calling onMasterMuteChanged(" << in_mute
-                   << "), error=" << result;
+        LOG(ERROR) << __func__ << ": " << mType << ": failed calling onMasterMuteChanged("
+                   << in_mute << "), error=" << result;
         // Reset master mute if it failed.
         onMasterMuteChanged(mMasterMute);
     }
@@ -1273,12 +1302,12 @@
 
 ndk::ScopedAStatus Module::getMasterVolume(float* _aidl_return) {
     *_aidl_return = mMasterVolume;
-    LOG(DEBUG) << __func__ << ": returning " << *_aidl_return;
+    LOG(DEBUG) << __func__ << ": " << mType << ": returning " << *_aidl_return;
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::setMasterVolume(float in_volume) {
-    LOG(DEBUG) << __func__ << ": " << in_volume;
+    LOG(DEBUG) << __func__ << ": " << mType << ": " << in_volume;
     if (in_volume >= 0.0f && in_volume <= 1.0f) {
         auto result = mDebug.simulateDeviceConnections ? ndk::ScopedAStatus::ok()
                                                        : onMasterVolumeChanged(in_volume);
@@ -1286,51 +1315,52 @@
             mMasterVolume = in_volume;
         } else {
             // Reset master volume if it failed.
-            LOG(ERROR) << __func__ << ": failed calling onMasterVolumeChanged(" << in_volume
-                       << "), error=" << result;
+            LOG(ERROR) << __func__ << ": " << mType << ": failed calling onMasterVolumeChanged("
+                       << in_volume << "), error=" << result;
             onMasterVolumeChanged(mMasterVolume);
         }
         return result;
     }
-    LOG(ERROR) << __func__ << ": invalid master volume value: " << in_volume;
+    LOG(ERROR) << __func__ << ": " << mType << ": invalid master volume value: " << in_volume;
     return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
 }
 
 ndk::ScopedAStatus Module::getMicMute(bool* _aidl_return) {
     *_aidl_return = mMicMute;
-    LOG(DEBUG) << __func__ << ": returning " << *_aidl_return;
+    LOG(DEBUG) << __func__ << ": " << mType << ": returning " << *_aidl_return;
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::setMicMute(bool in_mute) {
-    LOG(DEBUG) << __func__ << ": " << in_mute;
+    LOG(DEBUG) << __func__ << ": " << mType << ": " << in_mute;
     mMicMute = in_mute;
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::getMicrophones(std::vector<MicrophoneInfo>* _aidl_return) {
     *_aidl_return = getMicrophoneInfos();
-    LOG(DEBUG) << __func__ << ": returning " << ::android::internal::ToString(*_aidl_return);
+    LOG(DEBUG) << __func__ << ": " << mType << ": returning "
+               << ::android::internal::ToString(*_aidl_return);
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::updateAudioMode(AudioMode in_mode) {
     if (!isValidAudioMode(in_mode)) {
-        LOG(ERROR) << __func__ << ": invalid mode " << toString(in_mode);
+        LOG(ERROR) << __func__ << ": " << mType << ": invalid mode " << toString(in_mode);
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     // No checks for supported audio modes here, it's an informative notification.
-    LOG(DEBUG) << __func__ << ": " << toString(in_mode);
+    LOG(DEBUG) << __func__ << ": " << mType << ": " << toString(in_mode);
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::updateScreenRotation(ScreenRotation in_rotation) {
-    LOG(DEBUG) << __func__ << ": " << toString(in_rotation);
+    LOG(DEBUG) << __func__ << ": " << mType << ": " << toString(in_rotation);
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::updateScreenState(bool in_isTurnedOn) {
-    LOG(DEBUG) << __func__ << ": " << in_isTurnedOn;
+    LOG(DEBUG) << __func__ << ": " << mType << ": " << in_isTurnedOn;
     return ndk::ScopedAStatus::ok();
 }
 
@@ -1339,12 +1369,13 @@
         mSoundDose = ndk::SharedRefBase::make<sounddose::SoundDose>();
     }
     *_aidl_return = mSoundDose.getInstance();
-    LOG(DEBUG) << __func__ << ": returning instance of ISoundDose: " << _aidl_return->get();
+    LOG(DEBUG) << __func__ << ": " << mType
+               << ": returning instance of ISoundDose: " << _aidl_return->get();
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::generateHwAvSyncId(int32_t* _aidl_return) {
-    LOG(DEBUG) << __func__;
+    LOG(DEBUG) << __func__ << ": " << mType;
     (void)_aidl_return;
     return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
 }
@@ -1354,7 +1385,7 @@
 
 ndk::ScopedAStatus Module::getVendorParameters(const std::vector<std::string>& in_ids,
                                                std::vector<VendorParameter>* _aidl_return) {
-    LOG(DEBUG) << __func__ << ": id count: " << in_ids.size();
+    LOG(VERBOSE) << __func__ << ": " << mType << ": id count: " << in_ids.size();
     bool allParametersKnown = true;
     for (const auto& id : in_ids) {
         if (id == VendorDebug::kForceTransientBurstName) {
@@ -1367,7 +1398,7 @@
             _aidl_return->push_back(std::move(forceSynchronousDrain));
         } else {
             allParametersKnown = false;
-            LOG(ERROR) << __func__ << ": unrecognized parameter \"" << id << "\"";
+            LOG(VERBOSE) << __func__ << ": " << mType << ": unrecognized parameter \"" << id << "\"";
         }
     }
     if (allParametersKnown) return ndk::ScopedAStatus::ok();
@@ -1393,8 +1424,8 @@
 
 ndk::ScopedAStatus Module::setVendorParameters(const std::vector<VendorParameter>& in_parameters,
                                                bool in_async) {
-    LOG(DEBUG) << __func__ << ": parameter count " << in_parameters.size()
-               << ", async: " << in_async;
+    LOG(VERBOSE) << __func__ << ": " << mType << ": parameter count " << in_parameters.size()
+                 << ", async: " << in_async;
     bool allParametersKnown = true;
     for (const auto& p : in_parameters) {
         if (p.id == VendorDebug::kForceTransientBurstName) {
@@ -1407,7 +1438,8 @@
             }
         } else {
             allParametersKnown = false;
-            LOG(ERROR) << __func__ << ": unrecognized parameter \"" << p.id << "\"";
+            LOG(VERBOSE) << __func__ << ": " << mType << ": unrecognized parameter \"" << p.id
+                         << "\"";
         }
     }
     if (allParametersKnown) return ndk::ScopedAStatus::ok();
@@ -1418,10 +1450,11 @@
         int32_t in_portConfigId,
         const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>& in_effect) {
     if (in_effect == nullptr) {
-        LOG(DEBUG) << __func__ << ": port id " << in_portConfigId << ", null effect";
+        LOG(DEBUG) << __func__ << ": " << mType << ": port id " << in_portConfigId
+                   << ", null effect";
     } else {
-        LOG(DEBUG) << __func__ << ": port id " << in_portConfigId << ", effect Binder "
-                   << in_effect->asBinder().get();
+        LOG(DEBUG) << __func__ << ": " << mType << ": port id " << in_portConfigId
+                   << ", effect Binder " << in_effect->asBinder().get();
     }
     return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
 }
@@ -1430,17 +1463,18 @@
         int32_t in_portConfigId,
         const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>& in_effect) {
     if (in_effect == nullptr) {
-        LOG(DEBUG) << __func__ << ": port id " << in_portConfigId << ", null effect";
+        LOG(DEBUG) << __func__ << ": " << mType << ": port id " << in_portConfigId
+                   << ", null effect";
     } else {
-        LOG(DEBUG) << __func__ << ": port id " << in_portConfigId << ", effect Binder "
-                   << in_effect->asBinder().get();
+        LOG(DEBUG) << __func__ << ": " << mType << ": port id " << in_portConfigId
+                   << ", effect Binder " << in_effect->asBinder().get();
     }
     return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
 }
 
 ndk::ScopedAStatus Module::getMmapPolicyInfos(AudioMMapPolicyType mmapPolicyType,
                                               std::vector<AudioMMapPolicyInfo>* _aidl_return) {
-    LOG(DEBUG) << __func__ << ": mmap policy type " << toString(mmapPolicyType);
+    LOG(DEBUG) << __func__ << ": " << mType << ": mmap policy type " << toString(mmapPolicyType);
     std::set<int32_t> mmapSinks;
     std::set<int32_t> mmapSources;
     auto& ports = getConfig().ports;
@@ -1468,7 +1502,8 @@
                 auto sourcePortIt = findById<AudioPort>(ports, sourcePortId);
                 if (sourcePortIt == ports.end()) {
                     // This must not happen
-                    LOG(ERROR) << __func__ << ": port id " << sourcePortId << " cannot be found";
+                    LOG(ERROR) << __func__ << ": " << mType << ": port id " << sourcePortId
+                               << " cannot be found";
                     continue;
                 }
                 if (sourcePortIt->ext.getTag() != AudioPortExt::Tag::device) {
@@ -1486,7 +1521,8 @@
             auto sinkPortIt = findById<AudioPort>(ports, route.sinkPortId);
             if (sinkPortIt == ports.end()) {
                 // This must not happen
-                LOG(ERROR) << __func__ << ": port id " << route.sinkPortId << " cannot be found";
+                LOG(ERROR) << __func__ << ": " << mType << ": port id " << route.sinkPortId
+                           << " cannot be found";
                 continue;
             }
             if (sinkPortIt->ext.getTag() != AudioPortExt::Tag::device) {
@@ -1507,28 +1543,28 @@
 }
 
 ndk::ScopedAStatus Module::supportsVariableLatency(bool* _aidl_return) {
-    LOG(DEBUG) << __func__;
+    LOG(DEBUG) << __func__ << ": " << mType;
     *_aidl_return = false;
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::getAAudioMixerBurstCount(int32_t* _aidl_return) {
     if (!isMmapSupported()) {
-        LOG(DEBUG) << __func__ << ": mmap is not supported ";
+        LOG(DEBUG) << __func__ << ": " << mType << ": mmap is not supported ";
         return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
     }
     *_aidl_return = DEFAULT_AAUDIO_MIXER_BURST_COUNT;
-    LOG(DEBUG) << __func__ << ": returning " << *_aidl_return;
+    LOG(DEBUG) << __func__ << ": " << mType << ": returning " << *_aidl_return;
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::getAAudioHardwareBurstMinUsec(int32_t* _aidl_return) {
     if (!isMmapSupported()) {
-        LOG(DEBUG) << __func__ << ": mmap is not supported ";
+        LOG(DEBUG) << __func__ << ": " << mType << ": mmap is not supported ";
         return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
     }
     *_aidl_return = DEFAULT_AAUDIO_HARDWARE_BURST_MIN_DURATION_US;
-    LOG(DEBUG) << __func__ << ": returning " << *_aidl_return;
+    LOG(DEBUG) << __func__ << ": " << mType << ": returning " << *_aidl_return;
     return ndk::ScopedAStatus::ok();
 }
 
@@ -1551,45 +1587,45 @@
 
 ndk::ScopedAStatus Module::populateConnectedDevicePort(AudioPort* audioPort, int32_t) {
     if (audioPort->ext.getTag() != AudioPortExt::device) {
-        LOG(ERROR) << __func__ << ": not a device port: " << audioPort->toString();
+        LOG(ERROR) << __func__ << ": " << mType << ": not a device port: " << audioPort->toString();
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
     const auto& devicePort = audioPort->ext.get<AudioPortExt::device>();
     if (!devicePort.device.type.connection.empty()) {
-        LOG(ERROR) << __func__
-                   << ": module implementation must override 'populateConnectedDevicePort' "
+        LOG(ERROR) << __func__ << ": " << mType << ": module implementation must override "
+                                                  "'populateConnectedDevicePort' "
                    << "to handle connection of external devices.";
         return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
     }
-    LOG(VERBOSE) << __func__ << ": do nothing and return ok";
+    LOG(VERBOSE) << __func__ << ": " << mType << ": do nothing and return ok";
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::checkAudioPatchEndpointsMatch(
         const std::vector<AudioPortConfig*>& sources __unused,
         const std::vector<AudioPortConfig*>& sinks __unused) {
-    LOG(VERBOSE) << __func__ << ": do nothing and return ok";
+    LOG(VERBOSE) << __func__ << ": " << mType << ": do nothing and return ok";
     return ndk::ScopedAStatus::ok();
 }
 
 void Module::onExternalDeviceConnectionChanged(
         const ::aidl::android::media::audio::common::AudioPort& audioPort __unused,
         bool connected __unused) {
-    LOG(DEBUG) << __func__ << ": do nothing and return";
+    LOG(DEBUG) << __func__ << ": " << mType << ": do nothing and return";
 }
 
 void Module::onPrepareToDisconnectExternalDevice(
         const ::aidl::android::media::audio::common::AudioPort& audioPort __unused) {
-    LOG(DEBUG) << __func__ << ": do nothing and return";
+    LOG(DEBUG) << __func__ << ": " << mType << ": do nothing and return";
 }
 
 ndk::ScopedAStatus Module::onMasterMuteChanged(bool mute __unused) {
-    LOG(VERBOSE) << __func__ << ": do nothing and return ok";
+    LOG(VERBOSE) << __func__ << ": " << mType << ": do nothing and return ok";
     return ndk::ScopedAStatus::ok();
 }
 
 ndk::ScopedAStatus Module::onMasterVolumeChanged(float volume __unused) {
-    LOG(VERBOSE) << __func__ << ": do nothing and return ok";
+    LOG(VERBOSE) << __func__ << ": " << mType << ": do nothing and return ok";
     return ndk::ScopedAStatus::ok();
 }