mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-02 17:03:13 +00:00
Get rid of Audio::makeRawMemoryStream_OLD.
svn-id: r47715
This commit is contained in:
parent
523181d719
commit
8e3646e062
@ -95,7 +95,10 @@ void Player_MOD::startChannel(int id, void *data, int size, int rate, uint8 vol,
|
||||
_channels[i].pan = pan;
|
||||
_channels[i].freq = rate;
|
||||
_channels[i].ctr = 0;
|
||||
_channels[i].input = Audio::makeRawMemoryStream_OLD((const byte*)data, size, rate, 0, loopStart, loopEnd);
|
||||
|
||||
Audio::SeekableAudioStream *stream = Audio::makeRawStream((const byte *)data, size, rate, 0);
|
||||
_channels[i].input = Audio::makeLoopingAudioStream(stream, Audio::Timestamp(0, loopStart, rate), Audio::Timestamp(0, loopEnd, rate), loopStart == loopEnd ? 1 : 0);
|
||||
|
||||
// read the first sample
|
||||
_channels[i].input->readBuffer(&_channels[i].pos, 1);
|
||||
}
|
||||
|
@ -349,7 +349,8 @@ void Sound::playSound(int soundID) {
|
||||
}
|
||||
size -= waveSize;
|
||||
|
||||
stream = Audio::makeRawMemoryStream_OLD(sound, waveSize, rate, Audio::FLAG_UNSIGNED, loopStart, loopEnd);
|
||||
Audio::SeekableAudioStream *s = Audio::makeRawStream(sound, waveSize, rate, Audio::FLAG_UNSIGNED);
|
||||
stream = Audio::makeLoopingAudioStream(s, Audio::Timestamp(0, loopStart, rate), Audio::Timestamp(0, loopEnd, rate), 0);
|
||||
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID, 255, 0);
|
||||
}
|
||||
break;
|
||||
@ -430,17 +431,21 @@ void Sound::playSound(int soundID) {
|
||||
int vol = ptr[24] * 4;
|
||||
int loopStart = 0, loopEnd = 0;
|
||||
int loopcount = ptr[27];
|
||||
if (loopcount > 1) {
|
||||
// TODO: We can only loop once, or infinitely many times, but
|
||||
// have no support for a finite number of repetitions.
|
||||
// So far, I have seen only 1 and 255 (for infinite repetitions),
|
||||
// so maybe this is not really a problem.
|
||||
loopStart = READ_BE_UINT16(ptr + 10) - READ_BE_UINT16(ptr + 8);
|
||||
loopEnd = READ_BE_UINT16(ptr + 14);
|
||||
}
|
||||
|
||||
memcpy(sound, ptr + READ_BE_UINT16(ptr + 8), size);
|
||||
stream = Audio::makeRawMemoryStream_OLD(sound, size, rate, 0, loopStart, loopEnd);
|
||||
Audio::SeekableAudioStream *plainStream = Audio::makeRawStream(sound, size, rate, 0);
|
||||
|
||||
if (loopcount > 1) {
|
||||
loopStart = READ_BE_UINT16(ptr + 10) - READ_BE_UINT16(ptr + 8);
|
||||
loopEnd = READ_BE_UINT16(ptr + 14);
|
||||
|
||||
// TODO: Currently we will only ever play till "loopEnd", even when we only have
|
||||
// a finite repition count.
|
||||
stream = Audio::makeLoopingAudioStream(plainStream, Audio::Timestamp(0, loopStart, rate), Audio::Timestamp(0, loopEnd, rate), loopcount == 255 ? 0 : loopcount);
|
||||
} else {
|
||||
stream = plainStream;
|
||||
}
|
||||
|
||||
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID, vol, 0);
|
||||
}
|
||||
else {
|
||||
|
@ -339,37 +339,6 @@ SeekableAudioStream *makeRawMemoryStream(const byte *ptr, uint32 len,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AudioStream *makeRawMemoryStream_OLD(const byte *ptr, uint32 len,
|
||||
int rate, byte flags,
|
||||
uint loopStart, uint loopEnd,
|
||||
DisposeAfterUse::Flag autoFree
|
||||
) {
|
||||
SeekableAudioStream *s = makeRawMemoryStream(ptr, len, rate, flags, autoFree);
|
||||
|
||||
if (loopStart != loopEnd) {
|
||||
const bool isStereo = (flags & Audio::FLAG_STEREO) != 0;
|
||||
const bool is16Bit = (flags & Audio::FLAG_16BITS) != 0;
|
||||
|
||||
if (loopEnd == 0)
|
||||
loopEnd = len;
|
||||
assert(loopStart <= loopEnd);
|
||||
assert(loopEnd <= len);
|
||||
|
||||
// Verify the buffer sizes are sane
|
||||
if (is16Bit && isStereo)
|
||||
assert((loopStart & 3) == 0 && (loopEnd & 3) == 0);
|
||||
else if (is16Bit || isStereo)
|
||||
assert((loopStart & 1) == 0 && (loopEnd & 1) == 0);
|
||||
|
||||
const uint32 extRate = s->getRate() * (is16Bit ? 2 : 1) * (isStereo ? 2 : 1);
|
||||
|
||||
return new SubLoopingAudioStream(s, 0, Timestamp(0, loopStart, extRate), Timestamp(0, loopEnd, extRate));
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
#define MAKE_LINEAR_DISK(STEREO, UNSIGNED) \
|
||||
if (is16Bit) { \
|
||||
if (isLE) \
|
||||
|
@ -85,24 +85,6 @@ SeekableAudioStream *makeRawMemoryStream(const byte *ptr, uint32 len,
|
||||
DisposeAfterUse::Flag autofreeBuffer = DisposeAfterUse::YES
|
||||
);
|
||||
|
||||
/**
|
||||
* NOTE:
|
||||
* This API is considered deprecated.
|
||||
*
|
||||
* Factory function for a raw PCM AudioStream, which will simply treat all
|
||||
* data in the buffer described by ptr and len as raw sample data in the
|
||||
* specified format. It will then simply pass this data directly to the mixer,
|
||||
* after converting it to the sample format used by the mixer (i.e. 16 bit
|
||||
* signed native endian). Optionally supports (infinite) looping of a portion
|
||||
* of the data.
|
||||
*/
|
||||
AudioStream *makeRawMemoryStream_OLD(const byte *ptr, uint32 len,
|
||||
int rate, byte flags,
|
||||
uint loopStart, uint loopEnd,
|
||||
DisposeAfterUse::Flag autofreeBuffer = DisposeAfterUse::YES
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Struct used to define the audio data to be played by a RawDiskStream.
|
||||
*/
|
||||
|
@ -353,7 +353,29 @@ AudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, uint
|
||||
if (!data)
|
||||
return 0;
|
||||
|
||||
return makeRawMemoryStream_OLD(data, size, rate, flags, loopStart, loopEnd);
|
||||
SeekableAudioStream *s = Audio::makeRawStream(data, size, rate, flags);
|
||||
|
||||
if (loopStart != loopEnd) {
|
||||
const bool isStereo = (flags & Audio::FLAG_STEREO) != 0;
|
||||
const bool is16Bit = (flags & Audio::FLAG_16BITS) != 0;
|
||||
|
||||
if (loopEnd == 0)
|
||||
loopEnd = size;
|
||||
assert(loopStart <= loopEnd);
|
||||
assert(loopEnd <= (uint)size);
|
||||
|
||||
// Verify the buffer sizes are sane
|
||||
if (is16Bit && isStereo)
|
||||
assert((loopStart & 3) == 0 && (loopEnd & 3) == 0);
|
||||
else if (is16Bit || isStereo)
|
||||
assert((loopStart & 1) == 0 && (loopEnd & 1) == 0);
|
||||
|
||||
const uint32 extRate = s->getRate() * (is16Bit ? 2 : 1) * (isStereo ? 2 : 1);
|
||||
|
||||
return new SubLoopingAudioStream(s, 0, Timestamp(0, loopStart, extRate), Timestamp(0, loopEnd, extRate));
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user