aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Kołodziejski2002-09-30 19:10:35 +0000
committerPaweł Kołodziejski2002-09-30 19:10:35 +0000
commita9c1eb6075eaee8103dedaf39da3e716d2c598f8 (patch)
treed36f82c43ea658b4292ff58a60660899233d7d0d
parent8f7e3119bfc02d31f4129d16ae1032fbc11bd8de (diff)
downloadscummvm-rg350-a9c1eb6075eaee8103dedaf39da3e716d2c598f8.tar.gz
scummvm-rg350-a9c1eb6075eaee8103dedaf39da3e716d2c598f8.tar.bz2
scummvm-rg350-a9c1eb6075eaee8103dedaf39da3e716d2c598f8.zip
synced with local sources (imuse)
svn-id: r5053
-rw-r--r--scumm/imuse.cpp22
-rw-r--r--scumm/sound.cpp34
2 files changed, 32 insertions, 24 deletions
diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp
index c2972c7bbc..5eaebba43f 100644
--- a/scumm/imuse.cpp
+++ b/scumm/imuse.cpp
@@ -4846,7 +4846,7 @@ static void imus_digital_handler(void * engine) {
IMuseDigital::IMuseDigital(Scumm *scumm) {
memset(_channel, 0, sizeof(channel) * MAX_DIGITAL_CHANNELS);
_scumm = scumm;
- _scumm->_timer->installProcedure(imus_digital_handler, 100);
+ _scumm->_timer->installProcedure(imus_digital_handler, 200);
}
IMuseDigital::~IMuseDigital() {
@@ -4865,13 +4865,19 @@ void IMuseDigital::handler() {
continue;
}
+ uint32 new_size = _channel[l]._mixerSize;
if (_channel[l]._offset + _channel[l]._mixerSize > _channel[l]._size) {
- _channel[l]._mixerSize = _channel[l]._size - _channel[l]._offset;
- _channel[l]._toBeRemoved = true;
+ new_size = _channel[l]._size - _channel[l]._offset;
+ if(_channel[l]._isLoop == false) {
+ _channel[l]._toBeRemoved = true;
+ }
}
byte *buf = (byte*)malloc(_channel[l]._mixerSize);
- memcpy(buf, _channel[l]._data + _channel[l]._offset, _channel[l]._mixerSize);
+ memcpy(buf, _channel[l]._data + _channel[l]._offset, new_size);
+ if ((new_size != _channel[l]._mixerSize) && (_channel[l]._isLoop == true)) {
+ memcpy(buf, _channel[l]._data, _channel[l]._mixerSize - new_size);
+ }
new_mixer = false;
if (_channel[l]._mixerTrack == -1) {
@@ -4898,7 +4904,11 @@ void IMuseDigital::handler() {
}
_scumm->_system->unlock_mutex(_scumm->_mixer->_mutex);
- _channel[l]._offset += _channel[l]._mixerSize;
+ if ((new_size != _channel[l]._mixerSize) && (_channel[l]._isLoop == true)) {
+ _channel[l]._offset = _channel[l]._mixerSize - new_size;
+ } else {
+ _channel[l]._offset += _channel[l]._mixerSize;
+ }
}
}
}
@@ -4955,7 +4965,7 @@ void IMuseDigital::startSound(int sound) {
}
_channel[l]._mixerTrack = -1;
- _channel[l]._mixerSize = 22050 / 10;
+ _channel[l]._mixerSize = 22050 / 5;
_channel[l]._mixerFlags = SoundMixer::FLAG_AUTOFREE;
if (_channel[l]._bits == 12) {
_channel[l]._mixerSize *= 2;
diff --git a/scumm/sound.cpp b/scumm/sound.cpp
index 1ffb870b56..634a77bb7d 100644
--- a/scumm/sound.cpp
+++ b/scumm/sound.cpp
@@ -837,25 +837,23 @@ bool Sound::isSfxFinished() {
}
uint32 Sound::decode12BitsSample(byte * src, byte ** dst, uint32 size) {
- uint32 s_size = (size * 4) / 3;
- byte * ptr = *dst = (byte*)malloc (s_size + 4);
-
- uint32 r = 0, tmp, l;
- for (l = 0; l < size; l += 3) {
- tmp = (src[l + 1] & 0x0f) << 8;
- tmp = (tmp | src[l + 0]) << 4;
- tmp -= 0x8000;
- ptr[r++] = (byte)((tmp >> 8) & 0xff);
- ptr[r++] = (byte)(tmp & 0xff);
-
- tmp = (src[l + 1] & 0xf0) << 4;
- tmp = (tmp | src[l + 2]) << 4;
- tmp -= 0x8000;
- ptr[r++] = (byte)((tmp >> 8) & 0xff);
- ptr[r++] = (byte)(tmp & 0xff);
+ uint32 s_size = (size / 3) * 4;
+ uint32 loop_size = s_size / 4;
+ byte *ptr = *dst = (byte*)malloc(s_size);
+
+ uint32 tmp;
+ while(loop_size--) {
+ byte v1 = *src++;
+ byte v2 = *src++;
+ byte v3 = *src++;
+ tmp = ((((v2 & 0x0f) << 8) | v1) << 4) - 0x8000;
+ *ptr++ = (byte)((tmp >> 8) & 0xff);
+ *ptr++ = (byte)(tmp & 0xff);
+ tmp = ((((v2 & 0xf0) << 4) | v3) << 4) - 0x8000;
+ *ptr++ = (byte)((tmp >> 8) & 0xff);
+ *ptr++ = (byte)(tmp & 0xff);
}
-
- return r;
+ return s_size;
}
static void music_handler (void * engine) {