source: src/io/utils_apple_audio.c @ 927f630

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 927f630 was 1223979, checked in by Paul Brossier <piem@piem.org>, 12 years ago

src/io/sink_apple_audio.c: added apple_audio sink, merge apple stuff

  • Property mode set to 100644
File size: 1.3 KB
Line 
1#ifdef __APPLE__
2
3// CFURLRef, CFURLCreateWithFileSystemPath, ...
4#include <CoreFoundation/CoreFoundation.h>
5// ExtAudioFileRef, AudioStreamBasicDescription, AudioBufferList, ...
6#include <AudioToolbox/AudioToolbox.h>
7
8int createAubioBufferList(AudioBufferList *bufferList, int channels, int segmentSize);
9void freeAudioBufferList(AudioBufferList *bufferList);
10CFURLRef getURLFromPath(const char * path);
11
12int createAubioBufferList(AudioBufferList * bufferList, int channels, int segmentSize) {
13  bufferList->mNumberBuffers = 1;
14  bufferList->mBuffers[0].mNumberChannels = channels;
15  bufferList->mBuffers[0].mData = (short *)malloc(segmentSize * sizeof(short));
16  bufferList->mBuffers[0].mDataByteSize = segmentSize * sizeof(short);
17  return 0;
18}
19
20void freeAudioBufferList(AudioBufferList *bufferList) {
21  UInt32 i = 0;
22  if (!bufferList) return;
23  for (i = 0; i < bufferList->mNumberBuffers; i++) {
24    if (bufferList->mBuffers[i].mData) {
25      free (bufferList->mBuffers[i].mData);
26      bufferList->mBuffers[i].mData = NULL;
27    }
28  }
29  bufferList = NULL;
30}
31
32CFURLRef getURLFromPath(const char * path) {
33  CFStringRef cfTotalPath = CFStringCreateWithCString (kCFAllocatorDefault,
34      path, kCFStringEncodingUTF8);
35
36  return CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cfTotalPath,
37      kCFURLPOSIXPathStyle, false);
38}
39
40#endif /* __APPLE__ */
Note: See TracBrowser for help on using the repository browser.