OSX AUGraph娱乐导致badComponentType错误

时间:2011-12-01 21:27:52

标签: c++ macos audio

在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);

“result”出现为-2005(badComponentType)。有人知道是什么原因造成的吗?

1 个答案:

答案 0 :(得分:0)

在关机中调用AUGraphClose修复此问题。猜猜你不能有两个具有相同输出单位的开放图吗?