diff options
author | Max Kellermann <max@duempel.org> | 2009-02-26 22:01:42 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-02-26 22:01:42 +0100 |
commit | 353ae5e558c2dbdc7f9e148a14d8ffa0431e88de (patch) | |
tree | f3663fd6045ea1a82ee5dc6633199a727f9746fe /src | |
parent | 9dc966041d9a3bba82a9e9f72db6fe261ac82195 (diff) | |
download | mpd-353ae5e558c2dbdc7f9e148a14d8ffa0431e88de.tar.gz mpd-353ae5e558c2dbdc7f9e148a14d8ffa0431e88de.tar.xz mpd-353ae5e558c2dbdc7f9e148a14d8ffa0431e88de.zip |
osx: use OSStatus and GetMacOSStatusCommentString()
The return type of most OS X functions is OSStatus, not int. We can
get a nice error message from GetMacOSStatusCommentString(), log it.
Diffstat (limited to 'src')
-rw-r--r-- | src/output/osx_plugin.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/output/osx_plugin.c b/src/output/osx_plugin.c index 18a88ddce..fc3025ca1 100644 --- a/src/output/osx_plugin.c +++ b/src/output/osx_plugin.c @@ -150,7 +150,8 @@ osx_output_open(void *data, struct audio_format *audio_format) Component comp; AURenderCallbackStruct callback; AudioStreamBasicDescription stream_description; - int err; + OSStatus status; + ComponentResult result; if (audio_format->bits > 16) audio_format->bits = 16; @@ -167,23 +168,29 @@ osx_output_open(void *data, struct audio_format *audio_format) return false; } - if (OpenAComponent(comp, &od->au) != noErr) { - g_warning("Unable to open OS X component\n"); + status = OpenAComponent(comp, &od->au); + if (status != noErr) { + g_warning("Unable to open OS X component: %s", + GetMacOSStatusCommentString(status)); return false; } - if (AudioUnitInitialize(od->au) != 0) { + status = AudioUnitInitialize(od->au); + if (status != noErr) { CloseComponent(od->au); - g_warning("Unable to initialize OS X audio unit\n"); + g_warning("Unable to initialize OS X audio unit: %s", + GetMacOSStatusCommentString(status)); return false; } callback.inputProc = osx_render; callback.inputProcRefCon = od; - if (AudioUnitSetProperty(od->au, kAudioUnitProperty_SetRenderCallback, - kAudioUnitScope_Input, 0, - &callback, sizeof(callback)) != 0) { + result = AudioUnitSetProperty(od->au, + kAudioUnitProperty_SetRenderCallback, + kAudioUnitScope_Input, 0, + &callback, sizeof(callback)); + if (result != noErr) { AudioUnitUninitialize(od->au); CloseComponent(od->au); g_warning("unable to set callback for OS X audio unit\n"); @@ -204,10 +211,11 @@ osx_output_open(void *data, struct audio_format *audio_format) stream_description.mChannelsPerFrame = audio_format->channels; stream_description.mBitsPerChannel = audio_format->bits; - if (AudioUnitSetProperty(od->au, kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Input, 0, - &stream_description, - sizeof(stream_description)) != 0) { + result = AudioUnitSetProperty(od->au, kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Input, 0, + &stream_description, + sizeof(stream_description)); + if (result != noErr) { AudioUnitUninitialize(od->au); CloseComponent(od->au); g_warning("Unable to set format on OS X device\n"); @@ -222,9 +230,10 @@ osx_output_open(void *data, struct audio_format *audio_format) od->pos = 0; od->len = 0; - err = AudioOutputUnitStart(od->au); - if (err != 0) { - g_warning("unable to start audio output: %i", err); + status = AudioOutputUnitStart(od->au); + if (status != 0) { + g_warning("unable to start audio output: %s", + GetMacOSStatusCommentString(status)); return false; } |