diff options
author | Paul Gilbert | 2016-07-26 19:48:14 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-26 19:48:14 -0400 |
commit | 504cf6ecb688a3f1c65a857bffd527d8b0e6ba63 (patch) | |
tree | 0c0d96d4061c11850c851f0fc981c75a58c20515 /backends/mixer/sdl/sdl-mixer.cpp | |
parent | d8c28d15ae553d047b7e571f98727fa79ee143f3 (diff) | |
parent | e19922d181e775791f9105b8be7ff410770ede51 (diff) | |
download | scummvm-rg350-504cf6ecb688a3f1c65a857bffd527d8b0e6ba63.tar.gz scummvm-rg350-504cf6ecb688a3f1c65a857bffd527d8b0e6ba63.tar.bz2 scummvm-rg350-504cf6ecb688a3f1c65a857bffd527d8b0e6ba63.zip |
Merge branch 'master' into xeen
Diffstat (limited to 'backends/mixer/sdl/sdl-mixer.cpp')
-rw-r--r-- | backends/mixer/sdl/sdl-mixer.cpp | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/backends/mixer/sdl/sdl-mixer.cpp b/backends/mixer/sdl/sdl-mixer.cpp index dc0c853808..0ca3231892 100644 --- a/backends/mixer/sdl/sdl-mixer.cpp +++ b/backends/mixer/sdl/sdl-mixer.cpp @@ -30,8 +30,10 @@ #include "common/config-manager.h" #include "common/textconsole.h" -#ifdef GP2X +#if defined(GP2X) #define SAMPLES_PER_SEC 11025 +#elif defined(PLAYSTATION3) +#define SAMPLES_PER_SEC 48000 #else #define SAMPLES_PER_SEC 44100 #endif @@ -78,34 +80,49 @@ void SdlMixerManager::init() { if (SDL_OpenAudio(&fmt, &_obtained) != 0) { warning("Could not open audio device: %s", SDL_GetError()); + // The mixer is not marked as ready _mixer = new Audio::MixerImpl(g_system, desired.freq); - assert(_mixer); - _mixer->setReady(false); - } else { - debug(1, "Output sample rate: %d Hz", _obtained.freq); - if (_obtained.freq != desired.freq) - warning("SDL mixer output sample rate: %d differs from desired: %d", _obtained.freq, desired.freq); + return; + } + + // The obtained sample format is not supported by the mixer, call + // SDL_OpenAudio again with NULL as the second argument to force + // SDL to do resampling to the desired audio spec. + if (_obtained.format != desired.format) { + debug(1, "SDL mixer sound format: %d differs from desired: %d", _obtained.format, desired.format); + SDL_CloseAudio(); + + if (SDL_OpenAudio(&fmt, NULL) != 0) { + warning("Could not open audio device: %s", SDL_GetError()); + + // The mixer is not marked as ready + _mixer = new Audio::MixerImpl(g_system, desired.freq); + return; + } - debug(1, "Output buffer size: %d samples", _obtained.samples); - if (_obtained.samples != desired.samples) - warning("SDL mixer output buffer size: %d differs from desired: %d", _obtained.samples, desired.samples); + _obtained = desired; + } + + debug(1, "Output sample rate: %d Hz", _obtained.freq); + if (_obtained.freq != desired.freq) + warning("SDL mixer output sample rate: %d differs from desired: %d", _obtained.freq, desired.freq); - if (_obtained.format != desired.format) - warning("SDL mixer sound format: %d differs from desired: %d", _obtained.format, desired.format); + debug(1, "Output buffer size: %d samples", _obtained.samples); + if (_obtained.samples != desired.samples) + warning("SDL mixer output buffer size: %d differs from desired: %d", _obtained.samples, desired.samples); #ifndef __SYMBIAN32__ - // The SymbianSdlMixerManager does stereo->mono downmixing, - // but otherwise we require stereo output. - if (_obtained.channels != 2) - error("SDL mixer output requires stereo output device"); + // The SymbianSdlMixerManager does stereo->mono downmixing, + // but otherwise we require stereo output. + if (_obtained.channels != 2) + error("SDL mixer output requires stereo output device"); #endif - _mixer = new Audio::MixerImpl(g_system, _obtained.freq); - assert(_mixer); - _mixer->setReady(true); + _mixer = new Audio::MixerImpl(g_system, _obtained.freq); + assert(_mixer); + _mixer->setReady(true); - startAudio(); - } + startAudio(); } SDL_AudioSpec SdlMixerManager::getAudioSpec(uint32 outputRate) { |