# Delays in audio playback while using virtual_oss



## greenwho (Jul 25, 2022)

hi, this is my first time using a bsd and everything works, mostly.
i have headphones connected to my pc's front analog, and a microphone connected via usb,
after doing some research i got the two to work together with virtual_oss.

the problem im facing is that, most notibly, pausing or playing audio in vlc takes 2-3 seconds to register, same with changing volume, while skipping to another track does not have this issue.
similarly, game audio in team fortress 2 and counter strike is lagging behind by ~1 second.

otherwise, audio in web browsers is fine, mpv and cmus are both snappy.

while virtual_oss is disabled, audio playback is as expected in all of my programs, unfortunately i cannot use my microphone that way.

here's my virtual_oss config:

```
virtual_oss_dsp="-T /dev/sndstat -i 2 -C 2 -c 2 -r 48000 -b 24 -S -s 512 -P /dev/dsp4 -R /dev/dsp6 -d dsp -t vdsp.ctl"
```

here's my cat /dev/sndstat:

```
Installed devices:
pcm0: <NVIDIA (0x0080) (HDMI/DP 8ch)> (play)
pcm1: <NVIDIA (0x0080) (HDMI/DP 8ch)> (play)
pcm2: <NVIDIA (0x0080) (HDMI/DP 8ch)> (play)
pcm3: <Realtek ALC887 (Rear Analog)> (play/rec)
pcm4: <Realtek ALC887 (Front Analog)> (play/rec) default
pcm5: <Realtek ALC887 (Onboard Digital)> (play)
pcm6: <USB audio> (rec)
Installed devices from userspace:
dsp: <Virtual OSS> (play/rec)
```
tldr; audio in certain applications is sluggish when using virtual_oss


----------



## hselasky@ (Jul 25, 2022)

Hi,

Have you checked what sample rates are supported by your hardware?

Can you try -r 44100 instead of -r 48000 . virtual_oss depends on bit-perfect for low latency audio so to speak.


----------



## greenwho (Jul 25, 2022)

I have tried many configurations already so i cannot really remember all that ive tried.
Just tried your suggestion to be sure, no luck unfortunately.

If there are any commands I can use to check what settings I should be using, that would be great to know.
As is i've gotten pretty tired of browsing man pages and forum posts on the subject and i'm just about out of ideas.


----------



## hselasky@ (Jul 26, 2022)

Have you tried using a USB audio device for both audio IN and OUT?

Your issue sounds very strange, and I think the issue is either in the kernel (PCI audio device) or somewhere else (actual audio hardware). virtual_oss should respect and use the selected buffer size. Can you tell us more about your audio setup? How are things connected and what amplifiers are you using?


----------



## greenwho (Jul 26, 2022)

I've tried using just the front analog ports for both in and out, works fine without virtual_oss, but when on, and configured to use pcm4 for in + out, same problem as mixing with usb.

I thought i had some usb headphones laying around but i couldnt find them for testing, I'll probably buy a usb to aux adapter and test my current headphones with just usb audio.
Though this solution would probably work just fine without virtual_oss, I would still like to figure out whats going on.

My normal setup is headphones on front analog, and a mic connected with usb, nothing else inbetween, probably the most common setup for casual gaming considering I couldnt really find many analog mic's when I looked into it.

I've collected some info on my system below.

pciconf -lv

```
hostb0@pci0:0:0:0:      class=0x060000 rev=0x05 hdr=0x00 vendor=0x8086 device=0x591f subvendor=0x1458 subdevice=0x5000
    vendor     = 'Intel Corporation'
    device     = 'Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers'
    class      = bridge
    subclass   = HOST-PCI
pcib1@pci0:0:1:0:       class=0x060400 rev=0x05 hdr=0x01 vendor=0x8086 device=0x1901 subvendor=0x1458 subdevice=0x5000
    vendor     = 'Intel Corporation'
    device     = '6th-10th Gen Core Processor PCIe Controller (x16)'
    class      = bridge
    subclass   = PCI-PCI
none0@pci0:0:8:0:       class=0x088000 rev=0x00 hdr=0x00 vendor=0x8086 device=0x1911 subvendor=0x1458 subdevice=0x5000
    vendor     = 'Intel Corporation'
    device     = 'Xeon E3-1200 v5/v6 / E3-1500 v5 / 6th/7th/8th Gen Core Processor Gaussian Mixture Model'
    class      = base peripheral
xhci0@pci0:0:20:0:      class=0x0c0330 rev=0x00 hdr=0x00 vendor=0x8086 device=0xa2af subvendor=0x1458 subdevice=0x5007
    vendor     = 'Intel Corporation'
    device     = '200 Series/Z370 Chipset Family USB 3.0 xHCI Controller'
    class      = serial bus
    subclass   = USB
none1@pci0:0:22:0:      class=0x078000 rev=0x00 hdr=0x00 vendor=0x8086 device=0xa2ba subvendor=0x1458 subdevice=0x1c3a
    vendor     = 'Intel Corporation'
    device     = '200 Series PCH CSME HECI'
    class      = simple comms
ahci0@pci0:0:23:0:      class=0x010601 rev=0x00 hdr=0x00 vendor=0x8086 device=0xa282 subvendor=0x1458 subdevice=0xb005
    vendor     = 'Intel Corporation'
    device     = '200 Series PCH SATA controller [AHCI mode]'
    class      = mass storage
    subclass   = SATA
pcib2@pci0:0:27:0:      class=0x060400 rev=0xf0 hdr=0x01 vendor=0x8086 device=0xa2e7 subvendor=0x1458 subdevice=0x5001
    vendor     = 'Intel Corporation'
    device     = '200 Series PCH PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib3@pci0:0:27:2:      class=0x060400 rev=0xf0 hdr=0x01 vendor=0x8086 device=0xa2e9 subvendor=0x1458 subdevice=0x5001
    vendor     = 'Intel Corporation'
    device     = '200 Series PCH PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib4@pci0:0:27:3:      class=0x060400 rev=0xf0 hdr=0x01 vendor=0x8086 device=0xa2ea subvendor=0x1458 subdevice=0x5001
    vendor     = 'Intel Corporation'
    device     = '200 Series PCH PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib5@pci0:0:27:4:      class=0x060400 rev=0xf0 hdr=0x01 vendor=0x8086 device=0xa2eb subvendor=0x1458 subdevice=0x5001
    vendor     = 'Intel Corporation'
    device     = '200 Series PCH PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib6@pci0:0:28:0:      class=0x060400 rev=0xf0 hdr=0x01 vendor=0x8086 device=0xa290 subvendor=0x1458 subdevice=0x5001
    vendor     = 'Intel Corporation'
    device     = '200 Series PCH PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib7@pci0:0:28:2:      class=0x060400 rev=0xf0 hdr=0x01 vendor=0x8086 device=0xa292 subvendor=0x1458 subdevice=0x5001
    vendor     = 'Intel Corporation'
    device     = '200 Series PCH PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib8@pci0:0:28:3:      class=0x060400 rev=0xf0 hdr=0x01 vendor=0x8086 device=0xa293 subvendor=0x1458 subdevice=0x5001
    vendor     = 'Intel Corporation'
    device     = '200 Series PCH PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib9@pci0:0:28:4:      class=0x060400 rev=0xf0 hdr=0x01 vendor=0x8086 device=0xa294 subvendor=0x1458 subdevice=0x5001
    vendor     = 'Intel Corporation'
    device     = '200 Series PCH PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib10@pci0:0:29:0:     class=0x060400 rev=0xf0 hdr=0x01 vendor=0x8086 device=0xa298 subvendor=0x1458 subdevice=0x5001
    vendor     = 'Intel Corporation'
    device     = '200 Series PCH PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
isab0@pci0:0:31:0:      class=0x060100 rev=0x00 hdr=0x00 vendor=0x8086 device=0xa2c5 subvendor=0x1458 subdevice=0x5001
    vendor     = 'Intel Corporation'
    device     = '200 Series PCH LPC Controller (Z270)'
    class      = bridge
    subclass   = PCI-ISA
    none2@pci0:0:31:2:      class=0x058000 rev=0x00 hdr=0x00 vendor=0x8086 device=0xa2a1 subvendor=0x1458 subdevice=0x5001
    vendor     = 'Intel Corporation'
    device     = '200 Series/Z370 Chipset Family Power Management Controller'
    class      = memory
hdac1@pci0:0:31:3:      class=0x040300 rev=0x00 hdr=0x00 vendor=0x8086 device=0xa2f0 subvendor=0x1458 subdevice=0xa182
    vendor     = 'Intel Corporation'
    device     = '200 Series PCH HD Audio'
    class      = multimedia
    subclass   = HDA
ichsmb0@pci0:0:31:4:    class=0x0c0500 rev=0x00 hdr=0x00 vendor=0x8086 device=0xa2a3 subvendor=0x1458 subdevice=0x5001
    vendor     = 'Intel Corporation'
    device     = '200 Series/Z370 Chipset Family SMBus Controller'
    class      = serial bus
    subclass   = SMBus
vgapci0@pci0:1:0:0:     class=0x030000 rev=0xa1 hdr=0x00 vendor=0x10de device=0x1c82 subvendor=0x3842 subdevice=0x6255
    vendor     = 'NVIDIA Corporation'
    device     = 'GP107 [GeForce GTX 1050 Ti]'
    class      = display
    subclass   = VGA
hdac0@pci0:1:0:1:       class=0x040300 rev=0xa1 hdr=0x00 vendor=0x10de device=0x0fb9 subvendor=0x3842 subdevice=0x6255
    vendor     = 'NVIDIA Corporation'
    device     = 'GP107GL High Definition Audio Controller'
    class      = multimedia
    subclass   = HDA
re0@pci0:7:0:0: class=0x020000 rev=0x0c hdr=0x00 vendor=0x10ec device=0x8168 subvendor=0x1458 subdevice=0xe000
    vendor     = 'Realtek Semiconductor Co., Ltd.'
    device     = 'RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller'
    class      = network
    subclass   = ethernet
nvme0@pci0:10:0:0:      class=0x010802 rev=0x00 hdr=0x00 vendor=0x144d device=0xa809 subvendor=0x144d subdevice=0xa801
    vendor     = 'Samsung Electronics Co Ltd'
    device     = 'NVMe SSD Controller 980'
    class      = mass storage
    subclass   = NVM
```


----------

