audio: Fix update of an existing patch
The code for updating the existing patch did not modify
the patch stored in the module's list of patches.
Added a test which switches the patch to another port
config and validates that 'Module.getAudioPatches' returns
the updated patch.
Bug: 302573756
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I0e3412b9387cd451436a48af116dc5a940d868cf
diff --git a/audio/aidl/default/Module.cpp b/audio/aidl/default/Module.cpp
index 3117134..0d4e21f 100644
--- a/audio/aidl/default/Module.cpp
+++ b/audio/aidl/default/Module.cpp
@@ -515,7 +515,7 @@
}
}
- connectedPort.id = ++getConfig().nextPortId;
+ connectedPort.id = getConfig().nextPortId++;
auto [connectedPortsIt, _] =
mConnectedDevicePorts.insert(std::pair(connectedPort.id, std::set<int32_t>()));
LOG(DEBUG) << __func__ << ": template port " << templateId << " external device connected, "
@@ -865,6 +865,7 @@
patches.push_back(*_aidl_return);
} else {
oldPatch = *existing;
+ *existing = *_aidl_return;
}
patchesBackup = mPatches;
registerPatch(*_aidl_return);