/* Join a parallel thread - Wait for its termination, then return its result code: */ int PsychDeleteThread(psych_thread* threadhandle) { psych_uint32 rc; // Join on the thread, wait for termination: rc = (int) WaitForSingleObject((*threadhandle)->handle, INFINITE); if (WAIT_FAILED != rc) { // Retrieve exit code of terminated thread: GetExitCodeThread((*threadhandle)->handle, &rc); // Destroy its associated ressources: CloseHandle((*threadhandle)->handle); } else { printf("PTB-CRITICAL: In PsychDeleteThread: Waiting for termination of a worker thread failed! Prepare for trouble!\n"); } // Release event/condition variable for signalling of terminate requests: if (PsychDestroyCondition(&((*threadhandle)->terminateReq))) printf("PTB-CRITICAL: In PsychDeleteThread: Failed to destroy associated condition/signal object when trying to delete processing thread!"); // Null out now invalid thread handle of dead thread: (*threadhandle)->handle = NULL; (*threadhandle)->threadId = 0; (*threadhandle)->terminateReq = NULL; free(*threadhandle); *threadhandle = NULL; // Return return code of joined thread: return((int) rc); }
void PsychHIDShutdownHIDStandardInterfaces(void) { int i; // Release all keyboard queues: for (i = 0; i < PSYCH_HID_MAX_DEVICES; i++) { if (psychHIDKbQueueFirstPress[i]) { PsychHIDOSKbQueueRelease(i); } } // Close all devices registered in x_dev array: for (i = 0; i < PSYCH_HID_MAX_DEVICES; i++) { if (x_dev[i]) x_dev[i]->Release(); x_dev[i] = NULL; } // Release keyboard queue mutex: PsychDestroyMutex(&KbQueueMutex); PsychDestroyCondition(&KbQueueCondition); KbQueueThreadTerminate = FALSE; if (!CloseHandle(hEvent)) { printf("PsychHID-WARNING: Closing keyboard event handle failed!\n"); } ndevices = 0; // Close our dedicated x-display connection and we are done: if (dinput) dinput->Release(); dinput = NULL; return; }
psych_bool PsychHIDDeleteEventBuffer(int deviceIndex) { if (deviceIndex < 0) deviceIndex = PsychHIDGetDefaultKbQueueDevice(); if (hidEventBuffer[deviceIndex]) { // Empty the buffer, reset read/writepointers: PsychHIDFlushEventBuffer(deviceIndex); // Release it: free(hidEventBuffer[deviceIndex]); hidEventBuffer[deviceIndex] = NULL; PsychDestroyMutex(&hidEventBufferMutex[deviceIndex]); PsychDestroyCondition(&hidEventBufferCondition[deviceIndex]); } return(TRUE); }
void PsychHIDShutdownHIDStandardInterfaces(void) { int i; // Release all keyboard queues: for (i = 0; i < PSYCH_HID_MAX_DEVICES; i++) { if (psychHIDKbQueueFirstPress[i]) { PsychHIDOSKbQueueRelease(i); } } // Release keyboard queue mutex: PsychDestroyMutex(&KbQueueMutex); PsychDestroyCondition(&KbQueueCondition); return; }
/* * PsychGSDeleteMovie() -- Delete a movie object and release all associated ressources. */ void PsychGSDeleteMovie(int moviehandle) { if (moviehandle < 0 || moviehandle >= PSYCH_MAX_MOVIES) { PsychErrorExitMsg(PsychError_user, "Invalid moviehandle provided!"); } if (movieRecordBANK[moviehandle].theMovie == NULL) { PsychErrorExitMsg(PsychError_user, "Invalid moviehandle provided. No movie associated with this handle !!!"); } // Stop movie playback immediately: PsychMoviePipelineSetState(movieRecordBANK[moviehandle].theMovie, GST_STATE_NULL, 20.0); // Delete movieobject for this handle: gst_object_unref(GST_OBJECT(movieRecordBANK[moviehandle].theMovie)); movieRecordBANK[moviehandle].theMovie=NULL; // Delete visual context for this movie: movieRecordBANK[moviehandle].MovieContext = NULL; PsychDestroyMutex(&movieRecordBANK[moviehandle].mutex); PsychDestroyCondition(&movieRecordBANK[moviehandle].condition); free(movieRecordBANK[moviehandle].imageBuffer); movieRecordBANK[moviehandle].imageBuffer = NULL; movieRecordBANK[moviehandle].videosink = NULL; // Recycled texture in texture cache? if (movieRecordBANK[moviehandle].cached_texture > 0) { // Yes. Release it. glDeleteTextures(1, &(movieRecordBANK[moviehandle].cached_texture)); movieRecordBANK[moviehandle].cached_texture = 0; } // Decrease counter: if (numMovieRecords>0) numMovieRecords--; return; }