From 581ab2ed638663c67ffd7ac08e314be603de2c8e Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 4 Apr 2005 18:42:35 +0000 Subject: Got rid of isSoundHandleActive usage; made the SmushMixer thread safe svn-id: r17380 --- scumm/smush/smush_mixer.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'scumm/smush/smush_mixer.cpp') diff --git a/scumm/smush/smush_mixer.cpp b/scumm/smush/smush_mixer.cpp index c787f3aafc..06ac72e751 100644 --- a/scumm/smush/smush_mixer.cpp +++ b/scumm/smush/smush_mixer.cpp @@ -39,16 +39,19 @@ SmushMixer::SmushMixer(SoundMixer *m) : for (int32 i = 0; i < NUM_CHANNELS; i++) { _channels[i].id = -1; _channels[i].chan = NULL; + _channels[i].stream = NULL; } } SmushMixer::~SmushMixer() { + Common::StackLock lock(_mutex); for (int32 i = 0; i < NUM_CHANNELS; i++) { _mixer->stopHandle(_channels[i].handle); } } SmushChannel *SmushMixer::findChannel(int32 track) { + Common::StackLock lock(_mutex); debugC(DEBUG_SMUSH, "SmushMixer::findChannel(%d)", track); for (int32 i = 0; i < NUM_CHANNELS; i++) { if (_channels[i].id == track) @@ -58,6 +61,7 @@ SmushChannel *SmushMixer::findChannel(int32 track) { } void SmushMixer::addChannel(SmushChannel *c) { + Common::StackLock lock(_mutex); int32 track = c->getTrackIdentifier(); int i; @@ -86,6 +90,7 @@ void SmushMixer::addChannel(SmushChannel *c) { } bool SmushMixer::handleFrame() { + Common::StackLock lock(_mutex); debugC(DEBUG_SMUSH, "SmushMixer::handleFrame()"); for (int i = 0; i < NUM_CHANNELS; i++) { if (_channels[i].id != -1) { @@ -120,7 +125,7 @@ bool SmushMixer::handleFrame() { } if (_mixer->isReady()) { - if (!_mixer->isSoundHandleActive(_channels[i].handle)) { + if (!_channels[i].stream) { _channels[i].stream = makeAppendableAudioStream(rate, flags, 500000); _mixer->playInputStream(SoundMixer::kSFXSoundType, &_channels[i].handle, _channels[i].stream); } @@ -136,6 +141,7 @@ bool SmushMixer::handleFrame() { } bool SmushMixer::stop() { + Common::StackLock lock(_mutex); debugC(DEBUG_SMUSH, "SmushMixer::stop()"); for (int i = 0; i < NUM_CHANNELS; i++) { if (_channels[i].id != -1) { -- cgit v1.2.3