我正在使用Apple音频队列服务指南示例。https://developer.apple.com/library/mac/documentation/MusicAudio/Conceptual/AudioQueueProgrammingGuide/AQRecord/RecordingAudio.html#//apple_ref/doc/uid/TP40005343-CH4-SW1 通过这个例子,我得到了几个看不见的错误
#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
const static int kNumberBuffers=3; //Sets the number of audio queue buffers to use
typedef struct AQRecorderState{
AudioStreamPacketDescription * mDataFormat; // An AudioStreamBasicDescription structure (from CoreAudioTypes.h) representing the audio data format to write to disk. This format gets used by the audio queue specified in the mQueue field.
AudioQueueRef mQueue; // The recording audio queue created by your application.
AudioQueueBufferRef mBuffers[kNumberBuffers]; //An array holding pointers to the audio queue buffers managed by the audio queue.
AudioFileID mAudioFile; // An audio file object representing the file into which your program records audio data.
UInt32 bufferByteSize; // The size, in bytes, for each audio queue buffer
SInt64 mCurrentPacket; // The packet index for the first packet to be written from the current audio queue buffer.
bool mIsRunning; // Indicates whether queue is running.
}AQRecorderState;
static void HandleInputBuffer(
void *AQData, // Typically, aqData is a custom structure that contains state data for the audio queue
AudioQueueRef inAQ, // The audio queue that owns this callback.
AudioQueueBufferRef inBuffer, //The audio queue buffer containing the incoming audio data to record.
const AudioTimeStamp *inStartTime, //The sample time of the first sample in the audio queue buffer (not needed for simple recording).
UInt32 inNumPackets, //The number of packet descriptions in the inPacketDesc parameter. A value of 0 indicates CBR data.
const AudioStreamPacketDescription *inPacketDesc // For compressed audio data formats that require packet descriptions, the packet descriptions produced by the encoder for the packets in the buffer.
){
AudioFileWritePackets(AQData->mAudioFile, // Member reference base type 'void' is not a structure or union
false,
inBuffer->mAudioDataByteSize,
inPacketDesc,
AQData->mCurrentPacket, // same here
&inNumPackets,
inBuffer->mAudioData);
};
构建失败,我不知道错误在哪里,因为它在文档中没有说明它。谢谢你的帮助
答案 0 :(得分:3)
您无法访问void *
上的字段,您必须先将其转换为特定类型。
大概:
((AQRecorderState *) AQData)->mAudioFile