[Scummvm-git-logs] scummvm master -> 0670d1a16a6d9ac2890013400f7b5cc559c92f89
sev-
noreply at scummvm.org
Sun Dec 4 19:16:24 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:
0670d1a16a DIRECTOR: Switch to openFileOrDataFork
Commit: 0670d1a16a6d9ac2890013400f7b5cc559c92f89
https://github.com/scummvm/scummvm/commit/0670d1a16a6d9ac2890013400f7b5cc559c92f89
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2022-12-04T20:16:21+01:00
Commit Message:
DIRECTOR: Switch to openFileOrDataFork
Changed paths:
engines/director/lingo/xlibs/aiff.cpp
engines/director/resource.cpp
engines/director/sound.cpp
engines/director/window.cpp
engines/director/window.h
diff --git a/engines/director/lingo/xlibs/aiff.cpp b/engines/director/lingo/xlibs/aiff.cpp
index 739a47fb696..5cdc5dbe624 100644
--- a/engines/director/lingo/xlibs/aiff.cpp
+++ b/engines/director/lingo/xlibs/aiff.cpp
@@ -99,11 +99,10 @@ void AiffXObj::m_duration(int nargs) {
// Mac-ify any mac-paths to make them at least consistent:
Common::replace(filePath, "\\", ":");
- Common::MacResManager macresman;
- if (!macresman.open(Common::Path(pathMakeRelative(filePath), g_director->_dirSeparator))) {
+ auto aiffStream = Common::MacResManager::openFileOrDataFork(Common::Path(pathMakeRelative(filePath), g_director->_dirSeparator));
+ if (!aiffStream) {
error("Failed to open %s", filePath.c_str());
}
- auto aiffStream = macresman.getDataFork();
auto aiffHeader = Audio::AIFFHeader::readAIFFHeader(aiffStream, DisposeAfterUse::YES);
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index e28f29d0133..b774b646740 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -432,12 +432,9 @@ void Window::loadMac(const Common::String movie) {
openMainArchive(movie);
} else {
// The RIFX is located in the data fork of the executable
- _macBinary = new Common::MacResManager();
-
- if (!_macBinary->open(Common::Path(movie, g_director->_dirSeparator)) || !_macBinary->hasDataFork())
+ Common::SeekableReadStream *dataFork = Common::MacResManager::openFileOrDataFork(Common::Path(movie, g_director->_dirSeparator));
+ if (!dataFork)
error("Failed to open Mac binary '%s'", movie.c_str());
-
- Common::SeekableReadStream *dataFork = _macBinary->getDataFork();
_mainArchive = new RIFXArchive();
_mainArchive->setPathName(movie);
diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp
index d7ab7d13f35..a726beac532 100644
--- a/engines/director/sound.cpp
+++ b/engines/director/sound.cpp
@@ -786,11 +786,9 @@ bool SNDDecoder::hasLoopBounds() {
AudioFileDecoder::AudioFileDecoder(Common::String &path)
: AudioDecoder() {
_path = path;
- _macresman = new Common::MacResManager();
}
AudioFileDecoder::~AudioFileDecoder() {
- delete _macresman;
}
Audio::AudioStream *AudioFileDecoder::getAudioStream(bool looping, bool forPuppet, DisposeAfterUse::Flag disposeAfterUse) {
@@ -799,25 +797,10 @@ Audio::AudioStream *AudioFileDecoder::getAudioStream(bool looping, bool forPuppe
Common::Path filePath = Common::Path(pathMakeRelative(_path), g_director->_dirSeparator);
- Common::SeekableReadStream *dataFork = nullptr;
- Common::SeekableReadStream *copiedStream = nullptr;
-
- if (_macresman->open(filePath)) {
-
- dataFork = _macresman->getDataFork();
- }
-
- // Data has to be copied out instead of using the stream from
- // getDataFork() directly because it's possible for this audio
- // to outlive the owning MacResMan, which would otherwise free
- // the stream while it's still being read from.
- if (dataFork != nullptr)
- copiedStream = dataFork->readStream(dataFork->size());
- delete dataFork;
+ Common::SeekableReadStream *copiedStream = Common::MacResManager::openFileOrDataFork(filePath);
if (copiedStream == nullptr) {
warning("Failed to open %s", _path.c_str());
- delete copiedStream;
return nullptr;
}
diff --git a/engines/director/window.cpp b/engines/director/window.cpp
index 207841366e6..060a712b64b 100644
--- a/engines/director/window.cpp
+++ b/engines/director/window.cpp
@@ -51,7 +51,6 @@ Window::Window(int id, bool scrollable, bool resizable, bool editable, Graphics:
_currentMovie = nullptr;
_mainArchive = nullptr;
- _macBinary = nullptr;
_nextMovie.frameI = -1;
_newMovieStarted = true;
@@ -72,10 +71,6 @@ Window::Window(int id, bool scrollable, bool resizable, bool editable, Graphics:
Window::~Window() {
delete _soundManager;
delete _currentMovie;
- if (_macBinary) {
- delete _macBinary;
- _macBinary = nullptr;
- }
if (_puppetTransition)
delete _puppetTransition;
}
diff --git a/engines/director/window.h b/engines/director/window.h
index d3ec8a2b61e..12f21f3c410 100644
--- a/engines/director/window.h
+++ b/engines/director/window.h
@@ -207,7 +207,6 @@ private:
DirectorSound *_soundManager;
bool _isStage;
Archive *_mainArchive;
- Common::MacResManager *_macBinary;
Movie *_currentMovie;
Common::String _currentPath;
Common::StringArray _movieQueue;
More information about the Scummvm-git-logs
mailing list