DaemonForums  

Go Back   DaemonForums > NetBSD > NetBSD General

NetBSD General Other questions regarding NetBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
Old 4th October 2018
Sensucht94's Avatar
Sensucht94 Sensucht94 is offline
Real Name: Paolo Vincenzo Olivo
Shell Scout
 
Join Date: Oct 2017
Location: Rome
Posts: 88
Default

Quote:
Originally Posted by Simurghiyan View Post
A truly fascinating thread with some real surprises --thank you.
But it's nearly 2019, three years after the OP; NetBSD exists still and I'm quite happy with it as a workaday OS. AFAIK, no Code of Conduct dramas, no 'init dramas' ... just a very nice solid system (and to my mind the only probable heir to BSD-lite's 4.4's crown and sceptre). Can easily use it on the pi bramble too.
I completely agree with you; NetBSD is terribly alluring, just so fun, just so: think out of the box, and to my mind the most true to the 386BSD/4.4BSD-lite inheritance.
To add something to this thread, as of 8.0, NetBSD OSS sound subsystem has been heavily reshaped. we now happily have in-kernel mixing, audio(4). It would be one day good on the other hand, to see it completely replaced with a modern OSSv4 implementation like Illumos Boomer

Quote:
Apologies for the necro, if people here object to such things.
I don't think necro is a mustn't here but purposely going off-topic withing the same thread and diverting focus on a different subject surely is (which is not what I think you did here).


EDIT: by the way, welcome
__________________
“Mi casa tendrá dos piernas y mis sueños no tendrán fronteras„
Reply With Quote
Old 1 Week Ago
bashrules's Avatar
bashrules bashrules is offline
Aspiring Unix Greybeard
 
Join Date: Mar 2010
Location: Here
Posts: 56
Default

We have now an in-kernel mixer in NetBSD 9, don't we?

One user can nicely mix various audio streams. That does not work over several users. One user's audio stream blocks other users' audio streams.

Is there a way to mix every user's audio stream?
Reply With Quote
Old 1 Week Ago
Sensucht94's Avatar
Sensucht94 Sensucht94 is offline
Real Name: Paolo Vincenzo Olivo
Shell Scout
 
Join Date: Oct 2017
Location: Rome
Posts: 88
Default

Quote:
Originally Posted by bashrules View Post
We have now an in-kernel mixer in NetBSD 9, don't we?
Yes, as I stated above NetBSD's audio(4) sound subsystem is based on Solaris SunAudio API, which differs from traditional OSSv3 implementations, in the way it just passes one struct to the kernel (see AUDIO_SETINFO ioctl), and provides a simple and well-documented backend (everything on the software side is done the traditional way, which implies opening a pseudodevice /dev/audio – a hardware abstraction layer – for r/w operations), characterized by low-latency, low-cpu-usage and possibly cross-platform (Illumos?). It's been reworked for 8.0 and further improved across the transition towards 9.x to provide kernel built-in hardware-level mixing functionalities, thus substantially differing from other Unices where this task is typically left to userspace-level sound servers (well, you can do mixing on Linux with ALSA plugins like dmix, but it's just 'meh' – complex to set up and adapt to various scenarios, quite resource intensive, poor results, and, as if this wasn't already enough, applications are deprecating it –).

The rework also introduced a nice set of tunable sysctl values (e.g. hw.audioX.blk_ms for latency).
Quote:
One user can nicely mix various audio streams.
Yes! and it works really well. One can easily switch from let's say a MPD client or cmus to a YouTube video on a browser during playback without either of the two taking full control of /dev/audio (which would prevent other applications from using it) or even mix multiple sound sources without the need of a software-level sound server. Patches for Firefox and Seamonkey enabling them to use audio(4) as backend for cubeb have been upstreamed by nia@ last year, and now this is default on pkgsrc. I use Seamonkey with the native API as backend and I must say I'm really satisfied with the results.
Naturally this doesn't prevent anybody from using JACK2, Pulseaudio or Nas in more complex scenarios.
Quote:
That does not work over several users. One user's audio stream blocks other users' audio streams.
Where did you read this? AFAICT multiuser stream was part of the new audio mixer specification; in fact..
Quote:
Is there a way to mix every user's audio stream?
should be as easy as:

Code:
$ sysctl -w hw.audio0.multiuser=1 # (default is '0') 
 
$ echo 'hw.audio0.multiuser=1' >> /etc/sysctl.conf
__________________
“Mi casa tendrá dos piernas y mis sueños no tendrán fronteras„

Last edited by Sensucht94; 1 Week Ago at 07:40 AM. Reason: fix formatting
Reply With Quote
Old 1 Week Ago
bashrules's Avatar
bashrules bashrules is offline
Aspiring Unix Greybeard
 
