[Scummvm-git-logs] scummvm master -> 9d663f443ed9461792918251289c2d2584d48679

Scorpeg noreply at scummvm.org
Thu Nov 26 18:35:54 UTC 2026


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
9d663f443e VIDEO: Add support for loading SRT subtitles from streams


Commit: 9d663f443ed9461792918251289c2d2584d48679
    https://github.com/scummvm/scummvm/commit/9d663f443ed9461792918251289c2d2584d48679
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-26T21:35:38+03:00

Commit Message:
VIDEO: Add support for loading SRT subtitles from streams

Changed paths:
    video/subtitles.cpp
    video/subtitles.h


diff --git a/video/subtitles.cpp b/video/subtitles.cpp
index 1a843641214..3ddcf87672f 100644
--- a/video/subtitles.cpp
+++ b/video/subtitles.cpp
@@ -162,20 +162,23 @@ int SRTEntryComparatorBSearch(const void *item1, const void *item2) {
 
 bool SRTParser::parseFile(const Common::Path &fname) {
 	Common::File f;
-
-	cleanup();
-
 	if (!f.open(fname)) {
+		cleanup();
 		return false;
 	}
+	return parseStream(f, fname);
+}
 
-	byte buf[3];
-	f.read(buf, 3);
+bool SRTParser::parseStream(Common::SeekableReadStream &f, const Common::Path &fname) {
+	cleanup();
+
+	byte buf[3] = {0, 0, 0};
+	const uint32 bytesRead = f.read(buf, 3);
 
 	int line = 0;
 
 	// Skip UTF header if present
-	if (buf[0] != 0xef || buf[1] != 0xbb || buf[2] != 0xbf)
+	if (bytesRead != 3 || buf[0] != 0xef || buf[1] != 0xbb || buf[2] != 0xbf)
 		f.seek(0);
 
 	while (!f.eos()) {
@@ -265,6 +268,8 @@ bool SRTParser::parseFile(const Common::Path &fname) {
 }
 
 const Common::Array<SubtitlePart> *SRTParser::getSubtitleParts(uint32 timestamp) const {
+	if (_entries.empty())
+		return nullptr;
 	SRTEntry test(0, timestamp, 0, "");
 	SRTEntry *testptr = &test;
 
diff --git a/video/subtitles.h b/video/subtitles.h
index 6e9dbf38678..5b27965505e 100644
--- a/video/subtitles.h
+++ b/video/subtitles.h
@@ -29,6 +29,10 @@
 
 #include "graphics/surface.h"
 
+namespace Common {
+class SeekableReadStream;
+}
+
 namespace Graphics {
 class Font;
 }
@@ -67,6 +71,7 @@ public:
 
 	void cleanup();
 	bool parseFile(const Common::Path &fname);
+	bool parseStream(Common::SeekableReadStream &stream, const Common::Path &name);
 	void parseTextAndTags(const Common::String &text, Common::Array<SubtitlePart> &parts) const;
 	const Common::Array<SubtitlePart> *getSubtitleParts(uint32 timestamp) const;
 	bool isSfx() const;




More information about the Scummvm-git-logs mailing list