[Scummvm-cvs-logs] scummvm master -> dbee76236e9519932b14fb4aea81a07e86100309

dreammaster dreammaster at scummvm.org
Sat Aug 6 01:20:18 CEST 2016


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
de775c6bda TITANIC: Starting to flesh out sound loading
b312c8fe9d AUDIO: Add titanic to list of engines using wave files
dbee76236e IMAGE: Add titanic to list of engines using TGA decoder


Commit: de775c6bda1fd714cb8a4189dec9d21045fdf81e
    https://github.com/scummvm/scummvm/commit/de775c6bda1fd714cb8a4189dec9d21045fdf81e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-08-05T19:18:27-04:00

Commit Message:
TITANIC: Starting to flesh out sound loading

Changed paths:
    engines/titanic/sound/qmixer.cpp
    engines/titanic/sound/qmixer.h
    engines/titanic/sound/sound_manager.cpp
    engines/titanic/sound/sound_manager.h
    engines/titanic/sound/wave_file.cpp
    engines/titanic/sound/wave_file.h
    engines/titanic/support/movie.cpp



diff --git a/engines/titanic/sound/qmixer.cpp b/engines/titanic/sound/qmixer.cpp
index 7df6a70..d0117b2 100644
--- a/engines/titanic/sound/qmixer.cpp
+++ b/engines/titanic/sound/qmixer.cpp
@@ -24,4 +24,29 @@
 
 namespace Titanic {
 
+QMixer::QMixer(Audio::Mixer *mixer) : _mixer(mixer) {
+}
+
+bool QMixer::qsWaveMixInitEx(const QMIXCONFIG &config) {
+	// Not current implemented in ScummVM
+	return true;
+}
+
+void QMixer::qsWaveMixActivate(bool fActivate) {
+	// Not current implemented in ScummVM
+}
+
+int QMixer::qsWaveMixOpenChannel(int iChannel, WaveMixOpenChannel mode) {
+	// Not current implemented in ScummVM
+	return 0;
+}
+
+void QMixer::qsWaveMixCloseSession() {
+	_mixer->stopAll();
+}
+
+void QMixer::qsWaveMixFreeWave(Audio::SoundHandle &handle) {
+	_mixer->stopHandle(handle);
+}
+
 } // End of namespace Titanic z
