aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorTorbjörn Andersson2015-07-09 23:26:44 +0200
committerTorbjörn Andersson2015-07-09 23:45:12 +0200
commit5de5a7afaaa138c923df31e61be9d0d4ed303d9e (patch)
tree3c3500aef3cddc1d60aadaeb625ec366e1f9a058 /engines
parentf0a03fcd1b0190e6527df1d51e5a86c77f0f5195 (diff)
downloadscummvm-rg350-5de5a7afaaa138c923df31e61be9d0d4ed303d9e.tar.gz
scummvm-rg350-5de5a7afaaa138c923df31e61be9d0d4ed303d9e.tar.bz2
scummvm-rg350-5de5a7afaaa138c923df31e61be9d0d4ed303d9e.zip
ACCESS: Use looping audio stream for Amazon intro's projector sound
This is less prone to glitches than playing manually triggering the playing of the short non-looping version of the sound.
Diffstat (limited to 'engines')
-rw-r--r--engines/access/amazon/amazon_logic.cpp6
-rw-r--r--engines/access/sound.cpp24
-rw-r--r--engines/access/sound.h6
3 files changed, 20 insertions, 16 deletions
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index b2728ff246..b927243065 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -326,7 +326,6 @@ void Opening::doTitle() {
_vm->_buffer2.copyFrom(*_vm->_screen);
_vm->_buffer1.copyFrom(*_vm->_screen);
screen.forceFadeIn();
- _vm->_sound->playSound(1);
// WORKAROUND: This delay has been added to replace original game delay that
// came from loading resources, since nowadays it would be too fast to be visible
@@ -337,13 +336,14 @@ void Opening::doTitle() {
if (_vm->shouldQuit())
return;
+ _vm->_sound->playSound(1, true);
+
Resource *spriteData = _vm->_files->loadFile(0, 2);
_vm->_objectsTable[0] = new SpriteResource(_vm, spriteData);
delete spriteData;
_vm->_files->_setPaletteFlag = false;
_vm->_files->loadScreen(0, 4);
- _vm->_sound->playSound(1);
_vm->_buffer2.copyFrom(*_vm->_screen);
_vm->_buffer1.copyFrom(*_vm->_screen);
@@ -356,7 +356,6 @@ void Opening::doTitle() {
_vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71));
_vm->_buffer2.copyTo(_vm->_screen);
- _vm->_sound->playSound(1);
_vm->_events->_vbCount = 70;
while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0 && !_skipStart) {
_vm->_events->pollEventsAndWait();
@@ -368,6 +367,7 @@ void Opening::doTitle() {
return;
_vm->_sound->stopSound();
+ _vm->_sound->checkSoundQueue(); // HACK: Clear sound 1 from the queue
_vm->_sound->playSound(0);
screen.forceFadeOut();
_vm->_events->_vbCount = 100;
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index 95f8367b46..69133d082d 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -75,26 +75,26 @@ Resource *SoundManager::loadSound(int fileNum, int subfile) {
return _vm->_files->loadFile(fileNum, subfile);
}
-void SoundManager::playSound(int soundIndex) {
- debugC(1, kDebugSound, "playSound(%d)", soundIndex);
+void SoundManager::playSound(int soundIndex, bool loop) {
+ debugC(1, kDebugSound, "playSound(%d, %d)", soundIndex, loop);
int priority = _soundTable[soundIndex]._priority;
- playSound(_soundTable[soundIndex]._res, priority);
+ playSound(_soundTable[soundIndex]._res, priority, loop);
}
-void SoundManager::playSound(Resource *res, int priority) {
+void SoundManager::playSound(Resource *res, int priority, bool loop) {
debugC(1, kDebugSound, "playSound");
byte *resourceData = res->data();
assert(res->_size >= 32);
+ Audio::RewindableAudioStream *audioStream;
+
if (READ_BE_UINT32(resourceData) == MKTAG('R','I','F','F')) {
// CD version uses WAVE-files
Common::SeekableReadStream *waveStream = new Common::MemoryReadStream(resourceData, res->_size, DisposeAfterUse::NO);
- Audio::RewindableAudioStream *audioStream = Audio::makeWAVStream(waveStream, DisposeAfterUse::YES);
- _queue.push_back(audioStream);
-
+ audioStream = Audio::makeWAVStream(waveStream, DisposeAfterUse::YES);
} else if (READ_BE_UINT32(resourceData) == MKTAG('S', 'T', 'E', 'V')) {
// sound files have a fixed header of 32 bytes in total
// header content:
@@ -134,12 +134,16 @@ void SoundManager::playSound(Resource *res, int priority) {
return;
}
- Audio::RewindableAudioStream *audioStream = Audio::makeRawStream(resourceData + 32, sampleSize, sampleRate, 0, DisposeAfterUse::NO);
- _queue.push_back(audioStream);
-
+ audioStream = Audio::makeRawStream(resourceData + 32, sampleSize, sampleRate, 0, DisposeAfterUse::NO);
} else
error("Unknown format");
+ if (loop) {
+ _queue.push_back(new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::NO));
+ } else {
+ _queue.push_back(audioStream);
+ }
+
if (!_mixer->isSoundHandleActive(_effectsHandle))
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_effectsHandle,
_queue[0], -1, _mixer->kMaxChannelVolume, 0,
diff --git a/engines/access/sound.h b/engines/access/sound.h
index 90f6656e26..014c6651fb 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -49,11 +49,11 @@ private:
AccessEngine *_vm;
Audio::Mixer *_mixer;
Audio::SoundHandle _effectsHandle;
- Common::Array<Audio::RewindableAudioStream *> _queue;
+ Common::Array<Audio::AudioStream *> _queue;
void clearSounds();
- void playSound(Resource *res, int priority);
+ void playSound(Resource *res, int priority, bool loop);
public:
Common::Array<SoundEntry> _soundTable;
public:
@@ -62,7 +62,7 @@ public:
void loadSoundTable(int idx, int fileNum, int subfile, int priority = 1);
- void playSound(int soundIndex);
+ void playSound(int soundIndex, bool loop = false);
void checkSoundQueue();
bool isSFXPlaying();