aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorPaweł Kołodziejski2004-04-11 18:56:32 +0000
committerPaweł Kołodziejski2004-04-11 18:56:32 +0000
commitb05cc19d0d189d4aa9c5659c838b2c910dcf46f5 (patch)
treedaa2cfb554f91cde2ece0af1deaacc10b20787a3 /scumm
parent908e80060da53882360c8a89fd06fb5affacd075 (diff)
downloadscummvm-rg350-b05cc19d0d189d4aa9c5659c838b2c910dcf46f5.tar.gz
scummvm-rg350-b05cc19d0d189d4aa9c5659c838b2c910dcf46f5.tar.bz2
scummvm-rg350-b05cc19d0d189d4aa9c5659c838b2c910dcf46f5.zip
add initial code for pull procedure
svn-id: r13545
Diffstat (limited to 'scumm')
-rw-r--r--scumm/imuse_digi/dimuse.cpp66
-rw-r--r--scumm/imuse_digi/dimuse.h1
2 files changed, 67 insertions, 0 deletions
diff --git a/scumm/imuse_digi/dimuse.cpp b/scumm/imuse_digi/dimuse.cpp
index 1c0eb5447b..cb52b879fd 100644
--- a/scumm/imuse_digi/dimuse.cpp
+++ b/scumm/imuse_digi/dimuse.cpp
@@ -78,6 +78,72 @@ void IMuseDigital::resetState() {
_nextSeqToPlay = 0;
}
+void IMuseDigital::poolDataForMixer(int32 pullSize, byte *mixerBuffer, AudioStream *stream) {
+ Common::StackLock lock(_mutex, "IMuseDigital::poolDataForMixer()");
+ for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
+ if (_track[l]->stream == stream) {
+ int32 mixer_size = pullSize;
+ byte *data = NULL;
+ int32 result = 0, pos = 0;
+
+ if (_track[l]->curRegion == -1)
+ switchToNextRegion(l);
+
+ int bits = _sound->getBits(_track[l]->soundHandle);
+ do {
+ if (bits == 12) {
+ byte *ptr = NULL;
+
+ mixer_size += _track[l]->mod;
+ int mixer_size_12 = (mixer_size * 3) / 4;
+ int length = (mixer_size_12 / 3) * 4;
+ _track[l]->mod = mixer_size - length;
+
+ int32 offset = (_track[l]->regionOffset * 3) / 4;
+ int result2 = _sound->getDataFromRegion(_track[l]->soundHandle, _track[l]->curRegion, &ptr, offset, mixer_size_12);
+ result = BundleCodecs::decode12BitsSample(ptr, &data, result2);
+
+ free(ptr);
+ } else if (bits == 16) {
+ result = _sound->getDataFromRegion(_track[l]->soundHandle, _track[l]->curRegion, &data, _track[l]->regionOffset, mixer_size);
+ if (_sound->getChannels(_track[l]->soundHandle) == 1) {
+ result &= ~1;
+ }
+ if (_sound->getChannels(_track[l]->soundHandle) == 2) {
+ if (result & 2)
+ result &= ~2;
+ }
+ } else if (bits == 8) {
+ result = _sound->getDataFromRegion(_track[l]->soundHandle, _track[l]->curRegion, &data, _track[l]->regionOffset, mixer_size);
+ if (_sound->getChannels(_track[l]->soundHandle) == 2) {
+ result &= ~1;
+ }
+ }
+
+ if (result > mixer_size)
+ result = mixer_size;
+
+ memcpy(mixerBuffer + pos, data, result);
+ pos += result;
+ free(data);
+
+ _track[l]->regionOffset += result;
+ _track[l]->trackOffset += result;
+
+ if (_sound->isEndOfRegion(_track[l]->soundHandle, _track[l]->curRegion)) {
+ switchToNextRegion(l);
+ if (_track[l]->toBeRemoved)
+ break;
+ }
+ mixer_size -= result;
+ assert(mixer_size >= 0);
+ } while (mixer_size != 0);
+ return;
+ }
+ }
+ error("IMuseDigital::poolDataForMixer() Can't match streams");
+}
+
void IMuseDigital::callback() {
Common::StackLock lock(_mutex, "IMuseDigital::callback()");
int l = 0;
diff --git a/scumm/imuse_digi/dimuse.h b/scumm/imuse_digi/dimuse.h
index 1e1763762a..2e7b1906ae 100644
--- a/scumm/imuse_digi/dimuse.h
+++ b/scumm/imuse_digi/dimuse.h
@@ -93,6 +93,7 @@ private:
int _curMusicCue;
static void timer_handler(void *refConf);
+ void poolDataForMixer(int32 pullSize, byte *mixerBuffer, AudioStream *stream);
void callback();
void switchToNextRegion(int track);
void allocSlot(int priority);