/* alcDestroyContext Remove a Context */ ALCAPI ALCvoid ALCAPIENTRY alcDestroyContext(ALCcontext *context) { ALCcontext **list; InitAL(); // Lock context list SuspendContext(NULL); if (IsContext(context)) { // Lock context SuspendContext(context); ReleaseALSources(context); ReleaseALAuxiliaryEffectSlots(context); context->Device->Context = NULL; list = &g_pContextList; while(*list != context) list = &(*list)->next; *list = (*list)->next; g_ulContextCount--; // Unlock context ProcessContext(context); ExitContext(context); // Free memory (MUST do this after ProcessContext) memset(context, 0, sizeof(ALCcontext)); free(context); } else SetALCError(ALC_INVALID_CONTEXT); ProcessContext(NULL); }
/* alcDestroyContext Remove a Context */ ALCAPI ALCvoid ALCAPIENTRY alcDestroyContext(ALCcontext *context) { ALCcontext **list; ALuint i; if (IsContext(context)) { ALCdevice *Device = context->Device; if(Device->NumContexts == 1) ALCdevice_StopPlayback(Device); SuspendContext(NULL); for(i = 0;i < Device->NumContexts-1;i++) { if(Device->Contexts[i] == context) { memmove(&Device->Contexts[i], &Device->Contexts[i+1], (Device->NumContexts-i-1) * sizeof(*Device->Contexts)); break; } } Device->NumContexts--; // Lock context SuspendContext(context); if(context->SourceCount > 0) { #ifdef _DEBUG AL_PRINT("alcDestroyContext(): deleting %d Source(s)\n", context->SourceCount); #endif ReleaseALSources(context); } if(context->AuxiliaryEffectSlotCount > 0) { #ifdef _DEBUG AL_PRINT("alcDestroyContext(): deleting %d AuxiliaryEffectSlot(s)\n", context->AuxiliaryEffectSlotCount); #endif ReleaseALAuxiliaryEffectSlots(context); } list = &g_pContextList; while(*list != context) list = &(*list)->next; *list = (*list)->next; g_ulContextCount--; // Unlock context ProcessContext(context); ProcessContext(NULL); ExitContext(context); // Free memory (MUST do this after ProcessContext) memset(context, 0, sizeof(ALCcontext)); free(context); } else alcSetError(ALC_INVALID_CONTEXT); }