NetBSD Problem Report #55687
From leot@netbsd.org Tue Sep 29 17:33:36 2020
Return-Path: <leot@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 0519F1A9217
for <gnats-bugs@gnats.NetBSD.org>; Tue, 29 Sep 2020 17:33:36 +0000 (UTC)
Message-Id: <20200929173335.B978A84EE4@mail.netbsd.org>
Date: Tue, 29 Sep 2020 17:33:35 +0000 (UTC)
From: Leonardo Taccari <leot@NetBSD.org>
Reply-To: leot@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: Slowed down/noisy recording with audio(4) (probably incorrect sample rate)
X-Send-Pr-Version: 3.95
>Number: 55687
>Category: kern
>Synopsis: Slowed down and noisy recording with audio(4) (probably incorrect sample rate)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Sep 29 17:35:00 +0000 2020
>Last-Modified: Fri Oct 02 12:15:01 +0000 2020
>Originator: Leonardo Taccari
>Release: NetBSD 9.99.64
>Organization:
The NetBSD Foundation
>Environment:
System: NetBSD boh 9.99.64 NetBSD 9.99.64 (GENERIC) #0: Sat Jun 6 14:26:08 CEST 2020 leot@abacus:/tmp/obj/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
Relevant dmesg output:
hdaudio0 at pci0 dev 3 function 0: HD Audio Controller
hdaudio0: interrupting at msi0 vec 0
hdaudio0: HDA ver. 1.0, OSS 2, ISS 0, BSS 0, SDO 1, 64-bit
hdaudio0: autoconfiguration error: RIRB timeout
hdaudio0: autoconfiguration error: RIRB timeout
[...]
hdaudio1 at pci0 dev 27 function 0: HD Audio Controller
hdaudio1: interrupting at msi1 vec 0
hdaudio1: HDA ver. 1.0, OSS 4, ISS 4, BSS 0, SDO 1, 64-bit
hdafg0 at hdaudio1: vendor 14f1 product 510f
hdafg0: DAC00 2ch: Speaker [Built-In]
hdafg0: ADC01 2ch: Mic In [Built-In]
hdafg0: ADC02 2ch: Mic In [Jack]
hdafg0: DAC03 2ch: HP Out [Jack]
hdafg0: 2ch/2ch 44100Hz 48000Hz 96000Hz PCM16 PCM20 PCM24
audio0 at hdafg0: playback, capture, full duplex, independent
audio0: slinear_le:16 2ch 48000Hz, blk 1920 bytes (10ms) for playback
audio0: slinear_le:16 2ch 48000Hz, blk 1920 bytes (10ms) for recording
spkr0 at audio0: PC Speaker (synthesized)
Output of `mixerctl -a' used when recording:
outputs.master=0,0
outputs.master.mute=off
outputs.master2=159,159
outputs.master2.mute=off
inputs.beep=252,252
inputs.reclvl=222,222
inputs.reclvl.mute=off
record.mic=170,170
inputs.reclvl2=170,170
outputs.dacsel=DAC00,DAC03
record.source=ADC01,ADC02
Output of `audiocfg list':
0: [*] audio0 @ hdafg0: Conexant product 510f
playback: 2ch, 48000Hz
record: 2ch, 48000Hz
(PR) slinear_le 16/16, 2ch, { 44100, 48000, 96000 }
(PR) slinear_le 20/32, 2ch, { 44100, 48000, 96000 }
(PR) slinear_le 24/32, 2ch, { 44100, 48000, 96000 }
Output of `audioctl -a':
name=Conexant
version=product 510f
config=01h
encodings=mulaw:8*,alaw:8*,slinear:8*,ulinear:8*,slinear_le:16*,ulinear_le:16*,slinear_be:16*,ulinear_be:16*,slinear_le:32*,ulinear_le:32*,slinear_be:32*,ulinear_be:32*
properties=full_duplex,mmap,independent
full_duplex=1
fullduplex=1
blocksize=2048
hiwat=32
lowat=24
monitor_gain=0
mode=
play.rate=48000
play.channels=2
play.precision=16
play.encoding=slinear_le
play.gain=0
play.balance=32
play.port=0x0
play.avail_ports=0x0
play.seek=0
play.samples=0
play.eof=0
play.pause=0
play.error=0
play.waiting=0
play.open=0
play.active=1
play.buffer_size=65536
record.rate=8000
record.channels=1
record.precision=8
record.encoding=mulaw
record.gain=0
record.balance=32
record.port=0x0
record.avail_ports=0x0
record.seek=0
record.samples=0
record.eof=0
record.pause=0
record.error=0
record.waiting=0
record.open=0
record.active=0
record.buffer_size=65536
record.errors=0
Output of `sysctl -a':
hw.audio0.blk_ms = 10
hw.audio0.multiuser = 0
>Description:
Recording audio seems noisy/slowed down when using audiorecord(1) or
www/firefox78 (78.3.0).
A simpler way to reproduce it present later.
>How-To-Repeat:
When recording audio via:
% audiorecord -F wav -t 2 -e linear -P 16 -s 48000 -c 2 test_linear.wav
...and saying a couple of times `test test test' the voice seems slowed
down circa 2x and it's grave/noisy.
The recorded file can be played without any noise (so cleanly) via:
% audioplay -f -e linear -c 2 -s 96000 -P 16 test_linear.wav
An example recording of me doing that is at:
https://www.NetBSD.org/~leot/tmp/test_linear.wav
>Fix:
N/A, sorry!
>Audit-Trail:
From: Leonardo Taccari <leot@NetBSD.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: kern/55687: Slowed down/noisy recording with audio(4) (probably incorrect sample rate)
Date: Tue, 29 Sep 2020 19:37:57 +0200
Leonardo Taccari writes:
> [...]
> >How-To-Repeat:
> When recording audio via:
>
> % audiorecord -F wav -t 2 -e linear -P 16 -s 48000 -c 2 test_linear.wav
>
> ...and saying a couple of times `test test test' the voice seems slowed
> down circa 2x and it's grave/noisy.
>
> The recorded file can be played without any noise (so cleanly) via:
>
> % audioplay -f -e linear -c 2 -s 96000 -P 16 test_linear.wav
>
> [...]
Forgot to say in the PR but thanks a lot to <nat> who helped a lot and
spotted that and <jmcneill> and <jakllsch> for helping!
From: Tetsuya Isaki <isaki@pastel-flower.jp>
To: gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org,
gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org
Subject: Re: kern/55687: Slowed down/noisy recording with audio(4) (probably incorrect sample rate)
Date: Thu, 01 Oct 2020 21:10:09 +0900
Thank you for detailed report.
This uploaded WAV file appears to have four channels data like as
L,R,0,0, L,R,0,0, ... in 48kHz, despite WAV file header says two
channels 48kHz.
I found that this is because of record source has two inputs at
the same time on mixerctl. You will solve it by selecting one
recording source:
# mixerctl -w record.source={ADC01|ADC02}
I could reproduce it on NetBSD 9.0 and 7.1 hdafg on my laptop,
so this is not a new problem.
(And I agree that mixerctl is not user-friendly...)
For details:
In device attachment phase, MD driver(hdafg) reports supported
hardware formats (including number of channels or frequencies)
to MI audio layer. MI layer and MD driver agree it with each
other. In this case, MI and MD agree to record on stereo 48kHz.
But since there are two recording sources on mixerctl, hdafg
actually transferred four channels 48kHz of data during recording.
Although I don't know that what benefit or functionality does
multiple record source selection have, at least hdafg should be
fixed not to transfer unreported (and not agreed each other)
format data.
I'm not sure but... should hdafg (or mixerctl?) be able to select
only one record source at the same time?
Thanks,
---
Tetsuya Isaki <isaki@pastel-flower.jp / isaki@NetBSD.org>
From: Leonardo Taccari <leot@NetBSD.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: kern/55687: Slowed down/noisy recording with audio(4) (probably incorrect sample rate)
Date: Thu, 01 Oct 2020 14:59:14 +0200
Hello Tetsuya,
Tetsuya Isaki writes:
> [...]
> Thank you for detailed report.
>
> This uploaded WAV file appears to have four channels data like as
> L,R,0,0, L,R,0,0, ... in 48kHz, despite WAV file header says two
> channels 48kHz.
>
> I found that this is because of record source has two inputs at
> the same time on mixerctl. You will solve it by selecting one
> recording source:
>
> # mixerctl -w record.source={ADC01|ADC02}
>
> I could reproduce it on NetBSD 9.0 and 7.1 hdafg on my laptop,
> so this is not a new problem.
> (And I agree that mixerctl is not user-friendly...)
> [...]
Wow, I can confirm that doing `mixerctl -w record.source=ADC01' fixes
this problem! Thank you very much!
On all my machines I usually have `mixerctl=yes' and
`mixerctl_mixers="mixer0"' in rc.conf so I will probably forget
about it.
Should we leave this PR open and maybe adjust/add Subject: a short
summary of your analysis and/or to possibly help if other folks hit this
problem? (In any case feel free to possibly update the State:/Subject:
or any other possible PR fields)
Thank you very much again Tetsuya!
From: Jared McNeill <jmcneill@invisible.ca>
To: gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
leot@NetBSD.org
Subject: Re: kern/55687: Slowed down/noisy recording with audio(4) (probably
incorrect sample rate)
Date: Thu, 1 Oct 2020 12:19:02 -0300 (ADT)
On Thu, 1 Oct 2020, Tetsuya Isaki wrote:
> But since there are two recording sources on mixerctl, hdafg
> actually transferred four channels 48kHz of data during recording.
> Although I don't know that what benefit or functionality does
> multiple record source selection have, at least hdafg should be
> fixed not to transfer unreported (and not agreed each other)
> format data.
>
> I'm not sure but... should hdafg (or mixerctl?) be able to select
> only one record source at the same time?
For > 2 channel operation, an HD audio association includes more than one
DAC or ADC (each DAC or ADC widget can handle 1 or 2 channels). So being
able to select more than one record source is required.
Cheers,
Jared
From: Tetsuya Isaki <isaki@pastel-flower.jp>
To: Jared McNeill <jmcneill@invisible.ca>, gnats-bugs@netbsd.org,
kern-bug-people@netbsd.org,
gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org
Cc:
Subject: Re: kern/55687: Slowed down/noisy recording with audio(4) (probably incorrect sample rate)
Date: Fri, 02 Oct 2020 21:11:38 +0900
At Thu, 1 Oct 2020 12:19:02 -0300 (ADT),
Jared McNeill wrote:
> > I'm not sure but... should hdafg (or mixerctl?) be able to select
> > only one record source at the same time?
>
> For > 2 channel operation, an HD audio association includes more than one
> DAC or ADC (each DAC or ADC widget can handle 1 or 2 channels). So being
> able to select more than one record source is required.
Ah, I see. Thank you for explanation.
---
Tetsuya Isaki <isaki@pastel-flower.jp / isaki@NetBSD.org>
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.