[Scummvm-git-logs] scummvm master -> af8e07b943a77b576c293135538bb345ef717dd4
bluegr
noreply at scummvm.org
Wed Aug 24 20:37:37 UTC 2022
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:
af8e07b943 BACKENDS: Move isDataAndCDAudioReadFromSameCD() to AudioCDManager
Commit: af8e07b943a77b576c293135538bb345ef717dd4
https://github.com/scummvm/scummvm/commit/af8e07b943a77b576c293135538bb345ef717dd4
Author: SupSuper (supsuper at gmail.com)
Date: 2022-08-24T23:37:33+03:00
Commit Message:
BACKENDS: Move isDataAndCDAudioReadFromSameCD() to AudioCDManager
Changed paths:
backends/audiocd/audiocd.h
backends/audiocd/default/default-audiocd.h
backends/audiocd/win32/win32-audiocd.cpp
engines/engine.cpp
diff --git a/backends/audiocd/audiocd.h b/backends/audiocd/audiocd.h
index 13ab7f0bf6b..67b6f9a8e0a 100644
--- a/backends/audiocd/audiocd.h
+++ b/backends/audiocd/audiocd.h
@@ -107,8 +107,15 @@ public:
/**
* Checks whether the extracted audio cd tracks exists as files in
* the search paths.
+ * @return true if audio files of the expected naming scheme are found, and supported by ScummVM.
*/
virtual bool existExtractedCDAudioFiles(uint track) = 0;
+
+ /**
+ * Checks if game data are read from the same CD drive which should also play game CD audio.
+ * @return true, if this case is applicable, and the system doesn't allow it.
+ */
+ virtual bool isDataAndCDAudioReadFromSameCD() = 0;
};
#endif
diff --git a/backends/audiocd/default/default-audiocd.h b/backends/audiocd/default/default-audiocd.h
index 75cb0da6d34..5af7fe95efc 100644
--- a/backends/audiocd/default/default-audiocd.h
+++ b/backends/audiocd/default/default-audiocd.h
@@ -48,6 +48,7 @@ public:
virtual void update();
virtual Status getStatus() const; // Subclasses should override for better status results
virtual bool existExtractedCDAudioFiles(uint track);
+ virtual bool isDataAndCDAudioReadFromSameCD() { return false; }
private:
void fillPotentialTrackNames(Common::Array<Common::String> &trackNames, int track) const;
diff --git a/backends/audiocd/win32/win32-audiocd.cpp b/backends/audiocd/win32/win32-audiocd.cpp
index c35c46db835..848de684906 100644
--- a/backends/audiocd/win32/win32-audiocd.cpp
+++ b/backends/audiocd/win32/win32-audiocd.cpp
@@ -151,6 +151,7 @@ public:
void close() override;
bool play(int track, int numLoops, int startFrame, int duration, bool onlyEmulate,
Audio::Mixer::SoundType soundType) override;
+ bool isDataAndCDAudioReadFromSameCD() override;
protected:
bool openCD(int drive) override;
@@ -385,6 +386,26 @@ bool Win32AudioCDManager::tryAddDrive(char drive, DriveList &drives) {
return true;
}
+bool Win32AudioCDManager::isDataAndCDAudioReadFromSameCD() {
+ // It is a known bug under Windows that games that play CD audio cause
+ // ScummVM to crash if the data files are read from the same CD.
+ char driveLetter;
+ const Common::FSNode gameDataDir(ConfMan.get("path"));
+ if (!gameDataDir.getPath().empty()) {
+ driveLetter = gameDataDir.getPath()[0];
+ } else {
+ // That's it! I give up!
+ Common::FSNode currentDir(".");
+ if (!currentDir.getPath().empty()) {
+ driveLetter = currentDir.getPath()[0];
+ } else {
+ return false;
+ }
+ }
+
+ return Win32::isDriveCD(driveLetter);
+}
+
AudioCDManager *createWin32AudioCDManager() {
return new Win32AudioCDManager();
}
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 97b50b3bc71..d88f095ecfe 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -19,12 +19,6 @@
*
*/
-#if defined(WIN32)
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include "backends/platform/sdl/win32/win32_wrapper.h"
-#endif
-
#include "engines/engine.h"
#include "engines/dialogs.h"
#include "engines/util.h"
@@ -496,28 +490,13 @@ bool Engine::existExtractedCDAudioFiles(uint track) {
* @return true, if this case is applicable and the warning is displayed
*/
bool Engine::isDataAndCDAudioReadFromSameCD() {
-#if defined(WIN32)
- // It is a known bug under Windows that games that play CD audio cause
- // ScummVM to crash if the data files are read from the same CD. Check
- // if this appears to be the case and issue a warning.
-
// If we can find a compressed audio track, then it should be ok even
// if it's running from CD.
- char driveLetter;
- const Common::FSNode gameDataDir(ConfMan.get("path"));
- if (!gameDataDir.getPath().empty()) {
- driveLetter = gameDataDir.getPath()[0];
- } else {
- // That's it! I give up!
- Common::FSNode currentDir(".");
- if (!currentDir.getPath().empty()) {
- driveLetter = currentDir.getPath()[0];
- } else {
- return false;
- }
+ if (existExtractedCDAudioFiles()) {
+ return false;
}
- if (Win32::isDriveCD(driveLetter)) {
+ if (g_system->getAudioCDManager()->isDataAndCDAudioReadFromSameCD()) {
GUI::MessageDialog dialog(
_("You appear to be playing this game directly\n"
"from the CD. This is known to cause problems,\n"
@@ -527,7 +506,6 @@ bool Engine::isDataAndCDAudioReadFromSameCD() {
dialog.runModal();
return true;
}
-#endif // defined(WIN32)
return false;
}
More information about the Scummvm-git-logs
mailing list