void SDL_QuitSubSystem(Uint32 flags) { /* Shut down requested initialized subsystems */ #if !SDL_JOYSTICK_DISABLED if ((flags & SDL_initialized & SDL_INIT_JOYSTICK)) { SDL_JoystickQuit(); SDL_initialized &= ~SDL_INIT_JOYSTICK; } #endif #if !SDL_HAPTIC_DISABLED if ((flags & SDL_initialized & SDL_INIT_HAPTIC)) { SDL_HapticQuit(); SDL_initialized &= ~SDL_INIT_HAPTIC; } #endif #if !SDL_TIMERS_DISABLED if ((flags & SDL_initialized & SDL_INIT_TIMER)) { SDL_TimerQuit(); SDL_initialized &= ~SDL_INIT_TIMER; } #endif #if !SDL_AUDIO_DISABLED if ((flags & SDL_initialized & SDL_INIT_AUDIO)) { SDL_AudioQuit(); SDL_initialized &= ~SDL_INIT_AUDIO; } #endif #if !SDL_VIDEO_DISABLED if ((flags & SDL_initialized & SDL_INIT_VIDEO)) { SDL_VideoQuit(); SDL_initialized &= ~SDL_INIT_VIDEO; } #endif }
int SDL_TimerInit(void) { SDL_TimerData *data = &SDL_timer_data; if (!data->active) { data->timermap_lock = SDL_CreateMutex(); if (!data->timermap_lock) { return -1; } data->sem = SDL_CreateSemaphore(0); if (!data->sem) { SDL_DestroyMutex(data->timermap_lock); return -1; } data->active = SDL_TRUE; /* !!! FIXME: this is nasty. */ #if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC) #undef SDL_CreateThread data->thread = SDL_CreateThread(SDL_TimerThread, data, NULL, NULL); #else data->thread = SDL_CreateThread(SDL_TimerThread, data); #endif if (!data->thread) { SDL_TimerQuit(); return -1; } SDL_AtomicSet(&data->nextID, 1); } return 0; }
int SDL_TimerInit(void) { SDL_TimerData *data = &SDL_timer_data; if (!SDL_AtomicGet(&data->active)) { const char *name = "SDLTimer"; data->timermap_lock = SDL_CreateMutex(); if (!data->timermap_lock) { return -1; } data->sem = SDL_CreateSemaphore(0); if (!data->sem) { SDL_DestroyMutex(data->timermap_lock); return -1; } SDL_AtomicSet(&data->active, 1); /* Timer threads use a callback into the app, so we can't set a limited stack size here. */ data->thread = SDL_CreateThreadInternal(SDL_TimerThread, name, 0, data); if (!data->thread) { SDL_TimerQuit(); return -1; } SDL_AtomicSet(&data->nextID, 1); } return 0; }
void SDL_QuitSubSystem(Uint32 flags) { /* Shut down requested initialized subsystems */ #ifndef DISABLE_CDROM if ( (flags & SDL_initialized & SDL_INIT_CDROM) ) { SDL_CDROMQuit(); SDL_initialized &= ~SDL_INIT_CDROM; } #endif #ifndef DISABLE_JOYSTICK if ( (flags & SDL_initialized & SDL_INIT_JOYSTICK) ) { SDL_JoystickQuit(); SDL_initialized &= ~SDL_INIT_JOYSTICK; } #endif #ifndef DISABLE_TIMERS if ( (flags & SDL_initialized & SDL_INIT_TIMER) ) { SDL_TimerQuit(); SDL_initialized &= ~SDL_INIT_TIMER; } #endif #ifndef DISABLE_AUDIO if ( (flags & SDL_initialized & SDL_INIT_AUDIO) ) { SDL_AudioQuit(); SDL_initialized &= ~SDL_INIT_AUDIO; } #endif #ifndef DISABLE_VIDEO if ( (flags & SDL_initialized & SDL_INIT_VIDEO) ) { SDL_VideoQuit(); SDL_initialized &= ~SDL_INIT_VIDEO; } #endif }
void SDL_QuitSubSystem(Uint32 flags) { /* Shut down requested initialized subsystems */ #if !SDL_JOYSTICK_DISABLED if ((flags & SDL_INIT_GAMECONTROLLER)) { // Game controller implies Joystick. flags |= SDL_INIT_JOYSTICK; if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) { SDL_GameControllerQuit(); } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER); } if ((flags & SDL_INIT_JOYSTICK)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) { SDL_JoystickQuit(); } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK); } #endif #if !SDL_HAPTIC_DISABLED if ((flags & SDL_INIT_HAPTIC)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) { SDL_HapticQuit(); } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_HAPTIC); } #endif #if !SDL_AUDIO_DISABLED if ((flags & SDL_INIT_AUDIO)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) { SDL_AudioQuit(); } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO); } #endif #if !SDL_VIDEO_DISABLED if ((flags & SDL_INIT_VIDEO)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) { SDL_VideoQuit(); } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO); } #endif #if !SDL_TIMERS_DISABLED if ((flags & SDL_INIT_TIMER)) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) { SDL_TimerQuit(); } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_TIMER); } #endif }
int SDL_TimerInit(void) { int retval; retval = 0; if ( SDL_timer_started ) { SDL_TimerQuit(); } if ( ! SDL_timer_threaded ) { retval = SDL_SYS_TimerInit(); } if ( SDL_timer_threaded ) { SDL_timer_mutex = SDL_CreateMutex(); } if ( retval == 0 ) { SDL_timer_started = 1; } return(retval); }