@@ -118,7 +118,7 @@ static errno_t hplay_ctx(hound_context_t *ctx, const char *filename)
118
118
* @param filename File to play.
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 );
124
124
FILE * source = fopen (filename , "rb" );
@@ -157,10 +157,20 @@ static errno_t hplay(const char *filename)
157
157
return ENOMEM ;
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 );
166
176
return ret ;
@@ -214,6 +224,7 @@ static const struct option opts[] = {
214
224
{ "device" , required_argument , 0 , 'd' },
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 }
219
230
};
@@ -229,23 +240,25 @@ static void print_help(const char *name)
229
240
printf ("\t -h, --help\t Print this help.\n" );
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" );
236
248
}
237
249
238
250
int main (int argc , char * argv [])
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;
243
256
optind = 0 ;
244
257
int ret = 0 ;
245
258
246
259
/* Parse command line options */
247
260
while (ret != -1 ) {
248
- ret = getopt_long (argc , argv , "d:prh " , opts , & idx );
261
+ ret = getopt_long (argc , argv , "d:prt:h " , opts , & idx );
249
262
switch (ret ) {
250
263
case 'd' :
251
264
direct = true;
@@ -257,6 +270,9 @@ int main(int argc, char *argv[])
257
270
case 'p' :
258
271
parallel = true;
259
272
break ;
273
+ case 't' :
274
+ target = optarg ;
275
+ break ;
260
276
case 'h' :
261
277
print_help (* argv );
262
278
return 0 ;
@@ -333,7 +349,7 @@ int main(int argc, char *argv[])
333
349
atomic_fetch_add (& playcount , 1 );
334
350
fibril_add_ready (fid );
335
351
} else {
336
- hplay (file );
352
+ hplay (file , target );
337
353
}
338
354
}
339
355
}
0 commit comments