Changeset 485281e in mainline for uspace/app/wavplay/main.c


Ignore:
Timestamp:
2018-12-18T18:38:49Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
336b739
Parents:
c65590a
Message:

Allow specifying non-default audio target

Needed when there is more than one audio device. It would be nice
complementary functionality if we could actually configure the
default audio target.

File:
1 edited

Legend:

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

    rc65590a r485281e  
    119119 * @return Error code
    120120 */
    121 static errno_t hplay(const char *filename)
     121static errno_t hplay(const char *filename, const char *target)
    122122{
    123123        printf("Hound playback: %s\n", filename);
     
    158158        }
    159159
    160         ret = hound_context_connect_target(hound, HOUND_DEFAULT_TARGET);
     160        ret = hound_context_connect_target(hound, target);
    161161        if (ret != EOK) {
    162                 printf("Failed to connect to default target: %s\n",
     162                printf("Failed to connect to target '%s': %s\n", target,
    163163                    str_error(ret));
     164
     165                char **names = NULL;
     166                size_t count = 0;
     167                ret = hound_context_get_available_targets(hound, &names, &count);
     168                if (ret == EOK) {
     169                        printf("Available targets:\n");
     170                        for (size_t i = 0; i < count; i++)
     171                                printf(" - %s\n", names[i]);
     172                }
     173
    164174                hound_context_destroy(hound);
    165175                fclose(source);
     
    215225        { "parallel", no_argument, 0, 'p' },
    216226        { "record", no_argument, 0, 'r' },
     227        { "target", required_argument, 0, 't' },
    217228        { "help", no_argument, 0, 'h' },
    218229        { 0, 0, 0, 0 }
     
    230241        printf("\t -r, --record\t Start recording instead of playback. "
    231242            "(Not implemented)\n");
    232         printf("\t -d, --device\t Use specified device instead of the sound "
    233             "service. Use location path or a special device `default'\n");
     243        printf("\t -d, --device\t Direct output to specified device instead of "
     244            "the sound service. Use location path or a special device `default'\n");
     245        printf("\t -t, --target\t Output to the specified audio target.\n");
    234246        printf("\t -p, --parallel\t Play given files in parallel instead of "
    235247            "sequentially (does not work with -d).\n");
     
    239251{
    240252        const char *device = "default";
     253        const char *target = HOUND_DEFAULT_TARGET;
    241254        int idx = 0;
    242255        bool direct = false, record = false, parallel = false;
     
    246259        /* Parse command line options */
    247260        while (ret != -1) {
    248                 ret = getopt_long(argc, argv, "d:prh", opts, &idx);
     261                ret = getopt_long(argc, argv, "d:prt:h", opts, &idx);
    249262                switch (ret) {
    250263                case 'd':
     
    257270                case 'p':
    258271                        parallel = true;
     272                        break;
     273                case 't':
     274                        target = optarg;
    259275                        break;
    260276                case 'h':
     
    334350                                fibril_add_ready(fid);
    335351                        } else {
    336                                 hplay(file);
     352                                hplay(file, target);
    337353                        }
    338354                }
Note: See TracChangeset for help on using the changeset viewer.