source: src/io/utils_apple_audio.c @ ddf04fd

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

src/io/source_apple_audio.c: simplify buffer creation, reset size on seek

  • Property mode set to 100644
File size: 1.4 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 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
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.