[1223979] | 1 | #ifdef __APPLE__ |
---|
| 2 | |
---|
| 3 | // CFURLRef, CFURLCreateWithFileSystemPath, ... |
---|
| 4 | #include <CoreFoundation/CoreFoundation.h> |
---|
| 5 | // ExtAudioFileRef, AudioStreamBasicDescription, AudioBufferList, ... |
---|
| 6 | #include <AudioToolbox/AudioToolbox.h> |
---|
[19f222d] | 7 | #include "aubio_priv.h" |
---|
[1223979] | 8 | |
---|
| 9 | int createAubioBufferList(AudioBufferList *bufferList, int channels, int segmentSize); |
---|
| 10 | void freeAudioBufferList(AudioBufferList *bufferList); |
---|
| 11 | CFURLRef getURLFromPath(const char * path); |
---|
| 12 | |
---|
[c833f56] | 13 | int createAubioBufferList(AudioBufferList * bufferList, int channels, int max_source_samples) { |
---|
[1223979] | 14 | bufferList->mNumberBuffers = 1; |
---|
| 15 | bufferList->mBuffers[0].mNumberChannels = channels; |
---|
[c833f56] | 16 | bufferList->mBuffers[0].mData = AUBIO_ARRAY(short, max_source_samples); |
---|
| 17 | bufferList->mBuffers[0].mDataByteSize = max_source_samples * sizeof(short); |
---|
[1223979] | 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) { |
---|
[19f222d] | 26 | AUBIO_FREE(bufferList->mBuffers[i].mData); |
---|
[1223979] | 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__ */ |
---|