aboutsummaryrefslogtreecommitdiff
path: root/engines/tony
diff options
context:
space:
mode:
authorPaul Gilbert2012-06-11 12:20:12 +1000
committerPaul Gilbert2012-06-11 12:20:12 +1000
commit5b5a812d3750cc1e8063ccfc8d1d9bf4db6a127b (patch)
treeb8213537f63f07f77437cbabe9b681d0a034b4d2 /engines/tony
parent2da2981682cdc637faf5e2fccc041223d457bdc4 (diff)
downloadscummvm-rg350-5b5a812d3750cc1e8063ccfc8d1d9bf4db6a127b.tar.gz
scummvm-rg350-5b5a812d3750cc1e8063ccfc8d1d9bf4db6a127b.tar.bz2
scummvm-rg350-5b5a812d3750cc1e8063ccfc8d1d9bf4db6a127b.zip
TONY: Implemented process to properly set hEndOfBuffer when sound effects end
Diffstat (limited to 'engines/tony')
-rw-r--r--engines/tony/sound.cpp35
-rw-r--r--engines/tony/sound.h9
-rw-r--r--engines/tony/tony.cpp3
-rw-r--r--engines/tony/tony.h1
4 files changed, 48 insertions, 0 deletions
diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp
index 1fb4bbee1f..487bf54111 100644
--- a/engines/tony/sound.cpp
+++ b/engines/tony/sound.cpp
@@ -201,6 +201,8 @@ FPSFX::FPSFX(bool bSoundOn) {
_stream = 0;
_rewindableStream = 0;
bPaused = false;
+
+ _vm->_activeSfx.push_back(this);
}
@@ -219,6 +221,7 @@ FPSFX::~FPSFX() {
return;
g_system->getMixer()->stopHandle(_handle);
+ _vm->_activeSfx.remove(this);
delete _stream;
// _rewindableStream is deleted by deleting _stream
@@ -488,6 +491,38 @@ void FPSFX::GetVolume(int *lpdwVolume) {
*lpdwVolume = 0;
}
+/**
+ * Returns true if the underlying sound has ended
+ */
+bool FPSFX::endOfBuffer() const {
+ return !g_system->getMixer()->isSoundHandleActive(_handle) && (!_stream || _stream->endOfData());
+}
+
+/**
+ * Continually checks to see if active sounds have finished playing
+ * Sets the event signalling the sound has ended
+ */
+void FPSFX::soundCheckProcess(CORO_PARAM, const void *param) {
+ CORO_BEGIN_CONTEXT;
+ Common::List<FPSFX *>::iterator i;
+ CORO_END_CONTEXT(_ctx);
+
+ CORO_BEGIN_CODE(_ctx);
+
+ for (;;) {
+ // Check each active sound
+ for (_ctx->i = _vm->_activeSfx.begin(); _ctx->i != _vm->_activeSfx.end(); ++_ctx->i) {
+ FPSFX *sfx = *_ctx->i;
+ if (sfx->endOfBuffer())
+ CoroScheduler.setEvent(sfx->hEndOfBuffer);
+ }
+
+ // Delay until the next check is done
+ CORO_INVOKE_1(CoroScheduler.sleep, 50);
+ }
+
+ CORO_END_CODE;
+}
/****************************************************************************\
* Metodi di FPSTREAM
diff --git a/engines/tony/sound.h b/engines/tony/sound.h
index c64680a9cf..6593470d0c 100644
--- a/engines/tony/sound.h
+++ b/engines/tony/sound.h
@@ -209,6 +209,10 @@ private:
\****************************************************************************/
public:
+ /**
+ * Check process for whether sounds have finished playing
+ */
+ static void soundCheckProcess(CORO_PARAM, const void *param);
/****************************************************************************\
*
@@ -353,6 +357,11 @@ public:
\****************************************************************************/
void GetVolume(int *lpdwVolume);
+
+ /**
+ * Returns true if the sound has finished playing
+ */
+ bool endOfBuffer() const;
};
class FPSTREAM {
diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp
index 2b9d8fbc20..b1e45c8bfa 100644
--- a/engines/tony/tony.cpp
+++ b/engines/tony/tony.cpp
@@ -371,6 +371,9 @@ void TonyEngine::initMusic() {
// Preload sound effects
preloadUtilSFX(0, "U01.ADP"); // Reversed!!
preloadUtilSFX(1, "U02.ADP");
+
+ // Start check processes for sound
+ CoroScheduler.createProcess(FPSFX::soundCheckProcess, NULL);
}
void TonyEngine::closeMusic() {
diff --git a/engines/tony/tony.h b/engines/tony/tony.h
index cee15d07a4..43bc23c636 100644
--- a/engines/tony/tony.h
+++ b/engines/tony/tony.h
@@ -100,6 +100,7 @@ public:
Common::File _vdbFP;
Common::Array<VoiceHeader> _voices;
FPSOUND _theSound;
+ Common::List<FPSFX *> _activeSfx;
Globals _globals;
Debugger *_debugger;