[Scummvm-cvs-logs] SF.net SVN: scummvm:[47717] scummvm/trunk/sound
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Sat Jan 30 16:28:36 CET 2010
Revision: 47717
http://scummvm.svn.sourceforge.net/scummvm/?rev=47717&view=rev
Author: lordhoto
Date: 2010-01-30 15:28:07 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Remove RawMemoryStream.
Modified Paths:
--------------
scummvm/trunk/sound/audiostream.cpp
scummvm/trunk/sound/decoders/aiff.cpp
scummvm/trunk/sound/decoders/iff_sound.cpp
scummvm/trunk/sound/decoders/raw.cpp
scummvm/trunk/sound/decoders/raw.h
scummvm/trunk/sound/decoders/voc.cpp
scummvm/trunk/sound/decoders/wave.cpp
Modified: scummvm/trunk/sound/audiostream.cpp
===================================================================
--- scummvm/trunk/sound/audiostream.cpp 2010-01-30 15:26:54 UTC (rev 47716)
+++ scummvm/trunk/sound/audiostream.cpp 2010-01-30 15:28:07 UTC (rev 47717)
@@ -253,7 +253,7 @@
void QueuingAudioStream::queueBuffer(byte *data, uint32 size, DisposeAfterUse::Flag disposeAfterUse, byte flags) {
- AudioStream *stream = makeRawMemoryStream(data, size, getRate(), flags, disposeAfterUse);
+ AudioStream *stream = makeRawStream(data, size, getRate(), flags, disposeAfterUse);
queueAudioStream(stream, DisposeAfterUse::YES);
}
Modified: scummvm/trunk/sound/decoders/aiff.cpp
===================================================================
--- scummvm/trunk/sound/decoders/aiff.cpp 2010-01-30 15:26:54 UTC (rev 47716)
+++ scummvm/trunk/sound/decoders/aiff.cpp 2010-01-30 15:28:07 UTC (rev 47717)
@@ -173,7 +173,7 @@
stream.read(data, size);
// Since we allocated our own buffer for the data, we must specify DisposeAfterUse::YES.
- return makeRawMemoryStream(data, size, rate, flags);
+ return makeRawStream(data, size, rate, flags);
}
} // End of namespace Audio
Modified: scummvm/trunk/sound/decoders/iff_sound.cpp
===================================================================
--- scummvm/trunk/sound/decoders/iff_sound.cpp 2010-01-30 15:26:54 UTC (rev 47716)
+++ scummvm/trunk/sound/decoders/iff_sound.cpp 2010-01-30 15:28:07 UTC (rev 47717)
@@ -108,7 +108,7 @@
A8SVXLoader loader;
loader.load(input);
- SeekableAudioStream *stream = Audio::makeRawMemoryStream((byte *)loader._data, loader._dataSize, loader._header.samplesPerSec, 0);
+ SeekableAudioStream *stream = Audio::makeRawStream((byte *)loader._data, loader._dataSize, loader._header.samplesPerSec, 0);
uint32 loopStart = 0, loopEnd = 0;
if (loop) {
Modified: scummvm/trunk/sound/decoders/raw.cpp
===================================================================
--- scummvm/trunk/sound/decoders/raw.cpp 2010-01-30 15:26:54 UTC (rev 47716)
+++ scummvm/trunk/sound/decoders/raw.cpp 2010-01-30 15:28:07 UTC (rev 47717)
@@ -42,86 +42,9 @@
#pragma mark -
-#pragma mark --- RawMemoryStream ---
-#pragma mark -
-
-/**
- * A simple raw audio stream, purely memory based. It operates on a single
- * block of data, which is passed to it upon creation.
- * Optionally supports looping the sound.
- *
- * Design note: This code tries to be as efficient as possible (without
- * resorting to assembly, that is). To this end, it is written as a template
- * class. This way the compiler can create optimized code for each special
- * case. This results in a total of 12 versions of the code being generated.
- */
-template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE>
-class RawMemoryStream : public SeekableAudioStream {
-protected:
- const byte *_ptr;
- const byte *_end;
- const int _rate;
- const byte *_origPtr;
- const DisposeAfterUse::Flag _disposeAfterUse;
- const Timestamp _playtime;
-
-public:
- RawMemoryStream(int rate, const byte *ptr, uint len, DisposeAfterUse::Flag autoFreeMemory)
- : _ptr(ptr), _end(ptr+len), _rate(rate), _origPtr(ptr),
- _disposeAfterUse(autoFreeMemory),
- _playtime(0, len / (is16Bit ? 2 : 1) / (stereo ? 2 : 1), rate) {
- }
-
- virtual ~RawMemoryStream() {
- if (_disposeAfterUse == DisposeAfterUse::YES)
- free(const_cast<byte *>(_origPtr));
- }
-
- int readBuffer(int16 *buffer, const int numSamples);
-
- bool isStereo() const { return stereo; }
- bool endOfData() const { return _ptr >= _end; }
-
- int getRate() const { return _rate; }
- bool seek(const Timestamp &where);
- Timestamp getLength() const { return _playtime; }
-};
-
-template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE>
-int RawMemoryStream<stereo, is16Bit, isUnsigned, isLE>::readBuffer(int16 *buffer, const int numSamples) {
- int samples = numSamples;
- while (samples > 0 && _ptr < _end) {
- int len = MIN(samples, (int)(_end - _ptr) / (is16Bit ? 2 : 1));
- samples -= len;
- do {
- *buffer++ = READ_ENDIAN_SAMPLE(is16Bit, isUnsigned, _ptr, isLE);
- _ptr += (is16Bit ? 2 : 1);
- } while (--len);
- }
- return numSamples-samples;
-}
-
-template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE>
-bool RawMemoryStream<stereo, is16Bit, isUnsigned, isLE>::seek(const Timestamp &where) {
- const uint8 *ptr = _origPtr + convertTimeToStreamPos(where, getRate(), isStereo()).totalNumberOfFrames() * (is16Bit ? 2 : 1);
- if (ptr > _end) {
- _ptr = _end;
- return false;
- } else if (ptr == _end) {
- _ptr = _end;
- return true;
- } else {
- _ptr = ptr;
- return true;
- }
-}
-
-#pragma mark -
#pragma mark --- RawDiskStream ---
#pragma mark -
-
-
/**
* RawDiskStream. This can stream raw PCM audio data from disk. The
* function takes an pointer to an array of RawDiskStreamAudioBlock which defines the
@@ -153,7 +76,7 @@
RawStreamBlockList::const_iterator _curBlock; ///< Current audio block number
public:
RawDiskStream(int rate, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream, const RawStreamBlockList &blocks)
- : _rate(rate), _playtime(0, rate), _stream(stream), _disposeAfterUse(disposeStream), _blocks(blocks), _curBlock(blocks.begin()) {
+ : _rate(rate), _playtime(0, rate), _stream(stream), _disposeAfterUse(disposeStream), _blocks(blocks), _curBlock(_blocks.begin()) {
assert(_blocks.size() > 0);
@@ -299,46 +222,6 @@
* particular case it should actually help it :-)
*/
-#define MAKE_LINEAR(STEREO, UNSIGNED) \
- if (is16Bit) { \
- if (isLE) \
- return new RawMemoryStream<STEREO, true, UNSIGNED, true>(rate, ptr, len, autoFree); \
- else \
- return new RawMemoryStream<STEREO, true, UNSIGNED, false>(rate, ptr, len, autoFree); \
- } else \
- return new RawMemoryStream<STEREO, false, UNSIGNED, false>(rate, ptr, len, autoFree)
-
-SeekableAudioStream *makeRawMemoryStream(const byte *ptr, uint32 len,
- int rate, byte flags,
- DisposeAfterUse::Flag autoFree
- ) {
- const bool isStereo = (flags & Audio::FLAG_STEREO) != 0;
- const bool is16Bit = (flags & Audio::FLAG_16BITS) != 0;
- const bool isUnsigned = (flags & Audio::FLAG_UNSIGNED) != 0;
- const bool isLE = (flags & Audio::FLAG_LITTLE_ENDIAN) != 0;
-
- // Verify the buffer sizes are sane
- if (is16Bit && isStereo) {
- assert((len & 3) == 0);
- } else if (is16Bit || isStereo) {
- assert((len & 1) == 0);
- }
-
- if (isStereo) {
- if (isUnsigned) {
- MAKE_LINEAR(true, true);
- } else {
- MAKE_LINEAR(true, false);
- }
- } else {
- if (isUnsigned) {
- MAKE_LINEAR(false, true);
- } else {
- MAKE_LINEAR(false, false);
- }
- }
-}
-
#define MAKE_LINEAR_DISK(STEREO, UNSIGNED) \
if (is16Bit) { \
if (isLE) \
Modified: scummvm/trunk/sound/decoders/raw.h
===================================================================
--- scummvm/trunk/sound/decoders/raw.h 2010-01-30 15:26:54 UTC (rev 47716)
+++ scummvm/trunk/sound/decoders/raw.h 2010-01-30 15:28:07 UTC (rev 47717)
@@ -65,27 +65,6 @@
/**
- * Creates a audio stream, which plays the given raw data.
- *
- * The data pointer is assumed to have been allocated with malloc().
- * In particular, if autofreeBuffer is set to DisposeAfterUse::YES,
- * then this buffer will be deallocated using free(). So do not
- * use a buffer allocated with new[]!
- *
- * @param ptr pointer to a buffer containing audio data
- * @param len length of the buffer in bytes
- * @param rate sample rate of the data
- * @param flags audio format flags combination
- * @see RawFlags
- * @param autofreeBuffer whether the data buffer should be destroyed after playback
- * @return The new SeekableAudioStream (or 0 on failure).
- */
-SeekableAudioStream *makeRawMemoryStream(const byte *ptr, uint32 len,
- int rate, byte flags,
- DisposeAfterUse::Flag autofreeBuffer = DisposeAfterUse::YES
- );
-
-/**
* Struct used to define the audio data to be played by a RawDiskStream.
*/
struct RawDiskStreamAudioBlock {
Modified: scummvm/trunk/sound/decoders/voc.cpp
===================================================================
--- scummvm/trunk/sound/decoders/voc.cpp 2010-01-30 15:26:54 UTC (rev 47716)
+++ scummvm/trunk/sound/decoders/voc.cpp 2010-01-30 15:28:07 UTC (rev 47717)
@@ -390,7 +390,7 @@
if (!data)
return 0;
- return makeRawMemoryStream(data, size, rate, flags);
+ return makeRawStream(data, size, rate, flags);
#endif
}
Modified: scummvm/trunk/sound/decoders/wave.cpp
===================================================================
--- scummvm/trunk/sound/decoders/wave.cpp 2010-01-30 15:26:54 UTC (rev 47716)
+++ scummvm/trunk/sound/decoders/wave.cpp 2010-01-30 15:28:07 UTC (rev 47717)
@@ -188,7 +188,7 @@
if (disposeAfterUse == DisposeAfterUse::YES)
delete stream;
- return makeRawMemoryStream(data, size, rate, flags);
+ return makeRawStream(data, size, rate, flags);
}
} // 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