2003-07-25 13:42:05 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001-2003 The ScummVM project
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-07-30 09:26:54 +00:00
|
|
|
#include "stdafx.h"
|
2003-07-31 01:21:38 +00:00
|
|
|
#include "common/file.h"
|
2003-07-29 01:37:03 +00:00
|
|
|
#include "common/util.h"
|
2003-12-19 00:32:47 +00:00
|
|
|
#include "sound/audiostream.h"
|
|
|
|
#include "sound/mixer.h"
|
2003-07-25 13:42:05 +00:00
|
|
|
|
2003-08-07 22:19:55 +00:00
|
|
|
|
2003-08-06 20:44:42 +00:00
|
|
|
// This used to be an inline template function, but
|
|
|
|
// buggy template function handling in MSVC6 forced
|
|
|
|
// us to go with the macro approach. So far this is
|
|
|
|
// the only template function that MSVC6 seemed to
|
|
|
|
// compile incorrectly. Knock on wood.
|
2003-08-06 20:41:05 +00:00
|
|
|
#define READSAMPLE(is16Bit, isUnsigned, ptr) \
|
|
|
|
((is16Bit ? READ_BE_UINT16(ptr) : (*ptr << 8)) ^ (isUnsigned ? 0x8000 : 0))
|
2003-07-28 17:28:29 +00:00
|
|
|
|
2003-12-16 02:11:04 +00:00
|
|
|
#define READ_ENDIAN_SAMPLE(is16Bit, isUnsigned, ptr, isLE) \
|
|
|
|
((is16Bit ? (isLE ? READ_LE_UINT16(ptr) : READ_BE_UINT16(ptr)) : (*ptr << 8)) ^ (isUnsigned ? 0x8000 : 0))
|
|
|
|
|
2003-07-28 17:28:29 +00:00
|
|
|
#pragma mark -
|
2003-07-28 18:01:56 +00:00
|
|
|
#pragma mark --- LinearMemoryStream ---
|
2003-07-28 17:28:29 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
|
2003-12-16 02:11:04 +00:00
|
|
|
template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE>
|
2003-08-01 16:32:11 +00:00
|
|
|
class LinearMemoryStream : public AudioInputStream {
|
2003-07-25 13:42:05 +00:00
|
|
|
protected:
|
|
|
|
const byte *_ptr;
|
|
|
|
const byte *_end;
|
2003-08-01 16:32:11 +00:00
|
|
|
const byte *_loopPtr;
|
|
|
|
const byte *_loopEnd;
|
2003-12-17 02:19:24 +00:00
|
|
|
const int _rate;
|
2003-07-28 17:28:29 +00:00
|
|
|
|
2003-08-04 22:15:16 +00:00
|
|
|
inline bool eosIntern() const { return _ptr >= _end; };
|
|
|
|
public:
|
2003-12-17 02:19:24 +00:00
|
|
|
LinearMemoryStream(int rate, const byte *ptr, uint len, uint loopOffset, uint loopLen)
|
|
|
|
: _ptr(ptr), _end(ptr+len), _loopPtr(0), _loopEnd(0), _rate(rate) {
|
2003-08-07 23:54:39 +00:00
|
|
|
|
|
|
|
// Verify the buffer sizes are sane
|
|
|
|
if (is16Bit && stereo)
|
|
|
|
assert((len & 3) == 0 && (loopLen & 3) == 0);
|
|
|
|
else if (is16Bit || stereo)
|
|
|
|
assert((len & 1) == 0 && (loopLen & 1) == 0);
|
|
|
|
|
2003-08-04 22:15:16 +00:00
|
|
|
if (loopLen) {
|
|
|
|
_loopPtr = _ptr + loopOffset;
|
|
|
|
_loopEnd = _loopPtr + loopLen;
|
|
|
|
}
|
|
|
|
if (stereo) // Stereo requires even sized data
|
|
|
|
assert(len % 2 == 0);
|
2003-07-28 17:28:29 +00:00
|
|
|
}
|
2003-08-07 22:19:55 +00:00
|
|
|
int readBuffer(int16 *buffer, const int numSamples);
|
2003-08-04 22:15:16 +00:00
|
|
|
|
2003-12-17 01:32:00 +00:00
|
|
|
int16 read() {
|
|
|
|
//assert(_ptr < _end);
|
|
|
|
int16 val = READ_ENDIAN_SAMPLE(is16Bit, isUnsigned, _ptr, isLE);
|
|
|
|
_ptr += (is16Bit ? 2 : 1);
|
|
|
|
if (_loopPtr && eosIntern()) {
|
|
|
|
_ptr = _loopPtr;
|
|
|
|
_end = _loopEnd;
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
2003-08-04 22:15:16 +00:00
|
|
|
bool isStereo() const { return stereo; }
|
2003-12-19 01:30:19 +00:00
|
|
|
bool endOfData() const { return eosIntern(); }
|
2003-12-17 02:19:24 +00:00
|
|
|
|
|
|
|
int getRate() const { return _rate; }
|
2003-07-25 13:42:05 +00:00
|
|
|
};
|
|
|
|
|
2003-12-16 02:11:04 +00:00
|
|
|
template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE>
|
|
|
|
int LinearMemoryStream<stereo, is16Bit, isUnsigned, isLE>::readBuffer(int16 *buffer, const int numSamples) {
|
2003-08-05 01:14:27 +00:00
|
|
|
int samples = 0;
|
|
|
|
while (samples < numSamples && !eosIntern()) {
|
2003-08-07 22:19:55 +00:00
|
|
|
const int len = MIN(numSamples, samples + (int)(_end - _ptr) / (is16Bit ? 2 : 1));
|
2003-08-05 01:14:27 +00:00
|
|
|
while (samples < len) {
|
2003-12-16 02:11:04 +00:00
|
|
|
*buffer++ = READ_ENDIAN_SAMPLE(is16Bit, isUnsigned, _ptr, isLE);
|
2003-08-05 01:14:27 +00:00
|
|
|
_ptr += (is16Bit ? 2 : 1);
|
|
|
|
samples++;
|
|
|
|
}
|
|
|
|
// Loop, if looping was specified
|
2003-08-07 22:19:55 +00:00
|
|
|
if (_loopPtr && eosIntern()) {
|
2003-08-05 01:14:27 +00:00
|
|
|
_ptr = _loopPtr;
|
|
|
|
_end = _loopEnd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return samples;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-28 17:28:29 +00:00
|
|
|
#pragma mark -
|
|
|
|
#pragma mark --- WrappedMemoryStream ---
|
2003-07-28 16:55:43 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2003-07-25 13:42:05 +00:00
|
|
|
|
2003-07-28 18:01:56 +00:00
|
|
|
// Wrapped memory stream, to be used by the ChannelStream class (and possibly others?)
|
|
|
|
template<bool stereo, bool is16Bit, bool isUnsigned>
|
|
|
|
class WrappedMemoryStream : public WrappedAudioInputStream {
|
|
|
|
protected:
|
|
|
|
byte *_bufferStart;
|
|
|
|
byte *_bufferEnd;
|
|
|
|
byte *_pos;
|
|
|
|
byte *_end;
|
2003-12-17 01:50:50 +00:00
|
|
|
bool _finalized;
|
2003-12-17 02:19:24 +00:00
|
|
|
const int _rate;
|
2003-11-08 23:05:04 +00:00
|
|
|
|
2003-08-04 22:15:16 +00:00
|
|
|
inline bool eosIntern() const { return _end == _pos; };
|
2003-07-28 18:01:56 +00:00
|
|
|
public:
|
2003-12-17 02:19:24 +00:00
|
|
|
WrappedMemoryStream(int rate, uint bufferSize);
|
2003-08-04 22:15:16 +00:00
|
|
|
~WrappedMemoryStream() { free(_bufferStart); }
|
2003-08-07 22:19:55 +00:00
|
|
|
int readBuffer(int16 *buffer, const int numSamples);
|
2003-08-04 22:15:16 +00:00
|
|
|
|
2003-12-17 01:32:00 +00:00
|
|
|
int16 read();
|
2003-08-04 22:15:16 +00:00
|
|
|
bool isStereo() const { return stereo; }
|
2003-12-19 01:30:19 +00:00
|
|
|
bool endOfStream() const { return _finalized && eosIntern(); }
|
|
|
|
bool endOfData() const { return eosIntern(); }
|
2003-12-17 02:19:24 +00:00
|
|
|
|
|
|
|
int getRate() const { return _rate; }
|
2003-07-28 18:01:56 +00:00
|
|
|
|
|
|
|
void append(const byte *data, uint32 len);
|
2003-12-17 01:50:50 +00:00
|
|
|
void finish() { _finalized = true; }
|
2003-07-28 18:01:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-07-28 17:28:29 +00:00
|
|
|
template<bool stereo, bool is16Bit, bool isUnsigned>
|
2003-12-17 02:19:24 +00:00
|
|
|
WrappedMemoryStream<stereo, is16Bit, isUnsigned>::WrappedMemoryStream(int rate, uint bufferSize)
|
2003-12-19 00:09:34 +00:00
|
|
|
: _finalized(false), _rate(rate) {
|
2003-08-07 23:54:39 +00:00
|
|
|
|
|
|
|
// Verify the buffer size is sane
|
|
|
|
if (is16Bit && stereo)
|
|
|
|
assert((bufferSize & 3) == 0);
|
|
|
|
else if (is16Bit || stereo)
|
|
|
|
assert((bufferSize & 1) == 0);
|
|
|
|
|
2003-07-28 18:01:56 +00:00
|
|
|
_bufferStart = (byte *)malloc(bufferSize);
|
|
|
|
_pos = _end = _bufferStart;
|
|
|
|
_bufferEnd = _bufferStart + bufferSize;
|
2003-07-28 16:55:43 +00:00
|
|
|
}
|
|
|
|
|
2003-07-28 17:28:29 +00:00
|
|
|
template<bool stereo, bool is16Bit, bool isUnsigned>
|
2003-12-17 01:32:00 +00:00
|
|
|
inline int16 WrappedMemoryStream<stereo, is16Bit, isUnsigned>::read() {
|
|
|
|
if (eosIntern()) {
|
|
|
|
// If the stream contains no more data, it is silent...
|
|
|
|
return 0;
|
|
|
|
}
|
2003-08-06 20:41:05 +00:00
|
|
|
int16 val = READSAMPLE(is16Bit, isUnsigned, _pos);
|
2003-07-28 17:28:29 +00:00
|
|
|
_pos += (is16Bit ? 2 : 1);
|
|
|
|
|
2003-07-28 16:55:43 +00:00
|
|
|
// Wrap around?
|
|
|
|
if (_pos >= _bufferEnd)
|
|
|
|
_pos = _pos - (_bufferEnd - _bufferStart);
|
2003-07-28 17:28:29 +00:00
|
|
|
|
|
|
|
return val;
|
2003-07-28 16:55:43 +00:00
|
|
|
}
|
|
|
|
|
2003-07-28 17:28:29 +00:00
|
|
|
template<bool stereo, bool is16Bit, bool isUnsigned>
|
2003-08-07 22:19:55 +00:00
|
|
|
int WrappedMemoryStream<stereo, is16Bit, isUnsigned>::readBuffer(int16 *buffer, const int numSamples) {
|
2003-08-05 00:50:15 +00:00
|
|
|
int samples = 0;
|
2003-08-05 00:53:25 +00:00
|
|
|
while (samples < numSamples && !eosIntern()) {
|
|
|
|
const byte *endMarker = (_pos > _end) ? _bufferEnd : _end;
|
2003-08-07 22:19:55 +00:00
|
|
|
const int len = MIN(numSamples, samples + (int)(endMarker - _pos) / (is16Bit ? 2 : 1));
|
2003-08-05 00:50:15 +00:00
|
|
|
while (samples < len) {
|
2003-08-06 20:41:05 +00:00
|
|
|
*buffer++ = READSAMPLE(is16Bit, isUnsigned, _pos);
|
2003-08-05 00:50:15 +00:00
|
|
|
_pos += (is16Bit ? 2 : 1);
|
|
|
|
samples++;
|
|
|
|
}
|
|
|
|
// Wrap around?
|
|
|
|
if (_pos >= _bufferEnd)
|
|
|
|
_pos = _pos - (_bufferEnd - _bufferStart);
|
|
|
|
}
|
2003-08-04 22:15:16 +00:00
|
|
|
return samples;
|
2003-07-28 16:55:43 +00:00
|
|
|
}
|
|
|
|
|
2003-07-28 17:28:29 +00:00
|
|
|
template<bool stereo, bool is16Bit, bool isUnsigned>
|
|
|
|
void WrappedMemoryStream<stereo, is16Bit, isUnsigned>::append(const byte *data, uint32 len) {
|
2003-08-07 23:54:39 +00:00
|
|
|
|
|
|
|
// Verify the buffer size is sane
|
|
|
|
if (is16Bit && stereo)
|
|
|
|
assert((len & 3) == 0);
|
|
|
|
else if (is16Bit || stereo)
|
|
|
|
assert((len & 1) == 0);
|
2003-12-17 01:50:50 +00:00
|
|
|
|
|
|
|
// Verify the stream has not been finalized (by a call to finish()) yet
|
|
|
|
assert(!_finalized);
|
2003-08-07 23:54:39 +00:00
|
|
|
|
2003-07-28 16:55:43 +00:00
|
|
|
if (_end + len > _bufferEnd) {
|
|
|
|
// Wrap-around case
|
|
|
|
uint32 size_to_end_of_buffer = _bufferEnd - _end;
|
|
|
|
len -= size_to_end_of_buffer;
|
|
|
|
if ((_end < _pos) || (_bufferStart + len >= _pos)) {
|
|
|
|
debug(2, "WrappedMemoryStream: buffer overflow (A)");
|
|
|
|
return;
|
|
|
|
}
|
2003-07-28 18:01:56 +00:00
|
|
|
memcpy(_end, data, size_to_end_of_buffer);
|
|
|
|
memcpy(_bufferStart, data + size_to_end_of_buffer, len);
|
2003-07-28 16:55:43 +00:00
|
|
|
_end = _bufferStart + len;
|
|
|
|
} else {
|
|
|
|
if ((_end < _pos) && (_end + len >= _pos)) {
|
|
|
|
debug(2, "WrappedMemoryStream: buffer overflow (B)");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memcpy(_end, data, len);
|
|
|
|
_end += len;
|
2003-07-28 01:13:31 +00:00
|
|
|
}
|
2003-07-28 16:55:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-29 01:37:03 +00:00
|
|
|
#pragma mark -
|
2003-12-19 00:32:47 +00:00
|
|
|
#pragma mark --- Procedural stream ---
|
2003-07-29 01:37:03 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
|
2003-12-19 00:32:47 +00:00
|
|
|
#if 0
|
|
|
|
// Work in progress!!! Not yet usable/finished/working/anything :-)
|
2003-08-02 18:13:37 +00:00
|
|
|
|
2003-12-19 00:32:47 +00:00
|
|
|
class ProcInputStream : public AudioInputStream {
|
|
|
|
public:
|
|
|
|
typedef void InputProc (void *refCon, int16 *data, uint len);
|
2003-11-08 23:05:04 +00:00
|
|
|
|
2003-12-19 00:32:47 +00:00
|
|
|
private:
|
|
|
|
const int _rate;
|
|
|
|
const bool _isStereo;
|
|
|
|
InputProc *_proc;
|
|
|
|
void *_refCon;
|
|
|
|
int16 _buffer[2048];
|
|
|
|
const int16 *_pos;
|
|
|
|
int _len;
|
2003-07-29 01:37:03 +00:00
|
|
|
|
2003-12-19 00:32:47 +00:00
|
|
|
void refill() {
|
|
|
|
// Fill the buffer
|
|
|
|
(_proc)(_refCon, _buffer, 2048);
|
|
|
|
_pos = _buffer;
|
|
|
|
_len = 2048;
|
2003-07-31 01:21:38 +00:00
|
|
|
}
|
2003-11-08 23:05:04 +00:00
|
|
|
|
2003-12-19 00:32:47 +00:00
|
|
|
public:
|
|
|
|
ProcInputStream(int rate, bool stereo, InputProc *proc, void *refCon)
|
|
|
|
: _rate(rate), _isStereo(stereo), _proc(proc), _refCon(refCon), _len(0) { }
|
|
|
|
int readBuffer(int16 *buffer, const int numSamples) {
|
|
|
|
int remSamples = numSamples;
|
|
|
|
while (remSamples > 0) {
|
|
|
|
if (_len == 0)
|
|
|
|
refill();
|
|
|
|
// Copy data to the output
|
|
|
|
int samples = MIN(_len, remSamples);
|
|
|
|
memcpy(buffer, _pos, samples * sizeof(int16));
|
|
|
|
_pos += samples;
|
|
|
|
_len -= samples;
|
|
|
|
buffer += samples;
|
|
|
|
remSamples -= samples;
|
2003-07-30 18:40:28 +00:00
|
|
|
}
|
2003-12-19 00:32:47 +00:00
|
|
|
return numSamples;
|
2003-07-31 19:32:38 +00:00
|
|
|
}
|
2003-12-19 00:32:47 +00:00
|
|
|
int16 read() {
|
|
|
|
if (_len == 0)
|
2003-08-05 01:14:27 +00:00
|
|
|
refill();
|
2003-12-19 00:32:47 +00:00
|
|
|
_len--;
|
|
|
|
return *_pos++;
|
2003-08-05 01:14:27 +00:00
|
|
|
}
|
2003-12-19 00:32:47 +00:00
|
|
|
bool isStereo() const { return _isStereo; }
|
2003-12-19 01:30:19 +00:00
|
|
|
bool endOfData() const { return false; }
|
2003-08-04 22:15:16 +00:00
|
|
|
|
2003-12-19 00:32:47 +00:00
|
|
|
int getRate() const { return _rate; }
|
2003-08-04 22:15:16 +00:00
|
|
|
};
|
2003-07-29 01:37:03 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2003-07-28 16:55:43 +00:00
|
|
|
#pragma mark -
|
2003-07-28 17:28:29 +00:00
|
|
|
#pragma mark --- Input stream factories ---
|
|
|
|
#pragma mark -
|
2003-07-25 13:42:05 +00:00
|
|
|
|
|
|
|
|
2003-07-28 11:13:01 +00:00
|
|
|
template<bool stereo>
|
2003-12-17 02:19:24 +00:00
|
|
|
static AudioInputStream *makeLinearInputStream(int rate, const byte *ptr, uint32 len, bool is16Bit, bool isUnsigned, bool isLE, uint loopOffset, uint loopLen) {
|
2003-07-25 13:42:05 +00:00
|
|
|
if (isUnsigned) {
|
2003-12-16 02:11:04 +00:00
|
|
|
if (is16Bit) {
|
|
|
|
if (isLE)
|
2003-12-17 02:19:24 +00:00
|
|
|
return new LinearMemoryStream<stereo, true, true, true>(rate, ptr, len, loopOffset, loopLen);
|
2003-12-16 02:11:04 +00:00
|
|
|
else
|
2003-12-17 02:19:24 +00:00
|
|
|
return new LinearMemoryStream<stereo, true, true, false>(rate, ptr, len, loopOffset, loopLen);
|
2003-12-16 02:11:04 +00:00
|
|
|
} else
|
2003-12-17 02:19:24 +00:00
|
|
|
return new LinearMemoryStream<stereo, false, true, false>(rate, ptr, len, loopOffset, loopLen);
|
2003-07-25 13:42:05 +00:00
|
|
|
} else {
|
2003-12-16 02:11:04 +00:00
|
|
|
if (is16Bit) {
|
|
|
|
if (isLE)
|
2003-12-17 02:19:24 +00:00
|
|
|
return new LinearMemoryStream<stereo, true, false, true>(rate, ptr, len, loopOffset, loopLen);
|
2003-12-16 02:11:04 +00:00
|
|
|
else
|
2003-12-17 02:19:24 +00:00
|
|
|
return new LinearMemoryStream<stereo, true, false, false>(rate, ptr, len, loopOffset, loopLen);
|
2003-12-16 02:11:04 +00:00
|
|
|
} else
|
2003-12-17 02:19:24 +00:00
|
|
|
return new LinearMemoryStream<stereo, false, false, false>(rate, ptr, len, loopOffset, loopLen);
|
2003-07-25 13:42:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-28 18:01:56 +00:00
|
|
|
template<bool stereo>
|
2003-12-17 02:19:24 +00:00
|
|
|
static WrappedAudioInputStream *makeWrappedInputStream(int rate, uint32 len, bool is16Bit, bool isUnsigned) {
|
2003-07-28 18:01:56 +00:00
|
|
|
if (isUnsigned) {
|
|
|
|
if (is16Bit)
|
2003-12-17 02:19:24 +00:00
|
|
|
return new WrappedMemoryStream<stereo, true, true>(rate, len);
|
2003-07-28 18:01:56 +00:00
|
|
|
else
|
2003-12-17 02:19:24 +00:00
|
|
|
return new WrappedMemoryStream<stereo, false, true>(rate, len);
|
2003-07-28 18:01:56 +00:00
|
|
|
} else {
|
|
|
|
if (is16Bit)
|
2003-12-17 02:19:24 +00:00
|
|
|
return new WrappedMemoryStream<stereo, true, false>(rate, len);
|
2003-07-28 18:01:56 +00:00
|
|
|
else
|
2003-12-17 02:19:24 +00:00
|
|
|
return new WrappedMemoryStream<stereo, false, false>(rate, len);
|
2003-07-28 18:01:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-17 02:19:24 +00:00
|
|
|
AudioInputStream *makeLinearInputStream(int rate, byte _flags, const byte *ptr, uint32 len, uint loopOffset, uint loopLen) {
|
2003-07-30 19:43:51 +00:00
|
|
|
const bool is16Bit = (_flags & SoundMixer::FLAG_16BITS) != 0;
|
|
|
|
const bool isUnsigned = (_flags & SoundMixer::FLAG_UNSIGNED) != 0;
|
2003-12-16 02:11:04 +00:00
|
|
|
const bool isLE = (_flags & SoundMixer::FLAG_LITTLE_ENDIAN) != 0;
|
2003-07-28 18:01:56 +00:00
|
|
|
if (_flags & SoundMixer::FLAG_STEREO) {
|
2003-12-17 02:19:24 +00:00
|
|
|
return makeLinearInputStream<true>(rate, ptr, len, is16Bit, isUnsigned, isLE, loopOffset, loopLen);
|
2003-07-28 18:01:56 +00:00
|
|
|
} else {
|
2003-12-17 02:19:24 +00:00
|
|
|
return makeLinearInputStream<false>(rate, ptr, len, is16Bit, isUnsigned, isLE, loopOffset, loopLen);
|
2003-07-28 18:01:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-17 02:19:24 +00:00
|
|
|
WrappedAudioInputStream *makeWrappedInputStream(int rate, byte _flags, uint32 len) {
|
2003-07-30 19:43:51 +00:00
|
|
|
const bool is16Bit = (_flags & SoundMixer::FLAG_16BITS) != 0;
|
|
|
|
const bool isUnsigned = (_flags & SoundMixer::FLAG_UNSIGNED) != 0;
|
2003-07-28 18:01:56 +00:00
|
|
|
if (_flags & SoundMixer::FLAG_STEREO) {
|
2003-12-17 02:19:24 +00:00
|
|
|
return makeWrappedInputStream<true>(rate, len, is16Bit, isUnsigned);
|
2003-07-28 18:01:56 +00:00
|
|
|
} else {
|
2003-12-17 02:19:24 +00:00
|
|
|
return makeWrappedInputStream<false>(rate, len, is16Bit, isUnsigned);
|
2003-07-28 18:01:56 +00:00
|
|
|
}
|
2003-07-25 13:42:05 +00:00
|
|
|
}
|