>Synopsis: sndiod no longer does channel duplication as of src/usr.bin/sndiod/dev.c:1.61 >Category: user >Environment: System : OpenBSD 6.6 Details : OpenBSD 6.6-current (GENERIC.MP) #0: Thu Jan 2 22:06:44 EST 2020 peter_at_shoebox-kvm-openbsd-current.foo:/usr/src/sys/arch/amd64/compile/GENERIC.MP Architecture: OpenBSD.amd64 Machine : amd64 >Description: sndiod(8) describes the -j option, which when set causes streams to have their channels duplicated or joined as needed to match the (sub)device's channel count; for example, a mono stream has the single channel duplicated in each channel of a stereo device. As of revision 1.61 of src/usr.bin/sndiod/dev.c this no longer appears to be working; no duplication seems to be done. This revision replaces the following logic (paraphrased, showing the expansion/duplication case only): dev_nch = s->opt->pmax - s->opt->pmin + 1; /* ~snip~ */ if (dev_nch > s->mix.nch) s->mix.expand = dev_nch / s->mix.nch; with this: if (s->mix.cmap.nch > s->mix.nch) s->mix.expand = s->mix.cmap.nch / s->mix.nch; I believe the problem occurs because both s->mix.cmap.nch and s->mix.nch vary with the input stream's channel count. >How-To-Repeat: Playing any mono audio stream with the default sndiod configuration (assuming a stereo device) should demonstrate the issue; an example follows: # Prerequisite: audio device with >=2 channels (headphones help) # Start sndiod (-j on and -c 0:1 are defaults; greater channel # counts still exhibit the problem for me): $ sndiod -ddd -j on -c 0:1 # In another shell, attempt to play a mono stream: $ aucat -c 0:0 -i /dev/random # The result should be white noise in both channels, but white # noise is only heard in the left channel for me. >Fix: Reverting revision 1.61 of src/usr.bin/sndiod/dev.c corrects the problem for me. I do not fully understand the reasoning or the intended behavior; the following is a rough and wild stab at correcting the problem while implementing what I believe the commit message describes: Index: dev.c =================================================================== RCS file: /cvs/src/usr.bin/sndiod/dev.c,v retrieving revision 1.62 diff -u -p -r1.62 dev.c --- dev.c 21 Sep 2019 04:42:46 -0000 1.62 +++ dev.c 4 Jan 2020 01:01:20 -0000 _at_@ -1501,9 +1501,14 @@ dev_mmcloc(struct dev *d, unsigned int o void slot_initconv(struct slot *s) { + unsigned int target_nch; struct dev *d = s->dev; if (s->mode & MODE_PLAY) { + target_nch = d->pchan < (s->opt->pmax - s->opt->pmin + 1) + ? d->pchan + : (s->opt->pmax - s->opt->pmin + 1); + cmap_init(&s->mix.cmap, s->opt->pmin, s->opt->pmin + s->mix.nch - 1, s->opt->pmin, s->opt->pmin + s->mix.nch - 1, _at_@ -1519,14 +1524,18 @@ slot_initconv(struct slot *s) s->mix.join = 1; s->mix.expand = 1; if (s->opt->dup) { - if (s->mix.cmap.nch > s->mix.nch) - s->mix.expand = s->mix.cmap.nch / s->mix.nch; - else if (s->mix.cmap.nch > 0) - s->mix.join = s->mix.nch / s->mix.cmap.nch; + if (target_nch > s->mix.nch) + s->mix.expand = target_nch / s->mix.nch; + else if (s->mix.cmap.nch > target_nch) + s->mix.join = s->mix.nch / target_nch; } } if (s->mode & MODE_RECMASK) { + target_nch = d->rchan < (s->opt->rmax - s->opt->rmin + 1) + ? d->rchan + : (s->opt->pmax - s->opt->pmin + 1); + cmap_init(&s->sub.cmap, 0, ((s->mode & MODE_MON) ? d->pchan : d->rchan) - 1, s->opt->rmin, s->opt->rmax, _at_@ -1542,10 +1551,10 @@ slot_initconv(struct slot *s) s->sub.join = 1; s->sub.expand = 1; if (s->opt->dup) { - if (s->sub.cmap.nch > s->sub.nch) - s->sub.join = s->sub.cmap.nch / s->sub.nch; - else if (s->sub.cmap.nch > 0) - s->sub.expand = s->sub.nch / s->sub.cmap.nch; + if (target_nch > s->sub.nch) + s->sub.join = target_nch / s->sub.nch; + else if (s->sub.nch > target_nch) + s->sub.expand = s->sub.nch / target_nch; } /* dmesg: OpenBSD 6.6-current (GENERIC.MP) #0: Thu Jan 2 22:06:44 EST 2020 peter_at_shoebox-kvm-openbsd-current.foo:/usr/src/sys/arch/amd64/compile/GENERIC.MP real mem = 4177338368 (3983MB) avail mem = 4038266880 (3851MB) mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root bios0 at mainbus0: SMBIOS rev. 2.8 _at_ 0xbffffc60 (17 entries) bios0: vendor SeaBIOS version "rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org" date 04/01/2014 bios0: QEMU Standard PC (i440FX + PIIX, 1996) acpi0 at bios0: ACPI 1.0 acpi0: sleep states S5 acpi0: tables DSDT FACP APIC acpi0: wakeup devices acpitimer0 at acpi0: 3579545 Hz, 24 bits acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat cpu0 at mainbus0: apid 0 (boot processor) cpu0: AMD EPYC Processor (with IBPB), 2994.28 MHz, 17-01-02 cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,CPCTR,FSGSBASE,TSC_ADJUST,BMI1,AVX2,SMEP,BMI2,RDSEED,ADX,SMAP,CLFLUSHOPT,SHA,IBPB,VIRTSSBD,XSAVEOPT,XSAVEC,XGETBV1 cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 16-way L2 cache, 16MB 64b/line 16-way L3 cache cpu0: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped cpu0: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges cpu0: apic clock running at 1000MHz cpu1 at mainbus0: apid 1 (application processor) cpu1: AMD EPYC Processor (with IBPB), 2993.98 MHz, 17-01-02 cpu1: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,CPCTR,FSGSBASE,TSC_ADJUST,BMI1,AVX2,SMEP,BMI2,RDSEED,ADX,SMAP,CLFLUSHOPT,SHA,IBPB,VIRTSSBD,XSAVEOPT,XSAVEC,XGETBV1 cpu1: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 16-way L2 cache, 16MB 64b/line 16-way L3 cache cpu1: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped cpu1: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped cpu2 at mainbus0: apid 2 (application processor) cpu2: AMD EPYC Processor (with IBPB), 2993.98 MHz, 17-01-02 cpu2: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,CPCTR,FSGSBASE,TSC_ADJUST,BMI1,AVX2,SMEP,BMI2,RDSEED,ADX,SMAP,CLFLUSHOPT,SHA,IBPB,VIRTSSBD,XSAVEOPT,XSAVEC,XGETBV1 cpu2: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 16-way L2 cache, 16MB 64b/line 16-way L3 cache cpu2: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped cpu2: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped cpu3 at mainbus0: apid 3 (application processor) cpu3: AMD EPYC Processor (with IBPB), 2994.01 MHz, 17-01-02 cpu3: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,CPCTR,FSGSBASE,TSC_ADJUST,BMI1,AVX2,SMEP,BMI2,RDSEED,ADX,SMAP,CLFLUSHOPT,SHA,IBPB,VIRTSSBD,XSAVEOPT,XSAVEC,XGETBV1 cpu3: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 16-way L2 cache, 16MB 64b/line 16-way L3 cache cpu3: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped cpu3: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped cpu4 at mainbus0: apid 4 (application processor) cpu4: AMD EPYC Processor (with IBPB), 2994.04 MHz, 17-01-02 cpu4: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,CPCTR,FSGSBASE,TSC_ADJUST,BMI1,AVX2,SMEP,BMI2,RDSEED,ADX,SMAP,CLFLUSHOPT,SHA,IBPB,VIRTSSBD,XSAVEOPT,XSAVEC,XGETBV1 cpu4: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 16-way L2 cache, 16MB 64b/line 16-way L3 cache cpu4: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped cpu4: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped cpu5 at mainbus0: apid 5 (application processor) cpu5: AMD EPYC Processor (with IBPB), 2994.04 MHz, 17-01-02 cpu5: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,CPCTR,FSGSBASE,TSC_ADJUST,BMI1,AVX2,SMEP,BMI2,RDSEED,ADX,SMAP,CLFLUSHOPT,SHA,IBPB,VIRTSSBD,XSAVEOPT,XSAVEC,XGETBV1 cpu5: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 16-way L2 cache, 16MB 64b/line 16-way L3 cache cpu5: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped cpu5: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped cpu6 at mainbus0: apid 6 (application processor) cpu6: AMD EPYC Processor (with IBPB), 2994.09 MHz, 17-01-02 cpu6: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,CPCTR,FSGSBASE,TSC_ADJUST,BMI1,AVX2,SMEP,BMI2,RDSEED,ADX,SMAP,CLFLUSHOPT,SHA,IBPB,VIRTSSBD,XSAVEOPT,XSAVEC,XGETBV1 cpu6: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 16-way L2 cache, 16MB 64b/line 16-way L3 cache cpu6: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped cpu6: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped cpu7 at mainbus0: apid 7 (application processor) cpu7: AMD EPYC Processor (with IBPB), 2993.90 MHz, 17-01-02 cpu7: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,CPCTR,FSGSBASE,TSC_ADJUST,BMI1,AVX2,SMEP,BMI2,RDSEED,ADX,SMAP,CLFLUSHOPT,SHA,IBPB,VIRTSSBD,XSAVEOPT,XSAVEC,XGETBV1 cpu7: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 16-way L2 cache, 16MB 64b/line 16-way L3 cache cpu7: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped cpu7: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped ioapic0 at mainbus0: apid 0 pa 0xfec00000, version 11, 24 pins acpiprt0 at acpi0: bus 0 (PCI0) acpicpu0 at acpi0: C1(_at_1 halt!) acpicpu1 at acpi0: C1(_at_1 halt!) acpicpu2 at acpi0: C1(_at_1 halt!) acpicpu3 at acpi0: C1(_at_1 halt!) acpicpu4 at acpi0: C1(_at_1 halt!) acpicpu5 at acpi0: C1(_at_1 halt!) acpicpu6 at acpi0: C1(_at_1 halt!) acpicpu7 at acpi0: C1(_at_1 halt!) "ACPI0006" at acpi0 not configured acpipci0 at acpi0 PCI0: _OSC failed acpicmos0 at acpi0 "PNP0A06" at acpi0 not configured "PNP0A06" at acpi0 not configured "PNP0A06" at acpi0 not configured "QEMU0002" at acpi0 not configured "ACPI0010" at acpi0 not configured pvbus0 at mainbus0: KVM pvclock0 at pvbus0 pci0 at mainbus0 bus 0 pchb0 at pci0 dev 0 function 0 "Intel 82441FX" rev 0x02 pcib0 at pci0 dev 1 function 0 "Intel 82371SB ISA" rev 0x00 pciide0 at pci0 dev 1 function 1 "Intel 82371SB IDE" rev 0x00: DMA, channel 0 wired to compatibility, channel 1 wired to compatibility atapiscsi0 at pciide0 channel 0 drive 1 scsibus1 at atapiscsi0: 2 targets cd0 at scsibus1 targ 0 lun 0: <QEMU, QEMU DVD-ROM, 2.5+> removable cd0(pciide0:0:1): using PIO mode 4, DMA mode 2 pciide0: channel 1 disabled (no drives) piixpm0 at pci0 dev 1 function 3 "Intel 82371AB Power" rev 0x03: apic 0 int 9 iic0 at piixpm0 vga1 at pci0 dev 2 function 0 "Red Hat QXL Video" rev 0x04 wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation) wsdisplay0: screen 1-5 added (80x25, vt100 emulation) virtio0 at pci0 dev 3 function 0 "Qumranet Virtio Network" rev 0x00 vio0 at virtio0: address 52:54:00:8c:24:71 virtio0: msix shared auich0 at pci0 dev 4 function 0 "Intel 82801AA AC97" rev 0x01: apic 0 int 11, ICH ac97: codec id 0x83847600 (SigmaTel STAC9700) audio0 at auich0 uhci0 at pci0 dev 5 function 0 "Intel 82801I USB" rev 0x03: apic 0 int 10 uhci1 at pci0 dev 5 function 1 "Intel 82801I USB" rev 0x03: apic 0 int 10 uhci2 at pci0 dev 5 function 2 "Intel 82801I USB" rev 0x03: apic 0 int 11 ehci0 at pci0 dev 5 function 7 "Intel 82801I USB" rev 0x03: apic 0 int 11 usb0 at ehci0: USB revision 2.0 uhub0 at usb0 configuration 1 interface 0 "Intel EHCI root hub" rev 2.00/1.00 addr 1 virtio1 at pci0 dev 6 function 0 "Qumranet Virtio Console" rev 0x00 virtio1: no matching child driver; not configured virtio2 at pci0 dev 7 function 0 "Qumranet Virtio Storage" rev 0x00 vioblk0 at virtio2 scsibus2 at vioblk0: 2 targets sd0 at scsibus2 targ 0 lun 0: <VirtIO, Block Device, > sd0: 65536MB, 512 bytes/sector, 134217728 sectors virtio2: msix shared virtio3 at pci0 dev 8 function 0 "Qumranet Virtio Memory Balloon" rev 0x00 viomb0 at virtio3 virtio3: apic 0 int 11 virtio4 at pci0 dev 9 function 0 "Qumranet Virtio Network" rev 0x00 vio1 at virtio4: address 52:54:00:4b:99:34 virtio4: msix shared virtio5 at pci0 dev 10 function 0 "Qumranet Virtio Storage" rev 0x00 vioblk1 at virtio5 scsibus3 at vioblk1: 2 targets sd1 at scsibus3 targ 0 lun 0: <VirtIO, Block Device, > sd1: 6144MB, 512 bytes/sector, 12582912 sectors virtio5: msix shared virtio6 at pci0 dev 11 function 0 "Qumranet Virtio Storage" rev 0x00 vioblk2 at virtio6 scsibus4 at vioblk2: 2 targets sd2 at scsibus4 targ 0 lun 0: <VirtIO, Block Device, > sd2: 1024MB, 512 bytes/sector, 2097152 sectors virtio6: msix shared virtio7 at pci0 dev 12 function 0 "Qumranet Virtio RNG" rev 0x00 viornd0 at virtio7 virtio7: apic 0 int 11 isa0 at pcib0 isadma0 at isa0 fdc0 at isa0 port 0x3f0/6 irq 6 drq 2 com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo pckbc0 at isa0 port 0x60/5 irq 1 irq 12 pckbd0 at pckbc0 (kbd slot) wskbd0 at pckbd0: console keyboard, using wsdisplay0 pms0 at pckbc0 (aux slot) wsmouse0 at pms0 mux 0 pcppi0 at isa0 port 0x61 spkr0 at pcppi0 usb1 at uhci0: USB revision 1.0 uhub1 at usb1 configuration 1 interface 0 "Intel UHCI root hub" rev 1.00/1.00 addr 1 usb2 at uhci1: USB revision 1.0 uhub2 at usb2 configuration 1 interface 0 "Intel UHCI root hub" rev 1.00/1.00 addr 1 usb3 at uhci2: USB revision 1.0 uhub3 at usb3 configuration 1 interface 0 "Intel UHCI root hub" rev 1.00/1.00 addr 1 uhidev0 at uhub0 port 3 configuration 1 interface 0 "QEMU QEMU USB Tablet" rev 2.00/0.00 addr 2 uhidev0: iclass 3/0 ums0 at uhidev0: 3 buttons, Z dir wsmouse1 at ums0 mux 0 vscsi0 at root scsibus5 at vscsi0: 256 targets softraid0 at root scsibus6 at softraid0: 256 targets root on sd0a (11567ccd97827ab4.a) swap on sd0b dump on sd0b fd0 at fdc0 drive 1: density unknown usbdevs: Controller /dev/usb0: addr 01: 8086:0000 Intel, EHCI root hub high speed, self powered, config 1, rev 1.00 driver: uhub0 addr 02: 0627:0001 QEMU, QEMU USB Tablet high speed, power 100 mA, config 1, rev 0.00, iSerial 42 driver: uhidev0 Controller /dev/usb1: addr 01: 8086:0000 Intel, UHCI root hub full speed, self powered, config 1, rev 1.00 driver: uhub1 Controller /dev/usb2: addr 01: 8086:0000 Intel, UHCI root hub full speed, self powered, config 1, rev 1.00 driver: uhub2 Controller /dev/usb3: addr 01: 8086:0000 Intel, UHCI root hub full speed, self powered, config 1, rev 1.00 driver: uhub3Received on Sat Jan 04 2020 - 05:59:06 CET
This archive was generated by hypermail 2.3.0 : Tue Aug 09 2022 - 16:23:48 CEST