1 | #ifdef __APPLE__ |
---|
2 | |
---|
3 | // CFURLRef, CFURLCreateWithFileSystemPath, ... |
---|
4 | #include <CoreFoundation/CoreFoundation.h> |
---|
5 | // ExtAudioFileRef, AudioStreamBasicDescription, AudioBufferList, ... |
---|
6 | #include <AudioToolbox/AudioToolbox.h> |
---|
7 | #include "aubio_priv.h" |
---|
8 | |
---|
9 | int createAubioBufferList(AudioBufferList *bufferList, int channels, int segmentSize); |
---|
10 | void freeAudioBufferList(AudioBufferList *bufferList); |
---|
11 | CFURLRef getURLFromPath(const char * path); |
---|
12 | |
---|
13 | int createAubioBufferList(AudioBufferList * bufferList, int channels, int max_source_samples) { |
---|
14 | bufferList->mNumberBuffers = 1; |
---|
15 | bufferList->mBuffers[0].mNumberChannels = channels; |
---|
16 | bufferList->mBuffers[0].mData = AUBIO_ARRAY(short, max_source_samples); |
---|
17 | bufferList->mBuffers[0].mDataByteSize = max_source_samples * sizeof(short); |
---|
18 | return 0; |
---|
19 | } |
---|
20 | |
---|
21 | void freeAudioBufferList(AudioBufferList *bufferList) { |
---|
22 | UInt32 i = 0; |
---|
23 | if (!bufferList) return; |
---|
24 | for (i = 0; i < bufferList->mNumberBuffers; i++) { |
---|
25 | if (bufferList->mBuffers[i].mData) { |
---|
26 | AUBIO_FREE(bufferList->mBuffers[i].mData); |
---|
27 | bufferList->mBuffers[i].mData = NULL; |
---|
28 | } |
---|
29 | } |
---|
30 | bufferList = NULL; |
---|
31 | } |
---|
32 | |
---|
33 | CFURLRef getURLFromPath(const char * path) { |
---|
34 | CFStringRef cfTotalPath = CFStringCreateWithCString (kCFAllocatorDefault, |
---|
35 | path, kCFStringEncodingUTF8); |
---|
36 | |
---|
37 | return CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cfTotalPath, |
---|
38 | kCFURLPOSIXPathStyle, false); |
---|
39 | } |
---|
40 | |
---|
41 | #endif /* __APPLE__ */ |
---|