source: src/io/utils_apple_audio.c @ 19f222d

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

src/io/utils_apple_audio.c: use AUBIO_ARRAY / AUBIO_FREE

  • 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#include "aubio_priv.h"
8
9int createAubioBufferList(AudioBufferList *bufferList, int channels, int segmentSize);
10void freeAudioBufferList(AudioBufferList *bufferList);
11CFURLRef getURLFromPath(const char * path);
12
13int createAubioBufferList(AudioBufferList * bufferList, int channels, int segmentSize) {
14  bufferList->mNumberBuffers = 1;
15  bufferList->mBuffers[0].mNumberChannels = channels;
16  bufferList->mBuffers[0].mData = AUBIO_ARRAY(short, segmentSize);
17  bufferList->mBuffers[0].mDataByteSize = segmentSize * sizeof(short);
18  return 0;
19}
20
21void 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
33CFURLRef 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__ */
Note: See TracBrowser for help on using the repository browser.