chiark / gitweb /
(Slightly scrappy) new playlist box
[disorder] / lib / uaudio-apis.c
index b864aa05834bed6c487fcf9d74a8d1a1a6b3618d..568ae36ce8a22b4d22df1100ff264c6dedc127e2 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "common.h"
 #include "uaudio.h"
+#include "log.h"
 
 /** @brief List of known APIs
  *
@@ -30,7 +31,7 @@
  * The first one will be used as a default, so putting ALSA before OSS
  * constitutes a policy decision.
  */
-const struct uaudio *const  uaudio_apis[] = {
+const struct uaudio *const uaudio_apis[] = {
 #if HAVE_COREAUDIO_AUDIOHARDWARE_H
   &uaudio_coreaudio,
 #endif  
@@ -45,6 +46,18 @@ const struct uaudio *const  uaudio_apis[] = {
   NULL,
 };
 
+/** @brief Look up an audio API by name */
+const struct uaudio *uaudio_find(const char *name) {
+  int n;
+
+  for(n = 0; uaudio_apis[n]; ++n)
+    if(!strcmp(uaudio_apis[n]->name, name))
+      return uaudio_apis[n];
+  if(!strcmp(name, "network"))
+    return &uaudio_rtp;
+  disorder_fatal(0, "cannot find audio API '%s'", name);
+}
+
 /*
 Local Variables:
 c-basic-offset:2