aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2010-06-12 11:41:22 +0000
committerFilippos Karapetis2010-06-12 11:41:22 +0000
commitf4739f9f68026d5e3ea3304777260cef3101a031 (patch)
treede77b05835741f85608bdb35661988d567aafda2
parent277a700e6743b481eba8efb86fe37c339d880279 (diff)
downloadscummvm-rg350-f4739f9f68026d5e3ea3304777260cef3101a031.tar.gz
scummvm-rg350-f4739f9f68026d5e3ea3304777260cef3101a031.tar.bz2
scummvm-rg350-f4739f9f68026d5e3ea3304777260cef3101a031.zip
Added debug output to kDoAudio and some music commands. Also added a warning when an audio stream can't be created. Finally, the debug level of the MIDI parser debug output has been raised to 4, as it's too verbose
svn-id: r49605
-rw-r--r--engines/sci/engine/ksound.cpp15
-rw-r--r--engines/sci/sound/audio.cpp4
-rw-r--r--engines/sci/sound/midiparser_sci.cpp30
-rw-r--r--engines/sci/sound/soundcmd.cpp9
4 files changed, 39 insertions, 19 deletions
diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index ebfd6e6885..8cf9400353 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -119,6 +119,8 @@ reg_t kDoAudio(EngineState *s, int argc, reg_t *argv) {
return NULL_REG;
}
+ debugC(2, kDebugLevelSound, "kDoAudio: play sample %d, module %d", number, module);
+
// return sample length in ticks
if (argv[0].toUint16() == kSciAudioWPlay)
return make_reg(0, g_sci->_audio->wPlayAudio(module, number));
@@ -126,31 +128,39 @@ reg_t kDoAudio(EngineState *s, int argc, reg_t *argv) {
return make_reg(0, g_sci->_audio->startAudio(module, number));
}
case kSciAudioStop:
+ debugC(2, kDebugLevelSound, "kDoAudio: stop");
g_sci->_audio->stopAudio();
break;
case kSciAudioPause:
+ debugC(2, kDebugLevelSound, "kDoAudio: pause");
g_sci->_audio->pauseAudio();
break;
case kSciAudioResume:
+ debugC(2, kDebugLevelSound, "kDoAudio: resume");
g_sci->_audio->resumeAudio();
break;
case kSciAudioPosition:
+ //debugC(2, kDebugLevelSound, "kDoAudio: get position"); // too verbose
return make_reg(0, g_sci->_audio->getAudioPosition());
case kSciAudioRate:
+ debugC(2, kDebugLevelSound, "kDoAudio: set audio rate to %d", argv[1].toUint16());
g_sci->_audio->setAudioRate(argv[1].toUint16());
break;
case kSciAudioVolume: {
int16 volume = argv[1].toUint16();
volume = CLIP<int16>(volume, 0, AUDIO_VOLUME_MAX);
+ debugC(2, kDebugLevelSound, "kDoAudio: set volume to %d", volume);
mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volume * 2);
break;
}
case kSciAudioLanguage:
// In SCI1.1: tests for digital audio support
- if (getSciVersion() == SCI_VERSION_1_1)
+ if (getSciVersion() == SCI_VERSION_1_1) {
+ debugC(2, kDebugLevelSound, "kDoAudio: audio capability test");
return make_reg(0, 1);
- else {
+ } else {
int16 language = argv[1].toSint16();
+ debugC(2, kDebugLevelSound, "kDoAudio: set language to %d", language);
if (language != -1)
g_sci->getResMan()->setAudioLanguage(language);
@@ -162,6 +172,7 @@ reg_t kDoAudio(EngineState *s, int argc, reg_t *argv) {
}
break;
case kSciAudioCD:
+ debugC(2, kDebugLevelSound, "kDoAudio: CD audio subop");
return kDoCdAudio(s, argc - 1, argv + 1);
// TODO: There are 3 more functions used in Freddy Pharkas (11, 12 and 13) and new within sierra sci
// Details currently unknown
diff --git a/engines/sci/sound/audio.cpp b/engines/sci/sound/audio.cpp
index 62cfcd9621..b0b9a73e00 100644
--- a/engines/sci/sound/audio.cpp
+++ b/engines/sci/sound/audio.cpp
@@ -69,6 +69,8 @@ int AudioPlayer::startAudio(uint16 module, uint32 number) {
_wPlayFlag = false;
_mixer->playStream(Audio::Mixer::kSpeechSoundType, &_audioHandle, audioStream);
return sampleLen;
+ } else {
+ warning("startAudio: unable to create stream for audio number %d, module %d", number, module);
}
return 0;
@@ -81,6 +83,8 @@ int AudioPlayer::wPlayAudio(uint16 module, uint32 tuple) {
int sampleLen = 0;
Audio::AudioStream *audioStream = getAudioStream(module, tuple, &sampleLen);
+ if (!audioStream)
+ warning("wPlayAudio: unable to create stream for audio tuple %d, module %d", tuple, module);
delete audioStream;
_wPlayFlag = true;
return sampleLen;
diff --git a/engines/sci/sound/midiparser_sci.cpp b/engines/sci/sound/midiparser_sci.cpp
index f852367bfe..bb353da780 100644
--- a/engines/sci/sound/midiparser_sci.cpp
+++ b/engines/sci/sound/midiparser_sci.cpp
@@ -148,12 +148,12 @@ void MidiParser_SCI::parseNextEvent(EventInfo &info) {
_dataincAdd = false;
_pSnd->dataInc += _dataincToAdd;
_pSnd->signal = 0x7f + _pSnd->dataInc;
- debugC(2, kDebugLevelSound, "datainc %04x", _dataincToAdd);
+ debugC(4, kDebugLevelSound, "datainc %04x", _dataincToAdd);
}
if (_signalSet) {
_signalSet = false;
_pSnd->signal = _signalToSet;
- debugC(2, kDebugLevelSound, "signal %04x", _signalToSet);
+ debugC(4, kDebugLevelSound, "signal %04x", _signalToSet);
}
info.start = _position._play_pos;
@@ -313,7 +313,7 @@ void MidiParser_SCI::parseNextEvent(EventInfo &info) {
_pSnd->status = kSoundStopped;
_pSnd->signal = SIGNAL_OFFSET;
- debugC(2, kDebugLevelSound, "signal EOT");
+ debugC(4, kDebugLevelSound, "signal EOT");
}
}
break;
@@ -376,21 +376,21 @@ byte *MidiParser_SCI::midiMixChannels() {
command = *channel->data++;
if (command != kEndOfTrack) {
- debugC(2, kDebugLevelSound, "\nDELTA ");
+ debugC(4, kDebugLevelSound, "\nDELTA ");
// Write delta
while (new_delta > 240) {
*outData++ = 0xF8;
- debugC(2, kDebugLevelSound, "F8 ");
+ debugC(4, kDebugLevelSound, "F8 ");
new_delta -= 240;
}
*outData++ = (byte)new_delta;
- debugC(2, kDebugLevelSound, "%02X ", (uint32)new_delta);
+ debugC(4, kDebugLevelSound, "%02X ", (uint32)new_delta);
}
// Write command
switch (command) {
case 0xF0: // sysEx
*outData++ = command;
- debugC(2, kDebugLevelSound, "%02X ", command);
+ debugC(4, kDebugLevelSound, "%02X ", command);
do {
par1 = *channel->data++;
*outData++ = par1; // out
@@ -478,22 +478,22 @@ byte *MidiParser_SCI::midiFilterChannels(int channelMask) {
}
if ((1 << curChannel) & channelMask) {
if (command != kEndOfTrack) {
- debugC(2, kDebugLevelSound, "\nDELTA ");
+ debugC(4, kDebugLevelSound, "\nDELTA ");
// Write delta
while (delta > 240) {
*outData++ = 0xF8;
- debugC(2, kDebugLevelSound, "F8 ");
+ debugC(4, kDebugLevelSound, "F8 ");
delta -= 240;
}
*outData++ = (byte)delta;
- debugC(2, kDebugLevelSound, "%02X ", delta);
+ debugC(4, kDebugLevelSound, "%02X ", delta);
delta = 0;
}
// Write command
switch (command) {
case 0xF0: // sysEx
*outData++ = command;
- debugC(2, kDebugLevelSound, "%02X ", command);
+ debugC(4, kDebugLevelSound, "%02X ", command);
do {
curByte = *channelData++;
*outData++ = curByte; // out
@@ -507,20 +507,20 @@ byte *MidiParser_SCI::midiFilterChannels(int channelMask) {
default: // MIDI command
if (lastCommand != command) {
*outData++ = command;
- debugC(2, kDebugLevelSound, "%02X ", command);
+ debugC(4, kDebugLevelSound, "%02X ", command);
lastCommand = command;
}
if (midiParamCount > 0) {
if (curByte & 0x80) {
- debugC(2, kDebugLevelSound, "%02X ", *channelData);
+ debugC(4, kDebugLevelSound, "%02X ", *channelData);
*outData++ = *channelData++;
} else {
- debugC(2, kDebugLevelSound, "%02X ", curByte);
+ debugC(4, kDebugLevelSound, "%02X ", curByte);
*outData++ = curByte;
}
}
if (midiParamCount > 1) {
- debugC(2, kDebugLevelSound, "%02X ", *channelData);
+ debugC(4, kDebugLevelSound, "%02X ", *channelData);
*outData++ = *channelData++;
}
}
diff --git a/engines/sci/sound/soundcmd.cpp b/engines/sci/sound/soundcmd.cpp
index 2bbc5b44de..71fc2b7ef0 100644
--- a/engines/sci/sound/soundcmd.cpp
+++ b/engines/sci/sound/soundcmd.cpp
@@ -307,6 +307,9 @@ void SoundCommandParser::cmdInitSound(reg_t obj, int16 value) {
if (_soundVersion >= SCI_VERSION_1_EARLY)
newSound->volume = CLIP<int>(readSelectorValue(_segMan, obj, SELECTOR(vol)), 0, MUSIC_VOLUME_MAX);
+ debugC(2, kDebugLevelSound, "cmdInitSound, number %d, loop %d, prio %d, vol %d", resourceId,
+ newSound->loop, newSound->priority, newSound->volume);
+
// In SCI1.1 games, sound effects are started from here. If we can find
// a relevant audio resource, play it, otherwise switch to synthesized
// effects. If the resource exists, play it using map 65535 (sound
@@ -423,8 +426,6 @@ void SoundCommandParser::cmdPlaySound(reg_t obj, int16 value) {
// Find slot again :)
musicSlot = _music->getSlot(obj);
}
- int16 loop = readSelectorValue(_segMan, obj, SELECTOR(loop));
- debugC(2, kDebugLevelSound, "cmdPlaySound: resource number %d, loop %d", resourceId, loop);
writeSelector(_segMan, obj, SELECTOR(handle), obj);
@@ -442,6 +443,10 @@ void SoundCommandParser::cmdPlaySound(reg_t obj, int16 value) {
musicSlot->priority = readSelectorValue(_segMan, obj, SELECTOR(priority));
if (_soundVersion >= SCI_VERSION_1_EARLY)
musicSlot->volume = readSelectorValue(_segMan, obj, SELECTOR(vol));
+
+ debugC(2, kDebugLevelSound, "cmdPlaySound, number %d, loop %d, prio %d, vol %d", resourceId,
+ musicSlot->loop, musicSlot->priority, musicSlot->volume);
+
_music->soundPlay(musicSlot);
#endif