mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-05 00:36:57 +00:00
- Mark makeRawDiskStream factory as deprecated.
- Introduce two new makeRawStream factories, one is using RawStreamBlockList instead of an RawDiskStreamAudioBlock array. svn-id: r47713
This commit is contained in:
parent
17cebab354
commit
ec3f58e626
@ -306,10 +306,7 @@ void Music::play(uint32 resourceId, MusicFlags flags) {
|
||||
if (!_digitalMusicContext->isCompressed()) {
|
||||
byte musicFlags = Audio::FLAG_STEREO |
|
||||
Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN;
|
||||
Audio::RawDiskStreamAudioBlock audioBlocks[1];
|
||||
audioBlocks[0].pos = 0;
|
||||
audioBlocks[0].len = resData->size / 2; // 16-bit sound
|
||||
audioStream = Audio::makeRawDiskStream(musicStream, audioBlocks, 1, 11025, musicFlags, DisposeAfterUse::YES);
|
||||
audioStream = Audio::makeRawStream(musicStream, 11025, musicFlags, DisposeAfterUse::YES);
|
||||
} else {
|
||||
// Read compressed header to determine compression type
|
||||
musicFile->seek((uint32)resData->offset, SEEK_SET);
|
||||
|
@ -370,29 +370,31 @@ AudioStream *makeRawMemoryStream_OLD(const byte *ptr, uint32 len,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define MAKE_LINEAR_DISK(STEREO, UNSIGNED) \
|
||||
if (is16Bit) { \
|
||||
if (isLE) \
|
||||
return new RawDiskStream<STEREO, true, UNSIGNED, true>(rate, disposeStream, stream, blocks); \
|
||||
return new RawDiskStream<STEREO, true, UNSIGNED, true>(rate, disposeAfterUse, stream, blockList); \
|
||||
else \
|
||||
return new RawDiskStream<STEREO, true, UNSIGNED, false>(rate, disposeStream, stream, blocks); \
|
||||
return new RawDiskStream<STEREO, true, UNSIGNED, false>(rate, disposeAfterUse, stream, blockList); \
|
||||
} else \
|
||||
return new RawDiskStream<STEREO, false, UNSIGNED, false>(rate, disposeStream, stream, blocks)
|
||||
return new RawDiskStream<STEREO, false, UNSIGNED, false>(rate, disposeAfterUse, stream, blockList)
|
||||
|
||||
|
||||
SeekableAudioStream *makeRawDiskStream(Common::SeekableReadStream *stream, RawDiskStreamAudioBlock *block, int numBlocks,
|
||||
int rate, byte flags, DisposeAfterUse::Flag disposeStream) {
|
||||
SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream,
|
||||
const RawStreamBlockList &blockList,
|
||||
int rate,
|
||||
byte flags,
|
||||
DisposeAfterUse::Flag disposeAfterUse) {
|
||||
const bool isStereo = (flags & Audio::FLAG_STEREO) != 0;
|
||||
const bool is16Bit = (flags & Audio::FLAG_16BITS) != 0;
|
||||
const bool isUnsigned = (flags & Audio::FLAG_UNSIGNED) != 0;
|
||||
const bool isLE = (flags & Audio::FLAG_LITTLE_ENDIAN) != 0;
|
||||
|
||||
assert(numBlocks > 0);
|
||||
RawStreamBlockList blocks;
|
||||
for (int i = 0; i < numBlocks; ++i)
|
||||
blocks.push_back(block[i]);
|
||||
if (blockList.empty()) {
|
||||
warning("Empty block list passed to makeRawStream");
|
||||
if (disposeAfterUse == DisposeAfterUse::YES)
|
||||
delete stream;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (isStereo) {
|
||||
if (isUnsigned) {
|
||||
@ -409,4 +411,29 @@ SeekableAudioStream *makeRawDiskStream(Common::SeekableReadStream *stream, RawDi
|
||||
}
|
||||
}
|
||||
|
||||
SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream,
|
||||
int rate, byte flags,
|
||||
DisposeAfterUse::Flag disposeAfterUse) {
|
||||
RawStreamBlockList blocks;
|
||||
RawDiskStreamAudioBlock block;
|
||||
block.pos = 0;
|
||||
|
||||
const bool is16Bit = (flags & Audio::FLAG_16BITS) != 0;
|
||||
|
||||
block.len = stream->size() / (is16Bit ? 2 : 1);
|
||||
blocks.push_back(block);
|
||||
|
||||
return makeRawStream(stream, blocks, rate, flags, disposeAfterUse);
|
||||
}
|
||||
|
||||
SeekableAudioStream *makeRawDiskStream_OLD(Common::SeekableReadStream *stream, RawDiskStreamAudioBlock *block, int numBlocks,
|
||||
int rate, byte flags, DisposeAfterUse::Flag disposeStream) {
|
||||
assert(numBlocks > 0);
|
||||
RawStreamBlockList blocks;
|
||||
for (int i = 0; i < numBlocks; ++i)
|
||||
blocks.push_back(block[i]);
|
||||
|
||||
return makeRawStream(stream, blocks, rate, flags, disposeStream);
|
||||
}
|
||||
|
||||
} // End of namespace Audio
|
||||
|
@ -76,7 +76,7 @@ enum RawFlags {
|
||||
* @param len length of the buffer in bytes
|
||||
* @param rate sample rate of the data
|
||||
* @param flags audio format flags combination
|
||||
* @see Mixer::RawFlags
|
||||
* @see RawFlags
|
||||
* @param autofreeBuffer whether the data buffer should be destroyed after playback
|
||||
* @return The new SeekableAudioStream (or 0 on failure).
|
||||
*/
|
||||
@ -108,15 +108,53 @@ AudioStream *makeRawMemoryStream_OLD(const byte *ptr, uint32 len,
|
||||
*/
|
||||
struct RawDiskStreamAudioBlock {
|
||||
int32 pos; ///< Position in stream of the block (in bytes of course!)
|
||||
int32 len; ///< Length of the block (in samples)
|
||||
int32 len; ///< Length of the block (in sample (pairs))
|
||||
};
|
||||
|
||||
/**
|
||||
* List containing all blocks of a raw stream.
|
||||
* @see RawDiskStreamAudioBlock
|
||||
*/
|
||||
typedef Common::List<RawDiskStreamAudioBlock> RawStreamBlockList;
|
||||
|
||||
/**
|
||||
* Creates an audio stream, which plays from the given stream.
|
||||
*
|
||||
* @param stream Stream object to play from.
|
||||
* @param size Size of the buffer.
|
||||
* @param rate Rate of the sound data.
|
||||
* @param flags Audio flags combination.
|
||||
* @see RawFlags
|
||||
* @param disposeAfterUse Whether to delete the stream after use.
|
||||
* @return The new SeekableAudioStream (or 0 on failure).
|
||||
*/
|
||||
SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream,
|
||||
int rate, byte flags,
|
||||
DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
|
||||
|
||||
/**
|
||||
* Creates an audio stream, which plays from the given stream.
|
||||
*
|
||||
* @param stream Stream object to play from.
|
||||
* @param blockList List of blocks to play.
|
||||
* @see RawDiskStreamAudioBlock
|
||||
* @see RawStreamBlockList
|
||||
* @param rate Rate of the sound data.
|
||||
* @param flags Audio flags combination.
|
||||
* @see RawFlags
|
||||
* @param disposeAfterUse Whether to delete the stream after use.
|
||||
* @return The new SeekableAudioStream (or 0 on failure).
|
||||
*/
|
||||
SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream,
|
||||
const RawStreamBlockList &blockList,
|
||||
int rate,
|
||||
byte flags,
|
||||
DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
|
||||
|
||||
/**
|
||||
* NOTE:
|
||||
* This API is considered deprecated.
|
||||
*
|
||||
* Creates a audio stream, which plays from given stream.
|
||||
*
|
||||
* @param stream Stream to play from
|
||||
@ -125,11 +163,11 @@ typedef Common::List<RawDiskStreamAudioBlock> RawStreamBlockList;
|
||||
* @param numBlocks Number of blocks.
|
||||
* @param rate The rate
|
||||
* @param flags Flags combination.
|
||||
* @see Mixer::RawFlags
|
||||
* @see RawFlags
|
||||
* @param disposeStream Whether the "stream" object should be destroyed after playback.
|
||||
* @return The new SeekableAudioStream (or 0 on failure).
|
||||
*/
|
||||
SeekableAudioStream *makeRawDiskStream(Common::SeekableReadStream *stream,
|
||||
SeekableAudioStream *makeRawDiskStream_OLD(Common::SeekableReadStream *stream,
|
||||
RawDiskStreamAudioBlock *block, int numBlocks,
|
||||
int rate, byte flags,
|
||||
DisposeAfterUse::Flag disposeStream);
|
||||
|
@ -312,7 +312,7 @@ AudioStream *makeVOCDiskStream(Common::SeekableReadStream &stream, byte flags, D
|
||||
// Create an audiostream from the data. Note the numBlocks may be 0,
|
||||
// e.g. when invalid data is encountered. See bug #2890038.
|
||||
if (numBlocks)
|
||||
audioStream = makeRawDiskStream(&stream, block, numBlocks, rate, flags, takeOwnership, begin_loop, end_loop);
|
||||
audioStream = makeRawDiskStream_OLD(&stream, block, numBlocks, rate, flags, takeOwnership/*, begin_loop, end_loop*/);
|
||||
|
||||
delete[] block;
|
||||
|
||||
@ -332,7 +332,7 @@ SeekableAudioStream *makeVOCDiskStreamNoLoop(Common::SeekableReadStream &stream,
|
||||
// Create an audiostream from the data. Note the numBlocks may be 0,
|
||||
// e.g. when invalid data is encountered. See bug #2890038.
|
||||
if (numBlocks)
|
||||
audioStream = makeRawDiskStream(&stream, block, numBlocks, rate, flags, takeOwnership);
|
||||
audioStream = makeRawDiskStream_OLD(&stream, block, numBlocks, rate, flags, takeOwnership);
|
||||
|
||||
delete[] block;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user