[Scummvm-cvs-logs] SF.net SVN: scummvm:[47130] scummvm/trunk/engines/tucker

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Thu Jan 7 17:44:17 CET 2010


Revision: 47130
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47130&view=rev
Author:   lordhoto
Date:     2010-01-07 16:44:17 +0000 (Thu, 07 Jan 2010)

Log Message:
-----------
Adapt TUCKER to use RewindableAudioStream and Mixer::playInputStreamLooping. (Needs testing, please :-)

Modified Paths:
--------------
    scummvm/trunk/engines/tucker/resource.cpp
    scummvm/trunk/engines/tucker/sequences.cpp
    scummvm/trunk/engines/tucker/tucker.h

Modified: scummvm/trunk/engines/tucker/resource.cpp
===================================================================
--- scummvm/trunk/engines/tucker/resource.cpp	2010-01-07 16:34:56 UTC (rev 47129)
+++ scummvm/trunk/engines/tucker/resource.cpp	2010-01-07 16:44:17 UTC (rev 47130)
@@ -43,7 +43,7 @@
 
 struct CompressedSoundFile {
 	const char *filename;
-	Audio::AudioStream *(*makeStream)(Common::SeekableReadStream *stream, bool disposeAfterUse, uint32 startTime, uint32 duration, uint numLoops);
+	Audio::SeekableAudioStream *(*makeStream)(Common::SeekableReadStream *stream, bool disposeAfterUse);
 };
 
 static const CompressedSoundFile compressedSoundFilesTable[] = {
@@ -232,7 +232,7 @@
 	_fCompressedSound.close();
 }
 
-Audio::AudioStream *CompressedSound::load(CompressedSoundType type, int num, bool loop) {
+Audio::RewindableAudioStream *CompressedSound::load(CompressedSoundType type, int num) {
 	if (_compressedSoundType < 0) {
 		return 0;
 	}
@@ -256,7 +256,7 @@
 	if (offset == 0) {
 		return 0;
 	}
-	Audio::AudioStream *stream = 0;
+	Audio::SeekableAudioStream *stream = 0;
 	_fCompressedSound.seek(offset);
 	int dirOffset = _fCompressedSound.readUint32LE();
 	int dirSize = _fCompressedSound.readUint32LE();
@@ -270,7 +270,7 @@
 			_fCompressedSound.seek(dirOffset + dirSize * 8 + soundOffset);
 			Common::MemoryReadStream *tmp = _fCompressedSound.readStream(soundSize);
 			if (tmp) {
-				stream = (compressedSoundFilesTable[_compressedSoundType].makeStream)(tmp, true, 0, 0, loop ? 0 : 1);
+				stream = (compressedSoundFilesTable[_compressedSoundType].makeStream)(tmp, true);
 			}
 		}
 	}
@@ -913,16 +913,16 @@
 }
 
 void TuckerEngine::loadSound(Audio::Mixer::SoundType type, int num, int volume, bool loop, Audio::SoundHandle *handle) {
-	Audio::AudioStream *stream = 0;
+	Audio::RewindableAudioStream *stream = 0;
 	switch (type) {
 	case Audio::Mixer::kSFXSoundType:
-		stream = _compressedSound.load(kSoundTypeFx, num, loop);
+		stream = _compressedSound.load(kSoundTypeFx, num);
 		break;
 	case Audio::Mixer::kMusicSoundType:
-		stream = _compressedSound.load(kSoundTypeMusic, num, loop);
+		stream = _compressedSound.load(kSoundTypeMusic, num);
 		break;
 	case Audio::Mixer::kSpeechSoundType:
-		stream = _compressedSound.load(kSoundTypeSpeech, num, loop);
+		stream = _compressedSound.load(kSoundTypeSpeech, num);
 		break;
 	default:
 		return;
@@ -946,7 +946,7 @@
 		snprintf(fileName, sizeof(fileName), fmt, num);
 		Common::File *f = new Common::File;
 		if (f->open(fileName)) {
-			stream = Audio::makeLoopingAudioStream(Audio::makeWAVStream(f, true), loop ? 0 : 1);
+			stream = Audio::makeWAVStream(f, true);
 		} else {
 			delete f;
 		}
@@ -954,7 +954,11 @@
 
 	if (stream) {
 		_mixer->stopHandle(*handle);
-		_mixer->playInputStream(type, handle, stream, -1, scaleMixerVolume(volume, kMaxSoundVolume));
+
+		if (loop)
+			_mixer->playInputStreamLooping(type, handle, stream, 0, -1, scaleMixerVolume(volume, kMaxSoundVolume));
+		else
+			_mixer->playInputStream(type, handle, stream, -1, scaleMixerVolume(volume, kMaxSoundVolume));
 	}
 }
 

Modified: scummvm/trunk/engines/tucker/sequences.cpp
===================================================================
--- scummvm/trunk/engines/tucker/sequences.cpp	2010-01-07 16:34:56 UTC (rev 47129)
+++ scummvm/trunk/engines/tucker/sequences.cpp	2010-01-07 16:44:17 UTC (rev 47130)
@@ -574,11 +574,11 @@
 	} while (_lastFrameTime <= end);
 }
 
