Exemple #1
0
static void tinymix_list_controls(struct mixer *mixer, int print_all)
{
    struct mixer_ctl *ctl;
    const char *name, *type;
    unsigned int num_ctls, num_values;
    unsigned int i;

    num_ctls = mixer_get_num_ctls(mixer);

    printf("Number of controls: %u\n", num_ctls);

    if (print_all)
        printf("ctl\ttype\tnum\t%-40svalue\n", "name");
    else
        printf("ctl\ttype\tnum\t%-40s\n", "name");

    for (i = 0; i < num_ctls; i++) {
        ctl = mixer_get_ctl(mixer, i);

        name = mixer_ctl_get_name(ctl);
        type = mixer_ctl_get_type_string(ctl);
        num_values = mixer_ctl_get_num_values(ctl);
        printf("%u\t%s\t%u\t%-40s", i, type, num_values, name);
        if (print_all)
            tinymix_detail_control(mixer, name);
        printf("\n");
    }
}
Exemple #2
0
int main(int argc, char **argv)
{
    struct mixer *mixer;
    int card = 0;

    if ((argc > 2) && (strcmp(argv[1], "-D") == 0)) {
        argv++;
        if (argv[1]) {
            card = atoi(argv[1]);
            argv++;
            argc -= 2;
        } else {
            argc -= 1;
        }
    }

    mixer = mixer_open(card);
    if (!mixer) {
        fprintf(stderr, "Failed to open mixer\n");
        return EXIT_FAILURE;
    }


    if (argc == 1) {
        printf("Mixer name: '%s'\n", mixer_get_name(mixer));
        tinymix_list_controls(mixer);
    } else if (argc == 2) {
        tinymix_detail_control(mixer, argv[1], 1);
    } else if (argc >= 3) {
        tinymix_set_value(mixer, argv[1], &argv[2], argc - 2);
    } else {
        printf("Usage: tinymix [-D card] [control id] [value to set]\n");
    }

    mixer_close(mixer);

    return 0;
}
static void tinymix_list_controls(struct mixer *mixer)
{
    struct mixer_ctl *ctl;
    const char *type;
    unsigned int num_ctls, num_values;
    char buffer[256];
    unsigned int i;

    num_ctls = mixer_get_num_ctls(mixer);

    printf("Number of controls: %d\n", num_ctls);

    printf("ctl\ttype\tnum\t%-40s value\n", "name");
    for (i = 0; i < num_ctls; i++) {
        ctl = mixer_get_ctl(mixer, i);

        mixer_ctl_get_name(ctl, buffer, sizeof(buffer));
        type = mixer_ctl_get_type_string(ctl);
        num_values = mixer_ctl_get_num_values(ctl);
        printf("%d\t%s\t%d\t%-40s", i, type, num_values, buffer);
        tinymix_detail_control(mixer, i, 0);
    }
}
int main(int argc, char **argv)
{
    struct mixer *mixer;

    mixer = mixer_open(0);
    if (!mixer) {
        fprintf(stderr, "Failed to open mixer\n");
        return EXIT_FAILURE;
    }

    if (argc == 1)
        tinymix_list_controls(mixer);
    else if (argc == 2)
        tinymix_detail_control(mixer, atoi(argv[1]), 1);
    else if (argc == 3)
        tinymix_set_value(mixer, atoi(argv[1]), argv[2]);
    else
        printf("Usage: tinymix [control id] [value to set]\n");

    mixer_close(mixer);

    return 0;
}
Exemple #5
0
int main(int argc, char **argv)
{
    struct mixer *mixer;
    int card = 0;
    char *cmd;

    while (1) {
        static struct option long_options[] = {
            { "version", no_argument, NULL, 'v' },
            { "help",    no_argument, NULL, 'h' },
            { 0, 0, 0, 0 }
        };

        /* getopt_long stores the option index here. */
        int option_index = 0;
        int c = 0;

        c = getopt_long (argc, argv, "c:D:hv", long_options, &option_index);

        /* Detect the end of the options. */
        if (c == -1)
            break;

        switch (c) {
        case 'D':
            card = atoi(optarg);
            break;
        case 'h':
            usage();
            return EXIT_SUCCESS;
        case 'v':
            version();
            return EXIT_SUCCESS;
        }
    }

    mixer = mixer_open(card);
    if (!mixer) {
        fprintf(stderr, "Failed to open mixer\n");
        return EXIT_FAILURE;
    }

    cmd = argv[optind];
    if (cmd == NULL) {
        fprintf(stderr, "no command specified (see --help)\n");
        mixer_close(mixer);
        return EXIT_FAILURE;
    } else if (strcmp(cmd, "get") == 0) {
        if ((optind + 1) >= argc) {
            fprintf(stderr, "no control specified\n");
            mixer_close(mixer);
            return EXIT_FAILURE;
        }
        tinymix_detail_control(mixer, argv[optind + 1]);
        printf("\n");
    } else if (strcmp(cmd, "set") == 0) {
        if ((optind + 1) >= argc) {
            fprintf(stderr, "no control specified\n");
            mixer_close(mixer);
            return EXIT_FAILURE;
        }
        if ((optind + 2) >= argc) {
            fprintf(stderr, "no value(s) specified\n");
            mixer_close(mixer);
            return EXIT_FAILURE;
        }
        tinymix_set_value(mixer, argv[optind + 1], &argv[optind + 2], argc - optind - 2);
    } else if (strcmp(cmd, "controls") == 0) {
        tinymix_list_controls(mixer, 0);
    } else if (strcmp(cmd, "contents") == 0) {
        tinymix_list_controls(mixer, 1);
    } else {
        fprintf(stderr, "unknown command '%s' (see --help)\n", cmd);
        mixer_close(mixer);
        return EXIT_FAILURE;
    }

    mixer_close(mixer);
    return EXIT_SUCCESS;
}