[Scummvm-git-logs] scummvm master -> dd906521874740bbf7a712cc58d16f559dfde80f
yuv422
yuv422 at users.noreply.github.com
Thu May 14 14:04:24 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
dd90652187 DRAGONS: Fixed incorrect delete on PSX audio stream.
Commit: dd906521874740bbf7a712cc58d16f559dfde80f
https://github.com/scummvm/scummvm/commit/dd906521874740bbf7a712cc58d16f559dfde80f
Author: Eric Fry (yuv422 at users.noreply.github.com)
Date: 2020-05-14T23:59:34+10:00
Commit Message:
DRAGONS: Fixed incorrect delete on PSX audio stream.
Changed paths:
engines/dragons/sound.cpp
engines/dragons/sound.h
diff --git a/engines/dragons/sound.cpp b/engines/dragons/sound.cpp
index b5c70cf338..67d6508ab7 100644
--- a/engines/dragons/sound.cpp
+++ b/engines/dragons/sound.cpp
@@ -89,18 +89,12 @@ void SoundManager::playSpeech(uint32 textIndex) {
error("Failed to open dtspeech.xa");
}
CdIntToPos_0(speechLocation.sectorStart * 32);
- //TODO move the stream creation logic inside PSXAudioTrack.
- fd->seek(((speechLocation.sectorStart * 32) + speechLocation.startOffset) * RAW_CD_SECTOR_SIZE);
- PSXAudioTrack *_audioTrack = new PSXAudioTrack(fd, Audio::Mixer::kSpeechSoundType);
- for (int i = 0x0; i < speechLocation.sectorEnd - speechLocation.sectorStart; i++) {
- fd->seek(((speechLocation.sectorStart * 32) + speechLocation.startOffset + i * 32) * RAW_CD_SECTOR_SIZE);
- _audioTrack->queueAudioFromSector(fd);
- }
- _audioTrack->getAudioStream()->finish();
+ PSXAudioTrack *_audioTrack = new PSXAudioTrack();
+
+ _vm->setFlags(ENGINE_FLAG_8000);
+ _vm->_mixer->playStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, _audioTrack->createNewAudioStream(fd, speechLocation.sectorStart, speechLocation.startOffset, speechLocation.sectorEnd), -1, _speechVolume);
fd->close();
delete fd;
- _vm->setFlags(ENGINE_FLAG_8000);
- _vm->_mixer->playStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, _audioTrack->getAudioStream(), -1, _speechVolume);
delete _audioTrack;
}
@@ -146,20 +140,10 @@ void SoundManager::PauseCDMusic() {
}
}
-SoundManager::PSXAudioTrack::PSXAudioTrack(Common::SeekableReadStream *sector, Audio::Mixer::SoundType soundType) {
- sector->skip(19);
- byte format = sector->readByte();
- bool stereo = (format & (1 << 0)) != 0;
- uint rate = (format & (1 << 2)) ? 18900 : 37800;
- _audStream = Audio::makeQueuingAudioStream(rate, stereo);
-
+SoundManager::PSXAudioTrack::PSXAudioTrack() {
memset(&_adpcmStatus, 0, sizeof(_adpcmStatus));
}
-SoundManager::PSXAudioTrack::~PSXAudioTrack() {
- delete _audStream;
-}
-
// Ha! It's palindromic!
#define AUDIO_DATA_CHUNK_SIZE 2304
#define AUDIO_DATA_SAMPLE_COUNT 4032
@@ -172,7 +156,7 @@ static const int s_xaTable[5][2] = {
{ 122, -60 }
};
-void SoundManager::PSXAudioTrack::queueAudioFromSector(Common::SeekableReadStream *sector) {
+void SoundManager::PSXAudioTrack::queueAudioFromSector(Audio::QueuingAudioStream *audStream, Common::SeekableReadStream *sector) {
sector->skip(24);
// This XA audio is different (yet similar) from normal XA audio! Watch out!
@@ -183,7 +167,7 @@ void SoundManager::PSXAudioTrack::queueAudioFromSector(Common::SeekableReadStrea
byte *buf = new byte[AUDIO_DATA_CHUNK_SIZE];
sector->read(buf, AUDIO_DATA_CHUNK_SIZE);
- int channels = _audStream->isStereo() ? 2 : 1;
+ int channels = audStream->isStereo() ? 2 : 1;
int16 *dst = new int16[AUDIO_DATA_SAMPLE_COUNT];
int16 *leftChannel = dst;
int16 *rightChannel = dst + 1;
@@ -246,17 +230,33 @@ void SoundManager::PSXAudioTrack::queueAudioFromSector(Common::SeekableReadStrea
int flags = Audio::FLAG_16BITS;
- if (_audStream->isStereo())
+ if (audStream->isStereo())
flags |= Audio::FLAG_STEREO;
#ifdef SCUMM_LITTLE_ENDIAN
flags |= Audio::FLAG_LITTLE_ENDIAN;
#endif
- _audStream->queueBuffer((byte *)dst, AUDIO_DATA_SAMPLE_COUNT * 2, DisposeAfterUse::YES, flags);
+ audStream->queueBuffer((byte *)dst, AUDIO_DATA_SAMPLE_COUNT * 2, DisposeAfterUse::YES, flags);
delete[] buf;
}
+Audio::QueuingAudioStream *SoundManager::PSXAudioTrack::createNewAudioStream(Common::File *fd, uint16 sectorStart, int8 startOffset, uint16 sectorEnd) {
+ fd->seek(((sectorStart * 32) + startOffset) * RAW_CD_SECTOR_SIZE);
+ fd->skip(19);
+ byte format = fd->readByte();
+ bool stereo = (format & (1 << 0)) != 0;
+ uint rate = (format & (1 << 2)) ? 18900 : 37800;
+
+ Audio::QueuingAudioStream *audStream = Audio::makeQueuingAudioStream(rate, stereo);
+ for (int i = 0x0; i < sectorEnd - sectorStart; i++) {
+ fd->seek(((sectorStart * 32) + startOffset + i * 32) * RAW_CD_SECTOR_SIZE);
+ queueAudioFromSector(audStream, fd);
+ }
+ audStream->finish();
+ return audStream;
+}
+
SoundManager::SoundManager(DragonsEngine *vm, BigfileArchive *bigFileArchive, DragonRMS *dragonRMS)
: _vm(vm),
_bigFileArchive(bigFileArchive),
diff --git a/engines/dragons/sound.h b/engines/dragons/sound.h
index f3b581e6bb..fe0bec174a 100644
--- a/engines/dragons/sound.h
+++ b/engines/dragons/sound.h
@@ -100,20 +100,18 @@ private:
private:
class PSXAudioTrack {
- public:
- PSXAudioTrack(Common::SeekableReadStream *sector, Audio::Mixer::SoundType soundType);
- ~PSXAudioTrack();
-
- void queueAudioFromSector(Common::SeekableReadStream *sector);
- Audio::QueuingAudioStream *getAudioStream() {
- return _audStream;
- }
private:
- Audio::QueuingAudioStream *_audStream;
-
struct ADPCMStatus {
int16 sample[2];
} _adpcmStatus[2];
+
+ public:
+ PSXAudioTrack();
+
+ Audio::QueuingAudioStream *createNewAudioStream(Common::File *fd, uint16 sectorStart, int8 startOffset, uint16 sectorEnd);
+
+ private:
+ void queueAudioFromSector(Audio::QueuingAudioStream *audStream, Common::SeekableReadStream *sector);
};
};
More information about the Scummvm-git-logs
mailing list