Skip to content

VPAAMP-28: Merge MonitorLatency and RateCorrectionWorkerThread#1332

Merged
pstroffolino merged 3 commits into
dev_sprint_25_2from
feature/VPAAMP-28
May 26, 2026
Merged

VPAAMP-28: Merge MonitorLatency and RateCorrectionWorkerThread#1332
pstroffolino merged 3 commits into
dev_sprint_25_2from
feature/VPAAMP-28

Conversation

@srikanthreddybijjam-comcast
Copy link
Copy Markdown
Contributor

@srikanthreddybijjam-comcast srikanthreddybijjam-comcast commented Apr 21, 2026

Reason for change: Merged the new flow
Test Procedure: Refer jira ticket VPAAMP-28
Priority: P2

Copy link
Copy Markdown
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 (VPAAMP-28) consolidates the legacy live-latency “rate correction worker thread” logic into the unified AampLatencyMonitor flow, updating both production code paths and related unit tests to use EnableLatencyMonitor() / IsLatencyMonitorEnabled() rather than direct mDisableRateCorrection state.

Changes:

  • Remove the dedicated rate-correction thread/members and route enable/disable through AampLatencyMonitor.
  • Update stream abstractions (HLS/DASH/core) and playback control paths to toggle latency monitoring instead of mutating mDisableRateCorrection.
  • Adjust unit tests and fakes to reflect the new latency-monitor interface.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/utests/tests/PrivateInstanceAAMP/PauseOnPlaybackTests.cpp Updates tests to use EnableLatencyMonitor() / IsLatencyMonitorEnabled() expectations.
test/utests/tests/PrivAampTests/PrivAampTests.cpp Removes worker-thread tests and updates tune-related assertions to latency-monitor API.
test/utests/fakes/FakePrivateInstanceAAMP.cpp Removes legacy rate-correction stubs and introduces latency-monitor API stubs (currently incomplete).
streamabstraction.cpp Switches re-enable points from mDisableRateCorrection=false to EnableLatencyMonitor(true).
priv_aamp.h Removes legacy worker-thread members/APIs and adds IsLatencyMonitorEnabled().
priv_aamp.cpp Removes worker-thread implementation and routes enable/disable via AampLatencyMonitor.
main_aamp.cpp Replaces direct member toggling with EnableLatencyMonitor(false) on pause-related flow.
fragmentcollector_mpd.cpp Uses EnableLatencyMonitor(true/false) when entering live / refreshing tracks.
fragmentcollector_hls.cpp Uses EnableLatencyMonitor(true/false) when entering live / refreshing tracks.
aampgstplayer.cpp Changes flush behavior from syncing correction-rate variables to disabling latency monitor.
AampLatencyMonitor.h Adds IsRateCorrectionEnabled() accessor for rate-correction enabled state.
Comments suppressed due to low confidence (1)

priv_aamp.cpp:12714

  • In SetPreferredLanguages(), the new condition uses !mLatencyMonitor->IsRunning() to choose between TuneHelper(eTUNETYPE_SEEK) and TuneHelper(eTUNETYPE_SEEKTOLIVE). Previously this decision was based on mDisableRateCorrection (i.e., whether rate correction was disabled due to user pause/seek). The monitor thread can remain running even when rate correction is disabled, so IsRunning() is not equivalent and may cause unintended seeks to live. Use the rate-correction enabled state instead (e.g., IsLatencyMonitorEnabled()/IsRateCorrectionEnabled()) if the goal is to preserve the prior behavior.
							else if(!mLatencyMonitor->IsRunning())
							{
								TuneHelper(eTUNETYPE_SEEK);
							}
							else
							{
								TuneHelper(eTUNETYPE_SEEKTOLIVE);
							}

Comment thread test/utests/fakes/FakePrivateInstanceAAMP.cpp Outdated
Comment thread aampgstplayer.cpp Outdated
Comment thread aampgstplayer.cpp Outdated
Copy link
Copy Markdown
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 13 out of 13 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

