summaryrefslogtreecommitdiffstats
path: root/sys/dev/sound/pcm/sound.c
diff options
context:
space:
mode:
authorcg <cg@FreeBSD.org>2001-09-05 16:28:41 +0000
committercg <cg@FreeBSD.org>2001-09-05 16:28:41 +0000
commit9d8a805762329a53d281cceb6a882df9f8f81326 (patch)
tree9b366877ef6fe361dc6f34aa24fa1b89089581b9 /sys/dev/sound/pcm/sound.c
parent5f2415a1e944afe0b68330f6a37b04b185af81d8 (diff)
downloadFreeBSD-src-9d8a805762329a53d281cceb6a882df9f8f81326.zip
FreeBSD-src-9d8a805762329a53d281cceb6a882df9f8f81326.tar.gz
add a method for recording of specific channels for devices with more than
one hardware record channel. new devices, /dev/dsprX.Y where X is unit number and Y is channel index.
Diffstat (limited to 'sys/dev/sound/pcm/sound.c')
-rw-r--r--sys/dev/sound/pcm/sound.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c
index 4ad614b..f8b2592 100644
--- a/sys/dev/sound/pcm/sound.c
+++ b/sys/dev/sound/pcm/sound.c
@@ -41,7 +41,7 @@ struct snddev_channel {
struct snddev_info {
SLIST_HEAD(, snddev_channel) channels;
struct pcm_channel *fakechan;
- unsigned devcount, chancount, vchancount;
+ unsigned devcount, reccount, chancount, vchancount;
unsigned flags;
int inprog;
void *devinfo;
@@ -174,7 +174,7 @@ pcm_getfakechan(struct snddev_info *d)
/* return a locked channel */
struct pcm_channel *
-pcm_chnalloc(struct snddev_info *d, int direction, pid_t pid)
+pcm_chnalloc(struct snddev_info *d, int direction, pid_t pid, int chnum)
{
struct pcm_channel *c;
struct snddev_channel *sce;
@@ -187,9 +187,11 @@ pcm_chnalloc(struct snddev_info *d, int direction, pid_t pid)
c = sce->channel;
CHN_LOCK(c);
if ((c->direction == direction) && !(c->flags & CHN_F_BUSY)) {
- c->flags |= CHN_F_BUSY;
- c->pid = pid;
- return c;
+ if (chnum == -1 || c->num == chnum) {
+ c->flags |= CHN_F_BUSY;
+ c->pid = pid;
+ return c;
+ }
}
CHN_UNLOCK(c);
}
@@ -203,7 +205,7 @@ pcm_chnalloc(struct snddev_info *d, int direction, pid_t pid)
if (!SLIST_EMPTY(&c->children)) {
err = vchan_create(c);
if (!err)
- return pcm_chnalloc(d, direction, pid);
+ return pcm_chnalloc(d, direction, pid, -1);
else
device_printf(d->dev, "vchan_create(%s) == %d\n", c->name, err);
}
@@ -422,8 +424,18 @@ pcm_chn_add(struct snddev_info *d, struct pcm_channel *ch, int mkdev)
SLIST_INSERT_AFTER(after, sce, link);
}
- if (mkdev)
+ if (ch->direction == PCMDIR_REC)
+ ch->num = d->reccount++;
+/*
+ else
+ ch->num = d->playcount++;
+*/
+
+ if (mkdev) {
dsp_register(unit, d->devcount++);
+ if (ch->direction == PCMDIR_REC)
+ dsp_registerrec(unit, ch->num);
+ }
d->chancount++;
if (ch->flags & CHN_F_VIRTUAL)
d->vchancount++;
@@ -453,8 +465,11 @@ gotit:
SLIST_REMOVE(&d->channels, sce, snddev_channel, link);
free(sce, M_DEVBUF);
- if (rmdev)
+ if (rmdev) {
dsp_unregister(unit, --d->devcount);
+ if (ch->direction == PCMDIR_REC)
+ dsp_unregisterrec(unit, --d->reccount);
+ }
snd_mtxunlock(d->lock);
return 0;
@@ -552,6 +567,7 @@ pcm_register(device_t dev, void *devinfo, int numplay, int numrec)
d->dev = dev;
d->devinfo = devinfo;
d->devcount = 0;
+ d->reccount = 0;
d->chancount = 0;
d->vchancount = 0;
d->inprog = 0;
OpenPOWER on IntegriCloud