VirtualBox

Opened 15 years ago

Last modified 4 years ago

#4605 reopened defect

Ubuntu Linux guest audio output slow and distorted

Reported by: Larry Shurr Owned by:
Component: audio Version: VirtualBox 3.0.2
Keywords: slow tempo low pitch distortion Cc:
Guest type: Linux Host type: Windows

Description (last modified by aeichner)

There's some discussion in community forums related to this, but it doesn't go very far. Couldn't find any similar report in Bugtracker. Sorry if I overlooked.

This is an Ubuntu Linux 9.0.4 guest in Virtualbox 3.0.2 r49928 on a Vista SP1 host, a Presario C751 notebook. Following initial installation of the guest, sound playback works well. Only after shutting down the VM completely and then restarting will sound playback slow down with a commensurate lowering of pitch as though the clock is running slow. Sound distortion such as "chirping" and stuttering may be evident as well. The problem is temporarily repaired by reinstalling the Guest Additions and rebooting the VM (reboot only, don't shut it down!). Having done that, audio playback is restored to normal and will remain normal between reboots of the VM. Only after the VM is shut down will the problem recur. The same problem occurred in V 2.2.4 r47978. FWIW Video output seems to be affected as well.

A Windows XP SP3 guest does not seem to exhibit the same problem.

Using a VM for multimedia apps is silly, but what's amazing is how well it works when it works. It's not the way to go, but even if you don't, Ubuntu, for example, makes sounds like the drumbeat figure when GDM is ready for login, the Ubuntu "theme" as GNOME comes up and other sounds such as error notifications and the like and it is irritating for them to be slow, off pitch and distorted. More importantly, the fact that it sometimes works and sometimes doesn't implies an underlying problem that may be more significant.

If I can, I will dissect the Guest Additions installation and try to determine what seems to "fix" the problem.

Attachments (6)

good_audio.dmesg (23.3 KB ) - added by Claudio Nieder 14 years ago.
This is the dmesg output in the good case, i.e. audio has correct pitch.
bad_audio.dmsg (23.2 KB ) - added by Claudio Nieder 14 years ago.
This is the dmesg output in the bad case, i.e. audio pitch is much lower than it should be.
dmesg.ac97.clock.slow.txt (17.9 KB ) - added by Larry Shurr 14 years ago.
This file as after the first reboot following reinstall of the Guest Additions. Sound output is slow and distorted.
dmesg.ac97.clock.48000.txt (17.7 KB ) - added by Larry Shurr 14 years ago.
This file is from a subsequent emulated power cycle. Sound is normal hereafter unless there is a crash or a new kernel is installed.
bad_high_audio.dmsg (23.1 KB ) - added by Claudio Nieder 14 years ago.
dmesg with high pitch
sound (150 bytes ) - added by Larry Shurr 14 years ago.
Place in /etc/modprobe.d to activate the ac97 clock workaround discussed in this thread

Download all attachments as: .zip

Change History (38)

comment:1 by Larry Shurr, 15 years ago

FWIW the fault does not occur on a Windows XP SP 3 host. Of course the XP host's hardware is different, as well, so the comparison's not "pure".

comment:2 by Larry Shurr, 15 years ago

It's not much of a dissection so far, but it turns out that the Guest Addtions install scripts take arguments and "bash VBoxLinuxAdditions-x86.run kernel-module" followed by rebooting the VM is sufficient to correct the audio. This workaround still gets undone somehow when the VM is shut down. Audio is still slow and distorted when the VM is restarted. Curiously, the degree of slowdown/distortion varies from session to session.

comment:3 by Larry Shurr, 15 years ago

Well, I made a mistake in my observations. It's true that the degree of slowdown/distortion seemed to vary, but in each instance, I had reinstalled Guest Additions. It turns out, at least in my case, that if you simply shutdown the VM completely and then restart it one more time, the problem goes away. Something funny's going on, but it seems to go away.

Looking back, I see that I let this bug report be rated major by default,which may not have been the right rating even given my understanding of the problem at the time. I think it should be rated lower, now.

comment:4 by Larry Shurr, 15 years ago

If it tells you anything useful, software crashes cause a temporary return of symptoms. If Linux crashes or otherwise ends abnormally, it seems that the next boot will exhibit slow audio. You'll have to shutdown and restart the VM to "fix" it. After a little work, I have managed to get openSUSE 11.1 running the Plasma/KDE4 desktop running well as a guest. Once, Plasma took an abnormal exit on me and when it restarted, you guessed it, audio was slow. Had to shutdown and restart to "fix" it.

comment:5 by Claudio Nieder, 14 years ago

This problem still perstist in VirtualBox 3.1.0 r55467.

Host OS is OS X Snow Leopard 10.6.2 Darwin garfield1.lan 10.2.0 Darwin Kernel Version 10.2.0: Tue Nov 3 10:37:10 PST 2009; root:xnu-1486.2.11~1/RELEASE_I386 i386

Guest OS is Ubuntu 9.10 Linux garfield.inodes.ch 2.6.31-15-generic #50-Ubuntu SMP Tue Nov 10 14:54:29 UTC 2009 i686 GNU/Linux

After installing the VirtualBox GuestAddition for 3.1.0 (overwriting those of 3.0.12) and restarting Ubuntu audio was ok.

The next time I started VirtualBox and Ubuntu audio had a low pitch again.

In both instances I took dmesg outputs which I will attach to this bug report. One thing I notice towards the end: In the good case Linux tries to figure out the audio clock rate and does not succeed - I suppose it thinks the measured rate is off limits - thus sets the sample rate to 48000. In the bad case it seem to figure out an acceptable rate and sets that.

by Claudio Nieder, 14 years ago

Attachment: good_audio.dmesg added

This is the dmesg output in the good case, i.e. audio has correct pitch.

in reply to:  5 comment:6 by Claudio Nieder, 14 years ago

Replying to claudio_:

In both instances I took dmesg outputs which I will attach to this bug report. One thing I notice towards the end: In the good case Linux tries to figure out the audio clock rate and does not succeed - I suppose it thinks the measured rate is off limits - thus sets the sample rate to 48000. In the bad case it seem to figure out an acceptable rate and sets that.

What I forgot to write. The bad and good case also differ - as one can see in the first part of the dmesg output - in the CPU frequency detected. 470 MHz in one case 2 GHz in the other case.

by Claudio Nieder, 14 years ago

Attachment: bad_audio.dmsg added

This is the dmesg output in the bad case, i.e. audio pitch is much lower than it should be.

comment:7 by Larry Shurr, 14 years ago

O.K., I see the same thing that claudio_ reported. I'm currently running VB 3.0.12 r54655. My host is a Compaq Presario C700 running Vista SP1, but I can get the same failure on my desktops running Windows XP, as well. The guest is OpenSUSE 11.1 with the kernel recently updated to 2.6.27.37. The kernel update necessitates a reinstall of the Guest Additions and brings on a cycle of sound too slow until next emulated power cycle.

I've uploaded dmesg outputs, as well. In the file dmesg.ac97.clock.slow.txt, you see intel8x0_measure_ac97_clock() measure the clock and come up with a value it finds "acceptable" and the resulting clock rate is 41161 Hz. The sound is slow and distorted with that setting. In the file dmseg.ac97.clock.4800, you see intel8x0_measure_ac97_clock() measure the AC97 clock and come up with a value it finds unacceptable, causing it to set the clock to 48000 Hz. The result is undistorted sound from the emulated ac97.

It seems that the emulated ac97 sounds best when its default clock is something so unacceptable that the driver initializes it to 48000 Hz. The result is normal sound output. If the clock is already within the "acceptable" range (whatever that means), it is not changed and the sound quality you get is the luck of the draw.

by Larry Shurr, 14 years ago

Attachment: dmesg.ac97.clock.slow.txt added

This file as after the first reboot following reinstall of the Guest Additions. Sound output is slow and distorted.

by Larry Shurr, 14 years ago

Attachment: dmesg.ac97.clock.48000.txt added

This file is from a subsequent emulated power cycle. Sound is normal hereafter unless there is a crash or a new kernel is installed.

by Claudio Nieder, 14 years ago

Attachment: bad_high_audio.dmsg added

dmesg with high pitch

comment:8 by Claudio Nieder, 14 years ago

Today for the first time I had a situation where the pitch was higher then it should be. Thus I attached a further dmesg output for this situation too.

By the way this is on a MacBook Pro 17" (Early 2009 model).

comment:9 by Larry Shurr, 14 years ago

The high pitch outcome is interesting. When I look at your latest dmesg output, I see that it tried measuring the emulated ac97 chip's clock three times, rejecting outcomes of 62281 Hz & 64657 Hz before accepting 50732 Hz as a good setting. 'Course I'm talking almost like a really understand what's going on, whereas instead, so much is unknown, that I only have the vaguest of ideas. It seems to me, though, that the intel8x0 driver in Linux is making an assumption about the chip which does not hold in the VirtualBox emulation. Based on these few dmesg listings, I wonder what it means for the driver to accept whatever clock "setting" it "finds." It may be that the VBox emulation only gives good results if the clock is actually set to something. It looks like we always get good results when it decides to set the clock 48000 Hz instead of accepting whatever it thinks it found there.

comment:10 by Larry Shurr, 14 years ago

The recent messages from claudio_ led to a little more looking around WRT the emulated ac97 chipset, a SigmaTel STAC9700. You can look at the status of the "chip" using

'cat /proc/asound/card0/codec97#0/ac97#0-0'.

You can view the registers using

'cat /proc/asound/card0/codec97#0/ac97#0-0+regs'

and you can alter register settings by writing the settings you want into the ac97#0-0+regs node as root... or so it appears, e.g.

'echo 2e ac44 >/proc/asound/card0/codec97#0/ac97#0-0+regs'

will write 0xac44 (44100 decimal) to register 0x2e.

If the sound is too slow or fast, the settings shown by ac97#0-0 will be obviously 'wrong' and it's easy to find the 'off' values in ac97#0-0+regs, too, by converting the off settings from decimal to hex and looking for those values in the registers. You can change the settings to what they should be, but... that still doesn't fix the sound.

Either I'm missing something, it just doesn't work or it just doesn't work the way it seems like it ought to. You can look for the STAC9700 docs online and find out what the registers mean, e.g., if you write any value to register 00, the chip resets and that does seem to work. All the registers are set to default values and sound stops working. You can then set all the registers to what they ought to be and sound will work again, but if was slow or fast and distorted when you started, it will be exactly the same as before -- still too slow or fast. This suggests that there are other settings somewhere that may or not be accessible using /proc that also need to be changed to get sound working correctly, but I've run out of ideas for now.

comment:11 by Larry Shurr, 14 years ago

Workaround found -- see if it works for you. The workaround is in Linux's snd-intel8x0 driver, which has options for working around problems with various hardware and one of these allows you to disable auto-detect on the AC'97 codec clock and set it directly. Since I have never tried to use VB's Soundblaster 16 emulation, AFAIK nothing I say here applies to it.

I use openSUSE 11.1 now instead of Ubuntu, so I used YAST to change the setting. With other distros, YMMV. In YAST, select Hardware->Sound->Edit. In the Advanced Sound Options window, select the "AC'97 codec clock (0 = auto-detect)" option and click the Edit button. Enter the value 48000 and click the OK button, returning you to the "Sound Card Advanced Options" window, where you will click the Next button. This will return you to the Sound configuration window where you should click the OK button. At this point, you're finished, but YAST will first update the settings and reset the audio interface before returning you to the YAST Control Center window, which you can close.

O.K., this works for me. So far, there's no slow, distorted sound, even after powering down the emulated machine, which always induced the failure before now.

comment:12 by Claudio Nieder, 14 years ago

lshurr: I wonder where YAST stores the change. I think it might be one either the boot configuration (/boot/grub/menu.lst or /boot/grub/grub.conf) or the modprobe stuff i.e. some file in /etc/modprobe.d. Can you have a look which file was modified by YAST?

comment:13 by Larry Shurr, 14 years ago

claudio_: It's in the modprobe parameter files, which would stand to reason I suppose. The file I'm uploading, 'sound', was found in /etc/modprobe.d in my openSUSE VM. I reactivated my long-dormant Ubuntu 9.04 VM and copied it into /etc/modprobe.d. It works like a charm. I powered-off the Ubuntu VM using the 'Machine' menu and then restarted it, a scenario guaranteed, in the past, to induce slow, distorted audio and sound came up just fine, not slow, not distorted. Looks like it's a confirmed workaround.

by Larry Shurr, 14 years ago

Attachment: sound added

Place in /etc/modprobe.d to activate the ac97 clock workaround discussed in this thread

comment:14 by Claudio Nieder, 14 years ago

lshurr: Thank you. I put just the line

options snd-intel8x0 ac97_clock=48000

into /etc/modprobe.d/sound and I notice that all the lines regarding to 8x0 trying to find the correct frequency disappear from dmesg output. So it really picks up the preset value instead of trying to guess it.

Thus I too think this is a way to solve this problem on Linux side.

comment:15 by David Abrahams, 14 years ago

This workaround isn't helping me with an ubuntu 9.10 x64 guest on MacOS 10.6 x64 host :(. Maybe it's somehow a different problem

in reply to:  15 comment:16 by Larry Shurr, 14 years ago

Replying to bewst:

This workaround isn't helping me with an ubuntu 9.10 x64 guest on MacOS 10.6 x64 host :(. Maybe it's somehow a different problem

I am disappointed to learn of its failure for you after the satisfactory outcomes that claudio_ and I have obtained. Do you find the same things in your guest's dmesg output that we found? Since I am not running on a Mac, there's obviously much I don't know, but I believe I understand that whereas your host and guest are both 64-bit, in his and my case, our hosts and guests are all 32-bit. Even if I have misunderstood something, it may still be instructive if you were to create and load a 32-bit guest and see if the workaround works in that case.

comment:17 by David Abrahams, 14 years ago

I'm very pleased to say that with the latest VBox I am no longer having the problem. Audio is slightly glitchy, but not horrible like it was.

comment:18 by Frank Mehnert, 14 years ago

bewst, are you talking about a Mac OS X host? Which was the previous version which didn't work for you and which version works better?

comment:19 by David Abrahams, 14 years ago

yes: 3.1.4/3.1.6

in reply to:  17 comment:20 by Larry Shurr, 14 years ago

Replying to bewst:

I'm very pleased to say that with the latest VBox I am no longer having the problem. Audio is slightly glitchy, but not horrible like it was.

I'm glad to hear it. As long as power management is set to the max performance setting, I almost never have a glitch. I can even play videos in the guest with surprisingly good results as long as I use the VideoLan VLC player -- It is by far the most glitch-resistant video player. This is true even when running in a guest on my openSUSE laptop which has only a 1.6 GHz Celeron.

comment:21 by David Abrahams, 14 years ago

Weird; I just had the same experience all over again with a Windows guest. The distortion sounds exactly the same.

in reply to:  21 comment:22 by Larry Shurr, 14 years ago

Replying to bewst:

Weird; I just had the same experience all over again with a Windows guest. The distortion sounds exactly the same.

Interesting. I've never experienced distortion in a Windows guest, only with Linux guests and that was fully corrected by the workaround in my case.

comment:23 by Sander van Leeuwen, 13 years ago

Resolution: fixed
Status: newclosed

Retry with 3.2.10 please.

comment:24 by Claudio Nieder, 13 years ago

Resolution: fixed
Status: closedreopened

It happens again with Lubuntu 11.10 guest in a VirtualBox 4.1.2 hosted on Mac OSX Lion (10.7.1):

[ 8.635720] intel8x0_measure_ac97_clock: measured 124579 usecs (7241 samples) [ 8.635994] intel8x0: clocking to 39640

comment:25 by sunlover, 13 years ago

Resolution: fixed
Status: reopenedclosed

The snd_intel8x0 audio driver tries to autodetect the ac97 device clock. The autodetection method does not work in a virtual machine. You have to specify the frequency in /etc/modprobe.d/alsa-base.conf:

options snd-intel8x0 ac97_clock=48000

comment:26 by Ah Yes, 10 years ago

Resolution: fixed
Status: closedreopened

Sorry this is not fixed at all. The last post is a workaround, not a fix.

It's affecting FreeBSD guests too:

https://forums.freebsd.org/viewtopic.php?f=19&t=44579&p=251349#p251349

The same VM image in VMware Player (free edition) does not exhibit any issues at all. Timing is perfect, no audio dramas. Please consider fixing the issue with virtualbox that is causing this (it has to be some sort of timing issue, if VMWare have a way of not having these problems, it HAS to be possible to fix this issue in virtualbox).

comment:27 by aeichner, 8 years ago

Description: modified (diff)
Resolution: obsolete
Status: reopenedclosed

Please reopen if still relevant with a recent VirtualBox release.

comment:28 by PHO, 7 years ago

Resolution: obsolete
Status: closedreopened

Exactly the same problem happens on VBox 5.1.6, host OS X, guest NetBSD 7.0.1:

% dmesg|fgrep -i auich
auich0 at pci0 dev 5 function 0: i82801AA (ICH) AC-97 Audio
auich0: interrupting at ioapic0 pin 21
auich0: ac97: SigmaTel STAC9700 codec; no 3D stereo
auich0: ac97: ext id 0x809<AC97_23,VRM,VRA>
auich0: measured ac97 link rate at 453707 Hz, will use 454000 Hz
audio0 at auich0: full duplex, playback, capture, mmap, independent

There is a workaround though:

% sudo sysctl -w hw.auich0.ac97rate=48000

"auich" is an AC-97 driver for NetBSD. It estimates the clock rate of the (emulated) AC-97 by recording certain number of frames from PCM_LR and measuring the time it took. And the result is very surprising: it concludes that the AC-97 is running at whopping 454 KHz rather than the correct rate 48 KHz:

This either means the clock of the guest CPU (or perhaps RTC) is running insanely slow (unlikely!), or the emulated AC-97 is sending the recorded frames insanely fast. But my knowledge about these things is rather limited so I have no idea what is really going on. Do you have any idea?

Last edited 7 years ago by PHO (previous) (diff)

comment:29 by pentagonik, 6 years ago

Resolution: obsolete
Status: reopenedclosed

Please reopen if still relevant with a recent VirtualBox release. Also consider trying out one of the latest test builds which can be found here: https://www.virtualbox.org/wiki/Testbuilds

comment:30 by Ben Leggiero, 5 years ago

Resolution: obsolete
Status: closedreopened

This is still happening to me with VirtualBox 5.2.26 r128414 running guest Lubuntu 18.10 on host Windows 10.0.17134.590 (1803)

comment:31 by Newjoy, 5 years ago

VirtualBox: 5.2.18_Ubuntu r123745

Host: Xubuntu 18.04

Guest: Windows 10 (17763.475 1809)

After changing the Sound setting in Windows10, the sound rarely cracks.

Sound >> on the Playback menu click on Speaker, select configure at the bottom left >> change the default 5.1 Surround to Stereo. The crackling sound goes away.

comment:32 by jacky62, 4 years ago

Virtualbox: 5.2.34_Ubuntu r133883

Host: Linux Mint 19.3 Guest: Windows 10 x64

I have migrated my system to new hardware and I opened my Windows 10 machine on Virtualbox, it works but the audio seems to go slower than on my host (tried with multiple video/audio files).

Is there any solution for my specific case or workaround that I can try?

Thanks

Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use