mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-11 12:18:05 +00:00
ZVISION: Removed 'packed' audio handling from RawZorkStream.
Moved it to the factory method for creating Audio Streams
This commit is contained in:
parent
071d9f2241
commit
c7ce580bbd
@ -29,6 +29,7 @@
|
||||
#include "common/bufferedstream.h"
|
||||
#include "common/util.h"
|
||||
#include "audio/audiostream.h"
|
||||
#include "audio/decoders/raw.h"
|
||||
|
||||
#include "zvision/zork_raw.h"
|
||||
#include "zvision/zvision.h"
|
||||
@ -51,10 +52,9 @@ const int32 RawZorkStream::_amplitudeLookupTable[89] = {0x0007, 0x0008, 0x0009,
|
||||
0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B,
|
||||
0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF};
|
||||
|
||||
RawZorkStream::RawZorkStream(uint32 rate, bool stereo, bool packed, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
|
||||
RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
|
||||
: _rate(rate),
|
||||
_stereo(stereo),
|
||||
_packed(packed),
|
||||
_stream(stream, disposeStream),
|
||||
_endOfData(false) {
|
||||
_lastSample[0] = {0, 0};
|
||||
@ -65,18 +65,6 @@ RawZorkStream::RawZorkStream(uint32 rate, bool stereo, bool packed, DisposeAfter
|
||||
}
|
||||
|
||||
int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
|
||||
if (_packed)
|
||||
return decodeADPCM(buffer, numSamples);
|
||||
else {
|
||||
uint32 bytesRead = _stream->read(buffer, numSamples);
|
||||
if (_stream->eos())
|
||||
_endOfData = true;
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
}
|
||||
|
||||
int RawZorkStream::decodeADPCM(int16 *buffer, const int numSamples) {
|
||||
uint16 bytesRead = 0;
|
||||
|
||||
// 0: Left, 1: Right
|
||||
@ -143,21 +131,19 @@ bool RawZorkStream::rewind() {
|
||||
Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
|
||||
int rate,
|
||||
bool stereo,
|
||||
bool packed,
|
||||
DisposeAfterUse::Flag disposeAfterUse) {
|
||||
assert(stream->size() % 2 == 0);
|
||||
return new RawZorkStream(rate, stereo, packed, disposeAfterUse, stream);
|
||||
return new RawZorkStream(rate, stereo, disposeAfterUse, stream);
|
||||
}
|
||||
|
||||
Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
|
||||
int rate,
|
||||
bool stereo,
|
||||
bool packed,
|
||||
DisposeAfterUse::Flag disposeAfterUse) {
|
||||
return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, stereo, packed, DisposeAfterUse::YES);
|
||||
return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, stereo, DisposeAfterUse::YES);
|
||||
}
|
||||
|
||||
Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) {
|
||||
Audio::AudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) {
|
||||
Common::File *file = new Common::File();
|
||||
assert(file->open(filePath));
|
||||
|
||||
@ -179,7 +165,14 @@ Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath,
|
||||
}
|
||||
}
|
||||
|
||||
return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams.rate, soundParams.stereo, soundParams.packed, DisposeAfterUse::YES);
|
||||
if (soundParams.packed) {
|
||||
byte flags = 0;
|
||||
if (soundParams.stereo)
|
||||
flags |= Audio::FLAG_STEREO;
|
||||
return Audio::makeRawStream(file, soundParams.rate, flags, DisposeAfterUse::YES);
|
||||
}
|
||||
else
|
||||
return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams.rate, soundParams.stereo, DisposeAfterUse::YES);
|
||||
}
|
||||
|
||||
} // End of namespace ZVision
|
||||
|
@ -61,8 +61,7 @@ const SoundParams zgiSoundParamLookupTable[5] = {{'a',0x5622, false, false},
|
||||
*/
|
||||
class RawZorkStream : public Audio::RewindableAudioStream {
|
||||
public:
|
||||
RawZorkStream(uint32 rate, bool stereo, bool packed, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream);
|
||||
RawZorkStream(const Common::String &filePath, ZVision *engine);
|
||||
RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream);
|
||||
|
||||
~RawZorkStream() {
|
||||
}
|
||||
@ -75,7 +74,6 @@ private:
|
||||
Common::DisposablePtr<Common::SeekableReadStream> _stream; // Stream to read data from
|
||||
bool _endOfData; // Whether the stream end has been reached
|
||||
bool _stereo;
|
||||
bool _packed;
|
||||
|
||||
/**
|
||||
* Holds the frequency and index from the last sample
|
||||
@ -99,9 +97,6 @@ public:
|
||||
Audio::Timestamp getLength() const { return _playtime; }
|
||||
|
||||
bool rewind();
|
||||
|
||||
private:
|
||||
int decodeADPCM(int16 *buffer, const int numSamples);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -116,7 +111,6 @@ private:
|
||||
Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
|
||||
int rate,
|
||||
bool stereo,
|
||||
bool packed,
|
||||
DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
|
||||
|
||||
/**
|
||||
@ -130,10 +124,9 @@ Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
|
||||
Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
|
||||
int rate,
|
||||
bool stereo,
|
||||
bool packed,
|
||||
DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
|
||||
|
||||
Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine);
|
||||
Audio::AudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine);
|
||||
|
||||
} // End of namespace ZVision
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user