priv_aamp.cpp:12712

  • This retune path used to branch based on whether rate correction was disabled (mDisableRateCorrection). The new check uses !mLatencyMonitor->IsRunning(), which is not equivalent: the monitor can be running while correction is disabled via EnableLatencyMonitor(false). In that case this will incorrectly choose SEEKTOLIVE instead of SEEK. Use the rate-correction enabled flag (e.g., IsLatencyMonitorEnabled() / mLatencyMonitor->IsRateCorrectionEnabled()) for this decision, not the thread running state.
							else if(!mLatencyMonitor->IsRunning())
							{
								TuneHelper(eTUNETYPE_SEEK);
							}
							else
							{
								TuneHelper(eTUNETYPE_SEEKTOLIVE);
							}

Comment thread test/utests/fakes/FakeAampLatencyMonitor.cpp
Comment thread priv_aamp.cpp
Comment thread AampLatencyMonitor.cpp Outdated
Copy link
Copy Markdown
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 14 out of 14 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

priv_aamp.cpp:12720

  • This TuneHelper selection now uses !mLatencyMonitor->IsRunning() to decide between eTUNETYPE_SEEK vs eTUNETYPE_SEEKTOLIVE. That is not equivalent to the previous mDisableRateCorrection check: the latency monitor can remain running while rate correction is temporarily disabled (e.g., during seek/pause), and the player may also not be at the live point. With the current condition, a language/track retune can incorrectly force a seek-to-live when the user is behind live but the monitor thread is still running. Use the rate-correction enabled flag (e.g., IsLatencyMonitorEnabled() / mLatencyMonitor->IsRateCorrectionEnabled()) and/or IsAtLivePoint() to preserve the prior behavior.
							else if(!mLatencyMonitor->IsRunning())
							{
								TuneHelper(eTUNETYPE_SEEK);
							}
							else
							{
								TuneHelper(eTUNETYPE_SEEKTOLIVE);

Comment thread priv_aamp.cpp Outdated
Copy link
Copy Markdown
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 13 out of 13 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

test/utests/tests/AampLatencyMonitorTests/AampLatencyMonitorTestCases.cpp:776

  • There are a few trailing blank lines at the end of the file after the final test case; please remove the extra empty lines to keep the test file tidy and avoid noise in future diffs.

Comment thread priv_aamp.cpp Outdated
Copy link
Copy Markdown
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 13 out of 13 changed files in this pull request and generated 1 comment.

Comment thread test/utests/tests/AampLatencyMonitorTests/AampLatencyMonitorTestCases.cpp Outdated
Copy link
Copy Markdown
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 13 out of 13 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

priv_aamp.cpp:12792

  • In SetPreferredLanguages(), the branch deciding between TuneHelper(eTUNETYPE_SEEK) vs TuneHelper(eTUNETYPE_SEEKTOLIVE) now checks !mLatencyMonitor->IsRunning(). This is not equivalent to the prior mDisableRateCorrection behavior: the latency monitor can be running while rate correction is intentionally disabled (EnableLatencyMonitor(false) makes the worker wait), which would incorrectly force the SEEKTOLIVE path. Consider using the new rate-correction flag (e.g., IsLatencyMonitorEnabled()/mLatencyMonitor->IsRateCorrectionEnabled()) or an explicit “user is at live” condition instead of IsRunning().
							else if(!mLatencyMonitor->IsRunning())
							{
								TuneHelper(eTUNETYPE_SEEK);
							}
							else
							{
								TuneHelper(eTUNETYPE_SEEKTOLIVE);
							}

priv_aamp.cpp:5486

  • TeardownStream() no longer disables/suppresses latency rate correction before stopping/deleting the StreamAbstraction and interacting with the StreamSink. Since AampLatencyMonitor runs on its own thread and can call SetPlayBackRate() concurrently, leaving it enabled during teardown risks racing with sink/stream shutdown (and can apply correction rates during teardown/retune). Consider disabling (EnableLatencyMonitor(false)) or stopping the latency monitor at the start of TeardownStream(), and re-enabling/restarting it after the new tune reaches a stable live/playing state.
	//reset discontinuity related flags
	ResetDiscontinuityInTracks();
	UnblockWaitForDiscontinuityProcessToComplete();
	ResetTrackDiscontinuityIgnoredStatus();
	lock.unlock();
	{
		// Using StreamLock to make sure this is not interfering with GetFile() from PreCachePlaylistDownloadTask
		std::lock_guard<std::recursive_mutex> streamLock(mStreamLock);
		if (mpStreamAbstractionAAMP)

Comment thread test/utests/fakes/FakePrivateInstanceAAMP.cpp Outdated
Comment thread test/utests/tests/AampLatencyMonitorTests/AampLatencyMonitorTestCases.cpp Outdated
Comment thread test/utests/tests/AampLatencyMonitorTests/AampLatencyMonitorTestCases.cpp Outdated
Comment thread test/utests/tests/PrivAampTests/PrivAampTests.cpp Outdated
Comment thread fragmentcollector_hls.cpp Outdated
Comment thread priv_aamp.cpp Outdated
Comment thread priv_aamp.cpp Outdated
Comment thread priv_aamp.cpp Outdated
Comment thread priv_aamp.cpp Outdated
Comment thread streamabstraction.cpp Outdated
Copy link
Copy Markdown
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 18 out of 18 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

aampgstplayer.cpp:1072

  • Flush() still resets the pipeline state, but the previous correction-rate reset was removed without synchronizing the new AampLatencyMonitor state. After a flush, the monitor may keep a stale non-normal mCurrentRate and therefore fail to reapply rate correction when latency still requires it; please sync the monitor’s current rate when the flush succeeds.
	bool ret = playerInstance->Flush(position, rate, shouldTearDown, isAppSeek);
	if(ret)
	{
		for (int i = 0; i < AAMP_TRACK_COUNT; i++)
		{
			//reset buffer control states prior to gstreamer flush so that the first needs_data event is caught
			privateContext->mBufferControl[i].flush();
		}

Comment thread priv_aamp.cpp Outdated
Comment thread AampLatencyMonitor.h
Comment thread AampConfig.h
Comment thread test/utests/fakes/FakePrivateInstanceAAMP.cpp
Comment thread aampgstplayer.cpp
@srikanthreddybijjam-comcast srikanthreddybijjam-comcast force-pushed the feature/VPAAMP-28 branch 3 times, most recently from f74afbf to 0ebb125 Compare May 15, 2026 05:30
Comment thread streamabstraction.cpp Outdated
Comment thread streamabstraction.cpp Outdated
@srikanthreddybijjam-comcast srikanthreddybijjam-comcast force-pushed the feature/VPAAMP-28 branch 3 times, most recently from 65c91ed to 42b629f Compare May 18, 2026 10:27
Comment thread test/utests/fakes/FakeAampLatencyMonitor.cpp Outdated
Comment thread test/utests/fakes/FakePrivateInstanceAAMP.cpp Outdated
Comment thread test/utests/fakes/FakePrivateInstanceAAMP.cpp Outdated
Comment thread test/utests/tests/PrivAampTests/PrivAampTests.cpp Outdated
Comment thread test/utests/tests/PrivAampTests/PrivAampTests.cpp Outdated
Comment thread priv_aamp.cpp Outdated
Comment thread priv_aamp.cpp Outdated
Comment thread priv_aamp.cpp Outdated
Comment thread streamabstraction.cpp
Comment thread streamabstraction.cpp Outdated
@srikanthreddybijjam-comcast srikanthreddybijjam-comcast force-pushed the feature/VPAAMP-28 branch 8 times, most recently from 0930971 to 71c6166 Compare May 25, 2026 09:07
Comment thread priv_aamp.cpp Outdated
Comment thread test/utests/tests/StreamAbstractionAAMP_MPD/FunctionalTests.cpp Outdated
Reason for change: Merged the new flow
Test Procedure: Refer jira ticket VPAAMP-28
Priority: P2

Signed-off-by: srikanthreddybijjam-comcast <srikanthreddybijjam.2000@gmail.com>
@srikanthreddybijjam-comcast srikanthreddybijjam-comcast force-pushed the feature/VPAAMP-28 branch 2 times, most recently from 17b32a2 to ec0297a Compare May 26, 2026 08:38
Reason for change: Merged the new flow
Test Procedure: Refer jira ticket VPAAMP-28
Priority: P2

Signed-off-by: srikanthreddybijjam-comcast <srikanthreddybijjam.2000@gmail.com>
@pstroffolino pstroffolino merged commit f420100 into dev_sprint_25_2 May 26, 2026
6 checks passed
@pstroffolino pstroffolino deleted the feature/VPAAMP-28 branch May 26, 2026 19:45
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.

5 participants