[FileSystem] Fix playback stop when read external SRT subtitles files #25128
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fix playback stop when read external SRT subtitles files. Read automatically when are named same as MKV file in the same folder.
Motivation and context
Fixes an issue highly reported on forums:
https://forum.kodi.tv/showthread.php?tid=376989&pid=3192688#pid3192688
https://forum.kodi.tv/showthread.php?tid=376989&pid=3194378#pid3194378
https://forum.kodi.tv/showthread.php?tid=377229&pid=3194012#pid3194012
https://forum.kodi.tv/showthread.php?tid=377321&pid=3194890#pid3194890
https://forum.kodi.tv/showthread.php?tid=377304&pid=3194735#pid3194735
...
At first users found that changing the SMB chunk size to 64K fixes the problem and because SMB v1 is limited to 64K it seemed to be related, but can't be this because it only happens with external SRT subtitles: if the user uses SMB v1, then 128K wouldn't go well at all.
Seems chunk size 64K "fixes" this by change. The root cause is a regression from #24504 because (one more time)
READ_CHUNKED
flag has unexpected values. First is opened .mkv file and is flagged correctly but when opening external SRT part of flags are reused here:xbmc/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamFile.cpp
Lines 46 to 50 in 058a35d
Then is signaled with no
READ_AUDIO_VIDEO
to avoid use FileCache for subtitles, this is good. The most immediate solution is use this same flag to avoid use also StreamBuffer for subtitles but this not possible because not all video sources sets thisREAD_AUDIO_VIDEO
flag…. would break Blu-Ray and ISOs which was precisely the main use case of StreamBuffer.The most solid solution thinking in a fix and backport is create a new flag only for this and since FileCache already has a flag to signal not be used (
READ_NO_CACHE
) the same is logical with StreamBuffer: new flagREAD_NO_BUFFER
.In this way no risk of cause regressions because this flag currently only is used in this specific case. I also think it is good to have this flag in case other situations arise in the future where StreamBuffer should not be used in any way.
I have to say that the
READ_CHUNKED
flag has always seemed confusing to me and its use is not entirely clear. On the other hand, the flagREAD_AUDIO_VIDEO
is much clearer since in fact StreamBuffer should only be used for audio/video (same as FileCache).So, after merging this and the backport I would like to do a rework to start use more
READ_AUDIO_VIDEO
and try to eliminate/deprecate use ofREAD_CHUNKED
flag if possible.How has this been tested?
I cannot reproduce this even tested on Sony Android TV (arm-v7) with Play Store version with default settings nor on Shield (arm64/arm-v8). So it is clear that it does not always fails, it depends on more things or the server SMB implementation.
But reproduced locally that SteamBuffer is used to read external SRT subtitles when it shouldn't.
Affected users has confirmed that fix works:
https://forum.kodi.tv/showthread.php?tid=376989&pid=3195845#pid3195845
and even done a double check in current Omega nightly with all others fixes but without this specific fix still failing.
What is the effect on users?
Fix playback stop when read external SRT subtitles files in some setups using SMB and chunk size > 64K.
Screenshots (if appropriate):
Types of change
Checklist: