Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microphone access not working #3299

Closed
conath opened this issue Nov 8, 2021 · 10 comments
Closed

Microphone access not working #3299

conath opened this issue Nov 8, 2021 · 10 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists macOS macOS issues spice Spice/CocoaSpice related

Comments

@conath
Copy link
Contributor

conath commented Nov 8, 2021

VMs can't access my Mac's microphone even though the device "Intel HD Audio Controller" is selected and the -device hda-duplex is present in the Debug Log. Tested with two q35 guests and one virt guest.

  • UTM Version: 2.4.1
  • OS Version: macOS 12.1 beta
  • Apple Silicon

Debug log

Debug Log running Windows 11 ARM guest
Running:  -L /Applications/UTM/UTM.app/Contents/Resources/qemu -S -qmp tcp:127.0.0.1:4000,server,nowait -nodefaults -vga none -spice "unix=on,addr=/Users/chris/Library/Group Containers/WDNLXAD4W8.com.utmapp.UTM/305C84D7-49E8-4CDB-8CA4-AE5DBFECB0CA.spice,disable-ticketing=on,image-compression=off,playback-compression=off,streaming-video=off,gl=off" -device virtio-gpu-pci -cpu host -smp cpus=4,sockets=1,cores=4,threads=1 -machine virt,highmem=off,virtualization=on -accel hvf -accel tcg,thread=multi,tb-size=1024 -drive if=pflash,format=raw,unit=0,file=/Applications/UTM/UTM.app/Contents/Resources/qemu/edk2-aarch64-code.fd,readonly=on -drive "if=pflash,format=raw,unit=1,file=/Users/chris/Library/Containers/com.utmapp.UTM/Data/Documents/Windows 11 for ARM.utm/Images/efi_vars.fd" -boot menu=on -m 4096 -device ich9-intel-hda -device hda-duplex -name "Windows 11 for ARM" -device qemu-xhci,id=usb-bus -device usb-tablet,bus=usb-bus.0 -device usb-mouse,bus=usb-bus.0 -device usb-kbd,bus=usb-bus.0 -device qemu-xhci,id=usb-controller-0 -chardev spicevmc,name=usbredir,id=usbredirchardev0 -device usb-redir,chardev=usbredirchardev0,id=usbredirdev0,bus=usb-controller-0.0 -device usb-storage,drive=drive0,removable=true,bootindex=0,bus=usb-bus.0 -drive if=none,media=cdrom,id=drive0 -device virtio-blk-pci,drive=B14E51A9-C646-41F9-A26B-1D73232DDC66,bootindex=1 -drive "if=none,media=disk,id=B14E51A9-C646-41F9-A26B-1D73232DDC66,file=/Users/chris/Library/Containers/com.utmapp.UTM/Data/Documents/Windows 11 for ARM.utm/Images/driveC128GB.qcow2,cache=writethrough" -device virtio-net-pci,mac=8E:43:36:8C:30:B5,netdev=net0 -netdev vmnet-macos,mode=bridged,id=net0 -device virtio-serial -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 -chardev spicevmc,id=vdagent,debug=0,name=vdagent -uuid 305C84D7-49E8-4CDB-8CA4-AE5DBFECB0CA -rtc base=localtime
qemu-aarch64-softmmu: -netdev vmnet-macos,mode=bridged,id=net0: info: Started vmnet interface with configuration:
qemu-aarch64-softmmu: -netdev vmnet-macos,mode=bridged,id=net0: info: MTU:              1500
qemu-aarch64-softmmu: -netdev vmnet-macos,mode=bridged,id=net0: info: Max packet size:  1514
qemu-aarch64-softmmu: -netdev vmnet-macos,mode=bridged,id=net0: info: MAC:              36:c5:9f:c9:58:59
qemu-aarch64-softmmu: -netdev vmnet-macos,mode=bridged,id=net0: info: UUID:             45436D6D-E029-460B-9263-26DA3F2FB18D
qemu-aarch64-softmmu: warning: Spice: playback:0 (0x1388c5920): setsockopt failed, Operation not supported on socket
qemu-aarch64-softmmu: warning: Spice: record:0 (0x1388c59d0): setsockopt failed, Operation not supported on socket

VM config: config.plist.zip

