renamed AudioInputStream -> AudioStream

svn-id: r12110
This commit is contained in:
Max Horn 2004-01-03 14:10:13 +00:00
parent 2a6745a986
commit bfea71b0c4
20 changed files with 72 additions and 72 deletions

View file

@ -746,7 +746,7 @@ void IMuseDigital::callback() {
}
}
void IMuseDigital::startSound(int sound, byte *voiceBundleData, AudioInputStream *input) {
void IMuseDigital::startSound(int sound, byte *voiceBundleData, AudioStream *input) {
debug(5, "IMuseDigital::startSound(%d)", sound);
int l, r;
@ -782,7 +782,7 @@ void IMuseDigital::startSound(int sound, byte *voiceBundleData, AudioInputStream
if (input) {
// Do nothing here, we already have an audio stream
} else if (READ_UINT32(ptr) == MKID('Crea')) {
// Create an AudioInputStream
// Create an AudioStream
input = makeVOCStream(ptr);
} else if (READ_UINT32(ptr) == MKID('iMUS')) {
uint32 tag;
@ -922,7 +922,7 @@ void IMuseDigital::startSound(int sound, byte *voiceBundleData, AudioInputStream
} else
error("IMuseDigital::startSound(): Can't handle %d bit samples", bits);
// Create an AudioInputStream
// Create an AudioStream
input = makeLinearInputStream(freq, mixerFlags | SoundMixer::FLAG_AUTOFREE, data, size, 0, 0);
} else {
error("IMuseDigital::startSound(): Unknown sound format");

View file

@ -27,7 +27,7 @@
#include "scumm/music.h"
#include "sound/mixer.h"
class AudioInputStream;
class AudioStream;
namespace Scumm {
@ -81,7 +81,7 @@ private:
bool used;
bool started;
PlayingSoundHandle handle;
AudioInputStream *stream;
AudioStream *stream;
Channel();
};
@ -128,7 +128,7 @@ public:
void stopBundleMusic();
void playBundleSound(const char *sound);
void startSound(int sound, byte *voiceBundleData, AudioInputStream *input);
void startSound(int sound, byte *voiceBundleData, AudioStream *input);
public:
IMuseDigital(ScummEngine *scumm);

View file

@ -25,7 +25,7 @@
#include "scumm/scumm.h"
class AudioInputStream;
class AudioStream;
class RateConverter;
namespace Scumm {
@ -61,7 +61,7 @@ private:
int8 pan;
uint16 freq;
RateConverter *converter;
AudioInputStream *input;
AudioStream *input;
};
SoundMixer *_mixer;

View file

@ -813,7 +813,7 @@ void Sound::pauseSounds(bool pause) {
void Sound::startSfxSound(File *file, int file_size, PlayingSoundHandle *handle, int id) {
AudioInputStream *input;
AudioStream *input;
if (file_size > 0) {

View file

@ -54,7 +54,7 @@
* generated.
*/
template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE>
class LinearMemoryStream : public AudioInputStream {
class LinearMemoryStream : public AudioStream {
protected:
const byte *_ptr;
const byte *_end;
@ -125,7 +125,7 @@ int LinearMemoryStream<stereo, is16Bit, isUnsigned, isLE>::readBuffer(int16 *buf
#pragma mark -
#pragma mark --- WrappedMemoryStream ---
#pragma mark --- AppendableMemoryStream ---
#pragma mark -
@ -133,7 +133,7 @@ int LinearMemoryStream<stereo, is16Bit, isUnsigned, isLE>::readBuffer(int16 *buf
* Wrapped memory stream.
*/
template<bool stereo, bool is16Bit, bool isUnsigned>
class WrappedMemoryStream : public WrappedAudioInputStream {
class AppendableMemoryStream : public AppendableAudioStream {
protected:
byte *_bufferStart;
byte *_bufferEnd;
@ -144,8 +144,8 @@ protected:
inline bool eosIntern() const { return _end == _pos; };
public:
WrappedMemoryStream(int rate, uint bufferSize);
~WrappedMemoryStream() { free(_bufferStart); }
AppendableMemoryStream(int rate, uint bufferSize);
~AppendableMemoryStream() { free(_bufferStart); }
int readBuffer(int16 *buffer, const int numSamples);
int16 read();
@ -161,7 +161,7 @@ public:
template<bool stereo, bool is16Bit, bool isUnsigned>
WrappedMemoryStream<stereo, is16Bit, isUnsigned>::WrappedMemoryStream(int rate, uint bufferSize)
AppendableMemoryStream<stereo, is16Bit, isUnsigned>::AppendableMemoryStream(int rate, uint bufferSize)
: _finalized(false), _rate(rate) {
// Verify the buffer size is sane
@ -176,7 +176,7 @@ WrappedMemoryStream<stereo, is16Bit, isUnsigned>::WrappedMemoryStream(int rate,
}
template<bool stereo, bool is16Bit, bool isUnsigned>
inline int16 WrappedMemoryStream<stereo, is16Bit, isUnsigned>::read() {
inline int16 AppendableMemoryStream<stereo, is16Bit, isUnsigned>::read() {
assert(!eosIntern());
// Wrap around?
@ -190,7 +190,7 @@ inline int16 WrappedMemoryStream<stereo, is16Bit, isUnsigned>::read() {
}
template<bool stereo, bool is16Bit, bool isUnsigned>
int WrappedMemoryStream<stereo, is16Bit, isUnsigned>::readBuffer(int16 *buffer, const int numSamples) {
int AppendableMemoryStream<stereo, is16Bit, isUnsigned>::readBuffer(int16 *buffer, const int numSamples) {
int samples = 0;
while (samples < numSamples && !eosIntern()) {
// Wrap around?
@ -209,7 +209,7 @@ int WrappedMemoryStream<stereo, is16Bit, isUnsigned>::readBuffer(int16 *buffer,
}
template<bool stereo, bool is16Bit, bool isUnsigned>
void WrappedMemoryStream<stereo, is16Bit, isUnsigned>::append(const byte *data, uint32 len) {
void AppendableMemoryStream<stereo, is16Bit, isUnsigned>::append(const byte *data, uint32 len) {
// Verify the buffer size is sane
if (is16Bit && stereo)
@ -225,7 +225,7 @@ void WrappedMemoryStream<stereo, is16Bit, isUnsigned>::append(const byte *data,
uint32 size_to_end_of_buffer = _bufferEnd - _end;
len -= size_to_end_of_buffer;
if ((_end < _pos) || (_bufferStart + len >= _pos)) {
warning("WrappedMemoryStream: buffer overflow (A)");
warning("AppendableMemoryStream: buffer overflow (A)");
return;
}
memcpy(_end, data, size_to_end_of_buffer);
@ -233,7 +233,7 @@ void WrappedMemoryStream<stereo, is16Bit, isUnsigned>::append(const byte *data,
_end = _bufferStart + len;
} else {
if ((_end < _pos) && (_end + len >= _pos)) {
warning("WrappedMemoryStream: buffer overflow (B)");
warning("AppendableMemoryStream: buffer overflow (B)");
return;
}
memcpy(_end, data, len);
@ -250,7 +250,7 @@ void WrappedMemoryStream<stereo, is16Bit, isUnsigned>::append(const byte *data,
#if 0
// Work in progress!!! Not yet usable/finished/working/anything :-)
class ProcInputStream : public AudioInputStream {
class ProcInputStream : public AudioStream {
public:
typedef void InputProc (void *refCon, int16 *data, uint len);
@ -302,7 +302,7 @@ public:
} else \
return new LinearMemoryStream<STEREO, false, UNSIGNED, false>(rate, ptr, len, loopOffset, loopLen, autoFree)
AudioInputStream *makeLinearInputStream(int rate, byte _flags, const byte *ptr, uint32 len, uint loopOffset, uint loopLen) {
AudioStream *makeLinearInputStream(int rate, byte _flags, const byte *ptr, uint32 len, uint loopOffset, uint loopLen) {
const bool isStereo = (_flags & SoundMixer::FLAG_STEREO) != 0;
const bool is16Bit = (_flags & SoundMixer::FLAG_16BITS) != 0;
const bool isUnsigned = (_flags & SoundMixer::FLAG_UNSIGNED) != 0;
@ -326,11 +326,11 @@ AudioInputStream *makeLinearInputStream(int rate, byte _flags, const byte *ptr,
#define MAKE_WRAPPED(STEREO, UNSIGNED) \
if (is16Bit) \
return new WrappedMemoryStream<STEREO, true, UNSIGNED>(rate, len); \
return new AppendableMemoryStream<STEREO, true, UNSIGNED>(rate, len); \
else \
return new WrappedMemoryStream<STEREO, false, UNSIGNED>(rate, len)
return new AppendableMemoryStream<STEREO, false, UNSIGNED>(rate, len)
WrappedAudioInputStream *makeWrappedInputStream(int rate, byte _flags, uint32 len) {
AppendableAudioStream *makeAppendableAudioStream(int rate, byte _flags, uint32 len) {
const bool isStereo = (_flags & SoundMixer::FLAG_STEREO) != 0;
const bool is16Bit = (_flags & SoundMixer::FLAG_16BITS) != 0;
const bool isUnsigned = (_flags & SoundMixer::FLAG_UNSIGNED) != 0;

View file

@ -30,9 +30,9 @@
/**
* Generic input stream for the resampling code.
*/
class AudioInputStream {
class AudioStream {
public:
virtual ~AudioInputStream() {}
virtual ~AudioStream() {}
/**
* Fill the given buffer with up to numSamples samples.
@ -48,7 +48,7 @@ public:
/**
* Read a single (16 bit signed) sample from the stream.
*/
virtual int16 read() = 0;
// virtual int16 read() = 0;
/** Is this a stereo stream? */
virtual bool isStereo() const = 0;
@ -76,13 +76,13 @@ public:
virtual int getRate() const = 0;
};
class WrappedAudioInputStream : public AudioInputStream {
class AppendableAudioStream : public AudioStream {
public:
virtual void append(const byte *data, uint32 len) = 0;
virtual void finish() = 0;
};
class ZeroInputStream : public AudioInputStream {
class ZeroInputStream : public AudioStream {
private:
int _len;
public:
@ -100,7 +100,7 @@ public:
int getRate() const { return -1; }
};
AudioInputStream *makeLinearInputStream(int rate, byte _flags, const byte *ptr, uint32 len, uint loopOffset, uint loopLen);
WrappedAudioInputStream *makeWrappedInputStream(int rate, byte _flags, uint32 len);
AudioStream *makeLinearInputStream(int rate, byte _flags, const byte *ptr, uint32 len, uint loopOffset, uint loopLen);
AppendableAudioStream *makeAppendableAudioStream(int rate, byte _flags, uint32 len);
#endif

View file

@ -52,12 +52,12 @@ private:
protected:
RateConverter *_converter;
AudioInputStream *_input;
AudioStream *_input;
public:
Channel(SoundMixer *mixer, PlayingSoundHandle *handle, bool isMusic, byte volume, int8 pan, int id = -1);
Channel(SoundMixer *mixer, PlayingSoundHandle *handle, AudioInputStream *input, bool autofreeStream, bool isMusic, byte volume, int8 pan, bool reverseStereo = false, int id = -1);
Channel(SoundMixer *mixer, PlayingSoundHandle *handle, AudioStream *input, bool autofreeStream, bool isMusic, byte volume, int8 pan, bool reverseStereo = false, int id = -1);
virtual ~Channel();
void mix(int16 *data, uint len);
@ -229,7 +229,7 @@ void SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, u
}
// Create the input stream
AudioInputStream *input;
AudioStream *input;
if (flags & SoundMixer::FLAG_LOOP) {
if (loopEnd == 0) {
input = makeLinearInputStream(rate, flags, (byte *)sound, size, 0, size);
@ -249,7 +249,7 @@ void SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, u
#ifdef USE_MAD
void SoundMixer::playMP3(PlayingSoundHandle *handle, File *file, uint32 size, byte volume, int8 pan, int id) {
// Create the input stream
AudioInputStream *input = makeMP3Stream(file, size);
AudioStream *input = makeMP3Stream(file, size);
playInputStream(handle, input, false, volume, pan, id);
}
#endif
@ -257,12 +257,12 @@ void SoundMixer::playMP3(PlayingSoundHandle *handle, File *file, uint32 size, by
#ifdef USE_VORBIS
void SoundMixer::playVorbis(PlayingSoundHandle *handle, File *file, uint32 size, byte volume, int8 pan, int id) {
// Create the input stream
AudioInputStream *input = makeVorbisStream(file, size);
AudioStream *input = makeVorbisStream(file, size);
playInputStream(handle, input, false, volume, pan, id);
}
#endif
void SoundMixer::playInputStream(PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume, int8 pan, int id, bool autofreeStream) {
void SoundMixer::playInputStream(PlayingSoundHandle *handle, AudioStream *input, bool isMusic, byte volume, int8 pan, int id, bool autofreeStream) {
Common::StackLock lock(_mutex);
if (input == 0) {
@ -467,7 +467,7 @@ Channel::Channel(SoundMixer *mixer, PlayingSoundHandle *handle, bool isMusic,
assert(mixer);
}
Channel::Channel(SoundMixer *mixer, PlayingSoundHandle *handle, AudioInputStream *input,
Channel::Channel(SoundMixer *mixer, PlayingSoundHandle *handle, AudioStream *input,
bool autofreeStream, bool isMusic, byte volume, int8 pan, bool reverseStereo, int id)
: _mixer(mixer), _handle(handle), _autofreeStream(autofreeStream), _isMusic(isMusic),
_volume(volume), _pan(pan), _paused(false), _id(id), _converter(0), _input(input) {
@ -519,16 +519,16 @@ ChannelStream::ChannelStream(SoundMixer *mixer, PlayingSoundHandle *handle,
uint rate, byte flags, uint32 buffer_size, byte volume, int8 pan)
: Channel(mixer, handle, true, volume, pan) {
// Create the input stream
_input = makeWrappedInputStream(rate, flags, buffer_size);
_input = makeAppendableAudioStream(rate, flags, buffer_size);
// Get a rate converter instance
_converter = makeRateConverter(_input->getRate(), mixer->getOutputRate(), _input->isStereo(), (flags & SoundMixer::FLAG_REVERSE_STEREO) != 0);
}
void ChannelStream::finish() {
((WrappedAudioInputStream *)_input)->finish();
((AppendableAudioStream *)_input)->finish();
}
void ChannelStream::append(void *data, uint32 len) {
((WrappedAudioInputStream *)_input)->append((const byte *)data, len);
((AppendableAudioStream *)_input)->append((const byte *)data, len);
}

View file

@ -28,7 +28,7 @@
#include "common/system.h"
class AudioInputStream;
class AudioStream;
class Channel;
class File;
@ -113,7 +113,7 @@ public:
void playVorbis(PlayingSoundHandle *handle, File *file, uint32 size, byte volume = 255, int8 pan = 0, int id = -1);
#endif
void playInputStream(PlayingSoundHandle *handle, AudioInputStream *input, bool isMusic, byte volume = 255, int8 pan = 0, int id = -1, bool autofreeStream = true);
void playInputStream(PlayingSoundHandle *handle, AudioStream *input, bool isMusic, byte volume = 255, int8 pan = 0, int id = -1, bool autofreeStream = true);
/** Start a new stream. */

View file

@ -37,7 +37,7 @@
#pragma mark -
class MP3InputStream : public AudioInputStream {
class MP3InputStream : public AudioStream {
struct mad_stream _stream;
struct mad_frame _frame;
struct mad_synth _synth;
@ -261,7 +261,7 @@ int MP3InputStream::readBuffer(int16 *buffer, const int numSamples) {
return samples;
}
AudioInputStream *makeMP3Stream(File *file, uint size) {
AudioStream *makeMP3Stream(File *file, uint size) {
return new MP3InputStream(file, mad_timer_zero, size);
}
@ -376,7 +376,7 @@ void MP3TrackInfo::play(SoundMixer *mixer, PlayingSoundHandle *handle, int start
}
// Play it
AudioInputStream *input = new MP3InputStream(_file, durationTime, 0);
AudioStream *input = new MP3InputStream(_file, durationTime, 0);
mixer->playInputStream(handle, input, true);
}

View file

@ -27,13 +27,13 @@
#ifdef USE_MAD
class AudioInputStream;
class AudioStream;
class DigitalTrackInfo;
class File;
DigitalTrackInfo *makeMP3TrackInfo(File *file);
AudioInputStream *makeMP3Stream(File *file, uint size);
AudioStream *makeMP3Stream(File *file, uint size);
#endif

View file

@ -80,7 +80,7 @@ protected:
public:
LinearRateConverter(st_rate_t inrate, st_rate_t outrate);
int flow(AudioInputStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol_l, st_volume_t vol_r);
int flow(AudioStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol_l, st_volume_t vol_r);
int drain(st_sample_t *obuf, st_size_t osamp, st_volume_t vol) {
return (ST_SUCCESS);
}
@ -124,7 +124,7 @@ LinearRateConverter<stereo, reverseStereo>::LinearRateConverter(st_rate_t inrate
* Return number of samples processed.
*/
template<bool stereo, bool reverseStereo>
int LinearRateConverter<stereo, reverseStereo>::flow(AudioInputStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol_l, st_volume_t vol_r) {
int LinearRateConverter<stereo, reverseStereo>::flow(AudioStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol_l, st_volume_t vol_r) {
st_sample_t *ostart, *oend;
st_sample_t out[2];
@ -203,7 +203,7 @@ public:
free(_buffer);
}
virtual int flow(AudioInputStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol_l, st_volume_t vol_r) {
virtual int flow(AudioStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol_l, st_volume_t vol_r) {
assert(input.isStereo() == stereo);
st_sample_t *ptr;

View file

@ -27,7 +27,7 @@
#include "common/util.h"
//#include "sound/audiostream.h"
class AudioInputStream;
class AudioStream;
typedef int16 st_sample_t;
typedef uint16 st_volume_t;
@ -71,7 +71,7 @@ class RateConverter {
public:
RateConverter() {}
virtual ~RateConverter() {}
virtual int flow(AudioInputStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol_l, st_volume_t vol_r) = 0;
virtual int flow(AudioStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol_l, st_volume_t vol_r) = 0;
virtual int drain(st_sample_t *obuf, st_size_t osamp, st_volume_t vol) = 0;
};

View file

@ -681,7 +681,7 @@ int st_resample_start(resample_t r, st_rate_t inrate, st_rate_t outrate) {
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
int st_resample_flow(resample_t r, AudioInputStream &input, st_sample_t *obuf, st_size_t *osamp, st_volume_t vol) {
int st_resample_flow(resample_t r, AudioStream &input, st_sample_t *obuf, st_size_t *osamp, st_volume_t vol) {
long i, k, last;
long Nout = 0; // The number of bytes we effectively output
long Nx; // The number of bytes we will read from input
@ -689,7 +689,7 @@ int st_resample_flow(resample_t r, AudioInputStream &input, st_sample_t *obuf, s
const long obufSize = *osamp;
/*
TODO: adjust for the changes made to AudioInputStream; add support for stereo
TODO: adjust for the changes made to AudioStream; add support for stereo
initially, could just average the left/right channel -> bad for quality of course,
but easiest to implement and would get this going again.
Next step is to duplicate the X/Y buffers... a lot of computations don't care about
@ -946,7 +946,7 @@ ResampleRateConverter::~ResampleRateConverter() {
free(Y2);
}
int ResampleRateConverter::flow(AudioInputStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol) {
int ResampleRateConverter::flow(AudioStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol) {
// return st_resample_flow(&rstuff, input, obuf, &osamp, vol);
return 0;
}

View file

@ -85,7 +85,7 @@ protected:
public:
ResampleRateConverter(st_rate_t inrate, st_rate_t outrate, int quality);
~ResampleRateConverter();
virtual int flow(AudioInputStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol);
virtual int flow(AudioStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol);
virtual int drain(st_sample_t *obuf, st_size_t osamp, st_volume_t vol);
};

View file

@ -152,14 +152,14 @@ byte *loadVOCFile(File *file, int &size, int &rate) {
return data;
}
AudioInputStream *makeVOCStream(byte *ptr) {
AudioStream *makeVOCStream(byte *ptr) {
int size, rate, loops;
byte *data = readVOCFromMemory(ptr, size, rate, loops);
return makeLinearInputStream(rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_UNSIGNED, data, size, 0, 0);
}
AudioInputStream *makeVOCStream(File *file) {
AudioStream *makeVOCStream(File *file) {
int size, rate;
byte *data = loadVOCFile(file, size, rate);

View file

@ -26,7 +26,7 @@
#include "stdafx.h"
#include "common/scummsys.h"
class AudioInputStream;
class AudioStream;
class File;
#if !defined(__GNUC__)
@ -60,7 +60,7 @@ extern int getSampleRateFromVOCRate(int vocSR);
extern byte *readVOCFromMemory(byte *ptr, int &size, int &rate, int &loops);
extern byte *loadVOCFile(File *file, int &size, int &rate);
AudioInputStream *makeVOCStream(byte *ptr);
AudioInputStream *makeVOCStream(File *file);
AudioStream *makeVOCStream(byte *ptr);
AudioStream *makeVOCStream(File *file);
#endif

View file

@ -32,7 +32,7 @@
#include <vorbis/vorbisfile.h>
AudioInputStream *makeVorbisStream(OggVorbis_File *file, int duration);
AudioStream *makeVorbisStream(OggVorbis_File *file, int duration);
#pragma mark -
@ -145,7 +145,7 @@ void VorbisTrackInfo::play(SoundMixer *mixer, PlayingSoundHandle *handle, int st
ov_time_seek(&_ov_file, startFrame / 75.0);
#endif
AudioInputStream *input = makeVorbisStream(&_ov_file, duration * ov_info(&_ov_file, -1)->rate / 75);
AudioStream *input = makeVorbisStream(&_ov_file, duration * ov_info(&_ov_file, -1)->rate / 75);
mixer->playInputStream(handle, input, true);
}
@ -165,7 +165,7 @@ DigitalTrackInfo *makeVorbisTrackInfo(File *file) {
#pragma mark -
class VorbisInputStream : public AudioInputStream {
class VorbisInputStream : public AudioStream {
OggVorbis_File *_ov_file;
int _end_pos;
int _numChannels;
@ -274,11 +274,11 @@ void VorbisInputStream::refill() {
_bufferEnd = (int16 *)read_pos;
}
AudioInputStream *makeVorbisStream(OggVorbis_File *file, int duration) {
AudioStream *makeVorbisStream(OggVorbis_File *file, int duration) {
return new VorbisInputStream(file, duration);
}
AudioInputStream *makeVorbisStream(File *file, uint32 size) {
AudioStream *makeVorbisStream(File *file, uint32 size) {
OggVorbis_File *ov_file = new OggVorbis_File;
file_info *f = new file_info;

View file

@ -27,13 +27,13 @@
#ifdef USE_VORBIS
class AudioInputStream;
class AudioStream;
class DigitalTrackInfo;
class File;
DigitalTrackInfo *makeVorbisTrackInfo(File *file);
AudioInputStream *makeVorbisStream(File *file, uint32 size);
AudioStream *makeVorbisStream(File *file, uint32 size);
#endif

View file

@ -34,7 +34,7 @@
class SoundMixer;
class SwordMusicHandle : public AudioInputStream {
class SwordMusicHandle : public AudioStream {
private:
File _file;
bool _looping;

View file

@ -44,7 +44,7 @@ struct FxHandle {
PlayingSoundHandle _handle;
};
class MusicHandle : public AudioInputStream {
class MusicHandle : public AudioStream {
public:
bool _firstTime;
bool _streaming;