[Scummvm-cvs-logs] SF.net SVN: scummvm:[48238] scummvm/trunk
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Fri Mar 12 00:39:54 CET 2010
Revision: 48238
http://scummvm.svn.sourceforge.net/scummvm/?rev=48238&view=rev
Author: fingolfin
Date: 2010-03-11 23:39:51 +0000 (Thu, 11 Mar 2010)
Log Message:
-----------
Replace Audio::MixerImpl::setOutputRate with a new 'sampleRate' param to the MixerImpl constructor
Modified Paths:
--------------
scummvm/trunk/backends/platform/PalmOS/Src/be_base.cpp
scummvm/trunk/backends/platform/PalmOS/Src/be_base.h
scummvm/trunk/backends/platform/PalmOS/Src/be_os5.h
scummvm/trunk/backends/platform/PalmOS/Src/os5_sound.cpp
scummvm/trunk/backends/platform/dc/dcmain.cpp
scummvm/trunk/backends/platform/ds/arm9/source/osystem_ds.cpp
scummvm/trunk/backends/platform/gp2x/gp2x.cpp
scummvm/trunk/backends/platform/iphone/osys_sound.cpp
scummvm/trunk/backends/platform/n64/osys_n64_base.cpp
scummvm/trunk/backends/platform/n64/osys_n64_utilities.cpp
scummvm/trunk/backends/platform/null/null.cpp
scummvm/trunk/backends/platform/ps2/systemps2.cpp
scummvm/trunk/backends/platform/psp/osys_psp.cpp
scummvm/trunk/backends/platform/sdl/sdl.cpp
scummvm/trunk/backends/platform/symbian/src/SymbianOS.cpp
scummvm/trunk/backends/platform/symbian/src/SymbianOS.h
scummvm/trunk/backends/platform/wii/osystem.cpp
scummvm/trunk/backends/platform/wii/osystem_sfx.cpp
scummvm/trunk/backends/platform/wince/wince-sdl.cpp
scummvm/trunk/sound/mixer.cpp
scummvm/trunk/sound/mixer_intern.h
Modified: scummvm/trunk/backends/platform/PalmOS/Src/be_base.cpp
===================================================================
--- scummvm/trunk/backends/platform/PalmOS/Src/be_base.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/PalmOS/Src/be_base.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -110,9 +110,7 @@
// 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
Modified: scummvm/trunk/backends/platform/PalmOS/Src/be_base.h
===================================================================
--- scummvm/trunk/backends/platform/PalmOS/Src/be_base.h 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/PalmOS/Src/be_base.h 2010-03-11 23:39:51 UTC (rev 48238)
@@ -117,7 +117,7 @@
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:
Modified: scummvm/trunk/backends/platform/PalmOS/Src/be_os5.h
===================================================================
--- scummvm/trunk/backends/platform/PalmOS/Src/be_os5.h 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/PalmOS/Src/be_os5.h 2010-03-11 23:39:51 UTC (rev 48238)
@@ -140,7 +140,7 @@
virtual SndStreamVariableBufferCallback sound_callback();
virtual void sound_handler();
- virtual bool setSoundCallback(SoundProc proc, void *param);
+ virtual bool setupMixer();
void clearSoundCallback();
protected:
Modified: scummvm/trunk/backends/platform/PalmOS/Src/os5_sound.cpp
===================================================================
--- scummvm/trunk/backends/platform/PalmOS/Src/os5_sound.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/PalmOS/Src/os5_sound.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -66,7 +66,6 @@
_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 @@
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 @@
#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 @@
_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 @@
}
// if not true some scenes (indy3 256,...) may freeze (ESC to skip)
- _mixerMgr->setOutputRate(samplesPerSec);
_mixerMgr->setReady(true);
return true;
Modified: scummvm/trunk/backends/platform/dc/dcmain.cpp
===================================================================
--- scummvm/trunk/backends/platform/dc/dcmain.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/dc/dcmain.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -55,9 +55,10 @@
{
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);
}
Modified: scummvm/trunk/backends/platform/ds/arm9/source/osystem_ds.cpp
===================================================================
--- scummvm/trunk/backends/platform/ds/arm9/source/osystem_ds.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/ds/arm9/source/osystem_ds.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -98,7 +98,6 @@
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 @@
DS::startSound(11025, 4096);
}
- _mixer->setOutputRate(DS::getSoundFrequency());
+ _mixer = new Audio::MixerImpl(this, DS::getSoundFrequency());
_mixer->setReady(true);
OSystem::initBackend();
Modified: scummvm/trunk/backends/platform/gp2x/gp2x.cpp
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/gp2x/gp2x.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -587,16 +587,13 @@
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 @@
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 @@
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
Modified: scummvm/trunk/backends/platform/iphone/osys_sound.cpp
===================================================================
--- scummvm/trunk/backends/platform/iphone/osys_sound.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/iphone/osys_sound.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -46,8 +46,7 @@
}
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 @@
return;
}
- _mixer->setOutputRate(AUDIO_SAMPLE_RATE);
_mixer->setReady(true);
}
Modified: scummvm/trunk/backends/platform/n64/osys_n64_base.cpp
===================================================================
--- scummvm/trunk/backends/platform/n64/osys_n64_base.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/n64/osys_n64_base.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -887,7 +887,7 @@
}
void OSystem_N64::setupMixer(void) {
- _mixer = new Audio::MixerImpl(this);
+ _mixer = new Audio::MixerImpl(this, DEFAULT_SOUND_SAMPLE_RATE);
_mixer->setReady(false);
enableAudioPlayback();
Modified: scummvm/trunk/backends/platform/n64/osys_n64_utilities.cpp
===================================================================
--- scummvm/trunk/backends/platform/n64/osys_n64_utilities.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/n64/osys_n64_utilities.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -60,7 +60,6 @@
osys->_audioBufferSize = getAIBufferSize();
if (_firstRun) {
- localmixer->setOutputRate(DEFAULT_SOUND_SAMPLE_RATE);
localmixer->setReady(true);
_firstRun = false;
}
Modified: scummvm/trunk/backends/platform/null/null.cpp
===================================================================
--- scummvm/trunk/backends/platform/null/null.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/null/null.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -108,9 +108,6 @@
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 @@
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::deleteMutex(MutexRef mutex) {
}
-bool OSystem_NULL::setSoundCallback(SoundProc proc, void *param) {
- return true;
-}
-
void OSystem_NULL::quit() {
}
Modified: scummvm/trunk/backends/platform/ps2/systemps2.cpp
===================================================================
--- scummvm/trunk/backends/platform/ps2/systemps2.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/ps2/systemps2.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -339,8 +339,7 @@
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();
Modified: scummvm/trunk/backends/platform/psp/osys_psp.cpp
===================================================================
--- scummvm/trunk/backends/platform/psp/osys_psp.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/psp/osys_psp.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -949,27 +949,23 @@
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 @@
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 @@
// 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);
Modified: scummvm/trunk/backends/platform/sdl/sdl.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/sdl/sdl.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -715,7 +715,7 @@
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 @@
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 @@
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
Modified: scummvm/trunk/backends/platform/symbian/src/SymbianOS.cpp
===================================================================
--- scummvm/trunk/backends/platform/symbian/src/SymbianOS.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/symbian/src/SymbianOS.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -220,28 +220,22 @@
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 @@
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 @@
_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;
Modified: scummvm/trunk/backends/platform/symbian/src/SymbianOS.h
===================================================================
--- scummvm/trunk/backends/platform/symbian/src/SymbianOS.h 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/symbian/src/SymbianOS.h 2010-03-11 23:39:51 UTC (rev 48238)
@@ -63,9 +63,7 @@
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);
Modified: scummvm/trunk/backends/platform/wii/osystem.cpp
===================================================================
--- scummvm/trunk/backends/platform/wii/osystem.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/wii/osystem.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -136,7 +136,6 @@
strcpy(buf, "/");
_savefile = new DefaultSaveFileManager(buf);
- _mixer = new Audio::MixerImpl(this);
_timer = new DefaultTimerManager();
initGfx();
Modified: scummvm/trunk/backends/platform/wii/osystem_sfx.cpp
===================================================================
--- scummvm/trunk/backends/platform/wii/osystem_sfx.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/wii/osystem_sfx.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -65,6 +65,8 @@
}
void OSystem_Wii::initSfx() {
+ _mixer = new Audio::MixerImpl(this, 48000);
+
sfx_thread_running = false;
sfx_thread_quit = false;
@@ -96,7 +98,6 @@
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);
Modified: scummvm/trunk/backends/platform/wince/wince-sdl.cpp
===================================================================
--- scummvm/trunk/backends/platform/wince/wince-sdl.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/backends/platform/wince/wince-sdl.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -785,7 +785,7 @@
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 @@
// 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 @@
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);
}
Modified: scummvm/trunk/sound/mixer.cpp
===================================================================
--- scummvm/trunk/sound/mixer.cpp 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/sound/mixer.cpp 2010-03-11 23:39:51 UTC (rev 48238)
@@ -160,9 +160,11 @@
#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;
for (i = 0; i < ARRAYSIZE(_volumeForSoundType); i++)
@@ -179,21 +181,12 @@
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 @@
// 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 @@
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();
}
Modified: scummvm/trunk/sound/mixer_intern.h
===================================================================
--- scummvm/trunk/sound/mixer_intern.h 2010-03-11 20:33:27 UTC (rev 48237)
+++ scummvm/trunk/sound/mixer_intern.h 2010-03-11 23:39:51 UTC (rev 48238)
@@ -60,7 +60,7 @@
OSystem *_syst;
Common::Mutex _mutex;
- uint _sampleRate;
+ const uint _sampleRate;
bool _mixerReady;
uint32 _handleSeed;
@@ -69,7 +69,8 @@
public:
- MixerImpl(OSystem *system);
+
+ MixerImpl(OSystem *system, uint sampleRate);
~MixerImpl();
virtual bool isReady() const { return _mixerReady; }
@@ -123,21 +124,9 @@
/**
* 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);
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list