[libvirt-users] Audio in Windows 10 VM is distorted. Using ALSA.

Manuel Ullmann ullman.alias at posteo.de
Tue Dec 20 02:41:07 UTC 2016


Hi,

I can’t seem to find a solution for my last VM issue.
I have distorted sound, when I play the Windows 10 device test
sound. Only the Windows sound is affected. Mpd of the host is playing just fine
meanwhile. I am using ich9 as emulated card, which is detected and
installed correctly. The VM is using vfio-igd passthrough, so  vnc or
spice are not used.
I tried to match the Windows driver configuration, which only supports
16 bit output. I have a 24 bit USB headphone amplifier, which does not
support it (S32_LE only). Trying direct playback on the PCH card jack
did not help though.

The headphone amplifier is connected via optical Toslink, so there is
standard snd_hda_intel output used (snd_usb_audio is not involved).
Passing the USB part through I get much clearer output, but still have
popping sounds. Googling around, they seem to be quite common on Windows
10, although I had it working fine on two bare-metal machines.

I have tried fixed settings matching the ones of the dmixed device
too. Don’t know, what is polled with enabled poll option. I also tried
sdl and pulseaudio, which did not help. For the latter not so surprising
since it is an Alsa pipe. The former was worse.

The goal of this setup is having the same playlist state on both
systems and using the better audio framework for music playback (Windows uses
too much software layers). Of course the popping sounds on audio device
passthrough also would be annoying, but that might be a different issue.

Best regards,
Manuel

used alsa device:
pcm.dmixed {
	type asym
	playback.pcm {
		# See plugin:dmix at http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
		type dmix

		# Don't block other users, e.g. the Timidity midi-player daemon
		# http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
		ipc_key_add_uid false

		ipc_key 1025
		ipc_perm 0660
		ipc_gid audio

		# Don't put the rate here! Otherwise it resets the rate & channels set below, as shown by:  cat /proc/asound/card0/pcm0p/sub0/hw_params
		slave {
			# 2 for stereo, 6 for surround51, 8 for surround71
			channels 2
			pcm {
				format S16_LE
				#format S32_LE

				#rate 44100
				rate 48000

				# http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
				# Maybe helps
				nonblock true
				type hw
				card "PCH"
				device 0
				subdevice 0
			}

			# mplayer2 chooses 1024
			# period_size 512 with buffer_size 16384 stops crackling in xmame
			# 320 breaks flash - https://bbs.archlinux.org/viewtopic.php?id=129458
			#period_size 512
			period_size 1024

			# 4096 might make sound crackle
			# mplayer2 chooses 8192. Half-Life 2 chooses 16384.
			# If too large, use CONFIG_SND_HDA_PREALLOC_SIZE=2048
			buffer_size 8192
		}
	}
	capture.pcm "schneeball"
}

libvirt xml snippets:

    <sound model='ich9'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </sound>
    ...
    <qemu:env name='QEMU_AUDIO_DRV' value='alsa'/>
    <qemu:env name='QEMU_DAC_FIXED_SETTINGS' value='0'/>
    <qemu:env name='QEMU_DAC_TRY_POLL' value='0'/>
    <qemu:env name='QEMU_DAC_TIMER_PERIOD' value='0'/>
    <qemu:env name='QEMU_DAC_BUFFER_SIZE' value='0'/>
    <qemu:env name='QEMU_DAC_PERIOD_SIZE' value='0'/>
    <qemu:env name='QEMU_DAC_DEV' value='dmixed'/>




More information about the libvirt-users mailing list