在OSX上,我正在为音频系统创建AUGraph,如下所示:
OSStatus result = NewAUGraph(&mGraph);
AUNode outputNode;
AudioComponentDescription outputDesc;
outputDesc.componentType = kAudioUnitType_Output;
outputDesc.componentSubType = kAudioUnitSubType_DefaultOutput;
outputDesc.componentManufacturer = kAudioUnitManufacturer_Apple;
outputDesc.componentFlags = 0;
outputDesc.componentFlagsMask = 0;
result = AUGraphAddNode(mGraph, &outputDesc, &outputNode);
AUNode converterNode;
AudioComponentDescription converterDesc;
converterDesc.componentType = kAudioUnitType_FormatConverter;
converterDesc.componentSubType = kAudioUnitSubType_AUConverter;
converterDesc.componentManufacturer = kAudioUnitManufacturer_Apple;
converterDesc.componentFlags = 0;
outputDesc.componentFlagsMask = 0;
result = AUGraphAddNode(mGraph, &converterDesc, &converterNode);
result = AUGraphConnectNodeInput(mGraph, converterNode, 0, outputNode, 0);
result = AUGraphOpen(mGraph);
...initialize graph, start graph, etc...
一切正常,我可以听到声音,等等。随后系统关闭:
unsigned char isRunning = false;
AUGraphIsRunning(mGraph, &isRunning);
if (isRunning)
AUGraphStop(mGraph);
OSStatus result;
unsigned char isInitialized = false;
AUGraphIsInitialized(mGraph, &isInitialized);
if (isInitialized)
{
result = AUGraphUninitialize(mGraph);
}
result = DisposeAUGraph(mGraph);
同样,这里没有问题。但是,在重新启动系统后的第一个代码块再次执行后不久。上:
result = AUGraphOpen(mGraph);
“结果”显示为-2005(badComponentType)。有人知道是什么原因造成的吗?
最佳答案
在关机中调用AUGraphClose可以解决此问题。猜猜您不能有两个具有相同输出单位的开放图吗?
关于c++ - OSX AUGraph重新创建导致badComponentType错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8348537/