rnine / SimplyCoreAudio

🔊 A Swift framework that aims to make Core Audio use less tedious in macOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error while trying to get input devices

jupmoreno opened this issue · comments

Hi, I'm new to swift and macOS development but I'm trying to make an app that mutes every microphone in my computer and I think your library it's going to help a lot.

The code is the following:

var mute Bool
...
for audioDevice in AMCoreAudio.AudioDevice.allInputDevices() {
    if audioDevice.canMute(channel: kAudioObjectPropertyElementMaster, direction: .recording) {
        audioDevice.setMute(mute, channel: kAudioObjectPropertyElementMaster, direction: .recording)
    } else if audioDevice.canSetVolume(channel: kAudioObjectPropertyElementMaster, direction: .recording) {
        audioDevice.setVolume(mute ? 0.0 : 1.0, channel: kAudioObjectPropertyElementMaster, direction: .recording)
    } else {
        print("can't mute device") // TODO
    }
}

But when the code is executed, I get the following error:

2020-07-03 12:43:45.651132-0300 MC[24538:2666945] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x60000024ebc0> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2020-07-03 12:43:45.695838-0300 MC[24538:2666945]  HALC_ShellDriverPlugIn::Open: Can't get a pointer to the Open routine

I believe it's an error while using SwiftUI.

Can you help me?

Thanks!

commented

@jpmrno I believe these are CoreAudio notice messages and can be safely ignored. Are you finding any issues while using AMCoreAudio mute/volume functions?

@jpmrno I believe these are CoreAudio notice messages and can be safely ignored. Are you finding any issues while using AMCoreAudio mute/volume functions?

I'm getting an empty array from AMCoreAudio.AudioDevice.allInputDevices(). Am I doing something wrong?

I'm getting every device with channels(direction: .recording) == 0.

I was missing the mic entitlement. Sorry for the trouble and thanks for the response!

commented

I was missing the mic entitlement.

@jpmrno Ah yes, that's necessary in order to query input devices when app sandbox is enabled.

Sorry for the trouble and thanks for the response!

Glad you got it sorted out 👍