diff options
author | Max Horn | 2010-01-16 21:36:08 +0000 |
---|---|---|
committer | Max Horn | 2010-01-16 21:36:08 +0000 |
commit | 7ec2da968c9c572daa888e4f3215e99ba0e9e86b (patch) | |
tree | 17170e1ada083a09a6bbb8ac89889a9938473fa3 | |
parent | b8f2a3a34271b73ab2cb84ea25e5fbf80e076658 (diff) | |
download | scummvm-rg350-7ec2da968c9c572daa888e4f3215e99ba0e9e86b.tar.gz scummvm-rg350-7ec2da968c9c572daa888e4f3215e99ba0e9e86b.tar.bz2 scummvm-rg350-7ec2da968c9c572daa888e4f3215e99ba0e9e86b.zip |
Switch most AudioStream factories to use DisposeAfterUse::Flag
svn-id: r47334
34 files changed, 130 insertions, 123 deletions
diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp index 258f9b670c..5b72b948f8 100644 --- a/engines/agos/animation.cpp +++ b/engines/agos/animation.cpp @@ -302,10 +302,10 @@ void MoviePlayerDXA::startSound() { size = in.readUint32LE(); in.seek(offset, SEEK_SET); - _bgSoundStream = Audio::makeWAVStream(in.readStream(size), true); + _bgSoundStream = Audio::makeWAVStream(in.readStream(size), DisposeAfterUse::YES); in.close(); } else { - _bgSoundStream = Audio::makeWAVStream(_fileStream->readStream(size), true); + _bgSoundStream = Audio::makeWAVStream(_fileStream->readStream(size), DisposeAfterUse::YES); } } else { _bgSoundStream = Audio::SeekableAudioStream::openStreamFile(baseName); diff --git a/engines/agos/sound.cpp b/engines/agos/sound.cpp index 77604eca75..4d79f4fed3 100644 --- a/engines/agos/sound.cpp +++ b/engines/agos/sound.cpp @@ -248,7 +248,7 @@ Audio::AudioStream *WavSound::makeAudioStream(uint sound) { return NULL; _file->seek(_offsets[sound], SEEK_SET); - return Audio::makeWAVStream(_file, false); + return Audio::makeWAVStream(_file, DisposeAfterUse::NO); } void WavSound::playSound(uint sound, uint loopSound, Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte flags, int vol) { @@ -302,7 +302,7 @@ Audio::AudioStream *MP3Sound::makeAudioStream(uint sound) { Common::MemoryReadStream *tmp = _file->readStream(size); assert(tmp); - return Audio::makeMP3Stream(tmp, true); + return Audio::makeMP3Stream(tmp, DisposeAfterUse::YES); } void MP3Sound::playSound(uint sound, uint loopSound, Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte flags, int vol) { @@ -333,7 +333,7 @@ Audio::AudioStream *VorbisSound::makeAudioStream(uint sound) { Common::MemoryReadStream *tmp = _file->readStream(size); assert(tmp); - return Audio::makeVorbisStream(tmp, true); + return Audio::makeVorbisStream(tmp, DisposeAfterUse::YES); } void VorbisSound::playSound(uint sound, uint loopSound, Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte flags, int vol) { @@ -364,7 +364,7 @@ Audio::AudioStream *FlacSound::makeAudioStream(uint sound) { Common::MemoryReadStream *tmp = _file->readStream(size); assert(tmp); - return Audio::makeFlacStream(tmp, true); + return Audio::makeFlacStream(tmp, DisposeAfterUse::YES); } void FlacSound::playSound(uint sound, uint loopSound, Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte flags, int vol) { @@ -783,7 +783,7 @@ void Sound::playVoiceData(byte *soundData, uint sound) { void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, int pan, int vol, bool loop) { int size = READ_LE_UINT32(soundData + 4); Common::MemoryReadStream *stream = new Common::MemoryReadStream(soundData, size); - Audio::RewindableAudioStream *sndStream = Audio::makeWAVStream(stream, true); + Audio::RewindableAudioStream *sndStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES); convertVolume(vol); convertPan(pan); diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp index b97d367206..e75c6e0033 100644 --- a/engines/kyra/sound.cpp +++ b/engines/kyra/sound.cpp @@ -97,7 +97,7 @@ Audio::SeekableAudioStream *Sound::getVoiceStream(const char *file) { if (!stream) continue; - audioStream = _supportedCodecs[i].streamFunc(stream, true); + audioStream = _supportedCodecs[i].streamFunc(stream, DisposeAfterUse::YES); break; } @@ -241,12 +241,12 @@ namespace { // A simple wrapper to create VOC streams the way like creating MP3, OGG/Vorbis and FLAC streams. // Possible TODO: Think of making this complete and moving it to sound/voc.cpp ? -Audio::SeekableAudioStream *makeVOCStream(Common::SeekableReadStream *stream, bool disposeAfterUse) { +Audio::SeekableAudioStream *makeVOCStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse) { #ifdef STREAM_AUDIO_FROM_DISK Audio::SeekableAudioStream *as = Audio::makeVOCStream(*stream, Audio::Mixer::FLAG_UNSIGNED, disposeAfterUse); #else - Audio::SeekableAudioStream *as = Audio::makeVOCStream(*stream, Audio::Mixer::FLAG_UNSIGNED, false); + Audio::SeekableAudioStream *as = Audio::makeVOCStream(*stream, Audio::Mixer::FLAG_UNSIGNED, DisposeAfterUse::NO); if (disposeAfterUse) delete stream; diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h index ae0510853a..9cba030a13 100644 --- a/engines/kyra/sound.h +++ b/engines/kyra/sound.h @@ -243,7 +243,7 @@ private: const char *fileext; Audio::SeekableAudioStream *(*streamFunc)( Common::SeekableReadStream *stream, - bool disposeAfterUse); + DisposeAfterUse::Flag disposeAfterUse); }; static const SpeechCodecs _supportedCodecs[]; @@ -358,7 +358,7 @@ private: const char *fileext; Audio::SeekableAudioStream *(*streamFunc)( Common::SeekableReadStream *stream, - bool disposeAfterUse); + DisposeAfterUse::Flag disposeAfterUse); }; static const AudioCodecs _supportedCodecs[]; diff --git a/engines/kyra/sound_digital.cpp b/engines/kyra/sound_digital.cpp index 84b18ebc33..314d45299a 100644 --- a/engines/kyra/sound_digital.cpp +++ b/engines/kyra/sound_digital.cpp @@ -460,7 +460,7 @@ int SoundDigital::playSound(const char *filename, uint8 priority, Audio::Mixer:: strncpy(use->filename, filename, sizeof(use->filename)); use->priority = priority; - Audio::SeekableAudioStream *audioStream = _supportedCodecs[usedCodec].streamFunc(stream, true); + Audio::SeekableAudioStream *audioStream = _supportedCodecs[usedCodec].streamFunc(stream, DisposeAfterUse::YES); if (!audioStream) { warning("Couldn't create audio stream for file '%s'", filename); return -1; @@ -522,7 +522,7 @@ void SoundDigital::beginFadeOut(int channel, int ticks) { namespace { -Audio::SeekableAudioStream *makeAUDStream(Common::SeekableReadStream *stream, bool disposeAfterUse) { +Audio::SeekableAudioStream *makeAUDStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse) { return new AUDStream(stream); } diff --git a/engines/mohawk/sound.cpp b/engines/mohawk/sound.cpp index 1864cdd006..fd37bbdfee 100644 --- a/engines/mohawk/sound.cpp +++ b/engines/mohawk/sound.cpp @@ -108,7 +108,7 @@ Audio::SoundHandle *Sound::playSound(uint16 id, bool mainSoundFile, byte volume) delete mjmpStream; } - audStream = Audio::makeWAVStream(_vm->getRawData(ID_MSND, id), true); + audStream = Audio::makeWAVStream(_vm->getRawData(ID_MSND, id), DisposeAfterUse::YES); } else audStream = makeMohawkWaveStream(_vm->getRawData(ID_MSND, id)); break; @@ -448,7 +448,7 @@ Audio::AudioStream *Sound::makeMohawkWaveStream(Common::SeekableReadStream *stre } else if (data_chunk.encoding == kCodecMPEG2) { #ifdef USE_MAD Common::MemoryReadStream *dataStream = new Common::MemoryReadStream(data_chunk.audio_data, data_chunk.size, DisposeAfterUse::YES); - return Audio::makeLoopingAudioStream(Audio::makeMP3Stream(dataStream, true), loop ? 0 : 1); + return Audio::makeLoopingAudioStream(Audio::makeMP3Stream(dataStream, DisposeAfterUse::YES), loop ? 0 : 1); #else warning ("MAD library not included - unable to play MP2 audio"); #endif diff --git a/engines/queen/sound.cpp b/engines/queen/sound.cpp index b7dd9c66c9..b0bc2cf6b6 100644 --- a/engines/queen/sound.cpp +++ b/engines/queen/sound.cpp @@ -120,7 +120,7 @@ protected: void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) { Common::MemoryReadStream *tmp = f->readStream(size); assert(tmp); - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, new AudioStreamWrapper(Audio::makeMP3Stream(tmp, true))); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, new AudioStreamWrapper(Audio::makeMP3Stream(tmp, DisposeAfterUse::YES))); } }; #endif @@ -133,7 +133,7 @@ protected: void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) { Common::MemoryReadStream *tmp = f->readStream(size); assert(tmp); - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, new AudioStreamWrapper(Audio::makeVorbisStream(tmp, true))); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, new AudioStreamWrapper(Audio::makeVorbisStream(tmp, DisposeAfterUse::YES))); } }; #endif @@ -146,7 +146,7 @@ protected: void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) { Common::MemoryReadStream *tmp = f->readStream(size); assert(tmp); - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, new AudioStreamWrapper(Audio::makeFlacStream(tmp, true))); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, new AudioStreamWrapper(Audio::makeFlacStream(tmp, DisposeAfterUse::YES))); } }; #endif // #ifdef USE_FLAC diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 34b35305c2..37d211bc72 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -308,7 +308,7 @@ void Music::play(uint32 resourceId, MusicFlags flags) { Audio::LinearDiskStreamAudioBlock audioBlocks[1]; audioBlocks[0].pos = 0; audioBlocks[0].len = resData->size / 2; // 16-bit sound - audioStream = Audio::makeLinearDiskStream(musicStream, audioBlocks, 1, 11025, musicFlags, true); + audioStream = Audio::makeLinearDiskStream(musicStream, audioBlocks, 1, 11025, musicFlags, DisposeAfterUse::YES); } else { // Read compressed header to determine compression type musicFile->seek((uint32)resData->offset, SEEK_SET); @@ -316,15 +316,15 @@ void Music::play(uint32 resourceId, MusicFlags flags) { if (identifier == 0) { // MP3 #ifdef USE_MAD - audioStream = Audio::makeMP3Stream(musicStream, true); + audioStream = Audio::makeMP3Stream(musicStream, DisposeAfterUse::YES); #endif } else if (identifier == 1) { // OGG #ifdef USE_VORBIS - audioStream = Audio::makeVorbisStream(musicStream, true); + audioStream = Audio::makeVorbisStream(musicStream, DisposeAfterUse::YES); #endif } else if (identifier == 2) { // FLAC #ifdef USE_FLAC - audioStream = Audio::makeFlacStream(musicStream, true); + audioStream = Audio::makeFlacStream(musicStream, DisposeAfterUse::YES); #endif } } diff --git a/engines/saga/sound.cpp b/engines/saga/sound.cpp index e611cd4bdc..2636567880 100644 --- a/engines/saga/sound.cpp +++ b/engines/saga/sound.cpp @@ -83,17 +83,17 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int switch (buffer.soundType) { #ifdef USE_MAD case kSoundMP3: - stream = Audio::makeMP3Stream(new Common::MemoryReadStream(buffer.buffer, buffer.size, DisposeAfterUse::YES), true); + stream = Audio::makeMP3Stream(new Common::MemoryReadStream(buffer.buffer, buffer.size, DisposeAfterUse::YES), DisposeAfterUse::YES); break; #endif #ifdef USE_VORBIS case kSoundOGG: - stream = Audio::makeVorbisStream(new Common::MemoryReadStream(buffer.buffer, buffer.size, DisposeAfterUse::YES), true); + stream = Audio::makeVorbisStream(new Common::MemoryReadStream(buffer.buffer, buffer.size, DisposeAfterUse::YES), DisposeAfterUse::YES); break; #endif #ifdef USE_FLAC case kSoundFLAC: - stream = Audio::makeFlacStream(new Common::MemoryReadStream(buffer.buffer, buffer.size, DisposeAfterUse::YES), true); + stream = Audio::makeFlacStream(new Common::MemoryReadStream(buffer.buffer, buffer.size, DisposeAfterUse::YES), DisposeAfterUse::YES); break; #endif default: diff --git a/engines/sci/sound/audio.cpp b/engines/sci/sound/audio.cpp index 4011aa9fa3..54655eb0c7 100644 --- a/engines/sci/sound/audio.cpp +++ b/engines/sci/sound/audio.cpp @@ -230,7 +230,7 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32 if (memcmp(audioRes->data, "RIFF", 4) == 0) { // WAVE detected Common::MemoryReadStream *waveStream = new Common::MemoryReadStream(audioRes->data, audioRes->size, DisposeAfterUse::NO); - audioStream = Audio::makeWAVStream(waveStream, true); + audioStream = Audio::makeWAVStream(waveStream, DisposeAfterUse::YES); } } if (!audioStream) { diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp index d7642d10b7..59554b93a1 100644 --- a/engines/sci/sound/music.cpp +++ b/engines/sci/sound/music.cpp @@ -228,7 +228,7 @@ void SciMusic::soundPlay(MusicEntry *pSnd) { if (pSnd->pStreamAud && !_pMixer->isSoundHandleActive(pSnd->hCurrentAud)) { if (pSnd->loop > 1) { pSnd->pLoopStream = new Audio::LoopingAudioStream(pSnd->pStreamAud, - pSnd->loop, false + pSnd->loop, DisposeAfterUse::NO ); _pMixer->playInputStream(pSnd->soundType, &pSnd->hCurrentAud, pSnd->pLoopStream, -1, pSnd->volume, 0, diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp index 7b966943b8..e366a04969 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp @@ -704,15 +704,15 @@ int32 ImuseDigiSndMgr::getDataFromRegion(SoundDesc *soundDesc, int region, byte assert(tmp); #ifdef USE_FLAC if (soundMode == 3) - soundDesc->compressedStream = Audio::makeFlacStream(tmp, true); + soundDesc->compressedStream = Audio::makeFlacStream(tmp, DisposeAfterUse::YES); #endif #ifdef USE_VORBIS if (soundMode == 2) - soundDesc->compressedStream = Audio::makeVorbisStream(tmp, true); + soundDesc->compressedStream = Audio::makeVorbisStream(tmp, DisposeAfterUse::YES); #endif #ifdef USE_MAD if (soundMode == 1) - soundDesc->compressedStream = Audio::makeMP3Stream(tmp, true); + soundDesc->compressedStream = Audio::makeMP3Stream(tmp, DisposeAfterUse::YES); #endif assert(soundDesc->compressedStream); soundDesc->compressedStream->seek(offsetMs); diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp index df7b97a9af..cc84a4db4a 100644 --- a/engines/scumm/smush/smush_player.cpp +++ b/engines/scumm/smush/smush_player.cpp @@ -1110,7 +1110,7 @@ void SmushPlayer::tryCmpFile(const char *filename) { strcpy(fname + (i - filename), ".ogg"); if (file->open(fname)) { _compressedFileMode = true; - _vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_compressedFileSoundHandle, Audio::makeVorbisStream(file, true)); + _vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_compressedFileSoundHandle, Audio::makeVorbisStream(file, DisposeAfterUse::YES)); return; } #endif @@ -1119,7 +1119,7 @@ void SmushPlayer::tryCmpFile(const char *filename) { strcpy(fname + (i - filename), ".mp3"); if (file->open(fname)) { _compressedFileMode = true; - _vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_compressedFileSoundHandle, Audio::makeMP3Stream(file, true)); + _vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_compressedFileSoundHandle, Audio::makeMP3Stream(file, DisposeAfterUse::YES)); return; } #endif diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp index 957da9f26a..80887c7cb8 100644 --- a/engines/scumm/sound.cpp +++ b/engines/scumm/sound.cpp @@ -632,7 +632,7 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle assert(size > 0); tmp = _sfxFile->readStream(size); assert(tmp); - input = Audio::makeMP3Stream(tmp, true); + input = Audio::makeMP3Stream(tmp, DisposeAfterUse::YES); #endif break; case kVorbisMode: @@ -640,7 +640,7 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle assert(size > 0); tmp = _sfxFile->readStream(size); assert(tmp); - input = Audio::makeVorbisStream(tmp, true); + input = Audio::makeVorbisStream(tmp, DisposeAfterUse::YES); #endif break; case kFlacMode: @@ -648,7 +648,7 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle assert(size > 0); tmp = _sfxFile->readStream(size); assert(tmp); - input = Audio::makeFlacStream(tmp, true); + input = Audio::makeFlacStream(tmp, DisposeAfterUse::YES); #endif break; default: diff --git a/engines/sword1/music.cpp b/engines/sword1/music.cpp index de5906713e..9d74e6a3f2 100644 --- a/engines/sword1/music.cpp +++ b/engines/sword1/music.cpp @@ -62,7 +62,7 @@ bool MusicHandle::play(const char *fileBase, bool loop) { if (!_audioSource) { sprintf(fileName, "%s.flac", fileBase); if (_file.open(fileName)) { - _audioSource = Audio::makeLoopingAudioStream(Audio::makeFlacStream(&_file, false), loop ? 0 : 1); + _audioSource = Audio::makeLoopingAudioStream(Audio::makeFlacStream(&_file, DisposeAfterUse::NO), loop ? 0 : 1); if (!_audioSource) _file.close(); } @@ -71,7 +71,7 @@ bool MusicHandle::play(const char *fileBase, bool loop) { if (!_audioSource) { sprintf(fileName, "%s.fla", fileBase); if (_file.open(fileName)) { - _audioSource = Audio::makeLoopingAudioStream(Audio::makeFlacStream(&_file, false), loop ? 0 : 1); + _audioSource = Audio::makeLoopingAudioStream(Audio::makeFlacStream(&_file, DisposeAfterUse::NO), loop ? 0 : 1); if (!_audioSource) _file.close(); } @@ -81,7 +81,7 @@ bool MusicHandle::play(const char *fileBase, bool loop) { if (!_audioSource) { sprintf(fileName, "%s.ogg", fileBase); if (_file.open(fileName)) { - _audioSource = Audio::makeLoopingAudioStream(Audio::makeVorbisStream(&_file, false), loop ? 0 : 1); + _audioSource = Audio::makeLoopingAudioStream(Audio::makeVorbisStream(&_file, DisposeAfterUse::NO), loop ? 0 : 1); if (!_audioSource) _file.close(); } @@ -91,7 +91,7 @@ bool MusicHandle::play(const char *fileBase, bool loop) { if (!_audioSource) { sprintf(fileName, "%s.mp3", fileBase); if (_file.open(fileName)) { - _audioSource = Audio::makeLoopingAudioStream(Audio::makeMP3Stream(&_file, false), loop ? 0 : 1); + _audioSource = Audio::makeLoopingAudioStream(Audio::makeMP3Stream(&_file, DisposeAfterUse::NO), loop ? 0 : 1); if (!_audioSource) _file.close(); } @@ -100,7 +100,7 @@ bool MusicHandle::play(const char *fileBase, bool loop) { if (!_audioSource) { sprintf(fileName, "%s.wav", fileBase); if (_file.open(fileName)) - _audioSource = Audio::makeLoopingAudioStream(Audio::makeWAVStream(&_file, false), loop ? 0 : 1); + _audioSource = Audio::makeLoopingAudioStream(Audio::makeWAVStream(&_file, DisposeAfterUse::NO), loop ? 0 : 1); } if (!_audioSource) { diff --git a/engines/sword1/sound.cpp b/engines/sword1/sound.cpp index 98b87d56ea..b3671791a1 100644 --- a/engines/sword1/sound.cpp +++ b/engines/sword1/sound.cpp @@ -371,7 +371,7 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) { _cowFile.seek(index); Common::MemoryReadStream *tmp = _cowFile.readStream(sampleSize); assert(tmp); - _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeFlacStream(tmp, true), SOUND_SPEECH_ID, speechVol, speechPan); + _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeFlacStream(tmp, DisposeAfterUse::YES), SOUND_SPEECH_ID, speechVol, speechPan); // with compressed audio, we can't calculate the wave volume. // so default to talking. for (int cnt = 0; cnt < 480; cnt++) @@ -384,7 +384,7 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) { _cowFile.seek(index); Common::MemoryReadStream *tmp = _cowFile.readStream(sampleSize); assert(tmp); - _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeVorbisStream(tmp, true), SOUND_SPEECH_ID, speechVol, speechPan); + _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeVorbisStream(tmp, DisposeAfterUse::YES), SOUND_SPEECH_ID, speechVol, speechPan); // with compressed audio, we can't calculate the wave volume. // so default to talking. for (int cnt = 0; cnt < 480; cnt++) @@ -397,7 +397,7 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) { _cowFile.seek(index); Common::MemoryReadStream *tmp = _cowFile.readStream(sampleSize); assert(tmp); - _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeMP3Stream(tmp, true), SOUND_SPEECH_ID, speechVol, speechPan); + _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeMP3Stream(tmp, DisposeAfterUse::YES), SOUND_SPEECH_ID, speechVol, speechPan); // with compressed audio, we can't calculate the wave volume. // so default to talking. for (int cnt = 0; cnt < 480; cnt++) diff --git a/engines/sword2/music.cpp b/engines/sword2/music.cpp index 67d04c870d..e5936bb958 100644 --- a/engines/sword2/music.cpp +++ b/engines/sword2/music.cpp @@ -199,17 +199,17 @@ static Audio::AudioStream *getAudioStream(SoundFileHandle *fh, const char *base, #ifdef USE_MAD case kMP3Mode: tmp = new SafeSubReadStream(&fh->file, pos, pos + enc_len); - return Audio::makeMP3Stream(tmp, true); + return Audio::makeMP3Stream(tmp, DisposeAfterUse::YES); #endif #ifdef USE_VORBIS case kVorbisMode: tmp = new SafeSubReadStream(&fh->file, pos, pos + enc_len); - return Audio::makeVorbisStream(tmp, true); + return Audio::makeVorbisStream(tmp, DisposeAfterUse::YES); #endif #ifdef USE_FLAC case kFlacMode: tmp = new SafeSubReadStream(&fh->file, pos, pos + enc_len); - return Audio::makeFlacStream(tmp, true); + return Audio::makeFlacStream(tmp, DisposeAfterUse::YES); #endif default: return NULL; diff --git a/engines/sword2/sound.cpp b/engines/sword2/sound.cpp index 224bc66a95..2d02a2d3ba 100644 --- a/engines/sword2/sound.cpp +++ b/engines/sword2/sound.cpp @@ -336,7 +336,7 @@ int32 Sound::playFx(Audio::SoundHandle *handle, byte *data, uint32 len, uint8 vo if (Sword2Engine::isPsx()) input = new Audio::VagStream(stream); else - input = Audio::makeWAVStream(stream, true); + input = Audio::makeWAVStream(stream, DisposeAfterUse::YES); assert(input); diff --git a/engines/tinsel/sound.cpp b/engines/tinsel/sound.cpp index 9921d0edfa..8f6dd762ba 100644 --- a/engines/tinsel/sound.cpp +++ b/engines/tinsel/sound.cpp @@ -139,17 +139,17 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound switch (_soundMode) { case kMP3Mode: #ifdef USE_MAD - sampleStream = Audio::makeMP3Stream(compressedStream, true); + sampleStream = Audio::makeMP3Stream(compressedStream, DisposeAfterUse::YES); #endif break; case kVorbisMode: #ifdef USE_VORBIS - sampleStream = Audio::makeVorbisStream(compressedStream, true); + sampleStream = Audio::makeVorbisStream(compressedStream, DisposeAfterUse::YES); #endif break; case kFlacMode: #ifdef USE_FLAC - sampleStream = Audio::makeFlacStream(compressedStream, true); + sampleStream = Audio::makeFlacStream(compressedStream, DisposeAfterUse::YES); #endif break; default: @@ -289,21 +289,21 @@ bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int p switch (_soundMode) { case kMP3Mode: #ifdef USE_MAD - sampleStream = Audio::makeMP3Stream(compressedStream, true); + sampleStream = Audio::makeMP3Stream(compressedStream, DisposeAfterUse::YES); #endif break; case kVorbisMode: #ifdef USE_VORBIS - sampleStream = Audio::makeVorbisStream(compressedStream, true); + sampleStream = Audio::makeVorbisStream(compressedStream, DisposeAfterUse::YES); #endif break; case kFlacMode: #ifdef USE_FLAC - sampleStream = Audio::makeFlacStream(compressedStream, true); + sampleStream = Audio::makeFlacStream(compressedStream, DisposeAfterUse::YES); #endif break; default: - sampleStream = Audio::makeADPCMStream(compressedStream, true, sampleLen, Audio::kADPCMTinsel6, 22050, 1, 24); + sampleStream = Audio::makeADPCMStream(compressedStream, DisposeAfterUse::YES, sampleLen, Audio::kADPCMTinsel6, 22050, 1, 24); break; } diff --git a/engines/touche/resource.cpp b/engines/touche/resource.cpp index 55aab42ff4..1a9889c307 100644 --- a/engines/touche/resource.cpp +++ b/engines/touche/resource.cpp @@ -47,7 +47,7 @@ struct CompressedSpeechFile { const char *filename; Audio::SeekableAudioStream *(*makeStream)( Common::SeekableReadStream *stream, - bool disposeAfterUse); + DisposeAfterUse::Flag disposeAfterUse); }; static const CompressedSpeechFile compressedSpeechFilesTable[] = { @@ -667,7 +667,7 @@ void ToucheEngine::res_loadSpeechSegment(int num) { _fSpeech[0].seek(offs); Common::MemoryReadStream *tmp = _fSpeech[0].readStream(size); if (tmp) - stream = (compressedSpeechFilesTable[_compressedSpeechData].makeStream)(tmp, true); + stream = (compressedSpeechFilesTable[_compressedSpeechData].makeStream)(tmp, DisposeAfterUse::YES); } if (stream) { _speechPlaying = true; diff --git a/engines/tucker/resource.cpp b/engines/tucker/resource.cpp index 6c244d070a..e1bca03724 100644 --- a/engines/tucker/resource.cpp +++ b/engines/tucker/resource.cpp @@ -43,7 +43,7 @@ enum { struct CompressedSoundFile { const char *filename; - Audio::SeekableAudioStream *(*makeStream)(Common::SeekableReadStream *stream, bool disposeAfterUse); + Audio::SeekableAudioStream *(*makeStream)(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse); }; static const CompressedSoundFile compressedSoundFilesTable[] = { @@ -270,7 +270,7 @@ Audio::RewindableAudioStream *CompressedSound::load(CompressedSoundType type, in _fCompressedSound.seek(dirOffset + dirSize * 8 + soundOffset); Common::MemoryReadStream *tmp = _fCompressedSound.readStream(soundSize); if (tmp) { - stream = (compressedSoundFilesTable[_compressedSoundType].makeStream)(tmp, true); + stream = (compressedSoundFilesTable[_compressedSoundType].makeStream)(tmp, DisposeAfterUse::YES); } } } @@ -946,7 +946,7 @@ void TuckerEngine::loadSound(Audio::Mixer::SoundType type, int num, int volume, snprintf(fileName, sizeof(fileName), fmt, num); Common::File *f = new Common::File; if (f->open(fileName)) { - stream = Audio::makeWAVStream(f, true); + stream = Audio::makeWAVStream(f, DisposeAfterUse::YES); } else { delete f; } diff --git a/engines/tucker/sequences.cpp b/engines/tucker/sequences.cpp index 204913addf..cd3423d8c2 100644 --- a/engines/tucker/sequences.cpp +++ b/engines/tucker/sequences.cpp @@ -603,7 +603,7 @@ Audio::RewindableAudioStream *AnimationSequencePlayer::loadSound(int index, Anim } break; case kAnimationSoundTypeWAV: - stream = Audio::makeWAVStream(&f, false); + stream = Audio::makeWAVStream(&f, DisposeAfterUse::NO); break; } diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index 168ca49e2d..d8d2533bc7 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -55,7 +55,7 @@ struct StreamFileFormat { * Pointer to a function which tries to open a file of type StreamFormat. * Return NULL in case of an error (invalid/nonexisting file). */ - SeekableAudioStream *(*openStreamFile)(Common::SeekableReadStream *stream, bool disposeAfterUse); + SeekableAudioStream *(*openStreamFile)(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse); }; static const StreamFileFormat STREAM_FILEFORMATS[] = { @@ -83,7 +83,7 @@ SeekableAudioStream *SeekableAudioStream::openStreamFile(const Common::String &b fileHandle->open(filename); if (fileHandle->isOpen()) { // Create the stream object - stream = STREAM_FILEFORMATS[i].openStreamFile(fileHandle, true); + stream = STREAM_FILEFORMATS[i].openStreamFile(fileHandle, DisposeAfterUse::YES); fileHandle = 0; break; } @@ -102,12 +102,12 @@ SeekableAudioStream *SeekableAudioStream::openStreamFile(const Common::String &b #pragma mark --- LoopingAudioStream --- #pragma mark - -LoopingAudioStream::LoopingAudioStream(RewindableAudioStream *stream, uint loops, bool disposeAfterUse) +LoopingAudioStream::LoopingAudioStream(RewindableAudioStream *stream, uint loops, DisposeAfterUse::Flag disposeAfterUse) : _parent(stream), _disposeAfterUse(disposeAfterUse), _loops(loops), _completeIterations(0) { } LoopingAudioStream::~LoopingAudioStream() { - if (_disposeAfterUse) + if (_disposeAfterUse == DisposeAfterUse::YES) delete _parent; } @@ -169,7 +169,7 @@ SubLoopingAudioStream::SubLoopingAudioStream(SeekableAudioStream *stream, uint loops, const Timestamp loopStart, const Timestamp loopEnd, - bool disposeAfterUse) + DisposeAfterUse::Flag disposeAfterUse) : _parent(stream), _disposeAfterUse(disposeAfterUse), _loops(loops), _pos(0, getRate() * (isStereo() ? 2 : 1)), _loopStart(loopStart.convertToFramerate(getRate() * (isStereo() ? 2 : 1))), @@ -180,7 +180,7 @@ SubLoopingAudioStream::SubLoopingAudioStream(SeekableAudioStream *stream, } SubLoopingAudioStream::~SubLoopingAudioStream() { - if (_disposeAfterUse) + if (_disposeAfterUse == DisposeAfterUse::YES) delete _parent; } @@ -218,7 +218,7 @@ int SubLoopingAudioStream::readBuffer(int16 *buffer, const int numSamples) { #pragma mark --- SubSeekableAudioStream --- #pragma mark - -SubSeekableAudioStream::SubSeekableAudioStream(SeekableAudioStream *parent, const Timestamp start, const Timestamp end, bool disposeAfterUse) +SubSeekableAudioStream::SubSeekableAudioStream(SeekableAudioStream *parent, const Timestamp start, const Timestamp end, DisposeAfterUse::Flag disposeAfterUse) : _parent(parent), _disposeAfterUse(disposeAfterUse), _start(start.convertToFramerate(getRate())), _pos(0, getRate() * (isStereo() ? 2 : 1)), @@ -279,18 +279,18 @@ protected: const byte *_end; const int _rate; const byte *_origPtr; - const bool _disposeAfterUse; + const DisposeAfterUse::Flag _disposeAfterUse; const Timestamp _playtime; public: - LinearMemoryStream(int rate, const byte *ptr, uint len, bool autoFreeMemory) + LinearMemoryStream(int rate, const byte *ptr, uint len, DisposeAfterUse::Flag autoFreeMemory) : _ptr(ptr), _end(ptr+len), _rate(rate), _origPtr(ptr), _disposeAfterUse(autoFreeMemory), _playtime(0, len / (is16Bit ? 2 : 1) / (stereo ? 2 : 1), rate) { } virtual ~LinearMemoryStream() { - if (_disposeAfterUse) + if (_disposeAfterUse == DisposeAfterUse::YES) free(const_cast<byte *>(_origPtr)); } @@ -364,13 +364,13 @@ protected: int32 _filePos; ///< Current position in stream int32 _diskLeft; ///< Samples left in stream in current block not yet read to buffer int32 _bufferLeft; ///< Samples left in buffer in current block - bool _disposeAfterUse; ///< If true, delete stream object when LinearDiskStream is destructed + const DisposeAfterUse::Flag _disposeAfterUse; ///< Indicates whether the stream object should be deleted when this LinearDiskStream is destructed LinearDiskStreamAudioBlock *_audioBlock; ///< Audio block list - int _audioBlockCount; ///< Number of blocks in _audioBlock + const int _audioBlockCount; ///< Number of blocks in _audioBlock int _currentBlock; ///< Current audio block number public: - LinearDiskStream(int rate, bool disposeStream, Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, uint numBlocks) + LinearDiskStream(int rate, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, uint numBlocks) : _rate(rate), _playtime(0, rate), _stream(stream), _disposeAfterUse(disposeStream), _audioBlockCount(numBlocks) { @@ -407,7 +407,7 @@ public: virtual ~LinearDiskStream() { - if (_disposeAfterUse) { + if (_disposeAfterUse == DisposeAfterUse::YES) { delete _stream; } @@ -543,7 +543,7 @@ SeekableAudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate const bool is16Bit = (flags & Mixer::FLAG_16BITS) != 0; const bool isUnsigned = (flags & Mixer::FLAG_UNSIGNED) != 0; const bool isLE = (flags & Mixer::FLAG_LITTLE_ENDIAN) != 0; - const bool autoFree = (flags & Mixer::FLAG_AUTOFREE) != 0; + const DisposeAfterUse::Flag autoFree = (flags & Mixer::FLAG_AUTOFREE) != 0 ? DisposeAfterUse::YES : DisposeAfterUse::NO; // Verify the buffer sizes are sane if (is16Bit && isStereo) { @@ -605,14 +605,15 @@ AudioStream *makeLinearInputStream(const byte *ptr, uint32 len, int rate, #define MAKE_LINEAR_DISK(STEREO, UNSIGNED) \ if (is16Bit) { \ if (isLE) \ - return new LinearDiskStream<STEREO, true, UNSIGNED, true>(rate, takeOwnership, stream, block, numBlocks); \ + return new LinearDiskStream<STEREO, true, UNSIGNED, true>(rate, disposeStream, stream, block, numBlocks); \ else \ - return new LinearDiskStream<STEREO, true, UNSIGNED, false>(rate, takeOwnership, stream, block, numBlocks); \ + return new LinearDiskStream<STEREO, true, UNSIGNED, false>(rate, disposeStream, stream, block, numBlocks); \ } else \ - return new LinearDiskStream<STEREO, false, UNSIGNED, false>(rate, takeOwnership, stream, block, numBlocks) + return new LinearDiskStream<STEREO, false, UNSIGNED, false>(rate, disposeStream, stream, block, numBlocks) -SeekableAudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, int numBlocks, int rate, byte flags, bool takeOwnership) { +SeekableAudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, int numBlocks, + int rate, byte flags, DisposeAfterUse::Flag disposeStream) { const bool isStereo = (flags & Mixer::FLAG_STEREO) != 0; const bool is16Bit = (flags & Mixer::FLAG_16BITS) != 0; const bool isUnsigned = (flags & Mixer::FLAG_UNSIGNED) != 0; @@ -634,7 +635,7 @@ SeekableAudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, Li } AudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, - int numBlocks, int rate, byte flags, bool disposeStream, uint loopStart, uint loopEnd) { + int numBlocks, int rate, byte flags, DisposeAfterUse::Flag disposeStream, uint loopStart, uint loopEnd) { SeekableAudioStream *s = makeLinearDiskStream(stream, block, numBlocks, rate, flags, disposeStream); const bool isStereo = (flags & Mixer::FLAG_STEREO) != 0; @@ -683,8 +684,8 @@ private: */ struct StreamHolder { AudioStream *_stream; - bool _disposeAfterUse; - StreamHolder(AudioStream *stream, bool disposeAfterUse) + DisposeAfterUse::Flag _disposeAfterUse; + StreamHolder(AudioStream *stream, DisposeAfterUse::Flag disposeAfterUse) : _stream(stream), _disposeAfterUse(disposeAfterUse) {} }; @@ -731,7 +732,7 @@ public: virtual bool endOfStream() const { return _finished && _queue.empty(); } // Implement the QueuingAudioStream API - virtual void queueAudioStream(AudioStream *stream, bool disposeAfterUse); + virtual void queueAudioStream(AudioStream *stream, DisposeAfterUse::Flag disposeAfterUse); virtual void finish() { _finished = true; } uint32 numQueuedStreams() const { @@ -743,12 +744,12 @@ public: QueuingAudioStreamImpl::~QueuingAudioStreamImpl() { while (!_queue.empty()) { StreamHolder tmp = _queue.pop(); - if (tmp._disposeAfterUse) + if (tmp._disposeAfterUse == DisposeAfterUse::YES) delete tmp._stream; } } -void QueuingAudioStreamImpl::queueAudioStream(AudioStream *stream, bool disposeAfterUse) { +void QueuingAudioStreamImpl::queueAudioStream(AudioStream *stream, DisposeAfterUse::Flag disposeAfterUse) { if ((stream->getRate() != getRate()) || (stream->isStereo() != isStereo())) error("QueuingAudioStreamImpl::queueAudioStream: stream has mismatched parameters"); @@ -766,7 +767,7 @@ int QueuingAudioStreamImpl::readBuffer(int16 *buffer, const int numSamples) { if (stream->endOfData() ) { StreamHolder tmp = _queue.pop(); - if (tmp._disposeAfterUse) + if (tmp._disposeAfterUse == DisposeAfterUse::YES) delete stream; } } diff --git a/sound/audiostream.h b/sound/audiostream.h index 83bada8740..4174fe017d 100644 --- a/sound/audiostream.h +++ b/sound/audiostream.h @@ -29,6 +29,7 @@ #include "common/util.h" #include "common/scummsys.h" #include "common/stream.h" +#include "common/types.h" #include "sound/timestamp.h" @@ -115,7 +116,7 @@ public: * @param loops How often to loop (0 = infinite) * @param disposeAfteruse Destroy the stream after the LoopingAudioStream has finished playback. */ - LoopingAudioStream(RewindableAudioStream *stream, uint loops, bool disposeAfterUse = true); + LoopingAudioStream(RewindableAudioStream *stream, uint loops, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); ~LoopingAudioStream(); int readBuffer(int16 *buffer, const int numSamples); @@ -131,7 +132,7 @@ public: uint getCompleteIterations() const { return _completeIterations; } private: RewindableAudioStream *_parent; - bool _disposeAfterUse; + DisposeAfterUse::Flag _disposeAfterUse; uint _loops; uint _completeIterations; @@ -232,7 +233,7 @@ public: SubLoopingAudioStream(SeekableAudioStream *stream, uint loops, const Timestamp loopStart, const Timestamp loopEnd, - bool disposeAfterUse = true); + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); ~SubLoopingAudioStream(); int readBuffer(int16 *buffer, const int numSamples); @@ -242,7 +243,7 @@ public: int getRate() const { return _parent->getRate(); } private: SeekableAudioStream *_parent; - bool _disposeAfterUse; + DisposeAfterUse::Flag _disposeAfterUse; uint _loops; Timestamp _pos; @@ -271,9 +272,9 @@ public: * @param parent parent stream object. * @param start Start time. * @param end End time. - * @param disposeAfterUse Whether the parent stream object should be destroied on desctruction of the SubSeekableAudioStream. + * @param disposeAfterUse Whether the parent stream object should be destroyed on destruction of the SubSeekableAudioStream. */ - SubSeekableAudioStream(SeekableAudioStream *parent, const Timestamp start, const Timestamp end, bool disposeAfterUse = true); + SubSeekableAudioStream(SeekableAudioStream *parent, const Timestamp start, const Timestamp end, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); ~SubSeekableAudioStream(); int readBuffer(int16 *buffer, const int numSamples); @@ -289,7 +290,7 @@ public: Timestamp getLength() const { return _length; } private: SeekableAudioStream *_parent; - bool _disposeAfterUse; + DisposeAfterUse::Flag _disposeAfterUse; const Timestamp _start; const Timestamp _length; @@ -342,11 +343,11 @@ struct LinearDiskStreamAudioBlock { * @param len Length of the data (in bytes!) * @param flags Flags combination. * @see Mixer::RawFlags - * @param disposeStream Wheter the "stream" object should be destroyed after playback. + * @param disposeStream Whether the "stream" object should be destroyed after playback. * @return The new SeekableAudioStream (or 0 on failure). */ SeekableAudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, - int numBlocks, int rate, byte flags, bool disposeStream); + int numBlocks, int rate, byte flags, DisposeAfterUse::Flag disposeStream); /** * NOTE: @@ -358,7 +359,7 @@ SeekableAudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, Li * each block of uncompressed audio in the stream. */ AudioStream *makeLinearDiskStream(Common::SeekableReadStream *stream, LinearDiskStreamAudioBlock *block, - int numBlocks, int rate, byte flags, bool disposeStream, uint loopStart, uint loopEnd); + int numBlocks, int rate, byte flags, DisposeAfterUse::Flag disposeStream, uint loopStart, uint loopEnd); class QueuingAudioStream : public Audio::AudioStream { public: @@ -370,7 +371,7 @@ public: * deleted after all data contained in it has been played. */ virtual void queueAudioStream(Audio::AudioStream *audStream, - bool disposeAfterUse = true) = 0; + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES) = 0; /** * Queue a block of raw audio data for playback. This stream @@ -381,7 +382,7 @@ public: */ void queueBuffer(byte *data, uint32 size, byte flags) { AudioStream *stream = makeLinearInputStream(data, size, getRate(), flags, 0, 0); - queueAudioStream(stream, true); + queueAudioStream(stream, DisposeAfterUse::YES); } /** diff --git a/sound/flac.cpp b/sound/flac.cpp index 1c7f03b9d1..eb195e0c7b 100644 --- a/sound/flac.cpp +++ b/sound/flac.cpp @@ -726,7 +726,7 @@ void FlacInputStream::callWrapError(const ::FLAC__SeekableStreamDecoder *decoder SeekableAudioStream *makeFlacStream( Common::SeekableReadStream *stream, - bool disposeAfterUse) { + DisposeAfterUse::Flag disposeAfterUse) { return new FlacInputStream(stream, disposeAfterUse); } diff --git a/sound/flac.h b/sound/flac.h index 7c891d41d8..e35b608253 100644 --- a/sound/flac.h +++ b/sound/flac.h @@ -41,6 +41,7 @@ #ifndef SOUND_FLAC_H #define SOUND_FLAC_H +#include "common/types.h" #include "common/scummsys.h" #ifdef USE_FLAC @@ -64,7 +65,7 @@ class SeekableAudioStream; */ SeekableAudioStream *makeFlacStream( Common::SeekableReadStream *stream, - bool disposeAfterUse); + DisposeAfterUse::Flag disposeAfterUse); } // End of namespace Audio diff --git a/sound/mp3.cpp b/sound/mp3.cpp index 98144621c8..26f0e6d320 100644 --- a/sound/mp3.cpp +++ b/sound/mp3.cpp @@ -54,7 +54,7 @@ protected: }; Common::SeekableReadStream *_inStream; - bool _disposeAfterUse; + DisposeAfterUse::Flag _disposeAfterUse; uint _posInFrame; State _state; @@ -75,7 +75,7 @@ protected: public: MP3InputStream(Common::SeekableReadStream *inStream, - bool dispose); + DisposeAfterUse::Flag dispose); ~MP3InputStream(); int readBuffer(int16 *buffer, const int numSamples); @@ -95,7 +95,7 @@ protected: void deinitStream(); }; -MP3InputStream::MP3InputStream(Common::SeekableReadStream *inStream, bool dispose) : +MP3InputStream::MP3InputStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose) : _inStream(inStream), _disposeAfterUse(dispose), _posInFrame(0), @@ -129,7 +129,7 @@ MP3InputStream::MP3InputStream(Common::SeekableReadStream *inStream, bool dispos MP3InputStream::~MP3InputStream() { deinitStream(); - if (_disposeAfterUse) + if (_disposeAfterUse == DisposeAfterUse::YES) delete _inStream; } @@ -340,7 +340,7 @@ int MP3InputStream::readBuffer(int16 *buffer, const int numSamples) { SeekableAudioStream *makeMP3Stream( Common::SeekableReadStream *stream, - bool disposeAfterUse) { + DisposeAfterUse::Flag disposeAfterUse) { return new MP3InputStream(stream, disposeAfterUse); } diff --git a/sound/mp3.h b/sound/mp3.h index ca5a65ee00..3175df5e92 100644 --- a/sound/mp3.h +++ b/sound/mp3.h @@ -41,6 +41,7 @@ #ifndef SOUND_MP3_H #define SOUND_MP3_H +#include "common/types.h" #include "common/scummsys.h" #ifdef USE_MAD @@ -64,7 +65,7 @@ class SeekableAudioStream; */ SeekableAudioStream *makeMP3Stream( Common::SeekableReadStream *stream, - bool disposeAfterUse); + DisposeAfterUse::Flag disposeAfterUse); } // End of namespace Audio diff --git a/sound/voc.cpp b/sound/voc.cpp index 79a64769f7..9247d5276e 100644 --- a/sound/voc.cpp +++ b/sound/voc.cpp @@ -298,7 +298,7 @@ int parseVOCFormat(Common::SeekableReadStream& stream, LinearDiskStreamAudioBloc return currentBlock; } -AudioStream *makeVOCDiskStream(Common::SeekableReadStream &stream, byte flags, bool takeOwnership) { +AudioStream *makeVOCDiskStream(Common::SeekableReadStream &stream, byte flags, DisposeAfterUse::Flag takeOwnership) { const int MAX_AUDIO_BLOCKS = 256; LinearDiskStreamAudioBlock *block = new LinearDiskStreamAudioBlock[MAX_AUDIO_BLOCKS]; @@ -318,7 +318,7 @@ AudioStream *makeVOCDiskStream(Common::SeekableReadStream &stream, byte flags, b return audioStream; } -SeekableAudioStream *makeVOCDiskStreamNoLoop(Common::SeekableReadStream &stream, byte flags, bool takeOwnership) { +SeekableAudioStream *makeVOCDiskStreamNoLoop(Common::SeekableReadStream &stream, byte flags, DisposeAfterUse::Flag takeOwnership) { const int MAX_AUDIO_BLOCKS = 256; LinearDiskStreamAudioBlock *block = new LinearDiskStreamAudioBlock[MAX_AUDIO_BLOCKS]; @@ -341,7 +341,7 @@ SeekableAudioStream *makeVOCDiskStreamNoLoop(Common::SeekableReadStream &stream, #endif -AudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, uint loopStart, uint loopEnd, bool takeOwnershipOfStream) { +AudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, uint loopStart, uint loopEnd, DisposeAfterUse::Flag takeOwnershipOfStream) { #ifdef STREAM_AUDIO_FROM_DISK return makeVOCDiskStream(stream, flags, takeOwnershipOfStream); #else @@ -356,7 +356,7 @@ AudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, uint #endif } -SeekableAudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, bool takeOwnershipOfStream) { +SeekableAudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, DisposeAfterUse::Flag takeOwnershipOfStream) { #ifdef STREAM_AUDIO_FROM_DISK return makeVOCDiskStreamNoLoop(stream, flags, takeOwnershipOfStream); #else diff --git a/sound/voc.h b/sound/voc.h index 6008d3a7d7..191f42db02 100644 --- a/sound/voc.h +++ b/sound/voc.h @@ -38,6 +38,7 @@ #ifndef SOUND_VOC_H #define SOUND_VOC_H +#include "common/types.h" #include "common/scummsys.h" namespace Common { class ReadStream; } @@ -94,12 +95,12 @@ extern byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate) * * This function uses loadVOCFromStream() internally. */ -AudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags = 0, uint loopStart = 0, uint loopEnd = 0, bool takeOwnershipOfStream = false); +AudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags = 0, uint loopStart = 0, uint loopEnd = 0, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::NO); /** * This does not use any of the looping features of VOC files! */ -SeekableAudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, bool takeOwnershipOfStream); +SeekableAudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, DisposeAfterUse::Flag disposeAfterUse); } // End of namespace Audio diff --git a/sound/vorbis.cpp b/sound/vorbis.cpp index ed1ccf1346..4ce2f2c3f7 100644 --- a/sound/vorbis.cpp +++ b/sound/vorbis.cpp @@ -88,7 +88,7 @@ static ov_callbacks g_stream_wrap = { class VorbisInputStream : public SeekableAudioStream { protected: Common::SeekableReadStream *_inStream; - bool _disposeAfterUse; + DisposeAfterUse::Flag _disposeAfterUse; bool _isStereo; int _rate; @@ -103,7 +103,7 @@ protected: public: // startTime / duration are in milliseconds - VorbisInputStream(Common::SeekableReadStream *inStream, bool dispose); + VorbisInputStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose); ~VorbisInputStream(); int readBuffer(int16 *buffer, const int numSamples); @@ -118,7 +118,7 @@ protected: bool refill(); }; -VorbisInputStream::VorbisInputStream(Common::SeekableReadStream *inStream, bool dispose) : +VorbisInputStream::VorbisInputStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose) : _inStream(inStream), _disposeAfterUse(dispose), _length(0, 1000), @@ -148,7 +148,7 @@ VorbisInputStream::VorbisInputStream(Common::SeekableReadStream *inStream, bool VorbisInputStream::~VorbisInputStream() { ov_clear(&_ovFile); - if (_disposeAfterUse) + if (_disposeAfterUse == DisposeAfterUse::YES) delete _inStream; } @@ -241,7 +241,7 @@ bool VorbisInputStream::refill() { SeekableAudioStream *makeVorbisStream( Common::SeekableReadStream *stream, - bool disposeAfterUse) { + DisposeAfterUse::Flag disposeAfterUse) { return new VorbisInputStream(stream, disposeAfterUse); } diff --git a/sound/vorbis.h b/sound/vorbis.h index 9e49eead55..dd0a89bfdd 100644 --- a/sound/vorbis.h +++ b/sound/vorbis.h @@ -41,6 +41,7 @@ #ifndef SOUND_VORBIS_H #define SOUND_VORBIS_H +#include "common/types.h" #include "common/scummsys.h" #ifdef USE_VORBIS @@ -64,7 +65,7 @@ class SeekableAudioStream; */ SeekableAudioStream *makeVorbisStream( Common::SeekableReadStream *stream, - bool disposeAfterUse); + DisposeAfterUse::Flag disposeAfterUse); } // End of namespace Audio diff --git a/sound/wave.cpp b/sound/wave.cpp index e1a466393f..83a880dada 100644 --- a/sound/wave.cpp +++ b/sound/wave.cpp @@ -161,14 +161,14 @@ bool loadWAVFromStream(Common::SeekableReadStream &stream, int &size, int &rate, return true; } -RewindableAudioStream *makeWAVStream(Common::SeekableReadStream *stream, bool disposeAfterUse) { +RewindableAudioStream *makeWAVStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse) { int size, rate; byte flags; uint16 type; int blockAlign; if (!loadWAVFromStream(*stream, size, rate, flags, &type, &blockAlign)) { - if (disposeAfterUse) + if (disposeAfterUse == DisposeAfterUse::YES) delete stream; return 0; } @@ -184,7 +184,7 @@ RewindableAudioStream *makeWAVStream(Common::SeekableReadStream *stream, bool di assert(data); stream->read(data, size); - if (disposeAfterUse) + if (disposeAfterUse == DisposeAfterUse::YES) delete stream; // Since we allocated our own buffer for the data, we must set the autofree flag. diff --git a/sound/wave.h b/sound/wave.h index 542c38a31d..f0e3bb249b 100644 --- a/sound/wave.h +++ b/sound/wave.h @@ -38,6 +38,7 @@ #ifndef SOUND_WAVE_H #define SOUND_WAVE_H +#include "common/types.h" #include "common/scummsys.h" namespace Common { class SeekableReadStream; } @@ -74,7 +75,7 @@ extern bool loadWAVFromStream( */ RewindableAudioStream *makeWAVStream( Common::SeekableReadStream *stream, - bool disposeAfterUse = false); + DisposeAfterUse::Flag disposeAfterUse); } // End of namespace Audio |