AudioUnit:mediaserverd 报告的错误 - “获取物理格式的客户端格式时出现错误”

AudioUnit: Error reported by mediaserverd - "Error 'what' getting client format for physical format"

提问人:evalsyrelec 提问时间:9/19/2015 更新时间:11/25/2015 访问量:783

问:

我有一个使用 AudioUnit 的 VOIP 应用程序。在 iOS 9 上,我看到一条错误消息,内容如下。我在iOS 8中没有看到这一点:

mediaserverd[43]:13:16:38.880 错误:[0x1f72d000] >va> 500:获取物理格式的客户端格式时出现错误“what” [ 16/44100/2;旗帜: 0xc;字节/数据包:4;帧/包:1; 字节/帧:4;]

有谁知道这意味着什么?音频似乎工作正常,但我仍然对它有点恼火,如果可以的话,我想解决它。我的 AudioUnit 设置代码如下。帮助感谢。谢谢。

CheckError(NewAUGraph(&audioState.graph), "NewAUGraph failed");

AUNode rioNode;    
AudioComponentDescription desc;

desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_VoiceProcessingIO;
desc.componentFlags = 0;        // Documentation states "Set this value to zero"
desc.componentFlagsMask = 0;    // Documentation states "Set this value to zero"
desc.componentManufacturer = kAudioUnitManufacturer_Apple;

CheckError(AUGraphAddNode(audioState.graph, &desc, &rioNode), "AUGraphAddNode failed for RIO");
CheckError(AUGraphOpen(audioState.graph),"Failed to open graph");
CheckError(AUGraphNodeInfo(audioState.graph, rioNode, NULL, &audioState.rio),"Failed to get rio node info");

UInt32 flag = 1;
CheckError(AudioUnitSetProperty(audioState.rio,
                                kAudioOutputUnitProperty_EnableIO,
                                kAudioUnitScope_Input,
                                1,
                                &flag,
                                sizeof(flag)), "Enable IO Failed");

AudioStreamBasicDescription audioFormat;
size_t bytesPerSample = sizeof(SInt16);
audioFormat.mSampleRate         = 8000;
audioFormat.mFormatID           = kAudioFormatLinearPCM;
audioFormat.mFormatFlags        = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
audioFormat.mFramesPerPacket    = 1;
audioFormat.mChannelsPerFrame   = 1;
audioFormat.mBitsPerChannel     = 8 * (UInt32)bytesPerSample;
audioFormat.mBytesPerPacket     = (UInt32)bytesPerSample;
audioFormat.mBytesPerFrame      = (UInt32)bytesPerSample;

CheckError(AudioUnitSetProperty(audioState.rio,
                                kAudioUnitProperty_StreamFormat,
                                kAudioUnitScope_Output,
                                INPUT_BUS,
                                &audioFormat,
                                sizeof(audioFormat)), "Could not set RIO input stream format");

CheckError(AudioUnitSetProperty(audioState.rio,
                                kAudioUnitProperty_StreamFormat,
                                kAudioUnitScope_Input,
                                OUTPUT_BUS,
                                &audioFormat,
                                sizeof(audioFormat)), "Could not set RIO output stream format");


AURenderCallbackStruct callbackStruct;

// Set input callback
callbackStruct.inputProc = &recordingCallback;
callbackStruct.inputProcRefCon = &audioState;
CheckError(AudioUnitSetProperty(audioState.rio,
                                kAudioOutputUnitProperty_SetInputCallback,
                                kAudioUnitScope_Global,
                                INPUT_BUS,
                                &callbackStruct,
                                sizeof(callbackStruct)), "Could not set callback for recording");

// Set output callback
callbackStruct.inputProc = &playbackCallback;
callbackStruct.inputProcRefCon = &audioState;
CheckError(AudioUnitSetProperty(audioState.rio,
                                kAudioUnitProperty_SetRenderCallback,
                                kAudioUnitScope_Global,
                                OUTPUT_BUS,
                                &callbackStruct,
                                sizeof(callbackStruct)), "Could not set callback for playback");
iOS iOS9 音频单元

评论

0赞 rocky 11/25/2015
从错误来看,它似乎试图使用 44.1 kHz 作为采样率,但您在音频格式中将其设置为 8 kHz。也许尝试将其设置为 44100.0?
0赞 sahara108 1/12/2016
我也收到同样的错误。你有什么线索吗?

答: 暂无答案