diff options
Diffstat (limited to 'backends')
-rw-r--r-- | backends/platform/PalmOS/Src/be_base.h | 3 | ||||
-rw-r--r-- | backends/platform/PalmOS/Src/os5_sound.cpp | 9 | ||||
-rw-r--r-- | backends/platform/dc/dc.h | 4 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/osystem_ds.cpp | 4 | ||||
-rw-r--r-- | backends/platform/ds/arm9/source/osystem_ds.h | 2 | ||||
-rw-r--r-- | backends/platform/gp2x/gp2x-common.h | 3 | ||||
-rw-r--r-- | backends/platform/gp2x/gp2x.cpp | 25 | ||||
-rw-r--r-- | backends/platform/iphone/osys_main.h | 1 | ||||
-rw-r--r-- | backends/platform/iphone/osys_sound.cpp | 4 | ||||
-rw-r--r-- | backends/platform/n64/osys_n64_base.cpp | 6 | ||||
-rw-r--r-- | backends/platform/psp/osys_psp.cpp | 19 | ||||
-rw-r--r-- | backends/platform/psp/osys_psp.h | 1 | ||||
-rw-r--r-- | backends/platform/sdl/sdl.cpp | 23 | ||||
-rw-r--r-- | backends/platform/sdl/sdl.h | 3 | ||||
-rw-r--r-- | backends/platform/symbian/src/SymbianOS.cpp | 18 | ||||
-rw-r--r-- | backends/platform/wince/wince-sdl.cpp | 32 | ||||
-rw-r--r-- | backends/platform/wince/wince-sdl.h | 5 |
17 files changed, 66 insertions, 96 deletions
diff --git a/backends/platform/PalmOS/Src/be_base.h b/backends/platform/PalmOS/Src/be_base.h index 1d5883be38..30130ebfff 100644 --- a/backends/platform/PalmOS/Src/be_base.h +++ b/backends/platform/PalmOS/Src/be_base.h @@ -184,8 +184,6 @@ protected: Boolean _useNumPad, _showBatLow; UInt32 _batCheckTicks, _batCheckLast; - int _samplesPerSec; - public: void initBackend(); @@ -251,7 +249,6 @@ public: virtual void unlockMutex(MutexRef mutex) {} virtual void deleteMutex(MutexRef mutex) {} - int getOutputSampleRate() const { return _samplesPerSec; } virtual Audio::Mixer *getMixer(); void quit(); diff --git a/backends/platform/PalmOS/Src/os5_sound.cpp b/backends/platform/PalmOS/Src/os5_sound.cpp index 7553f032a9..1898f6ae90 100644 --- a/backends/platform/PalmOS/Src/os5_sound.cpp +++ b/backends/platform/PalmOS/Src/os5_sound.cpp @@ -98,10 +98,11 @@ 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"); + samplesPerSec = ConfMan.getInt("output_rate"); else - _samplesPerSec = SAMPLES_PER_SEC; + samplesPerSec = SAMPLES_PER_SEC; // try to create sound stream if (OPTIONS_TST(kOptPalmSoundAPI)) { @@ -109,7 +110,7 @@ bool OSystem_PalmOS5::setSoundCallback(SoundProc proc, void *param) { &_soundEx.handle, sndOutput, sndFormatPCM, - _samplesPerSec, + samplesPerSec, sndInt16Little, sndStereo, sound_callback(), @@ -132,7 +133,7 @@ bool OSystem_PalmOS5::setSoundCallback(SoundProc proc, void *param) { } // if not true some scenes (indy3 256,...) may freeze (ESC to skip) - _mixerMgr->setOutputRate(_samplesPerSec); + _mixerMgr->setOutputRate(samplesPerSec); _mixerMgr->setReady(true); return true; diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index 393e72caed..8a122ebb27 100644 --- a/backends/platform/dc/dc.h +++ b/backends/platform/dc/dc.h @@ -135,10 +135,6 @@ class OSystem_Dreamcast : private DCHardware, public BaseBackend, public Filesys // Returns true if an event was retrieved. bool pollEvent(Common::Event &event); - // Determine the output sample rate. Audio data provided by the sound - // callback will be played using this rate. - int getOutputSampleRate() const; - // Initialise the specified CD drive for audio playback. bool openCD(int drive); diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index 111f3a888b..164e6abbcd 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -697,10 +697,6 @@ void OSystem_DS::unlockMutex(MutexRef mutex) { void OSystem_DS::deleteMutex(MutexRef mutex) { } -int OSystem_DS::getOutputSampleRate() const { - return DS::getSoundFrequency(); -} - bool OSystem_DS::openCD(int drive) { return DS::CD::checkCD(); } diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h index 27c4052d9d..10b4c87f66 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.h +++ b/backends/platform/ds/arm9/source/osystem_ds.h @@ -125,8 +125,6 @@ public: virtual void unlockMutex(MutexRef mutex); virtual void deleteMutex(MutexRef mutex); - virtual int getOutputSampleRate() const; - virtual bool openCD(int drive); virtual bool pollCD(); diff --git a/backends/platform/gp2x/gp2x-common.h b/backends/platform/gp2x/gp2x-common.h index 6878673024..748d80ba1c 100644 --- a/backends/platform/gp2x/gp2x-common.h +++ b/backends/platform/gp2x/gp2x-common.h @@ -207,9 +207,6 @@ protected: bool _overlayVisible; Graphics::PixelFormat _overlayFormat; - // Audio - int _samplesPerSec; - // CD Audio SDL_CD *_cdrom; int _cdTrack, _cdNumLoops, _cdStartFrame, _cdDuration; diff --git a/backends/platform/gp2x/gp2x.cpp b/backends/platform/gp2x/gp2x.cpp index e15281dbf4..139c64ed38 100644 --- a/backends/platform/gp2x/gp2x.cpp +++ b/backends/platform/gp2x/gp2x.cpp @@ -246,7 +246,6 @@ OSystem_GP2X::OSystem_GP2X() _hwscreen(0), _screen(0), _tmpscreen(0), _overlayVisible(false), _overlayscreen(0), _tmpscreen2(0), - _samplesPerSec(0), _cdrom(0), _scalerProc(0), _modeChanged(false), _screenChangeCount(0), _dirtyChecksums(0), _mouseVisible(false), _mouseNeedsRedraw(false), _mouseData(0), _mouseSurface(0), _mouseOrigSurface(0), _cursorTargetScale(1), _cursorPaletteDisabled(true), @@ -582,25 +581,25 @@ void OSystem_GP2X::setupMixer() { SDL_AudioSpec obtained; // Determine the desired output sampling frequency. - _samplesPerSec = 0; + uint32 samplesPerSec = 0; if (ConfMan.hasKey("output_rate")) - _samplesPerSec = ConfMan.getInt("output_rate"); - if (_samplesPerSec <= 0) - _samplesPerSec = SAMPLES_PER_SEC; + samplesPerSec = ConfMan.getInt("output_rate"); + if (samplesPerSec <= 0) + samplesPerSec = SAMPLES_PER_SEC; //Quick EVIL Hack - DJWillis -// _samplesPerSec = 11025; +// 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. - int samples = 8192; - while (16 * samples >= _samplesPerSec) { + uint32 samples = 8192; + while (16 * samples >= samplesPerSec) { samples >>= 1; } memset(&desired, 0, sizeof(desired)); - desired.freq = _samplesPerSec; + desired.freq = samplesPerSec; desired.format = AUDIO_S16SYS; desired.channels = 2; //desired.samples = (uint16)samples; @@ -615,17 +614,17 @@ void OSystem_GP2X::setupMixer() { if (SDL_OpenAudio(&desired, &obtained) != 0) { warning("Could not open audio device: %s", SDL_GetError()); - _samplesPerSec = 0; + 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; - debug(1, "Output sample rate: %d Hz", _samplesPerSec); + 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); + _mixer->setOutputRate(samplesPerSec); _mixer->setReady(true); #ifdef MIXER_DOUBLE_BUFFERING diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index c923d0f4e8..3c80c83998 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -162,7 +162,6 @@ public: static void mixCallback(void *sys, byte *samples, int len); virtual void setupMixer(void); - virtual int getOutputSampleRate() const; virtual void setTimerCallback(TimerProc callback, int interval); virtual int getScreenChangeID() const { return _screenChangeCount; } virtual void quit(); diff --git a/backends/platform/iphone/osys_sound.cpp b/backends/platform/iphone/osys_sound.cpp index 60b8d04a9b..6affc114f3 100644 --- a/backends/platform/iphone/osys_sound.cpp +++ b/backends/platform/iphone/osys_sound.cpp @@ -105,7 +105,3 @@ void OSystem_IPHONE::stopSoundsystem() { AudioQueueDispose(s_AudioQueue.queue, true); _mixer->setReady(false); } - -int OSystem_IPHONE::getOutputSampleRate() const { - return AUDIO_SAMPLE_RATE; -} diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp index 746de23403..f268201e9a 100644 --- a/backends/platform/n64/osys_n64_base.cpp +++ b/backends/platform/n64/osys_n64_base.cpp @@ -183,9 +183,6 @@ void OSystem_N64::initBackend() { _savefile = new PAKSaveManager(); } - _mixer = new Audio::MixerImpl(this); - _mixer->setReady(false); - _timer = new DefaultTimerManager(); setTimerCallback(&timer_handler, 10); @@ -890,6 +887,9 @@ void OSystem_N64::setTimerCallback(TimerProc callback, int interval) { } void OSystem_N64::setupMixer(void) { + _mixer = new Audio::MixerImpl(this); + _mixer->setReady(false); + enableAudioPlayback(); } diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp index e29a9da763..50f233f752 100644 --- a/backends/platform/psp/osys_psp.cpp +++ b/backends/platform/psp/osys_psp.cpp @@ -90,8 +90,6 @@ OSystem_PSP::OSystem_PSP() : _screenWidth(0), _screenHeight(0), _overlayWidth(0) _cursorPaletteDisabled = true; - _samplesPerSec = 0; - //init SDL uint32 sdlFlags = SDL_INIT_AUDIO | SDL_INIT_TIMER; SDL_Init(sdlFlags); @@ -951,27 +949,28 @@ 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)); if (ConfMan.hasKey("output_rate")) - _samplesPerSec = ConfMan.getInt("output_rate"); + samplesPerSec = ConfMan.getInt("output_rate"); else - _samplesPerSec = SAMPLES_PER_SEC; + 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. - uint16 samples = 0x8000; + uint32 samples = 0x8000; for (;;) { - if (samples / (_samplesPerSec / 1000) < 100) + if (samples / (samplesPerSec / 1000) < 100) break; samples >>= 1; } - desired.freq = _samplesPerSec; + desired.freq = samplesPerSec; desired.format = AUDIO_S16SYS; desired.channels = 2; desired.samples = samples; @@ -984,16 +983,16 @@ void OSystem_PSP::setupMixer(void) { if (SDL_OpenAudio(&desired, &obtained) != 0) { warning("Could not open audio: %s", SDL_GetError()); - _samplesPerSec = 0; + 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; + samplesPerSec = obtained.freq; // Tell the mixer that we are ready and start the sound processing - _mixer->setOutputRate(_samplesPerSec); + _mixer->setOutputRate(samplesPerSec); _mixer->setReady(true); SDL_PauseAudio(0); diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h index 2d52ea2218..ed920e53c1 100644 --- a/backends/platform/psp/osys_psp.h +++ b/backends/platform/psp/osys_psp.h @@ -86,7 +86,6 @@ protected: uint32 _lastPadCheck; uint32 _padAccel; - uint32 _samplesPerSec; SceCtrlData pad; Common::SaveFileManager *_savefile; diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 27ae43d4b8..c5eb89ec8d 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -230,7 +230,6 @@ OSystem_SDL::OSystem_SDL() #endif _overlayVisible(false), _overlayscreen(0), _tmpscreen2(0), - _samplesPerSec(0), _cdrom(0), _scalerProc(0), _modeChanged(false), _screenChangeCount(0), _dirtyChecksums(0), _scrollLock(false), _mouseVisible(false), _mouseNeedsRedraw(false), _mouseData(0), _mouseSurface(0), @@ -709,22 +708,22 @@ void OSystem_SDL::setupMixer() { SDL_AudioSpec desired; // Determine the desired output sampling frequency. - _samplesPerSec = 0; + uint32 samplesPerSec = 0; if (ConfMan.hasKey("output_rate")) - _samplesPerSec = ConfMan.getInt("output_rate"); - if (_samplesPerSec <= 0) - _samplesPerSec = SAMPLES_PER_SEC; + samplesPerSec = ConfMan.getInt("output_rate"); + if (samplesPerSec <= 0) + 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 // that it must be a power of two. So e.g. at 22050 Hz, we request a // sample buffer size of 2048. - int samples = 8192; - while (samples * 16 > _samplesPerSec * 2) + uint32 samples = 8192; + while (samples * 16 > samplesPerSec * 2) samples >>= 1; memset(&desired, 0, sizeof(desired)); - desired.freq = _samplesPerSec; + desired.freq = samplesPerSec; desired.format = AUDIO_S16SYS; desired.channels = 2; desired.samples = (uint16)samples; @@ -738,17 +737,17 @@ void OSystem_SDL::setupMixer() { if (SDL_OpenAudio(&desired, &_obtainedRate) != 0) { warning("Could not open audio device: %s", SDL_GetError()); - _samplesPerSec = 0; + 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 = _obtainedRate.freq; - debug(1, "Output sample rate: %d Hz", _samplesPerSec); + 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); + _mixer->setOutputRate(samplesPerSec); _mixer->setReady(true); #if MIXER_DOUBLE_BUFFERING diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 2c1a22e7d6..e2af21320a 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -283,9 +283,6 @@ protected: bool _overlayVisible; Graphics::PixelFormat _overlayFormat; - // Audio - int _samplesPerSec; - // CD Audio SDL_CD *_cdrom; int _cdTrack, _cdNumLoops, _cdStartFrame, _cdDuration; diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp index aaa2c87158..480b62849e 100644 --- a/backends/platform/symbian/src/SymbianOS.cpp +++ b/backends/platform/symbian/src/SymbianOS.cpp @@ -222,13 +222,13 @@ void OSystem_SDL_Symbian::setupMixer() { memset(&desired, 0, sizeof(desired)); - _samplesPerSec = 0; + uint32 samplesPerSec = 0; if (ConfMan.hasKey("output_rate")) - _samplesPerSec = ConfMan.getInt("output_rate"); + samplesPerSec = ConfMan.getInt("output_rate"); - if (_samplesPerSec <= 0) - _samplesPerSec = SAMPLES_PER_SEC; + 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 @@ -237,12 +237,12 @@ void OSystem_SDL_Symbian::setupMixer() { uint32 samples = 0x8000; for (;;) { - if ((1000 * samples) / _samplesPerSec < 100) + if ((1000 * samples) / samplesPerSec < 100) break; samples >>= 1; } - desired.freq = _samplesPerSec; + desired.freq = samplesPerSec; desired.format = AUDIO_S16SYS; desired.channels = 2; desired.samples = (uint16)samples; @@ -256,13 +256,13 @@ void OSystem_SDL_Symbian::setupMixer() { if (SDL_OpenAudio(&desired, &obtained) != 0) { warning("Could not open audio device: %s", SDL_GetError()); - _samplesPerSec = 0; + 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; + samplesPerSec = obtained.freq; _channels = obtained.channels; // Need to create mixbuffer for stereo mix to downmix @@ -271,7 +271,7 @@ void OSystem_SDL_Symbian::setupMixer() { } // Tell the mixer that we are ready and start the sound processing - _mixer->setOutputRate(_samplesPerSec); + _mixer->setOutputRate(samplesPerSec); _mixer->setReady(true); SDL_PauseAudio(0); } diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp index 8bf3772db6..e359ba1744 100644 --- a/backends/platform/wince/wince-sdl.cpp +++ b/backends/platform/wince/wince-sdl.cpp @@ -783,16 +783,16 @@ void OSystem_WINCE3::setupMixer() { SDL_AudioSpec desired; int thread_priority; - compute_sample_rate(); - if (_sampleRate == 0) - warning("setSoundCallback called with 0 _sampleRate - audio will not work"); - else if (_mixer && _mixer->getOutputRate() == _sampleRate) { + uint32 sampleRate = compute_sample_rate(); + if (sampleRate == 0) + warning("setSoundCallback 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; } memset(&desired, 0, sizeof(desired)); - desired.freq = _sampleRate; + desired.freq = sampleRate; desired.format = AUDIO_S16SYS; desired.channels = 2; desired.samples = 128; @@ -817,7 +817,7 @@ void OSystem_WINCE3::setupMixer() { _mixer->setReady(false); } else { - debug(1, "Sound opened OK, mixing at %d Hz", _sampleRate); + debug(1, "Sound opened OK, mixing at %d Hz", sampleRate); // Re-create mixer to match the output rate int vol1 = _mixer->getVolumeForSoundType(Audio::Mixer::kPlainSoundType); @@ -830,7 +830,7 @@ void OSystem_WINCE3::setupMixer() { _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, vol2); _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, vol3); _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, vol4); - _mixer->setOutputRate(_sampleRate); + _mixer->setOutputRate(sampleRate); _mixer->setReady(true); SDL_PauseAudio(0); } @@ -875,7 +875,9 @@ bool OSystem_WINCE3::checkOggHighSampleRate() { } #endif -void OSystem_WINCE3::compute_sample_rate() { +uint32 OSystem_WINCE3::compute_sample_rate() { + uint32 sampleRate; + // Force at least medium quality FM synthesis for FOTAQ Common::String gameid(ConfMan.get("gameid")); if (gameid == "queen") { @@ -887,24 +889,22 @@ void OSystem_WINCE3::compute_sample_rate() { } // See if the output frequency is forced by the game if (gameid == "ft" || gameid == "dig" || gameid == "comi" || gameid == "queen" || gameid == "sword" || gameid == "agi") - _sampleRate = SAMPLES_PER_SEC_NEW; + sampleRate = SAMPLES_PER_SEC_NEW; else { if (ConfMan.hasKey("high_sample_rate") && ConfMan.getBool("high_sample_rate")) - _sampleRate = SAMPLES_PER_SEC_NEW; + sampleRate = SAMPLES_PER_SEC_NEW; else - _sampleRate = SAMPLES_PER_SEC_OLD; + sampleRate = SAMPLES_PER_SEC_OLD; } #ifdef USE_VORBIS // Modify the sample rate on the fly if OGG is involved - if (_sampleRate == SAMPLES_PER_SEC_OLD) + if (sampleRate == SAMPLES_PER_SEC_OLD) if (checkOggHighSampleRate()) - _sampleRate = SAMPLES_PER_SEC_NEW; + sampleRate = SAMPLES_PER_SEC_NEW; #endif -} -int OSystem_WINCE3::getOutputSampleRate() const { - return _sampleRate; + return sampleRate; } void OSystem_WINCE3::engineInit() { diff --git a/backends/platform/wince/wince-sdl.h b/backends/platform/wince/wince-sdl.h index 1aff930989..bbe601983e 100644 --- a/backends/platform/wince/wince-sdl.h +++ b/backends/platform/wince/wince-sdl.h @@ -132,7 +132,6 @@ protected: int getDefaultGraphicsMode() const; bool openCD(int drive); - int getOutputSampleRate() const; bool hasFeature(Feature f); void setFeatureState(Feature f, bool enable); @@ -153,7 +152,7 @@ private: void create_toolbar(); void update_game_settings(); void check_mappings(); - void compute_sample_rate(); + uint32 compute_sample_rate(); void retrieve_mouse_location(int &x, int &y); @@ -163,8 +162,6 @@ private: SDL_Surface *_toolbarHigh; // toolbar 640x80 bool _toolbarHighDrawn; // cache toolbar 640x80 - uint16 _sampleRate; // current audio sample rate - bool _freeLook; // freeLook mode (do not send mouse button events) bool _forceHideMouse; // force invisible mouse cursor |