Opened 2 years ago

Closed 21 months ago

#841 closed defect (fixed)

Intel HD Audio stuttering in VirtualBox

Reported by: Jiri Svoboda Owned by:
Priority: major Milestone: 0.12.1
Component: helenos/unspecified Version: mainline
Keywords: virtualbox Cc:
Blocker for: Depends on:
See also:

Description

When I try playing audio in VirtualBox using HD Audio device, the sound is stuttering

Change History (7)

comment:1 by Jiri Svoboda, 2 years ago

Keywords: virtualbox added

comment:2 by Jiri Svoboda, 2 years ago

Milestone: 0.12.1

comment:3 by Jiri Svoboda, 22 months ago

It is also possible to configure VirtualBox with a SB16 soundcard. Using SB16 the sound output is just fine (albeit a little quieter).

When using HD Audio the sound stutters horribly. No abnormal messages appear in /log/hdaudio.

comment:4 by Jiri Svoboda, 22 months ago

I've verified that we receive HD Audio interrupts in VirtualBox. The function hda_ctl_interrupt gets called while stream playback is in progress. I can see more than the usual number of last ditch effort process RIRB messages during the setup phase, but nothing during playback.

comment:5 by Jiri Svoboda, 22 months ago

The driver does not check for buffer underrun. HD Audio informs of buffer underrun in form of FIFO Error bit in stream descriptor status register. It is even possible to get an interrupt when this bit is turned on (but this complicates interrupt handling quite a bit). I've tried checking this bit in the interrupt handler (which is invoked upon buffer completion). There is another problem, i.e. which stream descriptors to check. In Qemu unused stream descriptors have a status of 0x00, in VirtualBox they have status 0xff. (Ideally we would only check used stream descriptors). Anyway I hacked it temporarily and found out that we do not get any FIFO errors in VirtualBox.

What else could be wrong? I am thinking whether the buffers are allocated correctly and whether we could have some problem with the audio data format. Currently the driver seems to always set a fixed audio format. It does read the supported formats from the audio converted widget, but then ignores them. It always tries to set 44100 Hz, 16 bits, 1 channel.

comment:6 by Jiri Svoboda, 22 months ago

Root cause: VirtualBox HD Audio reports a number of output converters. One of them (ID 8) seems to be the 'correct' one, supporting 16-bit PCM @ 44100 Hz, the others reporting 0 for both rates and format.

When faced with multiple output converters, which one should hdaudio driver send the audio to? Currently it initializes all of them, just in case, with the same stream as source. But this clearly doesn't work correctly here, the output converters seem to fight over the stream, creating the stuttering. If I enable just the one audio converter, audio plays fine!

How do we fix this properly? In this particular case we could filter out the 'fake' converters based on their capabilities. That should solve this particular problem. What to do in case of multiple valid output converters is another question.

comment:7 by Jiri Svoboda, 21 months ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.