[Scummvm-cvs-logs] CVS: scummvm/scumm imuse_digi.cpp,1.29,1.30
Max Horn
fingolfin at users.sourceforge.net
Tue Jul 1 17:52:06 CEST 2003
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv31115
Modified Files:
imuse_digi.cpp
Log Message:
cleanup
Index: imuse_digi.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- imuse_digi.cpp 27 Jun 2003 00:10:17 -0000 1.29
+++ imuse_digi.cpp 2 Jul 2003 00:49:03 -0000 1.30
@@ -690,13 +690,14 @@
static void imus_digital_handler(void *engine) {
// Avoid race condition
- if (engine && ((Scumm *)engine)->_imuseDigital)
- ((Scumm *)engine)->_imuseDigital->handler();
+ Scumm *scumm = Scumm *)engine;
+ if (scumm && scumm->_imuseDigital)
+ scumm->_imuseDigital->handler();
}
-IMuseDigital::IMuseDigital(Scumm *scumm) {
+IMuseDigital::IMuseDigital(Scumm *scumm)
+ : _scumm(scumm) {
memset(_channel, 0, sizeof(Channel) * MAX_DIGITAL_CHANNELS);
- _scumm = scumm;
for (int32 l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
_channel[l]._mixerChannel = -1;
}
@@ -705,11 +706,14 @@
}
IMuseDigital::~IMuseDigital() {
+ _scumm->_timer->releaseProcedure(imus_digital_handler);
+
for (int32 l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
- if (_channel[l]._mixerChannel != -1)
- _scumm->_mixer->endStream(_channel[l]._mixerChannel);
+ if (_channel[l]._mixerChannel != -1) {
+ _scumm->_mixer->stop(_channel[l]._mixerChannel);
+ _channel[l]._mixerChannel = -1;
+ }
}
- _scumm->_timer->releaseProcedure(imus_digital_handler);
}
void IMuseDigital::handler() {
@@ -720,16 +724,14 @@
for (l = 0; l < MAX_DIGITAL_CHANNELS;l ++) {
if (_channel[l]._used) {
- if (_channel[l]._toBeRemoved == true) {
+ if (_channel[l]._toBeRemoved) {
if (_channel[l]._mixerChannel != -1) {
- _scumm->_mixer->stop(_channel[l]._mixerChannel);
- _channel[l]._mixerChannel = -1;
- }
- if (_scumm->_mixer->_channels[l] == NULL) {
- free(_channel[l]._data);
- _channel[l]._used = false;
+ _scumm->_mixer->endStream(_channel[l]._mixerChannel);
_channel[l]._mixerChannel = -1;
}
+
+ free(_channel[l]._data);
+ _channel[l]._used = false;
continue;
}
@@ -767,7 +769,7 @@
}
}
- if ((_channel[l]._jump[0]._numLoops == 0) && (_channel[l]._isJump == true)) {
+ if ((_channel[l]._jump[0]._numLoops == 0) && _channel[l]._isJump) {
_channel[l]._isJump = false;
}
@@ -779,7 +781,14 @@
new_size *= 2;
}
- if (_channel[l]._isJump == false) {
+ if (_channel[l]._isJump) {
+ if (_channel[l]._jump[0]._numLoops != 500) {
+ _channel[l]._jump[0]._numLoops--;
+ }
+ if (_channel[l]._offset + mixer_size >= _channel[l]._jump[0]._offset) {
+ new_size = _channel[l]._jump[0]._offset - _channel[l]._offset;
+ }
+ } else {
if (_channel[l]._offset + mixer_size > _channel[l]._size) {
new_size = _channel[l]._size - _channel[l]._offset;
if (_channel[l]._numLoops == 0) {
@@ -787,19 +796,12 @@
mixer_size = new_size;
}
}
- } else if (_channel[l]._isJump == true) {
- if (_channel[l]._jump[0]._numLoops != 500) {
- _channel[l]._jump[0]._numLoops--;
- }
- if (_channel[l]._offset + mixer_size >= _channel[l]._jump[0]._offset) {
- new_size = _channel[l]._jump[0]._offset - _channel[l]._offset;
- }
}
byte *buf = (byte*)malloc(mixer_size);
memcpy(buf, _channel[l]._data + _channel[l]._offset, new_size);
- if ((new_size != mixer_size) && (_channel[l]._isJump == true)) {
+ if ((new_size != mixer_size) && _channel[l]._isJump) {
memcpy(buf + new_size, _channel[l]._data + _channel[l]._jump[0]._dest, mixer_size - new_size);
_channel[l]._offset = _channel[l]._jump[0]._dest + (mixer_size - new_size);
} else if ((_channel[l]._numLoops > 0) && (new_size != mixer_size)) {
@@ -1006,7 +1008,7 @@
void IMuseDigital::stopSound(int sound) {
debug(5, "IMuseDigital::stopSound(%d)", sound);
for (int32 l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
- if ((_channel[l]._idSound == sound) && (_channel[l]._used == true)) {
+ if ((_channel[l]._idSound == sound) && _channel[l]._used) {
_channel[l]._toBeRemoved = true;
}
}
@@ -1014,7 +1016,7 @@
void IMuseDigital::stopAll() {
for (int32 l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
- if (_channel[l]._used == true) {
+ if (_channel[l]._used) {
_channel[l]._toBeRemoved = true;
}
}
@@ -1045,7 +1047,7 @@
case 6: // volume control (0-127)
debug(5, "IMuseDigital::doCommand setting volume sample(%d), volume(%d)", sample, d);
for (l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
- if ((_channel[l]._idSound == sample) && (_channel[l]._used == true)) {
+ if ((_channel[l]._idSound == sample) && _channel[l]._used) {
chan = l;
break;
}
@@ -1071,7 +1073,7 @@
case 7: // right volume control (0-127)
debug(5, "IMuseDigital::doCommand setting right volume sample(%d),volume(%d)", sample, d);
for (l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
- if ((_channel[l]._idSound == sample) && (_channel[l]._used == true)) {
+ if ((_channel[l]._idSound == sample) && _channel[l]._used) {
chan = l;
break;
}
@@ -1091,7 +1093,7 @@
case 6: // fade volume control
debug(5, "IMuseDigital::doCommand fading volume sample(%d),fade(%d, %d)", sample, d, e);
for (l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
- if ((_channel[l]._idSound == sample) && (_channel[l]._used == true)) {
+ if ((_channel[l]._idSound == sample) && _channel[l]._used) {
chan = l;
break;
}
@@ -1244,7 +1246,7 @@
int IMuseDigital::getSoundStatus(int sound) {
debug(5, "IMuseDigital::getSoundStatus(%d)", sound);
for (int32 l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
- if ((_channel[l]._idSound == sound) && (_channel[l]._used == true)) {
+ if ((_channel[l]._idSound == sound) && _channel[l]._used) {
return 1;
}
}
More information about the Scummvm-git-logs
mailing list