Beispiel #1
0
ALsfpreset *NewPreset(ALCcontext *context)
{
    ALCdevice *device = context->Device;
    ALsfpreset *preset;
    ALenum err;

    preset = calloc(1, sizeof(*preset));
    if(!preset)
        SET_ERROR_AND_RETURN_VALUE(context, AL_OUT_OF_MEMORY, NULL);
    ALsfpreset_Construct(preset);

    err = NewThunkEntry(&preset->id);
    if(err == AL_NO_ERROR)
        err = InsertUIntMapEntry(&device->PresetMap, preset->id, preset);
    if(err != AL_NO_ERROR)
    {
        ALsfpreset_Destruct(preset);
        memset(preset, 0, sizeof(*preset));
        free(preset);

        SET_ERROR_AND_RETURN_VALUE(context, err, NULL);
    }

    return preset;
}
Beispiel #2
0
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
{
    ALCcontext *Context;

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

    if(n < 0 || IsBadWritePtr((void*)effectslots, n * sizeof(ALuint)))
        alSetError(Context, AL_INVALID_VALUE);
    else
    {
        ALenum err;
        ALsizei i;

        err = ResizeEffectSlotArray(Context, n);
        if(err != AL_NO_ERROR)
        {
            alSetError(Context, err);
            n = 0;
        }

        for(i = 0;i < n;i++)
        {
            ALeffectslot *slot = calloc(1, sizeof(ALeffectslot));
            if(!slot || InitEffectSlot(slot) != AL_NO_ERROR)
            {
                free(slot);
                // We must have run out or memory
                alSetError(Context, AL_OUT_OF_MEMORY);
                alDeleteAuxiliaryEffectSlots(i, effectslots);
                break;
            }

            LockContext(Context);
            err = ResizeEffectSlotArray(Context, 1);
            if(err == AL_NO_ERROR)
                Context->ActiveEffectSlots[Context->ActiveEffectSlotCount++] = slot;
            UnlockContext(Context);
            if(err == AL_NO_ERROR)
                err = NewThunkEntry(&slot->effectslot);
            if(err == AL_NO_ERROR)
                err = InsertUIntMapEntry(&Context->EffectSlotMap, slot->effectslot, slot);
            if(err != AL_NO_ERROR)
            {
                RemoveEffectSlotArray(Context, slot);
                FreeThunkEntry(slot->effectslot);
                ALeffectState_Destroy(slot->EffectState);
                free(slot);

                alSetError(Context, err);
                alDeleteAuxiliaryEffectSlots(i, effectslots);
                break;
            }

            effectslots[i] = slot->effectslot;
        }
    }

    ALCcontext_DecRef(Context);
}
Beispiel #3
0
ALbuffer *NewBuffer(ALCcontext *context)
{
    ALCdevice *device = context->Device;
    ALbuffer *buffer;
    ALenum err;

    buffer = calloc(1, sizeof(ALbuffer));
    if(!buffer)
        SET_ERROR_AND_RETURN_VALUE(context, AL_OUT_OF_MEMORY, NULL);
    RWLockInit(&buffer->lock);

    err = NewThunkEntry(&buffer->id);
    if(err == AL_NO_ERROR)
        err = InsertUIntMapEntry(&device->BufferMap, buffer->id, buffer);
    if(err != AL_NO_ERROR)
    {
        FreeThunkEntry(buffer->id);
        memset(buffer, 0, sizeof(ALbuffer));
        free(buffer);

        SET_ERROR_AND_RETURN_VALUE(context, err, NULL);
    }

    return buffer;
}
int pthread_key_create(pthread_key_t *key, void (*callback)(void*))
{
    *key = TlsAlloc();
    if(callback)
        InsertUIntMapEntry(&TlsDestructor, *key, callback);
    return 0;
}
Beispiel #5
0
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
{
    ALCcontext *context;
    VECTOR(ALeffectslot*) slotvec;
    ALsizei cur;
    ALenum err;

    context = GetContextRef();
    if(!context) return;

    VECTOR_INIT(slotvec);

    if(!(n >= 0))
        SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
    if(!VECTOR_RESERVE(slotvec, n))
        SET_ERROR_AND_GOTO(context, AL_OUT_OF_MEMORY, done);

    for(cur = 0;cur < n;cur++)
    {
        ALeffectslot *slot = al_calloc(16, sizeof(ALeffectslot));
        err = AL_OUT_OF_MEMORY;
        if(!slot || (err=InitEffectSlot(slot)) != AL_NO_ERROR)
        {
            al_free(slot);
            alDeleteAuxiliaryEffectSlots(cur, effectslots);
            SET_ERROR_AND_GOTO(context, err, done);
        }

        err = NewThunkEntry(&slot->id);
        if(err == AL_NO_ERROR)
            err = InsertUIntMapEntry(&context->EffectSlotMap, slot->id, slot);
        if(err != AL_NO_ERROR)
        {
            FreeThunkEntry(slot->id);
            DELETE_OBJ(slot->Params.EffectState);
            al_free(slot);

            alDeleteAuxiliaryEffectSlots(cur, effectslots);
            SET_ERROR_AND_GOTO(context, err, done);
        }

        aluInitEffectPanning(slot);

        VECTOR_PUSH_BACK(slotvec, slot);

        effectslots[cur] = slot->id;
    }
    err = AddEffectSlotArray(context, VECTOR_BEGIN(slotvec), n);
    if(err != AL_NO_ERROR)
    {
        alDeleteAuxiliaryEffectSlots(cur, effectslots);
        SET_ERROR_AND_GOTO(context, err, done);
    }

done:
    VECTOR_DEINIT(slotvec);

    ALCcontext_DecRef(context);
}
Beispiel #6
0
int altss_create(altss_t *tss_id, altss_dtor_t callback)
{
    DWORD key = TlsAlloc();
    if(key == TLS_OUT_OF_INDEXES)
        return althrd_error;

    *tss_id = key;
    if(callback != NULL)
        InsertUIntMapEntry(&TlsDestructors, key, callback);
    return althrd_success;
}
Beispiel #7
0
/*
*    alGenDatabuffersEXT(ALsizei n, ALuint *puiBuffers)
*
*    Generates n AL Databuffers, and stores the Databuffers Names in the array pointed to by puiBuffers
*/
AL_API ALvoid AL_APIENTRY alGenDatabuffersEXT(ALsizei n,ALuint *puiBuffers)
{
    ALCcontext *Context;
    ALsizei i=0;

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

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

        /* Check the pointer is valid (and points to enough memory to store
         * Databuffer Names) */
        if(!IsBadWritePtr((void*)puiBuffers, n * sizeof(ALuint)))
        {
            ALenum err;

            /* Create all the new Databuffers */
            while(i < n)
            {
                ALdatabuffer *buffer = calloc(1, sizeof(ALdatabuffer));
                if(!buffer)
                {
                    alSetError(Context, AL_OUT_OF_MEMORY);
                    alDeleteDatabuffersEXT(i, puiBuffers);
                    break;
                }

                buffer->databuffer = ALTHUNK_ADDENTRY(buffer);
                err = InsertUIntMapEntry(&device->DatabufferMap,
                                         buffer->databuffer, buffer);
                if(err != AL_NO_ERROR)
                {
                    ALTHUNK_REMOVEENTRY(buffer->databuffer);
                    memset(buffer, 0, sizeof(ALdatabuffer));
                    free(buffer);

                    alSetError(Context, err);
                    alDeleteDatabuffersEXT(i, puiBuffers);
                    break;
                }
                puiBuffers[i++] = buffer->databuffer;

                buffer->state = UNMAPPED;
            }
        }
        else
            alSetError(Context, AL_INVALID_VALUE);
    }

    ProcessContext(Context);
}
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
{
    ALCcontext *Context;
    ALsizei    cur = 0;

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

    al_try
    {
        ALenum err;

        CHECK_VALUE(Context, n >= 0);
        for(cur = 0;cur < n;cur++)
        {
            ALeffectslot *slot = al_calloc(16, sizeof(ALeffectslot));
            err = AL_OUT_OF_MEMORY;
            if(!slot || (err=InitEffectSlot(slot)) != AL_NO_ERROR)
            {
                al_free(slot);
                al_throwerr(Context, err);
                break;
            }

            err = NewThunkEntry(&slot->id);
            if(err == AL_NO_ERROR)
                err = InsertUIntMapEntry(&Context->EffectSlotMap, slot->id, slot);
            if(err != AL_NO_ERROR)
            {
                FreeThunkEntry(slot->id);
                ALeffectState_Destroy(slot->EffectState);
                al_free(slot);

                al_throwerr(Context, err);
            }

            effectslots[cur] = slot->id;
        }
        err = AddEffectSlotArray(Context, n, effectslots);
        if(err != AL_NO_ERROR)
            al_throwerr(Context, err);
    }
    al_catchany()
    {
        if(cur > 0)
            alDeleteAuxiliaryEffectSlots(cur, effectslots);
    }
    al_endtry;

    ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
{
    ALCcontext *context;
    ALeffectslot *first, *last;
    ALsizei cur;
    ALenum err;

    context = GetContextRef();
    if(!context) return;

    if(!(n >= 0))
        SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);

    first = last = NULL;
    for(cur = 0;cur < n;cur++)
    {
        ALeffectslot *slot = al_calloc(16, sizeof(ALeffectslot));
        err = AL_OUT_OF_MEMORY;
        if(!slot || (err=InitEffectSlot(slot)) != AL_NO_ERROR)
        {
            al_free(slot);
            alDeleteAuxiliaryEffectSlots(cur, effectslots);
            SET_ERROR_AND_GOTO(context, err, done);
        }

        err = NewThunkEntry(&slot->id);
        if(err == AL_NO_ERROR)
            err = InsertUIntMapEntry(&context->EffectSlotMap, slot->id, slot);
        if(err != AL_NO_ERROR)
        {
            FreeThunkEntry(slot->id);
            DELETE_OBJ(slot->Params.EffectState);
            al_free(slot);

            alDeleteAuxiliaryEffectSlots(cur, effectslots);
            SET_ERROR_AND_GOTO(context, err, done);
        }

        aluInitEffectPanning(slot);

        if(!first) first = slot;
        if(last) ATOMIC_STORE(&last->next, slot);
        last = slot;

        effectslots[cur] = slot->id;
    }
    AddEffectSlotList(context, first, last);

done:
    ALCcontext_DecRef(context);
}
Beispiel #10
0
/*
*    alGenBuffers(ALsizei n, ALuint *puiBuffers)
*
*    Generates n AL Buffers, and stores the Buffers Names in the array pointed to by puiBuffers
*/
AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers)
{
    ALCcontext *Context;
    ALsizei i=0;

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

    // Check that we are actually generation some Buffers
    if(n > 0)
    {
        ALCdevice *device = Context->Device;
        ALenum err;

        // Check the pointer is valid (and points to enough memory to store Buffer Names)
        if(IsBadWritePtr((void*)buffers, n * sizeof(ALuint)))
            alSetError(Context, AL_INVALID_VALUE);
        else
        {
            // Create all the new Buffers
            while(i < n)
            {
                ALbuffer *buffer = calloc(1, sizeof(ALbuffer));
                if(!buffer)
                {
                    alSetError(Context, AL_OUT_OF_MEMORY);
                    alDeleteBuffers(i, buffers);
                    break;
                }

                buffer->buffer = (ALuint)ALTHUNK_ADDENTRY(buffer);
                err = InsertUIntMapEntry(&device->BufferMap, buffer->buffer,
                                         buffer);
                if(err != AL_NO_ERROR)
                {
                    ALTHUNK_REMOVEENTRY(buffer->buffer);
                    memset(buffer, 0, sizeof(ALbuffer));
                    free(buffer);

                    alSetError(Context, err);
                    alDeleteBuffers(i, buffers);
                    break;
                }
                buffers[i++] = buffer->buffer;
            }
        }
    }

    ProcessContext(Context);
}
AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
{
    ALCcontext *Context;
    ALsizei i=0;

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

    if (n > 0)
    {
        ALCdevice *device = Context->Device;

        // Check that enough memory has been allocted in the 'filters' array for n Filters
        if (!IsBadWritePtr((void*)filters, n * sizeof(ALuint)))
        {
            ALenum err;

            while(i < n)
            {
                ALfilter *filter = calloc(1, sizeof(ALfilter));
                if(!filter)
                {
                    alSetError(Context, AL_OUT_OF_MEMORY);
                    alDeleteFilters(i, filters);
                    break;
                }

                filter->filter = ALTHUNK_ADDENTRY(filter);
                err = InsertUIntMapEntry(&device->FilterMap, filter->filter,
                                         filter);
                if(err != AL_NO_ERROR)
                {
                    ALTHUNK_REMOVEENTRY(filter->filter);
                    memset(filter, 0, sizeof(ALfilter));
                    free(filter);

                    alSetError(Context, err);
                    alDeleteFilters(i, filters);
                    break;
                }

                filters[i++] = filter->filter;
                InitFilterParams(filter, AL_FILTER_NULL);
            }
        }
    }

    ProcessContext(Context);
}
Beispiel #12
0
AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
{
    ALCcontext *Context;
    ALsizei    cur = 0;

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

    al_try
    {
        ALCdevice *device = Context->Device;
        ALenum err;

        CHECK_VALUE(Context, n >= 0);
        for(cur = 0;cur < n;cur++)
        {
            ALeffect *effect = calloc(1, sizeof(ALeffect));
            err = AL_OUT_OF_MEMORY;
            if(!effect || (err=InitEffect(effect)) != AL_NO_ERROR)
            {
                free(effect);
                al_throwerr(Context, err);
            }

            err = NewThunkEntry(&effect->id);
            if(err == AL_NO_ERROR)
                err = InsertUIntMapEntry(&device->EffectMap, effect->id, effect);
            if(err != AL_NO_ERROR)
            {
                FreeThunkEntry(effect->id);
                memset(effect, 0, sizeof(ALeffect));
                free(effect);

                al_throwerr(Context, err);
            }

            effects[cur] = effect->id;
        }
    }
    al_catchany()
    {
        if(cur > 0)
            alDeleteEffects(cur, effects);
    }
    al_endtry;

    ALCcontext_DecRef(Context);
}
Beispiel #13
0
AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
{
    ALCcontext *Context;
    ALsizei i;

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

    if(n < 0 || IsBadWritePtr((void*)filters, n * sizeof(ALuint)))
        alSetError(Context, AL_INVALID_VALUE);
    else
    {
        ALCdevice *device = Context->Device;
        ALenum err;

        for(i = 0;i < n;i++)
        {
            ALfilter *filter = calloc(1, sizeof(ALfilter));
            if(!filter)
            {
                alSetError(Context, AL_OUT_OF_MEMORY);
                alDeleteFilters(i, filters);
                break;
            }
            InitFilterParams(filter, AL_FILTER_NULL);

            err = NewThunkEntry(&filter->filter);
            if(err == AL_NO_ERROR)
                err = InsertUIntMapEntry(&device->FilterMap, filter->filter, filter);
            if(err != AL_NO_ERROR)
            {
                FreeThunkEntry(filter->filter);
                memset(filter, 0, sizeof(ALfilter));
                free(filter);

                alSetError(Context, err);
                alDeleteFilters(i, filters);
                break;
            }

            filters[i] = filter->filter;
        }
    }

    ALCcontext_DecRef(Context);
}
Beispiel #14
0
AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
{
    ALCcontext *Context;
    ALsizei i;

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

    if(n < 0 || IsBadWritePtr((void*)effects, n * sizeof(ALuint)))
        alSetError(Context, AL_INVALID_VALUE);
    else
    {
        ALCdevice *device = Context->Device;
        ALenum err;

        for(i = 0;i < n;i++)
        {
            ALeffect *effect = calloc(1, sizeof(ALeffect));
            if(!effect || InitEffect(effect) != AL_NO_ERROR)
            {
                free(effect);
                alSetError(Context, AL_OUT_OF_MEMORY);
                alDeleteEffects(i, effects);
                break;
            }

            err = NewThunkEntry(&effect->effect);
            if(err == AL_NO_ERROR)
                err = InsertUIntMapEntry(&device->EffectMap, effect->effect, effect);
            if(err != AL_NO_ERROR)
            {
                FreeThunkEntry(effect->effect);
                memset(effect, 0, sizeof(ALeffect));
                free(effect);

                alSetError(Context, err);
                alDeleteEffects(i, effects);
                break;
            }

            effects[i] = effect->effect;
        }
    }

    ALCcontext_DecRef(Context);
}
Beispiel #15
0
AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
{
    ALCcontext *Context;
    ALsizei    cur = 0;

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

    al_try
    {
        ALCdevice *device = Context->Device;
        ALenum err;

        CHECK_VALUE(Context, n >= 0);
        for(cur = 0;cur < n;cur++)
        {
            ALfilter *filter = calloc(1, sizeof(ALfilter));
            if(!filter)
                al_throwerr(Context, AL_OUT_OF_MEMORY);
            InitFilterParams(filter, AL_FILTER_NULL);

            err = NewThunkEntry(&filter->id);
            if(err == AL_NO_ERROR)
                err = InsertUIntMapEntry(&device->FilterMap, filter->id, filter);
            if(err != AL_NO_ERROR)
            {
                FreeThunkEntry(filter->id);
                memset(filter, 0, sizeof(ALfilter));
                free(filter);

                al_throwerr(Context, err);
            }

            filters[cur] = filter->id;
        }
    }
    al_catchany()
    {
        if(cur > 0)
            alDeleteFilters(cur, filters);
    }
    al_endtry;

    ALCcontext_DecRef(Context);
}
Beispiel #16
0
AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
{
    ALCcontext *Context;
    ALsizei i=0;

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

    if(n < 0 || IsBadWritePtr((void*)effects, n * sizeof(ALuint)))
        alSetError(Context, AL_INVALID_VALUE);
    else
    {
        ALCdevice *device = Context->Device;
        ALenum err;

        while(i < n)
        {
            ALeffect *effect = calloc(1, sizeof(ALeffect));
            if(!effect)
            {
                alSetError(Context, AL_OUT_OF_MEMORY);
                alDeleteEffects(i, effects);
                break;
            }

            effect->effect = ALTHUNK_ADDENTRY(effect);
            err = InsertUIntMapEntry(&device->EffectMap, effect->effect, effect);
            if(err != AL_NO_ERROR)
            {
                ALTHUNK_REMOVEENTRY(effect->effect);
                memset(effect, 0, sizeof(ALeffect));
                free(effect);

                alSetError(Context, err);
                alDeleteEffects(i, effects);
                break;
            }

            effects[i++] = effect->effect;
            InitEffectParams(effect, AL_EFFECT_NULL);
        }
    }

    ProcessContext(Context);
}
Beispiel #17
0
AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
{
    ALCcontext *Context;
    ALsizei i=0;

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

    if(n < 0 || IsBadWritePtr((void*)filters, n * sizeof(ALuint)))
        alSetError(Context, AL_INVALID_VALUE);
    else
    {
        ALCdevice *device = Context->Device;
        ALenum err;

        while(i < n)
        {
            ALfilter *filter = alCalloc(1, sizeof(ALfilter));
            if(!filter)
            {
                alSetError(Context, AL_OUT_OF_MEMORY);
                alDeleteFilters(i, filters);
                break;
            }

            filter->filter = ALTHUNK_ADDENTRY(filter);
            err = InsertUIntMapEntry(&device->FilterMap, filter->filter, filter);
            if(err != AL_NO_ERROR)
            {
                ALTHUNK_REMOVEENTRY(filter->filter);
                memset(filter, 0, sizeof(ALfilter));
                alFree(filter);

                alSetError(Context, err);
                alDeleteFilters(i, filters);
                break;
            }

            filters[i++] = filter->filter;
            InitFilterParams(filter, AL_FILTER_NULL);
        }
    }

    ProcessContext(Context);
}
Beispiel #18
0
AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
{
    ALCdevice *device;
    ALCcontext *context;
    ALsizei cur = 0;
    ALenum err;

    context = GetContextRef();
    if(!context) return;

    if(!(n >= 0))
        SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);

    device = context->Device;
    for(cur = 0;cur < n;cur++)
    {
        ALfilter *filter = calloc(1, sizeof(ALfilter));
        if(!filter)
        {
            alDeleteFilters(cur, filters);
            SET_ERROR_AND_GOTO(context, AL_OUT_OF_MEMORY, done);
        }
        InitFilterParams(filter, AL_FILTER_NULL);

        err = NewThunkEntry(&filter->id);
        if(err == AL_NO_ERROR)
            err = InsertUIntMapEntry(&device->FilterMap, filter->id, filter);
        if(err != AL_NO_ERROR)
        {
            FreeThunkEntry(filter->id);
            memset(filter, 0, sizeof(ALfilter));
            free(filter);

            alDeleteFilters(cur, filters);
            SET_ERROR_AND_GOTO(context, err, done);
        }

        filters[cur] = filter->id;
    }

