audio:aidl: Use module type in log prints

Module base class can be used by multiple module,
to identify the module in use from logs, use mType in the logs as well.

Change log type for getVendorParameter and setVendorParameters,
as all parameters might not be supported by each module and unsupported parameter does not mean an error.

Change-Id: I0f46f8a9be733edd11186140bc9c3f51ea8d0969
This commit is contained in:
Jaideep Sharma
2024-03-07 10:05:51 +05:30
parent b06a492bd9
commit 559a491dc1

View File

@@ -173,7 +173,8 @@ ndk::ScopedAStatus Module::createStreamContext(
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 @@ ndk::ScopedAStatus Module::createStreamContext(
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);
@@ -252,7 +254,8 @@ std::set<int32_t> Module::findConnectedPortConfigIds(int32_t portConfigId) {
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(),
@@ -269,7 +272,8 @@ ndk::ScopedAStatus Module::findPortIdForNewStream(int32_t in_portConfigId, Audio
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;
@@ -278,23 +282,23 @@ ndk::ScopedAStatus Module::findPortIdForNewStream(int32_t in_portConfigId, Audio
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);
@@ -322,7 +326,7 @@ bool Module::generateDefaultPortConfig(const AudioPort& port, AudioPortConfig* c
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;
}
@@ -489,7 +493,8 @@ ndk::ScopedAStatus Module::updateStreamsConnectedState(const AudioPatch& oldPatc
}
});
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) {
@@ -508,7 +513,8 @@ ndk::ScopedAStatus Module::setModuleDebug(
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);
}
@@ -523,25 +529,25 @@ ndk::ScopedAStatus Module::setModuleDebug(
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();
}
@@ -553,20 +559,23 @@ ndk::ScopedAStatus Module::connectExternalDevice(const AudioPort& in_templateIdA
{ // 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.
@@ -576,14 +585,16 @@ ndk::ScopedAStatus Module::connectExternalDevice(const AudioPort& in_templateIdA
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);
@@ -635,7 +646,8 @@ ndk::ScopedAStatus Module::connectExternalDevice(const AudioPort& in_templateIdA
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();
@@ -646,7 +658,8 @@ ndk::ScopedAStatus Module::connectExternalDevice(const AudioPort& in_templateIdA
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*/);
@@ -696,16 +709,18 @@ ndk::ScopedAStatus Module::disconnectExternalDevice(int32_t in_portId) {
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;
@@ -719,13 +734,14 @@ ndk::ScopedAStatus Module::disconnectExternalDevice(int32_t in_portId) {
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();) {
@@ -761,16 +777,18 @@ ndk::ScopedAStatus Module::prepareToDisconnectExternalDevice(int32_t in_portId)
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);
}
@@ -781,7 +799,7 @@ ndk::ScopedAStatus Module::prepareToDisconnectExternalDevice(int32_t in_portId)
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();
}
@@ -790,28 +808,29 @@ ndk::ScopedAStatus Module::getAudioPort(int32_t in_portId, AudioPort* _aidl_retu
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();
}
@@ -819,7 +838,7 @@ ndk::ScopedAStatus Module::getAudioRoutesForAudioPort(int32_t in_portId,
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);
@@ -830,12 +849,12 @@ ndk::ScopedAStatus Module::getAudioRoutesForAudioPort(int32_t in_portId,
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);
}
@@ -860,27 +879,27 @@ ndk::ScopedAStatus Module::openInputStream(const OpenInputStreamArguments& in_ar
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);
}
@@ -906,27 +925,29 @@ ndk::ScopedAStatus Module::openOutputStream(const OpenOutputStreamArguments& in_
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);
}
@@ -935,13 +956,13 @@ ndk::ScopedAStatus Module::setAudioPatch(const AudioPatch& in_requested, AudioPa
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);
}
@@ -962,7 +983,8 @@ ndk::ScopedAStatus Module::setAudioPatch(const AudioPatch& in_requested, AudioPa
}
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);
}
}
@@ -977,14 +999,15 @@ ndk::ScopedAStatus Module::setAudioPatch(const AudioPatch& in_requested, AudioPa
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);
@@ -1027,8 +1050,8 @@ ndk::ScopedAStatus Module::setAudioPatch(const AudioPatch& in_requested, AudioPa
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();
}
@@ -1046,28 +1069,29 @@ ndk::ScopedAStatus Module::setAudioPortConfigImpl(
::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()) {
@@ -1078,7 +1102,8 @@ ndk::ScopedAStatus Module::setAudioPortConfigImpl(
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);
}
}
@@ -1095,7 +1120,7 @@ ndk::ScopedAStatus Module::setAudioPortConfigImpl(
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;
@@ -1111,7 +1136,7 @@ ndk::ScopedAStatus Module::setAudioPortConfigImpl(
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;
}
@@ -1120,8 +1145,9 @@ ndk::ScopedAStatus Module::setAudioPortConfigImpl(
}
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);
}
@@ -1132,9 +1158,9 @@ ndk::ScopedAStatus Module::setAudioPortConfigImpl(
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 {
@@ -1148,9 +1174,9 @@ ndk::ScopedAStatus Module::setAudioPortConfigImpl(
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 {
@@ -1173,7 +1199,7 @@ ndk::ScopedAStatus Module::setAudioPortConfigImpl(
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;
@@ -1184,15 +1210,17 @@ ndk::ScopedAStatus Module::setAudioPortConfigImpl(
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();
@@ -1209,10 +1237,10 @@ ndk::ScopedAStatus Module::resetAudioPatch(int32_t in_patchId) {
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);
}
@@ -1221,13 +1249,13 @@ ndk::ScopedAStatus Module::resetAudioPortConfig(int32_t in_portConfigId) {
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);
}
@@ -1235,32 +1263,33 @@ ndk::ScopedAStatus Module::resetAudioPortConfig(int32_t in_portConfigId) {
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);
}
@@ -1269,12 +1298,12 @@ ndk::ScopedAStatus Module::setMasterMute(bool in_mute) {
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);
@@ -1282,51 +1311,52 @@ ndk::ScopedAStatus Module::setMasterVolume(float in_volume) {
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();
}
@@ -1335,12 +1365,13 @@ ndk::ScopedAStatus Module::getSoundDose(std::shared_ptr<ISoundDose>* _aidl_retur
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);
}
@@ -1350,7 +1381,7 @@ const std::string Module::VendorDebug::kForceSynchronousDrainName = "aosp.forceS
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) {
@@ -1363,7 +1394,7 @@ ndk::ScopedAStatus Module::getVendorParameters(const std::vector<std::string>& i
_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();
@@ -1389,8 +1420,8 @@ bool extractParameter(const VendorParameter& p, decltype(W::value)* v) {
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) {
@@ -1403,7 +1434,8 @@ ndk::ScopedAStatus Module::setVendorParameters(const std::vector<VendorParameter
}
} else {
allParametersKnown = false;
LOG(ERROR) << __func__ << ": unrecognized parameter \"" << p.id << "\"";
LOG(VERBOSE) << __func__ << ": " << mType << ": unrecognized parameter \"" << p.id
<< "\"";
}
}
if (allParametersKnown) return ndk::ScopedAStatus::ok();
@@ -1414,10 +1446,11 @@ ndk::ScopedAStatus Module::addDeviceEffect(
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);
}
@@ -1426,17 +1459,18 @@ ndk::ScopedAStatus Module::removeDeviceEffect(
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;
@@ -1464,7 +1498,8 @@ ndk::ScopedAStatus Module::getMmapPolicyInfos(AudioMMapPolicyType mmapPolicyType
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) {
@@ -1482,7 +1517,8 @@ ndk::ScopedAStatus Module::getMmapPolicyInfos(AudioMMapPolicyType mmapPolicyType
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) {
@@ -1503,28 +1539,28 @@ ndk::ScopedAStatus Module::getMmapPolicyInfos(AudioMMapPolicyType mmapPolicyType
}
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();
}
@@ -1547,45 +1583,45 @@ bool Module::isMmapSupported() {
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();
}