UTM icon indicating copy to clipboard operation
UTM copied to clipboard

If you put in headphones, audio is delayed by a few milliseconds

Open DUOLabs333 opened this issue 2 years ago • 12 comments

Describe the issue
If you connect a pair of headphones (I tested this with wireless headphones, though it may also occur with wired headphones), and you try to change the volume through pavucontrol, the audio inside the VM is delayed a few milliseconds after the appropriate action is taken. For example, audio won't sync in videos, and if you pause a video, the audio keeps playing for a short moment.

Configuration

  • UTM Version: 4.3.4
  • macOS Version: 11
  • Mac Chip (Intel, M1, ...): M1

Crash log

Debug log

Upload VM

DUOLabs333 avatar Aug 05 '23 22:08 DUOLabs333

Try switching the audio backed to CoreAudio

osy avatar Aug 05 '23 23:08 osy

Do I have to restart the VM first?

DUOLabs333 avatar Aug 05 '23 23:08 DUOLabs333

Yeah after changing it

osy avatar Aug 05 '23 23:08 osy

Sorry for taking so long to get back. This problem does occur if CoreAudio is enabled. Note that the delay only shows up if pavucontrol is opened.

DUOLabs333 avatar Aug 15 '23 02:08 DUOLabs333

It feels like a guest issue?

osy avatar Aug 19 '23 19:08 osy

I mean, maybe? I didn't have this issue with the other QEMU fork, so maybe it's a SPICE thing.

DUOLabs333 avatar Aug 19 '23 19:08 DUOLabs333

CoreAudio backend doesn’t go through SPICE. Are you using QEMU 7.2.0?

osy avatar Aug 19 '23 19:08 osy

This happens with 4.3.4 and 4.3.5.

DUOLabs333 avatar Aug 19 '23 20:08 DUOLabs333

Something I did not notice before: if you close pavucontrol, after a few seconds, it switches back to the default "mode". After the initial pavucontrol call, there seem to be two "modes" --- one, the default, where audio is delayed by ~1 sec. If you open pavucontrol, then it switches to the other mode, where audio is delayed by ~50 ms. This second mode is temporary and will switch in a few seconds once pavucontrol is closed. Both modes sound "different" --- one is not clearly worse than the other in terms of quality, but they definitely sound different.

If pavucontrol is open when the headphones are disconnected, then there is no sound in the VM until pavucontrol is exited.

DUOLabs333 avatar Aug 21 '23 21:08 DUOLabs333

This doesn't happen anymore with recent versions of QEMU, so I guess this issue can be closed.

DUOLabs333 avatar Jul 26 '24 17:07 DUOLabs333

What version of QEMU? Can you keep it open until QEMU is updated in UTM?

osy avatar Jul 26 '24 17:07 osy

I'm not sure which release it was --- I'm on HEAD right now (I'm using a thin wrapper over QEMU).

DUOLabs333 avatar Jul 26 '24 17:07 DUOLabs333

Hi!

FYI I'm experiencing the same issue and (I have the impression) it becomes worse over time:

  • Host: MacBook Pro M4 (Sequoia 15.1)
  • Guest: Debian Trixie ARM64 (incl. qemu-guest-agent and spice-vdagent)
  • UTM: Version 4.6.4 (107) (installed via Homebrew)
  • Sound Device: virtio-sound-pci
  • Sound Backend: "Default", "SPICE"

Switching the backend away from SPICE to coreaudio made the latency become much lower (not go away)! I installed pavucontrol just for this ticket and it seems to not switch to any low bitrate mode when using coreaudio (albeit the sound shortly stutters). With the default backend (SPICE), it does, though! The latency then isn't good with and without pavucontrol.

BTW: I had to explicitly close the VM window (the VM was already shut down) between switching sound backend, because otherwise starting the VM hangs.

OlafLostViking avatar Feb 15 '25 12:02 OlafLostViking