【问题标题】:How to get audio from device audio input using audio unit osx如何使用音频单元 osx 从设备音频输入中获取音频
【发布时间】:2018-05-08 07:34:48
【问题描述】:

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

- (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;
}

我确实收到了这个错误

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].

我希望有人可以帮助我提供音频单元和捕获麦克风输入的示例。谢谢

【问题讨论】:

    标签: macos audiounit


    【解决方案1】:

    看来,您的应用权利设置不正确。在功能选项卡下,您应该检查麦克风。请检查一次。

    【讨论】:

    • 感谢@Satya,选择麦克风解决了这个错误。我现在将其标记为解决方案。
    猜你喜欢
    • 1970-01-01
    • 2013-02-09
    • 2021-09-03
    • 1970-01-01
    • 2011-03-13
    • 2013-11-17
    • 2018-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多