audio: Fix remote submix module device ports handling
- remove the default address "0" for IN_SUBMIX and OUT_SUBMIX;
- remove the profiles in the device port and assign profiles when
connecting;
- make remote submix input to use "virtual" connection type,
same as the output;
- fix ModuleConfig in VTS to avoid returning devices with virtual
connections as "external devices" because they can actually
be connected even when connection simulation is disabled;
- fix TryConnectMissingDevice VTS test to disconnect the device
if the operation has unexpectedly succeeded.
Bug: 286914845
Bug: 294976817
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Ife11c9c356d1b5dc587d08cef47294e3b29f65c5
diff --git a/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp b/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp
index 9be7837..adea877 100644
--- a/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp
+++ b/audio/aidl/default/r_submix/ModuleRemoteSubmix.cpp
@@ -19,8 +19,8 @@
#include <vector>
#include <android-base/logging.h>
+#include <error/expected_utils.h>
-#include "RemoteSubmixUtils.h"
#include "core-impl/ModuleRemoteSubmix.h"
#include "core-impl/StreamRemoteSubmix.h"
@@ -33,18 +33,6 @@
namespace aidl::android::hardware::audio::core {
-ndk::ScopedAStatus ModuleRemoteSubmix::getTelephony(std::shared_ptr<ITelephony>* _aidl_return) {
- *_aidl_return = nullptr;
- LOG(DEBUG) << __func__ << ": returning null";
- return ndk::ScopedAStatus::ok();
-}
-
-ndk::ScopedAStatus ModuleRemoteSubmix::getBluetooth(std::shared_ptr<IBluetooth>* _aidl_return) {
- *_aidl_return = nullptr;
- LOG(DEBUG) << __func__ << ": returning null";
- return ndk::ScopedAStatus::ok();
-}
-
ndk::ScopedAStatus ModuleRemoteSubmix::getMicMute(bool* _aidl_return __unused) {
LOG(DEBUG) << __func__ << ": is not supported";
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
@@ -70,23 +58,26 @@
}
ndk::ScopedAStatus ModuleRemoteSubmix::populateConnectedDevicePort(AudioPort* audioPort) {
- LOG(VERBOSE) << __func__ << ": Profiles already populated by Configuration";
- for (auto profile : audioPort->profiles) {
- for (auto channelMask : profile.channelMasks) {
- if (!r_submix::isChannelMaskSupported(channelMask)) {
- LOG(ERROR) << __func__ << ": the profile " << profile.name
- << " has unsupported channel mask : " << channelMask.toString();
- return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
- }
- }
- for (auto sampleRate : profile.sampleRates) {
- if (!r_submix::isSampleRateSupported(sampleRate)) {
- LOG(ERROR) << __func__ << ": the profile " << profile.name
- << " has unsupported sample rate : " << sampleRate;
- return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
- }
- }
+ // Find the corresponding mix port and copy its profiles.
+ std::vector<AudioRoute> routes;
+ // At this moment, the port has the same ID as the template port, see connectExternalDevice.
+ RETURN_STATUS_IF_ERROR(getAudioRoutesForAudioPort(audioPort->id, &routes));
+ if (routes.empty()) {
+ LOG(ERROR) << __func__ << ": no routes found for the port " << audioPort->toString();
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
+ const auto& route = *routes.begin();
+ AudioPort mixPort;
+ if (route.sinkPortId == audioPort->id) {
+ if (route.sourcePortIds.empty()) {
+ LOG(ERROR) << __func__ << ": invalid route " << route.toString();
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ }
+ RETURN_STATUS_IF_ERROR(getAudioPort(*route.sourcePortIds.begin(), &mixPort));
+ } else {
+ RETURN_STATUS_IF_ERROR(getAudioPort(route.sinkPortId, &mixPort));
+ }
+ audioPort->profiles = mixPort.profiles;
return ndk::ScopedAStatus::ok();
}
@@ -106,12 +97,6 @@
return ndk::ScopedAStatus::ok();
}
-void ModuleRemoteSubmix::onExternalDeviceConnectionChanged(
- const ::aidl::android::media::audio::common::AudioPort& audioPort __unused,
- bool connected __unused) {
- LOG(DEBUG) << __func__ << ": do nothing and return";
-}
-
ndk::ScopedAStatus ModuleRemoteSubmix::onMasterMuteChanged(bool __unused) {
LOG(DEBUG) << __func__ << ": is not supported";
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);