source: src/io/utils_apple_audio.c @ c19f9e5

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

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

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[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
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;
[19f222d]16  bufferList->mBuffers[0].mData = AUBIO_ARRAY(short, segmentSize);
[1223979]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) {
[19f222d]26      AUBIO_FREE(bufferList->mBuffers[i].mData);
[1223979]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.