[Scummvm-cvs-logs] scummvm master -> 24836990da6080e20de9d2a15c564bc01428369b

bluegr bluegr at gmail.com
Fri Jan 3 15:04:08 CET 2014


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:
24836990da FULLPIPE: Add initial implementation of some sound-related functions


Commit: 24836990da6080e20de9d2a15c564bc01428369b
    https://github.com/scummvm/scummvm/commit/24836990da6080e20de9d2a15c564bc01428369b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-01-03T06:03:27-08:00

Commit Message:
FULLPIPE: Add initial implementation of some sound-related functions

Changed paths:
    engines/fullpipe/sound.cpp
    engines/fullpipe/sound.h
    engines/fullpipe/utils.h



diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp
index a08152e..8c6b01f 100644
--- a/engines/fullpipe/sound.cpp
+++ b/engines/fullpipe/sound.cpp
@@ -23,8 +23,12 @@
 #include "fullpipe/fullpipe.h"
 
 #include "fullpipe/objects.h"
+#include "fullpipe/scene.h"
 #include "fullpipe/sound.h"
 #include "fullpipe/ngiarchive.h"
+#include "common/memstream.h"
+#include "audio/audiostream.h"
+#include "audio/decoders/wave.h"
 
 namespace Fullpipe {
 
@@ -120,7 +124,8 @@ void FullpipeEngine::startSceneTrack() {
 }
 
 void FullpipeEngine::stopAllSounds() {
-	warning("STUB: FullpipeEngine::stopAllSounds()");
+	// TODO: Differences from stopAllSoundStreams()
+	g_fp->_mixer->stopAll();
 }
 
 void FullpipeEngine::toggleMute() {
@@ -128,7 +133,18 @@ void FullpipeEngine::toggleMute() {
 }
 
 void FullpipeEngine::playSound(int id, int flag) {
-	warning("STUB: FullpipeEngine::playSound(%d, %d)", id, flag);
+	SoundList *soundList = g_fp->_currentScene->_soundList;
+	Sound *sound = soundList->getSoundById(id);
+	if (!sound) {
+		warning("playSound: Can't find sound with ID %d", id);
+		return;
+	}
+	byte *soundData = sound->loadData();
+	Common::MemoryReadStream *dataStream = new Common::MemoryReadStream(soundData, sound->getDataSize());
+	Audio::RewindableAudioStream *wav = Audio::makeWAVStream(dataStream, DisposeAfterUse::YES);
+	Audio::AudioStream *audioStream = new Audio::LoopingAudioStream(wav, (flag == 1) ? 0 : 1);
+	Audio::SoundHandle handle = sound->getHandle();
+	g_fp->_mixer->playStream(Audio::Mixer::kSFXSoundType, &handle, audioStream);
 }
 
 void FullpipeEngine::playTrack(GameVar *sceneVar, const char *name, bool delayed) {
@@ -144,11 +160,18 @@ void FullpipeEngine::stopSoundStream2() {
 }
 
 void FullpipeEngine::stopAllSoundStreams() {
-	warning("STUB: FullpipeEngine::stopAllSoundStreams()");
+	// TODO: Differences from stopAllSounds()
+	g_fp->_mixer->stopAll();
 }
 
 void FullpipeEngine::stopAllSoundInstances(int id) {
-	warning("STUB: FullpipeEngine::stopAllSoundInstances(%d)", id);
+	SoundList *soundList = g_fp->_currentScene->_soundList;
+	for (int i = 0; i < soundList->getCount(); i++) {
+		Sound *sound = soundList->getSoundByIndex(i);
+		if (sound->getId() == id) {
+			g_fp->_mixer->stopHandle(sound->getHandle());
+		}
+	}
 }
 
 } // End of namespace Fullpipe
diff --git a/engines/fullpipe/sound.h b/engines/fullpipe/sound.h
index e2b271f..07830e9 100644
--- a/engines/fullpipe/sound.h
+++ b/engines/fullpipe/sound.h
@@ -32,12 +32,15 @@ class Sound : public MemoryObject {
 	int _directSoundBuffer;
 	int _directSoundBuffers[7];
 	byte *_soundData;
+	Audio::SoundHandle _handle;
 
   public:
 	Sound();
 	virtual bool load(MfcArchive &file, NGIArchive *archive);
 	virtual bool load(MfcArchive &file) { assert(0); return false; } // Disable base class
 	void updateVolume();
+	int getId() const { return _id; }
+	Audio::SoundHandle getHandle() const { return _handle; }
 
 	void setPanAndVolumeByStaticAni();
 };
@@ -55,6 +58,13 @@ class SoundList : public CObject {
 
 	int getCount() { return _soundItemsCount; }
 	Sound *getSoundByIndex(int idx) { return _soundItems[idx]; }
+	Sound *getSoundById(int id) {
+		for (int i = 0; i < _soundItemsCount; i++) {
+			if (_soundItems[i]->getId() == id)
+				return _soundItems[i];
+		}
+		return NULL;
+	}
 };
 
 } // End of namespace Fullpipe
diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h
index 64f56ce..427cd67 100644
--- a/engines/fullpipe/utils.h
+++ b/engines/fullpipe/utils.h
@@ -115,6 +115,7 @@ class MemoryObject : CObject {
 	void load() { loadFile(_memfilename); }
 	byte *getData();
 	byte *loadData();
+	int getDataSize() const { return _dataSize; }
 
 	bool testFlags();
 






More information about the Scummvm-git-logs mailing list