[Scummvm-git-logs] scummvm master -> b6d9b187d03f45f9dafa8b029c5ddb0cd6ec9a8b
bluegr
bluegr at gmail.com
Thu Apr 1 20:25:47 UTC 2021
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
fed5608e43 AUDIO: Wrap raw streams in SeekableSubReadStream instead of allocating them
054aee03d5 CGE: Make sure to stop playing sounds before freeing resources
b6d9b187d0 CGE2: Make sure to stop playing sounds before freeing resources
Commit: fed5608e439e9e60a454e06fa27246ea5844bf9d
https://github.com/scummvm/scummvm/commit/fed5608e439e9e60a454e06fa27246ea5844bf9d
Author: SupSuper (supsuper at gmail.com)
Date: 2021-04-01T23:25:43+03:00
Commit Message:
AUDIO: Wrap raw streams in SeekableSubReadStream instead of allocating them
Changed paths:
audio/decoders/mac_snd.cpp
audio/decoders/quicktime.cpp
audio/decoders/wave.cpp
diff --git a/audio/decoders/mac_snd.cpp b/audio/decoders/mac_snd.cpp
index 17495ad3f7..75f6bd915a 100644
--- a/audio/decoders/mac_snd.cpp
+++ b/audio/decoders/mac_snd.cpp
@@ -29,6 +29,7 @@
#include "common/textconsole.h"
#include "common/stream.h"
+#include "common/substream.h"
#include "audio/decoders/mac_snd.h"
#include "audio/decoders/raw.h"
@@ -98,15 +99,10 @@ SeekableAudioStream *makeMacSndStream(Common::SeekableReadStream *stream,
stream->skip(soundDataOffset);
- byte *data = (byte *)malloc(size);
- assert(data);
- stream->read(data, size);
-
- if (disposeAfterUse == DisposeAfterUse::YES)
- delete stream;
+ Common::SeekableReadStream *dataStream = new Common::SeekableSubReadStream(stream, stream->pos(), stream->pos() + size, disposeAfterUse);
// Since we allocated our own buffer for the data, we must specify DisposeAfterUse::YES.
- return makeRawStream(data, size, rate, Audio::FLAG_UNSIGNED);
+ return makeRawStream(dataStream, rate, Audio::FLAG_UNSIGNED);
}
} // End of namespace Audio
diff --git a/audio/decoders/quicktime.cpp b/audio/decoders/quicktime.cpp
index 4b0d5e078f..9b045b20ca 100644
--- a/audio/decoders/quicktime.cpp
+++ b/audio/decoders/quicktime.cpp
@@ -638,11 +638,7 @@ AudioStream *QuickTimeAudioDecoder::AudioSampleDesc::createAudioStream(Common::S
flags |= FLAG_STEREO;
if (_bitsPerSample == 16)
flags |= FLAG_16BITS;
- uint32 dataSize = stream->size();
- byte *data = (byte *)malloc(dataSize);
- stream->read(data, dataSize);
- delete stream;
- return makeRawStream(data, dataSize, _sampleRate, flags);
+ return makeRawStream(stream, _sampleRate, flags);
} else if (_codecTag == MKTAG('i', 'm', 'a', '4')) {
// Riven uses this codec (as do some Myst ME videos)
return makeADPCMStream(stream, DisposeAfterUse::YES, stream->size(), kADPCMApple, _sampleRate, _channels, 34);
diff --git a/audio/decoders/wave.cpp b/audio/decoders/wave.cpp
index 7ec42d4237..113ffc7e61 100644
--- a/audio/decoders/wave.cpp
+++ b/audio/decoders/wave.cpp
@@ -23,6 +23,7 @@
#include "common/debug.h"
#include "common/textconsole.h"
#include "common/stream.h"
+#include "common/substream.h"
#include "audio/audiostream.h"
#include "audio/decoders/wave_types.h"
@@ -191,33 +192,35 @@ SeekableAudioStream *makeWAVStream(Common::SeekableReadStream *stream, DisposeAf
delete stream;
return 0;
}
-
- if (type == kWaveFormatMSIMAADPCM) // MS IMA ADPCM
- return makeADPCMStream(stream, disposeAfterUse, size, Audio::kADPCMMSIma, rate, (flags & Audio::FLAG_STEREO) ? 2 : 1, blockAlign);
- else if (type == kWaveFormatMSADPCM) // MS ADPCM
- return makeADPCMStream(stream, disposeAfterUse, size, Audio::kADPCMMS, rate, (flags & Audio::FLAG_STEREO) ? 2 : 1, blockAlign);
- #ifdef USE_MAD
- else if (type == kWaveFormatMP3)
- return makeMP3Stream(stream, disposeAfterUse);
- #endif
+ int channels = (flags & Audio::FLAG_STEREO) ? 2 : 1;
+ int bytesPerSample = (flags & Audio::FLAG_16BITS) ? 2 : 1;
// Raw PCM, make sure the last packet is complete
- uint sampleSize = (flags & Audio::FLAG_16BITS ? 2 : 1) * (flags & Audio::FLAG_STEREO ? 2 : 1);
- if (size % sampleSize != 0) {
- warning("makeWAVStream: Trying to play a WAVE file with an incomplete PCM packet");
- size &= ~(sampleSize - 1);
+ if (type == kWaveFormatPCM) {
+ uint sampleSize = bytesPerSample * channels;
+ if (size % sampleSize != 0) {
+ warning("makeWAVStream: Trying to play a WAVE file with an incomplete PCM packet");
+ size &= ~(sampleSize - 1);
+ }
}
+ Common::SeekableReadStream *dataStream = new Common::SeekableSubReadStream(stream, stream->pos(), stream->pos() + size, disposeAfterUse);
- // Raw PCM. Just read everything at once.
- // TODO: More elegant would be to wrap the stream.
- byte *data = (byte *)malloc(size);
- assert(data);
- stream->read(data, size);
-
- if (disposeAfterUse == DisposeAfterUse::YES)
- delete stream;
+ switch (type) {
+ case kWaveFormatMSIMAADPCM:
+ return makeADPCMStream(dataStream, DisposeAfterUse::YES, 0, Audio::kADPCMMSIma, rate, channels, blockAlign);
+ case kWaveFormatMSADPCM:
+ return makeADPCMStream(dataStream, DisposeAfterUse::YES, 0, Audio::kADPCMMS, rate, channels, blockAlign);
+ #ifdef USE_MAD
+ case kWaveFormatMP3:
+ return makeMP3Stream(dataStream, DisposeAfterUse::YES);
+ #endif
+ case kWaveFormatPCM:
+ return makeRawStream(dataStream, rate, flags);
+ }
- return makeRawStream(data, size, rate, flags);
+ // If the format is unsupported, we already returned earlier, but just in case
+ delete dataStream;
+ return 0;
}
} // End of namespace Audio
Commit: 054aee03d520719cea7f55fa7e88d809afca6a28
https://github.com/scummvm/scummvm/commit/054aee03d520719cea7f55fa7e88d809afca6a28
Author: SupSuper (supsuper at gmail.com)
Date: 2021-04-01T23:25:43+03:00
Commit Message:
CGE: Make sure to stop playing sounds before freeing resources
Changed paths:
engines/cge/sound.cpp
diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp
index af5c128d97..93f628dca6 100644
--- a/engines/cge/sound.cpp
+++ b/engines/cge/sound.cpp
@@ -58,6 +58,7 @@ Sound::~Sound() {
void Sound::close() {
_vm->_midiPlayer->killMidi();
+ _vm->_mixer->stopAll();
}
void Sound::open() {
Commit: b6d9b187d03f45f9dafa8b029c5ddb0cd6ec9a8b
https://github.com/scummvm/scummvm/commit/b6d9b187d03f45f9dafa8b029c5ddb0cd6ec9a8b
Author: SupSuper (supsuper at gmail.com)
Date: 2021-04-01T23:25:43+03:00
Commit Message:
CGE2: Make sure to stop playing sounds before freeing resources
Changed paths:
engines/cge2/sound.cpp
diff --git a/engines/cge2/sound.cpp b/engines/cge2/sound.cpp
index f5fccbc6a6..8e48f7b709 100644
--- a/engines/cge2/sound.cpp
+++ b/engines/cge2/sound.cpp
@@ -56,6 +56,7 @@ Sound::~Sound() {
void Sound::close() {
_vm->_midiPlayer->killMidi();
+ _vm->_mixer->stopAll();
}
void Sound::open() {
More information about the Scummvm-git-logs
mailing list