From b9a107499911873a0f5e5452d292f6541f0f001a Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Fri, 27 Jun 2014 16:45:58 +0200 Subject: PS3: Make use of an updated SDL2 version This version, available at https://bitbucket.org/bgK/sdl_psl1ght, is based on SDL 2.0.3. --- backends/audiocd/sdl/sdl-audiocd.cpp | 4 +- backends/audiocd/sdl/sdl-audiocd.h | 4 +- backends/events/ps3sdl/ps3sdl-events.cpp | 8 +-- backends/events/sdl/sdl-events.cpp | 2 +- backends/mixer/sdl13/sdl13-mixer.cpp | 108 ------------------------------- backends/mixer/sdl13/sdl13-mixer.h | 67 ------------------- backends/mixer/sdl2/sdl2-mixer.cpp | 108 +++++++++++++++++++++++++++++++ backends/mixer/sdl2/sdl2-mixer.h | 67 +++++++++++++++++++ backends/module.mk | 6 +- backends/platform/sdl/ps3/ps3.cpp | 4 +- backends/platform/sdl/sdl.cpp | 8 +-- configure | 4 +- dists/ps3/readme-ps3.md | 4 +- 13 files changed, 195 insertions(+), 199 deletions(-) delete mode 100644 backends/mixer/sdl13/sdl13-mixer.cpp delete mode 100644 backends/mixer/sdl13/sdl13-mixer.h create mode 100644 backends/mixer/sdl2/sdl2-mixer.cpp create mode 100644 backends/mixer/sdl2/sdl2-mixer.h diff --git a/backends/audiocd/sdl/sdl-audiocd.cpp b/backends/audiocd/sdl/sdl-audiocd.cpp index c7b089af09..ff50c56af3 100644 --- a/backends/audiocd/sdl/sdl-audiocd.cpp +++ b/backends/audiocd/sdl/sdl-audiocd.cpp @@ -26,7 +26,7 @@ #include "backends/audiocd/sdl/sdl-audiocd.h" -#if !SDL_VERSION_ATLEAST(1, 3, 0) +#if !SDL_VERSION_ATLEAST(2, 0, 0) #include "common/textconsole.h" @@ -136,6 +136,6 @@ void SdlAudioCDManager::updateCD() { } } -#endif // !SDL_VERSION_ATLEAST(1, 3, 0) +#endif // !SDL_VERSION_ATLEAST(2, 0, 0) #endif diff --git a/backends/audiocd/sdl/sdl-audiocd.h b/backends/audiocd/sdl/sdl-audiocd.h index 783d4fe0f0..bfad7b6805 100644 --- a/backends/audiocd/sdl/sdl-audiocd.h +++ b/backends/audiocd/sdl/sdl-audiocd.h @@ -27,7 +27,7 @@ #include "backends/platform/sdl/sdl-sys.h" -#if !SDL_VERSION_ATLEAST(1, 3, 0) +#if !SDL_VERSION_ATLEAST(2, 0, 0) /** * The SDL audio cd manager. Implements real audio cd playback. @@ -49,6 +49,6 @@ protected: uint32 _cdEndTime, _cdStopTime; }; -#endif // !SDL_VERSION_ATLEAST(1, 3, 0) +#endif // !SDL_VERSION_ATLEAST(2, 0, 0) #endif diff --git a/backends/events/ps3sdl/ps3sdl-events.cpp b/backends/events/ps3sdl/ps3sdl-events.cpp index 0f6e01857b..1fc10559c2 100644 --- a/backends/events/ps3sdl/ps3sdl-events.cpp +++ b/backends/events/ps3sdl/ps3sdl-events.cpp @@ -126,8 +126,8 @@ bool PS3SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { * This pauses execution and keeps redrawing the screen until the XMB is closed. */ void PS3SdlEventSource::preprocessEvents(SDL_Event *event) { - if (event->type == SDL_ACTIVEEVENT) { - if (event->active.state == SDL_APPMOUSEFOCUS && !event->active.gain) { + if (event->type == SDL_WINDOWEVENT) { + if (event->window.event == SDL_WINDOWEVENT_LEAVE) { // XMB opened if (g_engine) g_engine->pauseEngine(true); @@ -145,9 +145,9 @@ void PS3SdlEventSource::preprocessEvents(SDL_Event *event) { } if (event->type == SDL_QUIT) return; - if (event->type != SDL_ACTIVEEVENT) + if (event->type != SDL_WINDOWEVENT) continue; - if (event->active.state == SDL_APPMOUSEFOCUS && event->active.gain) { + if (event->window.event == SDL_WINDOWEVENT_ENTER) { // XMB closed if (g_engine) g_engine->pauseEngine(false); diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index 038f61664f..745f398be6 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -314,7 +314,7 @@ Common::KeyCode SdlEventSource::SDLToOSystemKeycode(const SDLKey key) { case SDLK_y: return Common::KEYCODE_y; case SDLK_z: return Common::KEYCODE_z; case SDLK_DELETE: return Common::KEYCODE_DELETE; -#if SDL_VERSION_ATLEAST(1, 3, 0) +#if SDL_VERSION_ATLEAST(2, 0, 0) case SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_GRAVE): return Common::KEYCODE_TILDE; #else case SDLK_WORLD_16: return Common::KEYCODE_TILDE; diff --git a/backends/mixer/sdl13/sdl13-mixer.cpp b/backends/mixer/sdl13/sdl13-mixer.cpp deleted file mode 100644 index dc38242bde..0000000000 --- a/backends/mixer/sdl13/sdl13-mixer.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "common/scummsys.h" - -#if defined(SDL_BACKEND) - -#include "backends/mixer/sdl13/sdl13-mixer.h" -#include "common/debug.h" -#include "common/system.h" -#include "common/config-manager.h" -#include "common/textconsole.h" - -#ifdef GP2X -#define SAMPLES_PER_SEC 11025 -#else -#define SAMPLES_PER_SEC 44100 -#endif - -Sdl13MixerManager::Sdl13MixerManager() - : - SdlMixerManager(), - _device(0) { - -} - -Sdl13MixerManager::~Sdl13MixerManager() { - _mixer->setReady(false); - - SDL_CloseAudioDevice(_device); - - delete _mixer; -} - -void Sdl13MixerManager::init() { - // Start SDL Audio subsystem - if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) { - error("Could not initialize SDL: %s", SDL_GetError()); - } - - // Get the desired audio specs - SDL_AudioSpec desired = getAudioSpec(SAMPLES_PER_SEC); - - // Start SDL audio with the desired specs - _device = SDL_OpenAudioDevice(NULL, 0, &desired, &_obtained, - SDL_AUDIO_ALLOW_FREQUENCY_CHANGE); - - if (_device <= 0) { - warning("Could not open audio device: %s", SDL_GetError()); - - _mixer = new Audio::MixerImpl(g_system, desired.freq); - assert(_mixer); - _mixer->setReady(false); - } else { - debug(1, "Output sample rate: %d Hz", _obtained.freq); - - _mixer = new Audio::MixerImpl(g_system, _obtained.freq); - assert(_mixer); - _mixer->setReady(true); - - startAudio(); - } -} - -void Sdl13MixerManager::startAudio() { - // Start the sound system - SDL_PauseAudioDevice(_device, 0); -} - -void Sdl13MixerManager::suspendAudio() { - SDL_CloseAudioDevice(_device); - _audioSuspended = true; -} - -int Sdl13MixerManager::resumeAudio() { - if (!_audioSuspended) - return -2; - - _device = SDL_OpenAudioDevice(NULL, 0, &_obtained, NULL, 0); - if (_device <= 0) { - return -1; - } - - SDL_PauseAudioDevice(_device, 0); - _audioSuspended = false; - return 0; -} - -#endif diff --git a/backends/mixer/sdl13/sdl13-mixer.h b/backends/mixer/sdl13/sdl13-mixer.h deleted file mode 100644 index ff2bb43084..0000000000 --- a/backends/mixer/sdl13/sdl13-mixer.h +++ /dev/null @@ -1,67 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef BACKENDS_MIXER_SDL13_H -#define BACKENDS_MIXER_SDL13_H - -#include "backends/mixer/sdl/sdl-mixer.h" - -/** - * SDL mixer manager. It wraps the actual implementation - * of the Audio:Mixer used by the engine, and setups - * the SDL audio subsystem and the callback for the - * audio mixer implementation. - */ -class Sdl13MixerManager : public SdlMixerManager { -public: - Sdl13MixerManager(); - virtual ~Sdl13MixerManager(); - - /** - * Initialize and setups the mixer - */ - virtual void init(); - - /** - * Pauses the audio system - */ - virtual void suspendAudio(); - - /** - * Resumes the audio system - */ - virtual int resumeAudio(); - -protected: - - /** - * The opened SDL audio device - */ - SDL_AudioDeviceID _device; - - /** - * Starts SDL audio - */ - virtual void startAudio(); -}; - -#endif diff --git a/backends/mixer/sdl2/sdl2-mixer.cpp b/backends/mixer/sdl2/sdl2-mixer.cpp new file mode 100644 index 0000000000..96a1361a8c --- /dev/null +++ b/backends/mixer/sdl2/sdl2-mixer.cpp @@ -0,0 +1,108 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/scummsys.h" + +#if defined(SDL_BACKEND) + +#include "backends/mixer/sdl2/sdl2-mixer.h" +#include "common/debug.h" +#include "common/system.h" +#include "common/config-manager.h" +#include "common/textconsole.h" + +#ifdef GP2X +#define SAMPLES_PER_SEC 11025 +#else +#define SAMPLES_PER_SEC 44100 +#endif + +Sdl2MixerManager::Sdl2MixerManager() + : + SdlMixerManager(), + _device(0) { + +} + +Sdl2MixerManager::~Sdl2MixerManager() { + _mixer->setReady(false); + + SDL_CloseAudioDevice(_device); + + delete _mixer; +} + +void Sdl2MixerManager::init() { + // Start SDL Audio subsystem + if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) { + error("Could not initialize SDL: %s", SDL_GetError()); + } + + // Get the desired audio specs + SDL_AudioSpec desired = getAudioSpec(SAMPLES_PER_SEC); + + // Start SDL audio with the desired specs + _device = SDL_OpenAudioDevice(NULL, 0, &desired, &_obtained, + SDL_AUDIO_ALLOW_FREQUENCY_CHANGE); + + if (_device <= 0) { + warning("Could not open audio device: %s", SDL_GetError()); + + _mixer = new Audio::MixerImpl(g_system, desired.freq); + assert(_mixer); + _mixer->setReady(false); + } else { + debug(1, "Output sample rate: %d Hz", _obtained.freq); + + _mixer = new Audio::MixerImpl(g_system, _obtained.freq); + assert(_mixer); + _mixer->setReady(true); + + startAudio(); + } +} + +void Sdl2MixerManager::startAudio() { + // Start the sound system + SDL_PauseAudioDevice(_device, 0); +} + +void Sdl2MixerManager::suspendAudio() { + SDL_CloseAudioDevice(_device); + _audioSuspended = true; +} + +int Sdl2MixerManager::resumeAudio() { + if (!_audioSuspended) + return -2; + + _device = SDL_OpenAudioDevice(NULL, 0, &_obtained, NULL, 0); + if (_device <= 0) { + return -1; + } + + SDL_PauseAudioDevice(_device, 0); + _audioSuspended = false; + return 0; +} + +#endif diff --git a/backends/mixer/sdl2/sdl2-mixer.h b/backends/mixer/sdl2/sdl2-mixer.h new file mode 100644 index 0000000000..ce2616d92b --- /dev/null +++ b/backends/mixer/sdl2/sdl2-mixer.h @@ -0,0 +1,67 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef BACKENDS_MIXER_SDL2_H +#define BACKENDS_MIXER_SDL2_H + +#include "backends/mixer/sdl/sdl-mixer.h" + +/** + * SDL mixer manager. It wraps the actual implementation + * of the Audio:Mixer used by the engine, and setups + * the SDL audio subsystem and the callback for the + * audio mixer implementation. + */ +class Sdl2MixerManager : public SdlMixerManager { +public: + Sdl2MixerManager(); + virtual ~Sdl2MixerManager(); + + /** + * Initialize and setups the mixer + */ + virtual void init(); + + /** + * Pauses the audio system + */ + virtual void suspendAudio(); + + /** + * Resumes the audio system + */ + virtual int resumeAudio(); + +protected: + + /** + * The opened SDL audio device + */ + SDL_AudioDeviceID _device; + + /** + * Starts SDL audio + */ + virtual void startAudio(); +}; + +#endif diff --git a/backends/module.mk b/backends/module.mk index e5e2905781..025d653ddd 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -72,13 +72,11 @@ MODULE_OBJS += \ plugins/sdl/sdl-provider.o \ timer/sdl/sdl-timer.o -# SDL 1.3 removed audio CD support -ifndef USE_SDL13 +# SDL 2 removed audio CD support ifndef USE_SDL2 MODULE_OBJS += \ audiocd/sdl/sdl-audiocd.o endif -endif ifdef USE_OPENGL MODULE_OBJS += \ @@ -126,7 +124,7 @@ MODULE_OBJS += \ fs/posix/posix-fs-factory.o \ fs/ps3/ps3-fs-factory.o \ events/ps3sdl/ps3sdl-events.o \ - mixer/sdl13/sdl13-mixer.o + mixer/sdl2/sdl2-mixer.o endif ifeq ($(BACKEND),tizen) diff --git a/backends/platform/sdl/ps3/ps3.cpp b/backends/platform/sdl/ps3/ps3.cpp index f111379794..e531d79fba 100644 --- a/backends/platform/sdl/ps3/ps3.cpp +++ b/backends/platform/sdl/ps3/ps3.cpp @@ -31,7 +31,7 @@ #include "backends/saves/default/default-saves.h" #include "backends/fs/ps3/ps3-fs-factory.h" #include "backends/events/ps3sdl/ps3sdl-events.h" -#include "backends/mixer/sdl13/sdl13-mixer.h" +#include "backends/mixer/sdl2/sdl2-mixer.h" #include #include @@ -70,7 +70,7 @@ void OSystem_PS3::initBackend() { // Create the mixer manager if (_mixer == 0) { - _mixerManager = new Sdl13MixerManager(); + _mixerManager = new Sdl2MixerManager(); // Setup and start mixer _mixerManager->init(); diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 6d4dede212..fffb9d56d9 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -36,8 +36,8 @@ #include "backends/saves/default/default-saves.h" -// Audio CD support was removed with SDL 1.3 -#if SDL_VERSION_ATLEAST(1, 3, 0) +// Audio CD support was removed with SDL 2.0 +#if SDL_VERSION_ATLEAST(2, 0, 0) #include "backends/audiocd/default/default-audiocd.h" #else #include "backends/audiocd/sdl/sdl-audiocd.h" @@ -246,8 +246,8 @@ void OSystem_SDL::initBackend() { #endif if (_audiocdManager == 0) { - // Audio CD support was removed with SDL 1.3 -#if SDL_VERSION_ATLEAST(1, 3, 0) + // Audio CD support was removed with SDL 2.0 +#if SDL_VERSION_ATLEAST(2, 0, 0) _audiocdManager = new DefaultAudioCDManager(); #else _audiocdManager = new SdlAudioCDManager(); diff --git a/configure b/configure index 87070f5663..90aabc0259 100755 --- a/configure +++ b/configure @@ -2414,6 +2414,7 @@ case $_host_os in ;; ps3) # Force use of SDL and freetype from the ps3 toolchain + _sdlconfig=sdl2-config _sdlpath="$PS3DEV/portlibs/ppu:$PS3DEV/portlibs/ppu/bin" _freetypepath="$PS3DEV/portlibs/ppu:$PS3DEV/portlibs/ppu/bin" @@ -3108,9 +3109,6 @@ case $_backend in _sdlversion=`$_sdlconfig --version` case $_sdlversion in - 1.3.*) - add_line_to_config_mk "USE_SDL13 = 1" - ;; 2.0.*) add_line_to_config_mk "USE_SDL2 = 1" ;; diff --git a/dists/ps3/readme-ps3.md b/dists/ps3/readme-ps3.md index 2fb393b4fb..8290f87066 100644 --- a/dists/ps3/readme-ps3.md +++ b/dists/ps3/readme-ps3.md @@ -36,12 +36,12 @@ Unauthorized distribution of an installable package with non freeware games incl Building from source ==================== -This port of ScummVM to the PS3 is based on SDL. It uses the open source SDK PSL1GHT. +This port of ScummVM to the PS3 is based on SDL2. It uses the open source SDK PSL1GHT. The dependencies needed to build it are : - The toolchain from https://github.com/ps3dev/ps3toolchain -- SDL from https://github.com/zeldin/SDL_PSL1GHT +- SDL from https://bitbucket.org/bgK/sdl_psl1ght - ScummVM from https://github.com/scummvm/scummvm Once all the dependencies are correctly setup, an installable package can be obtained from source by issuing the following command : -- cgit v1.2.3 From f985a039d5dd8ef3d2d5700f4a32928d221836d8 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sun, 8 Mar 2015 13:13:50 +0100 Subject: SDL: Ensure the audio sample format is supported When SDL returns an unsupported audio sample format, ask SDL to do resampling to the one ScummVM expects. This is needed for the PS3 which natively only supports 32 bits floating point as a sample format. --- backends/mixer/sdl/sdl-mixer.cpp | 55 +++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/backends/mixer/sdl/sdl-mixer.cpp b/backends/mixer/sdl/sdl-mixer.cpp index dc0c853808..6afeeaefc6 100644 --- a/backends/mixer/sdl/sdl-mixer.cpp +++ b/backends/mixer/sdl/sdl-mixer.cpp @@ -78,34 +78,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) { -- cgit v1.2.3 From aa9191c4c46183664d2c3f64dbebbb1119067148 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sun, 8 Mar 2015 13:18:45 +0100 Subject: PS3: Remove the SDL2 mixer manager. It was only used by the PS3 backend, and the standard SDL mixer was fixed to work in the PS3 case. --- backends/mixer/sdl2/sdl2-mixer.cpp | 108 ------------------------------------- backends/mixer/sdl2/sdl2-mixer.h | 67 ----------------------- backends/module.mk | 3 +- backends/platform/sdl/ps3/ps3.cpp | 9 ---- 4 files changed, 1 insertion(+), 186 deletions(-) delete mode 100644 backends/mixer/sdl2/sdl2-mixer.cpp delete mode 100644 backends/mixer/sdl2/sdl2-mixer.h diff --git a/backends/mixer/sdl2/sdl2-mixer.cpp b/backends/mixer/sdl2/sdl2-mixer.cpp deleted file mode 100644 index 96a1361a8c..0000000000 --- a/backends/mixer/sdl2/sdl2-mixer.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "common/scummsys.h" - -#if defined(SDL_BACKEND) - -#include "backends/mixer/sdl2/sdl2-mixer.h" -#include "common/debug.h" -#include "common/system.h" -#include "common/config-manager.h" -#include "common/textconsole.h" - -#ifdef GP2X -#define SAMPLES_PER_SEC 11025 -#else -#define SAMPLES_PER_SEC 44100 -#endif - -Sdl2MixerManager::Sdl2MixerManager() - : - SdlMixerManager(), - _device(0) { - -} - -Sdl2MixerManager::~Sdl2MixerManager() { - _mixer->setReady(false); - - SDL_CloseAudioDevice(_device); - - delete _mixer; -} - -void Sdl2MixerManager::init() { - // Start SDL Audio subsystem - if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) { - error("Could not initialize SDL: %s", SDL_GetError()); - } - - // Get the desired audio specs - SDL_AudioSpec desired = getAudioSpec(SAMPLES_PER_SEC); - - // Start SDL audio with the desired specs - _device = SDL_OpenAudioDevice(NULL, 0, &desired, &_obtained, - SDL_AUDIO_ALLOW_FREQUENCY_CHANGE); - - if (_device <= 0) { - warning("Could not open audio device: %s", SDL_GetError()); - - _mixer = new Audio::MixerImpl(g_system, desired.freq); - assert(_mixer); - _mixer->setReady(false); - } else { - debug(1, "Output sample rate: %d Hz", _obtained.freq); - - _mixer = new Audio::MixerImpl(g_system, _obtained.freq); - assert(_mixer); - _mixer->setReady(true); - - startAudio(); - } -} - -void Sdl2MixerManager::startAudio() { - // Start the sound system - SDL_PauseAudioDevice(_device, 0); -} - -void Sdl2MixerManager::suspendAudio() { - SDL_CloseAudioDevice(_device); - _audioSuspended = true; -} - -int Sdl2MixerManager::resumeAudio() { - if (!_audioSuspended) - return -2; - - _device = SDL_OpenAudioDevice(NULL, 0, &_obtained, NULL, 0); - if (_device <= 0) { - return -1; - } - - SDL_PauseAudioDevice(_device, 0); - _audioSuspended = false; - return 0; -} - -#endif diff --git a/backends/mixer/sdl2/sdl2-mixer.h b/backends/mixer/sdl2/sdl2-mixer.h deleted file mode 100644 index ce2616d92b..0000000000 --- a/backends/mixer/sdl2/sdl2-mixer.h +++ /dev/null @@ -1,67 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef BACKENDS_MIXER_SDL2_H -#define BACKENDS_MIXER_SDL2_H - -#include "backends/mixer/sdl/sdl-mixer.h" - -/** - * SDL mixer manager. It wraps the actual implementation - * of the Audio:Mixer used by the engine, and setups - * the SDL audio subsystem and the callback for the - * audio mixer implementation. - */ -class Sdl2MixerManager : public SdlMixerManager { -public: - Sdl2MixerManager(); - virtual ~Sdl2MixerManager(); - - /** - * Initialize and setups the mixer - */ - virtual void init(); - - /** - * Pauses the audio system - */ - virtual void suspendAudio(); - - /** - * Resumes the audio system - */ - virtual int resumeAudio(); - -protected: - - /** - * The opened SDL audio device - */ - SDL_AudioDeviceID _device; - - /** - * Starts SDL audio - */ - virtual void startAudio(); -}; - -#endif diff --git a/backends/module.mk b/backends/module.mk index 025d653ddd..3d7dea1f26 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -123,8 +123,7 @@ MODULE_OBJS += \ fs/posix/posix-fs.o \ fs/posix/posix-fs-factory.o \ fs/ps3/ps3-fs-factory.o \ - events/ps3sdl/ps3sdl-events.o \ - mixer/sdl2/sdl2-mixer.o + events/ps3sdl/ps3sdl-events.o endif ifeq ($(BACKEND),tizen) diff --git a/backends/platform/sdl/ps3/ps3.cpp b/backends/platform/sdl/ps3/ps3.cpp index e531d79fba..0bb8300014 100644 --- a/backends/platform/sdl/ps3/ps3.cpp +++ b/backends/platform/sdl/ps3/ps3.cpp @@ -31,7 +31,6 @@ #include "backends/saves/default/default-saves.h" #include "backends/fs/ps3/ps3-fs-factory.h" #include "backends/events/ps3sdl/ps3sdl-events.h" -#include "backends/mixer/sdl2/sdl2-mixer.h" #include #include @@ -68,14 +67,6 @@ void OSystem_PS3::initBackend() { if (_savefileManager == 0) _savefileManager = new DefaultSaveFileManager(PREFIX "/saves"); - // Create the mixer manager - if (_mixer == 0) { - _mixerManager = new Sdl2MixerManager(); - - // Setup and start mixer - _mixerManager->init(); - } - // Event source if (_eventSource == 0) _eventSource = new PS3SdlEventSource(); -- cgit v1.2.3 From f37fb24caa87f5cde418ac8376e7fab1a1207dae Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sun, 8 Mar 2015 13:45:03 +0100 Subject: PS3: Set the default audio output rate to 48000 Hz SDL does an awful job at resampling 44100 -> 48000 Hz --- backends/mixer/sdl/sdl-mixer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backends/mixer/sdl/sdl-mixer.cpp b/backends/mixer/sdl/sdl-mixer.cpp index 6afeeaefc6..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 -- cgit v1.2.3