AEUtilities.h
Go to the documentation of this file.
1 //
2 // AEUtilities.h
3 // TheAmazingAudioEngine
4 //
5 // Created by Michael Tyson on 23/03/2016.
6 // Copyright © 2016 A Tasty Pixel. All rights reserved.
7 //
8 // This software is provided 'as-is', without any express or implied
9 // warranty. In no event will the authors be held liable for any damages
10 // arising from the use of this software.
11 //
12 // Permission is granted to anyone to use this software for any purpose,
13 // including commercial applications, and to alter it and redistribute it
14 // freely, subject to the following restrictions:
15 //
16 // 1. The origin of this software must not be misrepresented; you must not
17 // claim that you wrote the original software. If you use this software
18 // in a product, an acknowledgment in the product documentation would be
19 // appreciated but is not required.
20 //
21 // 2. Altered source versions must be plainly marked as such, and must not be
22 // misrepresented as being the original software.
23 //
24 // 3. This notice may not be removed or altered from any source distribution.
25 //
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #import <Foundation/Foundation.h>
32 #import <AudioToolbox/AudioToolbox.h>
33 #import "AETypes.h"
34 
43 AudioComponentDescription AEAudioComponentDescriptionMake(OSType manufacturer, OSType type, OSType subtype);
44 
51 BOOL AERateLimit(void);
52 
58 void AEError(OSStatus result, const char * _Nonnull operation, const char * _Nonnull file, int line);
59 
66 #define AECheckOSStatus(result,operation) (_AECheckOSStatus((result),(operation),strrchr(__FILE__, '/')+1,__LINE__))
67 static inline BOOL _AECheckOSStatus(OSStatus result, const char * _Nonnull operation, const char * _Nonnull file, int line) {
68  if ( result != noErr ) {
69  AEError(result, operation, file, line);
70  return NO;
71  }
72  return YES;
73 }
74 
93 ExtAudioFileRef _Nullable AEExtAudioFileCreate(NSURL * _Nonnull url, AEAudioFileType fileType, double sampleRate,
94  int channelCount, NSError * _Nullable * _Nullable error);
95 
96 
113 ExtAudioFileRef _Nullable AEExtAudioFileOpen(NSURL * _Nonnull url, AudioStreamBasicDescription * _Nullable outAudioDescription,
114  UInt64 * _Nullable outLengthInFrames, NSError * _Nullable * _Nullable error);
115 
116 #ifdef __cplusplus
117 }
118 #endif