aboutsummaryrefslogtreecommitdiff
path: root/scumm/smush
diff options
context:
space:
mode:
authorMax Horn2005-04-04 18:42:35 +0000
committerMax Horn2005-04-04 18:42:35 +0000
commit581ab2ed638663c67ffd7ac08e314be603de2c8e (patch)
tree1a67bb120698895c2ea4099e1960f20749a18554 /scumm/smush
parentadf9bcf5d1c2efdb57ebf01f06dc4457122c512c (diff)
downloadscummvm-rg350-581ab2ed638663c67ffd7ac08e314be603de2c8e.tar.gz
scummvm-rg350-581ab2ed638663c67ffd7ac08e314be603de2c8e.tar.bz2
scummvm-rg350-581ab2ed638663c67ffd7ac08e314be603de2c8e.zip
Got rid of isSoundHandleActive usage; made the SmushMixer thread safe
svn-id: r17380
Diffstat (limited to 'scumm/smush')
-rw-r--r--scumm/smush/smush_mixer.cpp8
-rw-r--r--scumm/smush/smush_mixer.h2
-rw-r--r--scumm/smush/smush_player.cpp2
3 files changed, 10 insertions, 2 deletions
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) {
diff --git a/scumm/smush/smush_mixer.h b/scumm/smush/smush_mixer.h
index b46366d182..5e56103190 100644
--- a/scumm/smush/smush_mixer.h
+++ b/scumm/smush/smush_mixer.h
@@ -45,6 +45,8 @@ private:
int _soundFrequency;
+ Common::Mutex _mutex;
+
public:
SmushMixer(SoundMixer *);
diff --git a/scumm/smush/smush_player.cpp b/scumm/smush/smush_player.cpp
index 2641d1ccec..1969adb48f 100644
--- a/scumm/smush/smush_player.cpp
+++ b/scumm/smush/smush_player.cpp
@@ -509,7 +509,7 @@ void SmushPlayer::handleIACT(Chunk &b) {
}
} while (--count);
- if (!_vm->_mixer->isSoundHandleActive(_IACTchannel)) {
+ if (!_IACTstream) {
_IACTstream = makeAppendableAudioStream(22050, SoundMixer::FLAG_STEREO | SoundMixer::FLAG_16BITS, 400000);
_vm->_mixer->playInputStream(SoundMixer::kSFXSoundType, &_IACTchannel, _IACTstream);
}