summaryrefslogtreecommitdiffstats
path: root/sys/dev/sound/pcm
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2004-02-28 19:47:02 +0000
committertruckman <truckman@FreeBSD.org>2004-02-28 19:47:02 +0000
commit0810203f400a00c493ca888054ecef05fd79854c (patch)
tree929fb68d1e346df84f89f946fd5915522c44cda8 /sys/dev/sound/pcm
parent9389696e8906abb17c16608befcd37d32e8ed693 (diff)
downloadFreeBSD-src-0810203f400a00c493ca888054ecef05fd79854c.zip
FreeBSD-src-0810203f400a00c493ca888054ecef05fd79854c.tar.gz
Create a new mutex type for virtual channels. This allows us to get
rid of the MTX_DUPOK flag on channel mutexes, which allows witness to do a better job of lock order checking. Nuke snd_chnmtxcreate() since it is no longer needed. Tested by: matk
Diffstat (limited to 'sys/dev/sound/pcm')
-rw-r--r--sys/dev/sound/pcm/channel.c24
-rw-r--r--sys/dev/sound/pcm/channel.h2
-rw-r--r--sys/dev/sound/pcm/sound.c26
-rw-r--r--sys/dev/sound/pcm/sound.h1
4 files changed, 24 insertions, 29 deletions
diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
index 4a18b52..cf970c7 100644
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -69,10 +69,20 @@ static int chn_buildfeeder(struct pcm_channel *c);
static void
chn_lockinit(struct pcm_channel *c, int dir)
{
- if (dir == PCMDIR_PLAY)
- c->lock = snd_chnmtxcreate(c->name, "pcm play channel");
- else
- c->lock = snd_chnmtxcreate(c->name, "pcm record channel");
+ switch(dir) {
+ case PCMDIR_PLAY:
+ c->lock = snd_mtxcreate(c->name, "pcm play channel");
+ break;
+ case PCMDIR_REC:
+ c->lock = snd_mtxcreate(c->name, "pcm record channel");
+ break;
+ case PCMDIR_VIRTUAL:
+ c->lock = snd_mtxcreate(c->name, "pcm virtual play channel");
+ break;
+ case 0:
+ c->lock = snd_mtxcreate(c->name, "pcm fake channel");
+ break;
+ }
}
static void
@@ -746,7 +756,7 @@ chn_reset(struct pcm_channel *c, u_int32_t fmt)
}
int
-chn_init(struct pcm_channel *c, void *devinfo, int dir)
+chn_init(struct pcm_channel *c, void *devinfo, int dir, int direction)
{
struct feeder_class *fc;
struct snd_dbuf *b, *bs;
@@ -791,7 +801,7 @@ chn_init(struct pcm_channel *c, void *devinfo, int dir)
ret = ENODEV;
CHN_UNLOCK(c); /* XXX - Unlock for CHANNEL_INIT() malloc() call */
- c->devinfo = CHANNEL_INIT(c->methods, devinfo, b, c, dir);
+ c->devinfo = CHANNEL_INIT(c->methods, devinfo, b, c, direction);
CHN_LOCK(c);
if (c->devinfo == NULL)
goto out;
@@ -800,7 +810,7 @@ chn_init(struct pcm_channel *c, void *devinfo, int dir)
if ((sndbuf_getsize(b) == 0) && ((c->flags & CHN_F_VIRTUAL) == 0))
goto out;
- ret = chn_setdir(c, dir);
+ ret = chn_setdir(c, direction);
if (ret)
goto out;
diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h
index 5a9492a..f2fb595 100644
--- a/sys/dev/sound/pcm/channel.h
+++ b/sys/dev/sound/pcm/channel.h
@@ -76,7 +76,7 @@ int chn_sync(struct pcm_channel *c, int threshold);
int chn_flush(struct pcm_channel *c);
int chn_poll(struct pcm_channel *c, int ev, struct thread *td);
-int chn_init(struct pcm_channel *c, void *devinfo, int dir);
+int chn_init(struct pcm_channel *c, void *devinfo, int dir, int direction);
int chn_kill(struct pcm_channel *c);
int chn_setdir(struct pcm_channel *c, int dir);
int chn_reset(struct pcm_channel *c, u_int32_t fmt);
diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c
index edb765e..67ba33e 100644
--- a/sys/dev/sound/pcm/sound.c
+++ b/sys/dev/sound/pcm/sound.c
@@ -82,22 +82,6 @@ snd_mtxcreate(const char *desc, const char *type)
#endif
}
-void *
-snd_chnmtxcreate(const char *desc, const char *type)
-{
-#ifdef USING_MUTEX
- struct mtx *m;
-
- m = malloc(sizeof(*m), M_DEVBUF, M_WAITOK | M_ZERO);
- if (m == NULL)
- return NULL;
- mtx_init(m, desc, type, MTX_DEF | MTX_DUPOK);
- return m;
-#else
- return (void *)0xcafebabe;
-#endif
-}
-
void
snd_mtxfree(void *m)
{
@@ -358,22 +342,24 @@ pcm_chn_create(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t c
{
struct pcm_channel *ch;
char *dirs;
- int err, *pnum;
+ int direction, err, *pnum;
switch(dir) {
case PCMDIR_PLAY:
dirs = "play";
+ direction = PCMDIR_PLAY;
pnum = &d->playcount;
break;
case PCMDIR_REC:
dirs = "record";
+ direction = PCMDIR_REC;
pnum = &d->reccount;
break;
case PCMDIR_VIRTUAL:
dirs = "virtual";
- dir = PCMDIR_PLAY;
+ direction = PCMDIR_PLAY;
pnum = &d->vchancount;
break;
@@ -402,7 +388,7 @@ pcm_chn_create(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t c
ch->dev = d->dev;
snprintf(ch->name, 32, "%s:%s:%d", device_get_nameunit(ch->dev), dirs, ch->num);
- err = chn_init(ch, devinfo, dir);
+ err = chn_init(ch, devinfo, dir, direction);
if (err) {
device_printf(d->dev, "chn_init(%s) failed: err = %d\n", ch->name, err);
kobj_delete(ch->methods, M_DEVBUF);
@@ -684,7 +670,7 @@ pcm_register(device_t dev, void *devinfo, int numplay, int numrec)
d->flags |= SD_F_SIMPLEX;
d->fakechan = fkchan_setup(dev);
- chn_init(d->fakechan, NULL, 0);
+ chn_init(d->fakechan, NULL, 0, 0);
#ifdef SND_DYNSYSCTL
sysctl_ctx_init(&d->sysctl_tree);
diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h
index aea9dc5..29ddd44 100644
--- a/sys/dev/sound/pcm/sound.h
+++ b/sys/dev/sound/pcm/sound.h
@@ -238,7 +238,6 @@ int snd_setup_intr(device_t dev, struct resource *res, int flags,
driver_intr_t hand, void *param, void **cookiep);
void *snd_mtxcreate(const char *desc, const char *type);
-void *snd_chnmtxcreate(const char *desc, const char *type);
void snd_mtxfree(void *m);
void snd_mtxassert(void *m);
#define snd_mtxlock(m) mtx_lock(m)
OpenPOWER on IntegriCloud