aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorTravis Howell2009-08-16 01:03:09 +0000
committerTravis Howell2009-08-16 01:03:09 +0000
commitac45cf6f6f0cf6e41b608561316bcbda115fb6b1 (patch)
tree01d5f13eec4f6a91859093de4fac88ef7991f756 /sound
parent09845556e0383fb187f548c7cfc1a68b22329f7e (diff)
parentb6a0f3e3716614ee270df048414c7f938299c476 (diff)
downloadscummvm-rg350-ac45cf6f6f0cf6e41b608561316bcbda115fb6b1.tar.gz
scummvm-rg350-ac45cf6f6f0cf6e41b608561316bcbda115fb6b1.tar.bz2
scummvm-rg350-ac45cf6f6f0cf6e41b608561316bcbda115fb6b1.zip
Merged revisions 43338-43340,43342,43344-43347,43349-43350,43352-43354,43357-43358,43362,43366,43369,43375,43377,43380,43383-43384,43386,43388,43390,43393,43400,43402,43404,43406-43409,43411,43413-43414 via svnmerge from
https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk ........ r43338 | lordhoto | 2009-08-13 10:19:26 +1000 (Thu, 13 Aug 2009) | 1 line Little optimization in Screen::setPaletteIndex, now it only resets the palette, when the color index really changed. ........ r43339 | lordhoto | 2009-08-13 10:20:37 +1000 (Thu, 13 Aug 2009) | 1 line Fix key input in credits sequences. ........ r43340 | lordhoto | 2009-08-13 10:21:42 +1000 (Thu, 13 Aug 2009) | 1 line Fix serious bug in StaticResource::unloadId. ........ r43342 | lordhoto | 2009-08-13 10:26:41 +1000 (Thu, 13 Aug 2009) | 1 line Do not unload credits data after copying it to a temporary buffer in Kyrandia 1 Amiga, since the credits will be looped and need reload every time. ........ r43344 | strangerke | 2009-08-13 19:56:54 +1000 (Thu, 13 Aug 2009) | 1 line Initial save handler for Playtoons ........ r43345 | strangerke | 2009-08-13 19:59:44 +1000 (Thu, 13 Aug 2009) | 2 lines - Add a specific OPCODEFUNC checkData to avoid having a Playtoons workaround in working code - Replace OPCODEDRAW 0x20,0x23 and 0x25 ........ r43346 | strangerke | 2009-08-13 20:00:35 +1000 (Thu, 13 Aug 2009) | 1 line Suppress no longer needed Playtoons workaround ........ r43347 | strangerke | 2009-08-13 20:08:07 +1000 (Thu, 13 Aug 2009) | 1 line fix methods ........ r43349 | lordhoto | 2009-08-14 01:55:12 +1000 (Fri, 14 Aug 2009) | 1 line Implemented support for the "Lore of the Lands" special of Lands of Lore CD. ........ r43350 | lordhoto | 2009-08-14 02:41:07 +1000 (Fri, 14 Aug 2009) | 1 line Move version string in Modern theme beneath the Logo in high res mode, this saves some space and looks nicer. ........ r43352 | lordhoto | 2009-08-14 02:50:30 +1000 (Fri, 14 Aug 2009) | 1 line Little fix of new modern theme layout in the launcher for 3x. ........ r43353 | lordhoto | 2009-08-14 03:00:19 +1000 (Fri, 14 Aug 2009) | 1 line Cleanup. ........ r43354 | lordhoto | 2009-08-14 03:00:40 +1000 (Fri, 14 Aug 2009) | 1 line Cleanup. ........ r43357 | agent-q | 2009-08-14 07:46:41 +1000 (Fri, 14 Aug 2009) | 1 line Allow VOCs to stream from disk. Disabled by default, use symbol STREAM_AUDIO_FROM_DISK to enable. See patch #2834001. ........ r43358 | Kirben | 2009-08-14 10:44:36 +1000 (Fri, 14 Aug 2009) | 1 line The Nintendo DS hack for introduction in Simon the Sorcerer 1 is only required for Windows version (WAV format) now. ........ r43362 | anotherguest | 2009-08-14 16:42:57 +1000 (Fri, 14 Aug 2009) | 1 line Updated files from 1.0.0 branch ........ r43366 | drmccoy | 2009-08-15 01:22:43 +1000 (Sat, 15 Aug 2009) | 2 lines Setting gob3 save/load mode of the temporary sprite "intro.$$$" to ignore and remove the TempSpriteHandler. Gob3 doesn't use it at all and Lost in Time only saves (with an invalid index) and never loads ........ r43369 | joostp | 2009-08-15 02:13:00 +1000 (Sat, 15 Aug 2009) | 2 lines PSP: create an EBOOT.PBP when building via configure ........ r43375 | joostp | 2009-08-15 02:44:29 +1000 (Sat, 15 Aug 2009) | 2 lines Fix incorrect memset() call (reported by Peter Bortas). ........ r43377 | joostp | 2009-08-15 02:54:43 +1000 (Sat, 15 Aug 2009) | 2 lines add psp_clean build rule to clean up EBOOT.PBP and scummvm_stripped.elf ........ r43380 | joostp | 2009-08-15 03:18:03 +1000 (Sat, 15 Aug 2009) | 3 lines MIPSpro compilation fixes / workarounds (from a patch by Rainer Canavan) The hashmap.h change is ugly, but so far the only thing found to work. Suggestions for a better "fix" appreciated! ........ r43383 | lordhoto | 2009-08-15 03:49:30 +1000 (Sat, 15 Aug 2009) | 1 line Little fix for lopping credits in Kyrandia 1 Amiga. ........ r43384 | joostp | 2009-08-15 04:02:17 +1000 (Sat, 15 Aug 2009) | 2 lines PSP: also create param.sfo when building via configure ........ r43386 | joostp | 2009-08-15 04:34:01 +1000 (Sat, 15 Aug 2009) | 2 lines PSP: add svn revision + build date to SFO title. ........ r43388 | joostp | 2009-08-15 09:20:46 +1000 (Sat, 15 Aug 2009) | 2 lines remove double semi-colon -- hopefully this kicks the buildbot back into action =) ........ r43390 | waltervn | 2009-08-15 10:28:59 +1000 (Sat, 15 Aug 2009) | 2 lines SCI: Added enum for map and volume versions. Removed res_version setting from detection.cpp (should be detectable). Cleanup. ........ r43393 | dhewg | 2009-08-15 15:39:44 +1000 (Sat, 15 Aug 2009) | 1 line Fix compilation. ........ r43400 | Kirben | 2009-08-15 20:09:32 +1000 (Sat, 15 Aug 2009) | 1 line Fix regression, that caused multiple sounds in Simon the Sorcerer 2 to be cut off. ........ r43402 | Kirben | 2009-08-15 20:31:20 +1000 (Sat, 15 Aug 2009) | 1 line Restore code to clear screen, before playing videos with smaller resolution in the Amiga version of The Feeble Files. ........ r43404 | joostp | 2009-08-15 20:44:58 +1000 (Sat, 15 Aug 2009) | 2 lines Properly implement PSPFilesystemFactory::makeCurrentDirectoryFileNode() ........ r43406 | dreammaster | 2009-08-15 21:50:59 +1000 (Sat, 15 Aug 2009) | 1 line Added Dirty Rect handling functionality ........ r43407 | waltervn | 2009-08-15 22:09:47 +1000 (Sat, 15 Aug 2009) | 1 line SCI: Rename sci_version_t to SciVersion ........ r43408 | waltervn | 2009-08-15 22:17:23 +1000 (Sat, 15 Aug 2009) | 1 line SCI: Add missing versions to exe version parsing ........ r43409 | eriktorbjorn | 2009-08-16 00:13:48 +1000 (Sun, 16 Aug 2009) | 2 lines Removed unnecessary semi-colons. ........ r43411 | lordhoto | 2009-08-16 00:59:11 +1000 (Sun, 16 Aug 2009) | 1 line Added const qualifiers to static data. ........ r43413 | lordhoto | 2009-08-16 01:30:35 +1000 (Sun, 16 Aug 2009) | 1 line Yet another slight graphic fix for the Kyrandia 1 Amiga credits. ........ r43414 | buddha_ | 2009-08-16 05:04:21 +1000 (Sun, 16 Aug 2009) | 4 lines Fix for bug #2835581 (KQ3: Game Crash When Leaving Tavern as Fly): - Use AGI version 0x3149 instead of the previous 0x3086 - Makes ESC pause the game (Identical to original in this respect) ........ svn-id: r43418
Diffstat (limited to 'sound')
-rw-r--r--sound/audiostream.cpp196
-rw-r--r--sound/audiostream.h20
-rw-r--r--sound/voc.cpp143
-rw-r--r--sound/voc.h5
4 files changed, 359 insertions, 5 deletions
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp
index 61a2e778ab..8ea72851e2 100644
--- a/sound/audiostream.cpp
+++ b/sound/audiostream.cpp
@@ -173,6 +173,162 @@ int LinearMemoryStream<stereo, is16Bit, isUnsigned, isLE>::readBuffer(int16 *buf
}
+
+#pragma mark -
+#pragma mark --- LinearDiskStream ---
+#pragma mark -
+
+
+
+/**
+ * LinearDiskStream. This can stream linear (PCM) audio from disk. The
+ * function takes an pointer to an array of LinearDiskStreamAudioBlock which defines the
+ * start position and length of each block of uncompressed audio in the stream.
+ */
+template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE>
+class LinearDiskStream : public AudioStream {
+
+// Allow backends to override buffer size
+#ifdef CUSTOM_AUDIO_BUFFER_SIZE
+ static const int32 BUFFER_SIZE = CUSTOM_AUDIO_BUFFER_SIZE;
+#else
+ static const int32 BUFFER_SIZE = 16384;
+#endif
+
+protected:
+ byte* _buffer; ///< Streaming buffer
+ const byte *_ptr; ///< Pointer to current position in stream buffer
+ const int _rate; ///< Sample rate of stream
+
+ int32 _playtime; ///< Calculated total play time
+ Common::SeekableReadStream *_stream; ///< Stream to read data from
+ int32 _filePos; ///< Current position in stream
+ int32 _diskLeft; ///< Samples left in stream in current block not yet read to buffer
+ int32 _bufferLeft; ///< Samples left in buffer in current block
+ bool _disposeAfterUse; ///< If true, delete stream object when LinearDiskStream is destructed
+
+ LinearDiskStreamAudioBlock *_audioBlock; ///< Audio block list
+ int _audioBlockCount; ///< Number of blocks in _audioBlock
+ int _currentBlock; ///< Current audio block number
+
+ int _beginLoop; ///< Loop parameter, currently not implemented
+ int _endLoop; ///< Loop parameter, currently not implemented
+
+
+public:
+ LinearDiskStream(int rate, uint beginLoop, uint endLoop, bool disposeStream, Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, uint numBlocks)
+ : _rate(rate), _stream(stream), _beginLoop(beginLoop), _endLoop(endLoop), _disposeAfterUse(disposeStream),
+ _audioBlockCount(numBlocks) {
+
+ // Allocate streaming buffer
+ if (is16Bit) {
+ _buffer = (byte *)malloc(BUFFER_SIZE * sizeof(int16));
+ } else {
+ _buffer = (byte *)malloc(BUFFER_SIZE * sizeof(byte));
+ }
+
+ _ptr = _buffer;
+ _bufferLeft = 0;
+
+ // Copy audio block data to our buffer
+ // TODO: Replace this with a Common::Array or Common::List to
+ // make it a little friendlier.
+ _audioBlock = new LinearDiskStreamAudioBlock[numBlocks];
+ memcpy(_audioBlock, block, numBlocks * sizeof(LinearDiskStreamAudioBlock));
+
+ // Set current buffer state, playing first block
+ _currentBlock = 0;
+ _filePos = _audioBlock[_currentBlock].pos;
+ _diskLeft = _audioBlock[_currentBlock].len;
+
+ // Add up length of all blocks in order to caluclate total play time
+ int len = 0;
+ for (int r = 0; r < _audioBlockCount; r++) {
+ len += _audioBlock[r].len;
+ }
+ _playtime = calculatePlayTime(rate, len / (is16Bit ? 2 : 1) / (stereo ? 2 : 1));
+ }
+
+
+ virtual ~LinearDiskStream() {
+ if (_disposeAfterUse) {
+ delete _stream;
+ }
+
+ delete[] _audioBlock;
+ free(_buffer);
+ }
+ int readBuffer(int16 *buffer, const int numSamples);
+
+ bool isStereo() const { return stereo; }
+ bool endOfData() const { return (_currentBlock == _audioBlockCount - 1) && (_diskLeft == 0) && (_bufferLeft == 0); }
+
+ int getRate() const { return _rate; }
+ int32 getTotalPlayTime() const { return _playtime; }
+};
+
+template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE>
+int LinearDiskStream<stereo, is16Bit, isUnsigned, isLE>::readBuffer(int16 *buffer, const int numSamples) {
+ int oldPos = _stream->pos();
+ bool restoreFilePosition = false;
+
+ int samples = numSamples;
+
+ while (samples > 0 && ((_diskLeft > 0 || _bufferLeft > 0) || (_currentBlock != _audioBlockCount - 1)) ) {
+
+ // Output samples in the buffer to the output
+ int len = MIN(samples, _bufferLeft);
+ samples -= len;
+ _bufferLeft -= len;
+
+ while (len > 0) {
+ *buffer++ = READ_ENDIAN_SAMPLE(is16Bit, isUnsigned, _ptr, isLE);
+ _ptr += (is16Bit ? 2 : 1);
+ len--;
+ }
+
+ // Have we now finished this block? If so, read the next block
+ if ((_bufferLeft == 0) && (_diskLeft == 0) && (_currentBlock != _audioBlockCount - 1)) {
+ // Next block
+ _currentBlock++;
+
+ _filePos = _audioBlock[_currentBlock].pos;
+ _diskLeft = _audioBlock[_currentBlock].len;
+ }
+
+
+ // Now read more data from disk if there is more to be read
+ if ((_bufferLeft == 0) && (_diskLeft > 0)) {
+ int32 readAmount = MIN(_diskLeft, BUFFER_SIZE);
+
+ _stream->seek(_filePos, SEEK_SET);
+ _stream->read(_buffer, readAmount * (is16Bit? 2: 1));
+
+ // Amount of data in buffer is now the amount read in, and
+ // the amount left to read on disk is decreased by the same amount
+ _bufferLeft = readAmount;
+ _diskLeft -= readAmount;
+ _ptr = (byte *)_buffer;
+ _filePos += readAmount * (is16Bit? 2: 1);
+
+ // Set this flag now we've used the file, it restores it's
+ // original position.
+ restoreFilePosition = true;
+ }
+ }
+
+ // In case calling code relies on the position of this stream staying
+ // constant, I restore the location if I've changed it. This is probably
+ // not necessary.
+ if (restoreFilePosition) {
+ _stream->seek(oldPos, SEEK_SET);
+ }
+
+ return numSamples-samples;
+}
+
+
+
#pragma mark -
#pragma mark --- Input stream factory ---
#pragma mark -
@@ -202,6 +358,7 @@ AudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate, byte f
const bool isLE = (flags & Audio::Mixer::FLAG_LITTLE_ENDIAN) != 0;
const bool autoFree = (flags & Audio::Mixer::FLAG_AUTOFREE) != 0;
+
uint loopOffset = 0, loopLen = 0;
if (flags & Audio::Mixer::FLAG_LOOP) {
if (loopEnd == 0)
@@ -236,6 +393,44 @@ AudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate, byte f
}
+
+
+
+#define MAKE_LINEAR_DISK(STEREO, UNSIGNED) \
+ if (is16Bit) { \
+ if (isLE) \
+ return new LinearDiskStream<STEREO, true, UNSIGNED, true>(rate, loopStart, loopEnd, takeOwnership, &stream, block, numBlocks); \
+ else \
+ return new LinearDiskStream<STEREO, true, UNSIGNED, false>(rate, loopStart, loopEnd, takeOwnership, &stream, block, numBlocks); \
+ } else \
+ return new LinearDiskStream<STEREO, false, UNSIGNED, false>(rate, loopStart, loopEnd, takeOwnership, &stream, block, numBlocks)
+
+
+AudioStream *makeLinearDiskStream(Common::SeekableReadStream& stream, LinearDiskStreamAudioBlock* block, int numBlocks, int rate, byte flags, bool takeOwnership, uint loopStart, uint loopEnd) {
+ const bool isStereo = (flags & Audio::Mixer::FLAG_STEREO) != 0;
+ const bool is16Bit = (flags & Audio::Mixer::FLAG_16BITS) != 0;
+ const bool isUnsigned = (flags & Audio::Mixer::FLAG_UNSIGNED) != 0;
+ const bool isLE = (flags & Audio::Mixer::FLAG_LITTLE_ENDIAN) != 0;
+
+
+ if (isStereo) {
+ if (isUnsigned) {
+ MAKE_LINEAR_DISK(true, true);
+ } else {
+ MAKE_LINEAR_DISK(true, false);
+ }
+ } else {
+ if (isUnsigned) {
+ MAKE_LINEAR_DISK(false, true);
+ } else {
+ MAKE_LINEAR_DISK(false, false);
+ }
+ }
+}
+
+
+
+
#pragma mark -
#pragma mark --- Appendable audio stream ---
#pragma mark -
@@ -306,7 +501,6 @@ BaseAppendableMemoryStream::~BaseAppendableMemoryStream() {
template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE>
int AppendableMemoryStream<stereo, is16Bit, isUnsigned, isLE>::readBuffer(int16 *buffer, const int numSamples) {
Common::StackLock lock(_mutex);
-
int samples = numSamples;
while (samples > 0 && !eosIntern()) {
Buffer buf = *_bufferQueue.begin();
diff --git a/sound/audiostream.h b/sound/audiostream.h
index a917957a77..99e140608d 100644
--- a/sound/audiostream.h
+++ b/sound/audiostream.h
@@ -28,7 +28,7 @@
#include "common/util.h"
#include "common/scummsys.h"
-
+#include "common/stream.h"
namespace Audio {
@@ -109,6 +109,7 @@ public:
virtual int32 getTotalPlayTime() const { return kUnknownPlayTime; }
};
+
/**
* Factory function for a raw linear AudioStream, which will simply treat all data
* in the buffer described by ptr and len as raw sample data in the specified
@@ -118,6 +119,23 @@ public:
*/
AudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate, byte flags, uint loopStart, uint loopEnd);
+
+/** Struct used to define the audio data to be played by a LinearDiskStream */
+
+struct LinearDiskStreamAudioBlock {
+ int32 pos; ///< Position in stream of the block
+ int32 len; ///< Length of the block (in samples)
+};
+
+
+/** Factory function for a Linear Disk Stream. This can stream linear (PCM) audio from disk. The
+ * function takes an pointer to an array of LinearDiskStreamAudioBlock which defines the
+ * start position and length of each block of uncompressed audio in the stream.
+ */
+
+AudioStream *makeLinearDiskStream(Common::SeekableReadStream& stream, LinearDiskStreamAudioBlock* block, int
+ numBlocks, int rate, byte flags, bool disposeStream, uint loopStart, uint loopEnd);
+
/**
* An audio stream to which additional data can be appended on-the-fly.
* Used by SMUSH, iMuseDigital, the Kyrandia 3 VQA player, etc.
diff --git a/sound/voc.cpp b/sound/voc.cpp
index 3e8d8c2ed3..a332477f3c 100644
--- a/sound/voc.cpp
+++ b/sound/voc.cpp
@@ -166,14 +166,155 @@ byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate) {
return loadVOCFromStream(stream, size, rate, loops, begin_loop, end_loop);
}
-AudioStream *makeVOCStream(Common::ReadStream &stream, byte flags, uint loopStart, uint loopEnd) {
+
+#ifdef STREAM_AUDIO_FROM_DISK
+
+int parseVOCFormat(Common::SeekableReadStream& stream, LinearDiskStreamAudioBlock* block, int &rate, int &loops, int &begin_loop, int &end_loop) {
+ VocFileHeader fileHeader;
+ int currentBlock = 0;
+ int size = 0;
+
+ if (stream.read(&fileHeader, 8) != 8)
+ goto invalid;
+
+ if (!memcmp(&fileHeader, "VTLK", 4)) {
+ if (stream.read(&fileHeader, sizeof(VocFileHeader)) != sizeof(VocFileHeader))
+ goto invalid;
+ } else if (!memcmp(&fileHeader, "Creative", 8)) {
+ if (stream.read(((byte *)&fileHeader) + 8, sizeof(VocFileHeader) - 8) != sizeof(VocFileHeader) - 8)
+ goto invalid;
+ } else {
+ invalid:;
+ warning("loadVOCFromStream: Invalid header");
+ return 0;
+ }
+
+ if (memcmp(fileHeader.desc, "Creative Voice File", 19) != 0)
+ error("loadVOCFromStream: Invalid header");
+ if (fileHeader.desc[19] != 0x1A)
+ debug(3, "loadVOCFromStream: Partially invalid header");
+
+ int32 offset = FROM_LE_16(fileHeader.datablock_offset);
+ int16 version = FROM_LE_16(fileHeader.version);
+ int16 code = FROM_LE_16(fileHeader.id);
+ assert(offset == sizeof(VocFileHeader));
+ // 0x100 is an invalid VOC version used by German version of DOTT (Disk) and
+ // French version of Simon the Sorcerer 2 (CD)
+ assert(version == 0x010A || version == 0x0114 || version == 0x0100);
+ assert(code == ~version + 0x1234);
+
+ int len;
+ size = 0;
+ begin_loop = 0;
+ end_loop = 0;
+
+ while ((code = stream.readByte())) {
+ len = stream.readByte();
+ len |= stream.readByte() << 8;
+ len |= stream.readByte() << 16;
+
+ switch (code) {
+ case 1:
+ case 9: {
+ int packing;
+ if (code == 1) {
+ int time_constant = stream.readByte();
+ packing = stream.readByte();
+ len -= 2;
+ rate = getSampleRateFromVOCRate(time_constant);
+ } else {
+ rate = stream.readUint32LE();
+ int bits = stream.readByte();
+ int channels = stream.readByte();
+ if (bits != 8 || channels != 1) {
+ warning("Unsupported VOC file format (%d bits per sample, %d channels)", bits, channels);
+ break;
+ }
+ packing = stream.readUint16LE();
+ stream.readUint32LE();
+ len -= 12;
+ }
+ debug(9, "VOC Data Block: %d, %d, %d", rate, packing, len);
+ if (packing == 0) {
+
+ // Found a data block - so add it to the block list
+ block[currentBlock].pos = stream.pos();
+ block[currentBlock].len = len;
+ currentBlock++;
+
+ stream.seek(len, SEEK_CUR);
+
+ size += len;
+ begin_loop = size;
+ end_loop = size;
+ } else {
+ warning("VOC file packing %d unsupported", packing);
+ }
+ } break;
+ case 3: // silence
+ // occur with a few Igor sounds, voc file starts with a silence block with a
+ // frequency different from the data block. Just ignore fow now (implementing
+ // it wouldn't make a big difference anyway...)
+ assert(len == 3);
+ stream.readUint16LE();
+ stream.readByte();
+ break;
+ case 6: // begin of loop
+ assert(len == 2);
+ loops = stream.readUint16LE();
+ break;
+ case 7: // end of loop
+ assert(len == 0);
+ break;
+ case 8: // "Extended"
+ // This occures in the LoL Intro demo. This block can usually be used to create stereo
+ // sound, but the LoL intro has only an empty block, thus this dummy implementation will
+ // work.
+ assert(len == 4);
+ stream.readUint16LE();
+ stream.readByte();
+ stream.readByte();
+ break;
+ default:
+ warning("Unhandled code in VOC file : %d", code);
+ return 0;
+ }
+ }
+ debug(4, "VOC Data Size : %d", size);
+ return currentBlock;
+}
+
+AudioStream *makeVOCDiskStream(Common::SeekableReadStream &stream, byte flags, bool takeOwnership) {
+ const int MAX_AUDIO_BLOCKS = 256;
+
+ LinearDiskStreamAudioBlock *block = new LinearDiskStreamAudioBlock[MAX_AUDIO_BLOCKS];
+ int rate, loops, begin_loop, end_loop;
+
+ int numBlocks = parseVOCFormat(stream, block, rate, loops, begin_loop, end_loop);
+
+ AudioStream* audioStream = makeLinearDiskStream(stream, block, numBlocks, rate, flags, takeOwnership, begin_loop, end_loop);
+
+ delete[] block;
+
+ return audioStream;
+}
+
+#endif
+
+
+AudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, uint loopStart, uint loopEnd, bool takeOwnershipOfStream) {
+#ifdef STREAM_AUDIO_FROM_DISK
+ return makeVOCDiskStream(stream, flags, takeOwnershipOfStream);
+#else
int size, rate;
byte *data = loadVOCFromStream(stream, size, rate);
+
if (!data)
return 0;
return makeLinearInputStream(data, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE, loopStart, loopEnd);
+#endif
}
diff --git a/sound/voc.h b/sound/voc.h
index 2b4796e048..c696afb0c8 100644
--- a/sound/voc.h
+++ b/sound/voc.h
@@ -41,6 +41,7 @@
#include "common/scummsys.h"
namespace Common { class ReadStream; }
+namespace Common { class SeekableReadStream; }
namespace Audio {
@@ -78,7 +79,7 @@ struct VocBlockHeader {
extern int getSampleRateFromVOCRate(int vocSR);
/**
- * Try to load a VOC from the given seekable stream. Returns a pointer to memory
+ * Try to load a VOC from the given stream. Returns a pointer to memory
* containing the PCM sample data (allocated with malloc). It is the callers
* responsibility to dellocate that data again later on! Currently this
* function only supports uncompressed raw PCM data.
@@ -92,7 +93,7 @@ extern byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate)
*
* This function uses loadVOCFromStream() internally.
*/
-AudioStream *makeVOCStream(Common::ReadStream &stream, byte flags = 0, uint loopStart = 0, uint loopEnd = 0);
+AudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags = 0, uint loopStart = 0, uint loopEnd = 0, bool takeOwnershipOfStream = false);
} // End of namespace Audio