aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/mixer.cpp41
-rw-r--r--sound/mixer.h21
-rw-r--r--sound/softsynth/adlib.cpp5
-rw-r--r--sound/softsynth/emumidi.h1
-rw-r--r--sound/softsynth/ym2612.cpp5
5 files changed, 17 insertions, 56 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index 1712209237..26fd195b07 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -108,7 +108,6 @@ Mixer::Mixer() {
_handleSeed = 0;
- _premixChannel = 0;
int i = 0;
for (i = 0; i < ARRAYSIZE(_volumeForSoundType); i++)
@@ -121,29 +120,14 @@ Mixer::Mixer() {
}
Mixer::~Mixer() {
- stopAll(true);
-
- delete _premixChannel;
- _premixChannel = 0;
+ for (int i = 0; i != NUM_CHANNELS; i++)
+ delete _channels[i];
}
uint Mixer::getOutputRate() const {
return (uint)_syst->getOutputSampleRate();
}
-void Mixer::setupPremix(AudioStream *stream, SoundType type) {
- Common::StackLock lock(_mutex);
-
- delete _premixChannel;
- _premixChannel = 0;
-
- if (stream == 0)
- return;
-
- // Create the channel
- _premixChannel = new Channel(this, type, stream, false);
-}
-
void Mixer::insertChannel(SoundHandle *handle, Channel *chan) {
int index = -1;
@@ -246,10 +230,7 @@ void Mixer::mix(int16 *buf, uint len) {
// zero the buf
memset(buf, 0, 2 * len * sizeof(int16));
- if (_premixChannel && !_premixChannel->isPaused())
- _premixChannel->mix(buf, len);
-
- // now mix all channels
+ // mix all channels
for (int i = 0; i != NUM_CHANNELS; i++)
if (_channels[i]) {
if (_channels[i]->isFinished()) {
@@ -268,18 +249,14 @@ void Mixer::mixCallback(void *s, byte *samples, int len) {
((Mixer *)s)->mix((int16 *)samples, len >> 2);
}
-void Mixer::stopAll(bool force) {
+void Mixer::stopAll() {
Common::StackLock lock(_mutex);
for (int i = 0; i != NUM_CHANNELS; i++) {
- if (_channels[i] != 0) {
- if (force || !_channels[i]->isPermanent()) {
- delete _channels[i];
- _channels[i] = 0;
- }
+ if (_channels[i] != 0 && !_channels[i]->isPermanent()) {
+ delete _channels[i];
+ _channels[i] = 0;
}
}
-
- // Note: the _premixChannel is *not* affected by stopAll!
}
void Mixer::stopID(int id) {
@@ -341,10 +318,6 @@ void Mixer::pauseAll(bool paused) {
_channels[i]->pause(paused);
}
}
-
- // Unlike stopAll, we also pause the premix channel, if present.
- if (_premixChannel)
- _premixChannel->pause(paused);
}
void Mixer::pauseID(int id, bool paused) {
diff --git a/sound/mixer.h b/sound/mixer.h
index f2bec71057..9b10bbf996 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -102,8 +102,6 @@ private:
OSystem *_syst;
Common::Mutex _mutex;
- Channel *_premixChannel;
-
int _volumeForSoundType[4];
uint32 _handleSeed;
@@ -120,8 +118,8 @@ public:
/**
* Is the mixer ready and setup? This may not be the case on systems which
* don't support digital sound output. In that case, the mixer proc may
- * never be called. That in turn can cause breakage in games which use the
- * premix callback for syncing. In particular, the Adlib MIDI emulation...
+ * never be called. That in turn can cause breakage in games which try to
+ * sync with an audio stream. In particular, the Adlib MIDI emulation...
*
* @return whether the mixer is ready and setup
*/
@@ -130,15 +128,6 @@ public:
/**
- * Set the premix stream. This is mainly used for the adlib music, but
- * is not limited to it. The premix stream is invoked by the mixer whenever
- * it needs to generate any data, before any other mixing takes place.
- */
- void setupPremix(AudioStream *stream, SoundType type = kPlainSoundType);
-
-
-
- /**
* Start playing the given raw sound data.
* Internally, this simply creates an audio input stream wrapping the data
* (using the makeLinearInputStream factory function), which is then
@@ -182,7 +171,7 @@ public:
/**
* Stop all currently playing sounds.
*/
- void stopAll(bool force = false);
+ void stopAll();
/**
* Stop playing the sound with given ID.
@@ -201,8 +190,8 @@ public:
/**
- * Pause/unpause all sounds, including all regular channels and the
- * premix channel.
+ * Pause/unpause all sounds, including all regular and permanent
+ * channels
*
* @param paused true to pause everything, false to unpause
*/
diff --git a/sound/softsynth/adlib.cpp b/sound/softsynth/adlib.cpp
index 96b1add13f..15a99069be 100644
--- a/sound/softsynth/adlib.cpp
+++ b/sound/softsynth/adlib.cpp
@@ -847,7 +847,7 @@ int MidiDriver_ADLIB::open() {
adlib_write(0xBD, 0x00);
create_lookup_table();
- _mixer->setupPremix(this);
+ _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_mixerSoundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, false, true);
return 0;
}
@@ -857,8 +857,7 @@ void MidiDriver_ADLIB::close() {
return;
_isOpen = false;
- // Detach the premix callback handler
- _mixer->setupPremix(0);
+ _mixer->stopHandle(_mixerSoundHandle);
uint i;
for (i = 0; i < ARRAYSIZE(_voices); ++i) {
diff --git a/sound/softsynth/emumidi.h b/sound/softsynth/emumidi.h
index 557e9b04cc..43161e51e4 100644
--- a/sound/softsynth/emumidi.h
+++ b/sound/softsynth/emumidi.h
@@ -30,6 +30,7 @@ class MidiDriver_Emulated : public Audio::AudioStream, public MidiDriver {
protected:
bool _isOpen;
Audio::Mixer *_mixer;
+ Audio::SoundHandle _mixerSoundHandle;
private:
Common::TimerManager::TimerProc _timerProc;
diff --git a/sound/softsynth/ym2612.cpp b/sound/softsynth/ym2612.cpp
index 40962c04c5..823e371a88 100644
--- a/sound/softsynth/ym2612.cpp
+++ b/sound/softsynth/ym2612.cpp
@@ -741,7 +741,7 @@ int MidiDriver_YM2612::open() {
MidiDriver_Emulated::open();
- _mixer->setupPremix(this);
+ _mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_mixerSoundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, false, true);
return 0;
}
@@ -750,8 +750,7 @@ void MidiDriver_YM2612::close() {
return;
_isOpen = false;
- // Detach the premix callback handler
- _mixer->setupPremix(0);
+ _mixer->stopHandle(_mixerSoundHandle);
}
void MidiDriver_YM2612::send(uint32 b) {