summaryrefslogtreecommitdiffstats
path: root/sys/dev/sound/pcm/vchan.c
diff options
context:
space:
mode:
authorcg <cg@FreeBSD.org>2001-08-23 11:30:52 +0000
committercg <cg@FreeBSD.org>2001-08-23 11:30:52 +0000
commit2cfb90cc8dc9d8f8ae1f12afed63cf0409ed6dd2 (patch)
tree069cd9e58d47e13e77afc32cbb02b958a6dbc95e /sys/dev/sound/pcm/vchan.c
parent1a36f4817c302232acb54087dddcd1d1f4c6a36f (diff)
downloadFreeBSD-src-2cfb90cc8dc9d8f8ae1f12afed63cf0409ed6dd2.zip
FreeBSD-src-2cfb90cc8dc9d8f8ae1f12afed63cf0409ed6dd2.tar.gz
many changes:
* add new channels to the end of the list so channels used in order of addition * de-globalise definition of struct snddev_info and provide accessor functions where necessary. * move the $FreeBSD$ tag in each .c file into a macro and allow the /dev/sndstat handler to display these when set to maximum verbosity to aid debugging. * allow each device to register its own sndstat handler to reduce the amount of groping sndstat must do in foreign structs.
Diffstat (limited to 'sys/dev/sound/pcm/vchan.c')
-rw-r--r--sys/dev/sound/pcm/vchan.c97
1 files changed, 8 insertions, 89 deletions
diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c
index 7a8d41d..46b3061 100644
--- a/sys/dev/sound/pcm/vchan.c
+++ b/sys/dev/sound/pcm/vchan.c
@@ -22,14 +22,14 @@
* 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.
- *
- * $FreeBSD$
*/
#include <dev/sound/pcm/sound.h>
#include <dev/sound/pcm/vchan.h>
#include "feeder_if.h"
+SND_DECLARE_FILE("$FreeBSD$");
+
struct vchinfo {
u_int32_t spd, fmt, blksz, bps, run;
struct pcm_channel *channel, *parent;
@@ -42,7 +42,6 @@ static u_int32_t vchan_fmt[] = {
0
};
-
static int
vchan_mix_s16(int16_t *to, int16_t *tmp, unsigned int count)
{
@@ -327,98 +326,18 @@ gotch:
return err;
}
-#ifdef SND_DYNSYSCTL
-static int
-sysctl_hw_snd_vchans(SYSCTL_HANDLER_ARGS)
-{
- struct snddev_info *d;
- struct snddev_channel *sce;
- struct pcm_channel *c;
- int err, oldcnt, newcnt, cnt;
-
- d = oidp->oid_arg1;
-
- snd_mtxlock(d->lock);
- cnt = 0;
- SLIST_FOREACH(sce, &d->channels, link) {
- c = sce->channel;
- if ((c->direction == PCMDIR_PLAY) && (c->flags & CHN_F_VIRTUAL))
- cnt++;
- }
- oldcnt = cnt;
- newcnt = cnt;
-
- err = sysctl_handle_int(oidp, &newcnt, sizeof(newcnt), req);
- if (err == 0 && req->newptr != NULL) {
- if (newcnt < 0 || newcnt > SND_MAXVCHANS) {
- snd_mtxunlock(d->lock);
- return EINVAL;
- }
-
- if (newcnt > cnt) {
- /* add new vchans - find a parent channel first */
- SLIST_FOREACH(sce, &d->channels, link) {
- c = sce->channel;
- /* not a candidate if not a play channel */
- if (c->direction != PCMDIR_PLAY)
- goto addskip;
- /* not a candidate if a virtual channel */
- if (c->flags & CHN_F_VIRTUAL)
- goto addskip;
- /* not a candidate if it's in use */
- if ((c->flags & CHN_F_BUSY) && (SLIST_EMPTY(&c->children)))
- goto addskip;
- /*
- * if we get here we're a nonvirtual play channel, and either
- * 1) not busy
- * 2) busy with children, not directly open
- *
- * thus we can add children
- */
- goto addok;
-addskip:
- }
- snd_mtxunlock(d->lock);
- return EBUSY;
-addok:
- c->flags |= CHN_F_BUSY;
- while (err == 0 && newcnt > cnt) {
- err = vchan_create(c);
- if (err == 0)
- cnt++;
- }
- if (SLIST_EMPTY(&c->children))
- c->flags &= ~CHN_F_BUSY;
- } else if (newcnt < cnt) {
- while (err == 0 && newcnt < cnt) {
- SLIST_FOREACH(sce, &d->channels, link) {
- c = sce->channel;
- if ((c->flags & (CHN_F_BUSY | CHN_F_VIRTUAL)) == CHN_F_VIRTUAL)
- goto remok;
- }
- snd_mtxunlock(d->lock);
- return EINVAL;
-remok:
- err = vchan_destroy(c);
- if (err == 0)
- cnt--;
- }
- }
- }
-
- snd_mtxunlock(d->lock);
- return err;
-}
-#endif
-
int
-vchan_initsys(struct snddev_info *d)
+vchan_initsys(device_t dev)
{
#ifdef SND_DYNSYSCTL
- SYSCTL_ADD_PROC(&d->sysctl_tree, SYSCTL_CHILDREN(d->sysctl_tree_top),
+ struct snddev_info *d;
+
+ d = device_get_softc(dev);
+ SYSCTL_ADD_PROC(snd_sysctl_tree(dev), SYSCTL_CHILDREN(snd_sysctl_tree_top(dev)),
OID_AUTO, "vchans", CTLTYPE_INT | CTLFLAG_RW, d, sizeof(d),
sysctl_hw_snd_vchans, "I", "")
#endif
+
return 0;
}
OpenPOWER on IntegriCloud