[Scummvm-cvs-logs] scummvm master -> 481a5e0e7c65674728eb31694a787723166a72ae
clone2727
clone2727 at gmail.com
Thu Aug 25 16:18:16 CEST 2011
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
37a401a172 AUDIO: Properly handle XA flags
481a5e0e7c SWORD1: Let the XA audio use its own looping
Commit: 37a401a17295d10f0e5fb104330fc5f21d125362
https://github.com/scummvm/scummvm/commit/37a401a17295d10f0e5fb104330fc5f21d125362
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-08-25T07:14:17-07:00
Commit Message:
AUDIO: Properly handle XA flags
Changed paths:
audio/decoders/xa.cpp
diff --git a/audio/decoders/xa.cpp b/audio/decoders/xa.cpp
index 9871775..9b4f27f 100644
--- a/audio/decoders/xa.cpp
+++ b/audio/decoders/xa.cpp
@@ -46,6 +46,7 @@ private:
byte _samplesRemaining;
int _rate;
double _s1, _s2;
+ uint _loopPoint;
};
XAStream::XAStream(Common::SeekableReadStream *stream, int rate, DisposeAfterUse::Flag disposeAfterUse)
@@ -54,6 +55,7 @@ XAStream::XAStream(Common::SeekableReadStream *stream, int rate, DisposeAfterUse
_predictor = 0;
_s1 = _s2 = 0.0;
_rate = rate;
+ _loopPoint = 0;
}
@@ -103,8 +105,20 @@ int XAStream::readBuffer(int16 *buffer, const int numSamples) {
byte shift = _predictor & 0xf;
_predictor >>= 4;
- if (_stream->readByte() == 7)
- return samplesDecoded;
+ byte flags = _stream->readByte();
+ if (flags & 0x1) {
+ if (flags == 3) {
+ // Loop
+ rewind();
+ continue;
+ } else {
+ // End of stream
+ return samplesDecoded;
+ }
+ } else if (flags & 0x4) {
+ // Set loop point
+ _loopPoint = _stream->pos() - 2;
+ }
for (i = 0; i < 28; i += 2) {
byte d = _stream->readByte();
@@ -135,7 +149,7 @@ int XAStream::readBuffer(int16 *buffer, const int numSamples) {
}
bool XAStream::rewind() {
- _stream->seek(0);
+ _stream->seek(_loopPoint);
_samplesRemaining = 0;
_predictor = 0;
_s1 = _s2 = 0.0;
Commit: 481a5e0e7c65674728eb31694a787723166a72ae
https://github.com/scummvm/scummvm/commit/481a5e0e7c65674728eb31694a787723166a72ae
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-08-25T07:14:17-07:00
Commit Message:
SWORD1: Let the XA audio use its own looping
Changed paths:
engines/sword1/music.cpp
engines/sword1/music.h
engines/sword1/sound.cpp
diff --git a/engines/sword1/music.cpp b/engines/sword1/music.cpp
index f31faff..c34630a 100644
--- a/engines/sword1/music.cpp
+++ b/engines/sword1/music.cpp
@@ -110,7 +110,7 @@ bool MusicHandle::play(const Common::String &filename, bool loop) {
return true;
}
-bool MusicHandle::playPSX(uint16 id, bool loop) {
+bool MusicHandle::playPSX(uint16 id) {
stop();
if (!_file.isOpen())
@@ -131,7 +131,7 @@ bool MusicHandle::playPSX(uint16 id, bool loop) {
// not over file size
if ((size != 0) && (size != 0xffffffff) && ((int32)(offset + size) <= _file.size())) {
_file.seek(offset, SEEK_SET);
- _audioSource = Audio::makeLoopingAudioStream(Audio::makeXAStream(_file.readStream(size), 11025), loop ? 0 : 1);
+ _audioSource = Audio::makeXAStream(_file.readStream(size), 11025);
fadeUp();
} else {
_audioSource = NULL;
@@ -297,7 +297,7 @@ void Music::startMusic(int32 tuneId, int32 loopFlag) {
the mutex before, to have the soundthread playing normally.
As the corresponding _converter is NULL, the handle will be ignored by the playing thread */
if (SwordEngine::isPsx()) {
- if (_handles[newStream].playPSX(tuneId, loopFlag != 0)) {
+ if (_handles[newStream].playPSX(tuneId)) {
_mutex.lock();
_converter[newStream] = Audio::makeRateConverter(_handles[newStream].getRate(), _mixer->getOutputRate(), _handles[newStream].isStereo(), false);
_mutex.unlock();
diff --git a/engines/sword1/music.h b/engines/sword1/music.h
index 4207019..f136620 100644
--- a/engines/sword1/music.h
+++ b/engines/sword1/music.h
@@ -44,7 +44,7 @@ public:
MusicHandle() : _fading(0), _audioSource(NULL) {}
virtual int readBuffer(int16 *buffer, const int numSamples);
bool play(const Common::String &filename, bool loop);
- bool playPSX(uint16 id, bool loop);
+ bool playPSX(uint16 id);
void stop();
void fadeUp();
void fadeDown();
diff --git a/engines/sword1/sound.cpp b/engines/sword1/sound.cpp
index faa07b1..677a986 100644
--- a/engines/sword1/sound.cpp
+++ b/engines/sword1/sound.cpp
@@ -255,8 +255,9 @@ void Sound::playSample(QueueElement *elem) {
uint8 volume = (volR + volL) / 2;
if (SwordEngine::isPsx()) {
+ // We ignore FX_LOOP as XA has its own looping mechanism
uint32 size = READ_LE_UINT32(sampleData);
- Audio::AudioStream *audStream = Audio::makeLoopingAudioStream(Audio::makeXAStream(new Common::MemoryReadStream(sampleData + 4, size-4), 11025), (_fxList[elem->id].type == FX_LOOP) ? 0 : 1);
+ Audio::AudioStream *audStream = Audio::makeXAStream(new Common::MemoryReadStream(sampleData + 4, size-4), 11025);
_mixer->playStream(Audio::Mixer::kSFXSoundType, &elem->handle, audStream, elem->id, volume, pan);
} else {
uint32 size = READ_LE_UINT32(sampleData + 0x28);
More information about the Scummvm-git-logs
mailing list