done:
    ALCcontext_DecRef(context);
}
Beispiel #19
0
AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers)
{
    ALCdevice *device;
    ALCcontext *context;
    ALsizei cur = 0;
    ALenum err;

    context = GetContextRef();
    if(!context) return;

    if(!(n >= 0))
        SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);

    device = context->Device;
    for(cur = 0; cur < n; cur++)
    {
        ALbuffer *buffer = calloc(1, sizeof(ALbuffer));
        if(!buffer)
        {
            alDeleteBuffers(cur, buffers);
            SET_ERROR_AND_GOTO(context, AL_OUT_OF_MEMORY, done);
        }
        RWLockInit(&buffer->lock);

        err = NewThunkEntry(&buffer->id);
        if(err == AL_NO_ERROR)
            err = InsertUIntMapEntry(&device->BufferMap, buffer->id, buffer);
        if(err != AL_NO_ERROR)
        {
            FreeThunkEntry(buffer->id);
            memset(buffer, 0, sizeof(ALbuffer));
            free(buffer);

            alDeleteBuffers(cur, buffers);
            SET_ERROR_AND_GOTO(context, err, done);
        }

        buffers[cur] = buffer->id;
    }

done:
    ALCcontext_DecRef(context);
}
Beispiel #20
0
AL_API void AL_APIENTRY alGenSoundfontsSOFT(ALsizei n, ALuint *ids)
{
    ALCdevice *device;
    ALCcontext *context;
    ALsizei cur = 0;
    ALenum err;

    context = GetContextRef();
    if(!context) return;

    if(!(n >= 0))
        SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);

    device = context->Device;
    for(cur = 0;cur < n;cur++)
    {
        ALsoundfont *sfont = calloc(1, sizeof(ALsoundfont));
        if(!sfont)
        {
            alDeleteSoundfontsSOFT(cur, ids);
            SET_ERROR_AND_GOTO(context, AL_OUT_OF_MEMORY, done);
        }
        ALsoundfont_Construct(sfont);

        err = NewThunkEntry(&sfont->id);
        if(err == AL_NO_ERROR)
            err = InsertUIntMapEntry(&device->SfontMap, sfont->id, sfont);
        if(err != AL_NO_ERROR)
        {
            ALsoundfont_Destruct(sfont);
            memset(sfont, 0, sizeof(ALsoundfont));
            free(sfont);

            alDeleteSoundfontsSOFT(cur, ids);
            SET_ERROR_AND_GOTO(context, err, done);
        }

        ids[cur] = sfont->id;
    }

done:
    ALCcontext_DecRef(context);
}
Beispiel #21
0
AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
{
    ALCdevice *device;
    ALCcontext *context;
    ALsizei cur;

    context = GetContextRef();
    if(!context) return;

    if(!(n >= 0))
        SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);

    device = context->Device;
    for(cur = 0;cur < n;cur++)
    {
        ALeffect *effect = calloc(1, sizeof(ALeffect));
        ALenum err = AL_OUT_OF_MEMORY;
        if(!effect || (err=InitEffect(effect)) != AL_NO_ERROR)
        {
            free(effect);
            alDeleteEffects(cur, effects);
            SET_ERROR_AND_GOTO(context, err, done);
        }

        err = NewThunkEntry(&effect->id);
        if(err == AL_NO_ERROR)
            err = InsertUIntMapEntry(&device->EffectMap, effect->id, effect);
        if(err != AL_NO_ERROR)
        {
            FreeThunkEntry(effect->id);
            memset(effect, 0, sizeof(ALeffect));
            free(effect);

            alDeleteEffects(cur, effects);
            SET_ERROR_AND_GOTO(context, err, done);
        }

        effects[cur] = effect->id;
    }

done:
    ALCcontext_DecRef(context);
}
Beispiel #22
0
int althrd_create(althrd_t *thr, althrd_start_t func, void *arg)
{
    thread_cntr *cntr;
    DWORD thrid;
    HANDLE hdl;

    cntr = malloc(sizeof(*cntr));
    if(!cntr) return althrd_nomem;

    cntr->func = func;
    cntr->arg = arg;

    hdl = CreateThread(NULL, THREAD_STACK_SIZE, althrd_starter, cntr, 0, &thrid);
    if(!hdl)
    {
        free(cntr);
        return althrd_error;
    }
    InsertUIntMapEntry(&ThrdIdHandle, thrid, hdl);

    *thr = thrid;
    return althrd_success;
}
Beispiel #23
0
int pthread_key_delete(pthread_key_t key)
{
    InsertUIntMapEntry(&TlsDestructor, key, NULL);
    TlsFree(key);
    return 0;
}
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
{
    ALCcontext *Context;
    ALCdevice *Device;

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

    Device = Context->Device;
    if(n < 0 || IsBadWritePtr((void*)effectslots, n * sizeof(ALuint)))
        alSetError(Context, AL_INVALID_VALUE);
    else if((ALuint)n > Device->AuxiliaryEffectSlotMax - Context->EffectSlotMap.size)
        alSetError(Context, AL_INVALID_VALUE);
    else
    {
        ALenum err;
        ALsizei i, j;

        i = 0;
        while(i < n)
        {
            ALeffectslot *slot = calloc(1, sizeof(ALeffectslot));
            if(!slot || !(slot->EffectState=NoneCreate()))
            {
                free(slot);
                // We must have run out or memory
                alSetError(Context, AL_OUT_OF_MEMORY);
                alDeleteAuxiliaryEffectSlots(i, effectslots);
                break;
            }

            slot->effectslot = (ALuint)ALTHUNK_ADDENTRY(slot);
            err = InsertUIntMapEntry(&Context->EffectSlotMap,
                                     slot->effectslot, slot);
            if(err != AL_NO_ERROR)
            {
                ALTHUNK_REMOVEENTRY(slot->effectslot);
                ALEffect_Destroy(slot->EffectState);
                free(slot);

                alSetError(Context, err);
                alDeleteAuxiliaryEffectSlots(i, effectslots);
                break;
            }

            effectslots[i++] = slot->effectslot;

            slot->Gain = int2ALfp(1);
            slot->AuxSendAuto = AL_TRUE;
            for(j = 0;j < BUFFERSIZE;j++)
                slot->WetBuffer[j] = int2ALfp(0);
            for(j = 0;j < 1;j++)
            {
                slot->ClickRemoval[j] = int2ALfp(0);
                slot->PendingClicks[j] = int2ALfp(0);
            }
            slot->refcount = 0;
        }
    }

    ProcessContext(Context);
}
Beispiel #25
0
void InitEffectFactoryMap(void)
{
    InitUIntMap(&EffectStateFactoryMap, ~0);

    InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_NULL, ALnullStateFactory_getFactory);
    InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_EAXREVERB, ALreverbStateFactory_getFactory);
    InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_REVERB, ALreverbStateFactory_getFactory);
    InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_AUTOWAH, ALautowahStateFactory_getFactory);
    InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_CHORUS, ALchorusStateFactory_getFactory);
    InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_COMPRESSOR, ALcompressorStateFactory_getFactory);
    InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_DISTORTION, ALdistortionStateFactory_getFactory);
    InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_ECHO, ALechoStateFactory_getFactory);
    InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_EQUALIZER, ALequalizerStateFactory_getFactory);
    InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_FLANGER, ALflangerStateFactory_getFactory);
    InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_RING_MODULATOR, ALmodulatorStateFactory_getFactory);
    InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_DEDICATED_DIALOGUE, ALdedicatedStateFactory_getFactory);
    InsertUIntMapEntry(&EffectStateFactoryMap, AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT, ALdedicatedStateFactory_getFactory);
}