views:

92

answers:

1

I'm developing an iPhone app that uses the Extended Audio File Services. I try to use ExtAudioFileRead to read the audio file, and store the data in an AudioBufferList structure.

AudioBufferList is defined as:

struct AudioBufferList {
UInt32      mNumberBuffers;
AudioBuffer mBuffers[1];
};
typedef struct AudioBufferList  AudioBufferList;

and AudioBuffer is defined as

struct AudioBuffer {
   UInt32  mNumberChannels;
   UInt32  mDataByteSize;
   void*   mData;
};
typedef struct AudioBuffer  AudioBuffer;

I want to manipulate the mData but I wonder what does the void* mean. Why is it void*? How can I decide what data type is actually stored in mData?

A: 

the mData field is marked as void because different audio formats have different storage requirements.

basically in C a void pointer can point to anything.

so you could say

mData = (SInt32 *)malloc(sizeof(Sint32) * numElements);

and then when you want to use it cast it to the data type you want.

Sint32 *myBuffer = (SInt32 *)mData;
Aran Mulholland