mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 16:33:50 +00:00
implemented priorites for imuse sounds
svn-id: r13392
This commit is contained in:
parent
ab64ef93ec
commit
7041ba3568
@ -226,10 +226,46 @@ void IMuseDigital::switchToNextRegion(int track) {
|
||||
_track[track].regionOffset = 0;
|
||||
}
|
||||
|
||||
void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, int soundGroup, AudioStream *input, int hookId, int volume) {
|
||||
void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, int soundGroup, AudioStream *input, int hookId, int volume, int priority) {
|
||||
Common::StackLock lock(_mutex, g_system, "IMuseDigital::startSound()");
|
||||
debug(5, "IMuseDigital::startSound(%d)", soundId);
|
||||
int l;
|
||||
int lower_priority = 127;
|
||||
bool found_free = false;
|
||||
|
||||
for (l = 0; l < MAX_DIGITAL_TRACKS; l++) {
|
||||
if (!_track[l].used && !_track[l].handle.isActive())
|
||||
found_free = true;
|
||||
}
|
||||
|
||||
if (!found_free) {
|
||||
warning("IMuseDigital::startSound(): All slots are full");
|
||||
for (l = 0; l < MAX_DIGITAL_TRACKS; l++) {
|
||||
if (_track[l].used && _track[l].handle.isActive() &&
|
||||
(lower_priority > _track[l].priority) && (!_track[l].stream2))
|
||||
lower_priority = _track[l].priority;
|
||||
}
|
||||
if (lower_priority <= priority) {
|
||||
int track_id = -1;
|
||||
for (l = 0; l < MAX_DIGITAL_TRACKS; l++) {
|
||||
if (_track[l].used && _track[l].handle.isActive() &&
|
||||
(lower_priority == _track[l].priority) && (!_track[l].stream2)) {
|
||||
track_id = l;
|
||||
}
|
||||
}
|
||||
assert(track_id != -1);
|
||||
_track[track_id].stream->finish();
|
||||
_track[track_id].stream = NULL;
|
||||
_vm->_mixer->stopHandle(_track[track_id].handle);
|
||||
_sound->closeSound(_track[track_id].soundHandle);
|
||||
_track[track_id].used = false;
|
||||
assert(!_track[track_id].handle.isActive());
|
||||
warning("IMuseDigital::startSound(): Removed sound %d from track %d", _track[track_id].soundId, track_id);
|
||||
} else {
|
||||
warning("IMuseDigital::startSound(): Priority sound too low");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (l = 0; l < MAX_DIGITAL_TRACKS; l++) {
|
||||
if (!_track[l].used && !_track[l].handle.isActive()) {
|
||||
@ -243,6 +279,7 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
|
||||
_track[l].started = false;
|
||||
_track[l].soundGroup = soundGroup;
|
||||
_track[l].curHookId = hookId;
|
||||
_track[l].priority = priority;
|
||||
_track[l].curRegion = -1;
|
||||
_track[l].dataOffset = 0;
|
||||
_track[l].regionOffset = 0;
|
||||
@ -315,7 +352,9 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
|
||||
return;
|
||||
}
|
||||
}
|
||||
warning("IMuseDigital::startSound(): All slots are full");
|
||||
|
||||
warning("it should not happen");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void IMuseDigital::stopSound(int soundId) {
|
||||
@ -332,6 +371,19 @@ void IMuseDigital::stopSound(int soundId) {
|
||||
}
|
||||
}
|
||||
|
||||
void IMuseDigital::setPriority(int soundId, int priority) {
|
||||
Common::StackLock lock(_mutex, g_system, "IMuseDigital::setPriority()");
|
||||
debug(5, "IMuseDigital::setPrioritySound(%d, %d)", soundId, priority);
|
||||
|
||||
assert ((priority >= 0) && (priority <= 127));
|
||||
|
||||
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
|
||||
if ((_track[l].soundId == soundId) && _track[l].used) {
|
||||
_track[l].priority = priority;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IMuseDigital::setVolume(int soundId, int volume) {
|
||||
Common::StackLock lock(_mutex, g_system, "IMuseDigital::setVolume()");
|
||||
debug(5, "IMuseDigital::setVolumeSound(%d, %d)", soundId, volume);
|
||||
@ -448,7 +500,8 @@ void IMuseDigital::parseScriptCmds(int a, int b, int c, int d, int e, int f, int
|
||||
case 0x400: // set group volume
|
||||
debug(5, "set group volume (0x400), soundId(%d), group volume(%d)", soundId, d);
|
||||
break;
|
||||
case 0x500: // set priority - could be ignored
|
||||
case 0x500: // set priority
|
||||
setPriority(soundId, d);
|
||||
break;
|
||||
case 0x600: // set volume
|
||||
setVolume(soundId, d);
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
namespace Scumm {
|
||||
|
||||
#define MAX_DIGITAL_TRACKS 16
|
||||
#define MAX_DIGITAL_TRACKS 8
|
||||
|
||||
struct imuseDigTable;
|
||||
struct imuseComiTable;
|
||||
@ -53,6 +53,7 @@ private:
|
||||
bool used;
|
||||
bool toBeRemoved;
|
||||
bool started;
|
||||
int priority;
|
||||
int32 regionOffset;
|
||||
int32 trackOffset;
|
||||
int32 dataOffset;
|
||||
@ -87,7 +88,7 @@ private:
|
||||
static void timer_handler(void *refConf);
|
||||
void callback();
|
||||
void switchToNextRegion(int track);
|
||||
void startSound(int soundId, const char *soundName, int soundType, int soundGroup, AudioStream *input, int hookId, int volume);
|
||||
void startSound(int soundId, const char *soundName, int soundType, int soundGroup, AudioStream *input, int hookId, int volume, int priority);
|
||||
|
||||
int32 getPosInMs(int soundId);
|
||||
void getLipSync(int soundId, int syncId, int32 msPos, int32 &width, int32 &height);
|
||||
@ -113,15 +114,15 @@ public:
|
||||
virtual ~IMuseDigital();
|
||||
|
||||
void startVoice(int soundId, AudioStream *input)
|
||||
{ debug(5, "startVoiceStream(%d)", soundId); startSound(soundId, NULL, 0, IMUSE_VOICE, input, 0, 127); }
|
||||
{ debug(5, "startVoiceStream(%d)", soundId); startSound(soundId, NULL, 0, IMUSE_VOICE, input, 0, 127, 127); }
|
||||
void startVoice(int soundId, const char *soundName)
|
||||
{ debug(5, "startVoiceBundle(%s)", soundName); startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_VOICE, NULL, 0, 127); }
|
||||
{ debug(5, "startVoiceBundle(%s)", soundName); startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_VOICE, NULL, 0, 127, 127); }
|
||||
void startMusic(int soundId, int volume)
|
||||
{ debug(5, "startMusicResource(%d)", soundId); startSound(soundId, NULL, IMUSE_RESOURCE, IMUSE_MUSIC, NULL, 0, volume); }
|
||||
{ debug(5, "startMusicResource(%d)", soundId); startSound(soundId, NULL, IMUSE_RESOURCE, IMUSE_MUSIC, NULL, 0, volume, 126); }
|
||||
void startMusic(const char *soundName, int soundId, int hookId, int volume)
|
||||
{ debug(5, "startMusicBundle(%s)", soundName); startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_MUSIC, NULL, hookId, volume); }
|
||||
void startSfx(int soundId)
|
||||
{ debug(5, "startSfx(%d)", soundId); startSound(soundId, NULL, IMUSE_RESOURCE, IMUSE_SFX, NULL, 0, 127); }
|
||||
{ debug(5, "startMusicBundle(%s)", soundName); startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_MUSIC, NULL, hookId, volume, 126); }
|
||||
void startSfx(int soundId, int priority)
|
||||
{ debug(5, "startSfx(%d)", soundId); startSound(soundId, NULL, IMUSE_RESOURCE, IMUSE_SFX, NULL, 0, 127, priority); }
|
||||
void startSound(int soundId)
|
||||
{ error("MusicEngine::startSound() Should be never called"); }
|
||||
void resetState() {
|
||||
@ -132,6 +133,7 @@ public:
|
||||
_curSeqAtribPos = 0;
|
||||
}
|
||||
|
||||
void setPriority(int soundId, int priority);
|
||||
void setVolume(int soundId, int volume);
|
||||
void setPan(int soundId, int pan);
|
||||
void setFade(int soundId, int destVolume, int delay60HzTicks);
|
||||
|
@ -1194,7 +1194,7 @@ bool Insane::smlayer_isSoundRunning(int32 sound) {
|
||||
|
||||
bool Insane::smlayer_startSfx(int32 sound) {
|
||||
if (smlayer_loadSound(sound, 0, 2)) {
|
||||
_vm->_imuseDigital->startSfx(readArray(sound));
|
||||
_vm->_imuseDigital->startSfx(readArray(sound), 40);
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
@ -1202,7 +1202,7 @@ bool Insane::smlayer_startSfx(int32 sound) {
|
||||
|
||||
bool Insane::smlayer_startVoice(int32 sound) {
|
||||
if (smlayer_loadSound(sound, 0, 2)) {
|
||||
_vm->_imuseDigital->startSfx(readArray(sound));
|
||||
_vm->_imuseDigital->startSfx(readArray(sound), 126);
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
@ -1212,7 +1212,8 @@ void Insane::smlayer_soundSetPan(int32 soundId, int32 pan) {
|
||||
_vm->_imuseDigital->setPan(soundId, pan);
|
||||
}
|
||||
|
||||
void Insane::smlayer_soundSetPriority(int32 sound, int32 priority) {
|
||||
void Insane::smlayer_soundSetPriority(int32 soundId, int32 priority) {
|
||||
_vm->_imuseDigital->setPriority(soundId, priority);
|
||||
}
|
||||
|
||||
void Insane::smlayer_drawSomething(byte *renderBitmap, int32 codecparam,
|
||||
|
Loading…
x
Reference in New Issue
Block a user