Skip to content

Commit

Permalink
Merge pull request xbmc#25264 from thexai/maxpassthroughoffsyncdurati…
Browse files Browse the repository at this point in the history
…on-rework

VideoPlayerAudio: simplifies max Out-Of-Sync (maxpassthroughoffsyncduration) setting
  • Loading branch information
thexai authored May 28, 2024
2 parents 666939d + 662a7bf commit 16aa281
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 34 deletions.
30 changes: 1 addition & 29 deletions xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,6 @@ void CVideoPlayerAudio::Process()
m_audioStats.Start();
m_disconAdjustCounter = 0;

// Only enable "learning" if advancedsettings m_maxPassthroughOffSyncDuration
// not exists or has it's default 10 ms value, otherwise use advancedsettings value
if (m_disconAdjustTimeMs == 10)
{
m_disconTimer.Set(30s);
m_disconLearning = true;
}
else
{
m_disconLearning = false;
}

bool onlyPrioMsgs = false;

while (!m_bStop)
Expand Down Expand Up @@ -549,23 +537,7 @@ bool CVideoPlayerAudio::ProcessDecoderOutput(DVDAudioFrame &audioframe)
{
double syncerror = m_audioSink.GetSyncError();

if (m_disconLearning)
{
const double syncErr = std::abs(syncerror);
if (syncErr > DVD_MSEC_TO_TIME(m_disconAdjustTimeMs))
m_disconAdjustTimeMs = DVD_TIME_TO_MSEC(syncErr);
if (m_disconTimer.IsTimePast())
{
m_disconLearning = false;
m_disconAdjustTimeMs = (static_cast<double>(m_disconAdjustTimeMs) * 1.15) + 5.0;
if (m_disconAdjustTimeMs > 80) // sanity check
m_disconAdjustTimeMs = 80;

CLog::LogF(LOGINFO, "Changed max allowed Out-Of-Sync value to {} ms due self-learning",
m_disconAdjustTimeMs);
}
}
else if (std::abs(syncerror) > DVD_MSEC_TO_TIME(m_disconAdjustTimeMs))
if (std::abs(syncerror) > DVD_MSEC_TO_TIME(m_disconAdjustTimeMs))
{
double correction = m_pClock->ErrorAdjust(syncerror, "CVideoPlayerAudio::OutputPacket");
if (correction != 0)
Expand Down
4 changes: 1 addition & 3 deletions xbmc/cores/VideoPlayer/VideoPlayerAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ class CVideoPlayerAudio : public CThread, public IDVDStreamPlayerAudio
SInfo m_info;

bool m_displayReset = false;
unsigned int m_disconAdjustTimeMs = 10; // maximum sync-off before adjusting
unsigned int m_disconAdjustTimeMs = 50; // maximum sync-off before adjusting
int m_disconAdjustCounter = 0;
XbmcThreads::EndTime<> m_disconTimer;
bool m_disconLearning = false;
};

2 changes: 1 addition & 1 deletion xbmc/settings/AdvancedSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ void CAdvancedSettings::ParseSettingsFile(const std::string &file)
XMLUtils::GetFloat(pElement, "limiterhold", m_limiterHold, 0.0f, 100.0f);
XMLUtils::GetFloat(pElement, "limiterrelease", m_limiterRelease, 0.001f, 100.0f);
XMLUtils::GetUInt(pElement, "maxpassthroughoffsyncduration", m_maxPassthroughOffSyncDuration,
10, 100);
20, 80);
XMLUtils::GetBoolean(pElement, "allowmultichannelfloat", m_AllowMultiChannelFloat);
XMLUtils::GetBoolean(pElement, "superviseaudiodelay", m_superviseAudioDelay);
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/settings/AdvancedSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler
int m_videoIgnoreSecondsAtStart;
float m_videoIgnorePercentAtEnd;
float m_audioApplyDrc;
unsigned int m_maxPassthroughOffSyncDuration = 10; // when 10 ms off adjust
unsigned int m_maxPassthroughOffSyncDuration = 50; // when 50 ms off adjust
bool m_AllowMultiChannelFloat = false; // Android only switch to be removed in v22
bool m_superviseAudioDelay = false; // Android only to correct broken audio firmwares

Expand Down

0 comments on commit 16aa281

Please sign in to comment.