Merge cherrypicks of ['android-review.googlesource.com/3018422', 'android-review.googlesource.com/3038652', 'android-review.googlesource.com/3047772', 'android-review.googlesource.com/3047078', 'android-review.googlesource.com/3047702', 'android-review.googlesource.com/3047703', 'android-review.googlesource.com/3047956', 'googleplex-android-review.googlesource.com/26519773', 'googleplex-android-review.googlesource.com/26576426', 'googleplex-android-review.googlesource.com/26767676'] into 24Q2-release.
Change-Id: I3d7e5910f29f1545833681868254b08bc5455220
diff --git a/audio/aidl/common/include/Utils.h b/audio/aidl/common/include/Utils.h
index ef312d5..a1008a4 100644
--- a/audio/aidl/common/include/Utils.h
+++ b/audio/aidl/common/include/Utils.h
@@ -174,6 +174,12 @@
return result;
}
+template <typename E, typename U = std::underlying_type_t<E>,
+ typename = std::enable_if_t<is_bit_position_enum<E>::value>>
+constexpr bool isAnyBitPositionFlagSet(U mask, std::initializer_list<E> flags) {
+ return (mask & makeBitPositionFlagMask<E>(flags)) != 0;
+}
+
constexpr int32_t frameCountFromDurationUs(long durationUs, int32_t sampleRateHz) {
return (static_cast<long long>(durationUs) * sampleRateHz) / 1000000LL;
}
diff --git a/audio/aidl/default/audio_effects_config.xml b/audio/aidl/default/audio_effects_config.xml
index 827ff80..e859a0e 100644
--- a/audio/aidl/default/audio_effects_config.xml
+++ b/audio/aidl/default/audio_effects_config.xml
@@ -72,10 +72,7 @@
<effects>
<effect name="automatic_gain_control_v2" library="pre_processing" uuid="89f38e65-d4d2-4d64-ad0e-2b3e799ea886"/>
- <effectProxy name="bassboost" uuid="14804144-a5ee-4d24-aa88-0002a5d5c51b">
- <libsw library="bassboostsw" uuid="fa8181f2-588b-11ed-9b6a-0242ac120002"/>
- <libsw library="bundle" uuid="8631f300-72e2-11df-b57e-0002a5d5c51b"/>
- </effectProxy>
+ <effect name="bassboost" library="bundle" uuid="8631f300-72e2-11df-b57e-0002a5d5c51b"/>
<effect name="downmix" library="downmix" uuid="93f04452-e4fe-41cc-91f9-e475b6d1d69f"/>
<effect name="dynamics_processing" library="dynamics_processing" uuid="e0e6539b-1781-7261-676f-6d7573696340"/>
<effect name="haptic_generator" library="haptic_generator" uuid="97c4acd1-8b82-4f2f-832e-c2fe5d7a9931"/>
@@ -86,16 +83,10 @@
<effect name="reverb_env_ins" library="reverb" uuid="c7a511a0-a3bb-11df-860e-0002a5d5c51b"/>
<effect name="reverb_pre_aux" library="reverb" uuid="f29a1400-a3bb-11df-8ddc-0002a5d5c51b"/>
<effect name="reverb_pre_ins" library="reverb" uuid="172cdf00-a3bc-11df-a72f-0002a5d5c51b"/>
- <effectProxy name="virtualizer" uuid="d3467faa-acc7-4d34-acaf-0002a5d5c51b">
- <libsw library="virtualizersw" uuid="fa819d86-588b-11ed-9b6a-0242ac120002"/>
- <libsw library="bundle" uuid="1d4033c0-8557-11df-9f2d-0002a5d5c51b"/>
- </effectProxy>
+ <effect name="virtualizer" library="bundle" uuid="1d4033c0-8557-11df-9f2d-0002a5d5c51b"/>
<effect name="visualizer" library="visualizer" uuid="d069d9e0-8329-11df-9168-0002a5d5c51b"/>
<effect name="volume" library="bundle" uuid="119341a0-8469-11df-81f9-0002a5d5c51b"/>
- <effectProxy name="equalizer" uuid="c8e70ecd-48ca-456e-8a4f-0002a5d5c51b">
- <libsw library="equalizersw" uuid="0bed4300-847d-11df-bb17-0002a5d5c51b"/>
- <libsw library="bundle" uuid="ce772f20-847d-11df-bb17-0002a5d5c51b"/>
- </effectProxy>
+ <effect name="equalizer" library="bundle" uuid="ce772f20-847d-11df-bb17-0002a5d5c51b"/>
<effect name="extension_effect" library="extensioneffect" uuid="fa81dd00-588b-11ed-9b6a-0242ac120002" type="fa81de0e-588b-11ed-9b6a-0242ac120002"/>
<effect name="acoustic_echo_canceler" library="pre_processing" uuid="bb392ec0-8d4d-11e0-a896-0002a5d5c51b"/>
<effect name="noise_suppression" library="pre_processing" uuid="c06c8400-8e06-11e0-9cb6-0002a5d5c51b"/>
diff --git a/audio/aidl/vts/ModuleConfig.cpp b/audio/aidl/vts/ModuleConfig.cpp
index 2b86271..d24c4c8 100644
--- a/audio/aidl/vts/ModuleConfig.cpp
+++ b/audio/aidl/vts/ModuleConfig.cpp
@@ -551,6 +551,11 @@
return result;
}
+std::optional<AudioPort> ModuleConfig::getPort(int32_t portId) {
+ auto portsIt = findById(mPorts, portId);
+ return portsIt != mPorts.end() ? std::optional<AudioPort>(*portsIt) : std::nullopt;
+}
+
ndk::ScopedAStatus ModuleConfig::onExternalDeviceConnected(IModule* module, const AudioPort& port) {
RETURN_STATUS_IF_ERROR(module->getAudioPorts(&mPorts));
RETURN_STATUS_IF_ERROR(module->getAudioRoutes(&mRoutes));
diff --git a/audio/aidl/vts/ModuleConfig.h b/audio/aidl/vts/ModuleConfig.h
index 4a87f8c..27286e5 100644
--- a/audio/aidl/vts/ModuleConfig.h
+++ b/audio/aidl/vts/ModuleConfig.h
@@ -166,6 +166,8 @@
return *config.begin();
}
+ std::optional<aidl::android::media::audio::common::AudioPort> getPort(int32_t portId);
+
ndk::ScopedAStatus onExternalDeviceConnected(
aidl::android::hardware::audio::core::IModule* module,
const aidl::android::media::audio::common::AudioPort& port);
diff --git a/audio/aidl/vts/TestUtils.h b/audio/aidl/vts/TestUtils.h
index 515b8a2..0a5addc 100644
--- a/audio/aidl/vts/TestUtils.h
+++ b/audio/aidl/vts/TestUtils.h
@@ -104,11 +104,13 @@
EXPECT_PRED_FORMAT2(::android::hardware::audio::common::testing::detail::assertResult, \
expected, ret)
-#define SKIP_TEST_IF_DATA_UNSUPPORTED(flags) \
- ({ \
- if ((flags).hwAcceleratorMode == Flags::HardwareAccelerator::TUNNEL || (flags).bypass) { \
- GTEST_SKIP() << "Skip data path for offload"; \
- } \
+#define SKIP_TEST_IF_DATA_UNSUPPORTED(flags) \
+ ({ \
+ if ((flags).hwAcceleratorMode == \
+ aidl::android::hardware::audio::effect::Flags::HardwareAccelerator::TUNNEL || \
+ (flags).bypass) { \
+ GTEST_SKIP() << "Skip data path for offload"; \
+ } \
})
// Test that the transaction status 'isOk' if it is a known transaction
diff --git a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
index 7373073..d576c7c 100644
--- a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp
@@ -56,6 +56,7 @@
using namespace android;
using aidl::android::hardware::audio::common::AudioOffloadMetadata;
using aidl::android::hardware::audio::common::getChannelCount;
+using aidl::android::hardware::audio::common::isAnyBitPositionFlagSet;
using aidl::android::hardware::audio::common::isBitPositionFlagSet;
using aidl::android::hardware::audio::common::isTelephonyDeviceType;
using aidl::android::hardware::audio::common::isValidAudioMode;
@@ -85,6 +86,7 @@
using aidl::android::media::audio::common::AudioDeviceType;
using aidl::android::media::audio::common::AudioDualMonoMode;
using aidl::android::media::audio::common::AudioFormatType;
+using aidl::android::media::audio::common::AudioInputFlags;
using aidl::android::media::audio::common::AudioIoFlags;
using aidl::android::media::audio::common::AudioLatencyMode;
using aidl::android::media::audio::common::AudioMMapPolicy;
@@ -131,13 +133,23 @@
}
template <typename C>
-std::vector<int32_t> GetNonExistentIds(const C& allIds) {
+std::vector<int32_t> GetNonExistentIds(const C& allIds, bool includeZero = true) {
if (allIds.empty()) {
- return std::vector<int32_t>{-1, 0, 1};
+ return includeZero ? std::vector<int32_t>{-1, 0, 1} : std::vector<int32_t>{-1, 1};
}
std::vector<int32_t> nonExistentIds;
- nonExistentIds.push_back(*std::min_element(allIds.begin(), allIds.end()) - 1);
- nonExistentIds.push_back(*std::max_element(allIds.begin(), allIds.end()) + 1);
+ if (auto value = *std::min_element(allIds.begin(), allIds.end()) - 1;
+ includeZero || value != 0) {
+ nonExistentIds.push_back(value);
+ } else {
+ nonExistentIds.push_back(value - 1);
+ }
+ if (auto value = *std::max_element(allIds.begin(), allIds.end()) + 1;
+ includeZero || value != 0) {
+ nonExistentIds.push_back(value);
+ } else {
+ nonExistentIds.push_back(value + 1);
+ }
return nonExistentIds;
}
@@ -779,6 +791,13 @@
};
return helper(v.begin(), helper);
}
+ Node makeNodes(StreamDescriptor::State s, TransitionTrigger t, size_t count, Node last) {
+ auto helper = [&](size_t c, auto&& h) -> Node {
+ if (c == 0) return last;
+ return makeNode(s, t, h(--c, h));
+ };
+ return helper(count, helper);
+ }
Node makeNodes(const std::vector<StateTransitionFrom>& v, StreamDescriptor::State f) {
return makeNodes(v, makeFinalNode(f));
}
@@ -1038,7 +1057,9 @@
<< ": received invalid byte count in the reply: " << reply.fmqByteCount;
return Status::ABORT;
}
- if (getDataMQ()->availableToWrite() != getDataMQ()->getQuantumCount()) {
+ // It is OK for the implementation to leave data in the MQ when the stream is paused.
+ if (reply.state != StreamDescriptor::State::PAUSED &&
+ getDataMQ()->availableToWrite() != getDataMQ()->getQuantumCount()) {
LOG(ERROR) << __func__ << ": the HAL module did not consume all data from the data MQ: "
<< "available to write " << getDataMQ()->availableToWrite()
<< ", total size: " << getDataMQ()->getQuantumCount();
@@ -1738,6 +1759,11 @@
}
TEST_P(AudioCoreModule, TryConnectMissingDevice) {
+ // Limit checks to connection types that are known to be detectable by HAL implementations.
+ static const std::set<std::string> kCheckedConnectionTypes{
+ AudioDeviceDescription::CONNECTION_HDMI, AudioDeviceDescription::CONNECTION_HDMI_ARC,
+ AudioDeviceDescription::CONNECTION_HDMI_EARC, AudioDeviceDescription::CONNECTION_IP_V4,
+ AudioDeviceDescription::CONNECTION_USB};
ASSERT_NO_FATAL_FAILURE(SetUpModuleConfig());
std::vector<AudioPort> ports = moduleConfig->getExternalDevicePorts();
if (ports.empty()) {
@@ -1746,11 +1772,12 @@
WithDebugFlags doNotSimulateConnections = WithDebugFlags::createNested(*debug);
doNotSimulateConnections.flags().simulateDeviceConnections = false;
ASSERT_NO_FATAL_FAILURE(doNotSimulateConnections.SetUp(module.get()));
+ bool hasAtLeastOneCheckedConnection = false;
for (const auto& port : ports) {
- // Virtual devices may not require external hardware and thus can always be connected.
- if (port.ext.get<AudioPortExt::device>().device.type.connection ==
- AudioDeviceDescription::CONNECTION_VIRTUAL)
+ if (kCheckedConnectionTypes.count(
+ port.ext.get<AudioPortExt::device>().device.type.connection) == 0) {
continue;
+ }
AudioPort portWithData = GenerateUniqueDeviceAddress(port), connectedPort;
ScopedAStatus status = module->connectExternalDevice(portWithData, &connectedPort);
EXPECT_STATUS(EX_ILLEGAL_STATE, status) << "static port " << portWithData.toString();
@@ -1761,6 +1788,10 @@
EXPECT_IS_OK(module->disconnectExternalDevice(connectedPort.id))
<< "when disconnecting device port ID " << connectedPort.id;
}
+ hasAtLeastOneCheckedConnection = true;
+ }
+ if (!hasAtLeastOneCheckedConnection) {
+ GTEST_SKIP() << "No external devices with connection types that can be checked.";
}
}
@@ -2871,6 +2902,182 @@
std::unique_ptr<WithStream<Stream>> mStream;
};
+class StreamLogicDefaultDriver : public StreamLogicDriver {
+ public:
+ StreamLogicDefaultDriver(std::shared_ptr<StateSequence> commands, size_t frameSizeBytes)
+ : mCommands(commands), mFrameSizeBytes(frameSizeBytes) {
+ mCommands->rewind();
+ }
+
+ // The three methods below is intended to be called after the worker
+ // thread has joined, thus no extra synchronization is needed.
+ bool hasObservablePositionIncrease() const { return mObservablePositionIncrease; }
+ bool hasRetrogradeObservablePosition() const { return mRetrogradeObservablePosition; }
+ std::string getUnexpectedStateTransition() const { return mUnexpectedTransition; }
+
+ bool done() override { return mCommands->done(); }
+ TransitionTrigger getNextTrigger(int maxDataSize, int* actualSize) override {
+ auto trigger = mCommands->getTrigger();
+ if (StreamDescriptor::Command* command = std::get_if<StreamDescriptor::Command>(&trigger);
+ command != nullptr) {
+ if (command->getTag() == StreamDescriptor::Command::Tag::burst) {
+ if (actualSize != nullptr) {
+ // In the output scenario, reduce slightly the fmqByteCount to verify
+ // that the HAL module always consumes all data from the MQ.
+ if (maxDataSize > static_cast<int>(mFrameSizeBytes)) {
+ LOG(DEBUG) << __func__ << ": reducing data size by " << mFrameSizeBytes;
+ maxDataSize -= mFrameSizeBytes;
+ }
+ *actualSize = maxDataSize;
+ }
+ command->set<StreamDescriptor::Command::Tag::burst>(maxDataSize);
+ } else {
+ if (actualSize != nullptr) *actualSize = 0;
+ }
+ }
+ return trigger;
+ }
+ bool interceptRawReply(const StreamDescriptor::Reply&) override { return false; }
+ bool processValidReply(const StreamDescriptor::Reply& reply) override {
+ if (reply.observable.frames != StreamDescriptor::Position::UNKNOWN) {
+ if (mPreviousFrames.has_value()) {
+ if (reply.observable.frames > mPreviousFrames.value()) {
+ mObservablePositionIncrease = true;
+ } else if (reply.observable.frames < mPreviousFrames.value()) {
+ mRetrogradeObservablePosition = true;
+ }
+ }
+ mPreviousFrames = reply.observable.frames;
+ }
+
+ auto expected = mCommands->getExpectedStates();
+ if (expected.count(reply.state) == 0) {
+ std::string s =
+ std::string("Unexpected transition from the state ")
+ .append(mPreviousState.has_value() ? toString(mPreviousState.value())
+ : "<initial state>")
+ .append(" to ")
+ .append(toString(reply.state))
+ .append(" (expected one of ")
+ .append(::android::internal::ToString(expected))
+ .append(") caused by the ")
+ .append(toString(mCommands->getTrigger()));
+ LOG(ERROR) << __func__ << ": " << s;
+ mUnexpectedTransition = std::move(s);
+ return false;
+ }
+ mCommands->advance(reply.state);
+ mPreviousState = reply.state;
+ return true;
+ }
+
+ protected:
+ std::shared_ptr<StateSequence> mCommands;
+ const size_t mFrameSizeBytes;
+ std::optional<StreamDescriptor::State> mPreviousState;
+ std::optional<int64_t> mPreviousFrames;
+ bool mObservablePositionIncrease = false;
+ bool mRetrogradeObservablePosition = false;
+ std::string mUnexpectedTransition;
+};
+
+// Defined later together with state transition sequences.
+std::shared_ptr<StateSequence> makeBurstCommands(bool isSync);
+
+// Certain types of ports can not be used without special preconditions.
+static bool skipStreamIoTestForMixPortConfig(const AudioPortConfig& portConfig) {
+ return (portConfig.flags.value().getTag() == AudioIoFlags::input &&
+ isAnyBitPositionFlagSet(portConfig.flags.value().template get<AudioIoFlags::input>(),
+ {AudioInputFlags::MMAP_NOIRQ, AudioInputFlags::VOIP_TX,
+ AudioInputFlags::HW_HOTWORD, AudioInputFlags::HOTWORD_TAP})) ||
+ (portConfig.flags.value().getTag() == AudioIoFlags::output &&
+ isAnyBitPositionFlagSet(
+ portConfig.flags.value().template get<AudioIoFlags::output>(),
+ {AudioOutputFlags::MMAP_NOIRQ, AudioOutputFlags::VOIP_RX,
+ AudioOutputFlags::COMPRESS_OFFLOAD, AudioOutputFlags::INCALL_MUSIC}));
+}
+
+// Certain types of devices can not be used without special preconditions.
+static bool skipStreamIoTestForDevice(const AudioDevice& device) {
+ return device.type.type == AudioDeviceType::IN_ECHO_REFERENCE;
+}
+
+template <typename Stream>
+class StreamFixtureWithWorker {
+ public:
+ explicit StreamFixtureWithWorker(bool isSync) : mIsSync(isSync) {}
+
+ void SetUp(IModule* module, ModuleConfig* moduleConfig, const AudioPort& devicePort) {
+ mStream = std::make_unique<StreamFixture<Stream>>();
+ ASSERT_NO_FATAL_FAILURE(
+ mStream->SetUpStreamForDevicePort(module, moduleConfig, devicePort));
+ MaybeSetSkipTestReason();
+ }
+
+ void SetUp(IModule* module, ModuleConfig* moduleConfig, const AudioPort& mixPort,
+ const AudioPort& devicePort) {
+ mStream = std::make_unique<StreamFixture<Stream>>();
+ ASSERT_NO_FATAL_FAILURE(
+ mStream->SetUpStreamForPortsPair(module, moduleConfig, mixPort, devicePort));
+ MaybeSetSkipTestReason();
+ }
+
+ void SendBurstCommands(bool validatePosition = true) {
+ ASSERT_NO_FATAL_FAILURE(StartWorkerToSendBurstCommands());
+ ASSERT_NO_FATAL_FAILURE(JoinWorkerAfterBurstCommands(validatePosition));
+ }
+
+ void StartWorkerToSendBurstCommands() {
+ const StreamContext* context = mStream->getStreamContext();
+ mWorkerDriver = std::make_unique<StreamLogicDefaultDriver>(makeBurstCommands(mIsSync),
+ context->getFrameSizeBytes());
+ mWorker = std::make_unique<typename IOTraits<Stream>::Worker>(
+ *context, mWorkerDriver.get(), mStream->getStreamEventReceiver());
+ LOG(DEBUG) << __func__ << ": starting " << IOTraits<Stream>::directionStr << " worker...";
+ ASSERT_TRUE(mWorker->start());
+ }
+
+ void JoinWorkerAfterBurstCommands(bool validatePosition = true) {
+ // Must call 'prepareToClose' before attempting to join because the stream may be stuck.
+ std::shared_ptr<IStreamCommon> common;
+ ASSERT_IS_OK(mStream->getStream()->getStreamCommon(&common));
+ ASSERT_IS_OK(common->prepareToClose());
+ LOG(DEBUG) << __func__ << ": joining " << IOTraits<Stream>::directionStr << " worker...";
+ mWorker->join();
+ EXPECT_FALSE(mWorker->hasError()) << mWorker->getError();
+ EXPECT_EQ("", mWorkerDriver->getUnexpectedStateTransition());
+ if (validatePosition) {
+ if (IOTraits<Stream>::is_input) {
+ EXPECT_TRUE(mWorkerDriver->hasObservablePositionIncrease());
+ }
+ EXPECT_FALSE(mWorkerDriver->hasRetrogradeObservablePosition());
+ }
+ mWorker.reset();
+ mWorkerDriver.reset();
+ }
+
+ void TeardownPatch() { mStream->TeardownPatch(); }
+
+ const AudioDevice& getDevice() const { return mStream->getDevice(); }
+ Stream* getStream() const { return mStream->getStream(); }
+ std::string skipTestReason() const {
+ return !mSkipTestReason.empty() ? mSkipTestReason : mStream->skipTestReason();
+ }
+
+ private:
+ void MaybeSetSkipTestReason() {
+ if (skipStreamIoTestForMixPortConfig(mStream->getPortConfig())) {
+ mSkipTestReason = "Mix port config is not supported for stream I/O tests";
+ }
+ }
+
+ const bool mIsSync;
+ std::string mSkipTestReason;
+ std::unique_ptr<StreamFixture<Stream>> mStream;
+ std::unique_ptr<StreamLogicDefaultDriver> mWorkerDriver;
+ std::unique_ptr<typename IOTraits<Stream>::Worker> mWorker;
+};
+
template <typename Stream>
class AudioStream : public AudioCoreModule {
public:
@@ -3276,10 +3483,12 @@
if (micDevicePorts.empty()) continue;
atLeastOnePort = true;
SCOPED_TRACE(port.toString());
- StreamFixture<IStreamIn> stream;
- ASSERT_NO_FATAL_FAILURE(stream.SetUpStreamForPortsPair(module.get(), moduleConfig.get(),
- port, micDevicePorts[0]));
+ StreamFixtureWithWorker<IStreamIn> stream(true /*isSync*/);
+ ASSERT_NO_FATAL_FAILURE(
+ stream.SetUp(module.get(), moduleConfig.get(), port, micDevicePorts[0]));
if (!stream.skipTestReason().empty()) continue;
+
+ ASSERT_NO_FATAL_FAILURE(stream.SendBurstCommands(false /*validatePosition*/));
std::vector<MicrophoneDynamicInfo> activeMics;
EXPECT_IS_OK(stream.getStream()->getActiveMicrophones(&activeMics));
EXPECT_FALSE(activeMics.empty());
@@ -3293,6 +3502,7 @@
EXPECT_NE(0UL, mic.channelMapping.size())
<< "No channels specified for the microphone \"" << mic.id << "\"";
}
+
stream.TeardownPatch();
// Now the port of the stream is not connected, check that there are no active microphones.
std::vector<MicrophoneDynamicInfo> emptyMics;
@@ -3670,85 +3880,6 @@
}
}
-class StreamLogicDefaultDriver : public StreamLogicDriver {
- public:
- StreamLogicDefaultDriver(std::shared_ptr<StateSequence> commands, size_t frameSizeBytes)
- : mCommands(commands), mFrameSizeBytes(frameSizeBytes) {
- mCommands->rewind();
- }
-
- // The three methods below is intended to be called after the worker
- // thread has joined, thus no extra synchronization is needed.
- bool hasObservablePositionIncrease() const { return mObservablePositionIncrease; }
- bool hasRetrogradeObservablePosition() const { return mRetrogradeObservablePosition; }
- std::string getUnexpectedStateTransition() const { return mUnexpectedTransition; }
-
- bool done() override { return mCommands->done(); }
- TransitionTrigger getNextTrigger(int maxDataSize, int* actualSize) override {
- auto trigger = mCommands->getTrigger();
- if (StreamDescriptor::Command* command = std::get_if<StreamDescriptor::Command>(&trigger);
- command != nullptr) {
- if (command->getTag() == StreamDescriptor::Command::Tag::burst) {
- if (actualSize != nullptr) {
- // In the output scenario, reduce slightly the fmqByteCount to verify
- // that the HAL module always consumes all data from the MQ.
- if (maxDataSize > static_cast<int>(mFrameSizeBytes)) {
- LOG(DEBUG) << __func__ << ": reducing data size by " << mFrameSizeBytes;
- maxDataSize -= mFrameSizeBytes;
- }
- *actualSize = maxDataSize;
- }
- command->set<StreamDescriptor::Command::Tag::burst>(maxDataSize);
- } else {
- if (actualSize != nullptr) *actualSize = 0;
- }
- }
- return trigger;
- }
- bool interceptRawReply(const StreamDescriptor::Reply&) override { return false; }
- bool processValidReply(const StreamDescriptor::Reply& reply) override {
- if (reply.observable.frames != StreamDescriptor::Position::UNKNOWN) {
- if (mPreviousFrames.has_value()) {
- if (reply.observable.frames > mPreviousFrames.value()) {
- mObservablePositionIncrease = true;
- } else if (reply.observable.frames < mPreviousFrames.value()) {
- mRetrogradeObservablePosition = true;
- }
- }
- mPreviousFrames = reply.observable.frames;
- }
-
- auto expected = mCommands->getExpectedStates();
- if (expected.count(reply.state) == 0) {
- std::string s =
- std::string("Unexpected transition from the state ")
- .append(mPreviousState.has_value() ? toString(mPreviousState.value())
- : "<initial state>")
- .append(" to ")
- .append(toString(reply.state))
- .append(" (expected one of ")
- .append(::android::internal::ToString(expected))
- .append(") caused by the ")
- .append(toString(mCommands->getTrigger()));
- LOG(ERROR) << __func__ << ": " << s;
- mUnexpectedTransition = std::move(s);
- return false;
- }
- mCommands->advance(reply.state);
- mPreviousState = reply.state;
- return true;
- }
-
- protected:
- std::shared_ptr<StateSequence> mCommands;
- const size_t mFrameSizeBytes;
- std::optional<StreamDescriptor::State> mPreviousState;
- std::optional<int64_t> mPreviousFrames;
- bool mObservablePositionIncrease = false;
- bool mRetrogradeObservablePosition = false;
- std::string mUnexpectedTransition;
-};
-
enum {
NAMED_CMD_NAME,
NAMED_CMD_DELAY_MS,
@@ -3779,7 +3910,11 @@
GTEST_SKIP() << "No mix ports have attached devices";
}
for (const auto& portConfig : allPortConfigs) {
+ auto port = moduleConfig->getPort(portConfig.portId);
+ ASSERT_TRUE(port.has_value());
+ SCOPED_TRACE(port->toString());
SCOPED_TRACE(portConfig.toString());
+ if (skipStreamIoTestForMixPortConfig(portConfig)) continue;
const bool isNonBlocking =
IOTraits<Stream>::is_input
? false
@@ -3860,6 +3995,7 @@
StreamFixture<Stream> stream;
ASSERT_NO_FATAL_FAILURE(
stream.SetUpStreamForMixPortConfig(module.get(), moduleConfig.get(), portConfig));
+ if (skipStreamIoTestForDevice(stream.getDevice())) return;
ASSERT_EQ("", stream.skipTestReason());
StreamLogicDefaultDriver driver(commandsAndStates,
stream.getStreamContext()->getFrameSizeBytes());
@@ -3888,6 +4024,7 @@
StreamFixture<Stream> stream;
ASSERT_NO_FATAL_FAILURE(
stream.SetUpPatchForMixPortConfig(module.get(), moduleConfig.get(), portConfig));
+ if (skipStreamIoTestForDevice(stream.getDevice())) return;
ASSERT_EQ("", stream.skipTestReason());
ASSERT_NO_FATAL_FAILURE(stream.TeardownPatchSetUpStream(module.get()));
StreamLogicDefaultDriver driver(commandsAndStates,
@@ -4086,7 +4223,7 @@
// Then use the same patch setting, except for having an invalid ID.
std::set<int32_t> patchIds;
ASSERT_NO_FATAL_FAILURE(GetAllPatchIds(&patchIds));
- for (const auto patchId : GetNonExistentIds(patchIds)) {
+ for (const auto patchId : GetNonExistentIds(patchIds, false /*includeZero*/)) {
AudioPatch patchWithNonExistendId = patch.get();
patchWithNonExistendId.id = patchId;
EXPECT_STATUS(EX_ILLEGAL_ARGUMENT,
@@ -4269,17 +4406,22 @@
using State = StreamDescriptor::State;
auto d = std::make_unique<StateDag>();
StateDag::Node last = d->makeFinalNode(State::ACTIVE);
- // Use a couple of bursts to ensure that the driver starts reporting the position.
- StateDag::Node active2 = d->makeNode(State::ACTIVE, kBurstCommand, last);
- StateDag::Node active = d->makeNode(State::ACTIVE, kBurstCommand, active2);
- StateDag::Node idle = d->makeNode(State::IDLE, kBurstCommand, active);
- if (!isSync) {
+ if (isSync) {
+ StateDag::Node idle = d->makeNode(
+ State::IDLE, kBurstCommand,
+ // Use several bursts to ensure that the driver starts reporting the position.
+ d->makeNodes(State::ACTIVE, kBurstCommand, 10, last));
+ d->makeNode(State::STANDBY, kStartCommand, idle);
+ } else {
+ StateDag::Node active2 = d->makeNode(State::ACTIVE, kBurstCommand, last);
+ StateDag::Node active = d->makeNode(State::ACTIVE, kBurstCommand, active2);
+ StateDag::Node idle = d->makeNode(State::IDLE, kBurstCommand, active);
// Allow optional routing via the TRANSFERRING state on bursts.
active2.children().push_back(d->makeNode(State::TRANSFERRING, kTransferReadyEvent, last));
active.children().push_back(d->makeNode(State::TRANSFERRING, kTransferReadyEvent, active2));
idle.children().push_back(d->makeNode(State::TRANSFERRING, kTransferReadyEvent, active));
+ d->makeNode(State::STANDBY, kStartCommand, idle);
}
- d->makeNode(State::STANDBY, kStartCommand, idle);
return std::make_shared<StateSequenceFollower>(std::move(d));
}
static const NamedCommandSequence kReadSeq =
@@ -4442,9 +4584,8 @@
std::make_pair(State::PAUSED, kStartCommand),
std::make_pair(State::ACTIVE, kPauseCommand),
std::make_pair(State::PAUSED, kBurstCommand),
- std::make_pair(State::PAUSED, kStartCommand),
- std::make_pair(State::ACTIVE, kPauseCommand)},
- State::PAUSED);
+ std::make_pair(State::PAUSED, kFlushCommand)},
+ State::IDLE);
if (!isSync) {
idle.children().push_back(
d->makeNodes({std::make_pair(State::TRANSFERRING, kPauseCommand),
@@ -4591,8 +4732,9 @@
template <typename Stream>
class WithRemoteSubmix {
public:
- WithRemoteSubmix() = default;
- explicit WithRemoteSubmix(AudioDeviceAddress address) : mAddress(address) {}
+ WithRemoteSubmix() : mStream(true /*isSync*/) {}
+ explicit WithRemoteSubmix(AudioDeviceAddress address)
+ : mStream(true /*isSync*/), mAddress(address) {}
WithRemoteSubmix(const WithRemoteSubmix&) = delete;
WithRemoteSubmix& operator=(const WithRemoteSubmix&) = delete;
@@ -4612,57 +4754,31 @@
void SetUp(IModule* module, ModuleConfig* moduleConfig) {
auto devicePort = getRemoteSubmixAudioPort(moduleConfig, mAddress);
ASSERT_TRUE(devicePort.has_value()) << "Device port for remote submix device not found";
- ASSERT_NO_FATAL_FAILURE(SetUp(module, moduleConfig, *devicePort));
+ ASSERT_NO_FATAL_FAILURE(mStream.SetUp(module, moduleConfig, *devicePort));
+ mAddress = mStream.getDevice().address;
}
- void SendBurstCommandsStartWorker() {
- const StreamContext* context = mStream->getStreamContext();
- mWorkerDriver = std::make_unique<StreamLogicDefaultDriver>(makeBurstCommands(true),
- context->getFrameSizeBytes());
- mWorker = std::make_unique<typename IOTraits<Stream>::Worker>(
- *context, mWorkerDriver.get(), mStream->getStreamEventReceiver());
- LOG(DEBUG) << __func__ << ": starting " << IOTraits<Stream>::directionStr << " worker...";
- ASSERT_TRUE(mWorker->start());
+ void StartWorkerToSendBurstCommands() {
+ ASSERT_NO_FATAL_FAILURE(mStream.StartWorkerToSendBurstCommands());
}
- void SendBurstCommandsJoinWorker() {
- // Must call 'prepareToClose' before attempting to join because the stream may be
- // stuck due to absence of activity from the other side of the remote submix pipe.
- std::shared_ptr<IStreamCommon> common;
- ASSERT_IS_OK(mStream->getStream()->getStreamCommon(&common));
- ASSERT_IS_OK(common->prepareToClose());
- LOG(DEBUG) << __func__ << ": joining " << IOTraits<Stream>::directionStr << " worker...";
- mWorker->join();
- EXPECT_FALSE(mWorker->hasError()) << mWorker->getError();
- EXPECT_EQ("", mWorkerDriver->getUnexpectedStateTransition());
- if (IOTraits<Stream>::is_input) {
- EXPECT_TRUE(mWorkerDriver->hasObservablePositionIncrease());
- }
- EXPECT_FALSE(mWorkerDriver->hasRetrogradeObservablePosition());
- mWorker.reset();
- mWorkerDriver.reset();
+ void JoinWorkerAfterBurstCommands() {
+ ASSERT_NO_FATAL_FAILURE(mStream.JoinWorkerAfterBurstCommands());
}
void SendBurstCommands() {
- ASSERT_NO_FATAL_FAILURE(SendBurstCommandsStartWorker());
- ASSERT_NO_FATAL_FAILURE(SendBurstCommandsJoinWorker());
+ ASSERT_NO_FATAL_FAILURE(mStream.StartWorkerToSendBurstCommands());
+ ASSERT_NO_FATAL_FAILURE(mStream.JoinWorkerAfterBurstCommands());
}
std::optional<AudioDeviceAddress> getAudioDeviceAddress() const { return mAddress; }
- std::string skipTestReason() const { return mStream->skipTestReason(); }
+ std::string skipTestReason() const { return mStream.skipTestReason(); }
private:
- void SetUp(IModule* module, ModuleConfig* moduleConfig, const AudioPort& devicePort) {
- mStream = std::make_unique<StreamFixture<Stream>>();
- ASSERT_NO_FATAL_FAILURE(
- mStream->SetUpStreamForDevicePort(module, moduleConfig, devicePort));
- mAddress = mStream->getDevice().address;
- }
+ void SetUp(IModule* module, ModuleConfig* moduleConfig, const AudioPort& devicePort) {}
+ StreamFixtureWithWorker<Stream> mStream;
std::optional<AudioDeviceAddress> mAddress;
- std::unique_ptr<StreamFixture<Stream>> mStream;
- std::unique_ptr<StreamLogicDefaultDriver> mWorkerDriver;
- std::unique_ptr<typename IOTraits<Stream>::Worker> mWorker;
};
class AudioModuleRemoteSubmix : public AudioCoreModule {
@@ -4712,10 +4828,10 @@
ASSERT_EQ("", streamIn.skipTestReason());
// Start writing into the output stream.
- ASSERT_NO_FATAL_FAILURE(streamOut.SendBurstCommandsStartWorker());
+ ASSERT_NO_FATAL_FAILURE(streamOut.StartWorkerToSendBurstCommands());
// Simultaneously, read from the input stream.
ASSERT_NO_FATAL_FAILURE(streamIn.SendBurstCommands());
- ASSERT_NO_FATAL_FAILURE(streamOut.SendBurstCommandsJoinWorker());
+ ASSERT_NO_FATAL_FAILURE(streamOut.JoinWorkerAfterBurstCommands());
}
TEST_P(AudioModuleRemoteSubmix, OpenInputMultipleTimes) {
@@ -4733,15 +4849,15 @@
ASSERT_EQ("", streamIns[i]->skipTestReason());
}
// Start writing into the output stream.
- ASSERT_NO_FATAL_FAILURE(streamOut.SendBurstCommandsStartWorker());
+ ASSERT_NO_FATAL_FAILURE(streamOut.StartWorkerToSendBurstCommands());
// Simultaneously, read from input streams.
for (size_t i = 0; i < streamInCount; i++) {
- ASSERT_NO_FATAL_FAILURE(streamIns[i]->SendBurstCommandsStartWorker());
+ ASSERT_NO_FATAL_FAILURE(streamIns[i]->StartWorkerToSendBurstCommands());
}
for (size_t i = 0; i < streamInCount; i++) {
- ASSERT_NO_FATAL_FAILURE(streamIns[i]->SendBurstCommandsJoinWorker());
+ ASSERT_NO_FATAL_FAILURE(streamIns[i]->JoinWorkerAfterBurstCommands());
}
- ASSERT_NO_FATAL_FAILURE(streamOut.SendBurstCommandsJoinWorker());
+ ASSERT_NO_FATAL_FAILURE(streamOut.JoinWorkerAfterBurstCommands());
// Clean up input streams in the reverse order because the device connection is owned
// by the first one.
for (size_t i = streamInCount; i != 0; --i) {
diff --git a/audio/aidl/vts/VtsHalBassBoostTargetTest.cpp b/audio/aidl/vts/VtsHalBassBoostTargetTest.cpp
index b54b442..4cb1f49 100644
--- a/audio/aidl/vts/VtsHalBassBoostTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalBassBoostTargetTest.cpp
@@ -166,6 +166,7 @@
}
void SetUp() override {
+ SKIP_TEST_IF_DATA_UNSUPPORTED(mDescriptor.common.flags);
ASSERT_NO_FATAL_FAILURE(SetUpBassBoost(mChannelLayout));
if (int32_t version;
mEffect->getInterfaceVersion(&version).isOk() && version < kMinDataTestHalVersion) {
@@ -173,7 +174,10 @@
}
}
- void TearDown() override { TearDownBassBoost(); }
+ void TearDown() override {
+ SKIP_TEST_IF_DATA_UNSUPPORTED(mDescriptor.common.flags);
+ TearDownBassBoost();
+ }
// Find FFT bin indices for testFrequencies and get bin center frequencies
void roundToFreqCenteredToFftBin(std::vector<int>& testFrequencies,
diff --git a/audio/aidl/vts/VtsHalDownmixTargetTest.cpp b/audio/aidl/vts/VtsHalDownmixTargetTest.cpp
index 360bf26..ef77f4d 100644
--- a/audio/aidl/vts/VtsHalDownmixTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalDownmixTargetTest.cpp
@@ -230,6 +230,7 @@
}
void SetUp() override {
+ SKIP_TEST_IF_DATA_UNSUPPORTED(mDescriptor.common.flags);
SetUpDownmix(mInputChannelLayout);
if (int32_t version;
mEffect->getInterfaceVersion(&version).isOk() && version < kMinDataTestHalVersion) {
@@ -241,7 +242,10 @@
setDataTestParams(mInputChannelLayout);
}
- void TearDown() override { TearDownDownmix(); }
+ void TearDown() override {
+ SKIP_TEST_IF_DATA_UNSUPPORTED(mDescriptor.common.flags);
+ TearDownDownmix();
+ }
void checkAtLeft(int32_t position) {
for (size_t i = 0, j = position; i < mOutputBufferSize;
diff --git a/audio/aidl/vts/VtsHalDynamicsProcessingTest.cpp b/audio/aidl/vts/VtsHalDynamicsProcessingTest.cpp
index 3f7a76d..e95bd4d 100644
--- a/audio/aidl/vts/VtsHalDynamicsProcessingTest.cpp
+++ b/audio/aidl/vts/VtsHalDynamicsProcessingTest.cpp
@@ -195,48 +195,42 @@
template <typename T>
bool DynamicsProcessingTestHelper::isBandConfigValid(const std::vector<T>& cfgs, int bandCount) {
- std::vector<float> freqs(cfgs.size(), -1);
+ std::unordered_set<int> freqs;
for (auto cfg : cfgs) {
if (cfg.channel < 0 || cfg.channel >= mChannelCount) return false;
if (cfg.band < 0 || cfg.band >= bandCount) return false;
- freqs[cfg.band] = cfg.cutoffFrequencyHz;
+ // duplicated band index
+ if (freqs.find(cfg.band) != freqs.end()) return false;
+ freqs.insert(cfg.band);
}
- if (std::count(freqs.begin(), freqs.end(), -1)) return false;
- return std::is_sorted(freqs.begin(), freqs.end());
+ return true;
}
bool DynamicsProcessingTestHelper::isParamValid(const DynamicsProcessing::Tag& tag,
const DynamicsProcessing& dp) {
switch (tag) {
case DynamicsProcessing::preEq: {
- if (!mEngineConfigApplied.preEqStage.inUse) return false;
return isChannelConfigValid(dp.get<DynamicsProcessing::preEq>());
}
case DynamicsProcessing::postEq: {
- if (!mEngineConfigApplied.postEqStage.inUse) return false;
return isChannelConfigValid(dp.get<DynamicsProcessing::postEq>());
}
case DynamicsProcessing::mbc: {
- if (!mEngineConfigApplied.mbcStage.inUse) return false;
return isChannelConfigValid(dp.get<DynamicsProcessing::mbc>());
}
case DynamicsProcessing::preEqBand: {
- if (!mEngineConfigApplied.preEqStage.inUse) return false;
return isBandConfigValid(dp.get<DynamicsProcessing::preEqBand>(),
mEngineConfigApplied.preEqStage.bandCount);
}
case DynamicsProcessing::postEqBand: {
- if (!mEngineConfigApplied.postEqStage.inUse) return false;
return isBandConfigValid(dp.get<DynamicsProcessing::postEqBand>(),
mEngineConfigApplied.postEqStage.bandCount);
}
case DynamicsProcessing::mbcBand: {
- if (!mEngineConfigApplied.mbcStage.inUse) return false;
return isBandConfigValid(dp.get<DynamicsProcessing::mbcBand>(),
mEngineConfigApplied.mbcStage.bandCount);
}
case DynamicsProcessing::limiter: {
- if (!mEngineConfigApplied.limiterInUse) return false;
return isChannelConfigValid(dp.get<DynamicsProcessing::limiter>());
}
case DynamicsProcessing::inputGain: {
diff --git a/audio/aidl/vts/VtsHalLoudnessEnhancerTargetTest.cpp b/audio/aidl/vts/VtsHalLoudnessEnhancerTargetTest.cpp
index 7f0091f..a075423 100644
--- a/audio/aidl/vts/VtsHalLoudnessEnhancerTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalLoudnessEnhancerTargetTest.cpp
@@ -156,6 +156,7 @@
}
void SetUp() override {
+ SKIP_TEST_IF_DATA_UNSUPPORTED(mDescriptor.common.flags);
SetUpLoudnessEnhancer();
// Creating AidlMessageQueues
@@ -164,7 +165,10 @@
mOutputMQ = std::make_unique<EffectHelper::DataMQ>(mOpenEffectReturn.outputDataMQ);
}
- void TearDown() override { TearDownLoudnessEnhancer(); }
+ void TearDown() override {
+ SKIP_TEST_IF_DATA_UNSUPPORTED(mDescriptor.common.flags);
+ TearDownLoudnessEnhancer();
+ }
// Fill inputBuffer with random values between -kMaxAudioSample to kMaxAudioSample
void generateInputBuffer() {
diff --git a/audio/aidl/vts/VtsHalVolumeTargetTest.cpp b/audio/aidl/vts/VtsHalVolumeTargetTest.cpp
index 059d6ab..1c1489d 100644
--- a/audio/aidl/vts/VtsHalVolumeTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalVolumeTargetTest.cpp
@@ -163,8 +163,14 @@
// Convert Decibel value to Percentage
int percentageDb(float level) { return std::round((1 - (pow(10, level / 20))) * 100); }
- void SetUp() override { ASSERT_NO_FATAL_FAILURE(SetUpVolumeControl()); }
- void TearDown() override { TearDownVolumeControl(); }
+ void SetUp() override {
+ SKIP_TEST_IF_DATA_UNSUPPORTED(mDescriptor.common.flags);
+ ASSERT_NO_FATAL_FAILURE(SetUpVolumeControl());
+ }
+ void TearDown() override {
+ SKIP_TEST_IF_DATA_UNSUPPORTED(mDescriptor.common.flags);
+ TearDownVolumeControl();
+ }
static constexpr int kMaxAudioSample = 1;
static constexpr int kTransitionDuration = 300;