Bug 140453 - [sound] [vbox] No sound inside Virtualbox on 50% volume
Summary: [sound] [vbox] No sound inside Virtualbox on 50% volume
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-10 21:20 UTC by mwisnicki+freebsd
Modified: 2021-04-22 13:26 UTC (History)
1 user (show)

See Also:


Attachments
vbox-patch-xzz.diff (1.66 KB, patch)
2009-12-16 01:57 UTC, Ariff Abdullah
no flags Details | Diff
ac97_due_to_buggy_codec.diff (1004 bytes, patch)
2009-12-16 01:57 UTC, Ariff Abdullah
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description mwisnicki+freebsd 2009-11-10 21:20:01 UTC
Using VirtualBox 3.0.8 on WindowsXP I don't have the sound in the FreeBSD
guest on default volume of 50. Changing it to 49 or 100 gives maximum volume.
Turns out it wraps on 50 - ie. any $vol>49 is the same as $vol-50.
Similar thing occurs on "pcm" control.

# sysctl hw.snd.verbose=4
# cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 32bit 2009061500/i386)
Installed devices:
pcm0: <Intel ICH (82801AA)> at io 0xd100, 0xd200 irq 9 bufsz 16384 kld snd_ich [MPSAFE] (1p:3v/1r:1v channels duplex default)
        snddev flags=0x2e2<AUTOVCHAN,BUSY,MPSAFE,REGISTERED,VPC>
        [pcm0:play:dsp0.p0]: spd 48000, fmt 0x00200010, flags 0x00002100, 0x00000004
        interrupts 5309, underruns 0, feed 5309, ready 0 [b:4096/2048/2|bs:4096/2048/2]
        channel flags=0x2100<BUSY,HAS_VCHAN>
        {userland} -> feeder_mixer(0x00200010) -> {hardware}
        pcm0:play:dsp0.p0[pcm0:virtual:dsp0.vp0]: spd 8000/48000, fmt 0x00100008/0x00200010, flags 0x10000000, 0x0000006b
        interrupts 0, underruns 0, feed 0, ready 0 [b:0/0/0|bs:4096/128/32]
        channel flags=0x10000000<VIRTUAL>
        {userland} -> feeder_root(0x00100008) -> feeder_format(0x00100008 -> 0x00100010) -> feeder_rate(0x00100010 q:1 8000 -> 48000) -> feeder_matrix(1.0 -> 2.0) -> feeder_volume(0x00200010) -> {hardware}
        pcm0:play:dsp0.p0[pcm0:virtual:dsp0.vp1]: spd 8000/48000, fmt 0x00100008/0x00200010, flags 0x10000000, 0x0000006b
        interrupts 0, underruns 0, feed 0, ready 0 [b:0/0/0|bs:4096/128/32]
        channel flags=0x10000000<VIRTUAL>
        {userland} -> feeder_root(0x00100008) -> feeder_format(0x00100008 -> 0x00100010) -> feeder_rate(0x00100010 q:1 8000 -> 48000) -> feeder_matrix(1.0 -> 2.0) -> feeder_volume(0x00200010) -> {hardware}
        pcm0:play:dsp0.p0[pcm0:virtual:dsp0.vp2]: spd 44100/48000, fmt 0x00200010, flags 0x10000000, 0x00000029
        interrupts 0, underruns 0, feed 0, ready 0 [b:0/0/0|bs:65536/2048/32]
        channel flags=0x10000000<VIRTUAL>
        {userland} -> feeder_root(0x00200010) -> feeder_volume(0x00200010) -> feeder_rate(0x00200010 q:1 44100 -> 48000) -> {hardware}
        [pcm0:record:dsp0.r0]: spd 48000, fmt 0x00200010, flags 0x00002100, 0x00000005
        interrupts 0, overruns 0, feed 0, hfree 4096, sfree 4096 [b:4096/2048/2|bs:4096/2048/2]
        channel flags=0x2100<BUSY,HAS_VCHAN>
        {hardware} -> feeder_root(0x00200010) -> feeder_mixer(0x00200010) -> {userland}
        pcm0:record:dsp0.r0[pcm0:virtual:dsp0.vr0]: spd 44100/48000, fmt 0x00200010, flags 0x10000000, 0x00000029
        interrupts 0, overruns 0, feed 0, hfree 0, sfree 65536 [b:0/0/0|bs:65536/2048/32]
        channel flags=0x10000000<VIRTUAL>
        {hardware} -> feeder_root(0x00200010) -> feeder_rate(0x00200010 q:1 48000 -> 44100) -> feeder_volume(0x00200010) -> {userland}

