Exemplo n.º 1
0
static void eaxreverb_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals)
{
    switch(param)
    {
        case AL_EAXREVERB_REFLECTIONS_PAN:
            if(isfinite(vals[0]) && isfinite(vals[1]) && isfinite(vals[2]))
            {
                LockContext(context);
                effect->Reverb.ReflectionsPan[0] = vals[0];
                effect->Reverb.ReflectionsPan[1] = vals[1];
                effect->Reverb.ReflectionsPan[2] = vals[2];
                UnlockContext(context);
            }
            else
                alSetError(context, AL_INVALID_VALUE);
            break;
        case AL_EAXREVERB_LATE_REVERB_PAN:
            if(isfinite(vals[0]) && isfinite(vals[1]) && isfinite(vals[2]))
            {
                LockContext(context);
                effect->Reverb.LateReverbPan[0] = vals[0];
                effect->Reverb.LateReverbPan[1] = vals[1];
                effect->Reverb.LateReverbPan[2] = vals[2];
                UnlockContext(context);
            }
            else
                alSetError(context, AL_INVALID_VALUE);
            break;

        default:
            eaxreverb_SetParamf(effect, context, param, vals[0]);
            break;
    }
}
Exemplo n.º 2
0
AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *value2, ALint *value3)
{
    ALCcontext *context;

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

    if(!(value1 && value2 && value3))
        SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
    switch (param)
    {
    case AL_POSITION:
        LockContext(context);
        *value1 = (ALint)context->Listener->Position[0];
        *value2 = (ALint)context->Listener->Position[1];
        *value3 = (ALint)context->Listener->Position[2];
        UnlockContext(context);
        break;

    case AL_VELOCITY:
        LockContext(context);
        *value1 = (ALint)context->Listener->Velocity[0];
        *value2 = (ALint)context->Listener->Velocity[1];
        *value3 = (ALint)context->Listener->Velocity[2];
        UnlockContext(context);
        break;

    default:
        SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
    }

done:
    ALCcontext_DecRef(context);
}
Exemplo n.º 3
0
AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void)
{
    ALCcontext *Context;

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

    if(ExchangeInt(&Context->DeferUpdates, AL_FALSE))
    {
        ALsizei pos;

        LockContext(Context);
        LockUIntMapRead(&Context->SourceMap);
        for(pos = 0;pos < Context->SourceMap.size;pos++)
        {
            ALsource *Source = Context->SourceMap.array[pos].value;
            ALenum new_state;

            if((Source->state == AL_PLAYING || Source->state == AL_PAUSED) &&
               Source->Offset >= 0.0)
                ApplyOffset(Source);

            new_state = ExchangeInt(&Source->new_state, AL_NONE);
            if(new_state)
                SetSourceState(Source, Context, new_state);
        }
        UnlockUIntMapRead(&Context->SourceMap);
        UnlockContext(Context);
    }

    ALCcontext_DecRef(Context);
}
Exemplo n.º 4
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);
}
Exemplo n.º 5
0
AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
{
    ALCcontext *context;

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

    if(!context->DeferUpdates)
    {
        ALboolean UpdateSources;
        ALactivesource **src, **src_end;
        ALeffectslot **slot, **slot_end;
        FPUCtl oldMode;

        SetMixerFPUMode(&oldMode);

        LockContext(context);
        context->DeferUpdates = AL_TRUE;

        /* Make sure all pending updates are performed */
        UpdateSources = ATOMIC_EXCHANGE(ALenum, &context->UpdateSources, AL_FALSE);

        src = context->ActiveSources;
        src_end = src + context->ActiveSourceCount;
        while(src != src_end)
        {
            ALsource *source = (*src)->Source;

            if(source->state != AL_PLAYING && source->state != AL_PAUSED)
            {
                ALactivesource *temp = *(--src_end);
                *src_end = *src;
                *src = temp;
                --(context->ActiveSourceCount);
                continue;
            }

            if(ATOMIC_EXCHANGE(ALenum, &source->NeedsUpdate, AL_FALSE) || UpdateSources)
                (*src)->Update(*src, context);

            src++;
        }

        slot = VECTOR_ITER_BEGIN(context->ActiveAuxSlots);
        slot_end = VECTOR_ITER_END(context->ActiveAuxSlots);
        while(slot != slot_end)
        {
            if(ATOMIC_EXCHANGE(ALenum, &(*slot)->NeedsUpdate, AL_FALSE))
                V((*slot)->EffectState,update)(context->Device, *slot);
            slot++;
        }

        UnlockContext(context);
        RestoreFPUMode(&oldMode);
    }

    ALCcontext_DecRef(context);
}
Exemplo n.º 6
0
AL_API ALvoid AL_APIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues)
{
    ALCcontext *Context;

    if(pflValues)
    {
        switch(eParam)
        {
            case AL_GAIN:
            case AL_METERS_PER_UNIT:
                alListenerf(eParam, pflValues[0]);
                return;

            case AL_POSITION:
            case AL_VELOCITY:
                alListener3f(eParam, pflValues[0], pflValues[1], pflValues[2]);
                return;
        }
    }

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

    if(pflValues)
    {
        switch(eParam)
        {
            case AL_ORIENTATION:
                if(isfinite(pflValues[0]) && isfinite(pflValues[1]) &&
                   isfinite(pflValues[2]) && isfinite(pflValues[3]) &&
                   isfinite(pflValues[4]) && isfinite(pflValues[5]))
                {
                    LockContext(Context);
                    // AT then UP
                    Context->Listener.Forward[0] = pflValues[0];
                    Context->Listener.Forward[1] = pflValues[1];
                    Context->Listener.Forward[2] = pflValues[2];
                    Context->Listener.Up[0] = pflValues[3];
                    Context->Listener.Up[1] = pflValues[4];
                    Context->Listener.Up[2] = pflValues[5];
                    Context->UpdateSources = AL_TRUE;
                    UnlockContext(Context);
                }
                else
                    alSetError(Context, AL_INVALID_VALUE);
                break;

            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
        }
    }
    else
        alSetError(Context, AL_INVALID_VALUE);

    ALCcontext_DecRef(Context);
}
Exemplo n.º 7
0
AL_API ALvoid AL_APIENTRY alListener3f(ALenum eParam, ALfloat flValue1, ALfloat flValue2, ALfloat flValue3)
{
    ALCcontext *Context;

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

    switch(eParam)
    {
        case AL_POSITION:
            if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3))
            {
                LockContext(Context);
                Context->Listener.Position[0] = flValue1;
                Context->Listener.Position[1] = flValue2;
                Context->Listener.Position[2] = flValue3;
                Context->UpdateSources = AL_TRUE;
                UnlockContext(Context);
            }
            else
                alSetError(Context, AL_INVALID_VALUE);
            break;

        case AL_VELOCITY:
            if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3))
            {
                LockContext(Context);
                Context->Listener.Velocity[0] = flValue1;
                Context->Listener.Velocity[1] = flValue2;
                Context->Listener.Velocity[2] = flValue3;
                Context->UpdateSources = AL_TRUE;
                UnlockContext(Context);
            }
            else
                alSetError(Context, AL_INVALID_VALUE);
            break;

        default:
            alSetError(Context, AL_INVALID_ENUM);
            break;
    }

    ALCcontext_DecRef(Context);
}
Exemplo n.º 8
0
AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
{
    ALCcontext *Context;

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

    if(!Context->DeferUpdates)
    {
        ALboolean UpdateSources;
        ALsource **src, **src_end;
        ALeffectslot **slot, **slot_end;
        FPUCtl oldMode;

        SetMixerFPUMode(&oldMode);

        LockContext(Context);
        Context->DeferUpdates = AL_TRUE;

        /* Make sure all pending updates are performed */
        UpdateSources = ExchangeInt(&Context->UpdateSources, AL_FALSE);

        src = Context->ActiveSources;
        src_end = src + Context->ActiveSourceCount;
        while(src != src_end)
        {
            if((*src)->state != AL_PLAYING)
            {
                Context->ActiveSourceCount--;
                *src = *(--src_end);
                continue;
            }

            if(ExchangeInt(&(*src)->NeedsUpdate, AL_FALSE) || UpdateSources)
                ALsource_Update(*src, Context);

            src++;
        }

        slot = Context->ActiveEffectSlots;
        slot_end = slot + Context->ActiveEffectSlotCount;
        while(slot != slot_end)
        {
            if(ExchangeInt(&(*slot)->NeedsUpdate, AL_FALSE))
                VCALL((*slot)->EffectState,update,(Context->Device, *slot));
            slot++;
        }

        UnlockContext(Context);
        RestoreFPUMode(&oldMode);
    }

    ALCcontext_DecRef(Context);
}
Exemplo n.º 9
0
static ALenum AddEffectSlotArray(ALCcontext *context, ALeffectslot **start, ALsizei count)
{
    ALenum err = AL_NO_ERROR;

    LockContext(context);
    if(!VECTOR_INSERT(context->ActiveAuxSlots, VECTOR_ITER_END(context->ActiveAuxSlots), start, start+count))
        err = AL_OUT_OF_MEMORY;
    UnlockContext(context);

    return err;
}
Exemplo n.º 10
0
AL_API ALvoid AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3)
{
    ALCcontext *Context;

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

    al_try
    {
        switch(param)
        {
            case AL_POSITION:
                CHECK_VALUE(Context, isfinite(value1) && isfinite(value2) && isfinite(value3));

                LockContext(Context);
                Context->Listener->Position[0] = value1;
                Context->Listener->Position[1] = value2;
                Context->Listener->Position[2] = value3;
                Context->UpdateSources = AL_TRUE;
                UnlockContext(Context);
                break;

            case AL_VELOCITY:
                CHECK_VALUE(Context, isfinite(value1) && isfinite(value2) && isfinite(value3));

                LockContext(Context);
                Context->Listener->Velocity[0] = value1;
                Context->Listener->Velocity[1] = value2;
                Context->Listener->Velocity[2] = value3;
                Context->UpdateSources = AL_TRUE;
                UnlockContext(Context);
                break;

            default:
                al_throwerr(Context, AL_INVALID_ENUM);
        }
    }
    al_endtry;

    ALCcontext_DecRef(Context);
}
Exemplo n.º 11
0
AL_API ALvoid AL_APIENTRY alListenerfv(ALenum param, const ALfloat *values)
{
    ALCcontext *Context;

    if(values)
    {
        switch(param)
        {
            case AL_GAIN:
            case AL_METERS_PER_UNIT:
                alListenerf(param, values[0]);
                return;

            case AL_POSITION:
            case AL_VELOCITY:
                alListener3f(param, values[0], values[1], values[2]);
                return;
        }
    }

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

    al_try
    {
        CHECK_VALUE(Context, values);
        switch(param)
        {
            case AL_ORIENTATION:
                CHECK_VALUE(Context, isfinite(values[0]) && isfinite(values[1]) &&
                                     isfinite(values[2]) && isfinite(values[3]) &&
                                     isfinite(values[4]) && isfinite(values[5]));

                LockContext(Context);
                /* AT then UP */
                Context->Listener->Forward[0] = values[0];
                Context->Listener->Forward[1] = values[1];
                Context->Listener->Forward[2] = values[2];
                Context->Listener->Up[0] = values[3];
                Context->Listener->Up[1] = values[4];
                Context->Listener->Up[2] = values[5];
                Context->UpdateSources = AL_TRUE;
                UnlockContext(Context);
                break;

            default:
                al_throwerr(Context, AL_INVALID_ENUM);
        }
    }
    al_endtry;

    ALCcontext_DecRef(Context);
}
Exemplo n.º 12
0
AL_API ALvoid AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3)
{
    ALCcontext *context;

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

    switch(param)
    {
    case AL_POSITION:
        if(!(isfinite(value1) && isfinite(value2) && isfinite(value3)))
            SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);

        LockContext(context);
        context->Listener->Position[0] = value1;
        context->Listener->Position[1] = value2;
        context->Listener->Position[2] = value3;
        context->UpdateSources = AL_TRUE;
        UnlockContext(context);
        break;

    case AL_VELOCITY:
        if(!(isfinite(value1) && isfinite(value2) && isfinite(value3)))
            SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);

        LockContext(context);
        context->Listener->Velocity[0] = value1;
        context->Listener->Velocity[1] = value2;
        context->Listener->Velocity[2] = value3;
        context->UpdateSources = AL_TRUE;
        UnlockContext(context);
        break;

    default:
        SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
    }

