[vfio-users] Why does the audio from VM crackle?

Bob Dawes xochipilli4 at yahoo.com
Wed Jun 15 10:28:02 UTC 2016


On 09/06/16 08:35, Philip Abernethy wrote:
>
> I actually have this problem with passed through audio. I could 
> improve there situation by fiddling with the sample frequency and size 
> in the audio settings. Currently running at 192000Hz and 24 bit.
> My first instinct was to blame it on me skimping on the CPU, because I 
> got me a quad core i5 instead of the octa core i7.
>
> Philip
>
>
> On Thu, 9 Jun 2016 09:08 Abdulla Bubshait, <abdulla.bubshait at gmail.com 
> <mailto:abdulla.bubshait at gmail.com>> wrote:
>
>     I am not the only one who has this issue, but if you emulate an
>     audio card you end up with occasional crackling audio output,
>     which is sometimes associated with drops in FPS.
>
>     I know there are ways to pass audio devices to the VM directly,
>     but in many setups it would be preferable to pass the audio to the
>     host.
>
>     Does anyone know the reason the audio has distortion or crackling,
>     and are there any known solutions to the problem?
>     _______________________________________________
>     vfio-users mailing list
>     vfio-users at redhat.com <mailto:vfio-users at redhat.com>
>     https://www.redhat.com/mailman/listinfo/vfio-users
>
>
>
> _______________________________________________
> vfio-users mailing list
> vfio-users at redhat.com
> https://www.redhat.com/mailman/listinfo/vfio-users

My onboard audio was almost completely unusable when I first started 
out, but I got it to work great with the following

export QEMU_AUDIO_DRV=alsa
export QEMU_ALSA_ADC_BUFFER_SIZE=1024 QEMU_ALSA_ADC_PERIOD_SIZE=256
export QEMU_ALSA_DAC_BUFFER_SIZE=1024 QEMU_ALSA_DAC_PERIOD_SIZE=256
export QEMU_AUDIO_DAC_FIXED_SETTINGS=1
export QEMU_AUDIO_DAC_FIXED_FREQ=44100 QEMU_AUDIO_DAC_FIXED_FMT=S16 
QEMU_AUDIO_ADC_FIXED_FREQ=44100 QEMU_AUDIO_ADC_FIXED_FMT=S16
export QEMU_AUDIO_DAC_TRY_POLL=1 QEMU_AUDIO_ADC_TRY_POLL=1
export QEMU_AUDIO_TIMER_PERIOD=50

qemu-system-.......

Have barely had a crackle since I switched to a lower time period and 
lined up the qemu audio timer period with the alsa timer period (so it's 
windows start / end together so are less sensitive to timer jitter). 
Pulse audio always worked great as an alternative but there was (and 
still is when I just tried) a bug with random time delays on the 
microphone with pulse audio.

If that doesn't work you can send me the contents of /proc/asound/timers 
and I'll work out a window size for you. On some linux kernels you might 
find modprobe snd_timer gets you a better timer. ALSA has quite a lot of 
kernel options around timers and buffers.

buildacct at Poople-PC:~$ more /proc/asound/timers
G0: system timer : 3333.333us (10000000 ticks)
P0-0-0: PCM playback 0-0-0 : SLAVE
P0-0-1: PCM capture 0-0-1 : SLAVE
P0-1-0: PCM playback 0-1-0 : SLAVE
P0-2-1: PCM capture 0-2-1 : SLAVE
P0-3-0: PCM playback 0-3-0 : SLAVE
P0-7-0: PCM playback 0-7-0 : SLAVE

Good luck - it's still a little twitchy even with the above, but 
removing the audio device from windows system manager and scanning for 
changes often fixes it on the 1 time in 20 I boot and it doesn't work. 
It's still possible to make it crackle by putting heavy load on both 
host and client.

Or you can use the passthrough audio from your graphics card of course.

Regards,

D

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/vfio-users/attachments/20160615/6e86c96f/attachment.htm>


More information about the vfio-users mailing list