-Audio::AudioStream *AnimationSequencePlayer::loadSound(int index, AnimationSoundType type) {
-	Audio::AudioStream *stream = _compressedSound->load(kSoundTypeIntro, index, type == kAnimationSoundTypeLoopingWAV);
-	if (stream) {
+Audio::RewindableAudioStream *AnimationSequencePlayer::loadSound(int index, AnimationSoundType type) {
+	Audio::RewindableAudioStream *stream = _compressedSound->load(kSoundTypeIntro, index);
+	if (stream)
 		return stream;
-	}
+
 	char fileName[64];
 	snprintf(fileName, sizeof(fileName), "audio/%s", _audioFileNamesTable[index]);
 	Common::File f;
@@ -603,8 +603,7 @@
 			}
 			break;
 		case kAnimationSoundTypeWAV:
-		case kAnimationSoundTypeLoopingWAV:
-			stream = Audio::makeLoopingAudioStream(Audio::makeWAVStream(&f, true), type == kAnimationSoundTypeLoopingWAV ? 0 : 1);
+			stream = Audio::makeWAVStream(&f, true);
 			break;
 		}
 		
@@ -625,7 +624,7 @@
 }
 
 void AnimationSequencePlayer::updateSounds() {
-	Audio::AudioStream *s = 0;
+	Audio::RewindableAudioStream *s = 0;
 	const SoundSequenceData *p = &_soundSeqData[_soundSeqDataIndex];
 	while (_soundSeqDataIndex < _soundSeqDataCount && p->timestamp <= _frameCounter) {
 		switch (p->opcode) {
@@ -635,8 +634,8 @@
 			}
 			break;
 		case 1:
-			if ((s = loadSound(p->num, kAnimationSoundTypeLoopingWAV)) != 0) {
-				_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_soundsHandle[p->index], s, -1, scaleMixerVolume(p->volume));
+			if ((s = loadSound(p->num, kAnimationSoundTypeWAV)) != 0) {
+				_mixer->playInputStreamLooping(Audio::Mixer::kSFXSoundType, &_soundsHandle[p->index], s, 0, -1, scaleMixerVolume(p->volume));
 			}
 			break;
 		case 2:

Modified: scummvm/trunk/engines/tucker/tucker.h
===================================================================
--- scummvm/trunk/engines/tucker/tucker.h	2010-01-07 16:34:56 UTC (rev 47129)
+++ scummvm/trunk/engines/tucker/tucker.h	2010-01-07 16:44:17 UTC (rev 47130)
@@ -232,7 +232,7 @@
 
 	void openFile();
 	void closeFile();
-	Audio::AudioStream *load(CompressedSoundType type, int num, bool loop);
+	Audio::RewindableAudioStream *load(CompressedSoundType type, int num);
 
 private:
 
@@ -872,8 +872,7 @@
 enum AnimationSoundType {
 	kAnimationSoundType8BitsRAW,
 	kAnimationSoundType16BitsRAW,
-	kAnimationSoundTypeWAV,
-	kAnimationSoundTypeLoopingWAV
+	kAnimationSoundTypeWAV
 };
 
 enum {
@@ -927,7 +926,7 @@
 
 	void syncTime();
 	void loadSounds(int num);
-	Audio::AudioStream *loadSound(int index, AnimationSoundType type);
+	Audio::RewindableAudioStream *loadSound(int index, AnimationSoundType type);
 	void updateSounds();
 	void fadeInPalette();
 	void fadeOutPalette();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list