From: Richard Kettlewell Date: Sat, 28 Feb 2009 11:03:49 +0000 (+0000) Subject: Merge more Core Audio hackery from uaudio branch. X-Git-Tag: 5.0~185 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/commitdiff_plain/cc06fc7e0dd17fa6d6aa34f3b59d786bb83ad7b8?hp=51cfd679239bb1b0581744b7b46a9311dfdbb0cf Merge more Core Audio hackery from uaudio branch. --- diff --git a/configure.ac b/configure.ac index e0de228..765123a 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) diff --git a/lib/coreaudio.c b/lib/coreaudio.c index c8732d5..f6a8162 100644 --- a/lib/coreaudio.c +++ b/lib/coreaudio.c @@ -25,7 +25,24 @@ #include "coreaudio.h" #include "log.h" +#include "printf.h" #include +/* evil bodge to work around broken header file */ +#undef error +#include +#include + +/** @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; } diff --git a/lib/coreaudio.h b/lib/coreaudio.h index 6e62053..dee24bb 100644 --- a/lib/coreaudio.h +++ b/lib/coreaudio.h @@ -24,6 +24,7 @@ #include +void coreaudio_fatal(OSStatus err, const char *fmt, ...); AudioDeviceID coreaudio_getdevice(const char *name); #endif /* COREAUDIO_H */ diff --git a/server/speaker.c b/server/speaker.c index 340e995..6f8a5d9 100644 --- a/server/speaker.c +++ b/server/speaker.c @@ -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