aboutsummaryrefslogtreecommitdiff
path: root/scumm/smush
diff options
context:
space:
mode:
authorMax Horn2003-12-18 01:22:28 +0000
committerMax Horn2003-12-18 01:22:28 +0000
commita458da989bbe77d798f68f253ee63a68c925b6c0 (patch)
tree95b6d5c2baf390f0246a9b8677bd5453f2aa9556 /scumm/smush
parent127e5ce5f94e2526a41c802c1adbe6480790c796 (diff)
downloadscummvm-rg350-a458da989bbe77d798f68f253ee63a68c925b6c0.tar.gz
scummvm-rg350-a458da989bbe77d798f68f253ee63a68c925b6c0.tar.bz2
scummvm-rg350-a458da989bbe77d798f68f253ee63a68c925b6c0.zip
cleanup
svn-id: r11729
Diffstat (limited to 'scumm/smush')
-rw-r--r--scumm/smush/smush_mixer.cpp57
-rw-r--r--scumm/smush/smush_mixer.h10
2 files changed, 26 insertions, 41 deletions
diff --git a/scumm/smush/smush_mixer.cpp b/scumm/smush/smush_mixer.cpp
index ad14292f39..195a0d9dd4 100644
--- a/scumm/smush/smush_mixer.cpp
+++ b/scumm/smush/smush_mixer.cpp
@@ -35,85 +35,68 @@ namespace Scumm {
SmushMixer::SmushMixer(SoundMixer *m) :
_mixer(m),
- _nextIndex(0),
_soundFrequency(22050) {
- for (int32 i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
+ for (int32 i = 0; i < NUM_CHANNELS; i++) {
_channels[i].id = -1;
_channels[i].chan = NULL;
- _channels[i].mixer_index = 0;
+ _channels[i].handle = 0;
}
}
SmushMixer::~SmushMixer() {
- for (int32 i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
- _mixer->stopChannel(_channels[i].mixer_index);
+ for (int32 i = 0; i < NUM_CHANNELS; i++) {
+ _mixer->stopChannel(_channels[i].handle);
}
}
SmushChannel *SmushMixer::findChannel(int32 track) {
debug(9, "SmushMixer::findChannel(%d)", track);
- for (int32 i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
+ for (int32 i = 0; i < NUM_CHANNELS; i++) {
if (_channels[i].id == track)
return _channels[i].chan;
}
return NULL;
}
-bool SmushMixer::addChannel(SmushChannel *c) {
+void SmushMixer::addChannel(SmushChannel *c) {
int32 track = c->getTrackIdentifier();
int i;
debug(9, "SmushMixer::addChannel(%d)", track);
- for (i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
+ for (i = 0; i < NUM_CHANNELS; i++) {
if (_channels[i].id == track)
- warning("SmushMixer::addChannel(%d) : channel already exists", track);
+ warning("SmushMixer::addChannel(%d): channel already exists", track);
}
- if (_nextIndex >= SoundMixer::NUM_CHANNELS)
- _nextIndex = 0;
- for (i = _nextIndex; i < SoundMixer::NUM_CHANNELS; i++) {
+ for (i = 0; i < NUM_CHANNELS; i++) {
if (_channels[i].chan == NULL || _channels[i].id == -1) {
_channels[i].chan = c;
_channels[i].id = track;
- _channels[i].mixer_index = 0;
- _nextIndex = i + 1;
- return true;
+ _channels[i].handle = 0;
+ return;
}
}
- for (i = 0; i < _nextIndex; i++) {
- if (_channels[i].chan == NULL || _channels[i].id == -1) {
- _channels[i].chan = c;
- _channels[i].id = track;
- _channels[i].mixer_index = 0;
- _nextIndex = i + 1;
- return true;
- }
- }
-
- warning("_nextIndex == %d", _nextIndex);
-
- for (i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
+ for (i = 0; i < NUM_CHANNELS; i++) {
warning("channel %d : %p(%d, %d) %d %d", i, (void *)_channels[i].chan,
_channels[i].chan ? _channels[i].chan->getTrackIdentifier() : -1,
_channels[i].chan ? _channels[i].chan->isTerminated() : 1,
- _channels[i].mixer_index);
+ _channels[i].handle);
}
- error("SmushMixer::add_channel() : no more channel available");
- return false;
+ error("SmushMixer::addChannel(%d): no channel available", track);
}
bool SmushMixer::handleFrame() {
debug(9, "SmushMixer::handleFrame()");
- for (int i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
+ for (int i = 0; i < NUM_CHANNELS; i++) {
if (_channels[i].id != -1) {
if (_channels[i].chan->isTerminated()) {
delete _channels[i].chan;
_channels[i].id = -1;
_channels[i].chan = NULL;
- _mixer->endStream(_channels[i].mixer_index);
+ _mixer->endStream(_channels[i].handle);
} else {
int32 rate;
bool stereo, is_short;
@@ -139,10 +122,10 @@ bool SmushMixer::handleFrame() {
}
if (_silentMixer == false) {
- if (_channels[i].mixer_index == 0) {
- _mixer->newStream(&_channels[i].mixer_index, data, size, rate, flags, 500000, 255, 0);
+ if (_channels[i].handle == 0) {
+ _mixer->newStream(&_channels[i].handle, data, size, rate, flags, 500000, 255, 0);
} else {
- _mixer->appendStream(_channels[i].mixer_index, data, size);
+ _mixer->appendStream(_channels[i].handle, data, size);
}
}
free(data);
@@ -154,7 +137,7 @@ bool SmushMixer::handleFrame() {
bool SmushMixer::stop() {
debug(9, "SmushMixer::stop()");
- for (int i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
+ for (int i = 0; i < NUM_CHANNELS; i++) {
if (_channels[i].id != -1) {
delete _channels[i].chan;
_channels[i].id = -1;
diff --git a/scumm/smush/smush_mixer.h b/scumm/smush/smush_mixer.h
index 8184985257..ec54d647e5 100644
--- a/scumm/smush/smush_mixer.h
+++ b/scumm/smush/smush_mixer.h
@@ -30,16 +30,18 @@ namespace Scumm {
class SmushChannel;
class SmushMixer {
+ enum {
+ NUM_CHANNELS = 16
+ };
private:
SoundMixer *_mixer;
struct {
int id;
SmushChannel *chan;
- PlayingSoundHandle mixer_index;
- } _channels[SoundMixer::NUM_CHANNELS];
+ PlayingSoundHandle handle;
+ } _channels[NUM_CHANNELS];
- int _nextIndex;
int _soundFrequency;
public:
@@ -47,7 +49,7 @@ public:
SmushMixer(SoundMixer *);
virtual ~SmushMixer();
SmushChannel *findChannel(int32 track);
- bool addChannel(SmushChannel *c);
+ void addChannel(SmushChannel *c);
bool handleFrame();
bool stop();
bool update();