few corrections, more debug

svn-id: r13618
This commit is contained in:
Paweł Kołodziejski 2004-04-24 20:41:30 +00:00
parent be28bc0403
commit bcb5005c31
2 changed files with 30 additions and 12 deletions

View File

@ -87,8 +87,18 @@ int IMuseDigital::pullProcCallback(void *refCon, CustomProcInputStream *stream,
int IMuseDigital::pullProc(CustomProcInputStream *stream, byte *mixerBuffer, int pullSize) {
Common::StackLock lock(_mutex, "IMuseDigital::pullProc()");
debug(5, "pullProc() pullSize:%d", pullSize);
for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
if ((_track[l]->used) && (_track[l]->stream == stream)) {
if (_track[l]->toBeRemoved) {
debug(5, "IMuseDigital::pullProc() stopped sound: %d", _track[l]->soundId);
_track[l]->stream->finish();
_track[l]->stream = NULL;
_sound->closeSound(_track[l]->soundHandle);
_track[l]->soundHandle = NULL;
_track[l]->used = false;
return 0;
}
_vm->_mixer->setChannelVolume(_track[l]->handle, _track[l]->mixerVol);
_vm->_mixer->setChannelBalance(_track[l]->handle, _track[l]->mixerPan);
int32 mixer_size = pullSize;
@ -97,11 +107,19 @@ int IMuseDigital::pullProc(CustomProcInputStream *stream, byte *mixerBuffer, int
if (_track[l]->curRegion == -1) {
switchToNextRegion(l);
if (_track[l]->toBeRemoved)
continue;
if (_track[l]->toBeRemoved) {
return 0;
}
}
int bits = _sound->getBits(_track[l]->soundHandle);
int channels = _sound->getChannels(_track[l]->soundHandle);
if ((bits == 16) && (channels == 2))
assert((pullSize & 3) == 0);
else if ((bits == 16) || (channels == 2))
assert((pullSize & 1) == 0);
do {
if (bits == 12) {
byte *ptr = NULL;
@ -175,16 +193,6 @@ void IMuseDigital::callback() {
_track[l]->used = false;
continue;
}
} else if (_track[l]->stream) {
if (_track[l]->toBeRemoved) {
debug(5, "IMuseDigital::callback() B: stopped sound: %d", _track[l]->soundId);
_track[l]->stream->finish();
_track[l]->stream = NULL;
_sound->closeSound(_track[l]->soundHandle);
_track[l]->soundHandle = NULL;
_track[l]->used = false;
continue;
}
}
if (_track[l]->volFadeUsed) {
@ -390,8 +398,11 @@ void IMuseDigital::callback() {
#endif
void IMuseDigital::switchToNextRegion(int track) {
debug(5, "switchToNextRegion(track:%d)", track);
if (track >= MAX_DIGITAL_TRACKS) {
_track[track]->toBeRemoved = true;
debug(5, "exit (fadetrack can't go next region) switchToNextRegion(track:%d)", track);
return;
}
@ -399,6 +410,7 @@ void IMuseDigital::switchToNextRegion(int track) {
if (++_track[track]->curRegion == num_regions) {
_track[track]->toBeRemoved = true;
debug(5, "exit (end of regions) switchToNextRegion(track:%d)", track);
return;
}

View File

@ -411,12 +411,14 @@ int ImuseDigiSndMgr::getNumJumps(soundStruct *soundHandle) {
}
int ImuseDigiSndMgr::getRegionOffset(soundStruct *soundHandle, int region) {
debug(5, "getRegionOffset() region:%d");
assert(soundHandle && checkForProperHandle(soundHandle));
assert(region >= 0 && region < soundHandle->numRegions);
return soundHandle->region[region].offset;
}
int ImuseDigiSndMgr::getJumpIdByRegionAndHookId(soundStruct *soundHandle, int region, int hookId) {
debug(5, "getJumpIdByRegionAndHookId() region:%d, hookId:%d", region, hookId);
assert(soundHandle && checkForProperHandle(soundHandle));
assert(region >= 0 && region < soundHandle->numRegions);
for (int l = 0; l < soundHandle->numJumps; l++) {
@ -442,6 +444,7 @@ void ImuseDigiSndMgr::getSyncSizeAndPtrById(soundStruct *soundHandle, int number
}
int ImuseDigiSndMgr::getRegionIdByJumpId(soundStruct *soundHandle, int jumpId) {
debug(5, "getRegionIdByJumpId() jumpId:%d", jumpId);
assert(soundHandle && checkForProperHandle(soundHandle));
assert(jumpId >= 0 && jumpId < soundHandle->numJumps);
for (int l = 0; l < soundHandle->numRegions; l++) {
@ -454,18 +457,21 @@ int ImuseDigiSndMgr::getRegionIdByJumpId(soundStruct *soundHandle, int jumpId) {
}
int ImuseDigiSndMgr::getJumpHookId(soundStruct *soundHandle, int number) {
debug(5, "getJumpHookId() number:%d", number);
assert(soundHandle && checkForProperHandle(soundHandle));
assert(number >= 0 && number < soundHandle->numJumps);
return soundHandle->jump[number].hookId;
}
int ImuseDigiSndMgr::getJumpFade(soundStruct *soundHandle, int number) {
debug(5, "getJumpFade() number:%d", number);
assert(soundHandle && checkForProperHandle(soundHandle));
assert(number >= 0 && number < soundHandle->numJumps);
return soundHandle->jump[number].fadeDelay;
}
int32 ImuseDigiSndMgr::getDataFromRegion(soundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size) {
debug(5, "getDataFromRegion() region:%d, offset:%d, size:%d, numRegions:%d", region, offset, size, soundHandle->numRegions);
assert(soundHandle && checkForProperHandle(soundHandle));
assert(buf && offset >= 0 && size >= 0);
assert(region >= 0 && region < soundHandle->numRegions);