Changeset 485281e in mainline
- Timestamp:
- 2018-12-18T18:38:49Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 336b739
- Parents:
- c65590a
- Location:
- uspace/app
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/modplay/modplay.c
rc65590a r485281e 39 39 #include <stdio.h> 40 40 #include <stdlib.h> 41 #include <str.h> 41 42 #include <str_error.h> 42 43 #include <trackmod.h> … … 67 68 } 68 69 70 static void print_syntax(void) 71 { 72 printf("syntax: modplay [<options>] <filename.mod>\n"); 73 printf("options:\n"); 74 printf("\t-t <target>\tOutput to specified audio target.\n"); 75 } 76 69 77 int main(int argc, char *argv[]) 70 78 { … … 78 86 void *buffer; 79 87 size_t buffer_size; 88 const char *target = HOUND_DEFAULT_TARGET; 80 89 errno_t rc; 81 90 82 if (argc != 2) { 83 printf("syntax: modplay <filename.mod>\n"); 91 ++argv; 92 --argc; 93 94 while (argc > 0 && (*argv)[0] == '-') { 95 if (str_cmp(*argv, "-t") == 0) { 96 ++argv; 97 --argc; 98 99 if (argc < 1) { 100 printf("Option '-t' requires an argument.\n"); 101 print_syntax(); 102 return 1; 103 } 104 105 target = *argv++; 106 --argc; 107 continue; 108 } 109 110 printf("Invalid option '%s'\n", *argv); 111 print_syntax(); 112 return 1; 113 } 114 115 if (argc != 1) { 116 print_syntax(); 84 117 return 1; 85 118 } … … 87 120 con = console_init(stdin, stdout); 88 121 89 rc = trackmod_module_load(argv[ 1], &mod);122 rc = trackmod_module_load(argv[0], &mod); 90 123 if (rc != EOK) { 91 printf("Error loading %s.\n", argv[ 1]);124 printf("Error loading %s.\n", argv[0]); 92 125 return 1; 93 126 } … … 114 147 } 115 148 116 rc = hound_context_connect_target(hound, HOUND_DEFAULT_TARGET);149 rc = hound_context_connect_target(hound, target); 117 150 if (rc != EOK) { 118 printf("Error connecting default audio target: %s.\n", str_error(rc)); 151 printf("Error connecting audio target '%s': %s.\n", 152 target, str_error(rc)); 153 154 char **names = NULL; 155 size_t count = 0; 156 rc = hound_context_get_available_targets(hound, &names, &count); 157 if (rc == EOK) { 158 printf("Available targets:\n"); 159 for (size_t i = 0; i < count; i++) 160 printf(" - %s\n", names[i]); 161 } 162 119 163 return 1; 120 164 } -
uspace/app/wavplay/main.c
rc65590a r485281e 119 119 * @return Error code 120 120 */ 121 static errno_t hplay(const char *filename )121 static errno_t hplay(const char *filename, const char *target) 122 122 { 123 123 printf("Hound playback: %s\n", filename); … … 158 158 } 159 159 160 ret = hound_context_connect_target(hound, HOUND_DEFAULT_TARGET);160 ret = hound_context_connect_target(hound, target); 161 161 if (ret != EOK) { 162 printf("Failed to connect to default target: %s\n",162 printf("Failed to connect to target '%s': %s\n", target, 163 163 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 164 174 hound_context_destroy(hound); 165 175 fclose(source); … … 215 225 { "parallel", no_argument, 0, 'p' }, 216 226 { "record", no_argument, 0, 'r' }, 227 { "target", required_argument, 0, 't' }, 217 228 { "help", no_argument, 0, 'h' }, 218 229 { 0, 0, 0, 0 } … … 230 241 printf("\t -r, --record\t Start recording instead of playback. " 231 242 "(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"); 234 246 printf("\t -p, --parallel\t Play given files in parallel instead of " 235 247 "sequentially (does not work with -d).\n"); … … 239 251 { 240 252 const char *device = "default"; 253 const char *target = HOUND_DEFAULT_TARGET; 241 254 int idx = 0; 242 255 bool direct = false, record = false, parallel = false; … … 246 259 /* Parse command line options */ 247 260 while (ret != -1) { 248 ret = getopt_long(argc, argv, "d:pr h", opts, &idx);261 ret = getopt_long(argc, argv, "d:prt:h", opts, &idx); 249 262 switch (ret) { 250 263 case 'd': … … 257 270 case 'p': 258 271 parallel = true; 272 break; 273 case 't': 274 target = optarg; 259 275 break; 260 276 case 'h': … … 334 350 fibril_add_ready(fid); 335 351 } else { 336 hplay(file );352 hplay(file, target); 337 353 } 338 354 }
Note:
See TracChangeset
for help on using the changeset viewer.