diff options
| -rw-r--r-- | engines/access/amazon/amazon_logic.cpp | 6 | ||||
| -rw-r--r-- | engines/access/sound.cpp | 24 | ||||
| -rw-r--r-- | engines/access/sound.h | 6 | 
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(); | 
