小编aka*_*aiz的帖子

如何使用音频单元 osx 从设备音频输入获取音频

我花了很长时间试图弄清楚如何使用音频单元从用户麦克风获取声音,以便我可以在音频单元录音回调中使用它,但我仍然堆栈。

- (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] …
Run Code Online (Sandbox Code Playgroud)

macos audiounit

1
推荐指数
1
解决办法
1639
查看次数

标签 统计

audiounit ×1

macos ×1