Skip to content

Commit 086d784

Browse files
VPAAMP-28: Merge MonitorLatency and RateCorrectionWorkerThread
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>
1 parent 0d6d941 commit 086d784

18 files changed

Lines changed: 111 additions & 360 deletions

‎AampConfig.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ static const ConfigLookupEntryInt mConfigLookupTableInt[AAMPCONFIG_INT_COUNT+CON
457457
{0,"timeBasedBufferSeconds",eAAMPConfig_TimeBasedBufferSeconds,true,eCONFIG_RANGE_PLAYBACK_OFFSET},
458458
{DEFAULT_MAX_DOWNLOAD_BUFFER,"maxDownloadBuffer",eAAMPConfig_MaxDownloadBuffer,true,eCONFIG_RANGE_PLAYBACK_OFFSET},
459459
{DEFAULT_TELEMETRY_REPORT_INTERVAL,"telemetryInterval",eAAMPConfig_TelemetryInterval,true},
460-
{0,"rateCorrectionDelay", eAAMPConfig_RateCorrectionDelay,true},
461460
{-1,"harvestDuration",eAAMPConfig_HarvestDuration,false,eCONFIG_RANGE_HARVEST_DURATION},
462461
{DEFAULT_SUBTITLE_CLOCK_SYNC_INTERVAL_S,"subtitleClockSyncInterval",eAAMPConfig_SubtitleClockSyncInterval,true},
463462
{eABSOLUTE_PROGRESS_WITHOUT_AVAILABILITY_START,"preferredAbsoluteReporting",eAAMPConfig_PreferredAbsoluteProgressReporting,true, eCONFIG_RANGE_ABSOLUTE_REPORTING},

‎AampConfig.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ typedef enum
308308
eAAMPConfig_TimeBasedBufferSeconds,
309309
eAAMPConfig_MaxDownloadBuffer, /**< Max download buffer in seconds, this can be used to limit player download job scheduling for DASH*/
310310
eAAMPConfig_TelemetryInterval, /**< time interval for the telemetry reporting*/
311-
eAAMPConfig_RateCorrectionDelay, /**< Delay Rate Correction upon discontinuity in seconds */
312311
eAAMPConfig_HarvestDuration, /**< Harvest duration time */
313312
eAAMPConfig_SubtitleClockSyncInterval, /**< time interval for synchronizing subtitle clock */
314313
eAAMPConfig_PreferredAbsoluteProgressReporting, /**< Preferred settings for absolute progress reporting**/

‎AampLatencyMonitor.cpp‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,12 @@ void AampLatencyMonitor::EnableRateCorrection(bool enabled)
196196
}
197197

