示例#1
0
文件: threads.c 项目: Kingsquee/crown
int althrd_detach(althrd_t thr)
{
    HANDLE hdl = RemoveUIntMapKey(&ThrdIdHandle, thr);
    if(!hdl) return althrd_error;

    CloseHandle(hdl);
    return althrd_success;
}
示例#2
0
AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
{
    ALCcontext *Context;
    ALeffectslot *EffectSlot;
    ALboolean SlotsValid = AL_FALSE;
    ALsizei i;

    Context = GetContextSuspended();
    if(!Context) return;

    if(n < 0)
        alSetError(Context, AL_INVALID_VALUE);
    else
    {
        SlotsValid = AL_TRUE;
        // Check that all effectslots are valid
        for(i = 0;i < n;i++)
        {
            if((EffectSlot=LookupEffectSlot(Context->EffectSlotMap, effectslots[i])) == NULL)
            {
                alSetError(Context, AL_INVALID_NAME);
                SlotsValid = AL_FALSE;
                break;
            }
            else if(EffectSlot->refcount > 0)
            {
                alSetError(Context, AL_INVALID_NAME);
                SlotsValid = AL_FALSE;
                break;
            }
        }
    }

    if(SlotsValid)
    {
        // All effectslots are valid
        for(i = 0;i < n;i++)
        {
            // Recheck that the effectslot is valid, because there could be duplicated names
            if((EffectSlot=LookupEffectSlot(Context->EffectSlotMap, effectslots[i])) == NULL)
                continue;

            ALEffect_Destroy(EffectSlot->EffectState);

            RemoveUIntMapKey(&Context->EffectSlotMap, EffectSlot->effectslot);
            ALTHUNK_REMOVEENTRY(EffectSlot->effectslot);

            memset(EffectSlot, 0, sizeof(ALeffectslot));
            free(EffectSlot);
        }
    }

    ProcessContext(Context);
}
示例#3
0
AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters)
{
    ALCcontext *Context;
    ALCdevice *device;
    ALfilter *ALFilter;
    ALboolean Failed;
    ALsizei i;

    Context = GetContextSuspended();
    if(!Context) return;

    Failed = AL_TRUE;
    device = Context->Device;
    if(n < 0)
        alSetError(Context, AL_INVALID_VALUE);
    else
    {
        Failed = AL_FALSE;
        // Check that all filters are valid
        for(i = 0;i < n;i++)
        {
            if(!filters[i])
                continue;

            if(LookupFilter(device->FilterMap, filters[i]) == NULL)
            {
                alSetError(Context, AL_INVALID_NAME);
                Failed = AL_TRUE;
                break;
            }
        }
    }

    if(!Failed)
    {
        // All filters are valid
        for(i = 0;i < n;i++)
        {
            // Recheck that the filter is valid, because there could be duplicated names
            if((ALFilter=LookupFilter(device->FilterMap, filters[i])) == NULL)
                continue;

            RemoveUIntMapKey(&device->FilterMap, ALFilter->filter);
            ALTHUNK_REMOVEENTRY(ALFilter->filter);

            memset(ALFilter, 0, sizeof(ALfilter));
            free(ALFilter);
        }
    }

    ProcessContext(Context);
}
示例#4
0
文件: threads.c 项目: Kingsquee/crown
int althrd_join(althrd_t thr, int *res)
{
    DWORD code;

    HANDLE hdl = RemoveUIntMapKey(&ThrdIdHandle, thr);
    if(!hdl) return althrd_error;

    WaitForSingleObject(hdl, INFINITE);
    GetExitCodeThread(hdl, &code);
    CloseHandle(hdl);

    if(res != NULL)
        *res = (int)code;
    return althrd_success;
}
示例#5
0
/*
*    alDatabeleteBuffersEXT(ALsizei n, ALuint *puiBuffers)
*
*    Deletes the n AL Databuffers pointed to by puiBuffers
*/
AL_API ALvoid AL_APIENTRY alDeleteDatabuffersEXT(ALsizei n, const ALuint *puiBuffers)
{
    ALCcontext *Context;
    ALdatabuffer *ALBuf;
    ALsizei i;
    ALboolean bFailed = AL_FALSE;

    Context = GetContextSuspended();
    if(!Context) return;

    /* Check we are actually Deleting some Databuffers */
    if(n >= 0)
    {
        ALCdevice *device = Context->Device;

        /* Check that all the databuffers are valid and can actually be
         * deleted */
        for(i = 0;i < n;i++)
        {
            if(!puiBuffers[i])
                continue;

            /* Check for valid Buffer ID */
            if((ALBuf=LookupDatabuffer(device->DatabufferMap, puiBuffers[i])) != NULL)
            {
                if(ALBuf->state != UNMAPPED)
                {
                    /* Databuffer still in use, cannot be deleted */
                    alSetError(Context, AL_INVALID_OPERATION);
                    bFailed = AL_TRUE;
                    break;
                }
            }
            else
            {
                /* Invalid Databuffer */
                alSetError(Context, AL_INVALID_NAME);
                bFailed = AL_TRUE;
                break;
            }
        }

        /* If all the Databuffers were valid (and unmapped), then we can
         * delete them */
        if(!bFailed)
        {
            for(i = 0;i < n;i++)
            {
                if((ALBuf=LookupDatabuffer(device->DatabufferMap, puiBuffers[i])) != NULL)
                {
                    if(ALBuf == Context->SampleSource)
                        Context->SampleSource = NULL;
                    if(ALBuf == Context->SampleSink)
                        Context->SampleSink = NULL;

                    // Release the memory used to store audio data
                    free(ALBuf->data);

                    // Release buffer structure
                    RemoveUIntMapKey(&device->DatabufferMap, ALBuf->databuffer);
                    ALTHUNK_REMOVEENTRY(puiBuffers[i]);

                    memset(ALBuf, 0, sizeof(ALdatabuffer));
                    free(ALBuf);
                }
            }
        }
    }
    else
        alSetError(Context, AL_INVALID_VALUE);

    ProcessContext(Context);
}
示例#6
0
文件: threads.c 项目: Kingsquee/crown
void altss_delete(altss_t tss_id)
{
    RemoveUIntMapKey(&TlsDestructors, tss_id);
    TlsFree(tss_id);
}
示例#7
0
/*
*    alDeleteBuffers(ALsizei n, ALuint *puiBuffers)
*
*    Deletes the n AL Buffers pointed to by puiBuffers
*/
AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *puiBuffers)
{
    ALCcontext *Context;
    ALbuffer *ALBuf;
    ALsizei i;

    Context = GetContextSuspended();
    if(!Context) return;

    // Check we are actually Deleting some Buffers
    if(n < 0)
        alSetError(Context, AL_INVALID_VALUE);
    else
    {
        ALCdevice *device = Context->Device;
        ALboolean bFailed = AL_FALSE;

        // Check that all the buffers are valid and can actually be deleted
        for (i = 0; i < n; i++)
        {
            if(!puiBuffers[i])
                continue;

            // Check for valid Buffer ID (can be NULL buffer)
            if((ALBuf=LookupBuffer(device->BufferMap, puiBuffers[i])) != NULL)
            {
                if(ALBuf->refcount != 0)
                {
                    // Buffer still in use, cannot be deleted
                    alSetError(Context, AL_INVALID_OPERATION);
                    bFailed = AL_TRUE;
                    break;
                }
            }
            else
            {
                // Invalid Buffer
                alSetError(Context, AL_INVALID_NAME);
                bFailed = AL_TRUE;
                break;
            }
        }

        // If all the Buffers were valid (and have Reference Counts of 0), then we can delete them
        if (!bFailed)
        {
            for (i = 0; i < n; i++)
            {
                if((ALBuf=LookupBuffer(device->BufferMap, puiBuffers[i])) != NULL)
                {
                    // Release the memory used to store audio data
                    free(ALBuf->data);

                    // Release buffer structure
                    RemoveUIntMapKey(&device->BufferMap, ALBuf->buffer);
                    ALTHUNK_REMOVEENTRY(ALBuf->buffer);

                    memset(ALBuf, 0, sizeof(ALbuffer));
                    free(ALBuf);
                }
            }
        }
    }

    ProcessContext(Context);
}