Add voice channel tracking to stop script race in BumpusVille VR.
svn-id: r4048
This commit is contained in:
parent
d0d3316634
commit
d447f05709
5 changed files with 49 additions and 28 deletions
|
@ -1652,6 +1652,7 @@ void Scumm::o6_isSoundRunning()
|
|||
int snd = pop();
|
||||
if (snd)
|
||||
snd = isSoundRunning(snd);
|
||||
|
||||
push(snd);
|
||||
}
|
||||
|
||||
|
@ -2328,6 +2329,8 @@ void Scumm::o6_wait()
|
|||
return;
|
||||
}
|
||||
case 169:
|
||||
//printf("waiting for message: %d\n", _vars[VAR_HAVE_MSG]);
|
||||
|
||||
if (_vars[VAR_HAVE_MSG])
|
||||
break;
|
||||
return;
|
||||
|
@ -2342,6 +2345,7 @@ void Scumm::o6_wait()
|
|||
|
||||
return;
|
||||
case 171:
|
||||
printf("wait for sentence");
|
||||
if (_sentenceNum) {
|
||||
if (sentence[_sentenceNum - 1].unk &&
|
||||
!isScriptInUse(_vars[VAR_SENTENCE_SCRIPT]))
|
||||
|
|
7
scumm.h
7
scumm.h
|
@ -1002,10 +1002,10 @@ public:
|
|||
void clearSoundQue();
|
||||
void talkSound(uint32 a, uint32 b, int mode);
|
||||
void processSfxQueues();
|
||||
void startTalkSound(uint32 a, uint32 b, int mode);
|
||||
int startTalkSound(uint32 a, uint32 b, int mode);
|
||||
void stopTalkSound();
|
||||
bool isMouthSyncOff(uint pos);
|
||||
void startSfxSound(void *file, int size);
|
||||
int startSfxSound(void *file, int size);
|
||||
void *openSfxFile();
|
||||
void addSoundToQueue(int sound);
|
||||
void addSoundToQueue2(int sound);
|
||||
|
@ -1016,10 +1016,11 @@ public:
|
|||
void pauseSounds(bool pause);
|
||||
bool isSfxFinished();
|
||||
void playBundleSound(char *sound);
|
||||
void playSfxSound(void *sound, uint32 size, uint rate);
|
||||
int playSfxSound(void *sound, uint32 size, uint rate);
|
||||
void playSfxSound_MP3(void *sound, uint32 size);
|
||||
void stopSfxSound();
|
||||
|
||||
int _talkChannel; /* Mixer channel actor is talking on */
|
||||
bool _useTalkAnims;
|
||||
uint16 _defaultTalkDelay;
|
||||
byte _haveMsg;
|
||||
|
|
49
sound.cpp
49
sound.cpp
|
@ -128,13 +128,22 @@ void Scumm::processSfxQueues()
|
|||
bool b, finished;
|
||||
|
||||
if (_talk_sound_mode != 0) {
|
||||
startTalkSound(_talk_sound_a, _talk_sound_b, _talk_sound_mode);
|
||||
if (_talk_sound_mode == 2)
|
||||
_talkChannel = startTalkSound(_talk_sound_a, _talk_sound_b, _talk_sound_mode);
|
||||
else
|
||||
startTalkSound(_talk_sound_a, _talk_sound_b, _talk_sound_mode);
|
||||
_talk_sound_mode = 0;
|
||||
}
|
||||
|
||||
if (_sfxMode == 2) {
|
||||
if (_vars[VAR_TALK_ACTOR]) { //_sfxMode == 2) {
|
||||
act = _vars[VAR_TALK_ACTOR];
|
||||
finished = isSfxFinished();
|
||||
if (_talkChannel < 0)
|
||||
finished = false;
|
||||
else if (this->_mixer->_channels[_talkChannel] == NULL)
|
||||
finished = true;
|
||||
else
|
||||
finished = false;
|
||||
|
||||
|
||||
if (act != 0 && (uint) act < 0x80 && !string[0].no_talk_anim) {
|
||||
a = derefActorSafe(act, "processSfxQueues");
|
||||
|
@ -148,11 +157,15 @@ void Scumm::processSfxQueues()
|
|||
}
|
||||
}
|
||||
}
|
||||
if (finished && _talkDelay == 0) {
|
||||
|
||||
if (finished && _talkDelay == 0) {
|
||||
stopTalk();
|
||||
_sfxMode = 0;
|
||||
_talkChannel = -1;
|
||||
}
|
||||
} else if (_sfxMode == 1) {
|
||||
}
|
||||
|
||||
if (_sfxMode == 1) {
|
||||
if (isSfxFinished()) {
|
||||
_sfxMode = 0;
|
||||
}
|
||||
|
@ -167,7 +180,7 @@ static int compar(const void *a, const void *b)
|
|||
}
|
||||
#endif
|
||||
|
||||
void Scumm::startTalkSound(uint32 offset, uint32 b, int mode)
|
||||
int Scumm::startTalkSound(uint32 offset, uint32 b, int mode)
|
||||
{
|
||||
int num = 0, i;
|
||||
byte file_byte, file_byte_2;
|
||||
|
@ -175,7 +188,7 @@ void Scumm::startTalkSound(uint32 offset, uint32 b, int mode)
|
|||
|
||||
if (!_sfxFile) {
|
||||
warning("startTalkSound: SFX file is not open");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (b > 8) {
|
||||
|
@ -220,7 +233,7 @@ void Scumm::startTalkSound(uint32 offset, uint32 b, int mode)
|
|||
_curSoundPos = 0;
|
||||
_mouthSyncMode = true;
|
||||
|
||||
startSfxSound(_sfxFile, size);
|
||||
return startSfxSound(_sfxFile, size);
|
||||
}
|
||||
|
||||
void Scumm::stopTalkSound()
|
||||
|
@ -409,7 +422,7 @@ enum {
|
|||
|
||||
};
|
||||
|
||||
void Scumm::startSfxSound(void *file, int file_size)
|
||||
int Scumm::startSfxSound(void *file, int file_size)
|
||||
{
|
||||
char ident[8];
|
||||
int block_type;
|
||||
|
@ -441,13 +454,13 @@ void Scumm::startSfxSound(void *file, int file_size)
|
|||
} else {
|
||||
invalid:;
|
||||
warning("startSfxSound: invalid header");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
block_type = getc((FILE *) file);
|
||||
if (block_type != 1) {
|
||||
warning("startSfxSound: Expecting block_type == 1, got %d", block_type);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
fread(work, 3, 1, (FILE *) file);
|
||||
|
@ -458,19 +471,19 @@ void Scumm::startSfxSound(void *file, int file_size)
|
|||
|
||||
if (comp != 0) {
|
||||
warning("startSfxSound: Unsupported compression type %d", comp);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
data = (byte *)malloc(size);
|
||||
if (data == NULL) {
|
||||
error("startSfxSound: out of memory");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fread(data, size, 1, (FILE *) file) != 1) {
|
||||
/* no need to free the memory since error will shut down */
|
||||
error("startSfxSound: cannot read %d bytes", size);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < size; i++) {
|
||||
// Fixme: From WinCE port
|
||||
|
@ -479,7 +492,7 @@ void Scumm::startSfxSound(void *file, int file_size)
|
|||
|
||||
data[i] ^= 0x80;
|
||||
}
|
||||
playSfxSound(data, size, 1000000 / (256 - rate));
|
||||
return playSfxSound(data, size, 1000000 / (256 - rate));
|
||||
}
|
||||
|
||||
|
||||
|
@ -584,11 +597,11 @@ void Scumm::playBundleSound(char *sound)
|
|||
warning("playBundleSound: %s", sound);
|
||||
}
|
||||
|
||||
void Scumm::playSfxSound(void *sound, uint32 size, uint rate)
|
||||
int Scumm::playSfxSound(void *sound, uint32 size, uint rate)
|
||||
{
|
||||
if (_soundsPaused)
|
||||
return;
|
||||
_mixer->play_raw(NULL, sound, size, rate, SoundMixer::FLAG_AUTOFREE);
|
||||
return -1;
|
||||
return _mixer->play_raw(NULL, sound, size, rate, SoundMixer::FLAG_AUTOFREE);
|
||||
}
|
||||
|
||||
void Scumm::playSfxSound_MP3(void *sound, uint32 size)
|
||||
|
|
|
@ -38,24 +38,26 @@ void SoundMixer::uninsert(Channel *chan) {
|
|||
error("SoundMixer::channel_deleted chan not found");
|
||||
}
|
||||
|
||||
void SoundMixer::insert(PlayingSoundHandle *handle, Channel *chan) {
|
||||
int SoundMixer::insert(PlayingSoundHandle *handle, Channel *chan) {
|
||||
for(int i=0; i!=NUM_CHANNELS; i++) {
|
||||
if (_channels[i] == NULL) {
|
||||
_channels[i] = chan;
|
||||
_handles[i] = handle;
|
||||
if (handle)
|
||||
*handle = i + 1;
|
||||
return;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
warning("SoundMixer::insert out of mixer slots");
|
||||
chan->destroy();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void SoundMixer::play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags) {
|
||||
insert(handle, new Channel_RAW(this, sound, size, rate, flags));
|
||||
int SoundMixer::play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags) {
|
||||
return insert(handle, new Channel_RAW(this, sound, size, rate, flags));
|
||||
}
|
||||
|
||||
#ifdef COMPRESSED_SOUND_FILE
|
||||
|
@ -202,8 +204,9 @@ void SoundMixer::Channel_RAW::mix(int16 *data, uint len) {
|
|||
free(s_org);
|
||||
}
|
||||
|
||||
if (!_size)
|
||||
if (_size < 1)
|
||||
destroy();
|
||||
|
||||
}
|
||||
|
||||
void SoundMixer::Channel_RAW::destroy() {
|
||||
|
|
|
@ -115,7 +115,7 @@ public:
|
|||
Channel *_channels[NUM_CHANNELS];
|
||||
PlayingSoundHandle *_handles[NUM_CHANNELS];
|
||||
|
||||
void insert(PlayingSoundHandle *handle, Channel *chan);
|
||||
int insert(PlayingSoundHandle *handle, Channel *chan);
|
||||
void uninsert(Channel *chan);
|
||||
|
||||
/* start playing a raw sound */
|
||||
|
@ -124,7 +124,7 @@ public:
|
|||
FLAG_UNSIGNED = 2, /* unsigned samples */
|
||||
FLAG_FILE = 4, /* sound is a FILE * that's read from */
|
||||
};
|
||||
void play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags);
|
||||
int play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags);
|
||||
#ifdef COMPRESSED_SOUND_FILE
|
||||
void play_mp3(PlayingSoundHandle *handle, void *sound, uint32 size, byte flags);
|
||||
void play_mp3_cdtrack(PlayingSoundHandle *handle, FILE* file, void *buffer, uint32 buffer_size, mad_timer_t duration);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue