Home | History | Annotate | only in /src/lib/libossaudio
History log of /src/lib/libossaudio
RevisionDateAuthorComments
 1.11 08-Jun-2021  nia ossaudio(3): refactor library into separate files
 1.10 05-May-2012  christos fix typo, WARNS=5
 1.9 21-Mar-2012  matt These directories don't handle WARNS=5
 1.8 12-Mar-2009  wiz branches: 1.8.6; 1.8.8;
Remove USETBL, now that man page does not need tbl any longer.
 1.7 03-Feb-2009  jmcneill branches: 1.7.2;
Add a table that describes the mappings from native audio mixer names
to their OSS equivalents.
 1.6 18-Nov-2003  grant drop whitespace
 1.5 13-Apr-1998  lukem use CPPFLAGS not CFLAGS
 1.4 07-Nov-1997  mikel back out last change
 1.3 01-Nov-1997  mikel don't build shared library
 1.2 19-Oct-1997  thorpej Install the "soundcard.h" include file in /usr/include, because:
- The documentation says <soundcard.h>, and
- You can't install an include into /usr/include/sys, because the user
might be using "symlinks" for the sys includes.
 1.1 16-Oct-1997  augustss Initial version of a user level emulation of the OSS audio API.
Useful for compiling Linux audio programs.
 1.7.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.8.8.1 07-May-2012  riz Apply patches (requested by christos in ticket #225):
lib/libossaudio/Makefile patch
lib/libossaudio/ossaudio.c patch
lib/libossaudio/soundcard.h patch

Fix compilation of ioctls without the 3rd argument in ossaudio.
[christos, ticket #225]
 1.8.6.2 23-May-2012  yamt sync with head.
 1.8.6.1 17-Apr-2012  yamt sync with head
 1.1 02-Apr-2013  agc branches: 1.1.2;
file Version.map was initially added on branch agc-symver.
 1.1.2.1 02-Apr-2013  agc add symbol versioning info for:

libcrypt
libcurses
libedit
libmenu
libossaudio
libposix
libskey
 1.1 08-Jun-2021  nia ossaudio(3): refactor library into separate files
 1.1 08-Jun-2021  nia ossaudio(3): refactor library into separate files
 1.1 08-Jun-2021  nia ossaudio(3): refactor library into separate files
 1.1 08-Jun-2021  nia ossaudio(3): refactor library into separate files
 1.2 09-Jun-2021  nia ossaudio(3): continue getting capabilities if AUDIO_GETFORMAT fails

we want this to work on mixer devices too
 1.1 08-Jun-2021  nia ossaudio(3): refactor library into separate files
 1.2 08-Jun-2021  nia ossaudio(3): nested switch statements are hard to read, refactor
 1.1 08-Jun-2021  nia ossaudio(3): refactor library into separate files
 1.1 08-Jun-2021  nia ossaudio(3): refactor library into separate files
 1.28 04-Dec-2022  uwe lib: Mark up error names in man pages with .Er
 1.27 20-Oct-2020  wiz Remove trailing whitespace.
 1.26 20-Oct-2020  nia ossaudio.3: Bump date
 1.25 20-Oct-2020  nia ossaudio(3): Turn BUGS section into a list of potential compat issues
 1.24 17-Oct-2020  wiz Use Fx and Nx. End Rs block. Remove trailing whitespace.
Remove unnecessary Pp.
 1.23 16-Oct-2020  nia ossaudio.3: note this is most/all of ossv3 and some of ossv4
 1.22 16-Oct-2020  nia ossaudio.3: Sort sections.
 1.21 16-Oct-2020  nia ossaudio.3: More information about the history and status of this API
 1.20 12-Mar-2009  joerg Use .Bl -column instead of tbl(1) for the device mapping list.
OK jmcneill@
 1.19 03-Feb-2009  jmcneill branches: 1.19.2;
Bump date for previous.
 1.18 03-Feb-2009  jmcneill Add a table that describes the mappings from native audio mixer names
to their OSS equivalents.
 1.17 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.16 16-Apr-2003  wiz branches: 1.16.30;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.15 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.14 20-Feb-2002  wiz Improve markup, sort sections.
 1.13 07-Feb-2002  ross Generate <>& symbolically.
 1.12 19-May-2001  jdolecek Use EAGAIN instead of EWOULDBLOCK. The actual numeric value is
same, but EAGAIN is the posixly correct name.
Addresses misc/12960.
 1.11 05-Jul-2000  msaitoh remove extra period in SEE ALL section
 1.10 02-Jul-1999  simonb More trailing white space.
 1.9 13-Apr-1999  augustss Make copyrights conform.
 1.8 22-Mar-1999  garbled branches: 1.8.2;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.7 12-Aug-1998  augustss Xref midi(4).
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 29-Oct-1997  augustss Fix a serious emulation bug.
Add some missing #defines.
Add a little more documentation.
 1.4 26-Oct-1997  augustss Add some missing defines and add history to man page.
 1.3 16-Oct-1997  augustss branches: 1.3.2;
Remove a copied line.
 1.2 16-Oct-1997  augustss Add some bugs to the man page.
 1.1 16-Oct-1997  augustss Initial version of a user level emulation of the OSS audio API.
Useful for compiling Linux audio programs.
 1.3.2.1 29-Oct-1997  mellon Pull rev 1.4 and 1.5 up from trunk (augustss)
 1.8.2.1 16-Apr-1999  augustss Make a bunch of copyright headers conform to the standard.
Pullup approved by Perry.
 1.16.30.1 18-May-2008  yamt sync with head.
 1.19.2.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.69 08-Jun-2021  nia ossaudio(3): refactor library into separate files
 1.68 09-May-2021  nia ossaudio: Set handle on OSSv4 mixer devices
 1.67 09-May-2021  nia libossaudio: Various OSSv4 fixes to allow reference programs to compile

- Define various new AFMT_*. These are not returned as supported
formats by SNDCTL_DSP_GETFMTS, because it would be very silly to
have Vorbis in the kernel.

- Implement PLAYTGT and RECSRC. For each NetBSD audio device
we only return one playback and recording source, "primary".

- Return preferred channel configuration in capabilities.
Either DSP_CH_STEREO, DSP_CH_MONO, or DSP_CH_MULTI
depending on the current hardware format.

- SNDCTL_DSP_HALT_* simply flushes the audio device.
 1.66 15-Mar-2021  nia branches: 1.66.2;
ossv4 mixer API: be extra careful with the inputs to AUDIO_MIXER_READ.

some drivers (not hdaudio(4), but uaudio(4), eap(4), sb(4), various other
old cards) will return error if a AUDIO_MIXER_VALUE is requested and the
number of channels is not specified as input. this is not documented as
well as it should be, unfortunately.
 1.65 19-Dec-2020  nia ossaudio(3): Do not reuse results from AUDIO_GETBUFINFO in SETINFO

Should help PR 55876.
 1.64 13-Nov-2020  nia ossaudio(3): Clone some useful behaviour from the Solaris kernel

Both SNDCTL_DSP_SPEED and SNDCTL_DSP_CHANNELS support a special value
0 to "query the configured value without changing it". In our case,
this actually means setting and querying the hardware rate.

I don't know if OSSv3 or FreeBSD or other implementations also do this.
But it seems safe and sensible to support.
 1.63 04-Nov-2020  nia ossaudio(3): Set errno and return -1 rather than returning errno.
 1.62 03-Nov-2020  nia ossaudio(3): Reduce code duplication for querying capabilities
 1.61 03-Nov-2020  nia ossaudio(3): Return device playback and capture capabilities in GETCAPS
 1.60 03-Nov-2020  nia ossaudio(3): return correctly initialized return value in unlikely
error case. pointed out by tnn.
 1.59 30-Oct-2020  nia ossaudio(3): Simplify setting rate (try to supply the nearest one possible)
 1.58 24-Oct-2020  roy libossaudio: return newfd here as we return retval elsewhere
 1.57 23-Oct-2020  wiz Fix typo in comment.
 1.56 23-Oct-2020  nia ossaudio(3): Add an implementation of SNDCTL_CARDINFO

Correct some of the counts returned by SNDCTL_SYSINFO so this works.
 1.55 22-Oct-2020  nia ossaudio(3): This is not compat_linux
 1.54 20-Oct-2020  nia ossaudio(3): Add SNDCTL_AUDIOINFO_EX as an alias of SNDCTL_AUDIOINFO
 1.53 20-Oct-2020  nia ossaudio(3): Plug a fd leak in the new mixer API
 1.52 19-Oct-2020  nia ossaudio(3): add some no-op defines for ossv4 compat.
 1.51 19-Oct-2020  nia ossaudio(3): these ioctls need to return samples, not bytes
 1.50 19-Oct-2020  nia ossaudio(3): Add SNDCTL_DSP_CURRENT_(I|O)PTR

In OSSv4 these are supposed to avoid the wrapping problems with the
older GET(I|O)PTR ioctls but we don't quite get the same benefit here.

XXX: We could probably fake it by maintaining some state in-between calls.
 1.49 17-Oct-2020  nia ossaudio(3): Add initial support for the OSSv4.1 Mixer API

One or two calls from this API were supported previously and have been
moved to the correct place.

Mapping the controls correctly is a difficult task. There is a define
hidden in the OSS headers that would allow an AUDIO_MIXER_SET control
to be represented perfectly, but it seems to _only_ exist there, and
no software supports it. So for now only one member of a set can be
set at a time - unfortunate. I've hidden code that should unlock
doing this the proper way under #notyet.

I'm not too happy with the way this code is managing file descriptors.
Currently it has to open a new fd for each ioctl due to OSSv4 deciding
to specify the device number in a structure rather than in the filename.
In the future, we could reuse the file descriptor if the correct one is
detected open.

This allows the mixer programs provided with the OSSv4 sources to compile
and work cleanly. I've observed problems with it failing to work on
secondary devices, and should investigate this later. There may be
a fd leak somewhere.
 1.48 16-Oct-2020  nia ossaudio(3): Add SNDCTL_DSP_COOKEDMODE, SNDCTL_DSP_GETERROR

SNDCTL_DSP_COOKEDMODE simply always returns 1.
"Cooked mode" is a silly way the OSSv4 authors chose to refer to allowing
for reprocessed streams. The NetBSD kernel always performs format
conversion and it can't be turned off.

SNDCTL_DSP_GETERROR provides access to the read/write over/underrun
counters. There are other things it might return, but they don't make
sense for our implementation.
 1.47 16-Oct-2020  nia ossaudio: Bump copyright date and improve description.
 1.46 16-Oct-2020  nia ossaudio: Add comments for the more obscure parts of SNDCTL_AUDIOINFO
 1.45 16-Oct-2020  nia ossaudio: Various OSSv4 fixes for SNDCTL_AUDIOINFO

- Per OSSv4, make this ioctl work on the main mixer device.
Since the native NetBSD API uses queries on individual audio devices,
we have to reopen the correct audio device specified in the input to the
ioctl and fetch information from that.
- Correctly return whether the device is for playback, capture, or both.
- Return the full name of the device in the name field.
- The "handle" has to be a globally unique identifier. The closest thing
we have to that is device numbers, so use device numbers.
- Return reasonable values in min_rate/max_rate and min_channels/max_channels.

This should allow Mumble's device enumeration to work with a lot less
patching.
 1.44 20-Apr-2020  nia ossaudio: removed outdated comment
 1.43 19-Apr-2020  nia ossaudio: Implement SNDCTL_DSP_(SET|GET)TRIGGER.
 1.42 19-Apr-2020  nia ossaudio: Make SNDCTL_DSP_[GET|SET][PLAY|RECORD]VOL closer to OSSv4

Problems in the previous code include returning values in the 0-255
range NetBSD uses instead of the 0-100 range OSSv4 expects, using
AUDIO_GETBUFINFO (which doesn't even return the mixer bits), and
not encoding channels as specified: "level=(left)|(right << 8)".

In reality, setting the gain in this way (through /dev/audio rather
than /dev/mixer) doesn't seem to work properly, and the mixer-set
value seems to be retained.

However, these changes at least ensure that the return values are
correct and the balance is set correctly.

I've only found one application using this API (audio/audacious), and
OSSv4 support in it is currently disabled precisely because it breaks
when it attempts to set the track volume using it.
 1.41 15-Apr-2020  nia ossaudio: If the user's channel count is rejected, use the hardware count
 1.40 15-Apr-2020  nia ossaudio: Make SNDCTL_DSP_SETFMT conform with OSSv4.

The OSSv4 spec says we shouldn't really error if an invalid format is
chosen by an application. Things are especially likely to be confused
if we return MULAW, since in OSSv4 terms that means that's the native
hardware format. Instead, set and return the current hardware format
if an invalid format is chosen.

For the 24-bit sample formats, note that the NetBSD kernel currently
can't handle them in its default configuration, and will return an error
code if you attempt to use them. So, if an applicaton requests 24-bit PCM,
promote it to 32-bit PCM. According to the spec, this is valid and
applications should be checking the return value anyway.

In the Linux compat layer, we just use S16LE as a fallback. The OSSv3
headers that are still being shipped with Linux don't contain definitions
for fancier formats and we can reasonably expect all applications to
support S16LE.
 1.39 15-Apr-2020  nia ossaudio: Make SNDCTL_DSP_SPEED more robust when using invalid rates.

From the perspective of reading the OSSv4 specification, NetBSD's
behaviour when an invalid sample rate is set makes no sense at all:
AUDIO_SETINFO simply returns an error code, and then we immediately
fall through to getting the sample rate, which is still set to the
legacy default of 8000 Hz.

Instead, what OSS applications generally expect is that they will be
able to receive the actual hardware sample rate. This is very, very
unlikely to be 8000 Hz on a modern machine.

No functional change when setting a sample rate between the supported
rates of 1000 and 192000 Hz. When a rate outside this range is requested,
the hardware rate is returned (on modern hardware, generally always 48000
Hz or a multiple of 48000 Hz).
 1.38 03-Nov-2019  isaki Use record field for recording even on
SNDCTL_DSP_STEREO, SNDCTL_DSP_SETFMT, and SNDCTL_DSP_CHANNELS.
 1.37 02-Nov-2019  isaki Use record.sample_rate for recording on SNDCTL_DSP_SPEED.
Fix PR lib/54667.
 1.36 02-Feb-2019  isaki branches: 1.36.2;
Fix minor bugs of SNDCTL_DSP_GETISPACE.
- hiwat is playback-only parameter.
- 'bytes' should not be rounded down.
 1.35 29-Jan-2019  isaki Revert a wrong SNDCTL_DSP_GETOSPACE part of rev1.33.
- 'fragments' is the number of full free blocks and should not be
negative value.
- 'bytes' should not be rounded down.
It makes mpv work correctly (fixes a second half of kern/53028).
Reviewed by mlelstv@
 1.34 23-Jan-2019  mrg memset to zero the entire array, not just 8 bytes of it.

picked up by gcc7's checker that the array size has not
been multipled by the member size.

here, we had 8 but should have had 8 * sizeof(int).

XXX: real bug - pullup-7, pullup-8
 1.33 23-Mar-2017  nat branches: 1.33.4; 1.33.10; 1.33.12;
Calculate GETISPACE/GETOSPACE properly.
Bump version.

Addresses PR kern/51999.
 1.32 10-Feb-2017  maya speed limit is 80 (missed this one)
 1.31 10-Feb-2017  maya strncpy->strlcpy. use sizeof instead of numbers.
 1.30 09-Sep-2014  nat branches: 1.30.2; 1.30.4;
Add missing defines for 16, 24 and 32 bit NE and OE formats.
Add the ability to set 24 and 32 bit precision.

This commit was approved by wiz@
 1.29 17-May-2014  nat branches: 1.29.2;
Adds ioctls and defines for OSSv4 compatibility.

The ioctl definitions and accompanying structures were
taken from FreeBSD's soundcard.h, hopefully providing
some binary compatibility.

The ioctls are as follows:
SNDCTL_SYSINFO: Returns a structure containing
details about the audio device.
SNDCTL_ENGINEINFO - SNDCTL_AUDIOINFO: Returns a
structure with playback/recording
characteristics.
SNDCTL_DSP_GETPLAYVOL, SNDCTL_DSP_SETPLAYVOL,
SNDCTL_DSP_GETRECVOL, SNDCTL_DSP_SETRECVOL:
Retrieves/Sets Playback/Recording volume.
SNDCTL_DSP_SKIP - SNDCTL_DSP_SILENCE: These ioctls
were intended to manipulate the underlying
audio buffer skip or insert silence. These
return EINVAL.

SOUND_VERSION is unchanged, but is definable, It will be
changed when the mixer OSSv4 ioctls are written.

Addresses PR 46611
This commit was approved by wiz@.
 1.28 05-May-2012  christos branches: 1.28.2; 1.28.8;
fix typo, WARNS=5
 1.27 04-May-2012  christos - match regular ioctl prototype (3rd argument is optional)
- fix lint issues
 1.26 13-Sep-2011  christos branches: 1.26.2; 1.26.4;
fix non-portable shift.
 1.25 06-Sep-2011  jmcneill Add support for AFMT_AC3
 1.24 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.23 08-Nov-2007  drochner branches: 1.23.6;
Set the number of record and play channels individually -- currently
we try to set both in one ioctl, to the same value, which fails if not
both record and play direction support that many channels. (Having
more play than record channels is common these days.)
This does likely address part of the problem described in PR pkg/35444
by Mihai Chelaru, and it helped Matthew R. Green about half a year
ago -- see the thread in tech-misc in April.
 1.22 18-Sep-2007  mlelstv Implement OSS_SNDCTL_DSP_GETODELAY and provide a no-op function
for OSS_SNDCTL_DSP_PROFILE.
 1.21 11-Jun-2007  joerg branches: 1.21.4;
Add a new ioctl AUDIO_GETBUFINFO. It works like AUDIO_GETINFO, but
doesn't obtain the ports, gain and balance related parameters.
Those generally require reading from the hardware and therefore are much
more expensive to obtain. Modify OSS emulation to use the new ioctl
where possible.

This reduces CPU usage of mplayer during mp3 playback with my Thinkpad
from 20% to < 1% and from 50% to 20% during Xvid playback.

Review and comments from jmcneill@
 1.20 01-Jun-2005  lukem branches: 1.20.4; 1.20.6;
appease gcc -Wuninitialized. some delint
 1.19 18-Nov-2004  kent getdevinfo():
If a mixer item does not match with AudioNsomething, check whether
it ends with '.' + AudioNsomething. PR#15441
 1.18 09-Mar-2003  lukem use __RCSID()
 1.17 12-Jan-2003  jdolecek add support for SNDCTL_DSP_SETDUPLEX ioctl to ossaudio emulation code
code provided by Andreas Wrede in PR kern/19793
 1.16 24-Dec-2001  mycroft Make SNDCTL_DSP_POST a nop. It's explicitly *not* supposed to sleep, and as
it's merely advisory (and in fact is implemented as a nop in the OSS->ALSA
shim), it should be safe to ignore it.
 1.15 08-Jul-2001  kim Map OSS mixer device "line1" to native mixer device "aux".
 1.14 10-May-2001  augustss Impproved fix of PR12796, from Frederick Bruckman <fb@enteract.com>
 1.13 09-May-2001  augustss Apply patch in PR lib/12796 from Frederick Bruckman <fb@enteract.com>
 1.12 16-Aug-2000  tron Use accurate rounding in conversion between OSS and NetBSD volume values.
The optimized integer formula was supplied by Wolfgang Solfrank on
"tech-kern@netbsd.org". This fixes problems with e.g FreeBSD TV (fxtv),
RealPlayer-7.0 Beta 2 (PR pkg/10818) and KDE's "kscd".
 1.11 04-Jul-2000  augustss Implement OSS_GETVERSION.
Accept mixer values above max (100).
Handle the info from AUDIO_MIXER_DEVINFO properly, parts of it is opaque.
 1.10 16-Nov-1999  augustss branches: 1.10.4;
Implement SOUND_MIXER_INFO.
 1.9 22-Aug-1999  kleink branches: 1.9.4;
Per discussion with Lennart Augustsson, change the behaviour to report emulated
encodings, too. (This is currently an issue with the eso(4) driver, which,
due to different byte orders in playing and recording directions, sets the
emulated flag for all 16-bit encodings, although it could be argued that this
is an unfortunate weakness of the query_encoding() interface.)
 1.8 02-Jul-1999  simonb More trailing white space.
 1.7 13-Apr-1999  augustss Make copyrights conform.
 1.6 25-May-1998  augustss branches: 1.6.2;
Fix off by one error.
 1.5 23-Mar-1998  augustss Track mycroft's change in src/sys/compat/oss/ossaudio.c.
 1.4 29-Oct-1997  augustss Fix a serious emulation bug.
Add some missing #defines.
Add a little more documentation.
 1.3 26-Oct-1997  augustss Add some missing defines and add history to man page.
 1.2 19-Oct-1997  augustss branches: 1.2.2;
Update for SunOS compatibility.
 1.1 16-Oct-1997  augustss Initial version of a user level emulation of the OSS audio API.
Useful for compiling Linux audio programs.
 1.2.2.1 29-Oct-1997  mellon Pull rev 1.3 and 1.4 up from trunk (augustss)
 1.6.2.2 26-Aug-2000  he Pull up revision 1.12 (via patch, requested by tron):
Use accurate rounding in conversion between OSS and NetBSD
volume values. Fixes among other things PR#10818.
 1.6.2.1 16-Apr-1999  augustss Make a bunch of copyright headers conform to the standard.
Pullup approved by Perry.
 1.9.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.10.4.4 27-Dec-2001  he Pull up revision 1.16 (requested by mycroft):
Change our emulation of SNDCTL_DSP_POST so that OSS applications
(e.g. xmms) don't randomly pause.
 1.10.4.3 16-Aug-2001  tv Pullup [fb]:

lib/libossaudio/ossaudio.c 1.13-1.14
lib/libossaudio/soundcard.h 1.11
sys/compat/ossaudio/ossaudio.c 1.34-1.35

Correctly calculate input and output hardware buffer sizes.
Fixes PR lib/12796.
 1.10.4.2 16-Aug-2000  tron pullup (approved by releng-1-5)

Use accurate rounding in conversion between OSS and NetBSD volume values.
The optimized integer formula was supplied by Wolfgang Solfrank on
"tech-kern@netbsd.org". This fixes problems with e.g FreeBSD TV (fxtv),
RealPlayer-7.0 Beta 2 (PR pkg/10818) and KDE's "kscd".

syssrc/sys/compat/ossaudio/ossaudio.c 1.31 -> 1.32
basesrc/lib/libossaudio/ossaudio.c 1.11 -> 1.12
 1.10.4.1 07-Aug-2000  augustss Pull up:
sys/compat/ossaudio/ossaudio.c 1.30-1.31
sys/compat/ossaudio/ossaudiovar.h 1.7-1.9
lib/libossaudio/ossaudio.c 1.10-1.11
Accept mixer values above max (100).
Handle the info from AUDIO_MIXER_DEVINFO properly, parts of it is opaque.
Approved by thorpej.
 1.20.6.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.20.4.1 12-Jun-2007  liamjfoy Pull up following revision(s) (requested by jmcneill in ticket #716):
share/man/man4/audio.4: revision 1.66
sys/compat/ossaudio/ossaudio.c: revision 1.56
sys/sys/audioio.h: revision 1.32
lib/libossaudio/ossaudio.c: revision 1.21
sys/dev/audio.c: revision 1.222
Add a new ioctl AUDIO_GETBUFINFO. It works like AUDIO_GETINFO, but
doesn't obtain the ports, gain and balance related parameters.
Those generally require reading from the hardware and therefore are
much
more expensive to obtain. Modify OSS emulation to use the new ioctl
where possible.
This reduces CPU usage of mplayer during mp3 playback with my Thinkpad
from 20% to < 1% and from 50% to 20% during Xvid playback.
Review and comments from jmcneill@
 1.21.4.2 09-Jan-2008  matt sync with HEAD
 1.21.4.1 06-Nov-2007  matt sync with HEAD
 1.23.6.1 18-May-2008  yamt sync with head.
 1.26.4.1 07-May-2012  riz Apply patches (requested by christos in ticket #225):
lib/libossaudio/Makefile patch
lib/libossaudio/ossaudio.c patch
lib/libossaudio/soundcard.h patch

Fix compilation of ioctls without the 3rd argument in ossaudio.
[christos, ticket #225]
 1.26.2.1 23-May-2012  yamt sync with head.
 1.28.8.1 10-Aug-2014  tls Rebase.
 1.28.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.29.2.1 11-Sep-2014  martin Pull up following revision(s) (requested by nat in ticket #92):
lib/libossaudio/ossaudio.c: revision 1.30
lib/libossaudio/soundcard.h: revision 1.24
Add missing defines for 16, 24 and 32 bit NE and OE formats.
Add the ability to set 24 and 32 bit precision.
 1.30.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.30.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.30.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.33.12.3 21-Apr-2020  martin Sync with HEAD
 1.33.12.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.33.12.1 10-Jun-2019  christos Sync with HEAD
 1.33.10.1 26-Jan-2019  pgoyette Sync with HEAD
 1.33.4.1 09-Feb-2019  martin Pull up following revision(s) (requested by isaki in ticket #1185):

lib/libossaudio/ossaudio.c: revision 1.35
sys/compat/ossaudio/ossaudio.c: revision 1.71

Revert a wrong SNDCTL_DSP_GETOSPACE part of rev1.33.
- 'fragments' is the number of full free blocks and should not be
negative value.
- 'bytes' should not be rounded down.

It makes mpv work correctly (fixes a second half of kern/53028).
Reviewed by mlelstv@

-

Revert a wrong OSS_SNDCTL_DSP_GETOSPACE part of rev1.70.
- 'fragments' is the number of full free blocks and should not be
negative value.
- 'bytes' should not be rounded down.
 1.36.2.2 27-Apr-2020  martin Pull up following revision(s) (requested by nia in ticket #855):

lib/libossaudio/ossaudio.c: revision 1.41
lib/libossaudio/ossaudio.c: revision 1.42
lib/libossaudio/ossaudio.c: revision 1.43
sys/compat/ossaudio/ossaudio.c: revision 1.80
sys/compat/ossaudio/ossaudio.c: revision 1.81
sys/compat/ossaudio/ossaudio.c: revision 1.82
lib/libossaudio/ossaudio.c: revision 1.39
sys/compat/ossaudio/ossaudio.c: revision 1.79
lib/libossaudio/ossaudio.c: revision 1.40

ossaudio: Make SNDCTL_DSP_SPEED more robust when using invalid rates.

From the perspective of reading the OSSv4 specification, NetBSD's
behaviour when an invalid sample rate is set makes no sense at all:
AUDIO_SETINFO simply returns an error code, and then we immediately
fall through to getting the sample rate, which is still set to the
legacy default of 8000 Hz.

Instead, what OSS applications generally expect is that they will be
able to receive the actual hardware sample rate. This is very, very
unlikely to be 8000 Hz on a modern machine.

No functional change when setting a sample rate between the supported
rates of 1000 and 192000 Hz. When a rate outside this range is requested,
the hardware rate is returned (on modern hardware, generally always 48000
Hz or a multiple of 48000 Hz).

ossaudio: Make SNDCTL_DSP_SETFMT conform with OSSv4.

The OSSv4 spec says we shouldn't really error if an invalid format is
chosen by an application. Things are especially likely to be confused
if we return MULAW, since in OSSv4 terms that means that's the native
hardware format. Instead, set and return the current hardware format
if an invalid format is chosen.

For the 24-bit sample formats, note that the NetBSD kernel currently
can't handle them in its default configuration, and will return an error
code if you attempt to use them. So, if an applicaton requests 24-bit PCM,
promote it to 32-bit PCM. According to the spec, this is valid and
applications should be checking the return value anyway.

In the Linux compat layer, we just use S16LE as a fallback. The OSSv3
headers that are still being shipped with Linux don't contain definitions
for fancier formats and we can reasonably expect all applications to
support S16LE.

ossaudio: If the user's channel count is rejected, use the hardware count

ossaudio: Make SNDCTL_DSP_[GET|SET][PLAY|RECORD]VOL closer to OSSv4

Problems in the previous code include returning values in the 0-255
range NetBSD uses instead of the 0-100 range OSSv4 expects, using
AUDIO_GETBUFINFO (which doesn't even return the mixer bits), and
not encoding channels as specified: "level=(left)|(right << 8)".

In reality, setting the gain in this way (through /dev/audio rather
than /dev/mixer) doesn't seem to work properly, and the mixer-set
value seems to be retained.

However, these changes at least ensure that the return values are
correct and the balance is set correctly.

I've only found one application using this API (audio/audacious), and
OSSv4 support in it is currently disabled precisely because it breaks
when it attempts to set the track volume using it.

ossaudio: Implement SNDCTL_DSP_(SET|GET)TRIGGER.
 1.36.2.1 19-Nov-2019  martin Pull up following revision(s) (requested by isaki in ticket #446):
lib/libossaudio/ossaudio.c: revision 1.37
lib/libossaudio/ossaudio.c: revision 1.38
sys/compat/ossaudio/ossaudio.c: revision 1.77
sys/compat/ossaudio/ossaudio.c: revision 1.78
Use record.sample_rate for recording on SNDCTL_DSP_SPEED.
Fix PR lib/54667.
Use record.sample_rate for recording on SNDCTL_DSP_SPEED.
It's kernel side of PR lib/54667.
Use record field for recording even on
SNDCTL_DSP_STEREO, SNDCTL_DSP_SETFMT, and SNDCTL_DSP_CHANNELS.
 1.66.2.1 31-May-2021  cjep sync with head
 1.1 21-Nov-2024  riastradh branches: 1.1.4;
libossaudio: Add expected symbols list.

PR lib/58838: shared libraries in base should all have expsym lists
 1.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 21-Nov-2024  perseant file ossaudio.expsym was added on branch perseant-exfatfs on 2025-08-02 05:54:53 +0000
 1.9 24-Mar-2017  nat ABI of libossaudio did not change, so there was no need to bump the version
number.

Pointed out by mrg@
 1.8 23-Mar-2017  nat Calculate GETISPACE/GETOSPACE properly.
Bump version.

Addresses PR kern/51999.
 1.7 18-May-2014  nat branches: 1.7.6; 1.7.10;
libossaudio minor version bump to signify new ioctls.
 1.6 11-Jan-2009  christos branches: 1.6.14; 1.6.24;
bump shared libraries.
 1.5 25-Feb-1999  abs Add a note to update src/distrib/sets/lists/base/shl.*, and add a missing
RCS Id.
 1.4 05-Jan-1998  perry RCSID Police.
 1.3 07-Nov-1997  mikel back out last change
 1.2 01-Nov-1997  mikel don't build shared library
 1.1 16-Oct-1997  augustss Initial version of a user level emulation of the OSS audio API.
Useful for compiling Linux audio programs.
 1.6.24.1 10-Aug-2014  tls Rebase.
 1.6.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.10.1 21-Apr-2017  bouyer Sync with HEAD
 1.7.6.1 26-Apr-2017  pgoyette Sync with HEAD
 1.34 09-May-2021  nia libossaudio: Various OSSv4 fixes to allow reference programs to compile

- Define various new AFMT_*. These are not returned as supported
formats by SNDCTL_DSP_GETFMTS, because it would be very silly to
have Vorbis in the kernel.

- Implement PLAYTGT and RECSRC. For each NetBSD audio device
we only return one playback and recording source, "primary".

- Return preferred channel configuration in capabilities.
Either DSP_CH_STEREO, DSP_CH_MONO, or DSP_CH_MULTI
depending on the current hardware format.

- SNDCTL_DSP_HALT_* simply flushes the audio device.
 1.33 03-Dec-2020  nia branches: 1.33.2;
Add some missing channel order related ioctl defines.

These are no-ops (unimplemented) on both FreeBSD and Solaris
and the one piece of code I've found that uses it seems to assume the
call will fail so it should be safe to leave this returning EINVAL.

However, it does need the definitions to compile...
 1.32 03-Nov-2020  nia ossaudio(3): More capability defines from OSSv4
 1.31 23-Oct-2020  nia ossaudio(3): Add an implementation of SNDCTL_CARDINFO

Correct some of the counts returned by SNDCTL_SYSINFO so this works.
 1.30 20-Oct-2020  nia ossaudio(3): Add SNDCTL_AUDIOINFO_EX as an alias of SNDCTL_AUDIOINFO
 1.29 20-Oct-2020  nia ossaudio(3): Add some endian-specific U16 formats

for compatibility with FreeBSD
 1.28 19-Oct-2020  nia ossaudio(3): add some no-op defines for ossv4 compat.
 1.27 19-Oct-2020  nia ossaudio(3): Add SNDCTL_DSP_CURRENT_(I|O)PTR

In OSSv4 these are supposed to avoid the wrapping problems with the
older GET(I|O)PTR ioctls but we don't quite get the same benefit here.

XXX: We could probably fake it by maintaining some state in-between calls.
 1.26 17-Oct-2020  nia ossaudio(3): Add initial support for the OSSv4.1 Mixer API

One or two calls from this API were supported previously and have been
moved to the correct place.

Mapping the controls correctly is a difficult task. There is a define
hidden in the OSS headers that would allow an AUDIO_MIXER_SET control
to be represented perfectly, but it seems to _only_ exist there, and
no software supports it. So for now only one member of a set can be
set at a time - unfortunate. I've hidden code that should unlock
doing this the proper way under #notyet.

I'm not too happy with the way this code is managing file descriptors.
Currently it has to open a new fd for each ioctl due to OSSv4 deciding
to specify the device number in a structure rather than in the filename.
In the future, we could reuse the file descriptor if the correct one is
detected open.

This allows the mixer programs provided with the OSSv4 sources to compile
and work cleanly. I've observed problems with it failing to work on
secondary devices, and should investigate this later. There may be
a fd leak somewhere.
 1.25 16-Oct-2020  nia ossaudio(3): Add SNDCTL_DSP_COOKEDMODE, SNDCTL_DSP_GETERROR

SNDCTL_DSP_COOKEDMODE simply always returns 1.
"Cooked mode" is a silly way the OSSv4 authors chose to refer to allowing
for reprocessed streams. The NetBSD kernel always performs format
conversion and it can't be turned off.

SNDCTL_DSP_GETERROR provides access to the read/write over/underrun
counters. There are other things it might return, but they don't make
sense for our implementation.
 1.24 09-Sep-2014  nat Add missing defines for 16, 24 and 32 bit NE and OE formats.
Add the ability to set 24 and 32 bit precision.

This commit was approved by wiz@
 1.23 17-May-2014  nat branches: 1.23.2;
Adds ioctls and defines for OSSv4 compatibility.

The ioctl definitions and accompanying structures were
taken from FreeBSD's soundcard.h, hopefully providing
some binary compatibility.

The ioctls are as follows:
SNDCTL_SYSINFO: Returns a structure containing
details about the audio device.
SNDCTL_ENGINEINFO - SNDCTL_AUDIOINFO: Returns a
structure with playback/recording
characteristics.
SNDCTL_DSP_GETPLAYVOL, SNDCTL_DSP_SETPLAYVOL,
SNDCTL_DSP_GETRECVOL, SNDCTL_DSP_SETRECVOL:
Retrieves/Sets Playback/Recording volume.
SNDCTL_DSP_SKIP - SNDCTL_DSP_SILENCE: These ioctls
were intended to manipulate the underlying
audio buffer skip or insert silence. These
return EINVAL.

SOUND_VERSION is unchanged, but is definable, It will be
changed when the mixer OSSv4 ioctls are written.

Addresses PR 46611
This commit was approved by wiz@.
 1.22 05-May-2012  christos branches: 1.22.2; 1.22.8;
fix typo, WARNS=5
 1.21 05-May-2012  christos avoid using cpp variadic macros and explain why.
 1.20 04-May-2012  christos - match regular ioctl prototype (3rd argument is optional)
- fix lint issues
 1.19 06-Sep-2011  jmcneill branches: 1.19.2; 1.19.4;
Add support for AFMT_AC3
 1.18 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.17 15-Mar-2008  bjs branches: 1.17.2;
s/prototyoe/prototype/
 1.16 18-Sep-2007  mlelstv branches: 1.16.4;
Implement OSS_SNDCTL_DSP_GETODELAY and provide a no-op function
for OSS_SNDCTL_DSP_PROFILE.
 1.15 09-Feb-2005  drochner branches: 1.15.16;
work around a prototype conflict by including ioctl.h
before we redefile ioctl()
 1.14 04-Feb-2005  perry de-__P
 1.13 27-May-2002  wiz Add SOUND_MASK_* for the last SOUND_MIXER_* values that didn't have any.
 1.12 11-Jan-2002  kleink Determine the 'native' endianness using _BYTE_ORDER from
<machine/endian_machdep.h>.

The previous method of wrapping a definition of _POSIX_SOURCE around the
inclusion of other headers to reduce namespace pollution had the
side-effect of not all required identifiers being defined when included
thereafter by the application itself (due to multiple-inclusion protection),
and is not blessed by that standard.
 1.11 09-May-2001  augustss Apply patch in PR lib/12796 from Frederick Bruckman <fb@enteract.com>
 1.10 16-Nov-1999  augustss branches: 1.10.4;
Implement SOUND_MIXER_INFO.
 1.9 13-Apr-1999  augustss branches: 1.9.4;
Make copyrights conform.
 1.8 18-Mar-1999  augustss branches: 1.8.2;
Avoid defining _POSIX_SOURCE.
 1.7 05-Feb-1999  kleink Make protection against multiple inclusion non-invasive wrt. name space.
 1.6 29-Jun-1998  augustss Revert the #define of ioctl to its previous state since my
"improvement" broke some packages.
 1.5 19-Jun-1998  augustss Add __BEGIN_DECLS & __END_DECLS for C++ and clean up a little.
 1.4 29-Oct-1997  augustss Add even more defines.
 1.3 29-Oct-1997  augustss Fix a serious emulation bug.
Add some missing #defines.
Add a little more documentation.
 1.2 26-Oct-1997  augustss Add some missing defines and add history to man page.
 1.1 16-Oct-1997  augustss branches: 1.1.2;
Initial version of a user level emulation of the OSS audio API.
Useful for compiling Linux audio programs.
 1.1.2.2 30-Oct-1997  mellon Pull rev 1.4 up from trunk (augustss)
 1.1.2.1 29-Oct-1997  mellon Pull rev 1.2 and 1.3 up from trunk (augustss)
 1.8.2.1 16-Apr-1999  augustss Make a bunch of copyright headers conform to the standard.
Pullup approved by Perry.
 1.9.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.10.4.2 06-Feb-2002  he Pull up revision 1.12 (requested by kleink):
Determine the ``native'' endianness using _BYTE_ORDER from
<machine/endian_machdep.h>.
 1.10.4.1 16-Aug-2001  tv Pullup [fb]:

lib/libossaudio/ossaudio.c 1.13-1.14
lib/libossaudio/soundcard.h 1.11
sys/compat/ossaudio/ossaudio.c 1.34-1.35

Correctly calculate input and output hardware buffer sizes.
Fixes PR lib/12796.
 1.15.16.2 23-Mar-2008  matt sync with HEAD
 1.15.16.1 06-Nov-2007  matt sync with HEAD
 1.16.4.1 24-Mar-2008  keiichi sync with head.
 1.17.2.1 18-May-2008  yamt sync with head.
 1.19.4.1 07-May-2012  riz Apply patches (requested by christos in ticket #225):
lib/libossaudio/Makefile patch
lib/libossaudio/ossaudio.c patch
lib/libossaudio/soundcard.h patch

Fix compilation of ioctls without the 3rd argument in ossaudio.
[christos, ticket #225]
 1.19.2.1 23-May-2012  yamt sync with head.
 1.22.8.1 10-Aug-2014  tls Rebase.
 1.22.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.23.2.1 11-Sep-2014  martin Pull up following revision(s) (requested by nat in ticket #92):
lib/libossaudio/ossaudio.c: revision 1.30
lib/libossaudio/soundcard.h: revision 1.24
Add missing defines for 16, 24 and 32 bit NE and OE formats.
Add the ability to set 24 and 32 bit precision.
 1.33.2.1 31-May-2021  cjep sync with head

RSS XML Feed