Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Cleanup of SDL_PrivateShouldInitSubsystem.

Also fixes a build error if a module was disabled.
  • Loading branch information
jorgenpt committed Feb 26, 2013
1 parent 3de4c3d commit b057254fd4da23b923996fe81276ff3591437029
Showing with 11 additions and 16 deletions.
  1. +11 −16 src/SDL.c
@@ -68,14 +68,9 @@ SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)

/* Private helper to check if a system needs init. */
static SDL_bool
SDL_PrivateShouldInitSubsystem(Uint32 flags, Uint32 subsystem)
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
{
int subsystem_index;
if ((flags & subsystem) == 0) {
return SDL_FALSE;
}

subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
return (SDL_SubsystemRefCount[subsystem_index] == 0);
}
@@ -106,8 +101,8 @@ SDL_InitSubSystem(Uint32 flags)

/* Initialize the timer subsystem */
if ((flags & SDL_INIT_TIMER) ){
if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_TIMER)) {
#if !SDL_TIMERS_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
if (SDL_TimerInit() < 0) {
return (-1);
}
@@ -121,8 +116,8 @@ SDL_InitSubSystem(Uint32 flags)

/* Initialize the video/event subsystem */
if ((flags & SDL_INIT_VIDEO) ){
if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_VIDEO)) {
#if !SDL_VIDEO_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
if (SDL_VideoInit(NULL) < 0) {
return (-1);
}
@@ -136,8 +131,8 @@ SDL_InitSubSystem(Uint32 flags)

/* Initialize the audio subsystem */
if ((flags & SDL_INIT_AUDIO) ){
if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_AUDIO)) {
#if !SDL_AUDIO_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
if (SDL_AudioInit(NULL) < 0) {
return (-1);
}
@@ -156,8 +151,8 @@ SDL_InitSubSystem(Uint32 flags)

/* Initialize the joystick subsystem */
if ((flags & SDL_INIT_JOYSTICK) ){
if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_JOYSTICK)) {
#if !SDL_JOYSTICK_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
if (SDL_JoystickInit() < 0) {
return (-1);
}
@@ -170,8 +165,8 @@ SDL_InitSubSystem(Uint32 flags)
}

if ((flags & SDL_INIT_GAMECONTROLLER) ){
if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_GAMECONTROLLER)) {
#if !SDL_JOYSTICK_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
if (SDL_GameControllerInit() < 0) {
return (-1);
}
@@ -185,11 +180,11 @@ SDL_InitSubSystem(Uint32 flags)

/* Initialize the haptic subsystem */
if ((flags & SDL_INIT_HAPTIC) ){
if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_HAPTIC)) {
#if !SDL_HAPTIC_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
if (SDL_HapticInit() < 0) {
return (-1);
}
return (-1);
}
}
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
#else
@@ -441,4 +436,4 @@ _DllMainCRTStartup(HANDLE hModule,

#endif /* __WIN32__ */

/* vi: set ts=4 sw=4 expandtab: */
/* vi: set sts=4 ts=4 sw=4 expandtab: */

0 comments on commit b057254

Please sign in to comment.