Skip to content

Commit 9060f8c

Browse files
committed
[inputstream.adaptive] Fix audio deadlock on quality STREAMCHANGE
When a bandwidth fluctuation triggered a representation change, Kodi Core handled the `DEMUX_SPECIALID_STREAMCHANGE` packet by sequentially reopening all active streams (e.g., Video 1001, then Audio 1014). If the first stream (Video) evaluated to no quality change, `CInputStreamAdaptive::OpenStream` set the `m_checkCoreReopen = true` optimization flag to short-circuit further sequence callbacks. However, because this block always returned `true`, if the subsequent stream (Audio) *did* change quality, its formal [Reset()](AdaptiveStream.h) and reconstruction was skipped entirely. The bypassed stream's state remained stuck at `EVENT_TYPE::REP_CHANGE`, causing the fragmented sample reader to permanently block new segment downloads, yielding a continuous `AP4_ERROR_EOS` loop and stalling playback. This commit hoists the `!streamChanged` conditional to guard the entire `m_checkCoreReopen` block, guaranteeing that a formally changed stream will bypass the fast-path optimization and execute its native `Reset()` cycle preventing the permanent `EOS` stall.
1 parent c721a0c commit 9060f8c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/main.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,20 +221,19 @@ 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
{
226-
LOG::Log(LOGDEBUG, "OpenStream(%d): The stream has already been opened", streamid);
227-
228228
// If the reader is in EOS from a transient failure during STREAMCHANGE,
229229
// reset it so audio can resume
230230
auto reader = stream->GetReader();
231-
bool isEos = reader && reader->EOS();
232-
bool streamChanged = stream->m_adStream.StreamChanged();
231+
bool isEos{reader && reader->EOS()};
233232

234-
LOG::Log(LOGDEBUG, "OpenStream(%d): Checking recovery. isEos=%d streamChanged=%d",
233+
LOG::Log(LOGDEBUG, "OpenStream(%d): The stream has already been opened. Checking recovery. isEos=%d streamChanged=%d",
235234
streamid, isEos, streamChanged);
236235

237-
if (isEos && !streamChanged)
236+
if (isEos)
238237
{
239238
LOG::Log(LOGINFO, "OpenStream(%d): Recovering stream from transient EOS", streamid);
240239
reader->Reset(false); // Clear EOS

0 commit comments

Comments
 (0)