X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/087a9b2eaf10974c1b3025bf7d439c2371625e70..ba32e50c1894049659544cd2cbb0f7ab06981add:/clients/playrtp.c diff --git a/clients/playrtp.c b/clients/playrtp.c index 2ab6790..5956122 100644 --- a/clients/playrtp.c +++ b/clients/playrtp.c @@ -1,6 +1,6 @@ /* * This file is part of DisOrder. - * Copyright (C) 2007-2009 Richard Kettlewell + * Copyright (C) 2007-2009, 2011, 2013 Richard Kettlewell * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -207,6 +207,7 @@ static const struct option options[] = { #if HAVE_COREAUDIO_AUDIOHARDWARE_H { "core-audio", no_argument, 0, 'c' }, #endif + { "api", required_argument, 0, 'A' }, { "dump", required_argument, 0, 'r' }, { "command", required_argument, 0, 'e' }, { "pause-mode", required_argument, 0, 'P' }, @@ -492,15 +493,19 @@ static void help(void) { " --max, -x FRAMES Buffer maximum size\n" " --rcvbuf, -R BYTES Socket receive buffer size\n" " --config, -C PATH Set configuration file\n" -#if HAVE_ALSA_ASOUNDLIB_H - " --alsa, -a Use ALSA to play audio\n" -#endif -#if HAVE_SYS_SOUNDCARD_H || EMPEG_HOST - " --oss, -o Use OSS to play audio\n" -#endif -#if HAVE_COREAUDIO_AUDIOHARDWARE_H - " --core-audio, -c Use Core Audio to play audio\n" -#endif + " --api, -A API Select audio API. Possibilities:\n" + " "); + int first = 1; + for(int n = 0; uaudio_apis[n]; ++n) { + if(uaudio_apis[n]->flags & UAUDIO_API_CLIENT) { + if(first) + first = 0; + else + xprintf(", "); + xprintf("%s", uaudio_apis[n]->name); + } + } + xprintf("\n" " --command, -e COMMAND Pipe audio to command.\n" " --pause-mode, -P silence For -e: pauses send silence (default)\n" " --pause-mode, -P suspend For -e: pauses suspend writes\n" @@ -648,8 +653,7 @@ int main(int argc, char **argv) { logdate = 1; mem_init(); if(!setlocale(LC_CTYPE, "")) disorder_fatal(errno, "error calling setlocale"); - backend = uaudio_apis[0]; - while((n = getopt_long(argc, argv, "hVdD:m:x:L:R:aocC:re:P:M", options, 0)) >= 0) { + while((n = getopt_long(argc, argv, "hVdD:m:x:L:R:aocC:re:P:MA:", options, 0)) >= 0) { switch(n) { case 'h': help(); case 'V': version("disorder-playrtp"); @@ -660,14 +664,23 @@ int main(int argc, char **argv) { case 'L': logfp = fopen(optarg, "w"); break; case 'R': target_rcvbuf = atoi(optarg); break; #if HAVE_ALSA_ASOUNDLIB_H - case 'a': backend = &uaudio_alsa; break; + case 'a': + disorder_error(0, "deprecated option; use --api alsa instead"); + backend = &uaudio_alsa; break; #endif #if HAVE_SYS_SOUNDCARD_H || EMPEG_HOST - case 'o': backend = &uaudio_oss; break; + case 'o': + disorder_error(0, "deprecated option; use --api oss instead"); + backend = &uaudio_oss; + break; #endif #if HAVE_COREAUDIO_AUDIOHARDWARE_H - case 'c': backend = &uaudio_coreaudio; break; + case 'c': + disorder_error(0, "deprecated option; use --api coreaudio instead"); + backend = &uaudio_coreaudio; + break; #endif + case 'A': backend = uaudio_find(optarg); break; case 'C': configfile = optarg; break; case 's': control_socket = optarg; break; case 'r': dumpfile = optarg; break; @@ -678,6 +691,18 @@ int main(int argc, char **argv) { } } if(config_read(0, NULL)) disorder_fatal(0, "cannot read configuration"); + if(!backend) { + backend = uaudio_default(uaudio_apis, UAUDIO_API_CLIENT); + if(!backend) + disorder_fatal(0, "no default uaudio API found"); + disorder_info("default audio API %s", backend->name); + } + if(backend == &uaudio_rtp) { + /* This means that you have NO local sound output. This can happen if you + * use a non-Apple GCC on a Mac (because it doesn't know how to compile + * CoreAudio/AudioHardware.h). */ + disorder_fatal(0, "cannot play RTP through RTP"); + } if(!maxbuffer) maxbuffer = 2 * minbuffer; argc -= optind; @@ -702,6 +727,8 @@ int main(int argc, char **argv) { default: disorder_fatal(0, "usage: disorder-playrtp [OPTIONS] [[ADDRESS] PORT]"); } + disorder_info("version "VERSION" process ID %lu", + (unsigned long)getpid()); /* Look up address and port */ if(!(res = get_address(&sl, &prefs, &sockname))) exit(1);