Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/sound/pcm/channel.c
Show First 20 Lines • Show All 1,170 Lines • ▼ Show 20 Lines | |||||
struct pcm_channel * | struct pcm_channel * | ||||
chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, | chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, | ||||
int dir, void *devinfo) | int dir, void *devinfo) | ||||
{ | { | ||||
struct pcm_channel *c; | struct pcm_channel *c; | ||||
struct feeder_class *fc; | struct feeder_class *fc; | ||||
struct snd_dbuf *b, *bs; | struct snd_dbuf *b, *bs; | ||||
char buf[CHN_NAMELEN]; | char buf[CHN_NAMELEN]; | ||||
int i, direction; | int err, i, direction; | ||||
PCM_BUSYASSERT(d); | PCM_BUSYASSERT(d); | ||||
PCM_LOCKASSERT(d); | PCM_LOCKASSERT(d); | ||||
switch (dir) { | switch (dir) { | ||||
case PCMDIR_PLAY: | case PCMDIR_PLAY: | ||||
case PCMDIR_PLAY_VIRTUAL: | case PCMDIR_PLAY_VIRTUAL: | ||||
direction = PCMDIR_PLAY; | direction = PCMDIR_PLAY; | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, | ||||
* is allocated by the driver or via DMA map setup, and tmpbuf | * is allocated by the driver or via DMA map setup, and tmpbuf | ||||
* seems to only come into existence in sndbuf_resize(). | * seems to only come into existence in sndbuf_resize(). | ||||
*/ | */ | ||||
if (c->direction == PCMDIR_PLAY) { | if (c->direction == PCMDIR_PLAY) { | ||||
bs->sl = sndbuf_getmaxsize(bs); | bs->sl = sndbuf_getmaxsize(bs); | ||||
bs->shadbuf = malloc(bs->sl, M_DEVBUF, M_WAITOK); | bs->shadbuf = malloc(bs->sl, M_DEVBUF, M_WAITOK); | ||||
} | } | ||||
/* vchans get a chn_reset() from vchan_create(). */ | |||||
if ((c->flags & CHN_F_VIRTUAL) == 0) { | |||||
CHN_LOCK(c); | |||||
err = chn_reset(c, c->format, c->speed); | |||||
CHN_UNLOCK(c); | |||||
if (err != 0) | |||||
goto fail; | |||||
} | |||||
PCM_LOCK(d); | PCM_LOCK(d); | ||||
CHN_INSERT_SORT_ASCEND(d, c, channels.pcm); | CHN_INSERT_SORT_ASCEND(d, c, channels.pcm); | ||||
if ((c->flags & CHN_F_VIRTUAL) == 0) | |||||
CHN_INSERT_SORT_ASCEND(d, c, channels.pcm.primary); | |||||
switch (c->type) { | switch (c->type) { | ||||
case PCMDIR_PLAY: | case PCMDIR_PLAY: | ||||
d->playcount++; | d->playcount++; | ||||
break; | break; | ||||
case PCMDIR_PLAY_VIRTUAL: | case PCMDIR_PLAY_VIRTUAL: | ||||
d->pvchancount++; | d->pvchancount++; | ||||
break; | break; | ||||
Show All 35 Lines | chn_kill(struct pcm_channel *c) | ||||
struct snddev_info *d = c->parentsnddev; | struct snddev_info *d = c->parentsnddev; | ||||
struct snd_dbuf *b = c->bufhard; | struct snd_dbuf *b = c->bufhard; | ||||
struct snd_dbuf *bs = c->bufsoft; | struct snd_dbuf *bs = c->bufsoft; | ||||
PCM_BUSYASSERT(c->parentsnddev); | PCM_BUSYASSERT(c->parentsnddev); | ||||
PCM_LOCK(d); | PCM_LOCK(d); | ||||
CHN_REMOVE(d, c, channels.pcm); | CHN_REMOVE(d, c, channels.pcm); | ||||
if ((c->flags & CHN_F_VIRTUAL) == 0) | |||||
CHN_REMOVE(d, c, channels.pcm.primary); | |||||
switch (c->type) { | switch (c->type) { | ||||
case PCMDIR_PLAY: | case PCMDIR_PLAY: | ||||
d->playcount--; | d->playcount--; | ||||
break; | break; | ||||
case PCMDIR_PLAY_VIRTUAL: | case PCMDIR_PLAY_VIRTUAL: | ||||
d->pvchancount--; | d->pvchancount--; | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 1,299 Lines • Show Last 20 Lines |