198198
mCorrectionEnabled.store(enabled);
199-
// Wake the worker so it can immediately reset the rate if needed.
199+
if (!enabled)
200+
{
201+
// Synchronously reset the pipeline rate to normal so mCurrentRate stays in sync
202+
// with the GStreamer seek that follows (e.g. FlushTrack), before the worker wakes.
203+
ResetToNormalRate();
204+
}
200205
{
201206
std::lock_guard<std::mutex> lock(mSleepMutex);
202207
mWakeupSignalled = true;

‎AampLatencyMonitor.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ class AampLatencyMonitor
185185
*/
186186
void EnableRateCorrection(bool enabled);
187187

188+
/**
189+
* @brief Returns true if rate correction is currently enabled.
190+
* Thread-safe (atomic load).
191+
*/
192+
bool IsRateCorrectionEnabled() const { return mCorrectionEnabled.load(); }
193+
188194
/**
189195
* @brief Returns the playback rate most recently applied by this monitor.
190196
*

‎aampgstplayer.cpp‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -950,12 +950,6 @@ void AAMPGstPlayer::FlushTrack(AampMediaType type,double pos)
950950
double audioDelta = aamp->mAudioDelta;
951951
double subDelta = aamp->mSubtitleDelta;
952952
double rate = playerInstance->FlushTrack(mediaType, pos, audioDelta, subDelta);
953-
954-
if(aamp->mCorrectionRate != rate)
955-
{
956-
AAMPLOG_MIL("Reset Rate Correction to 1");
957-
aamp->mCorrectionRate = rate;
958-
}
959953
}
960954

961955
/**
@@ -1076,8 +1070,6 @@ void AAMPGstPlayer::Flush(double position, int rate, bool shouldTearDown)
10761070
//reset buffer control states prior to gstreamer flush so that the first needs_data event is caught
10771071
privateContext->mBufferControl[i].flush();
10781072
}
1079-
1080-
aamp->mCorrectionRate = (double)AAMP_NORMAL_PLAY_RATE;
10811073
}
10821074
}
10831075

‎fragmentcollector_hls.cpp‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4023,7 +4023,8 @@ AAMPStatusType StreamAbstractionAAMP_HLS::Init(TuneType tuneType)
40234023
video->playTarget = 0;
40244024
subtitle->playTarget = 0;
40254025
aamp->NotifyOnEnteringLive();
4026-
aamp->mDisableRateCorrection = false;
4026+
// Re-enable latency rate correction after seeking to live edge.
4027+
aamp->EnableLatencyMonitor(true);
40274028
}
40284029
else if (((eTUNETYPE_SEEK == tuneType) || (eTUNETYPE_RETUNE == tuneType) || (eTUNETYPE_NEW_SEEK == tuneType)) && (this->rate > 0))
40294030
{
@@ -4049,7 +4050,8 @@ AAMPStatusType StreamAbstractionAAMP_HLS::Init(TuneType tuneType)
40494050
aamp->NotifyOnEnteringLive();
40504051
}
40514052
AAMPLOG_INFO("StreamAbstractionAAMP_HLS: Live latency correction is enabled due to the seek (rate=%f) to live window!!", this->rate);
4052-
aamp->mDisableRateCorrection = false;
4053+
// Re-enable latency rate correction; StartLatencyMonitor() is protected.
4054+
aamp->EnableLatencyMonitor(true);
40534055
}
40544056
else
40554057
{
@@ -7020,7 +7022,7 @@ void StreamAbstractionAAMP_HLS::RefreshTrack(AampMediaType type)
70207022
}
70217023
track->AbortWaitForCachedAndFreeFragment(true);
70227024
aamp->StopTrackInjection(type);
7023-
aamp->mDisableRateCorrection = true;
7025+
aamp->EnableLatencyMonitor(false);
70247026
if(aamp->IsLive() && !track->seamlessAudioSwitchInProgress)
70257027
{
70267028
// Abort ongoing wait for playlist refresh, so the track change can be processed immediately.

‎fragmentcollector_mpd.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3659,7 +3659,7 @@ AAMPStatusType StreamAbstractionAAMP_MPD::Init(TuneType tuneType)
36593659
notifyEnteringLive = true;
36603660
}
36613661
AAMPLOG_INFO("StreamAbstractionAAMP_MPD: Live latency correction is enabled due to the seek (rate=%f) to live window!!", currentRate);
3662-
aamp->mDisableRateCorrection = false;
3662+
aamp->EnableLatencyMonitor(true);
36633663
}
36643664

36653665
if (mLowLatencyMode && !liveAdjust)
@@ -6495,7 +6495,7 @@ void StreamAbstractionAAMP_MPD::RefreshTrack(AampMediaType type)
64956495
}
64966496
track->AbortWaitForCachedAndFreeFragment(true);
64976497
aamp->StopTrackInjection(type);
6498-
aamp->mDisableRateCorrection = true;
6498+
aamp->EnableLatencyMonitor(false);
64996499
}
65006500
}
65016501

‎main_aamp.cpp‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -949,14 +949,8 @@ void PlayerInstanceAAMP::SetRateInternal(float rate,int overshootcorrection)
949949
}
950950
aamp->mSinkPaused = true;
951951

952-
if(aamp->GetLLDashServiceData()->lowLatencyMode)
953-
{
954-
// PAUSED to PLAY without tune, LLD rate correction is disabled to keep position
955-
AAMPLOG_INFO("LL-Dash speed correction disabled after Pause");
956-
aamp->EnableLatencyMonitor(false);
957-
}
958-
AAMPLOG_INFO("StreamAbstractionAAMP_MPD: Live latency correction is disabled due to the Pause operation!!");
959-
aamp->mDisableRateCorrection = true;
952+
AAMPLOG_INFO("Latency correction is disabled due to the Pause operation!!");
953+
aamp->EnableLatencyMonitor(false);
960954
}
961955
}
962956
else

0 commit comments

Comments
 (0)