aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-08-05 23:08:34 -0400
committerPaul Gilbert2016-08-05 23:08:34 -0400
commitc691449958790019650829233a616c64ba726f71 (patch)
treedc31aee863372c33781efc80a69367e151bf6e91
parentdbee76236e9519932b14fb4aea81a07e86100309 (diff)
downloadscummvm-rg350-c691449958790019650829233a616c64ba726f71.tar.gz
scummvm-rg350-c691449958790019650829233a616c64ba726f71.tar.bz2
scummvm-rg350-c691449958790019650829233a616c64ba726f71.zip
TITANIC: Add sounds list to QSoundManager
-rw-r--r--engines/titanic/sound/sound_manager.cpp45
-rw-r--r--engines/titanic/sound/sound_manager.h39
-rw-r--r--engines/titanic/sound/wave_file.cpp1
3 files changed, 85 insertions, 0 deletions
diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp
index 0d133c37e6..ec26b170a6 100644
--- a/engines/titanic/sound/sound_manager.cpp
+++ b/engines/titanic/sound/sound_manager.cpp
@@ -34,6 +34,51 @@ CSoundManager::CSoundManager() : _musicPercent(75.0), _speechPercent(75.0),
/*------------------------------------------------------------------------*/
+void QSoundManagerSounds::add(CWaveFile *waveFile, int iChannel, CEndTalkerFn endFn, TTtalker *talker) {
+ push_back(new QSoundManagerSound(waveFile, iChannel, endFn, talker));
+}
+
+void QSoundManagerSounds::flushChannel(int iChannel) {
+ for (iterator i = begin(); i != end(); ++i) {
+ QSoundManagerSound *item = *i;
+ if (item->_iChannel == iChannel) {
+ if (item->_endFn)
+ item->_endFn(item->_talker);
+
+ remove(item);
+ delete item;
+ break;
+ }
+ }
+}
+
+void QSoundManagerSounds::flushChannel(int v1, int iChannel) {
+ for (iterator i = begin(); i != end(); ++i) {
+ QSoundManagerSound *item = *i;
+ if (item->_waveFile->isLoaded() && item->_iChannel == iChannel) {
+ if (item->_endFn)
+ item->_endFn(item->_talker);
+
+ remove(item);
+ delete item;
+ break;
+ }
+ }
+}
+
+bool QSoundManagerSounds::contains(const CWaveFile *waveFile) const {
+ for (const_iterator i = begin(); i != end(); ++i) {
+ const QSoundManagerSound *item = *i;
+ if (item->_waveFile == waveFile)
+ return true;
+ }
+
+ return false;
+}
+
+
+/*------------------------------------------------------------------------*/
+
QSoundManager::QSoundManager(Audio::Mixer *mixer) : CSoundManager(), QMixer(mixer),
_field18(0), _field1C(0) {
Common::fill(&_field4A0[0], &_field4A0[16], 0);
diff --git a/engines/titanic/sound/sound_manager.h b/engines/titanic/sound/sound_manager.h
index f703e4f022..e69cfffd78 100644
--- a/engines/titanic/sound/sound_manager.h
+++ b/engines/titanic/sound/sound_manager.h
@@ -23,6 +23,7 @@
#ifndef TITANIC_SOUND_MANAGER_H
#define TITANIC_SOUND_MANAGER_H
+#include "titanic/core/list.h"
#include "titanic/support/simple_file.h"
#include "titanic/sound/proximity.h"
#include "titanic/sound/qmixer.h"
@@ -125,11 +126,49 @@ public:
virtual void proc29() {}
};
+class QSoundManagerSound : public ListItem {
+public:
+ CWaveFile *_waveFile;
+ int _iChannel;
+ CEndTalkerFn _endFn;
+ TTtalker *_talker;
+public:
+ QSoundManagerSound() : ListItem(), _waveFile(nullptr),
+ _iChannel(0), _endFn(nullptr), _talker(nullptr) {}
+ QSoundManagerSound(CWaveFile *waveFile, int iChannel, CEndTalkerFn endFn, TTtalker *talker) :
+ ListItem(), _waveFile(waveFile), _iChannel(iChannel), _endFn(endFn), _talker(talker) {}
+};
+
+class QSoundManagerSounds : public List<QSoundManagerSound> {
+public:
+ /**
+ * Adds a new sound entry to the list
+ */
+ void add(CWaveFile *waveFile, int iChannel, CEndTalkerFn endFn, TTtalker *talker);
+
+ /**
+ * Flushes a wave file attached to the specified channel
+ */
+ void flushChannel(int iChannel);
+
+ /**
+ * Flushes a wave file attached to the specified channel
+ */
+ void flushChannel(int v1, int iChannel);
+
+ /**
+ * Returns true if the list contains the specified wave file
+ */
+ bool contains(const CWaveFile *waveFile) const;
+};
+
/**
* Concrete sound manager class that handles interfacing with
* the QMixer sound mixer class
*/
class QSoundManager : public CSoundManager, public QMixer {
+private:
+ QSoundManagerSounds _sounds;
public:
int _field18;
int _field1C;
diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp
index 56e12e3e61..6f0007f511 100644
--- a/engines/titanic/sound/wave_file.cpp
+++ b/engines/titanic/sound/wave_file.cpp
@@ -48,6 +48,7 @@ bool CWaveFile::loadSound(const CString &name) {
Common::SeekableReadStream *stream = file.readStream();
_stream = Audio::makeWAVStream(stream->readStream(stream->size()), DisposeAfterUse::YES);
+ return true;
}