我正在试图弄清楚如何从audiounit中获取频道映射信息,但即使在AudioUnitGetPropertyInfo中,我也遇到了错误-50(kAudio_ParamError)。
我正在使用Swift而我却无法正常工作。
有人必须处理此事的任何想法吗?
func CreateAUGraph(inout player: AUGraphPlayer) {
CheckError(NewAUGraph(&player.graph), operation: "Couldn't create new AuGraph...")
//output component description
var outputcd = AudioComponentDescription()
outputcd.componentType = kAudioUnitType_Output
outputcd.componentSubType = kAudioUnitSubType_DefaultOutput
outputcd.componentManufacturer = kAudioUnitManufacturer_Apple
var outputNode = AUNode()
CheckError(AUGraphAddNode(player.graph, &outputcd, &outputNode),
operation: "AUGraphAddNode[kAudioUnitSubType_DefaultOutput] failed")
AUGraphNodeInfo(player.graph, outputNode, nil, &player.outputAU)
var dataSize = UInt32()
CheckError(
AudioUnitGetPropertyInfo(player.outputAU, kAudioOutputUnitProperty_ChannelMap, kAudioUnitScope_Output, 0, &dataSize, nil)
, operation: "Cannot get size of ch map")
答案 0 :(得分:0)
AUGraph尚未打开,因此AudioUnitGetPropertyInfo无法连接到尚未存在的player.outputAU对象。
决议移动此
CheckError(AUGraphOpen(player.graph), operation: "AUGraphOpen failed")
之后
CheckError(NewAUGraph(&player.graph), operation: "Couldn't create new AuGraph...")