diff -r 000000000000 -r 06e7d03fd23e AudioUtils.mm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AudioUtils.mm Tue Jun 24 12:05:24 2008 -0700 @@ -0,0 +1,44 @@ +// +// AudioUtils.mm +// Cloudy +// +// Created by Jens Alfke on 6/17/08. +// Copyright 2008 Jens Alfke. All rights reserved. +// + +#import "AudioUtils.h" + + +NSString* MYCAErrorString( OSStatus coreAudioError ) +{ + if( coreAudioError >= 0x20202020 ) + return NSFileTypeForHFSTypeCode(coreAudioError); + else + return [NSString stringWithFormat: @"%i",coreAudioError]; +} + +NSError* MYCAError( OSStatus coreAudioError, NSString *message ) +{ + NSString *errStr = $sprintf(@"CoreAudio error %@", MYCAErrorString(coreAudioError)); + if( message ) + message = [message stringByAppendingFormat: @" [%@]", errStr]; + else + message = errStr; + NSString *domain = (coreAudioError >= 0x20202020) ?MYCoreAudioErrorDomain :NSOSStatusErrorDomain; + return [NSError errorWithDomain: domain code: coreAudioError + userInfo: $dict({NSLocalizedDescriptionKey, message})]; +} + + +void _MYThrowCAError( OSStatus err, NSString *operation ) throw(NSError*) +{ + NSError *error = MYCAError(err, $sprintf(@"Error in %@", operation)); + Warn(@"EXCEPTION: %@",error.localizedDescription); + throw error; +} + +void _MYWarnCAError( OSStatus err, NSString *operation ) +{ + NSError *error = MYCAError(err, $sprintf(@"Error in %@", operation)); + Warn(@"%@",error.localizedDescription); +}