[Scummvm-git-logs] scummvm master -> c2bc9a20862652b3f2eb3746f42d9d777a0a9e0d

sev- noreply at scummvm.org
Sun Nov 5 21:17:06 UTC 2023


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

Summary:
c2bc9a2086 AGS: Avoid playing unsupported WMV videos and look for alternatives


Commit: c2bc9a20862652b3f2eb3746f42d9d777a0a9e0d
    https://github.com/scummvm/scummvm/commit/c2bc9a20862652b3f2eb3746f42d9d777a0a9e0d
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-11-05T22:17:03+01:00

Commit Message:
AGS: Avoid playing unsupported WMV videos and look for alternatives

Prevent playing unsupported WIndows Media videos to avoid engine crashing,
and look for alternative formats. Also warn the user if no alternative is available
and continue.

Changed paths:
    engines/ags/engine/ac/global_video.cpp


diff --git a/engines/ags/engine/ac/global_video.cpp b/engines/ags/engine/ac/global_video.cpp
index f2418ee4a7a..6d046ac4cd7 100644
--- a/engines/ags/engine/ac/global_video.cpp
+++ b/engines/ags/engine/ac/global_video.cpp
@@ -150,18 +150,53 @@ void pause_sound_if_necessary_and_play_video(const char *name, int flags, VideoS
 		stop_all_sound_and_music();
 	}
 
-	if ((strlen(name) > 3) && (ags_stricmp(&name[strlen(name) - 3], "ogv") == 0)) {
-		play_theora_video(name, flags, skip, true);
-	} else if ((strlen(name) > 3) && (ags_stricmp(&name[strlen(name) - 3], "mpg") == 0)) {
-		play_mpeg_video(name, flags, skip, true);
-	} else if ((strlen(name) > 3) && (ags_stricmp(&name[strlen(name) - 3], "avi") == 0)) {
-		play_avi_video(name, flags, skip, true);
-	} else {
+	char *filename = ags_strdup(name);
+	bool play_success = false;
+	bool wmv = false;
+
+	if (strlen(filename) > 3) {
+		char *file_ext = &(filename[strlen(filename) - 3]);
+		if ((ags_stricmp(file_ext, "wmv") == 0) || (ags_stricmp(file_ext, "wfl") == 0)) {
+			// WMV is not supported, so let's look for reencoded videos
+			debug("Attempt to load unsupported WMV file - will look for reencoded equivalents");
+			strncpy(file_ext, "ogv", 4);
+			wmv = true;
+		}
+
+		if (ags_stricmp(file_ext, "ogv") == 0) {
+			if (wmv)
+				debug(0, "Looking for '%s'", filename);
+			play_success = play_theora_video(filename, flags, skip, !wmv);
+			if (!play_success && wmv)
+				strncpy(file_ext, "mpg", 4);
+		}
+
+		if (!play_success && (ags_stricmp(file_ext, "mpg") == 0)) {
+			if (wmv)
+				debug(0, "Looking for '%s'", filename);
+			play_success = play_mpeg_video(filename, flags, skip, !wmv);
+			if (!play_success && wmv)
+				strncpy(file_ext, "avi", 4);
+		}
+
+		if (!play_success && (ags_stricmp(file_ext, "avi") == 0)) {
+			if (wmv)
+				debug(0, "Looking for '%s'", filename);
+			play_success = play_avi_video(filename, flags, skip, !wmv);
+			if (!play_success && wmv) {
+				warning("No suitable equivalent found, skipping %s", name);
+				Display("WMV files are not supported!\nPlease convert %s\nto a suitable format (OGV/MPG). \nConsult ScummVM wiki for details.\n\nThe game will now continue.", name);
+			}
+		}
+	}
+
+	if (!play_success && !wmv) {
 		// Unsure what the video type is, so try each in turn
 		if (!play_avi_video(name, flags, skip, false) &&
-		        !play_mpeg_video(name, flags, skip, false) &&
-		        !play_theora_video(name, flags, skip, false))
+			!play_mpeg_video(name, flags, skip, false) &&
+			!play_theora_video(name, flags, skip, false)) {
 			Display("Unsupported video '%s'", name);
+		}
 	}
 
 	// Restore the game audio if we stopped them before the video playback




More information about the Scummvm-git-logs mailing list