aboutsummaryrefslogtreecommitdiff
path: root/audio/decoders
diff options
context:
space:
mode:
authorMatthew Hoops2011-04-08 17:04:29 -0400
committerMatthew Hoops2011-04-08 17:04:29 -0400
commitfaee277978c54ccb3dcccfedc75ddb31f44e630f (patch)
treebeee5c5b3ff3439b67076e58dc49246e9c4bdc9f /audio/decoders
parent88ebf13077a072ac0b3100e54f2949db46960e5e (diff)
downloadscummvm-rg350-faee277978c54ccb3dcccfedc75ddb31f44e630f.tar.gz
scummvm-rg350-faee277978c54ccb3dcccfedc75ddb31f44e630f.tar.bz2
scummvm-rg350-faee277978c54ccb3dcccfedc75ddb31f44e630f.zip
COMMON: Add a DisposeAfterUse flag to QuickTimeParser
Diffstat (limited to 'audio/decoders')
-rw-r--r--audio/decoders/quicktime.cpp29
-rw-r--r--audio/decoders/quicktime.h14
2 files changed, 34 insertions, 9 deletions
diff --git a/audio/decoders/quicktime.cpp b/audio/decoders/quicktime.cpp
index 53cce30125..62a6f6e404 100644
--- a/audio/decoders/quicktime.cpp
+++ b/audio/decoders/quicktime.cpp
@@ -46,16 +46,16 @@ QuickTimeAudioDecoder::~QuickTimeAudioDecoder() {
delete _audStream;
}
-bool QuickTimeAudioDecoder::loadFile(const Common::String &filename) {
- if (!Common::QuickTimeParser::loadFile(filename))
+bool QuickTimeAudioDecoder::loadAudioFile(const Common::String &filename) {
+ if (!Common::QuickTimeParser::parseFile(filename))
return false;
init();
return true;
}
-bool QuickTimeAudioDecoder::loadStream(Common::SeekableReadStream *stream) {
- if (!Common::QuickTimeParser::loadStream(stream))
+bool QuickTimeAudioDecoder::loadAudioStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle) {
+ if (!Common::QuickTimeParser::parseStream(stream, disposeFileHandle))
return false;
init();
@@ -319,8 +319,12 @@ public:
QuickTimeAudioStream() {}
~QuickTimeAudioStream() {}
- bool loadFile(const Common::String &filename) {
- return QuickTimeAudioDecoder::loadFile(filename) && _audioStreamIndex >= 0 && _audStream;
+ bool openFromFile(const Common::String &filename) {
+ return QuickTimeAudioDecoder::loadAudioFile(filename) && _audioStreamIndex >= 0 && _audStream;
+ }
+
+ bool openFromStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle) {
+ return QuickTimeAudioDecoder::loadAudioStream(stream, disposeFileHandle) && _audioStreamIndex >= 0 && _audStream;
}
// AudioStream API
@@ -358,7 +362,18 @@ public:
SeekableAudioStream *makeQuickTimeStream(const Common::String &filename) {
QuickTimeAudioStream *audioStream = new QuickTimeAudioStream();
- if (!audioStream->loadFile(filename)) {
+ if (!audioStream->openFromFile(filename)) {
+ delete audioStream;
+ return 0;
+ }
+
+ return audioStream;
+}
+
+SeekableAudioStream *makeQuickTimeStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse) {
+ QuickTimeAudioStream *audioStream = new QuickTimeAudioStream();
+
+ if (!audioStream->openFromStream(stream, disposeAfterUse)) {
delete audioStream;
return 0;
}
diff --git a/audio/decoders/quicktime.h b/audio/decoders/quicktime.h
index 9e2e95b705..be4d1097da 100644
--- a/audio/decoders/quicktime.h
+++ b/audio/decoders/quicktime.h
@@ -50,13 +50,13 @@ public:
* Load a QuickTime audio file
* @param filename the filename to load
*/
- bool loadFile(const Common::String &filename);
+ bool loadAudioFile(const Common::String &filename);
/**
* Load a QuickTime audio file from a SeekableReadStream
* @param stream the stream to load
*/
- bool loadStream(Common::SeekableReadStream *stream);
+ bool loadAudioStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle);
protected:
struct AudioSampleDesc : public Common::QuickTimeParser::SampleDesc {
@@ -93,6 +93,16 @@ protected:
*/
SeekableAudioStream *makeQuickTimeStream(const Common::String &filename);
+/**
+ * Try to load a QuickTime sound file from the given seekable stream and create a SeekableAudioStream
+ * from that data.
+ *
+ * @param stream the SeekableReadStream from which to read the data
+ * @param disposeAfterUse whether to delete the stream after use
+ * @return a new SeekableAudioStream, or NULL, if an error occurred
+ */
+SeekableAudioStream *makeQuickTimeStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
+
} // End of namespace Audio
#endif