我花了很长时间试图弄清楚如何使用音频单元从用户麦克风获取声音,以便我可以在音频单元录音回调中使用它,但我仍然堆栈。
- (OSStatus) setupMicInput {
AudioObjectPropertyAddress addr;
UInt32 size = sizeof(AudioDeviceID);
AudioDeviceID deviceID = 0;
addr.mSelector = kAudioHardwarePropertyDefaultInputDevice;
addr.mScope = kAudioObjectPropertyScopeGlobal;
addr.mElement = kAudioObjectPropertyElementMaster;
OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, 0, NULL, &size, &deviceID);
checkStatus(err);
if (err == noErr) {
err = AudioUnitSetProperty(audioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceID, size);
}
checkStatus(err);
return err;
}
Run Code Online (Sandbox Code Playgroud)
我确实收到此错误
2018-05-08 10:07:29.454485+0300 OsxSocketSound[1414:20839] [AudioHAL_Client] AudioHardware.cpp:578:AudioObjectGetPropertyDataSize: AudioObjectGetPropertyDataSize: no object with given ID 0
2018-05-08 10:07:29.454517+0300 OsxSocketSound[1414:20839]
[AudioHAL_Client] AudioHardware.cpp:666:AudioObjectGetPropertyData: AudioObjectGetPropertyData: no object with given ID 0
2018-05-08 10:07:29.454715+0300 OsxSocketSound[1414:20839]
[AudioHAL_Client] AudioHardware.cpp:3446:AudioDeviceSetProperty: AudioDeviceSetProperty: no device with given ID
2018-05-08 10:07:29.454738+0300 OsxSocketSound[1414:20839] 1610: ca_verify_noerr: [AudioDeviceSetProperty(mDeviceID, NULL, 0, isInput, kAudioDevicePropertyIOProcStreamUsage, theSize, theStreamUsage), 560227702].
Run Code Online (Sandbox Code Playgroud)
我希望有人可以帮助我举一个音频单元和捕获麦克风输入的例子。谢谢
| 归档时间: |
|
| 查看次数: |
1639 次 |
| 最近记录: |