Skip to content

Commit

Permalink
Merge pull request #637 from bgK/ps3-toolchain-update
Browse files Browse the repository at this point in the history
PS3: Update to SDL2
  • Loading branch information
lordhoto committed Dec 15, 2015
2 parents d80c39b + f37fb24 commit af08cee
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 228 deletions.
4 changes: 2 additions & 2 deletions backends/audiocd/sdl/sdl-audiocd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -136,6 +136,6 @@ void SdlAudioCDManager::updateCD() {
}
}

#endif // !SDL_VERSION_ATLEAST(1, 3, 0)
#endif // !SDL_VERSION_ATLEAST(2, 0, 0)

#endif
4 changes: 2 additions & 2 deletions backends/audiocd/sdl/sdl-audiocd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -49,6 +49,6 @@ class SdlAudioCDManager : public DefaultAudioCDManager {
uint32 _cdEndTime, _cdStopTime;
};

#endif // !SDL_VERSION_ATLEAST(1, 3, 0)
#endif // !SDL_VERSION_ATLEAST(2, 0, 0)

#endif
8 changes: 4 additions & 4 deletions backends/events/ps3sdl/ps3sdl-events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion backends/events/sdl/sdl-events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
59 changes: 38 additions & 21 deletions backends/mixer/sdl/sdl-mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
108 changes: 0 additions & 108 deletions backends/mixer/sdl13/sdl13-mixer.cpp

This file was deleted.

67 changes: 0 additions & 67 deletions backends/mixer/sdl13/sdl13-mixer.h

This file was deleted.

7 changes: 2 additions & 5 deletions backends/module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 += \
Expand Down Expand Up @@ -125,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/sdl13/sdl13-mixer.o
events/ps3sdl/ps3sdl-events.o
endif

ifeq ($(BACKEND),tizen)
Expand Down
9 changes: 0 additions & 9 deletions backends/platform/sdl/ps3/ps3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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/sdl13/sdl13-mixer.h"

#include <dirent.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -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 Sdl13MixerManager();

// Setup and start mixer
_mixerManager->init();
}

// Event source
if (_eventSource == 0)
_eventSource = new PS3SdlEventSource();
Expand Down
8 changes: 4 additions & 4 deletions backends/platform/sdl/sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit af08cee

Please sign in to comment.