Linux host - Linux guest Sound in VirtualBox

At the moment this doesn't really offer any answers: it's my notes so far on a quest to solve the problem. To my surprise, this proved quite easy on a Windows host with a Linux guest: one minor tweak (sorry, don't remember what) and it was running. The problem came when I tried to do the same thing with Linux running under Linux.

Setup

I'm running Ubuntu 14.04 as my primary operating system on one of the earlier Intel i7 chips with 8GB of RAM and (according to lspci) host sound provided by: "Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)". I have version 4.3.10 of VirtualBox, which is the most recent version provided by the Ubuntu 14.04 repos ... but which is pretty old given that 4.3.28 is currently available.

Progress (or lack thereof)

  • VirtualBox offers three choices of emulated soundcards to the guest OS:
    • Intel HD Audio
    • ICH AC97 (default - which often shows up in guests as "Intel 82801AA")
    • SoundBlaster 16
  • running "lspci" in the SliTaz (5.0RC3) guest shows that SliTaz will detect both the "Intel HD Audio" and the "ICH AC97" audio: the "SoundBlaster 16" isn't detected at all
  • but trying to run the music player with an mp3 player results in failure in both cases: with the HD, the player won't start, and with the AC97 the player plays fine, but no sound is coming out
  • I've checked the mixer thoroughly, both in the guest and host, and I believe that everything that should be turned up is turned up
  • same problem with a Debian Stretch amd64 guest
  • on closer examination "alsamixer" and "aumix" have different opinions: the latter claims there's no mixer to work with (by default it looks for /dev/mixer), the former happily adjusts volumes
  • following a hint from this site, I added the file /etc/modprobe.d/alsa-base.conf and added the following:
options snd-intel8x0 ac97_clock=48000
  • this is apparently needed because the AC97 driver tries to guess the clock rate and gets it wrong
  • then I rebooted
  • mpg321 filename.mp3 still played without sound
  • but now aumix opens without complaint
  • and ... aumix says all the volumes are at zero, while alsamixer says "Master" and "PCM" are most of the way up - why the discrepancy?
  • turning up the volumes in aumix results in sound coming out of the host system - horribly distorted and barely recognizable, but that's progress
  • tracing the article above back to the initial bug report and work-around led me to change /etc/modprobe.d/alsa-base.conf to:
options snd-intel8x0 ac97_clock=48000
options snd slots=snd-intel8x0
alias snd-card-0 snd-intel8x0
  • that didn't change anything
  • another posting I found suggested that giving the guest OS more resources - cores, memory, even more video memory (which seems just stupid but I did it anyway) might help ... so I gave the Debian guest lots more of everything even though it's a text-only install and I have a 1999 Celeron 400MHz with 256 MB that plays music just fine in a GUI ...
  • no difference
  • changing the VirtualBox "Host Audio Driver" from "PulseAudio" to "ALSA Audio Driver" made the playback less distorted, but far from good
  • since it's an option and changing the drivers had so far provided the most difference, I changed the "Host Audio Driver" again, this time to "OSS Audio Driver:" this produced sound about on par with the ALSA host driver
  • I've been working with the guest Debian, having installed the .deb packages for virtualbox-guest-utils, virtualbox-guest-dkms and virtualbox-guest-x11: I uninstalled them, and "inserted" the Guest Additions CD via the host system, and ran VBoxLinuxAdditions.run: theoretically, this should have a more or less identical result, and that does seem to have been the case
  • a return to the host PulseAudio driver proves that yes, indeed, it's worse
  • I returned to and tinkered with the SliTaz 5.0RC3 guest, which was being silent while it thought it was playing music (Host: PulseAudio, Guest: "ICH AC97")
  • aumix is NOT available in SliTaz (not without building it yourself)
  • so I tried something I'd seen mentioned in another post: alsactl init ... and suddenly I had perfect playback in SliTaz, easy as that
  • it glitched when I resized the guest OS window, but otherwise seems quite fine
  • on further inspection, it's glitchy with YouTube playback (although the video seems pretty good)
  • switching the guest off, changing to the ALSA Audio Driver, and booting up again fixes it: fantastic
  • now what's up with Debian?
  • typically, the Arch Wiki has pretty much the best article about VirtualBox - ironically, with nothing at all on sound. But for future reference, it's here