diff options
Diffstat (limited to 'backends/platform/symbian/src/SymbianOS.cpp')
-rw-r--r-- | backends/platform/symbian/src/SymbianOS.cpp | 37 |
1 files changed, 14 insertions, 23 deletions
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; |