Slide 42
Slide 42 text
NewAUGraph(&audioGraph); // 建立 audio grapg
AudioComponentDescription cdesc;
bzero(&cdesc, sizeof(AudioComponentDescription));
cdesc.componentType = kAudioUnitType_Output;
cdesc.componentSubType = kAudioUnitSubType_DefaultOutput;
cdesc.componentManufacturer = kAudioUnitManufacturer_Apple;
cdesc.componentFlags = 0;
cdesc.componentFlagsMask = 0;
AUGraphAddNode(audioGraph, &cdesc, &outputNode); // 建立 output node
AUGraphOpen(audioGraph);
AUGraphNodeInfo(audioGraph, outputNode, &cdesc, &outputUnit); // 建立 output unit
AudioStreamBasicDescription destFormat = LFPCMStreamDescription(); // 設定輸出格式
AudioUnitSetProperty(outputUnit, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input, 0, &destFormat, sizeof(destFormat));
AURenderCallbackStruct callbackStruct;
callbackStruct.inputProc = ZBPlayerAURenderCallback;
callbackStruct.inputProcRefCon = self;
AudioUnitSetProperty(outputUnit, kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input, 0, &callbackStruct, sizeof(callbackStruct)); // 建立 render
callback
AUGraphInitialize(audioGraph); // Init audio graph
CAShow(audioGraph); // 開始 audio graph
Thursday, August 15,