SwiftUI / Swift 中的 AudioQueueStart 错误 -66680 (kAudioQueueErr_InvalidDevice) 5.3
Error -66680 (kAudioQueueErr_InvalidDevice) from AudioQueueStart in SwiftUI / Swift 5.3
我正在尝试录制音频,例如来自 Macbook 的内置麦克风。这是我的代码:
func record() {
let sampleRate = 48000
let numChannels = 1
var inFormat = AudioStreamBasicDescription(mSampleRate: Double(sampleRate),
mFormatID: kAudioFormatLinearPCM,
mFormatFlags: kAudioFormatFlagsNativeFloatPacked,
mBytesPerPacket: UInt32(numChannels * MemoryLayout<UInt32>.size),
mFramesPerPacket: 1,
mBytesPerFrame: UInt32(numChannels * MemoryLayout<UInt32>.size),
mChannelsPerFrame: UInt32(numChannels),
mBitsPerChannel: UInt32(8 * MemoryLayout<UInt32>.size),
mReserved: UInt32(0))
var inAQ: AudioQueueRef? = nil;
var status = AudioQueueNewInput(&inFormat, callback, nil, nil, nil, 0, &inAQ)
print("AudioQueueNewInput returned " + status.description)
status = AudioQueueStart(inAQ!, nil)
print("AudioQueueStart returned " + status.description)
}
我从 this 的回答中获取了大部分内容。但是,我收到了一个不同的错误。输出是:
AudioQueueNewInput returned 0
2021-01-02 13:41:49.341243+0100 ocean[39484:6411401] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600002c79880> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2021-01-02 13:41:49.408830+0100 ocean[39484:6411401] HALC_ShellDriverPlugIn::Open: opening the plug-in failed, Error: 2003329396 (what)
2021-01-02 13:41:49.472141+0100 ocean[39484:6411401] [AQ] AudioQueueObject.cpp:1179:BuildConverter: AudioConverterNew returned -50
AudioQueueStart returned -50
OSStatus -50 表示参数错误。我的哪个参数不好?
编辑:我在系统首选项中设置了不同的音频输入。我切换到内部麦克风,现在收到不同的错误:
AudioQueueNewInput returned 0
2021-01-02 14:55:03.415688+0100 ocean[40044:6458085] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x6000035de820> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2021-01-02 14:55:03.482119+0100 ocean[40044:6458085] HALC_ShellDriverPlugIn::Open: opening the plug-in failed, Error: 2003329396 (what)
2021-01-02 14:55:03.483443+0100 ocean[40044:6458085] [aqme] AQMEIO.cpp:352:AQMEIOManager_FindIOUnit: error -66680 finding/initializing Device.AQDefaultInput
AudioQueueStart returned -66680
-66680 表示设备无效。关于为什么会这样的任何提示?我更新了标题,但我仍然想知道为什么其他音频输入拒绝这些参数。
通过在我的目标的签名和功能中启用“音频输入”解决了这个问题。它实际上解决了所有音频输入设备。
我正在尝试录制音频,例如来自 Macbook 的内置麦克风。这是我的代码:
func record() {
let sampleRate = 48000
let numChannels = 1
var inFormat = AudioStreamBasicDescription(mSampleRate: Double(sampleRate),
mFormatID: kAudioFormatLinearPCM,
mFormatFlags: kAudioFormatFlagsNativeFloatPacked,
mBytesPerPacket: UInt32(numChannels * MemoryLayout<UInt32>.size),
mFramesPerPacket: 1,
mBytesPerFrame: UInt32(numChannels * MemoryLayout<UInt32>.size),
mChannelsPerFrame: UInt32(numChannels),
mBitsPerChannel: UInt32(8 * MemoryLayout<UInt32>.size),
mReserved: UInt32(0))
var inAQ: AudioQueueRef? = nil;
var status = AudioQueueNewInput(&inFormat, callback, nil, nil, nil, 0, &inAQ)
print("AudioQueueNewInput returned " + status.description)
status = AudioQueueStart(inAQ!, nil)
print("AudioQueueStart returned " + status.description)
}
我从 this 的回答中获取了大部分内容。但是,我收到了一个不同的错误。输出是:
AudioQueueNewInput returned 0
2021-01-02 13:41:49.341243+0100 ocean[39484:6411401] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600002c79880> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2021-01-02 13:41:49.408830+0100 ocean[39484:6411401] HALC_ShellDriverPlugIn::Open: opening the plug-in failed, Error: 2003329396 (what)
2021-01-02 13:41:49.472141+0100 ocean[39484:6411401] [AQ] AudioQueueObject.cpp:1179:BuildConverter: AudioConverterNew returned -50
AudioQueueStart returned -50
OSStatus -50 表示参数错误。我的哪个参数不好?
编辑:我在系统首选项中设置了不同的音频输入。我切换到内部麦克风,现在收到不同的错误:
AudioQueueNewInput returned 0
2021-01-02 14:55:03.415688+0100 ocean[40044:6458085] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x6000035de820> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2021-01-02 14:55:03.482119+0100 ocean[40044:6458085] HALC_ShellDriverPlugIn::Open: opening the plug-in failed, Error: 2003329396 (what)
2021-01-02 14:55:03.483443+0100 ocean[40044:6458085] [aqme] AQMEIO.cpp:352:AQMEIOManager_FindIOUnit: error -66680 finding/initializing Device.AQDefaultInput
AudioQueueStart returned -66680
-66680 表示设备无效。关于为什么会这样的任何提示?我更新了标题,但我仍然想知道为什么其他音频输入拒绝这些参数。
通过在我的目标的签名和功能中启用“音频输入”解决了这个问题。它实际上解决了所有音频输入设备。