Beispiel #1
0
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
{
    ALCcontext *Context;
    ALsizei i;

    Context = alcGetCurrentContext();
    if(!Context)
    {
        alSetError(AL_INVALID_OPERATION);
        return;
    }
    SuspendContext(Context);

    if (n > 0)
    {
        /* NOTE: We only support one slot currently */
        if(n == 1 && Context->AuxiliaryEffectSlotCount == 0)
        {
            // Check that enough memory has been allocted in the 'effectslots' array for n Effect Slots
            if (!IsBadWritePtr((void*)effectslots, n * sizeof(ALuint)))
            {
                ALeffectslot **list = &Context->AuxiliaryEffectSlot;
                while(*list)
                    list = &(*list)->next;

                i = 0;
                while(i < n)
                {
                    *list = calloc(1, sizeof(ALeffectslot));
                    if(!(*list))
                    {
                        // We must have run out or memory
                        alDeleteAuxiliaryEffectSlots(i, effectslots);
                        alSetError(AL_OUT_OF_MEMORY);
                        break;
                    }

                    (*list)->Gain = 1.0;
                    (*list)->AuxSendAuto = AL_TRUE;
                    (*list)->refcount = 0;

                    effectslots[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
                    (*list)->effectslot = effectslots[i];

                    Context->AuxiliaryEffectSlotCount++;
                    i++;

                    list = &(*list)->next;
                }
            }
        }
        else
            alSetError(AL_INVALID_OPERATION);
    }

    ProcessContext(Context);
}
ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
{
    ALCcontext *Context;
    ALsizei i, j;

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

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

        if(Context->AuxiliaryEffectSlotCount+n <= Device->AuxiliaryEffectSlotMax)
        {
            // Check that enough memory has been allocted in the 'effectslots' array for n Effect Slots
            if (!IsBadWritePtr((void*)effectslots, n * sizeof(ALuint)))
            {
                ALeffectslot **list = &Context->AuxiliaryEffectSlot;
                while(*list)
                    list = &(*list)->next;

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

                    (*list)->Gain = 1.0;
                    (*list)->AuxSendAuto = AL_TRUE;
                    for(j = 0;j < BUFFERSIZE;j++)
                        (*list)->WetBuffer[j] = 0.0f;
                    (*list)->refcount = 0;

                    effectslots[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
                    (*list)->effectslot = effectslots[i];

                    Context->AuxiliaryEffectSlotCount++;
                    i++;

                    list = &(*list)->next;
                }
            }
        }
        else
            alSetError(AL_INVALID_OPERATION);
    }

    ProcessContext(Context);
}
Beispiel #3
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);
}
Beispiel #4
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 #6
0
/*
*    alGenBuffers(ALsizei n, ALuint *puiBuffers)
*
*    Generates n AL Buffers, and stores the Buffers Names in the array pointed to by puiBuffers
*/
ALAPI ALvoid ALAPIENTRY alGenBuffers(ALsizei n,ALuint *puiBuffers)
{
    ALCcontext *Context;
    ALsizei i=0;

    Context = alcGetCurrentContext();
    SuspendContext(Context);

    // Check that we are actually generation some Buffers
    if (n > 0)
    {
        // Check the pointer is valid (and points to enough memory to store Buffer Names)
        if (!IsBadWritePtr((void*)puiBuffers, n * sizeof(ALuint)))
        {
            ALbuffer **list = &g_pBuffers;
            while(*list)
                list = &(*list)->next;

            // Create all the new Buffers
            while(i < n)
            {
                *list = calloc(1, sizeof(ALbuffer));
                if(!(*list))
                {
                    alDeleteBuffers(i, puiBuffers);
                    alSetError(AL_OUT_OF_MEMORY);
                    break;
                }

                puiBuffers[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
                (*list)->state = UNUSED;
                g_uiBufferCount++;
                i++;

                list = &(*list)->next;
            }
        }
        else
        {
            // Pointer does not point to enough memory to write Buffer names
            alSetError(AL_INVALID_VALUE);
        }
    }

    ProcessContext(Context);

    return;
}
Beispiel #7
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 #8
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 #9
0
AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
{
    ALCcontext *Context;
    ALsizei i;

    Context = alcGetCurrentContext();
    SuspendContext(Context);

    if (n > 0)
    {
        // Check that enough memory has been allocted in the 'effects' array for n Effects
        if (!IsBadWritePtr((void*)effects, n * sizeof(ALuint)))
        {
            ALeffect **list = &g_EffectList;
            while(*list)
                list = &(*list)->next;

            i = 0;
            while(i < n)
            {
                *list = calloc(1, sizeof(ALeffect));
                if(!(*list))
                {
                    // We must have run out or memory
                    alDeleteEffects(i, effects);
                    alSetError(AL_OUT_OF_MEMORY);
                    break;
                }

                effects[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
                (*list)->effect = effects[i];

                InitEffectParams(*list, AL_EFFECT_NULL);
                g_EffectCount++;
                i++;

                list = &(*list)->next;
            }
        }
    }

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

    Context = alcGetCurrentContext();
    SuspendContext(Context);

    if (n > 0)
    {
        // Check that enough memory has been allocted in the 'filters' array for n Filters
        if (!IsBadWritePtr((void*)filters, n * sizeof(ALuint)))
        {
            ALfilter **list = &g_FilterList;
            while(*list)
                list = &(*list)->next;

            i = 0;
            while(i < n)
            {
                *list = calloc(1, sizeof(ALfilter));
                if(!(*list))
                {
                    // We must have run out or memory
                    alDeleteFilters(i, filters);
                    alSetError(AL_OUT_OF_MEMORY);
                    break;
                }

                filters[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
                (*list)->filter = filters[i];

                InitFilterParams(*list, AL_FILTER_NULL);
                g_FilterCount++;
                i++;

                list = &(*list)->next;
            }
        }
    }

    ProcessContext(Context);
}
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);
}