Skip to content

Feature/vplay 12682 optimization#1217

Open
varshnie wants to merge 4 commits intodev_sprint_25_2from
feature/VPLAY-12682_optimization
Open

Feature/vplay 12682 optimization#1217
varshnie wants to merge 4 commits intodev_sprint_25_2from
feature/VPLAY-12682_optimization

Conversation

@varshnie
Copy link
Contributor

Reason for change:AampUnderflowMonitor Optimization
Risks: Medium

Signed-off-by: varshnie <varshniblue14@gmail.com>

varshnie and others added 3 commits March 23, 2026 12:53
Reason for change:follow-up improvements for AampUnderflowMonitor
Risks: Medium

Signed-off-by: varshnie <varshniblue14@gmail.com>

VPLAY-12605:[L1 Test] AampUnderflowMonitor Tests

Reason for change:Added L1 for AampUnderflowMonitor
Test Procedure:Refer Jira Ticket
Risks: Medium

Signed-off-by: varshnie <varshniblue14@gmail.com>

Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…tionAAMP without stopping the underflow monitor first.

Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
@varshnie varshnie requested a review from a team as a code owner March 23, 2026 12:12
Copilot AI review requested due to automatic review settings March 23, 2026 12:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes and refactors the AampUnderflowMonitor lifecycle (creation/start/stop), adjusts buffering event semantics, and adds/extends unit test coverage around the monitor and its integration with StreamAbstractionAAMP.

Changes:

  • Initialize AampUnderflowMonitor from StreamAbstractionAAMP construction when enabled by config, and start/stop it from protocol-specific Start/Stop paths.
  • Update buffering-change API semantics (SendBufferChangeEvent(bool bufferingStart)) and tune LLD underflow buffer thresholds.
  • Add a new AampUnderflowMonitor unit test target plus additional integration tests/mocks.

Reviewed changes

Copilot reviewed 19 out of 21 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
streamabstraction.cpp Creates underflow monitor in StreamAbstractionAAMP ctor; simplifies Start/Stop/IsRunning wrappers.
StreamAbstractionAAMP.h Adds stronger lifecycle note for StopUnderflowMonitor; removes mutex member.
AampUnderflowMonitor.h Adds CV-based interruptible sleep infrastructure; renames thread member.
AampUnderflowMonitor.cpp Refactors thread lifecycle + polling logic; adds WaitMs().
priv_aamp.h Renames/clarifies SendBufferChangeEvent parameter meaning.
priv_aamp.cpp Updates buffering change emission and adjusts SetBufferingState flow; removes monitor start/stop from some tune/teardown paths.
fragmentcollector_hls.cpp Starts/stops underflow monitor during HLS Start/Stop.
fragmentcollector_mpd.cpp Starts/stops underflow monitor during MPD Start/Stop.
fragmentcollector_progressive.cpp Minor formatting cleanup in Stop().
AampDefine.h Adds LLD-specific underflow low/high buffer constants.
test/utests/tests/CMakeLists.txt Adds AampUnderflowMonitor test subdirectory.
test/utests/tests/AampUnderflowMonitor/CMakeLists.txt New test executable for underflow monitor.
test/utests/tests/AampUnderflowMonitor/FunctionalTests.cpp New functional tests for monitor Start/Stop and underflow transitions.
test/utests/tests/AampUnderflowMonitor/AampUnderflowMonitorTest.cpp Test binary main().
test/utests/tests/StreamAbstractionAAMP/FunctionalTests.cpp Adds wrapper API tests for Start/Stop underflow monitor + mock wiring.
test/utests/tests/StreamAbstractionAAMP/CMakeLists.txt Minor formatting tweak.
test/utests/mocks/MockPrivateInstanceAAMP.h Adds mock hooks used by underflow monitor tests (SetBufferingState, IsSinkCacheEmpty).
test/utests/mocks/MockAampUnderflowMonitor.h New mock interface + global pointer for fake underflow monitor plumbing.
test/utests/fakes/FakePrivateInstanceAAMP.cpp Routes SetBufferingState / IsSinkCacheEmpty through the mock when present; signature rename.
test/utests/fakes/FakeAampUnderflowMonitor.cpp Adds global mock pointer and forwards Start/Stop to it.
test/utests/drm/mocks/aampMocks.cpp Updates signature name for SendBufferChangeEvent.

