aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMax Horn2003-09-18 16:01:33 +0000
committerMax Horn2003-09-18 16:01:33 +0000
commit9470c9f66131d16ca19d111d21948ba57a1a8eb3 (patch)
tree79aa7b664c9dcab922649ad552ef03fe6ba58e21 /sound
parentdcf77f7a1008e4a6b98c9face6cc7461c6347e1d (diff)
downloadscummvm-rg350-9470c9f66131d16ca19d111d21948ba57a1a8eb3.tar.gz
scummvm-rg350-9470c9f66131d16ca19d111d21948ba57a1a8eb3.tar.bz2
scummvm-rg350-9470c9f66131d16ca19d111d21948ba57a1a8eb3.zip
changed & documented the premixer semantics
svn-id: r10294
Diffstat (limited to 'sound')
-rw-r--r--sound/mixer.cpp7
-rw-r--r--sound/mixer.h10
2 files changed, 9 insertions, 8 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index da5952ecf4..a8d611588f 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -160,7 +160,7 @@ bool SoundMixer::bindToSystem(OSystem *syst) {
return syst->set_sound_proc(mixCallback, this, OSystem::SOUND_16BIT);
}
-void SoundMixer::setupPremix(void *param, PremixProc *proc) {
+void SoundMixer::setupPremix(PremixProc *proc, void *param) {
StackLock lock(_mutex);
_premixParam = param;
_premixProc = proc;
@@ -279,12 +279,7 @@ void SoundMixer::mix(int16 *buf, uint len) {
StackLock lock(_mutex);
if (_premixProc && !_paused) {
- int i;
_premixProc(_premixParam, buf, len);
- // Convert mono data from the premix proc to stereo
- for (i = (len - 1); i >= 0; i--) {
- buf[2 * i] = buf[2 * i + 1] = buf[i];
- }
} else {
// zero the buf out
memset(buf, 0, 2 * len * sizeof(int16));
diff --git a/sound/mixer.h b/sound/mixer.h
index 0e7e89bddf..6c9e9a4671 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -83,8 +83,14 @@ public:
* to be generated */
bool bindToSystem(OSystem *syst);
- /** Premix procedure, useful when using fmopl adlib */
- void setupPremix(void * param, PremixProc * proc);
+ /**
+ * Set the premix procedure. This is mainly used for the adlib music, but is not limited
+ * to it. The premix proc is invoked by the mixer whenever it needs to generate any
+ * data, before any other mixing takes place. The premixer than has a chanve to fill
+ * the mix buffer with data (usually music samples). It should generate the specified
+ * number of 16bit stereo samples (i.e. len * 4 bytes).
+ */
+ void setupPremix(PremixProc *proc, void *param);
// start playing a raw sound
int playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags,