JustKernel

Ray Of Hope

Virtualbox – Audio architecture

Currently Virtualbox uses QEMU audio code. QEMU audio code is a big monolithic blog with single file auido.c implementing most of the audio functionality and 100s of preprocessor directives  (glue etc) in audio_template.h providing most of the helper functionalities for different platform.

My task here was to modify the audio code to and implement it according to PDM spec of Virtualbox. So the audio code block was divided into 3 entities :

Audio Device Code: DevIChAC97 for AC97, DevSB16 for SB 16 audio controller and DevIchHda and DevIchHdaCode for HDA based audio devices.

Intermediate audio driver: DevAudio.c and DrvAudioUtil.c implementing the intermediate audio driver.

Host audio backend: DrvHostCoreaudio.c for Mac, drvHostDSoundAudio.c for DSound for Windows and DrvHostAlsaAudio.c and DrvHostPulseAudio.c for linux.

Consider the case of playing of audio.

In the guest user plays a .mp3 file. The guest audio driver writes the audio samples to the audio card registers.  The guest audio driver, tries to access the audio device. These accesses are trapped by the  hypervisor and are redirected to device code which redirects the to the intermediate audio driver. Intermediate audio driver further transfer the audio samples to the host audio backends based on the host platform. Host audio backends(drivers) which have access to host and host’s hardware, write these audio samples the actual audio hardware present on the host.

Consider the case of recording:

A user recording his voice on voice recorder or using skype call. Guest audio driver tries to read the audio from the virtual audio card. The call is trapped by the hypervisor, redirected to the device code, which then further redirects the read request to intermediate audio driver. Intermediate audio driver redirect the read request to the host backend. Host backend reads the audio samples from the audio device and then send those samples up to the actual guest.

mail_to : anshul_makkar@justkernel.com

Tags:


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.