diff options
author | Max Horn | 2008-06-28 15:28:29 +0000 |
---|---|---|
committer | Max Horn | 2008-06-28 15:28:29 +0000 |
commit | c45d632f3b8c2d8c8aa46b05db758898de863e97 (patch) | |
tree | 7b8fee1589eb6a733aea389b305752ee7d63562b /backends/platform/symbian/src | |
parent | e68efca5a19fd738a78a61ea21efd19280521f31 (diff) | |
download | scummvm-rg350-c45d632f3b8c2d8c8aa46b05db758898de863e97.tar.gz scummvm-rg350-c45d632f3b8c2d8c8aa46b05db758898de863e97.tar.bz2 scummvm-rg350-c45d632f3b8c2d8c8aa46b05db758898de863e97.zip |
Patch ##1956946 (Audio::Mixer internal API revision) with some tweaks
svn-id: r32828
Diffstat (limited to 'backends/platform/symbian/src')
-rw-r--r-- | backends/platform/symbian/src/SymbianOS.cpp | 69 | ||||
-rw-r--r-- | backends/platform/symbian/src/SymbianOS.h | 9 |
2 files changed, 38 insertions, 40 deletions
diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp index d3e92731db..dfeb24d825 100644 --- a/backends/platform/symbian/src/SymbianOS.cpp +++ b/backends/platform/symbian/src/SymbianOS.cpp @@ -173,11 +173,8 @@ void OSystem_SDL_Symbian::quit() { OSystem_SDL::quit(); } -bool OSystem_SDL_Symbian::setSoundCallback(SoundProc proc, void *param) { +void OSystem_SDL_Symbian::setupMixer() { - // First save the proc and param - _sound_proc_param = param; - _sound_proc = proc; SDL_AudioSpec desired; SDL_AudioSpec obtained; @@ -207,48 +204,53 @@ bool OSystem_SDL_Symbian::setSoundCallback(SoundProc proc, void *param) { desired.format = AUDIO_S16SYS; desired.channels = 2; desired.samples = (uint16)samples; -#ifdef S60 desired.callback = symbianMixCallback; desired.userdata = this; -#else - desired.callback = proc; - desired.userdata = param; -#endif + + // 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()); - return false; - } - // Note: This should be the obtained output rate, but it seems that at - // least on some platforms SDL will lie and claim it did get the rate - // even if it didn't. Probably only happens for "weird" rates, though. - _samplesPerSec = obtained.freq; - _channels = obtained.channels; - - // Need to create mixbuffer for stereo mix to downmix - if (_channels != 2) { - _stereo_mix_buffer = new byte [obtained.size*2];//*2 for stereo values + _samplesPerSec = 0; + _mixer->setReady(false); + } else { + // Note: This should be the obtained output rate, but it seems that at + // least on some platforms SDL will lie and claim it did get the rate + // even if it didn't. Probably only happens for "weird" rates, though. + _samplesPerSec = obtained.freq; + _channels = obtained.channels; + + // Need to create mixbuffer for stereo mix to downmix + if (_channels != 2) { + _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); + _mixer->setReady(true); + SDL_PauseAudio(0); } - - SDL_PauseAudio(0); - return true; } /** * The mixer callback function, passed on to OSystem::setSoundCallback(). * This simply calls the mix() method. */ -void OSystem_SDL_Symbian::symbianMixCallback(void *s, byte *samples, int len) { - static_cast <OSystem_SDL_Symbian*>(s)->symbianMix(samples,len); -} +void OSystem_SDL_Symbian::symbianMixCallback(void *sys, byte *samples, int len) { + OSystem_SDL_Symbian *this_ = (OSystem_SDL_Symbian *)sys; + assert(this_); + if (!this_->_mixer) + return; -/** - * Actual mixing implementation - */ -void OSystem_SDL_Symbian::symbianMix(byte *samples, int len) { +#ifdef S60 // If not stereo then we need to downmix if (_channels != 2) { - _sound_proc(_sound_proc_param, _stereo_mix_buffer, len * 2); + this_->_mixer->mixCallback(_stereo_mix_buffer, len * 2); + int16 *bitmixDst = (int16 *)samples; int16 *bitmixSrc = (int16 *)_stereo_mix_buffer; @@ -258,9 +260,12 @@ void OSystem_SDL_Symbian::symbianMix(byte *samples, int len) { bitmixSrc += 2; } } else - _sound_proc(_sound_proc_param, samples, len); +#else + this_->_mixer->mixCallback(samples, len); +#endif } + /** * This is an implementation by the remapKey function * @param SDL_Event to remap diff --git a/backends/platform/symbian/src/SymbianOS.h b/backends/platform/symbian/src/SymbianOS.h index 77e42cd476..71d24f6286 100644 --- a/backends/platform/symbian/src/SymbianOS.h +++ b/backends/platform/symbian/src/SymbianOS.h @@ -58,7 +58,7 @@ public: // This function is overridden by the symbian port in order to provide MONO audio // downmix is done by supplying our own audiocallback // - virtual bool setSoundCallback(SoundProc proc, void *param); // overloaded by CE backend + virtual void setupMixer(); // overloaded by CE backend // Overloaded from SDL_Commmon void quit(); @@ -70,11 +70,6 @@ protected: // static void symbianMixCallback(void *s, byte *samples, int len); - // - // Actual mixing implementation - // - void symbianMix(byte *samples, int len); - virtual FilesystemFactory *getFilesystemFactory(); public: // vibration support @@ -121,8 +116,6 @@ protected: // Audio int _channels; - SoundProc _sound_proc; - void *_sound_proc_param; byte *_stereo_mix_buffer; // Used to handle joystick navi zones |