Example #1
0
AL_API ALvoid AL_APIENTRY alDeletePresetsSOFT(ALsizei n, const ALuint *ids)
{
    ALCdevice *device;
    ALCcontext *context;
    ALsfpreset *preset;
    ALsizei i;

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

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

    device = context->Device;
    for(i = 0;i < n;i++)
    {
        /* Check for valid ID */
        if((preset=LookupPreset(device, ids[i])) == NULL)
            SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
        if(ReadRef(&preset->ref) != 0)
            SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done);
    }

    for(i = 0;i < n;i++)
    {
        if((preset=LookupPreset(device, ids[i])) != NULL)
            DeletePreset(device, preset);
    }

done:
    ALCcontext_DecRef(context);
}
Example #2
0
AL_API void AL_APIENTRY alPresetiSOFT(ALuint id, ALenum param, ALint value)
{
    ALCdevice *device;
    ALCcontext *context;
    ALsfpreset *preset;

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

    device = context->Device;
    if((preset=LookupPreset(device, id)) == NULL)
        SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
    if(ReadRef(&preset->ref) != 0)
        SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done);
    switch(param)
    {
        case AL_MIDI_PRESET_SOFT:
            if(!(value >= 0 && value <= 127))
                SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
            preset->Preset = value;
            break;

        case AL_MIDI_BANK_SOFT:
            if(!(value >= 0 && value <= 128))
                SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
            preset->Bank = value;
            break;

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

done:
    ALCcontext_DecRef(context);
}
Example #3
0
AL_API void AL_APIENTRY alPresetivSOFT(ALuint id, ALenum param, const ALint *values)
{
    ALCdevice *device;
    ALCcontext *context;
    ALsfpreset *preset;

    switch(param)
    {
        case AL_MIDI_PRESET_SOFT:
        case AL_MIDI_BANK_SOFT:
            alPresetiSOFT(id, param, values[0]);
            return;
    }

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

    device = context->Device;
    if((preset=LookupPreset(device, id)) == NULL)
        SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
    if(ReadRef(&preset->ref) != 0)
        SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done);
    switch(param)
    {
        default:
            SET_ERROR_AND_GOTO(context, AL_INVALID_ENUM, done);
    }

done:
    ALCcontext_DecRef(context);
}
Example #4
0
AL_API void AL_APIENTRY alPresetFontsoundsSOFT(ALuint id, ALsizei count, const ALuint *fsids)
{
    ALCdevice *device;
    ALCcontext *context;
    ALsfpreset *preset;
    ALfontsound **sounds;
    ALsizei i;

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

    device = context->Device;
    if(!(preset=LookupPreset(device, id)))
        SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
    if(count < 0)
        SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);

    if(ReadRef(&preset->ref) != 0)
        SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done);

    if(count == 0)
        sounds = NULL;
    else
    {
        sounds = calloc(count, sizeof(sounds[0]));
        if(!sounds)
            SET_ERROR_AND_GOTO(context, AL_OUT_OF_MEMORY, done);

        for(i = 0;i < count;i++)
        {
            if(!(sounds[i]=LookupFontsound(device, fsids[i])))
            {
                free(sounds);
                SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
            }
        }
    }

    for(i = 0;i < count;i++)
        IncrementRef(&sounds[i]->ref);

    sounds = ExchangePtr((XchgPtr*)&preset->Sounds, sounds);
    count = ExchangeInt(&preset->NumSounds, count);

    for(i = 0;i < count;i++)
        DecrementRef(&sounds[i]->ref);
    free(sounds);

done:
    ALCcontext_DecRef(context);
}
Example #5
0
AL_API ALboolean AL_APIENTRY alIsPresetSOFT(ALuint id)
{
    ALCcontext *context;
    ALboolean ret;

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

    ret = LookupPreset(context->Device, id) ? AL_TRUE : AL_FALSE;

    ALCcontext_DecRef(context);

    return ret;
}
Example #6
0
AL_API void AL_APIENTRY alGetPresetivSOFT(ALuint id, ALenum param, ALint *values)
{
    ALCdevice *device;
    ALCcontext *context;
    ALsfpreset *preset;
    ALsizei i;

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

    device = context->Device;
    if((preset=LookupPreset(device, id)) == NULL)
        SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
    switch(param)
    {
        case AL_MIDI_PRESET_SOFT:
            values[0] = preset->Preset;
            break;

        case AL_MIDI_BANK_SOFT:
            values[0] = preset->Bank;
            break;

        case AL_FONTSOUNDS_SIZE_SOFT:
            values[0] = preset->NumSounds;
            break;

        case AL_FONTSOUNDS_SOFT:
            for(i = 0;i < preset->NumSounds;i++)
                values[i] = preset->Sounds[i]->id;
            break;

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

done:
    ALCcontext_DecRef(context);
}
Example #7
0
AL_API void AL_APIENTRY alSoundfontPresetsSOFT(ALuint id, ALsizei count, const ALuint *pids)
{
    ALCdevice *device;
    ALCcontext *context;
    ALsoundfont *sfont;
    ALsfpreset **presets;
    ALsizei i;

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

    device = context->Device;
    if(id == 0)
        SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done);
    if(!(sfont=LookupSfont(device, id)))
        SET_ERROR_AND_GOTO(context, AL_INVALID_NAME, done);
    if(count < 0)
        SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);

    WriteLock(&sfont->Lock);
    if(ReadRef(&sfont->ref) != 0)
    {
        WriteUnlock(&sfont->Lock);
        SET_ERROR_AND_GOTO(context, AL_INVALID_OPERATION, done);
    }

    if(count == 0)
        presets = NULL;
    else
    {
        presets = calloc(count, sizeof(presets[0]));
        if(!presets)
        {
            WriteUnlock(&sfont->Lock);
            SET_ERROR_AND_GOTO(context, AL_OUT_OF_MEMORY, done);
        }

        for(i = 0;i < count;i++)
        {
            if(!(presets[i]=LookupPreset(device, pids[i])))
            {
                free(presets);
                WriteUnlock(&sfont->Lock);
                SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
            }
        }
    }

    for(i = 0;i < count;i++)
        IncrementRef(&presets[i]->ref);

    presets = ExchangePtr((XchgPtr*)&sfont->Presets, presets);
    count = ExchangeInt(&sfont->NumPresets, count);
    WriteUnlock(&sfont->Lock);

    for(i = 0;i < count;i++)
        DecrementRef(&presets[i]->ref);
    free(presets);

done:
    ALCcontext_DecRef(context);
}