Conversation
varshnie
commented
Mar 23, 2026
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>
…monitor in streamabstarction stop
There was a problem hiding this comment.
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
AampUnderflowMonitorfromStreamAbstractionAAMPconstruction 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
AampUnderflowMonitorunit 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. |
5d2b338 to
7134431
Compare
7134431 to
0581631
Compare
| if(ISCONFIGSET(eAAMPConfig_EnableAampUnderflowMonitor)) | ||
| { | ||
| StopUnderflowMonitor(); | ||
| } |
There was a problem hiding this comment.
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.
| if(ISCONFIGSET(eAAMPConfig_EnableAampUnderflowMonitor)) | ||
| { | ||
| StopUnderflowMonitor(); | ||
| } |
There was a problem hiding this comment.
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).
| if(ISCONFIGSET(eAAMPConfig_EnableAampUnderflowMonitor)) | |
| { | |
| StopUnderflowMonitor(); | |
| } | |
| StopUnderflowMonitor(); |
| 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}) |
There was a problem hiding this comment.
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.
Reason for change:AampUnderflowMonitor Optimization Risks: Medium Signed-off-by: varshnie <varshniblue14@gmail.com>
0581631 to
b50643f
Compare