change loadVOCFromStream to take a reference instead of a pointer (to a stream)

svn-id: r16035
This commit is contained in:
Max Horn 2004-12-11 23:34:34 +00:00
parent 369e31a41c
commit 3891c0fa39
4 changed files with 19 additions and 19 deletions

View File

@ -1017,7 +1017,7 @@ void Sound::startSfxSound(File *file, int file_size, PlayingSoundHandle *handle,
#endif
break;
default:
input = makeVOCStream(_sfxFile);
input = makeVOCStream(*_sfxFile);
}
if (!input) {

View File

@ -181,7 +181,7 @@ void VocSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
_file->seek(_offsets[sound], SEEK_SET);
int size, samples_per_sec;
byte *buffer = loadVOCFromStream(_file, size, samples_per_sec);
byte *buffer = loadVOCFromStream(*_file, size, samples_per_sec);
_mixer->playRaw(handle, buffer, size, samples_per_sec, flags | SoundMixer::FLAG_AUTOFREE);
}

View File

@ -43,22 +43,22 @@ int getSampleRateFromVOCRate(int vocSR) {
}
}
byte *loadVOCFromStream(Common::ReadStream *stream, int &size, int &rate) {
byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate) {
int loops, begin_loop, end_loop;
return loadVOCFromStream(stream, size, rate, loops, begin_loop, end_loop);
}
byte *loadVOCFromStream(Common::ReadStream *stream, int &size, int &rate, int &loops, int &begin_loop, int &end_loop) {
byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate, int &loops, int &begin_loop, int &end_loop) {
VocFileHeader fileHeader;
if (stream->read(&fileHeader, 8) != 8)
if (stream.read(&fileHeader, 8) != 8)
goto invalid;
if (!memcmp(&fileHeader, "VTLK", 4)) {
if (stream->read(&fileHeader, sizeof(VocFileHeader)) != sizeof(VocFileHeader))
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)
if (stream.read(((byte *)&fileHeader) + 8, sizeof(VocFileHeader) - 8) != sizeof(VocFileHeader) - 8)
goto invalid;
} else {
invalid:;
@ -86,15 +86,15 @@ byte *loadVOCFromStream(Common::ReadStream *stream, int &size, int &rate, int &l
begin_loop = 0;
end_loop = 0;
while ((code = stream->readByte())) {
len = stream->readByte();
len |= stream->readByte() << 8;
len |= stream->readByte() << 16;
while ((code = stream.readByte())) {
len = stream.readByte();
len |= stream.readByte() << 8;
len |= stream.readByte() << 16;
switch(code) {
case 1: {
int time_constant = stream->readByte();
int packing = stream->readByte();
int time_constant = stream.readByte();
int packing = stream.readByte();
len -= 2;
rate = getSampleRateFromVOCRate(time_constant);
debug(9, "VOC Data Block: %d, %d, %d", rate, packing, len);
@ -104,7 +104,7 @@ byte *loadVOCFromStream(Common::ReadStream *stream, int &size, int &rate, int &l
} else {
ret_sound = (byte *)malloc(len);
}
stream->read(ret_sound + size, len);
stream.read(ret_sound + size, len);
size += len;
begin_loop = size;
end_loop = size;
@ -114,7 +114,7 @@ byte *loadVOCFromStream(Common::ReadStream *stream, int &size, int &rate, int &l
} break;
case 6: // begin of loop
assert(len == 2);
loops = stream->readUint16LE();
loops = stream.readUint16LE();
break;
case 7: // end of loop
assert(len == 0);
@ -128,7 +128,7 @@ byte *loadVOCFromStream(Common::ReadStream *stream, int &size, int &rate, int &l
return ret_sound;
}
AudioStream *makeVOCStream(Common::ReadStream *stream) {
AudioStream *makeVOCStream(Common::ReadStream &stream) {
int size, rate;
byte *data = loadVOCFromStream(stream, size, rate);

View File

@ -63,9 +63,9 @@ struct VocBlockHeader {
*/
extern int getSampleRateFromVOCRate(int vocSR);
extern byte *loadVOCFromStream(Common::ReadStream *stream, int &size, int &rate, int &loops, int &begin_loop, int &end_loop);
extern byte *loadVOCFromStream(Common::ReadStream *stream, int &size, int &rate);
extern byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate, int &loops, int &begin_loop, int &end_loop);
extern byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate);
AudioStream *makeVOCStream(Common::ReadStream *stream);
AudioStream *makeVOCStream(Common::ReadStream &stream);
#endif