Join Date: Mar 2010
Location: Here
Posts: 56
Default

Hello Sensucht,

Quote:
Originally Posted by Sensucht94 View Post
Yes, as I stated above NetBSD's audio(4) sound subsystem is based on Solaris SunAudio API, which differs from traditional OSSv3 implementations, in the way it just passes one struct to the kernel (see AUDIO_SETINFO ioctl), and provides a simple and well-documented backend (everything on the software side is done the traditional way, which implies opening a pseudodevice /dev/audio – a hardware abstraction layer – for r/w operations), characterized by low-latency, low-cpu-usage and possibly cross-platform (Illumos?).
Not necessarily an important question, but why don't I see /dev/audio opened?

Code:
# lsof -p `pgrep mpg123`
COMMAND  PID     USER   FD   TYPE DEVICE   SIZE/OFF     NODE NAME
mpg123  3882 bashrules cwd   VDIR   20,0       4096 41027584 /home/bashrules
mpg123  3882 bashrules txt   VREG    0,0     113920  1369211 /usr/local/bin/mpg123
mpg123  3882 bashrules txt   VREG    0,0       8160  1588547 /usr/local/lib/mpg123/output_sun.so
mpg123  3882 bashrules txt   VREG    0,0    2079944  6587525 /lib/libc.so.12.213
mpg123  3882 bashrules txt   VREG    0,0     208424  6587561 /lib/libm.so.0.12
mpg123  3882 bashrules txt   VREG    0,0      56408  1369224 /usr/local/lib/libout123.so.0.2.2
mpg123  3882 bashrules txt   VREG    0,0     206608  1369219 /usr/local/lib/libmpg123.so.0.44.10
mpg123  3882 bashrules txt   VREG    0,0     164176 10465283 /libexec/ld.elf_so
mpg123  3882 bashrules   0u  VCHR    5,5 0t51287932       13 /dev/pts/5
mpg123  3882 bashrules   1u  VCHR    5,5 0t51287932       13 /dev/pts/5
mpg123  3882 bashrules   2u  VCHR    5,5 0t51287932       13 /dev/pts/5
mpg123  3882 bashrules   3r  VREG   11,3   29374214 10469628 beethoven-symphony01.mp3
mpg123  3882 bashrules   4w                                  0xffffe866a7a3bcc0 file struct, ty=5, op=0xffffffff8102b9e0
Quote:
Originally Posted by Sensucht94 View Post
It's been reworked for 8.0 and further improved across the transition towards 9.x to provide kernel built-in hardware-level mixing functionalities, thus substantially differing from other Unices where this task is typically left to userspace-level sound servers (well, you can do mixing on Linux with ALSA plugins like dmix, but it's just 'meh' – complex to set up and adapt to various scenarios, quite resource intensive, poor results, and, as if this wasn't already enough, applications are deprecating it –).
I like the idea of an in-kernel mixer.


Quote:
Originally Posted by Sensucht94 View Post
The rework also introduced a nice set of tunable sysctl values (e.g. hw.audioX.blk_ms for latency). Yes! and it works really well. One can easily switch from let's say a MPD client or cmus to a YouTube video on a browser during playback without either of the two taking full control of /dev/audio (which would prevent other applications from using it) or even mix multiple sound sources without the need of a software-level sound server.
I should have looked for sysctl tunables by myself :-/ Now, multiple users can stream audio at the same time!


Quote:
Originally Posted by Sensucht94 View Post
Patches for Firefox and Seamonkey enabling them to use audio(4) as backend for cubeb have been upstreamed by nia@ last year, and now this is default on pkgsrc. I use Seamonkey with the native API as backend and I must say I'm really satisfied with the results.
I have 3 major sources of audio: mpg123, xmms (ouch) and firefox68. mpg123 and xmms use the sunaudio plugin.

I don't understand the situation in firefox. It's built with --disable-pulseaudio --disable-alsa --with-oss. So it uses oss? It compiles in cubeb_sun.c. So it uses sunaudio?
Reply With Quote
Old 1 Week Ago
bashrules's Avatar
bashrules bashrules is offline
Aspiring Unix Greybeard
 
Join Date: Mar 2010
Location: Here
Posts: 56
Default

One problem at a time. Now that mixing over all users work, I will attack my next problem. Every 10 to 100 min, the sound distorts (hard to describe). I can only recover audio by restarting all audio streams. Is anyone else running into this problem or am I alone?


My hardware:

From dmesg
Code:
hdaudio0 at pci0 dev 27 function 0: HD Audio Controller
hdaudio0: interrupting at msi0 vec 0
hdafg0 at hdaudio0: vendor 14f1 product 50a1
hdafg0: DAC00 2ch: Speaker [Jack]
hdafg0: ADC01 2ch: Mic In [Jack]
hdafg0: ADC02 2ch: Line In [Jack], Mic In [Jack]
hdafg0: DAC03 2ch: HP Out [Jack]
hdafg0: 2ch/2ch 44100Hz 48000Hz 96000Hz PCM16 PCM20 PCM24 AC3
audio0 at hdafg0: playback, capture, full duplex, independent
audio0: slinear_le:16 2ch 48000Hz, blk 4ms for playback
audio0: slinear_le:16 2ch 48000Hz, blk 4ms for recording
spkr1 at audio0: PC Speaker (synthesized)
wsbell at spkr1 not configured
hdafg1 at hdaudio0: vendor 8086 product 2805
hdafg1: DP00 8ch: Digital Out [Jack]
hdafg1: 8ch/0ch 48000Hz PCM16*
From lspci (27=0x1b)

Code:
$ lspci -vvs 0:1b.0
00:1b.0 Audio device: Intel Corporation 6 Series/C200 Series Chipset Family High Definition Audio Controller (rev 05)
	Subsystem: Dell Device 04ed
	Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Interrupt: pin A routed to IRQ 5
	Region 0: Memory at fe400000 (64-bit, non-prefetchable)
	Capabilities: [50] Power Management version 2
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=55mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
		Address: 00000000fee00000  Data: 0070
	Capabilities: [70] Express (v1) Root Complex Integrated Endpoint, MSI 00
		DevCap:	MaxPayload 128 bytes, PhantFunc 0
			ExtTag- RBE-
		DevCtl:	CorrErr- NonFatalErr- FatalErr- UnsupReq-
			RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop+
			MaxPayload 128 bytes, MaxReadReq 128 bytes
		DevSta:	CorrErr- NonFatalErr- FatalErr- UnsupReq- AuxPwr+ TransPend-
	Capabilities: [100 v1] Virtual Channel
		Caps:	LPEVC=0 RefClk=100ns PATEntryBits=1
		Arb:	Fixed- WRR32- WRR64- WRR128-
		Ctrl:	ArbSelect=Fixed
		Status:	InProgress-
		VC0:	Caps:	PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
			Arb:	Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
			Ctrl:	Enable+ ID=0 ArbSelect=Fixed TC/VC=01
			Status:	NegoPending- InProgress-
		VC1:	Caps:	PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
			Arb:	Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
			Ctrl:	Enable+ ID=1 ArbSelect=Fixed TC/VC=22
			Status:	NegoPending- InProgress-
	Capabilities: [130 v1] Root Complex Link
		Desc:	PortNumber=0f ComponentID=00 EltType=Config
		Link0:	Desc:	TargetPort=00 TargetComponent=00 AssocRCRB- LinkType=MemMapped LinkValid+
			Addr:	00000000fed1c000

A starting point is enabling debugging output by recompling the audio driver with these options

Code:
options 	HDAUDIOVERBOSE	# verbose HDAUDIO driver messages
options HDAUDIO_DEBUG
options HDAFG_DEBUG
That would be so simple if the default kernel was built modular and not as a giant blob. Grrrr.

Is there a debugging infra for the netbsd kernel? If not, I'll probably go for the follow-up step with some sort of printk equivalent.
Reply With Quote
Old 5 Days Ago
Sensucht94's Avatar
Sensucht94 Sensucht94 is offline
Real Name: Paolo Vincenzo Olivo
Shell Scout
 
Join Date: Oct 2017
Location: Rome
Posts: 88
Default

Quote:
Originally Posted by bashrules View Post
Not necessarily an important question, but why don't I see /dev/audio opened?
I suppose that's because mixing functionality cannot be disabled and a write lock is taken only under exceptional circumstances, for example when changing audio parameters. Clients must behave accordingly, and never assume that they have exclusive access to the audio device. Check out audio.c and Sun's documentation in this regard.

Have you tried with a NetBSD-native tool like fstat(1)? In my case with ]firefox and mpg123 both playing music at the same time, I get:
Code:
USER     CMD          PID   FD  MOUNT       INUM MODE         SZ|DV R/W NAME
vins     mpg123       436    4* audio   0xfffffc085ef0e490
vins     firefox      526   22* audio   0xfffffc0877cba0c0
Which shows they're both being mounting an audio pseudodevice but neither of the 2 is acquiring an exclusive write lock.
Quote:
I should have looked for sysctl tunables by myself
nevermind, forums exist for a purpose
Quote:
I have 3 major sources of audio: mpg123, xmms (ouch) and firefox68. mpg123 and xmms use the sunaudio plugin.
I don't understand the situation in firefox. It's built with --disable-pulseaudio --disable-alsa --with-oss. So it uses oss? It compiles in cubeb_sun.c. So it uses sunaudio?
It uses SunAudio: just open your browser and check out the built-in about:support URI. In the Media section, Firefox will indicate sun as default audio backend and /dev/audio as default output device, just like on Illumos.

