aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Kołodziejski2003-09-01 13:43:22 +0000
committerPaweł Kołodziejski2003-09-01 13:43:22 +0000
commit743a3fbdaff119eb2aa9461e92d188f7a1ed7cfb (patch)
tree4ca3e7d2a83663ade075a05056aa64d6c01964f3
parente6a0261c7e599abbe95ffef44bcebc3b38e2cb73 (diff)
downloadscummvm-rg350-743a3fbdaff119eb2aa9461e92d188f7a1ed7cfb.tar.gz
scummvm-rg350-743a3fbdaff119eb2aa9461e92d188f7a1ed7cfb.tar.bz2
scummvm-rg350-743a3fbdaff119eb2aa9461e92d188f7a1ed7cfb.zip
added sound handle stuff to mixer streams
svn-id: r9956
-rw-r--r--scumm/imuse_digi.cpp18
-rw-r--r--scumm/imuse_digi.h3
-rw-r--r--scumm/smush/smush_mixer.cpp16
-rw-r--r--scumm/smush/smush_mixer.h2
-rw-r--r--scumm/smush/smush_player.cpp11
-rw-r--r--scumm/smush/smush_player.h2
-rw-r--r--scumm/sound.cpp11
-rw-r--r--scumm/sound.h2
-rw-r--r--sword2/driver/d_sound.cpp33
9 files changed, 41 insertions, 57 deletions
diff --git a/scumm/imuse_digi.cpp b/scumm/imuse_digi.cpp
index 0b79d7aeca..472bc44134 100644
--- a/scumm/imuse_digi.cpp
+++ b/scumm/imuse_digi.cpp
@@ -699,7 +699,7 @@ IMuseDigital::IMuseDigital(Scumm *scumm)
: _scumm(scumm) {
memset(_channel, 0, sizeof(Channel) * MAX_DIGITAL_CHANNELS);
for (int l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
- _channel[l]._mixerChannel = -1;
+ _channel[l]._mixerChannel = 0;
}
_scumm->_timer->installProcedure(imus_digital_handler, 200000);
_pause = false;
@@ -709,10 +709,7 @@ IMuseDigital::~IMuseDigital() {
_scumm->_timer->releaseProcedure(imus_digital_handler);
for (int l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
- if (_channel[l]._mixerChannel != -1) {
- _scumm->_mixer->stop(_channel[l]._mixerChannel);
- _channel[l]._mixerChannel = -1;
- }
+ _scumm->_mixer->stop(_channel[l]._mixerChannel);
}
}
@@ -725,10 +722,7 @@ void IMuseDigital::handler() {
for (l = 0; l < MAX_DIGITAL_CHANNELS;l ++) {
if (_channel[l]._used) {
if (_channel[l]._toBeRemoved) {
- if (_channel[l]._mixerChannel != -1) {
- _scumm->_mixer->endStream(_channel[l]._mixerChannel);
- _channel[l]._mixerChannel = -1;
- }
+ _scumm->_mixer->endStream(_channel[l]._mixerChannel);
free(_channel[l]._data);
_channel[l]._used = false;
@@ -772,7 +766,7 @@ void IMuseDigital::handler() {
int32 new_size = _channel[l]._mixerSize;
int32 mixer_size = new_size;
- if (_channel[l]._mixerChannel == -1) {
+ if (_channel[l]._mixerChannel == 0) {
mixer_size *= 2;
new_size *= 2;
}
@@ -810,8 +804,8 @@ void IMuseDigital::handler() {
}
if (_scumm->_silentDigitalImuse == false) {
- if (_channel[l]._mixerChannel == -1) {
- _channel[l]._mixerChannel = _scumm->_mixer->newStream(buf, mixer_size,
+ if (_channel[l]._mixerChannel == 0) {
+ _scumm->_mixer->newStream(&_channel[l]._mixerChannel, buf, mixer_size,
_channel[l]._freq, _channel[l]._mixerFlags, 100000, 127, 0);
} else {
_scumm->_mixer->appendStream(_channel[l]._mixerChannel, buf, mixer_size);
diff --git a/scumm/imuse_digi.h b/scumm/imuse_digi.h
index 1c4a854890..915b1751e3 100644
--- a/scumm/imuse_digi.h
+++ b/scumm/imuse_digi.h
@@ -24,6 +24,7 @@
#define IMUSE_DIGI_H
#include "common/scummsys.h"
+#include "sound/mixer.h"
#define MAX_DIGITAL_CHANNELS 8
#define MAX_IMUSE_JUMPS 1
@@ -69,7 +70,7 @@ private:
int _idSound;
int32 _mixerSize;
int _mixerFlags;
- int _mixerChannel;
+ PlayingSoundHandle _mixerChannel;
bool _used;
bool _toBeRemoved;
};
diff --git a/scumm/smush/smush_mixer.cpp b/scumm/smush/smush_mixer.cpp
index c01753e2ab..04247fe2b4 100644
--- a/scumm/smush/smush_mixer.cpp
+++ b/scumm/smush/smush_mixer.cpp
@@ -35,14 +35,13 @@ SmushMixer::SmushMixer(SoundMixer *m) :
for (int32 i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
_channels[i].id = -1;
_channels[i].chan = NULL;
- _channels[i].mixer_index = -1;
+ _channels[i].mixer_index = 0;
}
}
SmushMixer::~SmushMixer() {
for (int32 i = 0; i < SoundMixer::NUM_CHANNELS; i++) {
- if (_channels[i].mixer_index != -1)
- _mixer->stop(_channels[i].mixer_index);
+ _mixer->stop(_channels[i].mixer_index);
}
}
@@ -72,7 +71,7 @@ bool SmushMixer::addChannel(SmushChannel *c) {
if (_channels[i].chan == NULL || _channels[i].id == -1) {
_channels[i].chan = c;
_channels[i].id = track;
- _channels[i].mixer_index = -1;
+ _channels[i].mixer_index = 0;
_nextIndex = i + 1;
return true;
}
@@ -82,7 +81,7 @@ bool SmushMixer::addChannel(SmushChannel *c) {
if (_channels[i].chan == NULL || _channels[i].id == -1) {
_channels[i].chan = c;
_channels[i].id = track;
- _channels[i].mixer_index = -1;
+ _channels[i].mixer_index = 0;
_nextIndex = i + 1;
return true;
}
@@ -109,8 +108,7 @@ bool SmushMixer::handleFrame() {
delete _channels[i].chan;
_channels[i].id = -1;
_channels[i].chan = NULL;
- if (_channels[i].mixer_index != -1)
- _mixer->endStream(_channels[i].mixer_index);
+ _mixer->endStream(_channels[i].mixer_index);
} else {
int32 rate;
bool stereo, is_short;
@@ -136,8 +134,8 @@ bool SmushMixer::handleFrame() {
}
if (_silentMixer == false) {
- if (_channels[i].mixer_index == -1) {
- _channels[i].mixer_index = _mixer->newStream(data, size, rate, flags, 500000, 127, 0);
+ if (_channels[i].mixer_index == 0) {
+ _mixer->newStream(&_channels[i].mixer_index, data, size, rate, flags, 500000, 127, 0);
} else {
_mixer->appendStream(_channels[i].mixer_index, data, size);
}
diff --git a/scumm/smush/smush_mixer.h b/scumm/smush/smush_mixer.h
index 6a62f786d4..5fb63381bf 100644
--- a/scumm/smush/smush_mixer.h
+++ b/scumm/smush/smush_mixer.h
@@ -32,7 +32,7 @@ private:
struct {
int id;
SmushChannel *chan;
- int mixer_index;
+ PlayingSoundHandle mixer_index;
} _channels[SoundMixer::NUM_CHANNELS];
int _nextIndex;
diff --git a/scumm/smush/smush_player.cpp b/scumm/smush/smush_player.cpp
index e3feacdb41..4775167777 100644
--- a/scumm/smush/smush_player.cpp
+++ b/scumm/smush/smush_player.cpp
@@ -227,7 +227,7 @@ SmushPlayer::SmushPlayer(Scumm *scumm, int speed, bool subtitles) {
_storeFrame = false;
_width = 0;
_height = 0;
- _IACTchannel = -1;
+ _IACTchannel = 0;
_IACTpos = 0;
_soundFrequency = 22050;
_speed = speed;
@@ -290,10 +290,7 @@ void SmushPlayer::deinit() {
_base = NULL;
}
- if (_IACTchannel != -1) {
- _scumm->_mixer->stop(_IACTchannel);
- _IACTchannel = -1;
- }
+ _scumm->_mixer->stop(_IACTchannel);
_scumm->_insaneState = false;
_scumm->abortCutscene();
@@ -461,8 +458,8 @@ void SmushPlayer::handleImuseAction(Chunk &b) {
}
} while (--count);
- if (_IACTchannel == -1) {
- _IACTchannel = _scumm->_mixer->newStream(output_data, 0x1000, 22050,
+ if (_IACTchannel == 0) {
+ _scumm->_mixer->newStream(&_IACTchannel, output_data, 0x1000, 22050,
SoundMixer::FLAG_STEREO | SoundMixer::FLAG_16BITS, 200000, 127, 0);
} else {
_scumm->_mixer->appendStream(_IACTchannel, output_data, 0x1000);
diff --git a/scumm/smush/smush_player.h b/scumm/smush/smush_player.h
index 35ebe00847..b94114a44c 100644
--- a/scumm/smush/smush_player.h
+++ b/scumm/smush/smush_player.h
@@ -51,7 +51,7 @@ private:
bool _skips[37];
int32 _frame;
- int _IACTchannel;
+ PlayingSoundHandle _IACTchannel;
byte _IACToutput[4096];
int32 _IACTpos;
bool _storeFrame;
diff --git a/scumm/sound.cpp b/scumm/sound.cpp
index 9b385053e5..8283f5a072 100644
--- a/scumm/sound.cpp
+++ b/scumm/sound.cpp
@@ -1104,7 +1104,7 @@ void Sound::playBundleMusic(const char *song) {
_pauseBundleMusic = false;
_musicBundleToBeRemoved = false;
_musicBundleToBeChanged = false;
- _bundleMusicTrack = -1;
+ _bundleMusicTrack = 0;
_numberSamplesBundleMusic = _bundle->getNumberOfMusicSamplesByName(song);
_nameBundleMusic = song;
_scumm->_timer->installProcedure(&music_handler, 1000000);
@@ -1137,10 +1137,7 @@ void Sound::bundleMusicHandler(Scumm *scumm) {
if (_musicBundleToBeRemoved) {
_scumm->_timer->releaseProcedure(&music_handler);
_nameBundleMusic = "";
- if (_bundleMusicTrack != -1) {
- _scumm->_mixer->stop(_bundleMusicTrack);
- _bundleMusicTrack = -1;
- }
+ _scumm->_mixer->stop(_bundleMusicTrack);
if (_musicBundleBufFinal) {
free(_musicBundleBufFinal);
_musicBundleBufFinal = NULL;
@@ -1248,8 +1245,8 @@ void Sound::bundleMusicHandler(Scumm *scumm) {
}
_bundleMusicPosition += final_size;
- if (_bundleMusicTrack == -1) {
- _bundleMusicTrack = _scumm->_mixer->newStream(buffer, final_size, rate,
+ if (_bundleMusicTrack == 0) {
+ _scumm->_mixer->newStream(&_bundleMusicTrack, buffer, final_size, rate,
SoundMixer::FLAG_16BITS | SoundMixer::FLAG_STEREO, 300000, 127, 0);
} else {
_scumm->_mixer->appendStream(_bundleMusicTrack, buffer, final_size);
diff --git a/scumm/sound.h b/scumm/sound.h
index 2cd1763233..7bd54ed6cd 100644
--- a/scumm/sound.h
+++ b/scumm/sound.h
@@ -57,7 +57,7 @@ protected:
byte *_musicBundleBufFinal;
byte *_musicBundleBufOutput;
bool _pauseBundleMusic;
- int32 _bundleMusicTrack;
+ PlayingSoundHandle _bundleMusicTrack;
bool _musicBundleToBeChanged;
bool _musicBundleToBeRemoved;
int32 _bundleMusicSampleBits;
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp
index 051487f223..4b19e1c2df 100644
--- a/sword2/driver/d_sound.cpp
+++ b/sword2/driver/d_sound.cpp
@@ -302,7 +302,7 @@ void Sword2Sound::FxServer(void) {
if (fxPaused) {
for (i = 0; i < MAXFX; i++) {
if ((fxId[i] == (int32) 0xfffffffe) || (fxId[i] == (int32) 0xffffffff)) {
- if (!g_engine->_mixer->isChannelActive(soundHandleFx[i])) {
+ if (!soundHandleFx[i]) {
fxId[i] = 0;
if (bufferFx[i] != NULL) {
free(bufferFx[i]);
@@ -318,7 +318,7 @@ void Sword2Sound::FxServer(void) {
for (i = 0; i < MAXFX; i++) {
if (fxId[i]) {
- if (!g_engine->_mixer->isChannelActive(soundHandleFx[i])) {
+ if (!soundHandleFx[i]) {
fxId[i] = 0;
if (bufferFx[i] != NULL) {
free(bufferFx[i]);
@@ -363,8 +363,7 @@ int32 Sword2Sound::InitialiseSound(uint16 freq, uint16 channels, uint16 bitDepth
int32 Sword2Sound::AmISpeaking() {
if ((!speechMuted) && (!speechPaused) && (soundHandleSpeech != 0)) {
- if (g_engine->_mixer->isChannelActive(soundHandleSpeech))
- return (RDSE_SPEAKING);
+ return (RDSE_SPEAKING);
}
return (RDSE_QUIET);
}
@@ -566,7 +565,6 @@ int32 Sword2Sound::PlayCompSpeech(const char *filename, uint32 speechid, uint8 v
for (uint j = 0; j < (bufferSize / 2); j++)
data16[j] = TO_BE_16(data16[j]);
- soundHandleSpeech = 0;
_mixer->playRaw(&soundHandleSpeech, data16, bufferSize, 22050, flags, volume, pan);
speechStatus = 1;
@@ -582,7 +580,6 @@ int32 Sword2Sound::StopSpeechSword2(void) {
if (speechStatus) {
g_engine->_mixer->stopHandle(soundHandleSpeech);
- soundHandleSpeech = 0;
speechStatus = 0;
return(RD_OK);
}
@@ -596,9 +593,8 @@ int32 Sword2Sound::GetSpeechStatus(void) {
if (speechPaused)
return(RDSE_SAMPLEPLAYING);
- if (g_engine->_mixer->isChannelActive(soundHandleSpeech) == false) {
+ if (!soundHandleSpeech) {
speechStatus = 0;
- soundHandleSpeech = 0;
return(RDSE_SAMPLEFINISHED);
}
return(RDSE_SAMPLEPLAYING);
@@ -1213,7 +1209,6 @@ void Sword2Sound::StartMusicFadeDown(int i) {
musFading[i] = -16;
musStreaming[i] = 0;
fpMus.close();
- soundHandleMusic[i] = 0;
}
int32 Sword2Sound::StreamCompMusic(const char *filename, uint32 musicId, int32 looping) {
@@ -1238,7 +1233,6 @@ int32 Sword2Sound::StreamCompMusic(const char *filename, uint32 musicId, int32 l
musFading[primaryStream] = 0;
g_engine->_mixer->stop(soundHandleMusic[primaryStream]);
musStreaming[primaryStream] = 0;
- soundHandleMusic[primaryStream] = 0;
}
// Pick the available music stream. If no music is playing it doesn't
@@ -1370,9 +1364,14 @@ int32 Sword2Sound::StreamCompMusic(const char *filename, uint32 musicId, int32 l
data16[i] = TO_BE_16(data16[i]);
}
- assert(!soundHandleMusic[primaryStream]);
- soundHandleMusic[primaryStream] = g_engine->_mixer->newStream(data16, bufferSizeMusic, 22050,
+ if (soundHandleMusic[primaryStream] == 0) {
+ warning("play music newStream(): this shouldn't happen");
+// assert(!soundHandleMusic[primaryStream]);
+ g_engine->_mixer->newStream(&soundHandleMusic[primaryStream], data16, bufferSizeMusic, 22050,
SoundMixer::FLAG_16BITS | SoundMixer::FLAG_AUTOFREE, 100000, volume, 0);
+ } else {
+ g_engine->_mixer->appendStream(soundHandleMusic[primaryStream], data16, bufferSizeMusic);
+ }
// Recorder some last variables
musStreaming[primaryStream] = 1;
@@ -1802,7 +1801,6 @@ void Sword2Sound::UpdateCompSampleStreaming(void) {
g_engine->_mixer->stop(soundHandleMusic[i]);
musStreaming[i] = 0;
musLooping[i] = 0;
- soundHandleMusic[i] = 0;
} else {
// Modify the volume according to the master volume and music mute state
if (musicMuted)
@@ -1903,10 +1901,10 @@ void Sword2Sound::UpdateCompSampleStreaming(void) {
if (soundHandleMusic[i] == 0) {
warning("play music appendStream(): this shouldn't happen");
- assert(soundHandleMusic[i]);
-// int volume = musicVolTable[volMusic[i]];
-// soundHandleMusic[i] = g_engine->_mixer->newStream(data16, bufferSizeMusic, 22050,
-// SoundMixer::FLAG_16BITS | SoundMixer::FLAG_AUTOFREE, 100000, volume, 0);
+// assert(soundHandleMusic[i]);
+ int volume = musicVolTable[volMusic[i]];
+ g_engine->_mixer->newStream(&soundHandleMusic[i], data16, bufferSizeMusic, 22050,
+ SoundMixer::FLAG_16BITS | SoundMixer::FLAG_AUTOFREE, 100000, volume, 0);
} else {
g_engine->_mixer->appendStream(soundHandleMusic[i], data16, len);
}
@@ -1919,7 +1917,6 @@ void Sword2Sound::UpdateCompSampleStreaming(void) {
// End of the music so we need to start fading and start the music again
if (fade) {
g_engine->_mixer->stop(soundHandleMusic[i]);
- soundHandleMusic[i] = 0;
musFading[i] = -16; // Fade the old music
// Close the music cluster if it's open