Skip to content

Commit 9c528ca

Browse files
committed
[chooser][demux] Fix screen resolution false positives and audio deadlock on STREAMCHANGE
Fix 1: Screen Resolution False Positives CRepresentationChooserDefault::CheckResolution() compared the user-configured resolution limit (m_screenWidth) against the actual physical hardware resolution (m_screenCurrentWidth), resulting in perpetual false positives every 10 seconds. Dedicated tracking variables (m_screenLastWidth, m_screenLastHeight) now correctly isolate physical window resize detection from the addon's maximum quality configuration limits. Fix 2: Audio Deadlock on Quality STREAMCHANGE When a bandwidth fluctuation triggered a representation change, Kodi Core reopened all active streams sequentially. If the first stream (Video) evaluated to no quality change, the m_checkCoreReopen optimization flag short-circuited all further OpenStream callbacks. If a subsequent stream (Audio) did change quality, its Reset() and reconstruction was skipped entirely, leaving it stuck at EVENT_TYPE::REP_CHANGE and permanently blocking segment downloads. This commit hoists a !streamChanged conditional to guard the entire m_checkCoreReopen block, guaranteeing that a formally changed stream bypasses the fast-path optimization and executes its native Reset() cycle.
1 parent e8e47b4 commit 9c528ca

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/common/ChooserDefault.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ void CRepresentationChooserDefault::SetSecureSession(const bool isSecureSession)
9191

9292
void CRepresentationChooserDefault::PostInit()
9393
{
94+
m_screenLastWidth = m_screenCurrentWidth;
95+
m_screenLastHeight = m_screenCurrentHeight;
96+
9497
RefreshResolution();
9598

9699
if (!m_bandwidthInitAuto)
@@ -116,7 +119,7 @@ void CRepresentationChooserDefault::PostInit()
116119

117120
void CRepresentationChooserDefault::CheckResolution()
118121
{
119-
if (m_screenWidth != m_screenCurrentWidth || m_screenHeight != m_screenCurrentHeight)
122+
if (m_screenLastWidth != m_screenCurrentWidth || m_screenLastHeight != m_screenCurrentHeight)
120123
{
121124
// Update the screen resolution values only after n seconds
122125
// to prevent too fast update when Kodi window will be resized
@@ -128,6 +131,8 @@ void CRepresentationChooserDefault::CheckResolution()
128131
return;
129132
}
130133
RefreshResolution();
134+
m_screenLastWidth = m_screenCurrentWidth;
135+
m_screenLastHeight = m_screenCurrentHeight;
131136
m_screenResLastUpdate = std::chrono::steady_clock::now();
132137
LOG::Log(LOGDEBUG, "[Repr. chooser] Screen resolution has changed: %ix%i", m_screenCurrentWidth,
133138
m_screenCurrentHeight);

src/common/ChooserDefault.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class ATTR_DLL_LOCAL CRepresentationChooserDefault : public IRepresentationChoos
4949

5050
int m_screenWidth{0};
5151
int m_screenHeight{0};
52+
int m_screenLastWidth{0};
53+
int m_screenLastHeight{0};
5254
std::optional<std::chrono::steady_clock::time_point> m_screenResLastUpdate;
5355

5456
std::pair<int, int> m_screenResMax; // Max resolution for non-protected video content

src/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ bool CInputStreamAdaptive::OpenStream(int streamid)
221221
}
222222
}
223223

224-
if (m_checkCoreReopen)
224+
bool streamChanged{stream->m_adStream.StreamChanged()};
225+
226+
if (m_checkCoreReopen && !streamChanged)
225227
{
226228
LOG::Log(LOGDEBUG, "OpenStream(%d): The stream has already been opened", streamid);
227229
return false;

0 commit comments

Comments
 (0)