コード例 #1
0
ファイル: ALc.c プロジェクト: xiaobinshe/multitv
static void InitAL(void)
{
    static int done = 0;
    if(!done)
    {
        int i;
        const char *devs;

        InitializeCriticalSection(&_alMutex);
        ALTHUNK_INIT();
        ReadALConfig();

        devs = GetConfigValue(NULL, "drivers", "");
        if(devs[0])
        {
            int n;
            size_t len;
            const char *next = devs;

            i = 0;

            do {
                devs = next;
                next = strchr(devs, ',');

                if(!devs[0] || devs[0] == ',')
                    continue;

                len = (next ? ((size_t)(next-devs)) : strlen(devs));
                for(n = i;BackendList[n].Init;n++)
                {
                    if(len == strlen(BackendList[n].name) &&
                       strncmp(BackendList[n].name, devs, len) == 0)
                    {
                        const char *name = BackendList[i].name;
                        void (*Init)(BackendFuncs*) = BackendList[i].Init;

                        BackendList[i].name = BackendList[n].name;
                        BackendList[i].Init = BackendList[n].Init;

                        BackendList[n].name = name;
                        BackendList[n].Init = Init;

                        i++;
                    }
                }
            } while(next++);

            BackendList[i].name = NULL;
            BackendList[i].Init = NULL;
        }

        for(i = 0;BackendList[i].Init;i++)
            BackendList[i].Init(&BackendList[i].Funcs);
        done = 1;
    }
}
コード例 #2
0
ファイル: ALc.c プロジェクト: ghoulsblade/vegaogre
static void InitAL(void)
{
    if(!init_done)
    {
        int i;
        const char *devs, *str;

        init_done = AL_TRUE;

        InitializeCriticalSection(&g_csMutex);
        ALTHUNK_INIT();
        ReadALConfig();

        devs = GetConfigValue(NULL, "drivers", "");
        if(devs[0])
        {
            int n;
            size_t len;
            const char *next = devs;

            i = 0;

            do {
                devs = next;
                next = strchr(devs, ',');

                if(!devs[0] || devs[0] == ',')
                    continue;

                len = (next ? ((size_t)(next-devs)) : strlen(devs));
                for(n = i;BackendList[n].Init;n++)
                {
                    if(len == strlen(BackendList[n].name) &&
                       strncmp(BackendList[n].name, devs, len) == 0)
                    {
                        const char *name = BackendList[i].name;
                        void (*Init)(BackendFuncs*) = BackendList[i].Init;

                        BackendList[i].name = BackendList[n].name;
                        BackendList[i].Init = BackendList[n].Init;

                        BackendList[n].name = name;
                        BackendList[n].Init = Init;

                        i++;
                    }
                }
            } while(next++);

            BackendList[i].name = NULL;
            BackendList[i].Init = NULL;
        }

        for(i = 0;BackendList[i].Init;i++)
            BackendList[i].Init(&BackendList[i].Funcs);

        str = GetConfigValue(NULL, "stereodup", "false");
        DuplicateStereo = (strcasecmp(str, "true") == 0 ||
                           strcasecmp(str, "yes") == 0 ||
                           strcasecmp(str, "on") == 0 ||
                           atoi(str) != 0);

        str = GetConfigValue(NULL, "excludefx", "");
        if(str[0])
        {
            const struct {
                const char *name;
                int type;
            } EffectList[] = {
                { "reverb", REVERB },
                { NULL, 0 }
            };
            int n;
            size_t len;
            const char *next = str;

            do {
                str = next;
                next = strchr(str, ',');

                if(!str[0] || next == str)
                    continue;

                len = (next ? ((size_t)(next-str)) : strlen(str));
                for(n = 0;EffectList[n].name;n++)
                {
                    if(len == strlen(EffectList[n].name) &&
                       strncmp(EffectList[n].name, str, len) == 0)
                        DisabledEffects[EffectList[n].type] = AL_TRUE;
                }
            } while(next++);
        }
    }
}
コード例 #3
0
ファイル: ALc.c プロジェクト: SergeStinckwich/openqwaq
static void alc_init(void)
{
    int i;
    const char *devs, *str;

    InitializeCriticalSection(&g_csMutex);
    ALTHUNK_INIT();
    ReadALConfig();

    tls_create(&LocalContext);

    devs = GetConfigValue(NULL, "drivers", "");
    if(devs[0])
    {
        int n;
        size_t len;
        const char *next = devs;

        i = 0;
        do {
            devs = next;
            next = strchr(devs, ',');

            if(!devs[0] || devs[0] == ',')
                continue;

            len = (next ? ((size_t)(next-devs)) : strlen(devs));
            for(n = i;BackendList[n].Init;n++)
            {
                if(len == strlen(BackendList[n].name) &&
                   strncmp(BackendList[n].name, devs, len) == 0)
                {
                    BackendInfo Bkp = BackendList[i];
                    BackendList[i] = BackendList[n];
                    BackendList[n] = Bkp;

                    i++;
                }
            }
        } while(next++);

        BackendList[i].name = NULL;
        BackendList[i].Init = NULL;
        BackendList[i].Deinit = NULL;
        BackendList[i].Probe = NULL;
    }

    for(i = 0;BackendList[i].Init;i++)
    {
        BackendList[i].Init(&BackendList[i].Funcs);

        BackendList[i].Probe(DEVICE_PROBE);
        BackendList[i].Probe(ALL_DEVICE_PROBE);
        BackendList[i].Probe(CAPTURE_DEVICE_PROBE);
    }

    DuplicateStereo = GetConfigValueBool(NULL, "stereodup", 0);

    str = GetConfigValue(NULL, "excludefx", "");
    if(str[0])
    {
        const struct {
            const char *name;
            int type;
        } EffectList[] = {
            { "eaxreverb", EAXREVERB },
            { "reverb", REVERB },
            { "echo", ECHO },
            { NULL, 0 }
        };
        int n;
        size_t len;
        const char *next = str;

        do {
            str = next;
            next = strchr(str, ',');

            if(!str[0] || next == str)
                continue;

            len = (next ? ((size_t)(next-str)) : strlen(str));
            for(n = 0;EffectList[n].name;n++)
            {
                if(len == strlen(EffectList[n].name) &&
                   strncmp(EffectList[n].name, str, len) == 0)
                    DisabledEffects[EffectList[n].type] = AL_TRUE;
            }
        } while(next++);
    }
}