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
This commit is contained in:
parent
9389696e89
commit
0810203f40
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user