@conath conath added bug Something isn't working spice Spice/CocoaSpice related macOS macOS issues labels Nov 8, 2021
@conath
Copy link
Contributor Author

conath commented Nov 8, 2021

Also tested with AC97 device, same result: guest sees a microphone but recordings contain silence, and the macOS microphone access prompt does not appear (even though UTM does not have microphone permission according to System Preferences).

@k4vld
Copy link

k4vld commented Dec 7, 2021

Hi, I have come across the same issue, is there any way to override it?
UTM hasn't requested mic access in the host system
The thing is my only reason to deal with virtualization is one voice recognition application for windows...
Big Sur M1 Air 2020 host
Win 11 guest

@SamHep0803
Copy link

It would be gladly appreciated if someone could look into this issue, there seems to be some sort of microphone being detected in my W11 VM (shows up as "Line In") however UTM hasn't actually requested microphone usage or anything like that. Thanks in advance!

@conath
Copy link
Contributor Author

conath commented Dec 25, 2021

I did a brief check: are we only missing the permissions prompt? To test this, I added these lines to UTMData.swift save(vm: UTMVirtualMachine):

    func save(vm: UTMVirtualMachine) throws {
        do {
            #if os(macOS)
            if vm.configuration.soundCard?.contains("hda") ?? false {
                /// get mic permisison
                AVCaptureDevice.requestAccess(for: .audio) { access in
                    print(access)
                }
            }
            #endif

To run this successfully, in the Info.plist for the Mac target you need to enable "Audio Input" in the "Hardened Runtime" and add a "NSMicrophoneUsageDescription" key with a string value. Then the next time a HDA-soundcard VM is saved, the microphone popup appears, and clicking Allow results in true printed. So far, so good.

However there is still no sound recorded in the running VM, I assume that no AVCaptureSession is started. So this is a topic that needs further research and development.

@conath conath linked a pull request Dec 25, 2021 that will close this issue
@vlad-a-c
Copy link

vlad-a-c commented Jan 9, 2022

i'm running utm 3.0.1 and i'm still not getting even the prompt to allow access. that's so weird though.

@conath
Copy link
Contributor Author

conath commented Jan 10, 2022

@vlad-a-c My current understanding is that mic access is not a feature of the macOS app yet, and is not working as intended on iOS.

@marrem
Copy link

marrem commented May 17, 2022

I experience the same issue. I have also tried with 'bare' qemu but I could get sound out off the vm but not into it. I would like to be able to choose in the vm the inputs that I see on my Mac. I have installed Rogue Amoeba's Loopback. I see the virtual input in my Mac's audio inputs.

image

Would be nice if I could see the same selection of inputs in my linux (ubuntu 22.04) guest.
I have SDR software running on host. I would like to send audio to vm audio input so I can use tools like qsstv in linux to receive sstv broadcasts.

@osy osy added the duplicate This issue or pull request already exists label Aug 1, 2022
@osy
Copy link
Contributor

osy commented Aug 1, 2022

Duplicate of #219

@osy osy marked this as a duplicate of #219 Aug 1, 2022
@osy osy closed this as not planned Won't fix, can't repro, duplicate, stale Aug 1, 2022
@GlobeShocked
Copy link

Thank you for providing the detailed instructions. I have been facing a similar issue, but I'm having some trouble understanding some aspects of your instructions. Could you provide some clarity on the following points?

  1. Where can I locate the UTMData.swift file? I'm assuming it is part of the project directory, but I would appreciate if you could give more specific guidance on its location.

  2. You mentioned enabling "Audio Input" in the "Hardened Runtime". Where can I find this "Hardened Runtime"? Is it within a specific application, or is it a part of system settings or line of code?

  3. I'm not quite clear on how to add a key with a string value. Specifically, you mentioned the "NSMicrophoneUsageDescription" key. How can I go about adding this?

I'm relatively new to this, and any additional explanation or clarification you could provide would be very helpful.

@allucat1000
Copy link

The issue still seems to not have been solved as on my W11 VM I am unable to use the microphone. Certain applications such as Duolingo can detect that I don't have a microphone, which means the issue isn't just with it not showing the popup menu for microphone and video permissions,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists macOS macOS issues spice Spice/CocoaSpice related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants