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