SoundSDL::~SoundSDL() { if (!_initialized) return; #if !JS SDL_mutexP(_mutex); #endif int iSave = emulating; emulating = 0; #if !JS SDL_SemPost(_semBufferFull); SDL_SemPost(_semBufferEmpty); SDL_mutexV(_mutex); SDL_DestroySemaphore(_semBufferFull); SDL_DestroySemaphore(_semBufferEmpty); #endif _semBufferFull = NULL; _semBufferEmpty = NULL; SDL_DestroyMutex(_mutex); _mutex = NULL; SDL_CloseAudio(); emulating = iSave; }
SoundSDL::~SoundSDL() { if (!_initialized) return; SDL_mutexP(_mutex); int iSave = emulating; emulating = 0; SDL_SemPost(_semBufferFull); SDL_SemPost(_semBufferEmpty); SDL_mutexV(_mutex); SDL_DestroySemaphore(_semBufferFull); SDL_DestroySemaphore(_semBufferEmpty); _semBufferFull = NULL; _semBufferEmpty = NULL; SDL_DestroyMutex(_mutex); _mutex = NULL; SDL_CloseAudioDevice(_dev); emulating = iSave; _initialized = false; }
void Android_DestroyWindow(_THIS, SDL_Window * window) { SDL_WindowData *data; if (window == Android_Window) { Android_Window = NULL; if (Android_PauseSem) SDL_DestroySemaphore(Android_PauseSem); if (Android_ResumeSem) SDL_DestroySemaphore(Android_ResumeSem); Android_PauseSem = NULL; Android_ResumeSem = NULL; if(window->driverdata) { data = (SDL_WindowData *) window->driverdata; if (data->egl_surface != EGL_NO_SURFACE) { SDL_EGL_DestroySurface(_this, data->egl_surface); } if (data->native_window) { ANativeWindow_release(data->native_window); } SDL_free(window->driverdata); window->driverdata = NULL; } } }
t_stat vid_close (void) { SDL_Event user_event; int status; if (vid_active) { vid_active = FALSE; if (vid_thread_handle) { sim_debug (SIM_VID_DBG_VIDEO|SIM_VID_DBG_KEY|SIM_VID_DBG_MOUSE, vid_dev, "vid_close()\n"); user_event.type = SDL_USEREVENT; user_event.user.code = EVENT_CLOSE; user_event.user.data1 = NULL; user_event.user.data2 = NULL; SDL_PushEvent (&user_event); SDL_WaitThread (vid_thread_handle, &status); vid_thread_handle = NULL; vid_dev = NULL; } if (vid_mouse_events.sem) { SDL_DestroySemaphore(vid_mouse_events.sem); vid_mouse_events.sem = NULL; } if (vid_key_events.sem) { SDL_DestroySemaphore(vid_key_events.sem); vid_key_events.sem = NULL; } } return SCPE_OK; }
int main(int argc, char** argv){ if(!argv[1]){ puts("No IP input found. Please initiate in the form ' ./Player <Server IP> '"); exit(1); } //fgets from stdin to get clientname (and pass that into run, ezpz) printf("Please enter your name: "); fgets(clientname, 64, stdin); clientname[strlen(clientname) - 1] = '\0'; printf("Hello %s!\n", clientname); strcat(clientname, " : "); namelen = strlen(clientname); /// SDL_Surface* screen = initScreen(); //Initiate the semaphores and chatserver thread msgbuf_sem = SDL_CreateSemaphore(1); textSem = SDL_CreateSemaphore(1); chatserv = SDL_CreateThread(chatserver, screen); //Initiate the server connection int socket_id = server_setup(argv[1]); //Initiate the client's sprite Uint32 colorkey = SDL_MapRGB( screen->format, 255, 255, 255); initiate(socket_id, colorkey); TTF_Init(); run(screen, socket_id); //CEASE AND DESIST SDL_KillThread(chatserv); SDL_FreeSurface(screen); SDL_Quit(); TTF_Quit(); int i; for(i=0; i<numMessages; i++) if(text[i] != NULL) SDL_FreeSurface(text[i]); SDL_DestroySemaphore(msgbuf_sem); SDL_DestroySemaphore(textSem); return 1; }
void SDL_DestroyBarrier(SDL_barrier *b) { if (b == NULL) return; SDL_DestroyMutex(b->mutex); SDL_DestroySemaphore(b->turnstile); SDL_DestroySemaphore(b->turnstile2); free(b); }
void AudioQueue_DESTROY (AudioQueue* self) { AudioQueue_destroy_buffers(self); Free(self->nodes); self->nodes = NULL; self->n = 0; SDL_DestroySemaphore(self->empty_node); SDL_DestroySemaphore(self->full_node); self->empty_node = self->full_node = NULL; }
void system_sound_shutdown(void) { SDL_SemPost(rsem); SDL_CloseAudio(); SDL_DestroySemaphore(rsem); SDL_DestroySemaphore(wsem); free(sound_buffer); sound_buffer = NULL; return; }
/* Destroy a condition variable */ DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond) { if ( cond ) { if ( cond->wait_sem ) { SDL_DestroySemaphore(cond->wait_sem); } if ( cond->wait_done ) { SDL_DestroySemaphore(cond->wait_done); } if ( cond->lock ) { SDL_DestroyMutex(cond->lock); } SDL_free(cond); } }
Case::~Case() { delete pAnimationManager; pAnimationManager = NULL; delete pAudioManager; pAudioManager = NULL; delete pContentManager; pContentManager = NULL; delete pDialogCharacterManager; pDialogCharacterManager = NULL; delete pDialogCutsceneManager; pDialogCutsceneManager = NULL; delete pEvidenceManager; pEvidenceManager = NULL; delete pFieldCharacterManager; pFieldCharacterManager = NULL; delete pFieldCutsceneManager; pFieldCutsceneManager = NULL; delete pFlagManager; pFlagManager = NULL; delete pPartnerManager; pPartnerManager = NULL; delete pSpriteManager; pSpriteManager = NULL; SDL_DestroySemaphore(pLoadStageSemaphore); pLoadStageSemaphore = NULL; }
static int ThreadHelper (void *startInfo) { ThreadFunction func; void *data; SDL_sem *sem; TrueThread thread; int result; func = ((struct ThreadStartInfo *) startInfo)->func; data = ((struct ThreadStartInfo *) startInfo)->data; sem = ((struct ThreadStartInfo *) startInfo)->sem; // Wait until the Thread structure is available. SDL_SemWait (sem); SDL_DestroySemaphore (sem); thread = ((struct ThreadStartInfo *) startInfo)->thread; HFree (startInfo); result = (*func) (data); #ifdef DEBUG_THREADS log_add (log_Debug, "Thread '%s' done (returned %d).", thread->name, result); fflush (stderr); #endif UnQueueThread (thread); DestroyThreadLocal (thread->localData); FinishThread (thread); /* Destroying the thread is the responsibility of ProcessThreadLifecycles() */ return result; }
LISPBUILDERSDLGLUE_API void SDLCALL SDL_glue_SDL_CloseAudio(void) { /* Seems this sequence of calls is quite important, or the glue-library will hang. 1) Bump the semaphore in case the callback is waiting on audio data. 2) Lock the callback. In effect returns when the callback returns. Also makes sure that the callback cannot be called again before we hav a chance to close the audio device. */ SDL_SemPost(audio_buffer_lock); SDL_LockAudio(); if (audio_buffer_lock != NULL) { SDL_DestroySemaphore(audio_buffer_lock); audio_buffer_lock = NULL; } if (buffer_fill_lock != NULL) { SDL_DestroyMutex(buffer_fill_lock); buffer_fill_lock = NULL; } /* It is very likely that the audio buffer will be a different size the next time the audio device is opened (assuming different input parameters. */ if (audio_buffer != NULL) { free(audio_buffer); audio_buffer = NULL; } SDL_CloseAudio(); }
void system_init(void) { SDL_sem *s; /* fake stack, OS manages size (and growth) */ stackbegin = stackend = (uintptr_t*)&s; #if (CONFIG_PLATFORM & PLATFORM_MAEMO) /* Make glib thread safe */ g_thread_init(NULL); g_type_init(); #endif if (SDL_Init(SDL_INIT_TIMER)) panicf("%s", SDL_GetError()); s = SDL_CreateSemaphore(0); /* 0-count so it blocks */ evt_thread = SDL_CreateThread(sdl_event_thread, s); /* wait for sdl_event_thread to run so that it can initialize the surfaces * and video subsystem needed for SDL events */ SDL_SemWait(s); /* cleanup */ SDL_DestroySemaphore(s); }
static void XAUDIO2_CloseDevice(_THIS) { if (this->hidden != NULL) { IXAudio2 *ixa2 = this->hidden->ixa2; IXAudio2SourceVoice *source = this->hidden->source; IXAudio2MasteringVoice *mastering = this->hidden->mastering; if (source != NULL) { IXAudio2SourceVoice_Stop(source, 0, XAUDIO2_COMMIT_NOW); IXAudio2SourceVoice_FlushSourceBuffers(source); IXAudio2SourceVoice_DestroyVoice(source); } if (ixa2 != NULL) { IXAudio2_StopEngine(ixa2); } if (mastering != NULL) { IXAudio2MasteringVoice_DestroyVoice(mastering); } if (ixa2 != NULL) { IXAudio2_Release(ixa2); } SDL_free(this->hidden->mixbuf); if (this->hidden->semaphore != NULL) { SDL_DestroySemaphore(this->hidden->semaphore); } SDL_free(this->hidden); this->hidden = NULL; } }
/* Function to perform any system-specific joystick related cleanup */ void SDL_SYS_JoystickQuit(void) { /* Cleanup Threads and Semaphore. */ running = 0; SDL_WaitThread(thread, NULL); SDL_DestroySemaphore(pad_sem); }
void FlcPlayer::deInitAudio() { if (_game) { Mix_HookMusic(NULL, NULL); Mix_CloseAudio(); _game->initAudio(); } else if(_audioData.sharedLock) SDL_DestroySemaphore(_audioData.sharedLock); if (_audioData.loadingBuffer) { free(_audioData.loadingBuffer->samples); delete _audioData.loadingBuffer; _audioData.loadingBuffer = 0; } if (_audioData.playingBuffer) { free(_audioData.playingBuffer->samples); delete _audioData.playingBuffer; _audioData.playingBuffer = 0; } }
VOID PAL_ShutdownInput( VOID ) /*++ Purpose: Shutdown the input subsystem. Parameters: None. Return value: None. --*/ { // // Cleanup Threads and Semaphore. // running = 0; SDL_WaitThread(bthread, NULL); SDL_DestroySemaphore(pad_sem); }
rt_err_t rt_mq_detach(rt_mq_t mq) { /* parameter check */ RT_ASSERT(mq != RT_NULL); SDL_DestroySemaphore(hmq->msg); SDL_DestroySemaphore(hmq->mutex); free(mq->host_mq); mq->host_mq = NULL; /* remove from list */ SDL_mutexP(_mq_list_mutex); rt_list_remove(&(mq->list)); SDL_mutexV(_mq_list_mutex); return RT_EOK; }
void PathfindQuit() { DestroyMemoryPool(g_PathDataPool); DestroyMemoryPool(g_PathPool); DestroyMemoryPool(g_PathScorePool); for(int i = 0; i < PATHTABLE_SIZE; ++i) free(g_PathStack.Stack[i]); SDL_DestroyMutex(g_PathStack.Lock); SDL_DestroySemaphore(g_PathStack.Sem); }
void remove_thread(unsigned int thread_id) #endif { struct thread_entry *current = cores[CURRENT_CORE].running; struct thread_entry *thread = thread_id_entry(thread_id); SDL_Thread *t; SDL_sem *s; if (thread_id != THREAD_ID_CURRENT && thread->id != thread_id) return; int oldlevel = disable_irq_save(); t = thread->context.t; s = thread->context.s; thread->context.t = NULL; if (thread != current) { switch (thread->state) { case STATE_BLOCKED: case STATE_BLOCKED_W_TMO: /* Remove thread from object it's waiting on */ remove_from_list_l(thread->bqp, thread); #ifdef HAVE_WAKEUP_EXT_CB if (thread->wakeup_ext_cb != NULL) thread->wakeup_ext_cb(thread); #endif break; } SDL_SemPost(s); } THREAD_SDL_DEBUGF("Removing thread: %d (%s)\n", thread - threads, THREAD_SDL_GET_NAME(thread)); new_thread_id(thread->id, thread); thread->state = STATE_KILLED; thread_queue_wake(&thread->queue); SDL_DestroySemaphore(s); if (thread == current) { /* Do a graceful exit - perform the longjmp back into the thread function to return */ restore_irq(oldlevel); longjmp(thread_jmpbufs[current - threads], 1); } SDL_KillThread(t); restore_irq(oldlevel); }
static void sighandler( int signo ){ if( signo == SIGINT ){ SDL_KillThread(chatserv); SDL_Quit(); TTF_Quit(); int i; for(i=0; i<numMessages; i++) if(text[i] != NULL) SDL_FreeSurface(text[i]); SDL_DestroySemaphore(msgbuf_sem); SDL_DestroySemaphore(textSem); exit(0); } }
CDebuggingServer::~CDebuggingServer() { SDL_DestroySemaphore(m_BreakPointsSem); if (m_MgContext) { mg_stop(m_MgContext); m_MgContext = NULL; } }
BXBGProcess::~BXBGProcess() { Stop(); if (m_pJobs) SDL_DestroySemaphore(m_pJobs); if (m_pQueueLock) SDL_DestroyMutex(m_pQueueLock); if (m_pCapacity) SDL_DestroySemaphore(m_pCapacity); if (m_pPauseCond) SDL_DestroyCond(m_pPauseCond); if (m_pPauseLock) SDL_DestroyMutex(m_pPauseLock); }
SndDrvTmpl::~SndDrvTmpl() { // TODO Auto-generated destructor stub enable = FALSE; if(RenderSem != NULL) { SDL_SemWait(RenderSem); SDL_DestroySemaphore(RenderSem); RenderSem = NULL; } }
/* Free the mutex */ void SDL_DestroyMutex(SDL_mutex *mutex) { if ( mutex ) { if ( mutex->sem ) { SDL_DestroySemaphore(mutex->sem); } free(mutex); } }
~CUserReporterWorker() { // Clean up resources SDL_DestroySemaphore(m_WorkerSem); curl_slist_free_all(m_Headers); curl_easy_cleanup(m_Curl); }
void fs_semaphore_destroy(fs_semaphore *semaphore) { #if defined(USE_PSEM) sem_destroy(&semaphore->semaphore); #elif defined(USE_SDL) SDL_DestroySemaphore(semaphore->semaphore); #else #error no thread support #endif g_free(semaphore); }
def_dll int sdl_semaphore::destroy() { if(_semaphore) { SDL_DestroySemaphore(_semaphore); _semaphore = NULL; return 0; } return -1; }
int destroyDisplay( SAC_ND_PARAM_in_nodesc( disp_nt, Display)) { SDL_Event event; if (SDLsac_isasync) { /* stop the timer */ if (SDLsac_timer != NULL) { SDL_RemoveTimer( SDLsac_timer); } /* tell the event handler to quit */ event.type = SDL_USEREVENT_QUIT; event.user.code = 0; event.user.data1 = NULL; event.user.data2 = NULL; SDL_PushEvent(&event); /* wait for event handler to finish */ if (SDLsac_eventhandler != NULL) { SDL_WaitThread( SDLsac_eventhandler, NULL); } #ifdef UPDATE_VIA_SEMAPHORE /* kill the updater */ SDL_KillThread( SDLsac_updater); /* destroy the semaphore */ SDL_DestroySemaphore( SDLsac_updatesem); #endif } /* destroy the semaphore */ SDL_DestroySemaphore( SDLsac_selectsem); /* finally, we can release this */ if (SDLsac_mutex != NULL) { SDL_DestroyMutex( SDLsac_mutex); } SDL_Quit(); return(0); }
static void CleanNetInfo() { SDL_SemWait(net_info.lock); SDL_DestroySemaphore(net_info.lock); int status; if (net_info.thread_refresh) SDL_WaitThread(net_info.thread_refresh, &status); net_info.thread_refresh = NULL; net_info.finished = true; net_info.lst_games.clear(); }