Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AESinkAudioTrack: Help broken firmwares to make kodi ignore broken delay #24597

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ bool CAESinkAUDIOTRACK::Initialize(AEAudioFormat &format, std::string &device)
}
}

m_superviseAudioDelay =
CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_superviseAudioDelay;

int atChannelMask = AEChannelMapToAUDIOTRACKChannelMask(m_format.m_channelLayout);
m_format.m_channelLayout = AUDIOTRACKChannelMaskToAEChannelMap(atChannelMask);
if (m_encoding == CJNIAudioFormat::ENCODING_IEC61937)
Expand Down Expand Up @@ -825,7 +828,7 @@ unsigned int CAESinkAUDIOTRACK::AddPackets(uint8_t **data, unsigned int frames,
const double max_stuck_delay_ms = m_audiotrackbuffer_sec_orig * 2000.0;
const double stime_ms = 1000.0 * frames / m_format.m_sampleRate;

if (m_stuckCounter * stime_ms > max_stuck_delay_ms)
if (m_superviseAudioDelay && (m_stuckCounter * stime_ms > max_stuck_delay_ms))
{
CLog::Log(LOGERROR, "Sink got stuck with {:f} ms - ask AE for reopening", max_stuck_delay_ms);
usleep(max_stuck_delay_ms * 1000);
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class CAESinkAUDIOTRACK : public IAESink
double m_hw_delay = 0.0;
CJNIAudioTimestamp m_timestamp;
XbmcThreads::EndTime<> m_stampTimer;
bool m_superviseAudioDelay = false;

std::vector<float> m_floatbuf;
std::vector<int16_t> m_shortbuf;
Expand Down
1 change: 1 addition & 0 deletions xbmc/settings/AdvancedSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ void CAdvancedSettings::ParseSettingsFile(const std::string &file)
XMLUtils::GetUInt(pElement, "maxpassthroughoffsyncduration", m_maxPassthroughOffSyncDuration,
10, 100);
XMLUtils::GetBoolean(pElement, "allowmultichannelfloat", m_AllowMultiChannelFloat);
XMLUtils::GetBoolean(pElement, "superviseaudiodelay", m_superviseAudioDelay);
}

pElement = pRootElement->FirstChildElement("x11");
Expand Down
3 changes: 2 additions & 1 deletion xbmc/settings/AdvancedSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler
float m_videoIgnorePercentAtEnd;
float m_audioApplyDrc;
unsigned int m_maxPassthroughOffSyncDuration = 10; // when 10 ms off adjust
bool m_AllowMultiChannelFloat = false; // Android only switch to be remved in v22
bool m_AllowMultiChannelFloat = false; // Android only switch to be removed in v22
bool m_superviseAudioDelay = false; // Android only to correct broken audio firmwares

int m_videoVDPAUScaling;
float m_videoNonLinStretchRatio;
Expand Down