Fix: 

Adjust volume to 100.
How-To-Repeat: 1. install VirtualBox 3.0.8
2. install FreeBSD 8.0-RC2 i386 as guest
3. kldload snd_ich
4. mixer pcm 50 (default)
5. try playing something
Comment 1 Remko Lodder freebsd_committer 2009-11-11 08:42:46 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-multimedia

reassign to multimedia team
Comment 2 Ariff Abdullah freebsd_committer 2009-12-16 01:57:24 UTC
Virtualbox (QEMU too) default to 5bit volume resolution, but it
appears through the volume resolution calibration process as
6bit. Clearly, it is a "hardware" bug. Virtualbox doing
slightly a better job by "clamping" the results (the lower bits
written as '1') whenever there is a write attempt on 5th (or
13th) bit, but _without_ resetting those high bit. As such, it
appears as a full 6-bit resolution result on the next codec
read. FreeBSD try to be honest here by doing supposed to be
correct calibration process and see/measure the result as is.
Others <insert whatever..> probably have their own static
mapping (think about vendor specific driver) or depends on
whatever magic marker, etc.

You have two choices:

1) Fix virtualbox ac97 codec emulation (probably not for you
   given the fact that your vbox runs on Windows).

or

2) "Fix" FreeBSD ac97 volume resolution calibration by
   accepting certain lower bits magic marker, ignoring the high bit.


--
Ariff Abdullah
FreeBSD

... Recording in stereo is obviously too advanced
    and confusing for us idiot ***** users :P ........

... Going with the standard and orthodox
    is the death of intellect ..............
Comment 3 mwisnicki+freebsd 2009-12-16 16:03:12 UTC
On Wed, Dec 16, 2009 at 02:57, Ariff Abdullah <ariff@freebsd.org> wrote:
> Virtualbox (QEMU too) default to 5bit volume resolution, but it
> appears through the volume resolution calibration process as
> 6bit. Clearly, it is a "hardware" bug. Virtualbox doing
> slightly a better job by "clamping" the results (the lower bits
> written as '1') whenever there is a write attempt on 5th (or
> 13th) bit, but _without_ resetting those high bit. As such, it
> appears as a full 6-bit resolution result on the next codec
> read. FreeBSD try to be honest here by doing supposed to be
> correct calibration process and see/measure the result as is.
> Others <insert whatever..> probably have their own static
> mapping (think about vendor specific driver) or depends on
> whatever magic marker, etc.
>
> You have two choices:
>
> 1) Fix virtualbox ac97 codec emulation (probably not for you
>   given the fact that your vbox runs on Windows).
>

Good to hear it's a known problem. Is there any reason why this patch
was not submitted to virtualbox (at least I couldn't find a ticket
there) ?
I don't really care about it since workaround is so simple, but it
would be nice to have it working correctly out of the box.

> or
>
> 2) "Fix" FreeBSD ac97 volume resolution calibration by
>   accepting certain lower bits magic marker, ignoring the high bit.
>
>
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2011-10-16 23:58:23 UTC
Responsible Changed
From-To: freebsd-multimedia->vbox

over to (correct) maintainer
Comment 5 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:29 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 6 Guido Falsi freebsd_committer 2021-04-22 13:26:02 UTC
Is this still an issue?

VirtualBox has been updated a lot since this was filed and various patches have been added to address sound issues.

Maybe this one can be closed?