turned PlayingSoundHandle into an 'opaque' (well not really :-) data type, mainly because people kept (accidentally and sometimes on purpose :-) misusing them
svn-id: r11881
This commit is contained in:
parent
3f77642948
commit
e9269257f3
22 changed files with 63 additions and 66 deletions
|
@ -33,7 +33,7 @@
|
||||||
namespace Queen {
|
namespace Queen {
|
||||||
|
|
||||||
Sound::Sound(SoundMixer *mixer, QueenEngine *vm) :
|
Sound::Sound(SoundMixer *mixer, QueenEngine *vm) :
|
||||||
_mixer(mixer), _vm(vm), _sfxToggle(true), _speechToggle(true), _musicToggle(true), _lastOverride(0), _currentSong(0), _sfxHandle(0) {
|
_mixer(mixer), _vm(vm), _sfxToggle(true), _speechToggle(true), _musicToggle(true), _lastOverride(0), _currentSong(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Sound::~Sound() {
|
Sound::~Sound() {
|
||||||
|
@ -68,7 +68,7 @@ Sound *Sound::giveSound(SoundMixer *mixer, QueenEngine *vm, uint8 compression) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::waitSfxFinished() {
|
void Sound::waitSfxFinished() {
|
||||||
while(_sfxHandle != 0)
|
while(_sfxHandle.isActive())
|
||||||
_vm->input()->delay(10);
|
_vm->input()->delay(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -805,7 +805,7 @@ void IMuseDigital::mixerCallback() {
|
||||||
_channel[l].offset += mixer_size;
|
_channel[l].offset += mixer_size;
|
||||||
|
|
||||||
if (_scumm->_silentDigitalImuse == false) {
|
if (_scumm->_silentDigitalImuse == false) {
|
||||||
if (_channel[l].handle == 0)
|
if (!_channel[l].handle.isActive())
|
||||||
_scumm->_mixer->newStream(&_channel[l].handle, _channel[l].freq,
|
_scumm->_mixer->newStream(&_channel[l].handle, _channel[l].freq,
|
||||||
_channel[l].mixerFlags, 100000);
|
_channel[l].mixerFlags, 100000);
|
||||||
_scumm->_mixer->setChannelVolume(_channel[l].handle, _channel[l].vol / 1000);
|
_scumm->_mixer->setChannelVolume(_channel[l].handle, _channel[l].vol / 1000);
|
||||||
|
@ -821,7 +821,7 @@ void IMuseDigital::startSound(int sound) {
|
||||||
int l, r;
|
int l, r;
|
||||||
|
|
||||||
for (l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
|
for (l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
|
||||||
if (!_channel[l].used && !_channel[l].handle) {
|
if (!_channel[l].used && !_channel[l].handle.isActive()) {
|
||||||
byte *ptr = _scumm->getResourceAddress(rtSound, sound);
|
byte *ptr = _scumm->getResourceAddress(rtSound, sound);
|
||||||
byte *s_ptr = ptr;
|
byte *s_ptr = ptr;
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
|
@ -1290,7 +1290,6 @@ void IMuseDigital::playBundleMusic(const char *song) {
|
||||||
_bundleSongPosInMs = 0;
|
_bundleSongPosInMs = 0;
|
||||||
_pauseBundleMusic = false;
|
_pauseBundleMusic = false;
|
||||||
_musicBundleToBeChanged = false;
|
_musicBundleToBeChanged = false;
|
||||||
_bundleMusicTrack = 0;
|
|
||||||
_numberSamplesBundleMusic = _bundle->getNumberOfMusicSamplesByName(song);
|
_numberSamplesBundleMusic = _bundle->getNumberOfMusicSamplesByName(song);
|
||||||
_nameBundleMusic = song;
|
_nameBundleMusic = song;
|
||||||
_scumm->_timer->installTimerProc(&music_handler, 1000000, this);
|
_scumm->_timer->installTimerProc(&music_handler, 1000000, this);
|
||||||
|
@ -1423,7 +1422,7 @@ void IMuseDigital::bundleMusicHandler() {
|
||||||
|
|
||||||
_bundleSongPosInMs = (_bundleMusicPosition * 5) / (_outputMixerSize / 200);
|
_bundleSongPosInMs = (_bundleMusicPosition * 5) / (_outputMixerSize / 200);
|
||||||
_bundleMusicPosition += final_size;
|
_bundleMusicPosition += final_size;
|
||||||
if (_bundleMusicTrack == 0)
|
if (!_bundleMusicTrack.isActive())
|
||||||
_scumm->_mixer->newStream(&_bundleMusicTrack, rate, SoundMixer::FLAG_16BITS | SoundMixer::FLAG_STEREO, 300000);
|
_scumm->_mixer->newStream(&_bundleMusicTrack, rate, SoundMixer::FLAG_16BITS | SoundMixer::FLAG_STEREO, 300000);
|
||||||
_scumm->_mixer->appendStream(_bundleMusicTrack, buffer, final_size);
|
_scumm->_mixer->appendStream(_bundleMusicTrack, buffer, final_size);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "scumm/player_mod.h"
|
#include "scumm/player_mod.h"
|
||||||
|
#include "sound/audiostream.h"
|
||||||
|
#include "sound/mixer.h"
|
||||||
|
#include "sound/rate.h"
|
||||||
|
|
||||||
namespace Scumm {
|
namespace Scumm {
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,9 @@
|
||||||
#define PLAYER_MOD_H
|
#define PLAYER_MOD_H
|
||||||
|
|
||||||
#include "scumm/scumm.h"
|
#include "scumm/scumm.h"
|
||||||
#include "sound/mixer.h"
|
|
||||||
#include "sound/audiostream.h"
|
class AudioInputStream;
|
||||||
#include "sound/rate.h"
|
class RateConverter;
|
||||||
|
|
||||||
namespace Scumm {
|
namespace Scumm {
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@ SmushMixer::SmushMixer(SoundMixer *m) :
|
||||||
for (int32 i = 0; i < NUM_CHANNELS; i++) {
|
for (int32 i = 0; i < NUM_CHANNELS; i++) {
|
||||||
_channels[i].id = -1;
|
_channels[i].id = -1;
|
||||||
_channels[i].chan = NULL;
|
_channels[i].chan = NULL;
|
||||||
_channels[i].handle = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,19 +69,17 @@ void SmushMixer::addChannel(SmushChannel *c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < NUM_CHANNELS; i++) {
|
for (i = 0; i < NUM_CHANNELS; i++) {
|
||||||
if ((_channels[i].chan == NULL || _channels[i].id == -1) && _channels[i].handle == 0) {
|
if ((_channels[i].chan == NULL || _channels[i].id == -1) && !_channels[i].handle.isActive()) {
|
||||||
_channels[i].chan = c;
|
_channels[i].chan = c;
|
||||||
_channels[i].id = track;
|
_channels[i].id = track;
|
||||||
_channels[i].handle = 0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < NUM_CHANNELS; i++) {
|
for (i = 0; i < NUM_CHANNELS; i++) {
|
||||||
warning("channel %d : %p(%d, %d) %d %d", i, (void *)_channels[i].chan,
|
warning("channel %d : %p(%d, %d) %d", i, (void *)_channels[i].chan,
|
||||||
_channels[i].chan ? _channels[i].chan->getTrackIdentifier() : -1,
|
_channels[i].chan ? _channels[i].chan->getTrackIdentifier() : -1,
|
||||||
_channels[i].chan ? _channels[i].chan->isTerminated() : 1,
|
_channels[i].chan ? _channels[i].chan->isTerminated() : 1);
|
||||||
_channels[i].handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error("SmushMixer::addChannel(%d): no channel available", track);
|
error("SmushMixer::addChannel(%d): no channel available", track);
|
||||||
|
@ -122,7 +119,7 @@ bool SmushMixer::handleFrame() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_silentMixer == false) {
|
if (_silentMixer == false) {
|
||||||
if (_channels[i].handle == 0)
|
if (!_channels[i].handle.isActive())
|
||||||
_mixer->newStream(&_channels[i].handle, rate, flags, 500000);
|
_mixer->newStream(&_channels[i].handle, rate, flags, 500000);
|
||||||
_mixer->appendStream(_channels[i].handle, data, size);
|
_mixer->appendStream(_channels[i].handle, data, size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,6 @@ SmushPlayer::SmushPlayer(ScummEngine *scumm, int speed, bool subtitles) {
|
||||||
_storeFrame = false;
|
_storeFrame = false;
|
||||||
_width = 0;
|
_width = 0;
|
||||||
_height = 0;
|
_height = 0;
|
||||||
_IACTchannel = 0;
|
|
||||||
_IACTpos = 0;
|
_IACTpos = 0;
|
||||||
_soundFrequency = 22050;
|
_soundFrequency = 22050;
|
||||||
_speed = speed;
|
_speed = speed;
|
||||||
|
@ -461,7 +460,7 @@ void SmushPlayer::handleIACT(Chunk &b) {
|
||||||
}
|
}
|
||||||
} while (--count);
|
} while (--count);
|
||||||
|
|
||||||
if (_IACTchannel == 0)
|
if (!_IACTchannel.isActive())
|
||||||
_scumm->_mixer->newStream(&_IACTchannel, 22050, SoundMixer::FLAG_STEREO | SoundMixer::FLAG_16BITS, 200000);
|
_scumm->_mixer->newStream(&_IACTchannel, 22050, SoundMixer::FLAG_STEREO | SoundMixer::FLAG_16BITS, 200000);
|
||||||
_scumm->_mixer->appendStream(_IACTchannel, output_data, 0x1000);
|
_scumm->_mixer->appendStream(_IACTchannel, output_data, 0x1000);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,6 @@ Sound::Sound(ScummEngine *parent) {
|
||||||
memset(this,0,sizeof(Sound)); // palmos
|
memset(this,0,sizeof(Sound)); // palmos
|
||||||
|
|
||||||
_scumm = parent;
|
_scumm = parent;
|
||||||
_talkChannelHandle = 0;
|
|
||||||
_currentCDSound = 0;
|
_currentCDSound = 0;
|
||||||
|
|
||||||
_sfxFile = 0;
|
_sfxFile = 0;
|
||||||
|
@ -427,7 +426,7 @@ void Sound::processSfxQueues() {
|
||||||
if ((_sfxMode & 2) && _scumm->VAR(_scumm->VAR_TALK_ACTOR)) {
|
if ((_sfxMode & 2) && _scumm->VAR(_scumm->VAR_TALK_ACTOR)) {
|
||||||
act = _scumm->VAR(_scumm->VAR_TALK_ACTOR);
|
act = _scumm->VAR(_scumm->VAR_TALK_ACTOR);
|
||||||
|
|
||||||
finished = !_talkChannelHandle;
|
finished = !_talkChannelHandle.isActive();
|
||||||
|
|
||||||
if (act != 0 && (uint) act < 0x80 && !_scumm->_string[0].no_talk_anim) {
|
if (act != 0 && (uint) act < 0x80 && !_scumm->_string[0].no_talk_anim) {
|
||||||
a = _scumm->derefActor(act, "processSfxQueues");
|
a = _scumm->derefActor(act, "processSfxQueues");
|
||||||
|
|
|
@ -163,7 +163,7 @@ void ScummEngine::CHARSET_1() {
|
||||||
if (_talkDelay)
|
if (_talkDelay)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((_gameId == GID_CMI || _gameId == GID_DIG) && _sound->_talkChannelHandle) {
|
if ((_gameId == GID_CMI || _gameId == GID_DIG) && _sound->_talkChannelHandle.isActive()) {
|
||||||
// Keep the 'speech' flag in _sound->_sfxMode set as long as the
|
// Keep the 'speech' flag in _sound->_sfxMode set as long as the
|
||||||
// _talkChannelHandle is valid.
|
// _talkChannelHandle is valid.
|
||||||
_sound->_sfxMode |= 2;
|
_sound->_sfxMode |= 2;
|
||||||
|
@ -317,7 +317,7 @@ void ScummEngine::CHARSET_1() {
|
||||||
} else {
|
} else {
|
||||||
if ((_gameId == GID_LOOM256) && _noSubtitles && (_sound->pollCD())) {
|
if ((_gameId == GID_LOOM256) && _noSubtitles && (_sound->pollCD())) {
|
||||||
// Special case for loomcd, since it only uses CD audio.for sound
|
// Special case for loomcd, since it only uses CD audio.for sound
|
||||||
} else if (_noSubtitles && (_haveMsg == 0xFE || _sound->_talkChannelHandle)) {
|
} else if (_noSubtitles && (_haveMsg == 0xFE || _sound->_talkChannelHandle.isActive())) {
|
||||||
// Subtitles are turned off, and there is a voice version
|
// Subtitles are turned off, and there is a voice version
|
||||||
// of this message -> don't print it.
|
// of this message -> don't print it.
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "base/engine.h"
|
#include "base/engine.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
#include "simon/midi.h"
|
#include "simon/midi.h"
|
||||||
#include "sound/mixer.h"
|
|
||||||
#include "simon/sound.h"
|
#include "simon/sound.h"
|
||||||
|
|
||||||
class GameDetector;
|
class GameDetector;
|
||||||
|
|
|
@ -262,10 +262,6 @@ SimonSound::SimonSound(const byte game, const GameSpecificSettings *gss, const C
|
||||||
_last_voice_file = 0;
|
_last_voice_file = 0;
|
||||||
_offsets = 0;
|
_offsets = 0;
|
||||||
|
|
||||||
_voice_handle = 0;
|
|
||||||
_effects_handle = 0;
|
|
||||||
_ambient_handle = 0;
|
|
||||||
|
|
||||||
_voice_file = false;
|
_voice_file = false;
|
||||||
_ambient_playing = 0;
|
_ambient_playing = 0;
|
||||||
|
|
||||||
|
|
|
@ -1615,7 +1615,7 @@ void SimonEngine::vc_59() {
|
||||||
vc_kill_sprite(file, start);
|
vc_kill_sprite(file, start);
|
||||||
} while (++start != end);
|
} while (++start != end);
|
||||||
} else {
|
} else {
|
||||||
if (_sound->_voice_handle == 0)
|
if (!_sound->_voice_handle.isActive())
|
||||||
vc_skip_next_instruction();
|
vc_skip_next_instruction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1798,7 +1798,7 @@ void SimonEngine::vc_63_palette_thing_2() {
|
||||||
|
|
||||||
void SimonEngine::vc_64_skip_if_no_speech() {
|
void SimonEngine::vc_64_skip_if_no_speech() {
|
||||||
// Simon2
|
// Simon2
|
||||||
if (_sound->_voice_handle == 0)
|
if (!_sound->_voice_handle.isActive())
|
||||||
vc_skip_next_instruction();
|
vc_skip_next_instruction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -728,7 +728,7 @@ bool SkyIntro::nextPart(uint16 *&data) {
|
||||||
SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_UNSIGNED, SOUND_VOICE);
|
SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_UNSIGNED, SOUND_VOICE);
|
||||||
return true;
|
return true;
|
||||||
case WAITVOICE:
|
case WAITVOICE:
|
||||||
while (_voice)
|
while (_voice.isActive())
|
||||||
if (!escDelay(50))
|
if (!escDelay(50))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1019,11 +1019,6 @@ SkySound::SkySound(SoundMixer *mixer, SkyDisk *pDisk, uint8 pVolume) {
|
||||||
_skyDisk = pDisk;
|
_skyDisk = pDisk;
|
||||||
_soundData = NULL;
|
_soundData = NULL;
|
||||||
_mixer = mixer;
|
_mixer = mixer;
|
||||||
_voiceHandle = 0;
|
|
||||||
_effectHandle = 0;
|
|
||||||
_bgSoundHandle = 0;
|
|
||||||
_ingameSpeech = 0;
|
|
||||||
_ingameSound0 = _ingameSound1 = 0;
|
|
||||||
_saveSounds[0] = _saveSounds[1] = 0xFFFF;
|
_saveSounds[0] = _saveSounds[1] = 0xFFFF;
|
||||||
_mainSfxVolume = pVolume;
|
_mainSfxVolume = pVolume;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
void playSound(uint16 sound, uint16 volume, uint8 channel);
|
void playSound(uint16 sound, uint16 volume, uint8 channel);
|
||||||
void fnStartFx(uint32 sound, uint8 channel);
|
void fnStartFx(uint32 sound, uint8 channel);
|
||||||
bool startSpeech(uint16 textNum);
|
bool startSpeech(uint16 textNum);
|
||||||
bool speechFinished(void) { return _ingameSpeech == 0; };
|
bool speechFinished(void) { return !_ingameSpeech.isActive(); };
|
||||||
void fnPauseFx(void);
|
void fnPauseFx(void);
|
||||||
void fnUnPauseFx(void);
|
void fnUnPauseFx(void);
|
||||||
void fnStopFx(void);
|
void fnStopFx(void);
|
||||||
|
|
|
@ -74,7 +74,7 @@ bool AudioCDManager::isPlaying() const {
|
||||||
void AudioCDManager::updateCD() {
|
void AudioCDManager::updateCD() {
|
||||||
if (_cd.playing) {
|
if (_cd.playing) {
|
||||||
// If the sound handle is 0, then playback stopped.
|
// If the sound handle is 0, then playback stopped.
|
||||||
if (!_cd.handle) {
|
if (!_cd.handle.isActive()) {
|
||||||
// If playback just stopped, check if the current track is supposed
|
// If playback just stopped, check if the current track is supposed
|
||||||
// to be repeated, and if that's the case, play it again. Else, stop
|
// to be repeated, and if that's the case, play it again. Else, stop
|
||||||
// the CD explicitly.
|
// the CD explicitly.
|
||||||
|
@ -94,7 +94,7 @@ void AudioCDManager::updateCD() {
|
||||||
|
|
||||||
AudioCDManager::Status AudioCDManager::getStatus() const {
|
AudioCDManager::Status AudioCDManager::getStatus() const {
|
||||||
// TODO: This could be improved for "real" CD playback.
|
// TODO: This could be improved for "real" CD playback.
|
||||||
// But to do that, we have to extend the OSystem interface.
|
// But to do that, we would have to extend the OSystem interface.
|
||||||
Status info = _cd;
|
Status info = _cd;
|
||||||
info.playing = isPlaying();
|
info.playing = isPlaying();
|
||||||
return info;
|
return info;
|
||||||
|
|
|
@ -152,10 +152,10 @@ void SoundMixer::newStream(PlayingSoundHandle *handle, uint rate, byte flags, ui
|
||||||
void SoundMixer::appendStream(PlayingSoundHandle handle, void *sound, uint32 size) {
|
void SoundMixer::appendStream(PlayingSoundHandle handle, void *sound, uint32 size) {
|
||||||
Common::StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
if (handle == 0)
|
if (!handle.isActive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int index = handle - 1;
|
int index = handle.getIndex();
|
||||||
|
|
||||||
if ((index < 0) || (index >= NUM_CHANNELS)) {
|
if ((index < 0) || (index >= NUM_CHANNELS)) {
|
||||||
warning("soundMixer::appendStream has invalid index %d", index);
|
warning("soundMixer::appendStream has invalid index %d", index);
|
||||||
|
@ -179,10 +179,10 @@ void SoundMixer::endStream(PlayingSoundHandle handle) {
|
||||||
Common::StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
// Simply ignore stop requests for handles of sounds that already terminated
|
// Simply ignore stop requests for handles of sounds that already terminated
|
||||||
if (handle == 0)
|
if (!handle.isActive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int index = handle - 1;
|
int index = handle.getIndex();
|
||||||
|
|
||||||
if ((index < 0) || (index >= NUM_CHANNELS)) {
|
if ((index < 0) || (index >= NUM_CHANNELS)) {
|
||||||
warning("soundMixer::endStream has invalid index %d", index);
|
warning("soundMixer::endStream has invalid index %d", index);
|
||||||
|
@ -219,7 +219,7 @@ void SoundMixer::insertChannel(PlayingSoundHandle *handle, Channel *chan) {
|
||||||
|
|
||||||
_channels[index] = chan;
|
_channels[index] = chan;
|
||||||
if (handle)
|
if (handle)
|
||||||
*handle = index + 1;
|
handle->setIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, int id, byte volume, int8 pan, uint32 loopStart, uint32 loopEnd) {
|
void SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, int id, byte volume, int8 pan, uint32 loopStart, uint32 loopEnd) {
|
||||||
|
@ -358,10 +358,10 @@ void SoundMixer::stopHandle(PlayingSoundHandle handle) {
|
||||||
Common::StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
// Simply ignore stop requests for handles of sounds that already terminated
|
// Simply ignore stop requests for handles of sounds that already terminated
|
||||||
if (handle == 0)
|
if (!handle.isActive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int index = handle - 1;
|
int index = handle.getIndex();
|
||||||
|
|
||||||
if ((index < 0) || (index >= NUM_CHANNELS)) {
|
if ((index < 0) || (index >= NUM_CHANNELS)) {
|
||||||
warning("soundMixer::stopHandle has invalid index %d", index);
|
warning("soundMixer::stopHandle has invalid index %d", index);
|
||||||
|
@ -377,10 +377,10 @@ void SoundMixer::stopHandle(PlayingSoundHandle handle) {
|
||||||
void SoundMixer::setChannelVolume(PlayingSoundHandle handle, byte volume) {
|
void SoundMixer::setChannelVolume(PlayingSoundHandle handle, byte volume) {
|
||||||
Common::StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
if (handle == 0)
|
if (!handle.isActive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int index = handle - 1;
|
int index = handle.getIndex();
|
||||||
|
|
||||||
if ((index < 0) || (index >= NUM_CHANNELS)) {
|
if ((index < 0) || (index >= NUM_CHANNELS)) {
|
||||||
warning("soundMixer::setChannelVolume has invalid index %d", index);
|
warning("soundMixer::setChannelVolume has invalid index %d", index);
|
||||||
|
@ -394,10 +394,10 @@ void SoundMixer::setChannelVolume(PlayingSoundHandle handle, byte volume) {
|
||||||
void SoundMixer::setChannelPan(PlayingSoundHandle handle, int8 pan) {
|
void SoundMixer::setChannelPan(PlayingSoundHandle handle, int8 pan) {
|
||||||
Common::StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
if (handle == 0)
|
if (!handle.isActive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int index = handle - 1;
|
int index = handle.getIndex();
|
||||||
|
|
||||||
if ((index < 0) || (index >= NUM_CHANNELS)) {
|
if ((index < 0) || (index >= NUM_CHANNELS)) {
|
||||||
warning("soundMixer::setChannelVolume has invalid index %d", index);
|
warning("soundMixer::setChannelVolume has invalid index %d", index);
|
||||||
|
@ -426,10 +426,10 @@ void SoundMixer::pauseHandle(PlayingSoundHandle handle, bool paused) {
|
||||||
Common::StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
// Simply ignore pause/unpause requests for handles of sound that alreayd terminated
|
// Simply ignore pause/unpause requests for handles of sound that alreayd terminated
|
||||||
if (handle == 0)
|
if (!handle.isActive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int index = handle - 1;
|
int index = handle.getIndex();
|
||||||
|
|
||||||
if ((index < 0) || (index >= NUM_CHANNELS)) {
|
if ((index < 0) || (index >= NUM_CHANNELS)) {
|
||||||
warning("soundMixer::pauseHandle has invalid index %d", index);
|
warning("soundMixer::pauseHandle has invalid index %d", index);
|
||||||
|
@ -496,7 +496,7 @@ Channel::~Channel() {
|
||||||
delete _converter;
|
delete _converter;
|
||||||
delete _input;
|
delete _input;
|
||||||
if (_handle)
|
if (_handle)
|
||||||
*_handle = 0;
|
_handle->resetIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* len indicates the number of sample *pairs*. So a value of
|
/* len indicates the number of sample *pairs*. So a value of
|
||||||
|
|
|
@ -35,12 +35,22 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef uint32 PlayingSoundHandle;
|
|
||||||
|
|
||||||
class AudioInputStream;
|
class AudioInputStream;
|
||||||
class Channel;
|
class Channel;
|
||||||
class File;
|
class File;
|
||||||
|
|
||||||
|
class PlayingSoundHandle {
|
||||||
|
friend class Channel;
|
||||||
|
friend class SoundMixer;
|
||||||
|
int val;
|
||||||
|
int getIndex() const { return val - 1; }
|
||||||
|
void setIndex(int i) { val = i + 1; }
|
||||||
|
void resetIndex() { val = 0; }
|
||||||
|
public:
|
||||||
|
PlayingSoundHandle() { resetIndex(); }
|
||||||
|
bool isActive() const { return val > 0; }
|
||||||
|
};
|
||||||
|
|
||||||
class SoundMixer {
|
class SoundMixer {
|
||||||
public:
|
public:
|
||||||
typedef void PremixProc (void *param, int16 *data, uint len);
|
typedef void PremixProc (void *param, int16 *data, uint len);
|
||||||
|
|
|
@ -79,7 +79,7 @@ void SwordSound::engine(void) {
|
||||||
if (_fxQueue[cnt2].delay == 0)
|
if (_fxQueue[cnt2].delay == 0)
|
||||||
playSample(&_fxQueue[cnt2]);
|
playSample(&_fxQueue[cnt2]);
|
||||||
} else {
|
} else {
|
||||||
if (!_fxQueue[cnt2].handle) { // sound finished
|
if (!_fxQueue[cnt2].handle.isActive()) { // sound finished
|
||||||
_resMan->resClose(_fxList[_fxQueue[cnt2].id].sampleId);
|
_resMan->resClose(_fxList[_fxQueue[cnt2].id].sampleId);
|
||||||
if (cnt2 != _endOfQueue-1)
|
if (cnt2 != _endOfQueue-1)
|
||||||
_fxQueue[cnt2] = _fxQueue[_endOfQueue - 1];
|
_fxQueue[cnt2] = _fxQueue[_endOfQueue - 1];
|
||||||
|
@ -109,7 +109,7 @@ bool SwordSound::amISpeaking(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SwordSound::speechFinished(void) {
|
bool SwordSound::speechFinished(void) {
|
||||||
return (_speechHandle == 0);
|
return !_speechHandle.isActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwordSound::newScreen(uint32 screen) {
|
void SwordSound::newScreen(uint32 screen) {
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "base/engine.h"
|
#include "base/engine.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
#include "sound/mixer.h"
|
|
||||||
#include "base/gameDetector.h"
|
#include "base/gameDetector.h"
|
||||||
#include "sworddefs.h"
|
#include "sworddefs.h"
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@ int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOu
|
||||||
tmpPal[255 * 4 + 2] = 255;
|
tmpPal[255 * 4 + 2] = 255;
|
||||||
_vm->_graphics->setPalette(0, 256, tmpPal, RDPAL_INSTANT);
|
_vm->_graphics->setPalette(0, 256, tmpPal, RDPAL_INSTANT);
|
||||||
|
|
||||||
PlayingSoundHandle handle = 0;
|
PlayingSoundHandle handle;
|
||||||
|
|
||||||
bool skipCutscene = false;
|
bool skipCutscene = false;
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOu
|
||||||
// more importantly - that we don't free the sound buffer while
|
// more importantly - that we don't free the sound buffer while
|
||||||
// it's in use.
|
// it's in use.
|
||||||
|
|
||||||
while (handle) {
|
while (handle.isActive()) {
|
||||||
_vm->_system->delay_msecs(100);
|
_vm->_system->delay_msecs(100);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "common/stdafx.h"
|
#include "common/stdafx.h"
|
||||||
#include "common/file.h"
|
#include "common/file.h"
|
||||||
#include "sword2/sword2.h"
|
#include "sword2/sword2.h"
|
||||||
|
#include "sound/rate.h"
|
||||||
|
|
||||||
namespace Sword2 {
|
namespace Sword2 {
|
||||||
|
|
||||||
|
@ -132,7 +133,6 @@ Sound::Sound(Sword2Engine *vm) {
|
||||||
|
|
||||||
memset(_fx, 0, sizeof(_fx));
|
memset(_fx, 0, sizeof(_fx));
|
||||||
|
|
||||||
_soundHandleSpeech = 0;
|
|
||||||
_soundOn = true;
|
_soundOn = true;
|
||||||
|
|
||||||
_converter = makeRateConverter(_music[0].getRate(), _vm->_mixer->getOutputRate(), _music[0].isStereo(), false);
|
_converter = makeRateConverter(_music[0].getRate(), _vm->_mixer->getOutputRate(), _music[0].isStereo(), false);
|
||||||
|
@ -243,7 +243,7 @@ void Sound::playLeadOut(uint8 *leadOut) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (_fx[i]._handle) {
|
while (_fx[i]._handle.isActive()) {
|
||||||
_vm->_graphics->updateDisplay();
|
_vm->_graphics->updateDisplay();
|
||||||
_vm->_system->delay_msecs(30);
|
_vm->_system->delay_msecs(30);
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ void Sound::fxServer(int16 *data, uint len) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int32 Sound::amISpeaking() {
|
int32 Sound::amISpeaking() {
|
||||||
if (!_speechMuted && !_speechPaused && _soundHandleSpeech != 0)
|
if (!_speechMuted && !_speechPaused && _soundHandleSpeech.isActive())
|
||||||
return RDSE_SPEAKING;
|
return RDSE_SPEAKING;
|
||||||
|
|
||||||
return RDSE_QUIET;
|
return RDSE_QUIET;
|
||||||
|
@ -441,7 +441,7 @@ int32 Sound::getSpeechStatus(void) {
|
||||||
if (_speechPaused)
|
if (_speechPaused)
|
||||||
return RDSE_SAMPLEPLAYING;
|
return RDSE_SAMPLEPLAYING;
|
||||||
|
|
||||||
if (!_soundHandleSpeech) {
|
if (!_soundHandleSpeech.isActive()) {
|
||||||
_speechStatus = false;
|
_speechStatus = false;
|
||||||
return RDSE_SAMPLEFINISHED;
|
return RDSE_SAMPLEFINISHED;
|
||||||
}
|
}
|
||||||
|
@ -459,7 +459,7 @@ void Sound::setSpeechVolume(uint8 volume) {
|
||||||
|
|
||||||
_speechVol = volume;
|
_speechVol = volume;
|
||||||
|
|
||||||
if (_soundHandleSpeech != 0 && !_speechMuted && getSpeechStatus() == RDSE_SAMPLEPLAYING) {
|
if (_soundHandleSpeech.isActive() && !_speechMuted && getSpeechStatus() == RDSE_SAMPLEPLAYING) {
|
||||||
_vm->_mixer->setChannelVolume(_soundHandleSpeech, 16 * _speechVol);
|
_vm->_mixer->setChannelVolume(_soundHandleSpeech, 16 * _speechVol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -558,7 +558,7 @@ int32 Sound::openFx(int32 id, uint8 *data) {
|
||||||
// between rooms.
|
// between rooms.
|
||||||
|
|
||||||
for (fxi = 0; fxi < MAXFX; fxi++) {
|
for (fxi = 0; fxi < MAXFX; fxi++) {
|
||||||
if (!_fx[fxi]._handle)
|
if (!_fx[fxi]._handle.isActive())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
|
|
||||||
#include "sound/audiostream.h"
|
#include "sound/audiostream.h"
|
||||||
#include "sound/mixer.h"
|
#include "sound/mixer.h"
|
||||||
#include "sound/rate.h"
|
|
||||||
|
class RateConverter;
|
||||||
|
|
||||||
namespace Sword2 {
|
namespace Sword2 {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue