chiark / gitweb /
Merge more Core Audio hackery from uaudio branch.
authorRichard Kettlewell <rjk@greenend.org.uk>
Sat, 28 Feb 2009 11:03:49 +0000 (11:03 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sat, 28 Feb 2009 11:03:49 +0000 (11:03 +0000)
configure.ac
lib/coreaudio.c
lib/coreaudio.h
server/speaker.c

index e0de22859dd7c9e3ce66d6a2d56c6f86c8313597..765123aafd708ec9ac238e4597591bc3eb075906 100644 (file)
@@ -91,7 +91,7 @@ case "$host" in
 *-apple-darwin* )
   AC_MSG_RESULT([Mac OS X])
   if test $want_coreaudio = yes; then
-    COREAUDIO="-framework CoreFoundation -framework CoreAudio"
+    COREAUDIO="-framework CoreFoundation -framework CoreServices -framework CoreAudio"
   fi
   browser=open
   AC_MSG_CHECKING([Mac OS X target version])
index c8732d558f3e23a70396cb2df2c8ba9088da8eb5..f6a8162995837b2a0e763df22b4538793268f16e 100644 (file)
 
 #include "coreaudio.h"
 #include "log.h"
+#include "printf.h"
 #include <CoreFoundation/CFString.h>
+/* evil bodge to work around broken header file */
+#undef error
+#include <CoreServices/CoreServices.h>
+#include <stdarg.h>
+
+/** @brief Report an error with an OSStatus */
+void coreaudio_fatal(OSStatus err, const char *fmt, ...) {
+  va_list ap;
+  char *msg;
+
+  va_start(ap, fmt);
+  byte_vasprintf(&msg, fmt, ap);
+  va_end(ap);
+
+  disorder_fatal(0, "%s: error %u", msg, (unsigned)err);
+}
 
 /** @brief Return the default device ID */
 static AudioDeviceID coreaudio_use_default(void) {
@@ -40,9 +57,9 @@ static AudioDeviceID coreaudio_use_default(void) {
   status = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
                                     &propertySize, &adid);
   if(status)
-    fatal(0, "AudioHardwareGetProperty kAudioHardwarePropertyDefaultOutputDevice: %d", (int)status);
+    coreaudio_fatal(status, "AudioHardwareGetProperty kAudioHardwarePropertyDefaultOutputDevice");
   if(adid == kAudioDeviceUnknown)
-    fatal(0, "no output device");
+    disorder_fatal(0, "no output device");
   return adid;
 }
 
@@ -70,7 +87,7 @@ static int coreaudio_find_device(AudioObjectPropertySelector selector,
                                     selector,
                                     &propertySize, &name);
     if(status)
-      fatal(0, "AudioDeviceGetProperty: %d", (int)status);
+      coreaudio_fatal(status, "AudioDeviceGetProperty");
 #if 0
     UInt8 output[1024];
     CFIndex used;
@@ -113,7 +130,7 @@ AudioDeviceID coreaudio_getdevice(const char *name) {
                                   name,
                                   kCFStringEncodingUTF8);
   if(!dev)
-    fatal(0, "CFStringCreateWithBytes failed");
+    disorder_fatal(0, "CFStringCreateWithBytes failed");
   /* Get a list of available devices */
   AudioDeviceID devs[1024];
   unsigned ndevs;
@@ -122,13 +139,12 @@ AudioDeviceID coreaudio_getdevice(const char *name) {
   status = AudioHardwareGetProperty(kAudioHardwarePropertyDevices,
                                     &propertySize, devs);
   if(status)
-    fatal(0, "AudioHardwareGetProperty kAudioHardwarePropertyDevices: %d",
-          (int)status);
+    coreaudio_fatal(status, "AudioHardwareGetProperty kAudioHardwarePropertyDevices");
   ndevs = propertySize / sizeof *devs;
   if(!ndevs)
-    fatal(0, "no sound devices found");
+    disorder_fatal(0, "no sound devices found");
   /* Try looking up by UID first */
-  found = coreaudio_find_device(kAudioDevicePropertyDeviceUID, //"UID",
+  found = coreaudio_find_device(-1*kAudioDevicePropertyDeviceUID, //"UID",
                                 devs, ndevs, dev, &adid);
   /* Failing that try looking up by name */
   if(!found)
@@ -136,7 +152,7 @@ AudioDeviceID coreaudio_getdevice(const char *name) {
                                   devs, ndevs, dev, &adid);
   CFRelease(dev);
   if(!found)
-    fatal(0, "cannot find device '%s'", name);
+    disorder_fatal(0, "cannot find device '%s'", name);
   return adid;
 }
 
index 6e620536b7ac64d49ec5bae19bf1e5cabf81a85f..dee24bbc748ac4992af2bf58ce204c802762ae1a 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <CoreAudio/AudioHardware.h>
 
+void coreaudio_fatal(OSStatus err, const char *fmt, ...);
 AudioDeviceID coreaudio_getdevice(const char *name);
 
 #endif /* COREAUDIO_H */
index 340e995a84c40e35779c934e3ee0b2fe99f6d6c5..6f8a5d9486f299e782c1658d5979171483a53a15 100644 (file)
@@ -33,7 +33,7 @@
  * this is arranged by the @c disorder-normalize program (see @ref
  * server/normalize.c).
  *
-7 * @b Garbage @b Collection.  This program deliberately does not use the
+ * @b Garbage @b Collection.  This program deliberately does not use the
  * garbage collector even though it might be convenient to do so.  This is for
  * two reasons.  Firstly some sound APIs use thread threads and we do not want
  * to have to deal with potential interactions between threading and garbage