Third-party software developers may refer to it differently in configure scripts depending on how much deep is their understanding of the subtle differences between sound APIs outside the Linux ecosystem; OpenAL-soft for examples refers to it as 'solaris', others may call it 'sun', 'sunaudio' or often 'OSS', implying /dev/audio to be a operating-system-specific OSS variant/derivative.

Indeed, support for legacy applications requiring a traditional OSS interface is provided by an emulation API, refer to ossaudio and the soundcard.h header.
For example QEMU (compiled by default against OSS) VMs can play sound just fine (using either NVMM or HAXM as backend for hw acceleration, otherwise it will feel laggy and sluggish), no sooner will have you pointed QEMU to the right interface (as opposed to the default /dev/dsp for OSS). My little script for Linux VMs on HAXM:
Code:
env QEMU_OSS_DC_DEV=/dev/audio QEMU_OSS_DAC_DEV=/dev/audio qemu-system-x86_64 \
        -boot c --accel hax -m 6G -soundhw hda -display gtk -k it \
        -M pc -cpu Broadwell -smp cores=2,threads=2 -vga std \
        -device virtio-net,netdev=vmnic -netdev user,id=vmnic \
        -drive file=$HOME/VMs/linux.img,if=virtio,cache=none
__________________
“Mi casa tendrá dos piernas y mis sueños no tendrán fronteras„

Last edited by Sensucht94; 4 Days Ago at 12:50 AM.
Reply With Quote
Old 5 Days Ago
Sensucht94's Avatar
Sensucht94 Sensucht94 is offline
Real Name: Paolo Vincenzo Olivo
Shell Scout
 
Join Date: Oct 2017
Location: Rome
Posts: 88
Default

Quote:
Originally Posted by bashrules View Post
One problem at a time. Now that mixing over all users work, I will attack my next problem. Every 10 to 100 min, the sound distorts (hard to describe). I can only recover audio by restarting all audio streams. Is anyone else running into this problem or am I alone?
That must be really bothering. Personally, I haven't run in such an issue so far (tested on 2 dedicated sound cards - a recent Creative SoundBlaster Audigy FX and an old AC'97 SoundBlaster Pro -, as well as onboard hadaudio), nor have seen it reported (but chances are high I would have missed it).
Quote:
A starting point is enabling debugging output by recompling the audio driver with these options
Code:
options     HDAUDIOVERBOSE    # verbose HDAUDIO driver messages
options HDAUDIO_DEBUG
options HDAFG_DEBUG
This looks like a good starting point; I think DDB support should be included too
Quote:
That would be so simple if the default kernel was built modular and not as a giant blob. Grrrr.
That's a possible and surely more modern and versatile approach; for contrast I go as far as building a minimal, monolithic, 9MB-large kernel on amd64 with everything I need built-in (including KASLR) and only it.
Quote:
Is there a debugging infra for the netbsd kernel? If not, I'll probably go for the follow-up step with some sort of printk equivalent.
You may want to look into ktruss(1), or, for a more cutting-edge solution, to the picotrace suite by @kamil, modeled after the ptrace(2) rework introduced in 8.0 release.

By the way, you may have or may have not already noticed that I'm no more than a hobbyist, and it's safe to assume your understanding of C and *nix and debugging is far more advanced than mine; that's why I strongly suggest you open a bug report, ask for support on netbsd-users mailing list; alternatively on #netsbd IRC or comp.unix.bsd.netbsd.misc newsgroup. Last but not least, you may consider opening a new thread here (considered we've gone pretty much off-topic at this point), even though I fear not many will be able to provide help, given the activity of this subforum

Cheers!
__________________
“Mi casa tendrá dos piernas y mis sueños no tendrán fronteras„

Last edited by Sensucht94; 4 Days Ago at 12:23 AM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Underlegend Networks - NetBSD free shell server muflon Off-Topic 1 8th September 2015 01:53 PM
[Link][HowTo] Setting up an 8TB NetBSD file server s0xxx Guides 0 20th August 2011 10:42 AM
Recording sound with external sound card backrow OpenBSD General 5 21st August 2009 08:17 PM
Convertin A Ubuntu ssh/ Samba server to NetBSd FloridaBSD FreeBSD General 6 24th May 2008 09:35 AM


All times are GMT. The time now is 11:28 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick