diff options
author | Matthew Hoops | 2011-04-08 17:04:29 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-04-08 17:04:29 -0400 |
commit | faee277978c54ccb3dcccfedc75ddb31f44e630f (patch) | |
tree | beee5c5b3ff3439b67076e58dc49246e9c4bdc9f /common | |
parent | 88ebf13077a072ac0b3100e54f2949db46960e5e (diff) | |
download | scummvm-rg350-faee277978c54ccb3dcccfedc75ddb31f44e630f.tar.gz scummvm-rg350-faee277978c54ccb3dcccfedc75ddb31f44e630f.tar.bz2 scummvm-rg350-faee277978c54ccb3dcccfedc75ddb31f44e630f.zip |
COMMON: Add a DisposeAfterUse flag to QuickTimeParser
Diffstat (limited to 'common')
-rw-r--r-- | common/quicktime.cpp | 13 | ||||
-rw-r--r-- | common/quicktime.h | 7 |
2 files changed, 14 insertions, 6 deletions
diff --git a/common/quicktime.cpp b/common/quicktime.cpp index d40f279f15..fe48cfdcb1 100644 --- a/common/quicktime.cpp +++ b/common/quicktime.cpp @@ -52,6 +52,7 @@ QuickTimeParser::QuickTimeParser() { _scaleFactorX = 1; _scaleFactorY = 1; _resFork = new Common::MacResManager(); + _disposeFileHandle = DisposeAfterUse::YES; initParseTable(); } @@ -61,12 +62,13 @@ QuickTimeParser::~QuickTimeParser() { delete _resFork; } -bool QuickTimeParser::loadFile(const Common::String &filename) { +bool QuickTimeParser::parseFile(const Common::String &filename) { if (!_resFork->open(filename) || !_resFork->hasDataFork()) return false; _foundMOOV = false; _numStreams = 0; + _disposeFileHandle = DisposeAfterUse::YES; MOVatom atom = { 0, 0, 0xffffffff }; @@ -98,15 +100,16 @@ bool QuickTimeParser::loadFile(const Common::String &filename) { return true; } -bool QuickTimeParser::loadStream(Common::SeekableReadStream *stream) { +bool QuickTimeParser::parseStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle) { _fd = stream; _foundMOOV = false; _numStreams = 0; + _disposeFileHandle = disposeFileHandle; MOVatom atom = { 0, 0, 0xffffffff }; if (readDefault(atom) < 0 || !_foundMOOV) { - _fd = 0; + close(); return false; } @@ -724,7 +727,9 @@ void QuickTimeParser::close() { _numStreams = 0; - delete _fd; + if (_disposeFileHandle == DisposeAfterUse::YES) + delete _fd; + _fd = 0; } diff --git a/common/quicktime.h b/common/quicktime.h index 7770860507..42b48bbb94 100644 --- a/common/quicktime.h +++ b/common/quicktime.h @@ -58,13 +58,14 @@ public: * Load a QuickTime file * @param filename the filename to load */ - bool loadFile(const Common::String &filename); + bool parseFile(const Common::String &filename); /** * Load a QuickTime file from a SeekableReadStream * @param stream the stream to load + * @param disposeFileHandle whether to delete the stream after use */ - bool loadStream(Common::SeekableReadStream *stream); + bool parseStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle = DisposeAfterUse::YES); /** * Close a QuickTime file @@ -84,6 +85,8 @@ protected: // This is the file handle from which data is read from. It can be the actual file handle or a decompressed stream. Common::SeekableReadStream *_fd; + DisposeAfterUse::Flag _disposeFileHandle; + struct MOVatom { uint32 type; uint32 offset; |