[Scummvm-cvs-logs] scummvm master -> 4ffbae38154949fdcf0e55cc18dbf8047e608829

bluegr bluegr at gmail.com
Sat Dec 28 12:31:08 CET 2013


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:
4ffbae3815 NEVERHOOD: Fix looping sounds (bug #6473)


Commit: 4ffbae38154949fdcf0e55cc18dbf8047e608829
    https://github.com/scummvm/scummvm/commit/4ffbae38154949fdcf0e55cc18dbf8047e608829
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-12-28T03:30:33-08:00

Commit Message:
NEVERHOOD: Fix looping sounds (bug #6473)

Based on salty-horse's patch - thanks!

Changed paths:
    engines/neverhood/sound.cpp
    engines/neverhood/sound.h



diff --git a/engines/neverhood/sound.cpp b/engines/neverhood/sound.cpp
index 3ea4549..4946de1 100644
--- a/engines/neverhood/sound.cpp
+++ b/engines/neverhood/sound.cpp
@@ -66,6 +66,12 @@ void SoundResource::play() {
 		soundItem->playSound(false);
 }
 
+void SoundResource::playLooping() {
+	AudioResourceManSoundItem *soundItem = getSoundItem();
+	if (soundItem)
+		soundItem->playSound(true);
+}
+
 void SoundResource::stop() {
 	AudioResourceManSoundItem *soundItem = getSoundItem();
 	if (soundItem)
@@ -244,7 +250,7 @@ void SoundItem::update() {
 		} else if (--_currCountdown == 0)
 			_soundResource->play();
 	} else if (_playLooping && !_soundResource->isPlaying())
-		_soundResource->play();
+		_soundResource->playLooping();
 }
 
 // SoundMan
@@ -558,10 +564,12 @@ int NeverhoodAudioStream::readBuffer(int16 *buffer, const int numSamples) {
 		}
 
 		if (bytesRead < bytesToRead || _stream->pos() >= _stream->size() || _stream->err() || _stream->eos()) {
-			if (_isLooping)
+			if (_isLooping) {
 				_stream->seek(0);
-			else
+				_prevValue = 0;
+			} else {
 				_endOfData = true;
+			}
 		}
 
 	}
@@ -609,7 +617,7 @@ void AudioResourceManSoundItem::playSound(bool looping) {
 	if (_data) {
 		const byte *shiftValue = _resourceHandle.extData();
 		Common::MemoryReadStream *stream = new Common::MemoryReadStream(_data, _resourceHandle.size(), DisposeAfterUse::NO);
-		NeverhoodAudioStream *audioStream = new NeverhoodAudioStream(22050, *shiftValue, false, DisposeAfterUse::YES, stream);
+		NeverhoodAudioStream *audioStream = new NeverhoodAudioStream(22050, *shiftValue, looping, DisposeAfterUse::YES, stream);
 		_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle,
 			audioStream, -1, VOLUME(_volume), PANNING(_panning));
 		debug(1, "playing sound %08X", _fileHash);
diff --git a/engines/neverhood/sound.h b/engines/neverhood/sound.h
index 548fe88..1f80f8d 100644
--- a/engines/neverhood/sound.h
+++ b/engines/neverhood/sound.h
@@ -50,6 +50,7 @@ public:
 	void unload();
 	void play(uint32 fileHash);
 	void play();
+	void playLooping();
 	void stop();
 	void setVolume(int16 volume);
 	void setPan(int16 pan);






More information about the Scummvm-git-logs mailing list