diff options
Diffstat (limited to 'sys/dev/sound/pcm/channel.c')
-rw-r--r-- | sys/dev/sound/pcm/channel.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c index 2e292b7..af338628 100644 --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -850,13 +850,20 @@ chn_dma_setmap(void *arg, bus_dma_segment_t *segs, int nseg, int error) int chn_allocbuf(snd_dbuf *b, bus_dma_tag_t parent_dmat) { - if (bus_dmamem_alloc(parent_dmat, (void **)&b->buf, + b->parent_dmat = parent_dmat; + if (bus_dmamem_alloc(b->parent_dmat, (void **)&b->buf, BUS_DMA_NOWAIT, &b->dmamap)) return -1; - if (bus_dmamap_load(parent_dmat, b->dmamap, b->buf, + if (bus_dmamap_load(b->parent_dmat, b->dmamap, b->buf, b->bufsize, chn_dma_setmap, b, 0)) return -1; return 0; } +void +chn_freebuf(snd_dbuf *b) +{ + bus_dmamem_free(b->parent_dmat, b->buf, b->dmamap); +} + static void buf_clear(snd_dbuf *b, u_int32_t fmt, int length) { @@ -1152,6 +1159,21 @@ chn_init(pcm_channel *c, void *devinfo, int dir) } int +chn_kill(pcm_channel *c) +{ + chn_trigger(c, PCMTRIG_ABORT); + while (chn_removefeeder(c) == 0); + free(c->feeder->desc, M_DEVBUF); + free(c->feeder, M_DEVBUF); + if (c->free) + c->free(c->devinfo); + else + chn_freebuf(&c->buffer); + c->flags |= CHN_F_DEAD; + return 0; +} + +int chn_setdir(pcm_channel *c, int dir) { int r; |