[Scummvm-cvs-logs] SF.net SVN: scummvm:[49844] scummvm/trunk
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Tue Jun 15 14:33:54 CEST 2010
Revision: 49844
http://scummvm.svn.sourceforge.net/scummvm/?rev=49844&view=rev
Author: fingolfin
Date: 2010-06-15 12:33:54 +0000 (Tue, 15 Jun 2010)
Log Message:
-----------
Modify makeAIFFStream to match the other sound decoder factories
Modified Paths:
--------------
scummvm/trunk/engines/sci/sound/audio.cpp
scummvm/trunk/engines/sword1/music.cpp
scummvm/trunk/sound/decoders/aiff.cpp
scummvm/trunk/sound/decoders/aiff.h
Modified: scummvm/trunk/engines/sci/sound/audio.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/audio.cpp 2010-06-15 12:33:20 UTC (rev 49843)
+++ scummvm/trunk/engines/sci/sound/audio.cpp 2010-06-15 12:33:54 UTC (rev 49844)
@@ -260,9 +260,11 @@
// Compressed audio made by our tool
byte *compressedData = (byte *)malloc(audioRes->size);
assert(compressedData);
- // We copy over the compressed data in our own buffer. If we don't do this resourcemanager may free the data
- // later. All other compression-types already decompress completely into an additional buffer here.
- // MP3/OGG/FLAC decompression works on-the-fly instead.
+ // We copy over the compressed data in our own buffer. We have to do
+ // this, because ResourceManager may free the original data late.
+ // All other compression types already decompress completely into an
+ // additional buffer here. MP3/OGG/FLAC decompression works on-the-fly
+ // instead.
memcpy(compressedData, audioRes->data, audioRes->size);
Common::MemoryReadStream *compressedStream = new Common::MemoryReadStream(compressedData, audioRes->size, DisposeAfterUse::YES);
@@ -319,8 +321,7 @@
*sampleLen = (waveFlags & Audio::FLAG_16BITS ? waveSize >> 1 : waveSize) * 60 / waveRate;
waveStream->seek(0, SEEK_SET);
- audioStream = Audio::makeAIFFStream(*waveStream);
- delete waveStream; // makeAIFFStream doesn't handle this for us
+ audioStream = Audio::makeAIFFStream(waveStream, DisposeAfterUse::YES);
} else if (audioRes->size > 14 && READ_BE_UINT16(audioRes->data) == 1 && READ_BE_UINT16(audioRes->data + 2) == 1
&& READ_BE_UINT16(audioRes->data + 4) == 5 && READ_BE_UINT32(audioRes->data + 10) == 0x00018051) {
// Mac snd detected
Modified: scummvm/trunk/engines/sword1/music.cpp
===================================================================
--- scummvm/trunk/engines/sword1/music.cpp 2010-06-15 12:33:20 UTC (rev 49843)
+++ scummvm/trunk/engines/sword1/music.cpp 2010-06-15 12:33:54 UTC (rev 49844)
@@ -107,7 +107,7 @@
if (!_audioSource) {
sprintf(fileName, "%s.aif", fileBase);
if (_file.open(fileName))
- _audioSource = Audio::makeLoopingAudioStream(Audio::makeAIFFStream(_file), loop ? 0 : 1);
+ _audioSource = Audio::makeLoopingAudioStream(Audio::makeAIFFStream(&_file, DisposeAfterUse::NO), loop ? 0 : 1);
}
if (!_audioSource)
Modified: scummvm/trunk/sound/decoders/aiff.cpp
===================================================================
--- scummvm/trunk/sound/decoders/aiff.cpp 2010-06-15 12:33:20 UTC (rev 49843)
+++ scummvm/trunk/sound/decoders/aiff.cpp 2010-06-15 12:33:54 UTC (rev 49844)
@@ -161,16 +161,21 @@
return true;
}
-SeekableAudioStream *makeAIFFStream(Common::SeekableReadStream &stream) {
+SeekableAudioStream *makeAIFFStream(Common::SeekableReadStream *stream,
+ DisposeAfterUse::Flag disposeAfterUse) {
int size, rate;
byte *data, flags;
- if (!loadAIFFFromStream(stream, size, rate, flags))
+ if (!loadAIFFFromStream(*stream, size, rate, flags)) {
+ if (disposeAfterUse == DisposeAfterUse::YES)
+ delete stream;
return 0;
+ }
data = (byte *)malloc(size);
assert(data);
- stream.read(data, size);
+ stream->read(data, size);
+ delete stream;
// Since we allocated our own buffer for the data, we must specify DisposeAfterUse::YES.
return makeRawStream(data, size, rate, flags);
Modified: scummvm/trunk/sound/decoders/aiff.h
===================================================================
--- scummvm/trunk/sound/decoders/aiff.h 2010-06-15 12:33:20 UTC (rev 49843)
+++ scummvm/trunk/sound/decoders/aiff.h 2010-06-15 12:33:54 UTC (rev 49844)
@@ -34,6 +34,7 @@
#define SOUND_AIFF_H
#include "common/scummsys.h"
+#include "common/types.h"
namespace Common { class SeekableReadStream; }
@@ -55,8 +56,14 @@
* from that data.
*
* This function uses loadAIFFFromStream() internally.
+ *
+ * @param stream the SeekableReadStream from which to read the AIFF data
+ * @param disposeAfterUse whether to delete the stream after use
+ * @return a new SeekableAudioStream, or NULL, if an error occurred
*/
-SeekableAudioStream *makeAIFFStream(Common::SeekableReadStream &stream);
+SeekableAudioStream *makeAIFFStream(
+ Common::SeekableReadStream *stream,
+ DisposeAfterUse::Flag disposeAfterUse);
} // End of namespace Audio
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list