Re: sndioctl(1) randomly fails to modify controls in USB audio device

2023-03-27 Thread Walter Alejandro Iglesias
Some other data you ask in the FAQ:

  # cat > /dev/audio1 < /dev/zero &
  [1] 98479
  # audioctl play.{bytes,errors}
  play.bytes=0
  play.errors=0
  # audioctl play.{bytes,errors}
  play.bytes=0
  play.errors=0

  # mixerctl -v -f /dev/audioctl1   
  outputs.dac=254,254 
  outputs.dac_mute=on  [ off on ]
  record.enable=sysctl  [ off on sysctl ]


-- 
Walter



sndioctl(1) randomly fails to modify controls in USB audio device

2023-03-27 Thread Walter Alejandro Iglesias
Hello,

Recently I bought a pair of external speakers for my desktop PC.  I
overlooked that they don't have a jack to connect them to the internal
sound card, they work alone through a USB port.

  $ dmesg
  [...]
  uaudio0 at uhub2 port 1 configuration 1 interface 1 "Ten X Technology, Inc. 
USB  AUDIO" rev 1.10/1.87 addr 2
  uaudio0: class v1, full-speed, sync, channels: 2 play, 0 rec, 3 ctls
  audio1 at uaudio0
  uhidev0 at uhub2 port 1 configuration 1 interface 2 "Ten X Technology, Inc. 
USB  AUDIO" rev 1.10/1.87 addr 2
  uhidev0: iclass 3/0
  [...]

  $ usbdevs | grep AUDIO
  addr 02: 1130:1620 Ten X Technology, Inc., USB  AUDIO

I followed the instructions in Multimedia FAQ and I got them working:

  $ grep sndiod /etc/rc.conf.local
  sndiod_flags=-f rsnd/0 -F rsnd/1
  
  $ sndioctl
  output.level=0.996
  output.mute=0
  server.device=1

... but modifying level and mute outputs using sndioctl(1) doesn't work
very well.  If I ran the following commands one after the other:

  $ sndioctl output.level
  output.level=0.996
  $ sndioctl output.level=-0.05
  output.level=0.945
  $ sndioctl output.level
  output.level=0.996
  $ sndioctl output.level=-0.05
  output.level=0.953
  $ sndioctl output.level
  output.level=0.996

... you see that the command initially reports that output.level was
modified, but when you check it again it wasn't (and you don't hear any
change in the level of sound).  With the mute control the communication
isn't fine either, after toggling it two or three times sndioctl reports
"no such control" and you have to restart sndiod(8) to make output.mute
appear again.

  $ sndioctl output.mute=!
  output.mute=1
  $ sndioctl output.mute=!
  output.mute=0
  $ sndioctl output.mute=!
  output.mute=1
  $ sndioctl output.mute=!
  output.mute: no such control


I've tried using mixerctl(8) to modify volume and mute and happens the same.


  ***


OpenBSD 7.3 (GENERIC.MP) #1123: Tue Mar 21 07:11:25 MDT 2023
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 4135260160 (3943MB)
avail mem = 3990536192 (3805MB)
random: good seed from bootblocks
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xeb920 (70 entries)
bios0: vendor Hewlett-Packard version "786E1 v01.16" date 08/17/2011
bios0: Hewlett-Packard HP Compaq dc7700 Convertible Minitower
acpi0 at bios0: ACPI 1.0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP APIC ASF! MCFG TCPA SLIC HPET
acpi0: wakeup devices PCI0(S4) COM1(S4) PEG1(S4) IGBE(S4) PCX1(S4) PCX2(S4) 
HUB_(S4) USB1(S3) USB2(S3) USB3(S3) USB4(S3) USB5(S3) EUS1(S3) EUS2(S3) PBTN(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM)2 CPU 4300 @ 1.80GHz, 1795.55 MHz, 06-0f-02
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,EST,TM2,SSSE3,CX16,xTPR,PDCM,NXE,LONG,LAHF,PERF,SENSOR,MELTDOWN
cpu0: 32KB 64b/line 8-way D-cache, 32KB 64b/line 8-way I-cache, 2MB 64b/line 
8-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 199MHz
cpu0: mwait min=64, max=64, C-substates=0.2, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM)2 CPU 4300 @ 1.80GHz, 1795.67 MHz, 06-0f-02
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,EST,TM2,SSSE3,CX16,xTPR,PDCM,NXE,LONG,LAHF,PERF,SENSOR,MELTDOWN
cpu1: 32KB 64b/line 8-way D-cache, 32KB 64b/line 8-way I-cache, 2MB 64b/line 
8-way L2 cache
cpu1: smt 0, core 1, package 0
ioapic0 at mainbus0: apid 1 pa 0xfec0, version 20, 24 pins, remapped
acpimcfg0 at acpi0
acpimcfg0: addr 0xf400, bus 0-63
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (PEG1)
acpiprt2 at acpi0: bus 32 (PCX1)
acpiprt3 at acpi0: bus -1 (PCX2)
acpiprt4 at acpi0: bus 7 (HUB_)
acpipci0 at acpi0 PCI0: 0x 0x0011 0x0001
acpicmos0 at acpi0
com0 at acpi0 COM1 addr 0x3f8/0x8 irq 4: ns16550a, 16 byte fifo
"PNP0003" at acpi0 not configured
acpibtn0 at acpi0: PBTN
"PNP0C14" at acpi0 not configured
acpicpu0 at acpi0: C1(@1 halt!), PSS
acpicpu1 at acpi0: C1(@1 halt!), PSS
cpu0: Enhanced SpeedStep 1795 MHz: speeds: 1800, 1200 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel 82Q965 Host" rev 0x02
inteldrm0 at pci0 dev 2 function 0 "Intel 82Q965 Video" rev 0x02
drm0 at inteldrm0
intagp0 at inteldrm0
agp0 at intagp0: aperture at 0xe000, size 0x1000
inteldrm0: apic 1 int 16, I965G, gen 4
"Intel 82Q965 HECI" rev 0x02 at pci0 dev 3 function 0 not configured
em0 at pci0 dev 25 function 0 "Intel ICH8 IGP AMT" rev 0x02: apic 1 int 19, 
address 00:0f:fe:77:4f:df
uhci0 at pci0 dev 26 function 0 "Intel 82801H USB" rev 0x02: apic 1 int 

