2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
2003-09-07 16:28:03 +00:00
|
|
|
* Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <dev/sound/pcm/sound.h>
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
#include "feeder_if.h"
|
|
|
|
|
2001-08-23 11:30:52 +00:00
|
|
|
SND_DECLARE_FILE("$FreeBSD$");
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
struct snd_dbuf *
|
2004-01-28 08:02:15 +00:00
|
|
|
sndbuf_create(device_t dev, char *drv, char *desc, struct pcm_channel *channel)
|
2001-03-24 23:10:29 +00:00
|
|
|
{
|
|
|
|
struct snd_dbuf *b;
|
|
|
|
|
2003-02-19 05:47:46 +00:00
|
|
|
b = malloc(sizeof(*b), M_DEVBUF, M_WAITOK | M_ZERO);
|
2001-03-24 23:10:29 +00:00
|
|
|
snprintf(b->name, SNDBUF_NAMELEN, "%s:%s", drv, desc);
|
2002-01-26 22:13:24 +00:00
|
|
|
b->dev = dev;
|
2004-01-28 08:02:15 +00:00
|
|
|
b->channel = channel;
|
2002-01-26 22:13:24 +00:00
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sndbuf_destroy(struct snd_dbuf *b)
|
|
|
|
{
|
2007-03-21 18:17:03 +00:00
|
|
|
sndbuf_free(b);
|
2001-03-24 23:10:29 +00:00
|
|
|
free(b, M_DEVBUF);
|
|
|
|
}
|
|
|
|
|
2003-02-20 17:31:12 +00:00
|
|
|
bus_addr_t
|
|
|
|
sndbuf_getbufaddr(struct snd_dbuf *buf)
|
|
|
|
{
|
|
|
|
return (buf->buf_addr);
|
|
|
|
}
|
|
|
|
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
static void
|
|
|
|
sndbuf_setmap(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
|
|
|
{
|
2001-03-24 23:10:29 +00:00
|
|
|
struct snd_dbuf *b = (struct snd_dbuf *)arg;
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
|
|
|
|
if (bootverbose) {
|
2004-10-15 03:50:04 +00:00
|
|
|
device_printf(b->dev, "sndbuf_setmap %lx, %lx; ",
|
|
|
|
(u_long)segs[0].ds_addr, (u_long)segs[0].ds_len);
|
|
|
|
printf("%p -> %lx\n", b->buf, (u_long)segs[0].ds_addr);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
}
|
2004-10-15 03:50:04 +00:00
|
|
|
if (error == 0)
|
|
|
|
b->buf_addr = segs[0].ds_addr;
|
|
|
|
else
|
|
|
|
b->buf_addr = 0;
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-03-24 23:10:29 +00:00
|
|
|
* Allocate memory for DMA buffer. If the device does not use DMA transfers,
|
|
|
|
* the driver can call malloc(9) and sndbuf_setup() itself.
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
*/
|
2003-02-20 17:31:12 +00:00
|
|
|
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
int
|
2007-04-18 18:26:41 +00:00
|
|
|
sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, int dmaflags,
|
|
|
|
unsigned int size)
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
{
|
2004-10-15 03:50:04 +00:00
|
|
|
int ret;
|
|
|
|
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
b->dmatag = dmatag;
|
2007-04-18 18:26:41 +00:00
|
|
|
b->dmaflags = dmaflags | BUS_DMA_NOWAIT;
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
b->maxsize = size;
|
|
|
|
b->bufsize = b->maxsize;
|
2004-10-15 03:50:04 +00:00
|
|
|
b->buf_addr = 0;
|
2007-02-01 09:46:03 +00:00
|
|
|
b->flags |= SNDBUF_F_MANAGED;
|
2007-04-18 18:26:41 +00:00
|
|
|
if (bus_dmamem_alloc(b->dmatag, (void **)&b->buf, b->dmaflags,
|
2007-03-21 18:17:03 +00:00
|
|
|
&b->dmamap)) {
|
|
|
|
sndbuf_free(b);
|
2004-10-15 03:50:04 +00:00
|
|
|
return (ENOMEM);
|
2007-03-21 18:17:03 +00:00
|
|
|
}
|
2004-10-15 03:50:04 +00:00
|
|
|
if (bus_dmamap_load(b->dmatag, b->dmamap, b->buf, b->maxsize,
|
|
|
|
sndbuf_setmap, b, 0) != 0 || b->buf_addr == 0) {
|
2007-03-21 18:17:03 +00:00
|
|
|
sndbuf_free(b);
|
2004-10-15 03:50:04 +00:00
|
|
|
return (ENOMEM);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = sndbuf_resize(b, 2, b->maxsize / 2);
|
|
|
|
if (ret != 0)
|
|
|
|
sndbuf_free(b);
|
2007-03-21 18:17:03 +00:00
|
|
|
|
2004-10-15 03:50:04 +00:00
|
|
|
return (ret);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-03-24 23:10:29 +00:00
|
|
|
sndbuf_setup(struct snd_dbuf *b, void *buf, unsigned int size)
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
{
|
2007-03-21 18:17:03 +00:00
|
|
|
b->flags &= ~SNDBUF_F_MANAGED;
|
2007-02-01 09:46:03 +00:00
|
|
|
if (buf)
|
|
|
|
b->flags |= SNDBUF_F_MANAGED;
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
b->buf = buf;
|
|
|
|
b->maxsize = size;
|
|
|
|
b->bufsize = b->maxsize;
|
|
|
|
return sndbuf_resize(b, 2, b->maxsize / 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-03-24 23:10:29 +00:00
|
|
|
sndbuf_free(struct snd_dbuf *b)
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
{
|
2001-03-24 23:10:29 +00:00
|
|
|
if (b->tmpbuf)
|
|
|
|
free(b->tmpbuf, M_DEVBUF);
|
|
|
|
|
MFp4 the sound Google Summer of Code project:
The goal was to sync with the OSSv4 API 4Front Technologies uses in their
proprietary OSS driver. This was successful as far as possible. The part
of the API which is stable is implemented, for the rest there are some
stubs already.
New system ioctls:
- SNDCTL_SYSINFO - obtain audio system info (version, # of audio/midi/
mixer devices, etc.)
- SNDCTL_AUDIOINFO - fetch details about a specific audio device
- SNDCTL_MIXERINFO - fetch details about a specific mixer device
New audio ioctls:
- Sync groups (SNDCTL_DSP_SYNCGROUP/SNDCTL_DSP_SYNCSTART) which allow
triggered playback/recording on multiple devices (even across processes
simultaneously).
- Peak meters (SNDCTL_DSP_GETIPEAKS/SNDCTL_DSP_GETOPEAKS) - can query
audio drivers for peak levels (needs driver support, disabled for now).
- Per channel playback/recording levels -
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL. Note that these are still in name
only, just wrapping around the AC97-style mixer at the moment. The next
step is to push them down to the drivers.
Audio ioctls still under development by 4Front (for which stubs may exist
in this commit):
- SNDCTL_GETNAME, SNDCTL_{GET,SET}{SONG,LABEL}
- SNDCTL_DSP_{GET,SET}_CHNORDER
- SNDCTL_MIX_ENUMINFO, SNDCTL_MIX_EXTINFO - (might be documented enough in
the OSS releases to work on this. These ioctls cover the cool "twiddle
any knob on your card" features.)
Missing:
- SNDCTL_DSP_COOKEDMODE -- this ioctl is used to give applications direct
access to a card's buffers, bypassing the feeder architecture. It's
a toughy -- "someone" needs to decide :
(a) if this is desireable, and (b) if it's reasonably feasible.
Updates for driver writers:
So far, only two routines to the channel class (in channel_if.m) are added.
One is for fetching a list of discrete supported playback/recording rates
of a channel, and the other is for fetching peak level info (useful for
drawing peak meters). Interested parties may want to help pushing down
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL into the drivers.
To use the new stuff you need to rebuild the sound drivers or your kernel
(depending on if you use modules or not) and to install soundcard.h (a
buildworld/installworld handles this).
Sponsored by: Google SoC 2006
Submitted by: ryanb
Many thanks to: 4Front Technologies for their cooperation, explanations
and the nice license of their soundcard.h.
2006-09-23 20:45:47 +00:00
|
|
|
if (b->shadbuf)
|
|
|
|
free(b->shadbuf, M_DEVBUF);
|
2007-02-01 09:46:03 +00:00
|
|
|
|
2007-03-21 18:17:03 +00:00
|
|
|
if (b->buf) {
|
|
|
|
if (b->flags & SNDBUF_F_MANAGED) {
|
|
|
|
if (b->dmamap)
|
|
|
|
bus_dmamap_unload(b->dmatag, b->dmamap);
|
|
|
|
if (b->dmatag)
|
|
|
|
bus_dmamem_free(b->dmatag, b->buf, b->dmamap);
|
|
|
|
} else
|
|
|
|
free(b->buf, M_DEVBUF);
|
|
|
|
}
|
2001-03-24 23:10:29 +00:00
|
|
|
|
2007-03-21 18:17:03 +00:00
|
|
|
b->tmpbuf = NULL;
|
|
|
|
b->shadbuf = NULL;
|
2001-05-27 14:39:34 +00:00
|
|
|
b->buf = NULL;
|
2007-03-21 18:17:03 +00:00
|
|
|
b->sl = 0;
|
|
|
|
b->dmatag = NULL;
|
|
|
|
b->dmamap = NULL;
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
}
|
|
|
|
|
2007-06-14 11:15:51 +00:00
|
|
|
#define SNDBUF_CACHE_SHIFT 5
|
|
|
|
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
int
|
2001-03-24 23:10:29 +00:00
|
|
|
sndbuf_resize(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz)
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
{
|
2007-06-14 11:15:51 +00:00
|
|
|
unsigned int bufsize, allocsize;
|
|
|
|
u_int8_t *tmpbuf;
|
2004-01-28 08:02:15 +00:00
|
|
|
|
|
|
|
chn_lock(b->channel);
|
2001-03-24 23:10:29 +00:00
|
|
|
if (b->maxsize == 0)
|
2004-01-28 08:02:15 +00:00
|
|
|
goto out;
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
if (blkcnt == 0)
|
|
|
|
blkcnt = b->blkcnt;
|
|
|
|
if (blksz == 0)
|
|
|
|
blksz = b->blksz;
|
2007-06-14 11:15:51 +00:00
|
|
|
if (blkcnt < 2 || blksz < 16 || (blkcnt * blksz) > b->maxsize) {
|
2004-01-28 08:02:15 +00:00
|
|
|
chn_unlock(b->channel);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
return EINVAL;
|
2004-01-28 08:02:15 +00:00
|
|
|
}
|
2002-01-26 22:13:24 +00:00
|
|
|
if (blkcnt == b->blkcnt && blksz == b->blksz)
|
2004-01-28 08:02:15 +00:00
|
|
|
goto out;
|
2003-04-20 17:08:56 +00:00
|
|
|
|
2007-06-14 11:15:51 +00:00
|
|
|
bufsize = blkcnt * blksz;
|
|
|
|
|
|
|
|
if (b->tmpbuf == NULL || bufsize > b->allocsize ||
|
|
|
|
bufsize < (b->allocsize >> SNDBUF_CACHE_SHIFT)) {
|
|
|
|
allocsize = round_page(bufsize);
|
|
|
|
chn_unlock(b->channel);
|
|
|
|
tmpbuf = malloc(allocsize, M_DEVBUF, M_WAITOK);
|
|
|
|
chn_lock(b->channel);
|
|
|
|
if (snd_verbose > 3)
|
|
|
|
printf("%s(): b=%p %p -> %p [%d -> %d : %d]\n",
|
|
|
|
__func__, b, b->tmpbuf, tmpbuf,
|
|
|
|
b->allocsize, allocsize, bufsize);
|
|
|
|
if (b->tmpbuf != NULL)
|
|
|
|
free(b->tmpbuf, M_DEVBUF);
|
|
|
|
b->tmpbuf = tmpbuf;
|
|
|
|
b->allocsize = allocsize;
|
|
|
|
} else if (snd_verbose > 3)
|
|
|
|
printf("%s(): b=%p %d [%d] NOCHANGE\n",
|
|
|
|
__func__, b, b->allocsize, b->bufsize);
|
|
|
|
|
2004-01-28 08:02:15 +00:00
|
|
|
b->blkcnt = blkcnt;
|
|
|
|
b->blksz = blksz;
|
2007-06-14 11:15:51 +00:00
|
|
|
b->bufsize = bufsize;
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
sndbuf_reset(b);
|
2004-01-28 08:02:15 +00:00
|
|
|
out:
|
|
|
|
chn_unlock(b->channel);
|
2001-03-24 23:10:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sndbuf_remalloc(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz)
|
|
|
|
{
|
2007-06-14 11:15:51 +00:00
|
|
|
unsigned int bufsize, allocsize;
|
|
|
|
u_int8_t *buf, *tmpbuf, *shadbuf;
|
2002-11-25 17:17:43 +00:00
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
if (blkcnt < 2 || blksz < 16)
|
|
|
|
return EINVAL;
|
|
|
|
|
2002-11-25 17:17:43 +00:00
|
|
|
bufsize = blksz * blkcnt;
|
2001-03-24 23:10:29 +00:00
|
|
|
|
2007-06-14 11:15:51 +00:00
|
|
|
if (bufsize > b->allocsize ||
|
|
|
|
bufsize < (b->allocsize >> SNDBUF_CACHE_SHIFT)) {
|
|
|
|
allocsize = round_page(bufsize);
|
|
|
|
chn_unlock(b->channel);
|
|
|
|
buf = malloc(allocsize, M_DEVBUF, M_WAITOK);
|
|
|
|
tmpbuf = malloc(allocsize, M_DEVBUF, M_WAITOK);
|
|
|
|
shadbuf = malloc(allocsize, M_DEVBUF, M_WAITOK);
|
|
|
|
chn_lock(b->channel);
|
|
|
|
if (b->buf != NULL)
|
|
|
|
free(b->buf, M_DEVBUF);
|
|
|
|
b->buf = buf;
|
|
|
|
if (b->tmpbuf != NULL)
|
|
|
|
free(b->tmpbuf, M_DEVBUF);
|
|
|
|
b->tmpbuf = tmpbuf;
|
|
|
|
if (b->shadbuf != NULL)
|
|
|
|
free(b->shadbuf, M_DEVBUF);
|
|
|
|
b->shadbuf = shadbuf;
|
|
|
|
if (snd_verbose > 3)
|
|
|
|
printf("%s(): b=%p %d -> %d [%d]\n",
|
|
|
|
__func__, b, b->allocsize, allocsize, bufsize);
|
|
|
|
b->allocsize = allocsize;
|
|
|
|
} else if (snd_verbose > 3)
|
|
|
|
printf("%s(): b=%p %d [%d] NOCHANGE\n",
|
|
|
|
__func__, b, b->allocsize, b->bufsize);
|
2002-11-25 17:17:43 +00:00
|
|
|
|
|
|
|
b->blkcnt = blkcnt;
|
|
|
|
b->blksz = blksz;
|
|
|
|
b->bufsize = bufsize;
|
|
|
|
b->maxsize = bufsize;
|
MFp4 the sound Google Summer of Code project:
The goal was to sync with the OSSv4 API 4Front Technologies uses in their
proprietary OSS driver. This was successful as far as possible. The part
of the API which is stable is implemented, for the rest there are some
stubs already.
New system ioctls:
- SNDCTL_SYSINFO - obtain audio system info (version, # of audio/midi/
mixer devices, etc.)
- SNDCTL_AUDIOINFO - fetch details about a specific audio device
- SNDCTL_MIXERINFO - fetch details about a specific mixer device
New audio ioctls:
- Sync groups (SNDCTL_DSP_SYNCGROUP/SNDCTL_DSP_SYNCSTART) which allow
triggered playback/recording on multiple devices (even across processes
simultaneously).
- Peak meters (SNDCTL_DSP_GETIPEAKS/SNDCTL_DSP_GETOPEAKS) - can query
audio drivers for peak levels (needs driver support, disabled for now).
- Per channel playback/recording levels -
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL. Note that these are still in name
only, just wrapping around the AC97-style mixer at the moment. The next
step is to push them down to the drivers.
Audio ioctls still under development by 4Front (for which stubs may exist
in this commit):
- SNDCTL_GETNAME, SNDCTL_{GET,SET}{SONG,LABEL}
- SNDCTL_DSP_{GET,SET}_CHNORDER
- SNDCTL_MIX_ENUMINFO, SNDCTL_MIX_EXTINFO - (might be documented enough in
the OSS releases to work on this. These ioctls cover the cool "twiddle
any knob on your card" features.)
Missing:
- SNDCTL_DSP_COOKEDMODE -- this ioctl is used to give applications direct
access to a card's buffers, bypassing the feeder architecture. It's
a toughy -- "someone" needs to decide :
(a) if this is desireable, and (b) if it's reasonably feasible.
Updates for driver writers:
So far, only two routines to the channel class (in channel_if.m) are added.
One is for fetching a list of discrete supported playback/recording rates
of a channel, and the other is for fetching peak level info (useful for
drawing peak meters). Interested parties may want to help pushing down
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL into the drivers.
To use the new stuff you need to rebuild the sound drivers or your kernel
(depending on if you use modules or not) and to install soundcard.h (a
buildworld/installworld handles this).
Sponsored by: Google SoC 2006
Submitted by: ryanb
Many thanks to: 4Front Technologies for their cooperation, explanations
and the nice license of their soundcard.h.
2006-09-23 20:45:47 +00:00
|
|
|
b->sl = bufsize;
|
2002-11-25 17:17:43 +00:00
|
|
|
|
2004-01-28 08:02:15 +00:00
|
|
|
sndbuf_reset(b);
|
|
|
|
|
2007-06-14 11:15:51 +00:00
|
|
|
return 0;
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
}
|
|
|
|
|
MFp4 the sound Google Summer of Code project:
The goal was to sync with the OSSv4 API 4Front Technologies uses in their
proprietary OSS driver. This was successful as far as possible. The part
of the API which is stable is implemented, for the rest there are some
stubs already.
New system ioctls:
- SNDCTL_SYSINFO - obtain audio system info (version, # of audio/midi/
mixer devices, etc.)
- SNDCTL_AUDIOINFO - fetch details about a specific audio device
- SNDCTL_MIXERINFO - fetch details about a specific mixer device
New audio ioctls:
- Sync groups (SNDCTL_DSP_SYNCGROUP/SNDCTL_DSP_SYNCSTART) which allow
triggered playback/recording on multiple devices (even across processes
simultaneously).
- Peak meters (SNDCTL_DSP_GETIPEAKS/SNDCTL_DSP_GETOPEAKS) - can query
audio drivers for peak levels (needs driver support, disabled for now).
- Per channel playback/recording levels -
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL. Note that these are still in name
only, just wrapping around the AC97-style mixer at the moment. The next
step is to push them down to the drivers.
Audio ioctls still under development by 4Front (for which stubs may exist
in this commit):
- SNDCTL_GETNAME, SNDCTL_{GET,SET}{SONG,LABEL}
- SNDCTL_DSP_{GET,SET}_CHNORDER
- SNDCTL_MIX_ENUMINFO, SNDCTL_MIX_EXTINFO - (might be documented enough in
the OSS releases to work on this. These ioctls cover the cool "twiddle
any knob on your card" features.)
Missing:
- SNDCTL_DSP_COOKEDMODE -- this ioctl is used to give applications direct
access to a card's buffers, bypassing the feeder architecture. It's
a toughy -- "someone" needs to decide :
(a) if this is desireable, and (b) if it's reasonably feasible.
Updates for driver writers:
So far, only two routines to the channel class (in channel_if.m) are added.
One is for fetching a list of discrete supported playback/recording rates
of a channel, and the other is for fetching peak level info (useful for
drawing peak meters). Interested parties may want to help pushing down
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL into the drivers.
To use the new stuff you need to rebuild the sound drivers or your kernel
(depending on if you use modules or not) and to install soundcard.h (a
buildworld/installworld handles this).
Sponsored by: Google SoC 2006
Submitted by: ryanb
Many thanks to: 4Front Technologies for their cooperation, explanations
and the nice license of their soundcard.h.
2006-09-23 20:45:47 +00:00
|
|
|
/**
|
|
|
|
* @brief Zero out space in buffer free area
|
|
|
|
*
|
|
|
|
* This function clears a chunk of @c length bytes in the buffer free area
|
|
|
|
* (i.e., where the next write will be placed).
|
|
|
|
*
|
|
|
|
* @param b buffer context
|
|
|
|
* @param length number of bytes to blank
|
|
|
|
*/
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
void
|
2001-03-24 23:10:29 +00:00
|
|
|
sndbuf_clear(struct snd_dbuf *b, unsigned int length)
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
{
|
|
|
|
int i;
|
2001-03-05 16:45:38 +00:00
|
|
|
u_char data, *p;
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
|
|
|
|
if (length == 0)
|
|
|
|
return;
|
2001-03-05 16:45:38 +00:00
|
|
|
if (length > b->bufsize)
|
|
|
|
length = b->bufsize;
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
|
Welcome to Once-a-year Sound Mega-Commit. Enjoy numerous updates and fixes
in every sense.
General
-------
- Multichannel safe, endian safe, format safe
* Large part of critical pcm filters such as vchan.c, feeder_rate.c,
feeder_volume.c, feeder_fmt.c and feeder.c has been rewritten so that
using them does not cause the pcm data to be converted to 16bit little
endian.
* Macrosses for accessing pcm data safely are defined within sound.h in
the form of PCM_READ_* / PCM_WRITE_*
* Currently, most of them are probably limited for mono/stereo handling,
but the future addition of true multichannel will be much easier.
- Low latency operation
* Well, this require lot more works to do not just within sound driver,
but we're heading towards right direction. Buffer/block sizing within
channel.c is rewritten to calculate precise allocation for various
combination of sample/data/rate size. As a result, applying correct
SNDCTL_DSP_POLICY value will achive expected latency behaviour simmilar
to what commercial 4front driver do.
* Signal handling fix. ctrl+c of "cat /dev/zero > /dev/dsp" does not
result long delay.
* Eliminate sound truncation if the sound data is too small.
DIY:
1) Download / extract
http://people.freebsd.org/~ariff/lowlatency/shortfiles.tar.gz
2) Do a comparison between "cat state*.au > /dev/dsp" and
"for x in state*.au ; do cat $x > /dev/dsp ; done"
- there should be no "perceivable" differences.
Double close for PR kern/31445.
CAVEAT: Low latency come with (unbearable) price especially for poorly
written applications. Applications that trying to act smarter
by requesting (wrong) blocksize/blockcount will suffer the most.
Fixup samples/patches can be found at:
http://people.freebsd.org/~ariff/ports/
- Switch minimum/maximum sampling rate limit to "1" and "2016000" (48k * 42)
due to closer compatibility with 4front driver.
Discussed with: marcus@ (long time ago?)
- All driver specific sysctls in the form of "hw.snd.pcm%d.*" have been
moved to their own dev sysctl nodes, notably:
hw.snd.pcm%d.vchans -> dev.pcm.%d.vchans
Bump __FreeBSD_version.
Driver specific
---------------
- Ditto for sysctls.
- snd_atiixp, snd_es137x, snd_via8233, snd_hda
* Numerous cleanups and fixes.
* _EXPERIMENTAL_ polling mode support using simple callout_* mechanisme.
This was intended for pure debugging and latency measurement, but proven
good enough in few unexpected and rare cases (such as problematic shared
IRQ with GIANT devices - USB). Polling can be enabled/disabled through
dev.pcm.0.polling. Disabled by default.
- snd_ich
* Fix possible overflow during speed calibration. Delay final
initialization (pcm_setstatus) after calibration finished.
PR: kern/100169
Tested by: Kevin Overman <oberman@es.net>
* Inverted EAPD for few Nec VersaPro.
PR: kern/104715
Submitted by: KAWATA Masahiko <kawata@mta.biglobe.ne.jp>
Thanks to various people, notably Joel Dahl, Yuriy Tsibizov, Kevin Oberman,
those at #freebsd-azalia @ freenode and others for testing.
Joel Dahl will do the manpage update.
2006-11-26 12:24:06 +00:00
|
|
|
data = sndbuf_zerodata(b->fmt);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
i = sndbuf_getfreeptr(b);
|
|
|
|
p = sndbuf_getbuf(b);
|
2001-03-05 16:45:38 +00:00
|
|
|
while (length > 0) {
|
|
|
|
p[i] = data;
|
|
|
|
length--;
|
|
|
|
i++;
|
|
|
|
if (i >= b->bufsize)
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
MFp4 the sound Google Summer of Code project:
The goal was to sync with the OSSv4 API 4Front Technologies uses in their
proprietary OSS driver. This was successful as far as possible. The part
of the API which is stable is implemented, for the rest there are some
stubs already.
New system ioctls:
- SNDCTL_SYSINFO - obtain audio system info (version, # of audio/midi/
mixer devices, etc.)
- SNDCTL_AUDIOINFO - fetch details about a specific audio device
- SNDCTL_MIXERINFO - fetch details about a specific mixer device
New audio ioctls:
- Sync groups (SNDCTL_DSP_SYNCGROUP/SNDCTL_DSP_SYNCSTART) which allow
triggered playback/recording on multiple devices (even across processes
simultaneously).
- Peak meters (SNDCTL_DSP_GETIPEAKS/SNDCTL_DSP_GETOPEAKS) - can query
audio drivers for peak levels (needs driver support, disabled for now).
- Per channel playback/recording levels -
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL. Note that these are still in name
only, just wrapping around the AC97-style mixer at the moment. The next
step is to push them down to the drivers.
Audio ioctls still under development by 4Front (for which stubs may exist
in this commit):
- SNDCTL_GETNAME, SNDCTL_{GET,SET}{SONG,LABEL}
- SNDCTL_DSP_{GET,SET}_CHNORDER
- SNDCTL_MIX_ENUMINFO, SNDCTL_MIX_EXTINFO - (might be documented enough in
the OSS releases to work on this. These ioctls cover the cool "twiddle
any knob on your card" features.)
Missing:
- SNDCTL_DSP_COOKEDMODE -- this ioctl is used to give applications direct
access to a card's buffers, bypassing the feeder architecture. It's
a toughy -- "someone" needs to decide :
(a) if this is desireable, and (b) if it's reasonably feasible.
Updates for driver writers:
So far, only two routines to the channel class (in channel_if.m) are added.
One is for fetching a list of discrete supported playback/recording rates
of a channel, and the other is for fetching peak level info (useful for
drawing peak meters). Interested parties may want to help pushing down
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL into the drivers.
To use the new stuff you need to rebuild the sound drivers or your kernel
(depending on if you use modules or not) and to install soundcard.h (a
buildworld/installworld handles this).
Sponsored by: Google SoC 2006
Submitted by: ryanb
Many thanks to: 4Front Technologies for their cooperation, explanations
and the nice license of their soundcard.h.
2006-09-23 20:45:47 +00:00
|
|
|
/**
|
|
|
|
* @brief Zap buffer contents, resetting "ready area" fields
|
|
|
|
*
|
|
|
|
* @param b buffer context
|
|
|
|
*/
|
2001-05-27 14:39:34 +00:00
|
|
|
void
|
|
|
|
sndbuf_fillsilence(struct snd_dbuf *b)
|
|
|
|
{
|
Welcome to Once-a-year Sound Mega-Commit. Enjoy numerous updates and fixes
in every sense.
General
-------
- Multichannel safe, endian safe, format safe
* Large part of critical pcm filters such as vchan.c, feeder_rate.c,
feeder_volume.c, feeder_fmt.c and feeder.c has been rewritten so that
using them does not cause the pcm data to be converted to 16bit little
endian.
* Macrosses for accessing pcm data safely are defined within sound.h in
the form of PCM_READ_* / PCM_WRITE_*
* Currently, most of them are probably limited for mono/stereo handling,
but the future addition of true multichannel will be much easier.
- Low latency operation
* Well, this require lot more works to do not just within sound driver,
but we're heading towards right direction. Buffer/block sizing within
channel.c is rewritten to calculate precise allocation for various
combination of sample/data/rate size. As a result, applying correct
SNDCTL_DSP_POLICY value will achive expected latency behaviour simmilar
to what commercial 4front driver do.
* Signal handling fix. ctrl+c of "cat /dev/zero > /dev/dsp" does not
result long delay.
* Eliminate sound truncation if the sound data is too small.
DIY:
1) Download / extract
http://people.freebsd.org/~ariff/lowlatency/shortfiles.tar.gz
2) Do a comparison between "cat state*.au > /dev/dsp" and
"for x in state*.au ; do cat $x > /dev/dsp ; done"
- there should be no "perceivable" differences.
Double close for PR kern/31445.
CAVEAT: Low latency come with (unbearable) price especially for poorly
written applications. Applications that trying to act smarter
by requesting (wrong) blocksize/blockcount will suffer the most.
Fixup samples/patches can be found at:
http://people.freebsd.org/~ariff/ports/
- Switch minimum/maximum sampling rate limit to "1" and "2016000" (48k * 42)
due to closer compatibility with 4front driver.
Discussed with: marcus@ (long time ago?)
- All driver specific sysctls in the form of "hw.snd.pcm%d.*" have been
moved to their own dev sysctl nodes, notably:
hw.snd.pcm%d.vchans -> dev.pcm.%d.vchans
Bump __FreeBSD_version.
Driver specific
---------------
- Ditto for sysctls.
- snd_atiixp, snd_es137x, snd_via8233, snd_hda
* Numerous cleanups and fixes.
* _EXPERIMENTAL_ polling mode support using simple callout_* mechanisme.
This was intended for pure debugging and latency measurement, but proven
good enough in few unexpected and rare cases (such as problematic shared
IRQ with GIANT devices - USB). Polling can be enabled/disabled through
dev.pcm.0.polling. Disabled by default.
- snd_ich
* Fix possible overflow during speed calibration. Delay final
initialization (pcm_setstatus) after calibration finished.
PR: kern/100169
Tested by: Kevin Overman <oberman@es.net>
* Inverted EAPD for few Nec VersaPro.
PR: kern/104715
Submitted by: KAWATA Masahiko <kawata@mta.biglobe.ne.jp>
Thanks to various people, notably Joel Dahl, Yuriy Tsibizov, Kevin Oberman,
those at #freebsd-azalia @ freenode and others for testing.
Joel Dahl will do the manpage update.
2006-11-26 12:24:06 +00:00
|
|
|
if (b->bufsize > 0)
|
|
|
|
memset(sndbuf_getbuf(b), sndbuf_zerodata(b->fmt), b->bufsize);
|
2001-05-27 14:39:34 +00:00
|
|
|
b->rp = 0;
|
|
|
|
b->rl = b->bufsize;
|
|
|
|
}
|
|
|
|
|
MFp4 the sound Google Summer of Code project:
The goal was to sync with the OSSv4 API 4Front Technologies uses in their
proprietary OSS driver. This was successful as far as possible. The part
of the API which is stable is implemented, for the rest there are some
stubs already.
New system ioctls:
- SNDCTL_SYSINFO - obtain audio system info (version, # of audio/midi/
mixer devices, etc.)
- SNDCTL_AUDIOINFO - fetch details about a specific audio device
- SNDCTL_MIXERINFO - fetch details about a specific mixer device
New audio ioctls:
- Sync groups (SNDCTL_DSP_SYNCGROUP/SNDCTL_DSP_SYNCSTART) which allow
triggered playback/recording on multiple devices (even across processes
simultaneously).
- Peak meters (SNDCTL_DSP_GETIPEAKS/SNDCTL_DSP_GETOPEAKS) - can query
audio drivers for peak levels (needs driver support, disabled for now).
- Per channel playback/recording levels -
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL. Note that these are still in name
only, just wrapping around the AC97-style mixer at the moment. The next
step is to push them down to the drivers.
Audio ioctls still under development by 4Front (for which stubs may exist
in this commit):
- SNDCTL_GETNAME, SNDCTL_{GET,SET}{SONG,LABEL}
- SNDCTL_DSP_{GET,SET}_CHNORDER
- SNDCTL_MIX_ENUMINFO, SNDCTL_MIX_EXTINFO - (might be documented enough in
the OSS releases to work on this. These ioctls cover the cool "twiddle
any knob on your card" features.)
Missing:
- SNDCTL_DSP_COOKEDMODE -- this ioctl is used to give applications direct
access to a card's buffers, bypassing the feeder architecture. It's
a toughy -- "someone" needs to decide :
(a) if this is desireable, and (b) if it's reasonably feasible.
Updates for driver writers:
So far, only two routines to the channel class (in channel_if.m) are added.
One is for fetching a list of discrete supported playback/recording rates
of a channel, and the other is for fetching peak level info (useful for
drawing peak meters). Interested parties may want to help pushing down
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL into the drivers.
To use the new stuff you need to rebuild the sound drivers or your kernel
(depending on if you use modules or not) and to install soundcard.h (a
buildworld/installworld handles this).
Sponsored by: Google SoC 2006
Submitted by: ryanb
Many thanks to: 4Front Technologies for their cooperation, explanations
and the nice license of their soundcard.h.
2006-09-23 20:45:47 +00:00
|
|
|
/**
|
|
|
|
* @brief Reset buffer w/o flushing statistics
|
|
|
|
*
|
|
|
|
* This function just zeroes out buffer contents and sets the "ready length"
|
|
|
|
* to zero. This was originally to facilitate minimal playback interruption
|
|
|
|
* (i.e., dropped samples) in SNDCTL_DSP_SILENCE/SKIP ioctls.
|
|
|
|
*
|
|
|
|
* @param b buffer context
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
sndbuf_softreset(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
b->rl = 0;
|
|
|
|
if (b->buf && b->bufsize > 0)
|
|
|
|
sndbuf_clear(b, b->bufsize);
|
|
|
|
}
|
|
|
|
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
void
|
2001-03-24 23:10:29 +00:00
|
|
|
sndbuf_reset(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
b->hp = 0;
|
|
|
|
b->rp = 0;
|
|
|
|
b->rl = 0;
|
|
|
|
b->dl = 0;
|
|
|
|
b->prev_total = 0;
|
|
|
|
b->total = 0;
|
|
|
|
b->xrun = 0;
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
if (b->buf && b->bufsize > 0)
|
|
|
|
sndbuf_clear(b, b->bufsize);
|
MFp4 the sound Google Summer of Code project:
The goal was to sync with the OSSv4 API 4Front Technologies uses in their
proprietary OSS driver. This was successful as far as possible. The part
of the API which is stable is implemented, for the rest there are some
stubs already.
New system ioctls:
- SNDCTL_SYSINFO - obtain audio system info (version, # of audio/midi/
mixer devices, etc.)
- SNDCTL_AUDIOINFO - fetch details about a specific audio device
- SNDCTL_MIXERINFO - fetch details about a specific mixer device
New audio ioctls:
- Sync groups (SNDCTL_DSP_SYNCGROUP/SNDCTL_DSP_SYNCSTART) which allow
triggered playback/recording on multiple devices (even across processes
simultaneously).
- Peak meters (SNDCTL_DSP_GETIPEAKS/SNDCTL_DSP_GETOPEAKS) - can query
audio drivers for peak levels (needs driver support, disabled for now).
- Per channel playback/recording levels -
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL. Note that these are still in name
only, just wrapping around the AC97-style mixer at the moment. The next
step is to push them down to the drivers.
Audio ioctls still under development by 4Front (for which stubs may exist
in this commit):
- SNDCTL_GETNAME, SNDCTL_{GET,SET}{SONG,LABEL}
- SNDCTL_DSP_{GET,SET}_CHNORDER
- SNDCTL_MIX_ENUMINFO, SNDCTL_MIX_EXTINFO - (might be documented enough in
the OSS releases to work on this. These ioctls cover the cool "twiddle
any knob on your card" features.)
Missing:
- SNDCTL_DSP_COOKEDMODE -- this ioctl is used to give applications direct
access to a card's buffers, bypassing the feeder architecture. It's
a toughy -- "someone" needs to decide :
(a) if this is desireable, and (b) if it's reasonably feasible.
Updates for driver writers:
So far, only two routines to the channel class (in channel_if.m) are added.
One is for fetching a list of discrete supported playback/recording rates
of a channel, and the other is for fetching peak level info (useful for
drawing peak meters). Interested parties may want to help pushing down
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL into the drivers.
To use the new stuff you need to rebuild the sound drivers or your kernel
(depending on if you use modules or not) and to install soundcard.h (a
buildworld/installworld handles this).
Sponsored by: Google SoC 2006
Submitted by: ryanb
Many thanks to: 4Front Technologies for their cooperation, explanations
and the nice license of their soundcard.h.
2006-09-23 20:45:47 +00:00
|
|
|
sndbuf_clearshadow(b);
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
}
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
u_int32_t
|
|
|
|
sndbuf_getfmt(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
return b->fmt;
|
|
|
|
}
|
|
|
|
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
int
|
2001-03-24 23:10:29 +00:00
|
|
|
sndbuf_setfmt(struct snd_dbuf *b, u_int32_t fmt)
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
{
|
|
|
|
b->fmt = fmt;
|
|
|
|
b->bps = 1;
|
|
|
|
b->bps <<= (b->fmt & AFMT_STEREO)? 1 : 0;
|
Whats New:
1. Support wide range sampling rate, as low as 1hz up to int32 max
(which is, insane) through new feeder_rate, multiple precisions
choice (32/64 bit converter). This is indeed, quite insane, but it
does give us more room and flexibility. Plenty sysctl options to
adjust resampling characteristics.
2. Support 24/32 bit pcm format conversion through new, much improved,
simplified and optimized feeder_fmt.
Changes:
1. buffer.c / dsp.c / sound.h
* Support for 24/32 AFMT.
2. feeder_rate.c
* New implementation of sampling rate conversion with 32/64 bit
precision, 1 - int32max hz (which is, ridiculous, yet very
addictive). Much improved / smarter buffer management to not
cause any missing samples at the end of conversion process
* Tunable sysctls for various aspect:
hw.snd.feeder_rate_ratemin - minimum allowable sampling rate
(default to 4000)
hw.snd.feeder_rate_ratemax - maximum allowable sampling rate
(default to 1102500)
hw.snd.feeder_rate_buffersize - conversion buffer size
(default to 8192)
hw.snd.feeder_rate_scaling - scaling / conversion method
(please refer to the source for explaination). Default to
previous implementation type.
3. feeder_fmt.c / sound.h
* New implementation, support for 24/32bit conversion, optimized,
and simplified. Few routines has been removed (8 to xlaw, 16 to
8). It just doesn't make sense.
4. channel.c
* Support for 24/32 AFMT
* Fix wrong xruns increment, causing incorrect underruns statistic
while using vchans.
5. vchan.c
* Support for 24/32 AFMT
* Proper speed / rate detection especially for fixed rate ac97.
User can override it using kernel hint:
hint.pcm.<unit>.vchanrate="xxxx".
Notes / Issues:
* Virtual Channels (vchans)
Enabling vchans can really, really help to solve overrun
issues. This is quite understandable, because it operates
entirely within its own buffering system without relying on
hardware interrupt / state. Even if you don't need vchan,
just enable single channel can help much. Few soundcards
(notably via8233x, sblive, possibly others) have their own
hardware multi channel, and this is unfortunately beyond
vchan reachability.
* The arrival of 24/32 also come with a price. Applications
that can do 24/32bit playback need to be recompiled (notably
mplayer). Use (recompiled) mplayer to experiment / test /
debug this various format using -af format=fmt. Note that
24bit seeking in mplayer is a little bit broken, sometimes
can cause silence or loud static noise. Pausing / seeking
few times can solve this problem.
You don't have to rebuild world entirely for this. Simply
copy /usr/src/sys/sys/soundcard.h to
/usr/include/sys/soundcard.h would suffice. Few drivers also
need recompilation, and this can be done via
/usr/src/sys/modules/sound/.
Support for 24bit hardware playback is beyond the scope of
this changes. That would require spessific hardware driver
changes.
* Don't expect playing 9999999999hz is a wise decision. Be
reasonable. The new feeder_rate implemention provide
flexibility, not insanity. You can easily chew up your CPU
with this kind of mind instability. Please use proper
mosquito repellent device for this obvious cracked brain
attempt. As for testing purposes, you can use (again)
mplayer to generate / play with different sampling rate. Use
something like "mplayer -af resample=192000:0:0 <files>".
Submitted by: Ariff Abdullah <skywizard@MyBSD.org.my>
Tested by: multimedia@
2005-07-31 16:16:22 +00:00
|
|
|
if (b->fmt & AFMT_16BIT)
|
|
|
|
b->bps <<= 1;
|
|
|
|
else if (b->fmt & AFMT_24BIT)
|
|
|
|
b->bps *= 3;
|
|
|
|
else if (b->fmt & AFMT_32BIT)
|
|
|
|
b->bps <<= 2;
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
unsigned int
|
|
|
|
sndbuf_getspd(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
return b->spd;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sndbuf_setspd(struct snd_dbuf *b, unsigned int spd)
|
|
|
|
{
|
|
|
|
b->spd = spd;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
sndbuf_getalign(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
static int align[] = {0, 1, 1, 2, 2, 2, 2, 3};
|
|
|
|
|
|
|
|
return align[b->bps - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
sndbuf_getblkcnt(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
return b->blkcnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sndbuf_setblkcnt(struct snd_dbuf *b, unsigned int blkcnt)
|
|
|
|
{
|
|
|
|
b->blkcnt = blkcnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
sndbuf_getblksz(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
return b->blksz;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sndbuf_setblksz(struct snd_dbuf *b, unsigned int blksz)
|
|
|
|
{
|
|
|
|
b->blksz = blksz;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
sndbuf_getbps(struct snd_dbuf *b)
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
{
|
|
|
|
return b->bps;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
2001-03-24 23:10:29 +00:00
|
|
|
sndbuf_getbuf(struct snd_dbuf *b)
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
{
|
|
|
|
return b->buf;
|
|
|
|
}
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
void *
|
|
|
|
sndbuf_getbufofs(struct snd_dbuf *b, unsigned int ofs)
|
|
|
|
{
|
2002-01-25 02:39:34 +00:00
|
|
|
KASSERT(ofs < b->bufsize, ("%s: ofs invalid %d", __func__, ofs));
|
2001-03-24 23:10:29 +00:00
|
|
|
|
|
|
|
return b->buf + ofs;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
sndbuf_getsize(struct snd_dbuf *b)
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
{
|
|
|
|
return b->bufsize;
|
|
|
|
}
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
unsigned int
|
|
|
|
sndbuf_getmaxsize(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
return b->maxsize;
|
|
|
|
}
|
|
|
|
|
2007-06-14 11:15:51 +00:00
|
|
|
unsigned int
|
|
|
|
sndbuf_getallocsize(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
return b->allocsize;
|
|
|
|
}
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
unsigned int
|
|
|
|
sndbuf_runsz(struct snd_dbuf *b)
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
{
|
|
|
|
return b->dl;
|
|
|
|
}
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
void
|
|
|
|
sndbuf_setrun(struct snd_dbuf *b, int go)
|
|
|
|
{
|
|
|
|
b->dl = go? b->blksz : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct selinfo *
|
|
|
|
sndbuf_getsel(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
return &b->sel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************/
|
|
|
|
unsigned int
|
|
|
|
sndbuf_getxrun(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
SNDBUF_LOCKASSERT(b);
|
|
|
|
|
|
|
|
return b->xrun;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-17 17:43:06 +00:00
|
|
|
sndbuf_setxrun(struct snd_dbuf *b, unsigned int xrun)
|
2001-03-24 23:10:29 +00:00
|
|
|
{
|
|
|
|
SNDBUF_LOCKASSERT(b);
|
|
|
|
|
2006-07-17 17:43:06 +00:00
|
|
|
b->xrun = xrun;
|
2001-03-24 23:10:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
sndbuf_gethwptr(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
SNDBUF_LOCKASSERT(b);
|
|
|
|
|
|
|
|
return b->hp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sndbuf_sethwptr(struct snd_dbuf *b, unsigned int ptr)
|
|
|
|
{
|
|
|
|
SNDBUF_LOCKASSERT(b);
|
|
|
|
|
|
|
|
b->hp = ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
sndbuf_getready(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
SNDBUF_LOCKASSERT(b);
|
2001-12-10 08:09:49 +00:00
|
|
|
KASSERT((b->rl >= 0) && (b->rl <= b->bufsize), ("%s: b->rl invalid %d", __func__, b->rl));
|
2001-03-24 23:10:29 +00:00
|
|
|
|
|
|
|
return b->rl;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
sndbuf_getreadyptr(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
SNDBUF_LOCKASSERT(b);
|
2001-12-10 08:09:49 +00:00
|
|
|
KASSERT((b->rp >= 0) && (b->rp <= b->bufsize), ("%s: b->rp invalid %d", __func__, b->rp));
|
2001-03-24 23:10:29 +00:00
|
|
|
|
|
|
|
return b->rp;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
sndbuf_getfree(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
SNDBUF_LOCKASSERT(b);
|
2001-12-10 08:09:49 +00:00
|
|
|
KASSERT((b->rl >= 0) && (b->rl <= b->bufsize), ("%s: b->rl invalid %d", __func__, b->rl));
|
2001-03-24 23:10:29 +00:00
|
|
|
|
|
|
|
return b->bufsize - b->rl;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
sndbuf_getfreeptr(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
SNDBUF_LOCKASSERT(b);
|
2001-12-10 08:09:49 +00:00
|
|
|
KASSERT((b->rp >= 0) && (b->rp <= b->bufsize), ("%s: b->rp invalid %d", __func__, b->rp));
|
|
|
|
KASSERT((b->rl >= 0) && (b->rl <= b->bufsize), ("%s: b->rl invalid %d", __func__, b->rl));
|
2001-03-24 23:10:29 +00:00
|
|
|
|
|
|
|
return (b->rp + b->rl) % b->bufsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
sndbuf_getblocks(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
SNDBUF_LOCKASSERT(b);
|
|
|
|
|
|
|
|
return b->total / b->blksz;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
sndbuf_getprevblocks(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
SNDBUF_LOCKASSERT(b);
|
|
|
|
|
|
|
|
return b->prev_total / b->blksz;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
sndbuf_gettotal(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
SNDBUF_LOCKASSERT(b);
|
|
|
|
|
|
|
|
return b->total;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sndbuf_updateprevtotal(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
SNDBUF_LOCKASSERT(b);
|
|
|
|
|
|
|
|
b->prev_total = b->total;
|
|
|
|
}
|
|
|
|
|
Welcome to Once-a-year Sound Mega-Commit. Enjoy numerous updates and fixes
in every sense.
General
-------
- Multichannel safe, endian safe, format safe
* Large part of critical pcm filters such as vchan.c, feeder_rate.c,
feeder_volume.c, feeder_fmt.c and feeder.c has been rewritten so that
using them does not cause the pcm data to be converted to 16bit little
endian.
* Macrosses for accessing pcm data safely are defined within sound.h in
the form of PCM_READ_* / PCM_WRITE_*
* Currently, most of them are probably limited for mono/stereo handling,
but the future addition of true multichannel will be much easier.
- Low latency operation
* Well, this require lot more works to do not just within sound driver,
but we're heading towards right direction. Buffer/block sizing within
channel.c is rewritten to calculate precise allocation for various
combination of sample/data/rate size. As a result, applying correct
SNDCTL_DSP_POLICY value will achive expected latency behaviour simmilar
to what commercial 4front driver do.
* Signal handling fix. ctrl+c of "cat /dev/zero > /dev/dsp" does not
result long delay.
* Eliminate sound truncation if the sound data is too small.
DIY:
1) Download / extract
http://people.freebsd.org/~ariff/lowlatency/shortfiles.tar.gz
2) Do a comparison between "cat state*.au > /dev/dsp" and
"for x in state*.au ; do cat $x > /dev/dsp ; done"
- there should be no "perceivable" differences.
Double close for PR kern/31445.
CAVEAT: Low latency come with (unbearable) price especially for poorly
written applications. Applications that trying to act smarter
by requesting (wrong) blocksize/blockcount will suffer the most.
Fixup samples/patches can be found at:
http://people.freebsd.org/~ariff/ports/
- Switch minimum/maximum sampling rate limit to "1" and "2016000" (48k * 42)
due to closer compatibility with 4front driver.
Discussed with: marcus@ (long time ago?)
- All driver specific sysctls in the form of "hw.snd.pcm%d.*" have been
moved to their own dev sysctl nodes, notably:
hw.snd.pcm%d.vchans -> dev.pcm.%d.vchans
Bump __FreeBSD_version.
Driver specific
---------------
- Ditto for sysctls.
- snd_atiixp, snd_es137x, snd_via8233, snd_hda
* Numerous cleanups and fixes.
* _EXPERIMENTAL_ polling mode support using simple callout_* mechanisme.
This was intended for pure debugging and latency measurement, but proven
good enough in few unexpected and rare cases (such as problematic shared
IRQ with GIANT devices - USB). Polling can be enabled/disabled through
dev.pcm.0.polling. Disabled by default.
- snd_ich
* Fix possible overflow during speed calibration. Delay final
initialization (pcm_setstatus) after calibration finished.
PR: kern/100169
Tested by: Kevin Overman <oberman@es.net>
* Inverted EAPD for few Nec VersaPro.
PR: kern/104715
Submitted by: KAWATA Masahiko <kawata@mta.biglobe.ne.jp>
Thanks to various people, notably Joel Dahl, Yuriy Tsibizov, Kevin Oberman,
those at #freebsd-azalia @ freenode and others for testing.
Joel Dahl will do the manpage update.
2006-11-26 12:24:06 +00:00
|
|
|
unsigned int
|
|
|
|
snd_xbytes(unsigned int v, unsigned int from, unsigned int to)
|
|
|
|
{
|
|
|
|
unsigned int w, x, y;
|
|
|
|
|
|
|
|
if (from == to)
|
|
|
|
return v;
|
|
|
|
|
|
|
|
if (from == 0 || to == 0 || v == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
x = from;
|
|
|
|
y = to;
|
|
|
|
while (y != 0) {
|
|
|
|
w = x % y;
|
|
|
|
x = y;
|
|
|
|
y = w;
|
|
|
|
}
|
|
|
|
from /= x;
|
|
|
|
to /= x;
|
|
|
|
|
|
|
|
return (unsigned int)(((u_int64_t)v * to) / from);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
sndbuf_xbytes(unsigned int v, struct snd_dbuf *from, struct snd_dbuf *to)
|
|
|
|
{
|
|
|
|
if (from == NULL || to == NULL || v == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return snd_xbytes(v, sndbuf_getbps(from) * sndbuf_getspd(from),
|
|
|
|
sndbuf_getbps(to) * sndbuf_getspd(to));
|
|
|
|
}
|
|
|
|
|
|
|
|
u_int8_t
|
|
|
|
sndbuf_zerodata(u_int32_t fmt)
|
|
|
|
{
|
|
|
|
if (fmt & AFMT_SIGNED)
|
|
|
|
return (0x00);
|
|
|
|
else if (fmt & AFMT_MU_LAW)
|
|
|
|
return (0x7f);
|
|
|
|
else if (fmt & AFMT_A_LAW)
|
|
|
|
return (0x55);
|
|
|
|
return (0x80);
|
|
|
|
}
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
/************************************************************/
|
|
|
|
|
MFp4 the sound Google Summer of Code project:
The goal was to sync with the OSSv4 API 4Front Technologies uses in their
proprietary OSS driver. This was successful as far as possible. The part
of the API which is stable is implemented, for the rest there are some
stubs already.
New system ioctls:
- SNDCTL_SYSINFO - obtain audio system info (version, # of audio/midi/
mixer devices, etc.)
- SNDCTL_AUDIOINFO - fetch details about a specific audio device
- SNDCTL_MIXERINFO - fetch details about a specific mixer device
New audio ioctls:
- Sync groups (SNDCTL_DSP_SYNCGROUP/SNDCTL_DSP_SYNCSTART) which allow
triggered playback/recording on multiple devices (even across processes
simultaneously).
- Peak meters (SNDCTL_DSP_GETIPEAKS/SNDCTL_DSP_GETOPEAKS) - can query
audio drivers for peak levels (needs driver support, disabled for now).
- Per channel playback/recording levels -
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL. Note that these are still in name
only, just wrapping around the AC97-style mixer at the moment. The next
step is to push them down to the drivers.
Audio ioctls still under development by 4Front (for which stubs may exist
in this commit):
- SNDCTL_GETNAME, SNDCTL_{GET,SET}{SONG,LABEL}
- SNDCTL_DSP_{GET,SET}_CHNORDER
- SNDCTL_MIX_ENUMINFO, SNDCTL_MIX_EXTINFO - (might be documented enough in
the OSS releases to work on this. These ioctls cover the cool "twiddle
any knob on your card" features.)
Missing:
- SNDCTL_DSP_COOKEDMODE -- this ioctl is used to give applications direct
access to a card's buffers, bypassing the feeder architecture. It's
a toughy -- "someone" needs to decide :
(a) if this is desireable, and (b) if it's reasonably feasible.
Updates for driver writers:
So far, only two routines to the channel class (in channel_if.m) are added.
One is for fetching a list of discrete supported playback/recording rates
of a channel, and the other is for fetching peak level info (useful for
drawing peak meters). Interested parties may want to help pushing down
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL into the drivers.
To use the new stuff you need to rebuild the sound drivers or your kernel
(depending on if you use modules or not) and to install soundcard.h (a
buildworld/installworld handles this).
Sponsored by: Google SoC 2006
Submitted by: ryanb
Many thanks to: 4Front Technologies for their cooperation, explanations
and the nice license of their soundcard.h.
2006-09-23 20:45:47 +00:00
|
|
|
/**
|
|
|
|
* @brief Acquire buffer space to extend ready area
|
|
|
|
*
|
|
|
|
* This function extends the ready area length by @c count bytes, and may
|
|
|
|
* optionally copy samples from another location stored in @c from. The
|
|
|
|
* counter @c snd_dbuf::total is also incremented by @c count bytes.
|
|
|
|
*
|
|
|
|
* @param b audio buffer
|
|
|
|
* @param from sample source (optional)
|
|
|
|
* @param count number of bytes to acquire
|
|
|
|
*
|
|
|
|
* @retval 0 Unconditional
|
|
|
|
*/
|
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the
sample rate and format in use. it will aim for a power of two size small
enough to generate block sizes of at most 20ms. it will also set the
hard-blocksize taking into account rate/format conversions in use.
update drivers to implement setblocksize correctly:
updated, tested: sb16, emu10k1, maestro, solo
updated, untested: ad1816, ess, mss, sb8, csa
not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686
i lack hardware to test: ad1816, csa, fm801, neomagic
others will be updated/tested in the next few days.
2000-12-23 03:16:13 +00:00
|
|
|
int
|
2001-03-24 23:10:29 +00:00
|
|
|
sndbuf_acquire(struct snd_dbuf *b, u_int8_t *from, unsigned int count)
|
|
|
|
{
|
|
|
|
int l;
|
|
|
|
|
2001-12-10 08:09:49 +00:00
|
|
|
KASSERT(count <= sndbuf_getfree(b), ("%s: count %d > free %d", __func__, count, sndbuf_getfree(b)));
|
|
|
|
KASSERT((b->rl >= 0) && (b->rl <= b->bufsize), ("%s: b->rl invalid %d", __func__, b->rl));
|
2001-03-24 23:10:29 +00:00
|
|
|
b->total += count;
|
|
|
|
if (from != NULL) {
|
|
|
|
while (count > 0) {
|
2007-03-16 17:13:44 +00:00
|
|
|
l = min(count, sndbuf_getsize(b) - sndbuf_getfreeptr(b));
|
2001-03-24 23:10:29 +00:00
|
|
|
bcopy(from, sndbuf_getbufofs(b, sndbuf_getfreeptr(b)), l);
|
|
|
|
from += l;
|
|
|
|
b->rl += l;
|
|
|
|
count -= l;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
b->rl += count;
|
2001-12-10 08:09:49 +00:00
|
|
|
KASSERT((b->rl >= 0) && (b->rl <= b->bufsize), ("%s: b->rl invalid %d, count %d", __func__, b->rl, count));
|
2001-03-24 23:10:29 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
MFp4 the sound Google Summer of Code project:
The goal was to sync with the OSSv4 API 4Front Technologies uses in their
proprietary OSS driver. This was successful as far as possible. The part
of the API which is stable is implemented, for the rest there are some
stubs already.
New system ioctls:
- SNDCTL_SYSINFO - obtain audio system info (version, # of audio/midi/
mixer devices, etc.)
- SNDCTL_AUDIOINFO - fetch details about a specific audio device
- SNDCTL_MIXERINFO - fetch details about a specific mixer device
New audio ioctls:
- Sync groups (SNDCTL_DSP_SYNCGROUP/SNDCTL_DSP_SYNCSTART) which allow
triggered playback/recording on multiple devices (even across processes
simultaneously).
- Peak meters (SNDCTL_DSP_GETIPEAKS/SNDCTL_DSP_GETOPEAKS) - can query
audio drivers for peak levels (needs driver support, disabled for now).
- Per channel playback/recording levels -
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL. Note that these are still in name
only, just wrapping around the AC97-style mixer at the moment. The next
step is to push them down to the drivers.
Audio ioctls still under development by 4Front (for which stubs may exist
in this commit):
- SNDCTL_GETNAME, SNDCTL_{GET,SET}{SONG,LABEL}
- SNDCTL_DSP_{GET,SET}_CHNORDER
- SNDCTL_MIX_ENUMINFO, SNDCTL_MIX_EXTINFO - (might be documented enough in
the OSS releases to work on this. These ioctls cover the cool "twiddle
any knob on your card" features.)
Missing:
- SNDCTL_DSP_COOKEDMODE -- this ioctl is used to give applications direct
access to a card's buffers, bypassing the feeder architecture. It's
a toughy -- "someone" needs to decide :
(a) if this is desireable, and (b) if it's reasonably feasible.
Updates for driver writers:
So far, only two routines to the channel class (in channel_if.m) are added.
One is for fetching a list of discrete supported playback/recording rates
of a channel, and the other is for fetching peak level info (useful for
drawing peak meters). Interested parties may want to help pushing down
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL into the drivers.
To use the new stuff you need to rebuild the sound drivers or your kernel
(depending on if you use modules or not) and to install soundcard.h (a
buildworld/installworld handles this).
Sponsored by: Google SoC 2006
Submitted by: ryanb
Many thanks to: 4Front Technologies for their cooperation, explanations
and the nice license of their soundcard.h.
2006-09-23 20:45:47 +00:00
|
|
|
/**
|
|
|
|
* @brief Dispose samples from channel buffer, increasing size of ready area
|
|
|
|
*
|
|
|
|
* This function discards samples from the supplied buffer by advancing the
|
|
|
|
* ready area start pointer and decrementing the ready area length. If
|
|
|
|
* @c to is not NULL, then the discard samples will be copied to the location
|
|
|
|
* it points to.
|
|
|
|
*
|
|
|
|
* @param b PCM channel sound buffer
|
|
|
|
* @param to destination buffer (optional)
|
|
|
|
* @param count number of bytes to discard
|
|
|
|
*
|
|
|
|
* @returns 0 unconditionally
|
|
|
|
*/
|
2001-03-24 23:10:29 +00:00
|
|
|
int
|
|
|
|
sndbuf_dispose(struct snd_dbuf *b, u_int8_t *to, unsigned int count)
|
|
|
|
{
|
|
|
|
int l;
|
|
|
|
|
2001-12-10 08:09:49 +00:00
|
|
|
KASSERT(count <= sndbuf_getready(b), ("%s: count %d > ready %d", __func__, count, sndbuf_getready(b)));
|
|
|
|
KASSERT((b->rl >= 0) && (b->rl <= b->bufsize), ("%s: b->rl invalid %d", __func__, b->rl));
|
2001-03-24 23:10:29 +00:00
|
|
|
if (to != NULL) {
|
|
|
|
while (count > 0) {
|
2007-03-16 17:13:44 +00:00
|
|
|
l = min(count, sndbuf_getsize(b) - sndbuf_getreadyptr(b));
|
2001-03-24 23:10:29 +00:00
|
|
|
bcopy(sndbuf_getbufofs(b, sndbuf_getreadyptr(b)), to, l);
|
|
|
|
to += l;
|
|
|
|
b->rl -= l;
|
|
|
|
b->rp = (b->rp + l) % b->bufsize;
|
|
|
|
count -= l;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
b->rl -= count;
|
|
|
|
b->rp = (b->rp + count) % b->bufsize;
|
|
|
|
}
|
2001-12-10 08:09:49 +00:00
|
|
|
KASSERT((b->rl >= 0) && (b->rl <= b->bufsize), ("%s: b->rl invalid %d, count %d", __func__, b->rl, count));
|
2001-03-24 23:10:29 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* count is number of bytes we want added to destination buffer */
|
|
|
|
int
|
|
|
|
sndbuf_feed(struct snd_dbuf *from, struct snd_dbuf *to, struct pcm_channel *channel, struct pcm_feeder *feeder, unsigned int count)
|
|
|
|
{
|
Welcome to Once-a-year Sound Mega-Commit. Enjoy numerous updates and fixes
in every sense.
General
-------
- Multichannel safe, endian safe, format safe
* Large part of critical pcm filters such as vchan.c, feeder_rate.c,
feeder_volume.c, feeder_fmt.c and feeder.c has been rewritten so that
using them does not cause the pcm data to be converted to 16bit little
endian.
* Macrosses for accessing pcm data safely are defined within sound.h in
the form of PCM_READ_* / PCM_WRITE_*
* Currently, most of them are probably limited for mono/stereo handling,
but the future addition of true multichannel will be much easier.
- Low latency operation
* Well, this require lot more works to do not just within sound driver,
but we're heading towards right direction. Buffer/block sizing within
channel.c is rewritten to calculate precise allocation for various
combination of sample/data/rate size. As a result, applying correct
SNDCTL_DSP_POLICY value will achive expected latency behaviour simmilar
to what commercial 4front driver do.
* Signal handling fix. ctrl+c of "cat /dev/zero > /dev/dsp" does not
result long delay.
* Eliminate sound truncation if the sound data is too small.
DIY:
1) Download / extract
http://people.freebsd.org/~ariff/lowlatency/shortfiles.tar.gz
2) Do a comparison between "cat state*.au > /dev/dsp" and
"for x in state*.au ; do cat $x > /dev/dsp ; done"
- there should be no "perceivable" differences.
Double close for PR kern/31445.
CAVEAT: Low latency come with (unbearable) price especially for poorly
written applications. Applications that trying to act smarter
by requesting (wrong) blocksize/blockcount will suffer the most.
Fixup samples/patches can be found at:
http://people.freebsd.org/~ariff/ports/
- Switch minimum/maximum sampling rate limit to "1" and "2016000" (48k * 42)
due to closer compatibility with 4front driver.
Discussed with: marcus@ (long time ago?)
- All driver specific sysctls in the form of "hw.snd.pcm%d.*" have been
moved to their own dev sysctl nodes, notably:
hw.snd.pcm%d.vchans -> dev.pcm.%d.vchans
Bump __FreeBSD_version.
Driver specific
---------------
- Ditto for sysctls.
- snd_atiixp, snd_es137x, snd_via8233, snd_hda
* Numerous cleanups and fixes.
* _EXPERIMENTAL_ polling mode support using simple callout_* mechanisme.
This was intended for pure debugging and latency measurement, but proven
good enough in few unexpected and rare cases (such as problematic shared
IRQ with GIANT devices - USB). Polling can be enabled/disabled through
dev.pcm.0.polling. Disabled by default.
- snd_ich
* Fix possible overflow during speed calibration. Delay final
initialization (pcm_setstatus) after calibration finished.
PR: kern/100169
Tested by: Kevin Overman <oberman@es.net>
* Inverted EAPD for few Nec VersaPro.
PR: kern/104715
Submitted by: KAWATA Masahiko <kawata@mta.biglobe.ne.jp>
Thanks to various people, notably Joel Dahl, Yuriy Tsibizov, Kevin Oberman,
those at #freebsd-azalia @ freenode and others for testing.
Joel Dahl will do the manpage update.
2006-11-26 12:24:06 +00:00
|
|
|
unsigned int cnt;
|
|
|
|
|
2001-05-27 14:39:34 +00:00
|
|
|
KASSERT(count > 0, ("can't feed 0 bytes"));
|
|
|
|
|
2001-03-24 23:10:29 +00:00
|
|
|
if (sndbuf_getfree(to) < count)
|
|
|
|
return EINVAL;
|
|
|
|
|
Welcome to Once-a-year Sound Mega-Commit. Enjoy numerous updates and fixes
in every sense.
General
-------
- Multichannel safe, endian safe, format safe
* Large part of critical pcm filters such as vchan.c, feeder_rate.c,
feeder_volume.c, feeder_fmt.c and feeder.c has been rewritten so that
using them does not cause the pcm data to be converted to 16bit little
endian.
* Macrosses for accessing pcm data safely are defined within sound.h in
the form of PCM_READ_* / PCM_WRITE_*
* Currently, most of them are probably limited for mono/stereo handling,
but the future addition of true multichannel will be much easier.
- Low latency operation
* Well, this require lot more works to do not just within sound driver,
but we're heading towards right direction. Buffer/block sizing within
channel.c is rewritten to calculate precise allocation for various
combination of sample/data/rate size. As a result, applying correct
SNDCTL_DSP_POLICY value will achive expected latency behaviour simmilar
to what commercial 4front driver do.
* Signal handling fix. ctrl+c of "cat /dev/zero > /dev/dsp" does not
result long delay.
* Eliminate sound truncation if the sound data is too small.
DIY:
1) Download / extract
http://people.freebsd.org/~ariff/lowlatency/shortfiles.tar.gz
2) Do a comparison between "cat state*.au > /dev/dsp" and
"for x in state*.au ; do cat $x > /dev/dsp ; done"
- there should be no "perceivable" differences.
Double close for PR kern/31445.
CAVEAT: Low latency come with (unbearable) price especially for poorly
written applications. Applications that trying to act smarter
by requesting (wrong) blocksize/blockcount will suffer the most.
Fixup samples/patches can be found at:
http://people.freebsd.org/~ariff/ports/
- Switch minimum/maximum sampling rate limit to "1" and "2016000" (48k * 42)
due to closer compatibility with 4front driver.
Discussed with: marcus@ (long time ago?)
- All driver specific sysctls in the form of "hw.snd.pcm%d.*" have been
moved to their own dev sysctl nodes, notably:
hw.snd.pcm%d.vchans -> dev.pcm.%d.vchans
Bump __FreeBSD_version.
Driver specific
---------------
- Ditto for sysctls.
- snd_atiixp, snd_es137x, snd_via8233, snd_hda
* Numerous cleanups and fixes.
* _EXPERIMENTAL_ polling mode support using simple callout_* mechanisme.
This was intended for pure debugging and latency measurement, but proven
good enough in few unexpected and rare cases (such as problematic shared
IRQ with GIANT devices - USB). Polling can be enabled/disabled through
dev.pcm.0.polling. Disabled by default.
- snd_ich
* Fix possible overflow during speed calibration. Delay final
initialization (pcm_setstatus) after calibration finished.
PR: kern/100169
Tested by: Kevin Overman <oberman@es.net>
* Inverted EAPD for few Nec VersaPro.
PR: kern/104715
Submitted by: KAWATA Masahiko <kawata@mta.biglobe.ne.jp>
Thanks to various people, notably Joel Dahl, Yuriy Tsibizov, Kevin Oberman,
those at #freebsd-azalia @ freenode and others for testing.
Joel Dahl will do the manpage update.
2006-11-26 12:24:06 +00:00
|
|
|
do {
|
|
|
|
cnt = FEEDER_FEED(feeder, channel, to->tmpbuf, count, from);
|
Last major commit and updates for RELENG_7:
- Rework the entire pcm_channel structure:
* Remove rarely used link placeholder, instead, make each pcm_channel
as head/link of each own/each other. Unlock - Lock sequence due to
sleep malloc has been reduced.
* Implement "busy" queue which will contain list of busy/active
channels. This greatly reduce locking contention for example while
servicing interrupt for hardware with many channels or when virtual
channels reach its 256 peak channels.
- So I heard you like v chan ... O RLY?
Welcome to Virtual **Record** Channels (vrec, rec vchans, vchans for
recording, Rec-Chan, you decide), the ultimate solutions for your
nagging O_RDWR full-duplex wannabe (note: flash plugins) monopolizing
single record channel causing EBUSY. Vrec works exactly like Vchans
(or, should I rename it to "Vplay" :) , except that it operates on the
opposite direction (recording). Up to 256 vrecs (like vchans) are
possible.
Notes:
* Relocate dev.pcm.%d.{vchans,vchanformat,vchanrate} to each of its
respective node/direction:
dev.pcm.%d.play.* for "play" (cdev = dsp%d.vp%d)
dev.pcm.%d.rec.* for "record" (cdev = dsp%d.vr%d)
* Don't expect that it will magically give you ability to split
"recording source" (eg: 1 channel for cdrom, 1 channel for mic,
etc). Just admit that you only have a *single* recording source /
channel. Please bug your hardware vendor instead :)
- Bump maxautovchans from 4 to 16. For a full-fledged multimedia
desktop/workstation with too many soundservers installed (esound,
artsd, jackd, pulse/polypaudio, ding-dong pling plong mudkip fuh fuh,
etc), 4 seems inadequate. There will be no memory penalty here, since
virtual channels are allocate only by demand.
- Nuke/Rework the entire statically created cdev entries. Everything is
clonable through snd own clone manager which designed to withstand many
kind of abusive devfs droids such as:
* while : ; do /bin/test -e /dev/dsp ; done
* jot 16777216 0 | while read x ; do ls /dev/dsp0.$x ; done
* hundreds (could be thousands) concurrent threads/process opening
"/dev/dsp" (previously, this might result EBUSY even with just
3 contesting threads/procs).
o Reusable clone objects (instead of creating new one like there's no
tomorrow) after certain expiration deadline. The clone allocator will
decide whether to reuse, share, or creating new clone.
o Automatic garbage collector.
- Dynamic unit magic allocator. Maximum attached soundcards can be tuned
using tunable "hw.snd.maxunit" (Default to 512). Minimum is 16, and
maximum is 2048.
- ..other fixes, mostly related to concurrency issues.
joel@ will do the manpage updates on sound(4).
Have fun.
2007-05-31 18:43:33 +00:00
|
|
|
if (cnt) {
|
Welcome to Once-a-year Sound Mega-Commit. Enjoy numerous updates and fixes
in every sense.
General
-------
- Multichannel safe, endian safe, format safe
* Large part of critical pcm filters such as vchan.c, feeder_rate.c,
feeder_volume.c, feeder_fmt.c and feeder.c has been rewritten so that
using them does not cause the pcm data to be converted to 16bit little
endian.
* Macrosses for accessing pcm data safely are defined within sound.h in
the form of PCM_READ_* / PCM_WRITE_*
* Currently, most of them are probably limited for mono/stereo handling,
but the future addition of true multichannel will be much easier.
- Low latency operation
* Well, this require lot more works to do not just within sound driver,
but we're heading towards right direction. Buffer/block sizing within
channel.c is rewritten to calculate precise allocation for various
combination of sample/data/rate size. As a result, applying correct
SNDCTL_DSP_POLICY value will achive expected latency behaviour simmilar
to what commercial 4front driver do.
* Signal handling fix. ctrl+c of "cat /dev/zero > /dev/dsp" does not
result long delay.
* Eliminate sound truncation if the sound data is too small.
DIY:
1) Download / extract
http://people.freebsd.org/~ariff/lowlatency/shortfiles.tar.gz
2) Do a comparison between "cat state*.au > /dev/dsp" and
"for x in state*.au ; do cat $x > /dev/dsp ; done"
- there should be no "perceivable" differences.
Double close for PR kern/31445.
CAVEAT: Low latency come with (unbearable) price especially for poorly
written applications. Applications that trying to act smarter
by requesting (wrong) blocksize/blockcount will suffer the most.
Fixup samples/patches can be found at:
http://people.freebsd.org/~ariff/ports/
- Switch minimum/maximum sampling rate limit to "1" and "2016000" (48k * 42)
due to closer compatibility with 4front driver.
Discussed with: marcus@ (long time ago?)
- All driver specific sysctls in the form of "hw.snd.pcm%d.*" have been
moved to their own dev sysctl nodes, notably:
hw.snd.pcm%d.vchans -> dev.pcm.%d.vchans
Bump __FreeBSD_version.
Driver specific
---------------
- Ditto for sysctls.
- snd_atiixp, snd_es137x, snd_via8233, snd_hda
* Numerous cleanups and fixes.
* _EXPERIMENTAL_ polling mode support using simple callout_* mechanisme.
This was intended for pure debugging and latency measurement, but proven
good enough in few unexpected and rare cases (such as problematic shared
IRQ with GIANT devices - USB). Polling can be enabled/disabled through
dev.pcm.0.polling. Disabled by default.
- snd_ich
* Fix possible overflow during speed calibration. Delay final
initialization (pcm_setstatus) after calibration finished.
PR: kern/100169
Tested by: Kevin Overman <oberman@es.net>
* Inverted EAPD for few Nec VersaPro.
PR: kern/104715
Submitted by: KAWATA Masahiko <kawata@mta.biglobe.ne.jp>
Thanks to various people, notably Joel Dahl, Yuriy Tsibizov, Kevin Oberman,
those at #freebsd-azalia @ freenode and others for testing.
Joel Dahl will do the manpage update.
2006-11-26 12:24:06 +00:00
|
|
|
sndbuf_acquire(to, to->tmpbuf, cnt);
|
Last major commit and updates for RELENG_7:
- Rework the entire pcm_channel structure:
* Remove rarely used link placeholder, instead, make each pcm_channel
as head/link of each own/each other. Unlock - Lock sequence due to
sleep malloc has been reduced.
* Implement "busy" queue which will contain list of busy/active
channels. This greatly reduce locking contention for example while
servicing interrupt for hardware with many channels or when virtual
channels reach its 256 peak channels.
- So I heard you like v chan ... O RLY?
Welcome to Virtual **Record** Channels (vrec, rec vchans, vchans for
recording, Rec-Chan, you decide), the ultimate solutions for your
nagging O_RDWR full-duplex wannabe (note: flash plugins) monopolizing
single record channel causing EBUSY. Vrec works exactly like Vchans
(or, should I rename it to "Vplay" :) , except that it operates on the
opposite direction (recording). Up to 256 vrecs (like vchans) are
possible.
Notes:
* Relocate dev.pcm.%d.{vchans,vchanformat,vchanrate} to each of its
respective node/direction:
dev.pcm.%d.play.* for "play" (cdev = dsp%d.vp%d)
dev.pcm.%d.rec.* for "record" (cdev = dsp%d.vr%d)
* Don't expect that it will magically give you ability to split
"recording source" (eg: 1 channel for cdrom, 1 channel for mic,
etc). Just admit that you only have a *single* recording source /
channel. Please bug your hardware vendor instead :)
- Bump maxautovchans from 4 to 16. For a full-fledged multimedia
desktop/workstation with too many soundservers installed (esound,
artsd, jackd, pulse/polypaudio, ding-dong pling plong mudkip fuh fuh,
etc), 4 seems inadequate. There will be no memory penalty here, since
virtual channels are allocate only by demand.
- Nuke/Rework the entire statically created cdev entries. Everything is
clonable through snd own clone manager which designed to withstand many
kind of abusive devfs droids such as:
* while : ; do /bin/test -e /dev/dsp ; done
* jot 16777216 0 | while read x ; do ls /dev/dsp0.$x ; done
* hundreds (could be thousands) concurrent threads/process opening
"/dev/dsp" (previously, this might result EBUSY even with just
3 contesting threads/procs).
o Reusable clone objects (instead of creating new one like there's no
tomorrow) after certain expiration deadline. The clone allocator will
decide whether to reuse, share, or creating new clone.
o Automatic garbage collector.
- Dynamic unit magic allocator. Maximum attached soundcards can be tuned
using tunable "hw.snd.maxunit" (Default to 512). Minimum is 16, and
maximum is 2048.
- ..other fixes, mostly related to concurrency issues.
joel@ will do the manpage updates on sound(4).
Have fun.
2007-05-31 18:43:33 +00:00
|
|
|
count -= cnt;
|
|
|
|
}
|
Welcome to Once-a-year Sound Mega-Commit. Enjoy numerous updates and fixes
in every sense.
General
-------
- Multichannel safe, endian safe, format safe
* Large part of critical pcm filters such as vchan.c, feeder_rate.c,
feeder_volume.c, feeder_fmt.c and feeder.c has been rewritten so that
using them does not cause the pcm data to be converted to 16bit little
endian.
* Macrosses for accessing pcm data safely are defined within sound.h in
the form of PCM_READ_* / PCM_WRITE_*
* Currently, most of them are probably limited for mono/stereo handling,
but the future addition of true multichannel will be much easier.
- Low latency operation
* Well, this require lot more works to do not just within sound driver,
but we're heading towards right direction. Buffer/block sizing within
channel.c is rewritten to calculate precise allocation for various
combination of sample/data/rate size. As a result, applying correct
SNDCTL_DSP_POLICY value will achive expected latency behaviour simmilar
to what commercial 4front driver do.
* Signal handling fix. ctrl+c of "cat /dev/zero > /dev/dsp" does not
result long delay.
* Eliminate sound truncation if the sound data is too small.
DIY:
1) Download / extract
http://people.freebsd.org/~ariff/lowlatency/shortfiles.tar.gz
2) Do a comparison between "cat state*.au > /dev/dsp" and
"for x in state*.au ; do cat $x > /dev/dsp ; done"
- there should be no "perceivable" differences.
Double close for PR kern/31445.
CAVEAT: Low latency come with (unbearable) price especially for poorly
written applications. Applications that trying to act smarter
by requesting (wrong) blocksize/blockcount will suffer the most.
Fixup samples/patches can be found at:
http://people.freebsd.org/~ariff/ports/
- Switch minimum/maximum sampling rate limit to "1" and "2016000" (48k * 42)
due to closer compatibility with 4front driver.
Discussed with: marcus@ (long time ago?)
- All driver specific sysctls in the form of "hw.snd.pcm%d.*" have been
moved to their own dev sysctl nodes, notably:
hw.snd.pcm%d.vchans -> dev.pcm.%d.vchans
Bump __FreeBSD_version.
Driver specific
---------------
- Ditto for sysctls.
- snd_atiixp, snd_es137x, snd_via8233, snd_hda
* Numerous cleanups and fixes.
* _EXPERIMENTAL_ polling mode support using simple callout_* mechanisme.
This was intended for pure debugging and latency measurement, but proven
good enough in few unexpected and rare cases (such as problematic shared
IRQ with GIANT devices - USB). Polling can be enabled/disabled through
dev.pcm.0.polling. Disabled by default.
- snd_ich
* Fix possible overflow during speed calibration. Delay final
initialization (pcm_setstatus) after calibration finished.
PR: kern/100169
Tested by: Kevin Overman <oberman@es.net>
* Inverted EAPD for few Nec VersaPro.
PR: kern/104715
Submitted by: KAWATA Masahiko <kawata@mta.biglobe.ne.jp>
Thanks to various people, notably Joel Dahl, Yuriy Tsibizov, Kevin Oberman,
those at #freebsd-azalia @ freenode and others for testing.
Joel Dahl will do the manpage update.
2006-11-26 12:24:06 +00:00
|
|
|
} while (count && cnt);
|
2001-03-24 23:10:29 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
sndbuf_dump(struct snd_dbuf *b, char *s, u_int32_t what)
|
|
|
|
{
|
|
|
|
printf("%s: [", s);
|
|
|
|
if (what & 0x01)
|
|
|
|
printf(" bufsize: %d, maxsize: %d", b->bufsize, b->maxsize);
|
|
|
|
if (what & 0x02)
|
|
|
|
printf(" dl: %d, rp: %d, rl: %d, hp: %d", b->dl, b->rp, b->rl, b->hp);
|
|
|
|
if (what & 0x04)
|
|
|
|
printf(" total: %d, prev_total: %d, xrun: %d", b->total, b->prev_total, b->xrun);
|
|
|
|
if (what & 0x08)
|
|
|
|
printf(" fmt: 0x%x, spd: %d", b->fmt, b->spd);
|
|
|
|
if (what & 0x10)
|
|
|
|
printf(" blksz: %d, blkcnt: %d, flags: 0x%x", b->blksz, b->blkcnt, b->flags);
|
|
|
|
printf(" ]\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************/
|
|
|
|
u_int32_t
|
|
|
|
sndbuf_getflags(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
return b->flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sndbuf_setflags(struct snd_dbuf *b, u_int32_t flags, int on)
|
|
|
|
{
|
|
|
|
b->flags &= ~flags;
|
|
|
|
if (on)
|
|
|
|
b->flags |= flags;
|
|
|
|
}
|
|
|
|
|
MFp4 the sound Google Summer of Code project:
The goal was to sync with the OSSv4 API 4Front Technologies uses in their
proprietary OSS driver. This was successful as far as possible. The part
of the API which is stable is implemented, for the rest there are some
stubs already.
New system ioctls:
- SNDCTL_SYSINFO - obtain audio system info (version, # of audio/midi/
mixer devices, etc.)
- SNDCTL_AUDIOINFO - fetch details about a specific audio device
- SNDCTL_MIXERINFO - fetch details about a specific mixer device
New audio ioctls:
- Sync groups (SNDCTL_DSP_SYNCGROUP/SNDCTL_DSP_SYNCSTART) which allow
triggered playback/recording on multiple devices (even across processes
simultaneously).
- Peak meters (SNDCTL_DSP_GETIPEAKS/SNDCTL_DSP_GETOPEAKS) - can query
audio drivers for peak levels (needs driver support, disabled for now).
- Per channel playback/recording levels -
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL. Note that these are still in name
only, just wrapping around the AC97-style mixer at the moment. The next
step is to push them down to the drivers.
Audio ioctls still under development by 4Front (for which stubs may exist
in this commit):
- SNDCTL_GETNAME, SNDCTL_{GET,SET}{SONG,LABEL}
- SNDCTL_DSP_{GET,SET}_CHNORDER
- SNDCTL_MIX_ENUMINFO, SNDCTL_MIX_EXTINFO - (might be documented enough in
the OSS releases to work on this. These ioctls cover the cool "twiddle
any knob on your card" features.)
Missing:
- SNDCTL_DSP_COOKEDMODE -- this ioctl is used to give applications direct
access to a card's buffers, bypassing the feeder architecture. It's
a toughy -- "someone" needs to decide :
(a) if this is desireable, and (b) if it's reasonably feasible.
Updates for driver writers:
So far, only two routines to the channel class (in channel_if.m) are added.
One is for fetching a list of discrete supported playback/recording rates
of a channel, and the other is for fetching peak level info (useful for
drawing peak meters). Interested parties may want to help pushing down
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL into the drivers.
To use the new stuff you need to rebuild the sound drivers or your kernel
(depending on if you use modules or not) and to install soundcard.h (a
buildworld/installworld handles this).
Sponsored by: Google SoC 2006
Submitted by: ryanb
Many thanks to: 4Front Technologies for their cooperation, explanations
and the nice license of their soundcard.h.
2006-09-23 20:45:47 +00:00
|
|
|
/**
|
|
|
|
* @brief Clear the shadow buffer by filling with samples equal to zero.
|
|
|
|
*
|
|
|
|
* @param b buffer to clear
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
sndbuf_clearshadow(struct snd_dbuf *b)
|
|
|
|
{
|
|
|
|
KASSERT(b != NULL, ("b is a null pointer"));
|
|
|
|
KASSERT(b->sl >= 0, ("illegal shadow length"));
|
|
|
|
|
Welcome to Once-a-year Sound Mega-Commit. Enjoy numerous updates and fixes
in every sense.
General
-------
- Multichannel safe, endian safe, format safe
* Large part of critical pcm filters such as vchan.c, feeder_rate.c,
feeder_volume.c, feeder_fmt.c and feeder.c has been rewritten so that
using them does not cause the pcm data to be converted to 16bit little
endian.
* Macrosses for accessing pcm data safely are defined within sound.h in
the form of PCM_READ_* / PCM_WRITE_*
* Currently, most of them are probably limited for mono/stereo handling,
but the future addition of true multichannel will be much easier.
- Low latency operation
* Well, this require lot more works to do not just within sound driver,
but we're heading towards right direction. Buffer/block sizing within
channel.c is rewritten to calculate precise allocation for various
combination of sample/data/rate size. As a result, applying correct
SNDCTL_DSP_POLICY value will achive expected latency behaviour simmilar
to what commercial 4front driver do.
* Signal handling fix. ctrl+c of "cat /dev/zero > /dev/dsp" does not
result long delay.
* Eliminate sound truncation if the sound data is too small.
DIY:
1) Download / extract
http://people.freebsd.org/~ariff/lowlatency/shortfiles.tar.gz
2) Do a comparison between "cat state*.au > /dev/dsp" and
"for x in state*.au ; do cat $x > /dev/dsp ; done"
- there should be no "perceivable" differences.
Double close for PR kern/31445.
CAVEAT: Low latency come with (unbearable) price especially for poorly
written applications. Applications that trying to act smarter
by requesting (wrong) blocksize/blockcount will suffer the most.
Fixup samples/patches can be found at:
http://people.freebsd.org/~ariff/ports/
- Switch minimum/maximum sampling rate limit to "1" and "2016000" (48k * 42)
due to closer compatibility with 4front driver.
Discussed with: marcus@ (long time ago?)
- All driver specific sysctls in the form of "hw.snd.pcm%d.*" have been
moved to their own dev sysctl nodes, notably:
hw.snd.pcm%d.vchans -> dev.pcm.%d.vchans
Bump __FreeBSD_version.
Driver specific
---------------
- Ditto for sysctls.
- snd_atiixp, snd_es137x, snd_via8233, snd_hda
* Numerous cleanups and fixes.
* _EXPERIMENTAL_ polling mode support using simple callout_* mechanisme.
This was intended for pure debugging and latency measurement, but proven
good enough in few unexpected and rare cases (such as problematic shared
IRQ with GIANT devices - USB). Polling can be enabled/disabled through
dev.pcm.0.polling. Disabled by default.
- snd_ich
* Fix possible overflow during speed calibration. Delay final
initialization (pcm_setstatus) after calibration finished.
PR: kern/100169
Tested by: Kevin Overman <oberman@es.net>
* Inverted EAPD for few Nec VersaPro.
PR: kern/104715
Submitted by: KAWATA Masahiko <kawata@mta.biglobe.ne.jp>
Thanks to various people, notably Joel Dahl, Yuriy Tsibizov, Kevin Oberman,
those at #freebsd-azalia @ freenode and others for testing.
Joel Dahl will do the manpage update.
2006-11-26 12:24:06 +00:00
|
|
|
if ((b->shadbuf != NULL) && (b->sl > 0))
|
|
|
|
memset(b->shadbuf, sndbuf_zerodata(b->fmt), b->sl);
|
MFp4 the sound Google Summer of Code project:
The goal was to sync with the OSSv4 API 4Front Technologies uses in their
proprietary OSS driver. This was successful as far as possible. The part
of the API which is stable is implemented, for the rest there are some
stubs already.
New system ioctls:
- SNDCTL_SYSINFO - obtain audio system info (version, # of audio/midi/
mixer devices, etc.)
- SNDCTL_AUDIOINFO - fetch details about a specific audio device
- SNDCTL_MIXERINFO - fetch details about a specific mixer device
New audio ioctls:
- Sync groups (SNDCTL_DSP_SYNCGROUP/SNDCTL_DSP_SYNCSTART) which allow
triggered playback/recording on multiple devices (even across processes
simultaneously).
- Peak meters (SNDCTL_DSP_GETIPEAKS/SNDCTL_DSP_GETOPEAKS) - can query
audio drivers for peak levels (needs driver support, disabled for now).
- Per channel playback/recording levels -
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL. Note that these are still in name
only, just wrapping around the AC97-style mixer at the moment. The next
step is to push them down to the drivers.
Audio ioctls still under development by 4Front (for which stubs may exist
in this commit):
- SNDCTL_GETNAME, SNDCTL_{GET,SET}{SONG,LABEL}
- SNDCTL_DSP_{GET,SET}_CHNORDER
- SNDCTL_MIX_ENUMINFO, SNDCTL_MIX_EXTINFO - (might be documented enough in
the OSS releases to work on this. These ioctls cover the cool "twiddle
any knob on your card" features.)
Missing:
- SNDCTL_DSP_COOKEDMODE -- this ioctl is used to give applications direct
access to a card's buffers, bypassing the feeder architecture. It's
a toughy -- "someone" needs to decide :
(a) if this is desireable, and (b) if it's reasonably feasible.
Updates for driver writers:
So far, only two routines to the channel class (in channel_if.m) are added.
One is for fetching a list of discrete supported playback/recording rates
of a channel, and the other is for fetching peak level info (useful for
drawing peak meters). Interested parties may want to help pushing down
SNDCTL_DSP_{GET,SET}{PLAY,REC}VOL into the drivers.
To use the new stuff you need to rebuild the sound drivers or your kernel
(depending on if you use modules or not) and to install soundcard.h (a
buildworld/installworld handles this).
Sponsored by: Google SoC 2006
Submitted by: ryanb
Many thanks to: 4Front Technologies for their cooperation, explanations
and the nice license of their soundcard.h.
2006-09-23 20:45:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef OSSV4_EXPERIMENT
|
|
|
|
/**
|
|
|
|
* @brief Return peak value from samples in buffer ready area.
|
|
|
|
*
|
|
|
|
* Peak ranges from 0-32767. If channel is monaural, most significant 16
|
|
|
|
* bits will be zero. For now, only expects to work with 1-2 channel
|
|
|
|
* buffers.
|
|
|
|
*
|
|
|
|
* @note Currently only operates with linear PCM formats.
|
|
|
|
*
|
|
|
|
* @param b buffer to analyze
|
|
|
|
* @param lpeak pointer to store left peak value
|
|
|
|
* @param rpeak pointer to store right peak value
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
sndbuf_getpeaks(struct snd_dbuf *b, int *lp, int *rp)
|
|
|
|
{
|
|
|
|
u_int32_t lpeak, rpeak;
|
|
|
|
|
|
|
|
lpeak = 0;
|
|
|
|
rpeak = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @todo fill this in later
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
#endif
|