From a2a9fa50039d69643527020ab6706b319f0e6c62 Mon Sep 17 00:00:00 2001 From: Mikhail Naganov Date: Fri, 19 Apr 2024 14:30:58 -0700 Subject: [PATCH] audio: Use more bursts in audio I/O VTS tests Some audio outputs use A/V sync and requre mode bursts in order to start reporting the presentation position. Bug: 300735639 Bug: 328010709 Test: atest VtsHalAudioCoreTargetTest Change-Id: Icad0942f2ba1dcd6f030a7dc4f37e22fdbd6dd71 --- .../vts/VtsHalAudioCoreModuleTargetTest.cpp | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp index 039695b360..a3248e0f9d 100644 --- a/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp +++ b/audio/aidl/vts/VtsHalAudioCoreModuleTargetTest.cpp @@ -781,6 +781,13 @@ struct StateDag : public Dag { }; 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& v, StreamDescriptor::State f) { return makeNodes(v, makeFinalNode(f)); } @@ -4377,17 +4384,22 @@ std::shared_ptr makeBurstCommands(bool isSync) { using State = StreamDescriptor::State; auto d = std::make_unique(); 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(std::move(d)); } static const NamedCommandSequence kReadSeq =