chiark / gitweb /
uaudio: more sophisticated choice of default playback API
[disorder] / clients / playrtp.c
index 2ab67906ba5ffff9ab44cee412bb397b7092a6fb..61cf6abcedc643027f2c7d1700a49e50c03b37c2 100644 (file)
@@ -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
@@ -648,7 +648,6 @@ 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) {
     switch(n) {
     case 'h': help();
@@ -678,6 +677,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 +713,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);