# Sound plays for 15 seconds and crashes in Freebsd 12.3-RELEASE-p3 on MacOS X 10.14 running inside Virtualbox 6.1 Host



## Alex Student (Mar 21, 2022)

Hello, (this is my first post)

The sound crashes after a shot period, like there is a problem in buffering.
The audio device on the virtualbox host is ICH AC97. 

_I like audio very much on a desktop; it is essential to me._

/boot/loader.conf has:

```
snd_ich_load="YES"
```
I tried to specify sysctl settings to force it to work, but the buffersize is *readonly* on sysctl.
How can I check buffer is correct? Or specify maybe in pacmd?

What am I missing?
Help is appreciated, more people are trying FreeBSD on virtualbox, I am not the only one, I recon.

Whats below?

The sysctl script whit manual settings
Output from sndstats
First time I got stuck after trying to resolve it with freebsd handbook.

s=sudo sysctl

```
s hw.snd.compat_linux_mmap=0
s hw.snd.default_auto=2
s hw.snd.default_unit=0
s dev.pcm.0.bitperfect=0
#s dev.pcm.0.buffersize=16384
s dev.pcm.0.ac97rate=48000
s dev.pcm.0.rec.vchanformat=s16le:2.0
s dev.pcm.0.rec.vchanrate=48000
s dev.pcm.0.rec.vchanmode=fixed
s dev.pcm.0.rec.vchans=2
s dev.pcm.0.play.vchanformat=s16le:2.0
s dev.pcm.0.play.vchanrate=48000
s dev.pcm.0.play.vchanmode=fixed
s dev.pcm.0.play.vchans=2
s hw.snd.feeder_eq_exact_rate=1
s hw.snd.feeder_rate_max=48000
s hw.snd.feeder_rate_min=48000
s hw.snd.feeder_rate_polyphase_max=400000  #183040
s hw.snd.feeder_rate_quality=0
s hw.snd.feeder_rate_round=0 #default 25 max 500
s hw.snd.latency=10 # 00 to 10
s hw.snd.latency_profile=1 # def 1
s hw.snd.maxautovchans=4
s hw.snd.report_soft_formats=1
s hw.snd.report_soft_matrix=1
s hw.snd.verbose=4
s dev.pcm.0.polling=1
```

SNDSTAT

```
FreeBSD Audio Driver (64bit 2009061500/amd64)
Installed devices:
pcm0: <Intel ICH (82801AA)> at io 0xd100, 0xd200 irq 21 bufsz 16384  (1p:2v/1r:2v) default
    snddev flags=0x2e2<AUTOVCHAN,BUSY,MPSAFE,REGISTERED,VPC>
    [pcm0:play:dsp0.p0]: spd 48000, fmt 0x00200010, flags 0x00002100, 0x00000004
    interrupts 392, underruns 0, feed 392, ready 0 [b:16384/8192/2|bs:16384/8192/2]
    channel flags=0x2100<BUSY,HAS_VCHAN>
    {userland} -> feeder_mixer(0x00200010) -> {hardware}
    pcm0:play:dsp0.p0[pcm0:virtual:dsp0.vp0]: spd 44100/48000, fmt 0x00200010, flags 0x10000000, 0x00000029
    interrupts 0, underruns 0, feed 0, ready 0 [b:0/0/0|bs:131072/65536/2]
    channel flags=0x10000000<VIRTUAL>
    {userland} -> feeder_root(0x00200010) -> feeder_volume(0x00200010) -> feeder_rate(0x00200010 q:0 44100 -> 48000) -> {hardware}
    pcm0:play:dsp0.p0[pcm0:virtual:dsp0.vp1]: spd 8000, fmt 0x00100008, flags 0x10000000, 0x00000000
    interrupts 0, underruns 0, feed 0, ready 0 [b:0/0/0|bs:0/0/0]
    channel flags=0x10000000<VIRTUAL>
    {userland} -> feeder_root(0x00000000) -> {hardware}
    [pcm0:record:dsp0.r0]: spd 48000, fmt 0x00200010, flags 0x00002100, 0x00000005
    interrupts 3366, overruns 0, feed 6732, hfree 16384, sfree 16384 [b:16384/8192/2|bs:16384/8192/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 131072 [b:0/0/0|bs:131072/65536/2]
    channel flags=0x10000000<VIRTUAL>
    {hardware} -> feeder_root(0x00200010) -> feeder_rate(0x00200010 q:0 48000 -> 44100) -> feeder_volume(0x00200010) -> {userland}
    pcm0:record:dsp0.r0[pcm0:virtual:dsp0.vr1]: spd 8000, fmt 0x00100008, flags 0x10000000, 0x00000000
    interrupts 0, overruns 0, feed 0, hfree 0, sfree 0 [b:0/0/0|bs:0/0/0]
    channel flags=0x10000000<VIRTUAL>
    {hardware} -> feeder_root(0x00000000) -> {userland}
No devices installed from userspace.

File Versions:
$FreeBSD: releng/12.3/sys/dev/sound/isa/sndbuf_dma.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pci/cmi.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pci/csa.c 338200 2018-08-22 14:06:31Z avatar $
$FreeBSD: releng/12.3/sys/dev/sound/pci/csapcm.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pci/es137x.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pci/ich.c 365298 2020-09-03 13:56:30Z markj $
$FreeBSD: releng/12.3/sys/dev/sound/pci/via8233.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pci/hda/hdaa.c 370354 2021-08-19 07:37:08Z gbe $
$FreeBSD: releng/12.3/sys/dev/sound/pci/hda/hdaa_patches.c 369870 2021-05-27 00:51:03Z emaste $
$FreeBSD: releng/12.3/sys/dev/sound/pci/hda/hdac.c 367124 2020-10-29 00:30:38Z mav $
$FreeBSD: releng/12.3/sys/dev/sound/pci/hda/hdacc.c 369105 2021-01-22 16:46:11Z mav $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/ac97.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/ac97_patch.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/buffer.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/channel.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/dsp.c 369534 2021-03-31 13:23:04Z markj $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/feeder.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/feeder_chain.c 370693 2021-09-29 17:25:48Z gbe $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/feeder_eq.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/feeder_format.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/feeder_matrix.c 370693 2021-09-29 17:25:48Z gbe $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/feeder_mixer.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/feeder_rate.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/feeder_volume.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/mixer.c 359885 2020-04-13 16:31:13Z hselasky $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/sndstat.c 326255 2017-11-27 14:52:40Z pfg $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/sound.c 358877 2020-03-11 08:24:50Z hselasky $
$FreeBSD: releng/12.3/sys/dev/sound/pcm/vchan.c 326255 2017-11-27 14:52:40Z pfg $
```


----------



## Alex Student (Mar 21, 2022)

Host running MacOS X 10.14

Means that virtualbox is running on MacOS. And in virtualbox freebsd is running. Just to be clear. Thanks for your attention.


----------



## Alex Student (Mar 23, 2022)

Workaround for audio to work

Audio will only work when the virtualbox setting is set to single cpu. More than one cpu will break audio playback. (The same is true for midnightbsd on virtualbox)

Can anyone fix this behavior or point me to a fix. Thanks!!!


----------