diff --git a/engines/titanic/sound/qmixer.h b/engines/titanic/sound/qmixer.h
index 990abf5..8dda647 100644
--- a/engines/titanic/sound/qmixer.h
+++ b/engines/titanic/sound/qmixer.h
@@ -27,6 +27,35 @@
 
 namespace Titanic {
 
+enum WaveMixOpenChannel {
+	QMIX_OPENSINGLE		= 0,	// Open the single channel specified by iChannel
+	QMIX_OPENALL		= 1,	// Opens all the channels, iChannel ignored
+	QMIX_OPENCOUNT		= 2,	// Open iChannel Channels (eg. if iChannel = 4 will create channels 0-3)
+	QMIX_OPENAVAILABLE	= 3		// Open the first unopened channel, and return channel number
+};
+
+/**
+ * Mixer configuration structure for qsWaveMixInitEx
+ */
+struct QMIXCONFIG {
+	uint32 dwSize;
+	uint32 dwFlags;
+	uint32 dwSamplingRate;   // Sampling rate in Hz
+	void *lpIDirectSound;
+	const void *lpGuid;
+	int iChannels;          // Number of channels
+	int iOutput;            // if 0, uses best output device
+	int iLatency;           // (in ms) if 0, uses default for output device
+	int iMath;              // style of math
+	uint hwnd;
+
+	QMIXCONFIG() : dwSize(40), dwFlags(0), dwSamplingRate(0), lpIDirectSound(nullptr),
+		lpGuid(nullptr), iChannels(0), iOutput(0), iLatency(0), iMath(0), hwnd(0) {}
+	QMIXCONFIG(uint32 rate, int channels, int latency) : dwSize(40),  dwFlags(0),
+		dwSamplingRate(rate), iChannels(channels), iLatency(latency),
+		lpIDirectSound(nullptr), lpGuid(nullptr), iOutput(0), iMath(0), hwnd(0) {}
+};
+
 /**
  * Vector positioning in metres
  */
@@ -41,19 +70,43 @@ struct QSVECTOR {
  * QSound Labs, Inc. Which itself is apparently based on Microsoft's
  * WaveMix API.
  *
- * It does not currently have any actual code from
- * the library, and instead remaps calls to ScummVM's existing mixer
- * where possible. This means that advanced features of the QMixer 
- * library, like being able to set up both the player and sounds at 
- * different positions are currently ignored, and all sounds play 
- * at full volume.
+ * It does not currently have any actual code from the library, 
+ * and instead remaps calls to ScummVM's existing mixer where possible.
+ * This means that advanced features of the QMixer library, like being
+ * able to set up both the player and sounds at different positions are
+ * currently ignored, and all sounds play at full volume.
  */
 class QMixer {
 private:
 	Audio::Mixer *_mixer;
 public:
-	QMixer(Audio::Mixer *mixer) : _mixer(mixer) {}
+	QMixer(Audio::Mixer *mixer);
 	virtual ~QMixer() {}
+
+	/**
+	 * Initializes the mixer
+	 */
+	bool qsWaveMixInitEx(const QMIXCONFIG &config);
+
+	/**
+	 * Activates the mixer
+	 */
+	void qsWaveMixActivate(bool fActivate);
+
+	/**
+	 * Opens channels in the mixer for access
+	 */
+	int qsWaveMixOpenChannel(int iChannel, WaveMixOpenChannel mode);
+
+	/**
+	 * Closes down the mixer
+	 */
+	void qsWaveMixCloseSession();
+
+	/**
+	 * Stops a sound from playing
+	 */
+	void qsWaveMixFreeWave(Audio::SoundHandle &handle);
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp
index bd50a8e..0d133c3 100644
--- a/engines/titanic/sound/sound_manager.cpp
+++ b/engines/titanic/sound/sound_manager.cpp
@@ -24,6 +24,10 @@
 
 namespace Titanic {
 
+const uint SAMPLING_RATE = 22050;
+const uint LATENCY = 100;
+const uint CHANNELS_COUNT = 16;
+
 CSoundManager::CSoundManager() : _musicPercent(75.0), _speechPercent(75.0),
 	_masterPercent(75.0), _parrotPercent(75.0), _field14(1) {
 }
@@ -33,11 +37,27 @@ CSoundManager::CSoundManager() : _musicPercent(75.0), _speechPercent(75.0),
 QSoundManager::QSoundManager(Audio::Mixer *mixer) : CSoundManager(), QMixer(mixer),
 		_field18(0), _field1C(0) {
 	Common::fill(&_field4A0[0], &_field4A0[16], 0);
+
+	qsWaveMixInitEx(QMIXCONFIG(SAMPLING_RATE, CHANNELS_COUNT, LATENCY));
+	qsWaveMixActivate(true);
+	qsWaveMixOpenChannel(0, QMIX_OPENALL);
+}
+
+QSoundManager::~QSoundManager() {
+	// Close down the mixer
+	qsWaveMixCloseSession();
 }
 
 CWaveFile *QSoundManager::loadSound(const CString &name) {
-	warning("TODO");
-	return nullptr;
+	CWaveFile *waveFile = new CWaveFile();
+
+	// Try to load the specified sound
+	if (!waveFile->loadSound(name)) {
+		delete waveFile;
+		return nullptr;
+	}
+
+	return waveFile;
 }
 
 CWaveFile *QSoundManager::loadSpeech(CDialogueFile *dialogueFile, int speechId) {
@@ -98,13 +118,8 @@ int QSoundManager::proc16() const {
 	return 0;
 }
 
-void QSoundManager::WaveMixPump() {
-	warning("TODO");
-}
-
-bool QSoundManager::movieStarted() const {
-	// TODO
-	return 0;
+uint QSoundManager::getLatency() const {
+	return LATENCY;
 }
 
 void QSoundManager::proc19(int v) {
@@ -127,4 +142,8 @@ void QSoundManager::proc30() {
 	warning("TODO");
 }
 
+void QSoundManager::soundFreed(Audio::SoundHandle &handle) {
+	qsWaveMixFreeWave(handle);
+}
+
 } // End of namespace Titanic z
diff --git a/engines/titanic/sound/sound_manager.h b/engines/titanic/sound/sound_manager.h
index af97db3..f703e4f 100644
--- a/engines/titanic/sound/sound_manager.h
+++ b/engines/titanic/sound/sound_manager.h
@@ -81,12 +81,11 @@ public:
 	virtual bool isActive(const CWaveFile *waveFile) const { return false; }
 
 	virtual int proc16() const { return 0; }
-	virtual void WaveMixPump() {}
 	
 	/**
-	 * Called when a movie with audio is started
+	 * Returns the movie latency
 	 */
-	virtual bool movieStarted() const { return false; }
+	virtual uint getLatency() const { return 0; }
 
 	virtual void setMusicPercent(double percent) { _musicPercent = percent; }
 	virtual void setSpeechPercent(double percent) { _speechPercent = percent; }
@@ -138,7 +137,7 @@ public:
 	int _field4A0[16];
 public:
 	QSoundManager(Audio::Mixer *mixer);
-	virtual ~QSoundManager() {}
+	virtual ~QSoundManager();
 
 	/**
 	 * Loads a sound
@@ -176,13 +175,11 @@ public:
 	virtual bool isActive(const CWaveFile *soundRes) const;
 
 	virtual int proc16() const;
-	virtual void WaveMixPump();
-
 	
 	/**
-	 * Called when a movie with audio is started
+	 * Returns the movie latency
 	 */
-	virtual bool movieStarted() const;
+	virtual uint getLatency() const;
 
 	virtual void proc19(int v);
 	virtual void proc20(int v);
@@ -190,6 +187,11 @@ public:
 
 	virtual void proc29();
 	virtual void proc30();
+
+	/**
+	 * Called when a wave file is freed
+	 */
+	void soundFreed(Audio::SoundHandle &handle);
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp
index 7749a7b..56e12e3 100644
--- a/engines/titanic/sound/wave_file.cpp
+++ b/engines/titanic/sound/wave_file.cpp
@@ -20,13 +20,35 @@
  *
  */
 
+#include "audio/decoders/wave.h"
 #include "titanic/sound/wave_file.h"
+#include "titanic/sound/sound_manager.h"
+#include "titanic/support/simple_file.h"
 
 namespace Titanic {
 
+CWaveFile::~CWaveFile() {
+	if (_stream) {
+		_owner->soundFreed(_soundHandle);
+		delete _stream;
+	}
+}
+
 int CWaveFile::fn1() {
 	// TODO
 	return 0;
 }
 
+bool CWaveFile::loadSound(const CString &name) {
+	assert(!_stream);
+
+	StdCWadFile file;
+	if (!file.open(name))
+		return false;
+
+	Common::SeekableReadStream *stream = file.readStream();
+	_stream = Audio::makeWAVStream(stream->readStream(stream->size()), DisposeAfterUse::YES);
+}
+
+
 } // End of namespace Titanic z
diff --git a/engines/titanic/sound/wave_file.h b/engines/titanic/sound/wave_file.h
index 0d8d863..ff85df5 100644
--- a/engines/titanic/sound/wave_file.h
+++ b/engines/titanic/sound/wave_file.h
@@ -23,32 +23,35 @@
 #ifndef TITANIC_WAVE_FILE_H
 #define TITANIC_WAVE_FILE_H
 
-#include "titanic/support/simple_file.h"
+#include "audio/audiostream.h"
+#include "audio/mixer.h"
+#include "titanic/support/string.h"
 
 namespace Titanic {
 
-class CSoundManager;
+class QSoundManager;
 
 class CWaveFile {
 public:
-	int _field0;
-	int _field4;
-	int _field8;
-	uint _handle;
-	CSoundManager *_owner;
-	int _field14;
-	int _field18;
-	int _field1C;
-	int _field20;
-	int _field24;
-	int _field28;
-	int _field2C;
+	QSoundManager *_owner;
+	Audio::AudioStream *_stream;
+	Audio::SoundHandle _soundHandle;
 public:
-	CWaveFile() : _field0(2), _field4(0), _field8(0), _handle(0),
-		_owner(nullptr), _field14(1), _field18(0), _field1C(0),
-		_field20(0), _field24(0), _field28(0), _field2C(-1) {}
+	CWaveFile() : _owner(nullptr), _stream(nullptr) {}
+	CWaveFile(QSoundManager *owner) : _owner(owner), _stream(nullptr) {}
+	~CWaveFile();
 
 	int fn1();
+
+	/**
+	 * Tries to load the specified wave file sound
+	 */
+	bool loadSound(const CString &name);
+
+	/**
+	 * Returns true if the wave file has data loaded
+	 */
+	bool isLoaded() const { return _stream != nullptr; }
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/support/movie.cpp b/engines/titanic/support/movie.cpp
index 8810cf0..5453d8c 100644
--- a/engines/titanic/support/movie.cpp
+++ b/engines/titanic/support/movie.cpp
@@ -199,8 +199,8 @@ int OSMovie::getFrame() const {
 }
 
 void OSMovie::movieStarted() {
-	if (_aviSurface._hasAudio)
-		_aviSurface._soundManager->movieStarted();
+	//if (_aviSurface._hasAudio)
+	//	_aviSurface._soundManager->movieStarted();
 
 	// Register the movie in the playing list
 	addToPlayingMovies();


Commit: b312c8fe9d5fd55188e2aa8910f5a5eff78b8def
    https://github.com/scummvm/scummvm/commit/b312c8fe9d5fd55188e2aa8910f5a5eff78b8def
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-08-05T19:19:17-04:00

Commit Message:
AUDIO: Add titanic to list of engines using wave files

Changed paths:
    audio/decoders/wave.h



diff --git a/audio/decoders/wave.h b/audio/decoders/wave.h
index a7fb769..aaf4a01 100644
--- a/audio/decoders/wave.h
+++ b/audio/decoders/wave.h
@@ -38,6 +38,7 @@
  *  - sherlock
  *  - sword1
  *  - sword2
+ *	- titanic
  *  - tony
  *  - tucker
  *  - wintermute


Commit: dbee76236e9519932b14fb4aea81a07e86100309
    https://github.com/scummvm/scummvm/commit/dbee76236e9519932b14fb4aea81a07e86100309
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-08-05T19:19:45-04:00

Commit Message:
IMAGE: Add titanic to list of engines using TGA decoder

Changed paths:
    image/tga.h



diff --git a/image/tga.h b/image/tga.h
index 677c178..ef897be 100644
--- a/image/tga.h
+++ b/image/tga.h
@@ -26,6 +26,7 @@
 
 /*
  * TGA decoder used in engines:
+ *	- titanic
  *  - wintermute
  *  - zvision
  */






More information about the Scummvm-git-logs mailing list