Пример #1
0
/* mixer helper function */
static int mixer_enum_string_to_value(struct mixer_ctl *ctl, const char *string)
{
    unsigned int i;

    /* Search the enum strings for a particular one */
    for (i = 0; i < mixer_ctl_get_num_enums(ctl); i++) {
        if (strcmp(mixer_ctl_get_enum_string(ctl, i), string) == 0)
            break;
    }

    return i;
}
Пример #2
0
static void tinymix_print_enum(struct mixer_ctl *ctl)
{
    unsigned int num_enums;
    unsigned int i;
    unsigned int value;
    const char *string;

    num_enums = mixer_ctl_get_num_enums(ctl);
    value = mixer_ctl_get_value(ctl, 0);

    for (i = 0; i < num_enums; i++) {
        string = mixer_ctl_get_enum_string(ctl, i);
        printf("%s%s, ", value == i ? "> " : "", string);
    }
}
Пример #3
0
static void tinymix_print_enum(struct mixer_ctl *ctl, int print_all)
{
    unsigned int num_enums;
    char buffer[256];
    unsigned int i;

    num_enums = mixer_ctl_get_num_enums(ctl);

    for (i = 0; i < num_enums; i++) {
        mixer_ctl_get_enum_string(ctl, i, buffer, sizeof(buffer));
        if (print_all)
            printf("\t%s%s", mixer_ctl_get_value(ctl, 0) == (int)i ? ">" : "",
                   buffer);
        else if (mixer_ctl_get_value(ctl, 0) == (int)i)
            printf(" %-s", buffer);
    }
}
Пример #4
0
static void tinymix_print_enum(struct mixer_ctl *ctl, int print_all)
{
    unsigned int num_enums;
    unsigned int i;
    const char *string;

    num_enums = mixer_ctl_get_num_enums(ctl);

    for (i = 0; i < num_enums; i++) {
        string = mixer_ctl_get_enum_string(ctl, i);
        if (print_all)
            printf("\t%s%s", mixer_ctl_get_value(ctl, 0) == (int)i ? ">" : "",
                   string);
        else if (mixer_ctl_get_value(ctl, 0) == (int)i)
            printf(" %-s", string);
    }
}
Пример #5
0
int mixer_cache_populate(struct audio_tool_mixer_cache *cache, struct mixer *mixer)
{
    struct mixer_ctl *ctl;
    struct audio_tool_mixer_control_info *cur;
    const char* name;
    size_t count, n, v;
    int tmp;

    if (!cache)
        return EINVAL;

    if (!mixer)
        return EINVAL;

    if (cache->ctrls)
        free(cache->ctrls);

    count = mixer_get_num_ctls(mixer);
    cache->count = count;

    if (count) {
        cache->ctrls = calloc(count, sizeof(struct audio_tool_mixer_control_info));
        if (! cache->ctrls)
            return -ENOMEM;
    }

    for (n = 0, cur = cache->ctrls ; n < count ; ++n, ++cur) {
        ctl = mixer_get_ctl(mixer, n);
        if (!ctl)
            return ENODEV;
        name = mixer_ctl_get_name(ctl);
        if (!name)
            return ENODEV;

        cur->id = n;
        cur->type = mixer_ctl_get_type(ctl);
        strcpy(cur->name, name);
        cur->num_values = mixer_ctl_get_num_values(ctl);
        if (cur->num_values > MAX_NUM_VALUES)
            cur->num_values = MAX_NUM_VALUES;
        for (v = 0 ; v < cur->num_values ; ++v) {
            switch (cur->type) {
            case MIXER_CTL_TYPE_BOOL:
            case MIXER_CTL_TYPE_INT:
                cur->value.integer[v] = mixer_ctl_get_value(ctl, v);
                break;
            case MIXER_CTL_TYPE_ENUM:
                tmp = mixer_ctl_get_value(ctl, v);
                name = mixer_ctl_get_enum_string(ctl, tmp);
                // null value names were causing seg fault here
                if (name)
                    strcpy(cur->value.enumerated[v], name);
                else
                    printf("Skipping ENUM due to null setting for %s\n", cur->name);
                break;
            case MIXER_CTL_TYPE_BYTE:
                cur->value.byte[v] = mixer_ctl_get_value(ctl, v);
                break;
            case MIXER_CTL_TYPE_INT64:
                cur->value.integer64[v] = mixer_ctl_get_value(ctl, v);
                break;
            default:
                (void)0;
            }
        }
    }

    return 0;
}