an addition to VIS(3)

2023-03-27 Thread pjp
>Synopsis:  getting a dig compatible vis is hard
>Category:  library
>Environment:
System  : OpenBSD 7.2
Details : OpenBSD 7.2 (GENERIC.MP) #2: Thu Nov 24 23:53:03 MST 2022
 
r...@syspatch-72-arm64.openbsd.org:/usr/src/sys/arch/arm64/compile/GENERIC.MP

Architecture: OpenBSD.arm64
Machine : arm64
>Description:
I'm trying to vis my program and make an output like dig(1) but it
doesn't work because it's like an octal number \027 but in decimal.  This would
make it easy for my dns program to use vis.  I have made a patch to OpenBSD 7.2
which I checked that the versions are right.  This seems like something I tried
to get committed before but my research with google didn't find it.
>How-To-Repeat:
>From dig:

;; QUESTION SECTION:
;mapping33.dtschland.eu.IN  TXT

;; ANSWER SECTION:
mapping33.dtschland.eu. 72891   IN  TXT "\027test"

notice it took me some understanding that in dig \000 is decimal after RFC 1035
section 5.1.
>Fix:
I have made patches for your consideration.  I can only hope it will be included
for 7.4.  It's not tested but if put in snapshots I'll dedicate a machine to
testing this.

Index: include/vis.h
===
RCS file: /cvs/src/include/vis.h,v
retrieving revision 1.15
diff -u -p -r1.15 vis.h
--- include/vis.h   20 Jul 2015 01:52:27 -  1.15
+++ include/vis.h   27 Mar 2023 12:40:06 -
@@ -52,6 +52,7 @@
 #defineVIS_SAFE0x20/* only encode "unsafe" characters */
 #defineVIS_DQ  0x200   /* backslash-escape double quotes */
 #defineVIS_ALL 0x400   /* encode all characters */
+#defineVIS_DNS 0x800   /* for RFC 1035 section 5.1 escapes */
 
 /*
  * other
Index: lib/libc/gen/vis.3
===
RCS file: /cvs/src/lib/libc/gen/vis.3,v
retrieving revision 1.37
diff -u -p -r1.37 vis.3
--- lib/libc/gen/vis.3  30 Jul 2022 07:19:30 -  1.37
+++ lib/libc/gen/vis.3  27 Mar 2023 12:40:06 -
@@ -27,7 +27,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd $Mdocdate: July 30 2022 $
+.Dd $Mdocdate: March 27 2023 $
 .Dt VIS 3
 .Os
 .Sh NAME
@@ -285,6 +285,11 @@ The form is
 where
 .Ar d
 represents an octal digit.
+.It Dv VIS_DNS
+Use a three digit decimal sequence like the command 
+.Xr dig 1
+which is a backslash followed by three decimal letters.  This coincides with
+RFC 1035 section 5.1.
 .El
 .Pp
 There is one additional flag,
Index: lib/libc/gen/vis.c
===
RCS file: /cvs/src/lib/libc/gen/vis.c,v
retrieving revision 1.26
diff -u -p -r1.26 vis.c
--- lib/libc/gen/vis.c  4 May 2022 18:57:50 -   1.26
+++ lib/libc/gen/vis.c  27 Mar 2023 12:40:06 -
@@ -83,6 +83,7 @@ vis(char *dst, int c, int flag, int next
int vis_cstyle = flag & VIS_CSTYLE;
int vis_octal = flag & VIS_OCTAL;
int vis_glob = flag & VIS_GLOB;
+   int vis_dns = flag & VIS_DNS;
 
if (isvisible(c, flag)) {
if ((c == '"' && vis_dq) ||
@@ -134,6 +135,17 @@ vis(char *dst, int c, int flag, int next
*dst++ = '0';
*dst++ = '0';
}
+   goto done;
+   }
+   }
+   if (vis_dns) {
+   /* reversed from /usr/src/usr.bin/dig/lib/dns/name.c */
+   if (c < 0x20 || c > 0x7f) {
+   *dst++ = '\\';
+   *dst++ = 0x30 + ((c / 100) % 10);
+   *dst++ = 0x30 + ((c / 10) % 10);
+   *dst++ = 0x30 + (c % 10);
+
goto done;
}
}


dmesg:
my box hasn't changed yet.