Skip to content

Commit

Permalink
SWORD1: Let the XA audio use its own looping
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hoops committed Aug 25, 2011
1 parent 37a401a commit 481a5e0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions engines/sword1/music.cpp
Expand Up @@ -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())
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion engines/sword1/music.h
Expand Up @@ -44,7 +44,7 @@ class MusicHandle : public Audio::AudioStream {
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();
Expand Down
3 changes: 2 additions & 1 deletion engines/sword1/sound.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 481a5e0

Please sign in to comment.