Changeset aef1799 in mainline for uspace/app/wavplay/main.c


Ignore:
Timestamp:
2012-07-17T10:57:41Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1f7da3b
Parents:
cd8f19d
Message:

Integrate dplay into wavplay.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/app/wavplay/main.c

    rcd8f19d raef1799  
    4141#include <hound/client.h>
    4242#include <pcm/sample_format.h>
    43 
     43#include <getopt.h>
     44
     45#include "dplay.h"
    4446#include "wave.h"
    4547
     
    119121}
    120122
     123static const struct option opts[] = {
     124        {"device", required_argument, 0, 'd'},
     125        {"record", no_argument, 0, 'r'},
     126        {0, 0, 0, 0}
     127};
     128
     129
    121130int main(int argc, char *argv[])
    122131{
    123         if (argc != 2)
    124                 return 1;
    125         const char *file = argv[1];
     132        const char *device = "default";
     133        int idx = 0;
     134        bool direct = false, record = false;
     135        optind = 0;
     136        int ret = 0;
     137        while (ret != -1) {
     138                ret = getopt_long(argc, argv, "d:r", opts, &idx);
     139                switch (ret) {
     140                case 'd':
     141                        direct = true;
     142                        device = optarg;
     143                        break;
     144                case 'r':
     145                        record = true;
     146                        break;
     147                };
     148        }
     149
     150        if (optind == argc) {
     151                printf("Not enough arguments.\n");
     152                return 1;
     153        }
     154        const char *file = argv[optind];
     155
     156        printf("%s %s\n", record ? "Recording" : "Playing", file);
     157        if (record) {
     158                printf("Recording is not supported yet.\n");
     159                return 1;
     160        }
     161        if (direct)
     162                return dplay(device, file);
    126163
    127164        task_id_t tid = task_get_id();
     
    149186        pcm_sample_format_t format;
    150187        const char *error;
    151         const int ret = wav_parse_header(&header, NULL, NULL, &channels, &rate,
     188        ret = wav_parse_header(&header, NULL, NULL, &channels, &rate,
    152189            &format, &error);
    153190        if (ret != EOK) {
Note: See TracChangeset for help on using the changeset viewer.