aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/platform/PalmOS/Src/be_base.cpp4
-rw-r--r--backends/platform/PalmOS/Src/be_base.h2
-rw-r--r--backends/platform/PalmOS/Src/be_os5.h2
-rw-r--r--backends/platform/PalmOS/Src/os5_sound.cpp22
-rw-r--r--backends/platform/dc/dcmain.cpp5
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp3
-rw-r--r--backends/platform/gp2x/gp2x.cpp23
-rw-r--r--backends/platform/iphone/osys_sound.cpp4
-rw-r--r--backends/platform/n64/osys_n64_base.cpp2
-rw-r--r--backends/platform/n64/osys_n64_utilities.cpp1
-rw-r--r--backends/platform/null/null.cpp10
-rw-r--r--backends/platform/ps2/systemps2.cpp3
-rw-r--r--backends/platform/psp/osys_psp.cpp35
-rw-r--r--backends/platform/sdl/sdl.cpp14
-rw-r--r--backends/platform/symbian/src/SymbianOS.cpp37
-rw-r--r--backends/platform/symbian/src/SymbianOS.h4
-rw-r--r--backends/platform/wii/osystem.cpp1
-rw-r--r--backends/platform/wii/osystem_sfx.cpp3
-rw-r--r--backends/platform/wince/wince-sdl.cpp7
-rw-r--r--sound/mixer.cpp18
-rw-r--r--sound/mixer_intern.h19
21 files changed, 81 insertions, 138 deletions
diff --git a/backends/platform/PalmOS/Src/be_base.cpp b/backends/platform/PalmOS/Src/be_base.cpp
index 66dd823df0..b3caee105d 100644
--- a/backends/platform/PalmOS/Src/be_base.cpp
+++ b/backends/platform/PalmOS/Src/be_base.cpp
@@ -110,9 +110,7 @@ void OSystem_PalmBase::initBackend() {
// Create and hook up the mixer, if none exists yet (we check for this to
// allow subclasses to provide their own).
if (_mixerMgr == 0) {
- _mixerMgr = new Audio::MixerImpl(this);
- setSoundCallback(0, _mixerMgr);
-// setSoundCallback(Audio::Mixer::mixCallback, _mixerMgr);
+ setupMixer();
}
// Create and hook up the timer manager, if none exists yet (we check for
diff --git a/backends/platform/PalmOS/Src/be_base.h b/backends/platform/PalmOS/Src/be_base.h
index 30130ebfff..1885114ace 100644
--- a/backends/platform/PalmOS/Src/be_base.h
+++ b/backends/platform/PalmOS/Src/be_base.h
@@ -117,7 +117,7 @@ private:
void simulate_mouse(Common::Event &event, Int8 iHoriz, Int8 iVert, Coord *xr, Coord *yr);
virtual void sound_handler() = 0;
- virtual bool setSoundCallback(SoundProc proc, void *param) = 0;
+ virtual bool setupMixer() = 0;
virtual void clearSoundCallback() = 0;
protected:
diff --git a/backends/platform/PalmOS/Src/be_os5.h b/backends/platform/PalmOS/Src/be_os5.h
index 692e304007..2040c7faea 100644
--- a/backends/platform/PalmOS/Src/be_os5.h
+++ b/backends/platform/PalmOS/Src/be_os5.h
@@ -140,7 +140,7 @@ private:
virtual SndStreamVariableBufferCallback sound_callback();
virtual void sound_handler();
- virtual bool setSoundCallback(SoundProc proc, void *param);
+ virtual bool setupMixer();
void clearSoundCallback();
protected:
diff --git a/backends/platform/PalmOS/Src/os5_sound.cpp b/backends/platform/PalmOS/Src/os5_sound.cpp
index 1898f6ae90..73ab64c0d5 100644
--- a/backends/platform/PalmOS/Src/os5_sound.cpp
+++ b/backends/platform/PalmOS/Src/os5_sound.cpp
@@ -66,7 +66,6 @@ void OSystem_PalmOS5::sound_handler() {
_soundEx.dataP = MemPtrNew(_soundEx.size);
_mixerMgr->mixCallback((byte *)_soundEx.dataP, _soundEx.size);
-// ((SoundProc)_sound.proc)(_sound.param, (byte *)_soundEx.dataP, _soundEx.size);
_soundEx.set = true;
}
}// TODO : no Sound API case
@@ -76,10 +75,18 @@ SndStreamVariableBufferCallback OSystem_PalmOS5::sound_callback() {
return sndCallback;
}
-bool OSystem_PalmOS5::setSoundCallback(SoundProc proc, void *param) {
+bool OSystem_PalmOS5::setupMixer() {
Err e;
Boolean success = false;
+ uint32 samplesPerSec;
+ if (ConfMan.hasKey("output_rate"))
+ samplesPerSec = ConfMan.getInt("output_rate");
+ else
+ samplesPerSec = SAMPLES_PER_SEC;
+
+ _mixerMgr = new Audio::MixerImpl(this, samplesPerSec);
+
if (!_sound.active) {
if (gVars->fmQuality != FM_QUALITY_INI) {
ConfMan.setBool("FM_medium_quality", (gVars->fmQuality == FM_QUALITY_MED));
@@ -89,8 +96,8 @@ bool OSystem_PalmOS5::setSoundCallback(SoundProc proc, void *param) {
#if defined (COMPILE_OS5)
CALLBACK_INIT(_soundEx);
#endif
- _sound.proc = proc;
- _sound.param = param;
+ _sound.proc = 0;
+ _sound.param = _mixerMgr;
_sound.active = true; // always true when we call this function, false when sound is off
_soundEx.handle = 0;
@@ -98,12 +105,6 @@ bool OSystem_PalmOS5::setSoundCallback(SoundProc proc, void *param) {
_soundEx.set = false;
_soundEx.dataP = NULL; // set by the handler
- uint32 samplesPerSec;
- if (ConfMan.hasKey("output_rate"))
- samplesPerSec = ConfMan.getInt("output_rate");
- else
- samplesPerSec = SAMPLES_PER_SEC;
-
// try to create sound stream
if (OPTIONS_TST(kOptPalmSoundAPI)) {
e = SndStreamCreateExtended(
@@ -133,7 +134,6 @@ bool OSystem_PalmOS5::setSoundCallback(SoundProc proc, void *param) {
}
// if not true some scenes (indy3 256,...) may freeze (ESC to skip)
- _mixerMgr->setOutputRate(samplesPerSec);
_mixerMgr->setReady(true);
return true;
diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp
index 8ad4708ebf..5a9286093f 100644
--- a/backends/platform/dc/dcmain.cpp
+++ b/backends/platform/dc/dcmain.cpp
@@ -55,9 +55,10 @@ void OSystem_Dreamcast::initBackend()
{
ConfMan.setInt("autosave_period", 0);
_savefile = createSavefileManager();
- _mixer = new Audio::MixerImpl(this);
_timer = new DefaultTimerManager();
- _mixer->setOutputRate(initSound());
+
+ uint sampleRate = initSound();
+ _mixer = new Audio::MixerImpl(this, sampleRate);
_mixer->setReady(true);
}
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index 164e6abbcd..691fb2ec7a 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -98,7 +98,6 @@ void OSystem_DS::initBackend() {
ConfMan.setInt("autosave_period", 0);
ConfMan.setBool("FM_medium_quality", true);
- _mixer = new Audio::MixerImpl(this);
_timer = new DefaultTimerManager();
DS::setTimerCallback(&OSystem_DS::timerHandler, 10);
@@ -108,7 +107,7 @@ void OSystem_DS::initBackend() {
DS::startSound(11025, 4096);
}
- _mixer->setOutputRate(DS::getSoundFrequency());
+ _mixer = new Audio::MixerImpl(this, DS::getSoundFrequency());
_mixer->setReady(true);
OSystem::initBackend();
diff --git a/backends/platform/gp2x/gp2x.cpp b/backends/platform/gp2x/gp2x.cpp
index 139c64ed38..3d4ed51c1f 100644
--- a/backends/platform/gp2x/gp2x.cpp
+++ b/backends/platform/gp2x/gp2x.cpp
@@ -587,16 +587,13 @@ void OSystem_GP2X::setupMixer() {
if (samplesPerSec <= 0)
samplesPerSec = SAMPLES_PER_SEC;
- //Quick EVIL Hack - DJWillis
-// samplesPerSec = 11025;
-
// Determine the sample buffer size. We want it to store enough data for
- // about 1/16th of a second. Note that it must be a power of two.
- // So e.g. at 22050 Hz, we request a sample buffer size of 2048.
+ // at least 1/16th of a second (though at most 8192 samples). Note
+ // that it must be a power of two. So e.g. at 22050 Hz, we request a
+ // sample buffer size of 2048.
uint32 samples = 8192;
- while (16 * samples >= samplesPerSec) {
+ while (samples * 16 > samplesPerSec * 2)
samples >>= 1;
- }
memset(&desired, 0, sizeof(desired));
desired.freq = samplesPerSec;
@@ -607,14 +604,11 @@ void OSystem_GP2X::setupMixer() {
desired.callback = mixCallback;
desired.userdata = this;
- // Create the mixer instance
assert(!_mixer);
- _mixer = new Audio::MixerImpl(this);
- assert(_mixer);
-
if (SDL_OpenAudio(&desired, &obtained) != 0) {
warning("Could not open audio device: %s", SDL_GetError());
- samplesPerSec = 0;
+ _mixer = new Audio::MixerImpl(this, samplesPerSec);
+ assert(_mixer);
_mixer->setReady(false);
} else {
// Note: This should be the obtained output rate, but it seems that at
@@ -623,8 +617,9 @@ void OSystem_GP2X::setupMixer() {
samplesPerSec = obtained.freq;
debug(1, "Output sample rate: %d Hz", samplesPerSec);
- // Tell the mixer that we are ready and start the sound processing
- _mixer->setOutputRate(samplesPerSec);
+ // Create the mixer instance and start the sound processing
+ _mixer = new Audio::MixerImpl(this, samplesPerSec);
+ assert(_mixer);
_mixer->setReady(true);
#ifdef MIXER_DOUBLE_BUFFERING
diff --git a/backends/platform/iphone/osys_sound.cpp b/backends/platform/iphone/osys_sound.cpp
index 6affc114f3..55892580f6 100644
--- a/backends/platform/iphone/osys_sound.cpp
+++ b/backends/platform/iphone/osys_sound.cpp
@@ -46,8 +46,7 @@ void OSystem_IPHONE::mixCallback(void *sys, byte *samples, int len) {
}
void OSystem_IPHONE::setupMixer() {
- //printf("setSoundCallback()\n");
- _mixer = new Audio::MixerImpl(this);
+ _mixer = new Audio::MixerImpl(this, AUDIO_SAMPLE_RATE);
s_soundCallback = mixCallback;
s_soundParam = this;
@@ -91,7 +90,6 @@ void OSystem_IPHONE::startSoundsystem() {
return;
}
- _mixer->setOutputRate(AUDIO_SAMPLE_RATE);
_mixer->setReady(true);
}
diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp
index f268201e9a..5e4b84ba3f 100644
--- a/backends/platform/n64/osys_n64_base.cpp
+++ b/backends/platform/n64/osys_n64_base.cpp
@@ -887,7 +887,7 @@ void OSystem_N64::setTimerCallback(TimerProc callback, int interval) {
}
void OSystem_N64::setupMixer(void) {
- _mixer = new Audio::MixerImpl(this);
+ _mixer = new Audio::MixerImpl(this, DEFAULT_SOUND_SAMPLE_RATE);
_mixer->setReady(false);
enableAudioPlayback();
diff --git a/backends/platform/n64/osys_n64_utilities.cpp b/backends/platform/n64/osys_n64_utilities.cpp
index 61b1d7a160..bc4661889f 100644
--- a/backends/platform/n64/osys_n64_utilities.cpp
+++ b/backends/platform/n64/osys_n64_utilities.cpp
@@ -60,7 +60,6 @@ void enableAudioPlayback(void) {
osys->_audioBufferSize = getAIBufferSize();
if (_firstRun) {
- localmixer->setOutputRate(DEFAULT_SOUND_SAMPLE_RATE);
localmixer->setReady(true);
_firstRun = false;
}
diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp
index 1539dfe8fd..51166baae7 100644
--- a/backends/platform/null/null.cpp
+++ b/backends/platform/null/null.cpp
@@ -108,9 +108,6 @@ public:
virtual void unlockMutex(MutexRef mutex);
virtual void deleteMutex(MutexRef mutex);
- typedef void (*SoundProc)(void *param, byte *buf, int len);
- virtual bool setSoundCallback(SoundProc proc, void *param);
-
virtual void quit();
virtual Common::SaveFileManager *getSavefileManager();
@@ -150,10 +147,9 @@ OSystem_NULL::~OSystem_NULL() {
void OSystem_NULL::initBackend() {
_savefile = new DefaultSaveFileManager();
- _mixer = new Audio::MixerImpl(this);
+ _mixer = new Audio::MixerImpl(this, 22050);
_timer = new DefaultTimerManager();
- _mixer->setOutputRate(22050);
_mixer->setReady(false);
gettimeofday(&_startTime, NULL);
@@ -299,10 +295,6 @@ void OSystem_NULL::unlockMutex(MutexRef mutex) {
void OSystem_NULL::deleteMutex(MutexRef mutex) {
}
-bool OSystem_NULL::setSoundCallback(SoundProc proc, void *param) {
- return true;
-}
-
void OSystem_NULL::quit() {
}
diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp
index 7bc90a7f0a..49d583d1a1 100644
--- a/backends/platform/ps2/systemps2.cpp
+++ b/backends/platform/ps2/systemps2.cpp
@@ -339,8 +339,7 @@ OSystem_PS2::OSystem_PS2(const char *elfPath) {
void OSystem_PS2::init(void) {
sioprintf("Timer...\n");
_scummTimerManager = new DefaultTimerManager();
- _scummMixer = new Audio::MixerImpl(this);
- _scummMixer->setOutputRate(48000);
+ _scummMixer = new Audio::MixerImpl(this, 48000);
_scummMixer->setReady(true);
initTimer();
diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp
index 50f233f752..8b4c005221 100644
--- a/backends/platform/psp/osys_psp.cpp
+++ b/backends/platform/psp/osys_psp.cpp
@@ -949,27 +949,23 @@ void OSystem_PSP::mixCallback(void *sys, byte *samples, int len) {
void OSystem_PSP::setupMixer(void) {
SDL_AudioSpec desired;
SDL_AudioSpec obtained;
- uint32 samplesPerSec;
-
- memset(&desired, 0, sizeof(desired));
+ // Determine the desired output sampling frequency.
+ uint32 samplesPerSec = 0;
if (ConfMan.hasKey("output_rate"))
samplesPerSec = ConfMan.getInt("output_rate");
- else
+ if (samplesPerSec <= 0)
samplesPerSec = SAMPLES_PER_SEC;
- // Originally, we always used 2048 samples. This loop will produce the
- // same result at 22050 Hz, and should hopefully produce something
- // sensible for other frequencies. Note that it must be a power of two.
-
- uint32 samples = 0x8000;
-
- for (;;) {
- if (samples / (samplesPerSec / 1000) < 100)
- break;
+ // Determine the sample buffer size. We want it to store enough data for
+ // at least 1/16th of a second (though at most 8192 samples). Note
+ // that it must be a power of two. So e.g. at 22050 Hz, we request a
+ // sample buffer size of 2048.
+ uint32 samples = 8192;
+ while (samples * 16 > samplesPerSec * 2)
samples >>= 1;
- }
+ memset(&desired, 0, sizeof(desired));
desired.freq = samplesPerSec;
desired.format = AUDIO_S16SYS;
desired.channels = 2;
@@ -978,12 +974,10 @@ void OSystem_PSP::setupMixer(void) {
desired.userdata = this;
assert(!_mixer);
- _mixer = new Audio::MixerImpl(this);
- assert(_mixer);
-
if (SDL_OpenAudio(&desired, &obtained) != 0) {
warning("Could not open audio: %s", SDL_GetError());
- samplesPerSec = 0;
+ _mixer = new Audio::MixerImpl(this, samplesPerSec);
+ assert(_mixer);
_mixer->setReady(false);
} else {
// Note: This should be the obtained output rate, but it seems that at
@@ -991,8 +985,9 @@ void OSystem_PSP::setupMixer(void) {
// even if it didn't. Probably only happens for "weird" rates, though.
samplesPerSec = obtained.freq;
- // Tell the mixer that we are ready and start the sound processing
- _mixer->setOutputRate(samplesPerSec);
+ // Create the mixer instance and start the sound processing
+ _mixer = new Audio::MixerImpl(this, samplesPerSec);
+ assert(_mixer);
_mixer->setReady(true);
SDL_PauseAudio(0);
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index c5eb89ec8d..246327786d 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -715,7 +715,7 @@ void OSystem_SDL::setupMixer() {
samplesPerSec = SAMPLES_PER_SEC;
// Determine the sample buffer size. We want it to store enough data for
- // at least 1/16th of a second (though at maximum 8192 samples). Note
+ // at least 1/16th of a second (though at most 8192 samples). Note
// that it must be a power of two. So e.g. at 22050 Hz, we request a
// sample buffer size of 2048.
uint32 samples = 8192;
@@ -730,14 +730,11 @@ void OSystem_SDL::setupMixer() {
desired.callback = mixCallback;
desired.userdata = this;
- // Create the mixer instance
assert(!_mixer);
- _mixer = new Audio::MixerImpl(this);
- assert(_mixer);
-
if (SDL_OpenAudio(&desired, &_obtainedRate) != 0) {
warning("Could not open audio device: %s", SDL_GetError());
- samplesPerSec = 0;
+ _mixer = new Audio::MixerImpl(this, samplesPerSec);
+ assert(_mixer);
_mixer->setReady(false);
} else {
// Note: This should be the obtained output rate, but it seems that at
@@ -746,8 +743,9 @@ void OSystem_SDL::setupMixer() {
samplesPerSec = _obtainedRate.freq;
debug(1, "Output sample rate: %d Hz", samplesPerSec);
- // Tell the mixer that we are ready and start the sound processing
- _mixer->setOutputRate(samplesPerSec);
+ // Create the mixer instance and start the sound processing
+ _mixer = new Audio::MixerImpl(this, samplesPerSec);
+ assert(_mixer);
_mixer->setReady(true);
#if MIXER_DOUBLE_BUFFERING
diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp
index 480b62849e..f8df2a5d5c 100644
--- a/backends/platform/symbian/src/SymbianOS.cpp
+++ b/backends/platform/symbian/src/SymbianOS.cpp
@@ -220,28 +220,22 @@ void OSystem_SDL_Symbian::setupMixer() {
SDL_AudioSpec desired;
SDL_AudioSpec obtained;
- memset(&desired, 0, sizeof(desired));
-
+ // Determine the desired output sampling frequency.
uint32 samplesPerSec = 0;
-
if (ConfMan.hasKey("output_rate"))
samplesPerSec = ConfMan.getInt("output_rate");
-
if (samplesPerSec <= 0)
samplesPerSec = SAMPLES_PER_SEC;
- // Originally, we always used 2048 samples. This loop will produce the
- // same result at 22050 Hz, and should hopefully produce something
- // sensible for other frequencies. Note that it must be a power of two.
-
- uint32 samples = 0x8000;
-
- for (;;) {
- if ((1000 * samples) / samplesPerSec < 100)
- break;
+ // Determine the sample buffer size. We want it to store enough data for
+ // at least 1/16th of a second (though at most 8192 samples). Note
+ // that it must be a power of two. So e.g. at 22050 Hz, we request a
+ // sample buffer size of 2048.
+ uint32 samples = 8192;
+ while (samples * 16 > samplesPerSec * 2)
samples >>= 1;
- }
+ memset(&desired, 0, sizeof(desired));
desired.freq = samplesPerSec;
desired.format = AUDIO_S16SYS;
desired.channels = 2;
@@ -249,14 +243,11 @@ void OSystem_SDL_Symbian::setupMixer() {
desired.callback = symbianMixCallback;
desired.userdata = this;
- // Create the mixer instance
assert(!_mixer);
- _mixer = new Audio::MixerImpl(this);
- assert(_mixer);
-
if (SDL_OpenAudio(&desired, &obtained) != 0) {
warning("Could not open audio device: %s", SDL_GetError());
- samplesPerSec = 0;
+ _mixer = new Audio::MixerImpl(this, samplesPerSec);
+ assert(_mixer);
_mixer->setReady(false);
} else {
// Note: This should be the obtained output rate, but it seems that at
@@ -270,16 +261,16 @@ void OSystem_SDL_Symbian::setupMixer() {
_stereo_mix_buffer = new byte [obtained.size*2];//*2 for stereo values
}
- // Tell the mixer that we are ready and start the sound processing
- _mixer->setOutputRate(samplesPerSec);
+ // Create the mixer instance and start the sound processing
+ _mixer = new Audio::MixerImpl(this, samplesPerSec);
+ assert(_mixer);
_mixer->setReady(true);
SDL_PauseAudio(0);
}
}
/**
- * The mixer callback function, passed on to OSystem::setSoundCallback().
- * This simply calls the mix() method.
+ * The mixer callback function.
*/
void OSystem_SDL_Symbian::symbianMixCallback(void *sys, byte *samples, int len) {
OSystem_SDL_Symbian *this_ = (OSystem_SDL_Symbian *)sys;
diff --git a/backends/platform/symbian/src/SymbianOS.h b/backends/platform/symbian/src/SymbianOS.h
index 5c6b7c505c..42929f8029 100644
--- a/backends/platform/symbian/src/SymbianOS.h
+++ b/backends/platform/symbian/src/SymbianOS.h
@@ -63,9 +63,7 @@ public:
RFs& FsSession();
protected:
//
- // The mixer callback function, passed on to OSystem::setSoundCallback().
- // This simply calls the mix() method.
- // and then does downmixing for symbian if needed
+ // The mixer callback function.
//
static void symbianMixCallback(void *s, byte *samples, int len);
diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp
index 12df2ca7e1..c3f350440f 100644
--- a/backends/platform/wii/osystem.cpp
+++ b/backends/platform/wii/osystem.cpp
@@ -136,7 +136,6 @@ void OSystem_Wii::initBackend() {
strcpy(buf, "/");
_savefile = new DefaultSaveFileManager(buf);
- _mixer = new Audio::MixerImpl(this);
_timer = new DefaultTimerManager();
initGfx();
diff --git a/backends/platform/wii/osystem_sfx.cpp b/backends/platform/wii/osystem_sfx.cpp
index 6af6958c32..d2e884aa22 100644
--- a/backends/platform/wii/osystem_sfx.cpp
+++ b/backends/platform/wii/osystem_sfx.cpp
@@ -65,6 +65,8 @@ static void * sfx_thread_func(void *arg) {
}
void OSystem_Wii::initSfx() {
+ _mixer = new Audio::MixerImpl(this, 48000);
+
sfx_thread_running = false;
sfx_thread_quit = false;
@@ -96,7 +98,6 @@ void OSystem_Wii::initSfx() {
DCFlushRange(sound_buffer[0], SFX_THREAD_FRAG_SIZE);
DCFlushRange(sound_buffer[1], SFX_THREAD_FRAG_SIZE);
- _mixer->setOutputRate(48000);
_mixer->setReady(true);
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);
diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp
index e359ba1744..068935582b 100644
--- a/backends/platform/wince/wince-sdl.cpp
+++ b/backends/platform/wince/wince-sdl.cpp
@@ -785,7 +785,7 @@ void OSystem_WINCE3::setupMixer() {
uint32 sampleRate = compute_sample_rate();
if (sampleRate == 0)
- warning("setSoundCallback called with sample rate 0 - audio will not work");
+ warning("OSystem_WINCE3::setupMixer called with sample rate 0 - audio will not work");
else if (_mixer && _mixer->getOutputRate() == sampleRate) {
debug(1, "Skipping sound mixer re-init: samplerate is good");
return;
@@ -801,7 +801,7 @@ void OSystem_WINCE3::setupMixer() {
// Create the mixer instance
if (_mixer == 0)
- _mixer = new Audio::MixerImpl(this);
+ _mixer = new Audio::MixerImpl(this, sampleRate);
// Add sound thread priority
if (!ConfMan.hasKey("sound_thread_priority"))
@@ -825,12 +825,11 @@ void OSystem_WINCE3::setupMixer() {
int vol3 = _mixer->getVolumeForSoundType(Audio::Mixer::kSFXSoundType);
int vol4 = _mixer->getVolumeForSoundType(Audio::Mixer::kSpeechSoundType);
delete _mixer;
- _mixer = new Audio::MixerImpl(this);
+ _mixer = new Audio::MixerImpl(this, sampleRate);
_mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, vol1);
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, vol2);
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, vol3);
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, vol4);
- _mixer->setOutputRate(sampleRate);
_mixer->setReady(true);
SDL_PauseAudio(0);
}
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index eae370e12b..93a18d51b0 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -160,8 +160,10 @@ private:
#pragma mark -
-MixerImpl::MixerImpl(OSystem *system)
- : _syst(system), _sampleRate(0), _mixerReady(false), _handleSeed(0) {
+MixerImpl::MixerImpl(OSystem *system, uint sampleRate)
+ : _syst(system), _sampleRate(sampleRate), _mixerReady(false), _handleSeed(0) {
+
+ assert(sampleRate > 0);
int i;
@@ -179,21 +181,12 @@ MixerImpl::~MixerImpl() {
void MixerImpl::setReady(bool ready) {
_mixerReady = ready;
-
- // If the mixer is set to ready, then we better have a positive sample rate!
- assert(!_mixerReady || _sampleRate > 0);
}
uint MixerImpl::getOutputRate() const {
return _sampleRate;
}
-void MixerImpl::setOutputRate(uint sampleRate) {
- if (_sampleRate != 0 && _sampleRate != sampleRate)
- error("Changing the Audio::Mixer output sample rate is not supported");
- _sampleRate = sampleRate;
-}
-
void MixerImpl::insertChannel(SoundHandle *handle, Channel *chan) {
int index = -1;
for (int i = 0; i != NUM_CHANNELS; i++) {
@@ -299,7 +292,6 @@ void MixerImpl::mixCallback(byte *samples, uint len) {
// Since the mixer callback has been called, the mixer must be ready...
_mixerReady = true;
- assert(_sampleRate > 0);
// zero the buf
memset(buf, 0, 2 * len * sizeof(int16));
@@ -376,7 +368,7 @@ Timestamp MixerImpl::getElapsedTime(SoundHandle handle) {
const int index = handle._val % NUM_CHANNELS;
if (!_channels[index] || _channels[index]->getHandle()._val != handle._val)
- return Timestamp(0, _sampleRate ? _sampleRate : 1);
+ return Timestamp(0, _sampleRate);
return _channels[index]->getElapsedTime();
}
diff --git a/sound/mixer_intern.h b/sound/mixer_intern.h
index a1037f1107..2ccd1ff2bf 100644
--- a/sound/mixer_intern.h
+++ b/sound/mixer_intern.h
@@ -60,7 +60,7 @@ private:
OSystem *_syst;
Common::Mutex _mutex;
- uint _sampleRate;
+ const uint _sampleRate;
bool _mixerReady;
uint32 _handleSeed;
@@ -69,7 +69,8 @@ private:
public:
- MixerImpl(OSystem *system);
+
+ MixerImpl(OSystem *system, uint sampleRate);
~MixerImpl();
virtual bool isReady() const { return _mixerReady; }
@@ -123,21 +124,9 @@ public:
/**
* Set the internal 'is ready' flag of the mixer.
* Backends should invoke Mixer::setReady(true) once initialisation of
- * their audio system has been completed (and in particular, *after*
- * setOutputRate() has been called).
+ * their audio system has been completed.
*/
void setReady(bool ready);
-
- /**
- * Set the output sample rate.
- *
- * @param sampleRate the new output sample rate
- *
- * @note Right now, this can be done exactly ONCE. That is, the mixer
- * currently does not support changing the output sample rate after it
- * has been set for the first time. This may change in the future.
- */
- void setOutputRate(uint sampleRate);
};