done:
    ALCcontext_DecRef(context);
}
Exemplo n.º 13
0
AL_API ALvoid AL_APIENTRY alListenerfv(ALenum param, const ALfloat *values)
{
    ALCcontext *context;

    if(values)
    {
        switch(param)
        {
        case AL_GAIN:
        case AL_METERS_PER_UNIT:
            alListenerf(param, values[0]);
            return;

        case AL_POSITION:
        case AL_VELOCITY:
            alListener3f(param, values[0], values[1], values[2]);
            return;
        }
    }

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

    if(!(values))
        SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
    switch(param)
    {
    case AL_ORIENTATION:
        if(!(isfinite(values[0]) && isfinite(values[1]) && isfinite(values[2]) &&
             isfinite(values[3]) && isfinite(values[4]) && isfinite(values[5])))
            SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);

        LockContext(context);
        /* AT then UP */
        context->Listener->Forward[0] = values[0];
        context->Listener->Forward[1] = values[1];
        context->Listener->Forward[2] = values[2];
        context->Listener->Up[0] = values[3];
        context->Listener->Up[1] = values[4];
        context->Listener->Up[2] = values[5];
        context->UpdateSources = AL_TRUE;
        UnlockContext(context);
        break;

    default:
        SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
    }

done:
    ALCcontext_DecRef(context);
}
Exemplo n.º 14
0
AL_API void AL_APIENTRY alGetListener3i(ALenum eParam, ALint *plValue1, ALint *plValue2, ALint *plValue3)
{
    ALCcontext *Context;

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

    if(plValue1 && plValue2 && plValue3)
    {
        switch (eParam)
        {
            case AL_POSITION:
                LockContext(Context);
                *plValue1 = (ALint)Context->Listener.Position[0];
                *plValue2 = (ALint)Context->Listener.Position[1];
                *plValue3 = (ALint)Context->Listener.Position[2];
                UnlockContext(Context);
                break;

            case AL_VELOCITY:
                LockContext(Context);
                *plValue1 = (ALint)Context->Listener.Velocity[0];
                *plValue2 = (ALint)Context->Listener.Velocity[1];
                *plValue3 = (ALint)Context->Listener.Velocity[2];
                UnlockContext(Context);
                break;

            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
        }
    }
    else
        alSetError(Context, AL_INVALID_VALUE);

    ALCcontext_DecRef(Context);
}
Exemplo n.º 15
0
AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *value2, ALint *value3)
{
    ALCcontext *Context;

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

    al_try
    {
        CHECK_VALUE(Context, value1 && value2 && value3);
        switch (param)
        {
            case AL_POSITION:
                LockContext(Context);
                *value1 = (ALint)Context->Listener->Position[0];
                *value2 = (ALint)Context->Listener->Position[1];
                *value3 = (ALint)Context->Listener->Position[2];
                UnlockContext(Context);
                break;

            case AL_VELOCITY:
                LockContext(Context);
                *value1 = (ALint)Context->Listener->Velocity[0];
                *value2 = (ALint)Context->Listener->Velocity[1];
                *value3 = (ALint)Context->Listener->Velocity[2];
                UnlockContext(Context);
                break;

            default:
                al_throwerr(Context, AL_INVALID_ENUM);
        }
    }
    al_endtry;

    ALCcontext_DecRef(Context);
}
Exemplo n.º 16
0
static void eaxreverb_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals)
{
    switch(param)
    {
        case AL_EAXREVERB_REFLECTIONS_PAN:
            LockContext(context);
            vals[0] = effect->Reverb.ReflectionsPan[0];
            vals[1] = effect->Reverb.ReflectionsPan[1];
            vals[2] = effect->Reverb.ReflectionsPan[2];
            UnlockContext(context);
            break;
        case AL_EAXREVERB_LATE_REVERB_PAN:
            LockContext(context);
            vals[0] = effect->Reverb.LateReverbPan[0];
            vals[1] = effect->Reverb.LateReverbPan[1];
            vals[2] = effect->Reverb.LateReverbPan[2];
            UnlockContext(context);
            break;

        default:
            eaxreverb_GetParamf(effect, context, param, vals);
            break;
    }
}
Exemplo n.º 17
0
static void RemoveEffectSlotArray(ALCcontext *context, const ALeffectslot *slot)
{
    ALeffectslot **iter;

    LockContext(context);
#define MATCH_SLOT(_i)  (slot == *(_i))
    VECTOR_FIND_IF(iter, ALeffectslot*, context->ActiveAuxSlots, MATCH_SLOT);
    if(iter != VECTOR_ITER_END(context->ActiveAuxSlots))
    {
        *iter = VECTOR_BACK(context->ActiveAuxSlots);
        VECTOR_POP_BACK(context->ActiveAuxSlots);
    }
#undef MATCH_SLOT
    UnlockContext(context);
}
Exemplo n.º 18
0
AL_API ALvoid AL_APIENTRY alGetListenerfv(ALenum eParam, ALfloat *pflValues)
{
    ALCcontext *Context;

    switch(eParam)
    {
        case AL_GAIN:
        case AL_METERS_PER_UNIT:
            alGetListenerf(eParam, pflValues);
            return;

        case AL_POSITION:
        case AL_VELOCITY:
            alGetListener3f(eParam, pflValues+0, pflValues+1, pflValues+2);
            return;
    }

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

    if(pflValues)
    {
        switch(eParam)
        {
            case AL_ORIENTATION:
                LockContext(Context);
                // AT then UP
                pflValues[0] = Context->Listener.Forward[0];
                pflValues[1] = Context->Listener.Forward[1];
                pflValues[2] = Context->Listener.Forward[2];
                pflValues[3] = Context->Listener.Up[0];
                pflValues[4] = Context->Listener.Up[1];
                pflValues[5] = Context->Listener.Up[2];
                UnlockContext(Context);
                break;

            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
        }
    }
    else
        alSetError(Context, AL_INVALID_VALUE);

    ALCcontext_DecRef(Context);
}
Exemplo n.º 19
0
AL_API ALvoid AL_APIENTRY alGetListenerfv(ALenum param, ALfloat *values)
{
    ALCcontext *Context;

    switch(param)
    {
        case AL_GAIN:
        case AL_METERS_PER_UNIT:
            alGetListenerf(param, values);
            return;

        case AL_POSITION:
        case AL_VELOCITY:
            alGetListener3f(param, values+0, values+1, values+2);
            return;
    }

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

    al_try
    {
        CHECK_VALUE(Context, values);
        switch(param)
        {
            case AL_ORIENTATION:
                LockContext(Context);
                // AT then UP
                values[0] = Context->Listener->Forward[0];
                values[1] = Context->Listener->Forward[1];
                values[2] = Context->Listener->Forward[2];
                values[3] = Context->Listener->Up[0];
                values[4] = Context->Listener->Up[1];
                values[5] = Context->Listener->Up[2];
                UnlockContext(Context);
                break;

            default:
                al_throwerr(Context, AL_INVALID_ENUM);
        }
    }
    al_endtry;

    ALCcontext_DecRef(Context);
}
Exemplo n.º 20
0
static ALvoid RemoveEffectSlotArray(ALCcontext *Context, ALeffectslot *slot)
{
    ALeffectslot **slotlist, **slotlistend;

    LockContext(Context);
    slotlist = Context->ActiveEffectSlots;
    slotlistend = slotlist + Context->ActiveEffectSlotCount;
    while(slotlist != slotlistend)
    {
        if(*slotlist == slot)
        {
            *slotlist = *(--slotlistend);
            Context->ActiveEffectSlotCount--;
            break;
        }
        slotlist++;
    }
    UnlockContext(Context);
}
Exemplo n.º 21
0
AL_API ALvoid AL_APIENTRY alGetListenerfv(ALenum param, ALfloat *values)
{
    ALCcontext *context;

    switch(param)
    {
    case AL_GAIN:
    case AL_METERS_PER_UNIT:
        alGetListenerf(param, values);
        return;

    case AL_POSITION:
    case AL_VELOCITY:
        alGetListener3f(param, values+0, values+1, values+2);
        return;
    }

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

    if(!(values))
        SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
    switch(param)
    {
    case AL_ORIENTATION:
        LockContext(context);
        // AT then UP
        values[0] = context->Listener->Forward[0];
        values[1] = context->Listener->Forward[1];
        values[2] = context->Listener->Forward[2];
        values[3] = context->Listener->Up[0];
        values[4] = context->Listener->Up[1];
        values[5] = context->Listener->Up[2];
        UnlockContext(context);
        break;

    default:
        SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
    }

done:
    ALCcontext_DecRef(context);
}
Exemplo n.º 22
0
AL_API void AL_APIENTRY alGetListeneriv(ALenum eParam, ALint* plValues)
{
    ALCcontext *Context;

    switch(eParam)
    {
        case AL_POSITION:
        case AL_VELOCITY:
            alGetListener3i(eParam, plValues+0, plValues+1, plValues+2);
            return;
    }

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

    if(plValues)
    {
        switch(eParam)
        {
            case AL_ORIENTATION:
                LockContext(Context);
                // AT then UP
                plValues[0] = (ALint)Context->Listener.Forward[0];
                plValues[1] = (ALint)Context->Listener.Forward[1];
                plValues[2] = (ALint)Context->Listener.Forward[2];
                plValues[3] = (ALint)Context->Listener.Up[0];
                plValues[4] = (ALint)Context->Listener.Up[1];
                plValues[5] = (ALint)Context->Listener.Up[2];
                UnlockContext(Context);
                break;

            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
        }
    }
    else
        alSetError(Context, AL_INVALID_VALUE);

    ALCcontext_DecRef(Context);
}
Exemplo n.º 23
0
AL_API ALvoid AL_APIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues)
{
    ALCcontext *Context;

    if(pflValues)
    {
        switch(eParam)
        {
            case AL_GAIN:
            case AL_METERS_PER_UNIT:
                alListenerf(eParam, pflValues[0]);
                return;

            case AL_POSITION:
            case AL_VELOCITY:
                alListener3f(eParam, pflValues[0], pflValues[1], pflValues[2]);
                return;
        }
    }

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

    if(pflValues)
    {
        switch(eParam)
        {
            case AL_ORIENTATION:
                if(isfinite(pflValues[0]) && isfinite(pflValues[1]) &&
                   isfinite(pflValues[2]) && isfinite(pflValues[3]) &&
                   isfinite(pflValues[4]) && isfinite(pflValues[5]))
                {
                    ALfloat U[3], V[3], N[3];

                    /* AT then UP */
                    N[0] = pflValues[0];
                    N[1] = pflValues[1];
                    N[2] = pflValues[2];
                    aluNormalize(N);
                    V[0] = pflValues[3];
                    V[1] = pflValues[4];
                    V[2] = pflValues[5];
                    aluNormalize(V);
                    /* Build and normalize right-vector */
                    aluCrossproduct(N, V, U);
                    aluNormalize(U);

                    LockContext(Context);
                    Context->Listener.Forward[0] = pflValues[0];
                    Context->Listener.Forward[1] = pflValues[1];
                    Context->Listener.Forward[2] = pflValues[2];
                    Context->Listener.Up[0] = pflValues[3];
                    Context->Listener.Up[1] = pflValues[4];
                    Context->Listener.Up[2] = pflValues[5];
                    Context->Listener.Matrix[0][0] =  U[0];
                    Context->Listener.Matrix[0][1] =  V[0];
                    Context->Listener.Matrix[0][2] = -N[0];
                    Context->Listener.Matrix[0][3] =  0.0f;
                    Context->Listener.Matrix[1][0] =  U[1];
                    Context->Listener.Matrix[1][1] =  V[1];
                    Context->Listener.Matrix[1][2] = -N[1];
                    Context->Listener.Matrix[1][3] =  0.0f;
                    Context->Listener.Matrix[2][0] =  U[2];
                    Context->Listener.Matrix[2][1] =  V[2];
                    Context->Listener.Matrix[2][2] = -N[2];
                    Context->Listener.Matrix[2][3] =  0.0f;
                    Context->Listener.Matrix[3][0] =  0.0f;
                    Context->Listener.Matrix[3][1] =  0.0f;
                    Context->Listener.Matrix[3][2] =  0.0f;
                    Context->Listener.Matrix[3][3] =  1.0f;
                    Context->UpdateSources = AL_TRUE;
                    UnlockContext(Context);
                }
                else
                    alSetError(Context, AL_INVALID_VALUE);
                break;

            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
        }
    }
    else
        alSetError(Context, AL_INVALID_VALUE);

    ALCcontext_DecRef(Context);
}