@varshnie varshnie force-pushed the feature/VPLAY-12682_optimization branch from 5d2b338 to 7134431 Compare March 23, 2026 14:57
Copilot AI review requested due to automatic review settings March 23, 2026 17:20
@varshnie varshnie force-pushed the feature/VPLAY-12682_optimization branch from 7134431 to 0581631 Compare March 23, 2026 17:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 22 changed files in this pull request and generated 6 comments.

Comment on lines +10489 to +10492
if(ISCONFIGSET(eAAMPConfig_EnableAampUnderflowMonitor))
{
StopUnderflowMonitor();
}
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StreamAbstractionAAMP_MPD::Stop() only stops the underflow monitor when clearChannelData is true and the config flag is set. If the monitor was started and Stop(false) is used during teardown/retune paths, the monitor thread may keep running while the stream is being torn down. Consider stopping the monitor based on mUnderflowMonitor existence/running state rather than IsConfigSet, and not gating it on clearChannelData if the stream is about to be destroyed.

Copilot uses AI. Check for mistakes.
Comment on lines +5002 to +5005
if(ISCONFIGSET(eAAMPConfig_EnableAampUnderflowMonitor))
{
StopUnderflowMonitor();
}
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StreamAbstractionAAMP_HLS::Stop() stops the underflow monitor only when the config flag is set. If the monitor exists/runs but the config value changes (or differs between construction and stop), this can leave the monitor thread running during teardown. Prefer stopping based on mUnderflowMonitor existence/running state (or always calling StopUnderflowMonitor() and letting it no-op when null).

Suggested change
if(ISCONFIGSET(eAAMPConfig_EnableAampUnderflowMonitor))
{
StopUnderflowMonitor();
}
StopUnderflowMonitor();

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +46
set(AAMP_SOURCES ${AAMP_ROOT}/streamabstraction.cpp
${AAMP_ROOT}/CachedFragment.cpp
${AAMP_ROOT}/AampUnderflowMonitor.cpp)

add_executable(${EXEC_NAME}
${TEST_SOURCES}
${AAMP_SOURCES})

if (CMAKE_XCODE_BUILD_SYSTEM)
xcode_define_schema(${EXEC_NAME})
endif()

if (COVERAGE_ENABLED)
include(CodeCoverage)
APPEND_COVERAGE_COMPILER_FLAGS()
endif()

target_link_libraries(${EXEC_NAME} fakes -lpthread ${LIBDASH_LINK_LIBRARIES} ${GLIB_LINK_LIBRARIES} ${OS_LD_FLAGS} ${GMOCK_LINK_LIBRARIES} ${GTEST_LINK_LIBRARIES} ${LIBCJSON_LINK_LIBRARIES})
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new AampUnderflowMonitor test target links against the fakes library (which includes test/utests/fakes/FakeAampUnderflowMonitor.cpp via a file(GLOB ...)), while also compiling the real ${AAMP_ROOT}/AampUnderflowMonitor.cpp. That will produce duplicate symbol definitions for AampUnderflowMonitor::* at link time. Consider either (1) removing AampUnderflowMonitor.cpp from this test executable and relying on the fake, or (2) not linking fakes for this target (or excluding FakeAampUnderflowMonitor.cpp from fakes) so the real implementation is tested.

Copilot uses AI. Check for mistakes.
Reason for change:AampUnderflowMonitor Optimization
Risks: Medium

Signed-off-by: varshnie <varshniblue14@gmail.com>
@varshnie varshnie force-pushed the feature/VPLAY-12682_optimization branch from 0581631 to b50643f Compare March 24, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants