Split the first special element from sc_audiochan list.
- This makes sc_audiochan a list of only open audio chan. - "SIMPLEQ_FIRST(&sc->sc_audiochan)->vc" is now "sc->hwvc". No functional changes (except one debug message).
This commit is contained in:
parent
b79ea570a8
commit
c241a3c1cb
166
sys/dev/audio.c
166
sys/dev/audio.c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: audio.c,v 1.393 2017/08/13 05:04:08 isaki Exp $ */
|
||||
/* $NetBSD: audio.c,v 1.394 2017/08/15 04:42:56 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2016 Nathanial Sloss <nathanialsloss@yahoo.com.au>
|
||||
@ -148,7 +148,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.393 2017/08/13 05:04:08 isaki Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.394 2017/08/15 04:42:56 isaki Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "audio.h"
|
||||
@ -215,12 +215,12 @@ int audio_idle_timeout = 30;
|
||||
#endif
|
||||
|
||||
#define HW_LOCK(x) do { \
|
||||
if ((x) == SIMPLEQ_FIRST(&sc->sc_audiochan)->vc) \
|
||||
if ((x) == sc->sc_hwvc) \
|
||||
mutex_enter(sc->sc_intr_lock); \
|
||||
} while (0)
|
||||
|
||||
#define HW_UNLOCK(x) do { \
|
||||
if ((x) == SIMPLEQ_FIRST(&sc->sc_audiochan)->vc) \
|
||||
if ((x) == sc->sc_hwvc) \
|
||||
mutex_exit(sc->sc_intr_lock); \
|
||||
} while (0)
|
||||
|
||||
@ -284,7 +284,7 @@ void audio_init_ringbuffer(struct audio_softc *,
|
||||
struct audio_ringbuffer *, int);
|
||||
int audio_initbufs(struct audio_softc *, struct virtual_channel *);
|
||||
void audio_calcwater(struct audio_softc *, struct virtual_channel *);
|
||||
int audio_drain(struct audio_softc *, struct audio_chan *);
|
||||
int audio_drain(struct audio_softc *, struct virtual_channel *);
|
||||
void audio_clear(struct audio_softc *, struct virtual_channel *);
|
||||
void audio_clear_intr_unlocked(struct audio_softc *sc,
|
||||
struct virtual_channel *);
|
||||
@ -481,7 +481,6 @@ audioattach(device_t parent, device_t self, void *aux)
|
||||
struct audio_softc *sc;
|
||||
struct audio_attach_args *sa;
|
||||
struct virtual_channel *vc;
|
||||
struct audio_chan *chan;
|
||||
const struct audio_hw_if *hwp;
|
||||
const struct sysctlnode *node;
|
||||
void *hdlp;
|
||||
@ -517,11 +516,10 @@ audioattach(device_t parent, device_t self, void *aux)
|
||||
sc->sc_trigger_started = false;
|
||||
sc->sc_rec_started = false;
|
||||
sc->sc_dying = false;
|
||||
chan = kmem_zalloc(sizeof(struct audio_chan), KM_SLEEP);
|
||||
vc = kmem_zalloc(sizeof(struct virtual_channel), KM_SLEEP);
|
||||
chan->vc = vc;
|
||||
SIMPLEQ_INIT(&sc->sc_audiochan);
|
||||
SIMPLEQ_INSERT_HEAD(&sc->sc_audiochan, chan, entries);
|
||||
|
||||
vc = kmem_zalloc(sizeof(struct virtual_channel), KM_SLEEP);
|
||||
sc->sc_hwvc = vc;
|
||||
vc->sc_open = 0;
|
||||
vc->sc_mode = 0;
|
||||
vc->sc_npfilters = 0;
|
||||
@ -930,12 +928,16 @@ audiodetach(device_t self, int flags)
|
||||
audio_free_ring(sc, &chan->vc->sc_mpr);
|
||||
audio_free_ring(sc, &chan->vc->sc_mrr);
|
||||
}
|
||||
audio_free_ring(sc, &sc->sc_hwvc->sc_mpr);
|
||||
audio_free_ring(sc, &sc->sc_hwvc->sc_mrr);
|
||||
audio_free_ring(sc, &sc->sc_pr);
|
||||
audio_free_ring(sc, &sc->sc_rr);
|
||||
SIMPLEQ_FOREACH(chan, &sc->sc_audiochan, entries) {
|
||||
audio_destroy_pfilters(chan->vc);
|
||||
audio_destroy_rfilters(chan->vc);
|
||||
}
|
||||
audio_destroy_pfilters(sc->sc_hwvc);
|
||||
audio_destroy_rfilters(sc->sc_hwvc);
|
||||
|
||||
auconv_delete_encodings(sc->sc_encodings);
|
||||
|
||||
@ -948,10 +950,7 @@ audiodetach(device_t self, int flags)
|
||||
sc->sc_sih_wr = NULL;
|
||||
}
|
||||
|
||||
chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
|
||||
kmem_free(chan->vc, sizeof(struct virtual_channel));
|
||||
SIMPLEQ_REMOVE(&sc->sc_audiochan, chan, audio_chan, entries);
|
||||
kmem_free(chan, sizeof(struct audio_chan));
|
||||
kmem_free(sc->sc_hwvc, sizeof(struct virtual_channel));
|
||||
kmem_free(sc->sc_mixer_state, sizeof(mixer_ctrl_t) *
|
||||
(sc->sc_nmixer_states + 1));
|
||||
|
||||
@ -1081,26 +1080,21 @@ void audio_print_params(const char *, struct audio_params *);
|
||||
void
|
||||
audio_printsc(struct audio_softc *sc)
|
||||
{
|
||||
struct audio_chan *chan;
|
||||
|
||||
chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
|
||||
|
||||
if (chan == NULL)
|
||||
return;
|
||||
struct virtual_channel *vc;
|
||||
|
||||
vc = sc->sc_hwvc;
|
||||
|
||||
printf("hwhandle %p hw_if %p ", sc->hw_hdl, sc->hw_if);
|
||||
printf("open 0x%x mode 0x%x\n", chan->vc->sc_open,
|
||||
chan->vc->sc_mode);
|
||||
printf("open 0x%x mode 0x%x\n", vc->sc_open, vc->sc_mode);
|
||||
printf("rchan 0x%x wchan 0x%x ", cv_has_waiters(&sc->sc_rchan),
|
||||
cv_has_waiters(&sc->sc_wchan));
|
||||
printf("rring used 0x%x pring used=%d\n",
|
||||
audio_stream_get_used(&chan->vc->sc_mrr.s),
|
||||
audio_stream_get_used(&chan->vc->sc_mpr.s));
|
||||
printf("rbus 0x%x pbus 0x%x ", chan->vc->sc_rbus,
|
||||
chan->vc->sc_pbus);
|
||||
printf("blksize %d", chan->vc->sc_mpr.blksize);
|
||||
printf("hiwat %d lowat %d\n", chan->vc->sc_mpr.usedhigh,
|
||||
chan->vc->sc_mpr.usedlow);
|
||||
audio_stream_get_used(&vc->sc_mrr.s),
|
||||
audio_stream_get_used(&vc->sc_mpr.s));
|
||||
printf("rbus 0x%x pbus 0x%x ", vc->sc_rbus, vc->sc_pbus);
|
||||
printf("blksize %d", vc->sc_mpr.blksize);
|
||||
printf("hiwat %d lowat %d\n", vc->sc_mpr.usedhigh,
|
||||
vc->sc_mpr.usedlow);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1164,13 +1158,13 @@ audio_alloc_ring(struct audio_softc *sc, struct audio_ringbuffer *r,
|
||||
int direction, size_t bufsize)
|
||||
{
|
||||
const struct audio_hw_if *hw;
|
||||
struct audio_chan *chan;
|
||||
struct virtual_channel *vc;
|
||||
void *hdl;
|
||||
vaddr_t vstart;
|
||||
vsize_t vsize;
|
||||
int error;
|
||||
|
||||
chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
|
||||
vc = sc->sc_hwvc;
|
||||
hw = sc->hw_if;
|
||||
hdl = sc->hw_hdl;
|
||||
/*
|
||||
@ -1182,7 +1176,7 @@ audio_alloc_ring(struct audio_softc *sc, struct audio_ringbuffer *r,
|
||||
if (hw->round_buffersize)
|
||||
bufsize = hw->round_buffersize(hdl, direction, bufsize);
|
||||
|
||||
if (hw->allocm && (r == &chan->vc->sc_mpr || r == &chan->vc->sc_mrr)) {
|
||||
if (hw->allocm && (r == &vc->sc_mpr || r == &vc->sc_mrr)) {
|
||||
/* Hardware ringbuffer. No dedicated uvm object.*/
|
||||
r->uobj = NULL;
|
||||
r->s.start = hw->allocm(hdl, direction, bufsize);
|
||||
@ -1227,17 +1221,16 @@ audio_alloc_ring(struct audio_softc *sc, struct audio_ringbuffer *r,
|
||||
void
|
||||
audio_free_ring(struct audio_softc *sc, struct audio_ringbuffer *r)
|
||||
{
|
||||
struct audio_chan *chan;
|
||||
struct virtual_channel *vc;
|
||||
vaddr_t vstart;
|
||||
vsize_t vsize;
|
||||
|
||||
if (r->s.start == NULL)
|
||||
return;
|
||||
|
||||
chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
|
||||
vc = sc->sc_hwvc;
|
||||
|
||||
if (sc->hw_if->freem && (r == &chan->vc->sc_mpr ||
|
||||
r == &chan->vc->sc_mrr)) {
|
||||
if (sc->hw_if->freem && (r == &vc->sc_mpr || r == &vc->sc_mrr)) {
|
||||
/* Hardware ringbuffer. */
|
||||
KASSERT(r->uobj == NULL);
|
||||
sc->hw_if->freem(sc->hw_hdl, r->s.start, r->s.bufsize);
|
||||
@ -1585,8 +1578,6 @@ audio_waitio(struct audio_softc *sc, kcondvar_t *chan, struct virtual_channel *v
|
||||
|
||||
found = false;
|
||||
SIMPLEQ_FOREACH(vchan, &sc->sc_audiochan, entries) {
|
||||
if (vchan == SIMPLEQ_FIRST(&sc->sc_audiochan))
|
||||
continue;
|
||||
if (vchan->vc == vc) {
|
||||
found = true;
|
||||
break;
|
||||
@ -2022,12 +2013,10 @@ int
|
||||
audio_initbufs(struct audio_softc *sc, struct virtual_channel *vc)
|
||||
{
|
||||
const struct audio_hw_if *hw;
|
||||
struct audio_chan *chan;
|
||||
int error;
|
||||
|
||||
chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
|
||||
if (vc == NULL) {
|
||||
vc = chan->vc;
|
||||
vc = sc->sc_hwvc;
|
||||
sc->sc_pr.blksize = vc->sc_mrr.blksize;
|
||||
sc->sc_rr.blksize = vc->sc_mrr.blksize;
|
||||
}
|
||||
@ -2035,7 +2024,7 @@ audio_initbufs(struct audio_softc *sc, struct virtual_channel *vc)
|
||||
DPRINTF(("audio_initbufs: mode=0x%x\n", vc->sc_mode));
|
||||
hw = sc->hw_if;
|
||||
if (audio_can_capture(sc) &&
|
||||
((vc->sc_open & AUOPEN_READ) || vc == chan->vc)) {
|
||||
((vc->sc_open & AUOPEN_READ) || vc == sc->sc_hwvc)) {
|
||||
audio_init_ringbuffer(sc, &vc->sc_mrr,
|
||||
AUMODE_RECORD);
|
||||
if (sc->sc_opens == 0 && hw->init_input &&
|
||||
@ -2046,11 +2035,11 @@ audio_initbufs(struct audio_softc *sc, struct virtual_channel *vc)
|
||||
return error;
|
||||
}
|
||||
}
|
||||
if (vc == SIMPLEQ_FIRST(&sc->sc_audiochan)->vc)
|
||||
if (vc == sc->sc_hwvc)
|
||||
sc->sc_rr.blksize = vc->sc_mrr.blksize;
|
||||
|
||||
if (audio_can_playback(sc) &&
|
||||
((vc->sc_open & AUOPEN_WRITE) || vc == chan->vc)) {
|
||||
((vc->sc_open & AUOPEN_WRITE) || vc == sc->sc_hwvc)) {
|
||||
audio_init_ringbuffer(sc, &vc->sc_mpr,
|
||||
AUMODE_PLAY);
|
||||
vc->sc_sil_count = 0;
|
||||
@ -2062,7 +2051,7 @@ audio_initbufs(struct audio_softc *sc, struct virtual_channel *vc)
|
||||
return error;
|
||||
}
|
||||
}
|
||||
if (vc == SIMPLEQ_FIRST(&sc->sc_audiochan)->vc)
|
||||
if (vc == sc->sc_hwvc)
|
||||
sc->sc_pr.blksize = vc->sc_mpr.blksize;
|
||||
|
||||
#ifdef AUDIO_INTR_TIME
|
||||
@ -2134,8 +2123,6 @@ audio_open(dev_t dev, struct audio_softc *sc, int flags, int ifmt,
|
||||
return ENXIO;
|
||||
n = 1;
|
||||
SIMPLEQ_FOREACH(chan, &sc->sc_audiochan, entries) {
|
||||
if (chan == SIMPLEQ_FIRST(&sc->sc_audiochan))
|
||||
continue;
|
||||
n = chan->chan + 1;
|
||||
}
|
||||
if (n < 0)
|
||||
@ -2328,10 +2315,9 @@ audio_init_play(struct audio_softc *sc, struct virtual_channel *vc)
|
||||
}
|
||||
|
||||
int
|
||||
audio_drain(struct audio_softc *sc, struct audio_chan *chan)
|
||||
audio_drain(struct audio_softc *sc, struct virtual_channel *vc)
|
||||
{
|
||||
struct audio_ringbuffer *cb;
|
||||
struct virtual_channel *vc;
|
||||
int error, cc, i, used;
|
||||
uint drops;
|
||||
bool hw = false;
|
||||
@ -2340,14 +2326,13 @@ audio_drain(struct audio_softc *sc, struct audio_chan *chan)
|
||||
KASSERT(mutex_owned(sc->sc_intr_lock));
|
||||
|
||||
error = 0;
|
||||
vc = chan->vc;
|
||||
DPRINTF(("audio_drain: enter busy=%d\n", vc->sc_pbus));
|
||||
cb = &chan->vc->sc_mpr;
|
||||
cb = &vc->sc_mpr;
|
||||
if (cb->mmapped)
|
||||
return 0;
|
||||
|
||||
used = audio_stream_get_used(&cb->s);
|
||||
if (chan == SIMPLEQ_FIRST(&sc->sc_audiochan)) {
|
||||
if (vc == sc->sc_hwvc) {
|
||||
hw = true;
|
||||
used += audio_stream_get_used(&sc->sc_pr.s);
|
||||
}
|
||||
@ -2401,8 +2386,8 @@ audio_drain(struct audio_softc *sc, struct audio_chan *chan)
|
||||
drops = cb->drops;
|
||||
error = 0;
|
||||
while (cb->drops == drops && !error) {
|
||||
DPRINTF(("audio_drain: chan=%d used=%d, drops=%ld\n",
|
||||
chan->chan,
|
||||
DPRINTF(("audio_drain: vc=%p used=%d, drops=%ld\n",
|
||||
vc,
|
||||
audio_stream_get_used(&vc->sc_mpr.s),
|
||||
cb->drops));
|
||||
mutex_exit(sc->sc_intr_lock);
|
||||
@ -2459,12 +2444,12 @@ audio_close(struct audio_softc *sc, int flags, struct audio_chan *chan)
|
||||
*/
|
||||
if ((flags & FWRITE) && vc->sc_pbus) {
|
||||
if (!vc->sc_mpr.pause)
|
||||
audio_drain(sc, chan);
|
||||
audio_drain(sc, chan->vc);
|
||||
vc->sc_pbus = false;
|
||||
}
|
||||
if (sc->sc_opens == 1) {
|
||||
if (vc->sc_mpr.mmapped == false)
|
||||
audio_drain(sc, SIMPLEQ_FIRST(&sc->sc_audiochan));
|
||||
audio_drain(sc, sc->sc_hwvc);
|
||||
if (hw->drain)
|
||||
(void)hw->drain(sc->hw_hdl);
|
||||
hw->halt_output(sc->hw_hdl);
|
||||
@ -2733,14 +2718,12 @@ audio_fill_silence(const struct audio_params *params, uint8_t *p, int n)
|
||||
int
|
||||
audio_silence_copyout(struct audio_softc *sc, int n, struct uio *uio)
|
||||
{
|
||||
struct audio_chan *chan;
|
||||
struct virtual_channel *vc;
|
||||
uint8_t zerobuf[128];
|
||||
int error;
|
||||
int k;
|
||||
|
||||
chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
|
||||
vc = chan->vc;
|
||||
vc = sc->sc_hwvc;
|
||||
audio_fill_silence(&vc->sc_rparams, zerobuf, sizeof zerobuf);
|
||||
|
||||
error = 0;
|
||||
@ -2991,8 +2974,6 @@ audio_ioctl(dev_t dev, struct audio_softc *sc, u_long cmd, void *addr, int flag,
|
||||
KASSERT(mutex_owned(sc->sc_lock));
|
||||
|
||||
SIMPLEQ_FOREACH(pchan, &sc->sc_audiochan, entries) {
|
||||
if (pchan == SIMPLEQ_FIRST(&sc->sc_audiochan))
|
||||
continue;
|
||||
if (pchan->chan == chan->deschan)
|
||||
break;
|
||||
}
|
||||
@ -3135,7 +3116,7 @@ audio_ioctl(dev_t dev, struct audio_softc *sc, u_long cmd, void *addr, int flag,
|
||||
case AUDIO_DRAIN:
|
||||
DPRINTF(("AUDIO_DRAIN\n"));
|
||||
mutex_enter(sc->sc_intr_lock);
|
||||
error = audio_drain(sc, pchan);
|
||||
error = audio_drain(sc, pchan->vc);
|
||||
if (!error && sc->sc_opens == 1 && hw->drain)
|
||||
error = hw->drain(sc->hw_hdl);
|
||||
mutex_exit(sc->sc_intr_lock);
|
||||
@ -3451,8 +3432,6 @@ audio_mmap(struct audio_softc *sc, off_t *offp, size_t len, int prot,
|
||||
int
|
||||
audiostartr(struct audio_softc *sc, struct virtual_channel *vc)
|
||||
{
|
||||
|
||||
struct audio_chan *chan;
|
||||
int error;
|
||||
|
||||
KASSERT(mutex_owned(sc->sc_lock));
|
||||
@ -3461,10 +3440,9 @@ audiostartr(struct audio_softc *sc, struct virtual_channel *vc)
|
||||
vc->sc_mrr.s.start, audio_stream_get_used(&vc->sc_mrr.s),
|
||||
vc->sc_mrr.usedhigh, vc->sc_mrr.mmapped));
|
||||
|
||||
chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
|
||||
if (!audio_can_capture(sc))
|
||||
return EINVAL;
|
||||
if (vc == chan->vc)
|
||||
if (vc == sc->sc_hwvc)
|
||||
return 0;
|
||||
|
||||
error = 0;
|
||||
@ -3482,12 +3460,10 @@ audiostartr(struct audio_softc *sc, struct virtual_channel *vc)
|
||||
int
|
||||
audiostartp(struct audio_softc *sc, struct virtual_channel *vc)
|
||||
{
|
||||
struct audio_chan *chan;
|
||||
int error, used;
|
||||
|
||||
KASSERT(mutex_owned(sc->sc_lock));
|
||||
|
||||
chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
|
||||
error = 0;
|
||||
used = audio_stream_get_used(&vc->sc_mpr.s);
|
||||
DPRINTF(("audiostartp: start=%p used=%d(hi=%d blk=%d) mmapped=%d\n",
|
||||
@ -3496,7 +3472,7 @@ audiostartp(struct audio_softc *sc, struct virtual_channel *vc)
|
||||
|
||||
if (!audio_can_playback(sc))
|
||||
return EINVAL;
|
||||
if (vc == chan->vc)
|
||||
if (vc == sc->sc_hwvc)
|
||||
return 0;
|
||||
|
||||
if (!vc->sc_mpr.mmapped && used < vc->sc_mpr.blksize) {
|
||||
@ -3513,7 +3489,7 @@ audiostartp(struct audio_softc *sc, struct virtual_channel *vc)
|
||||
error = mix_write(sc);
|
||||
if (error)
|
||||
goto done;
|
||||
vc = chan->vc;
|
||||
vc = sc->sc_hwvc;
|
||||
vc->sc_mpr.s.outp =
|
||||
audio_stream_add_outp(&vc->sc_mpr.s,
|
||||
vc->sc_mpr.s.outp, vc->sc_mpr.blksize);
|
||||
@ -3630,13 +3606,11 @@ void
|
||||
audio_pint(void *v)
|
||||
{
|
||||
struct audio_softc *sc;
|
||||
struct audio_chan *chan;
|
||||
struct virtual_channel *vc;
|
||||
int blksize, cc, used;
|
||||
|
||||
sc = v;
|
||||
chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
|
||||
vc = chan->vc;
|
||||
vc = sc->sc_hwvc;
|
||||
blksize = vc->sc_mpr.blksize;
|
||||
|
||||
if (sc->sc_dying == true || sc->sc_trigger_started == false)
|
||||
@ -3698,9 +3672,6 @@ audio_mix(void *v)
|
||||
if (!sc->sc_opens)
|
||||
break; /* ignore interrupt if not open */
|
||||
|
||||
if (chan == SIMPLEQ_FIRST(&sc->sc_audiochan))
|
||||
continue;
|
||||
|
||||
vc = chan->vc;
|
||||
|
||||
if (!vc->sc_open)
|
||||
@ -3835,7 +3806,7 @@ audio_mix(void *v)
|
||||
}
|
||||
mutex_enter(sc->sc_intr_lock);
|
||||
|
||||
vc = SIMPLEQ_FIRST(&sc->sc_audiochan)->vc;
|
||||
vc = sc->sc_hwvc;
|
||||
cb = &sc->sc_pr;
|
||||
inp = cb->s.inp;
|
||||
cc = blksize - (inp - cb->s.start) % blksize;
|
||||
@ -3909,9 +3880,6 @@ audio_upmix(void *v)
|
||||
if (!sc->sc_opens)
|
||||
break; /* ignore interrupt if not open */
|
||||
|
||||
if (chan == SIMPLEQ_FIRST(&sc->sc_audiochan))
|
||||
continue;
|
||||
|
||||
vc = chan->vc;
|
||||
|
||||
if (!(vc->sc_open & AUOPEN_READ))
|
||||
@ -4102,17 +4070,13 @@ audio_check_params(struct audio_params *p)
|
||||
static int
|
||||
audio_set_vchan_defaults(struct audio_softc *sc, u_int mode)
|
||||
{
|
||||
struct audio_chan *chan;
|
||||
struct virtual_channel *vc;
|
||||
struct audio_info ai;
|
||||
int error;
|
||||
|
||||
KASSERT(mutex_owned(sc->sc_lock));
|
||||
|
||||
chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
|
||||
if (chan == NULL)
|
||||
return EINVAL;
|
||||
vc = chan->vc;
|
||||
vc = sc->sc_hwvc;
|
||||
|
||||
/* default parameters */
|
||||
vc->sc_rparams = sc->sc_vchan_params;
|
||||
@ -4749,7 +4713,7 @@ audiosetinfo(struct audio_softc *sc, struct audio_info *ai, bool reset,
|
||||
audio_init_record(sc, vc);
|
||||
}
|
||||
|
||||
if (vc == SIMPLEQ_FIRST(&sc->sc_audiochan)->vc) {
|
||||
if (vc == sc->sc_hwvc) {
|
||||
if (!cleared) {
|
||||
audio_clear_intr_unlocked(sc, vc);
|
||||
cleared = true;
|
||||
@ -5252,9 +5216,6 @@ audio_suspend(device_t dv, const pmf_qual_t *qual)
|
||||
mutex_enter(sc->sc_lock);
|
||||
audio_mixer_capture(sc);
|
||||
SIMPLEQ_FOREACH(chan, &sc->sc_audiochan, entries) {
|
||||
if (chan == SIMPLEQ_FIRST(&sc->sc_audiochan))
|
||||
continue;
|
||||
|
||||
vc = chan->vc;
|
||||
if (vc->sc_pbus && !pbus)
|
||||
pbus = true;
|
||||
@ -5291,10 +5252,7 @@ audio_resume(device_t dv, const pmf_qual_t *qual)
|
||||
|
||||
audio_mixer_restore(sc);
|
||||
SIMPLEQ_FOREACH(chan, &sc->sc_audiochan, entries) {
|
||||
if (chan == SIMPLEQ_FIRST(&sc->sc_audiochan))
|
||||
continue;
|
||||
vc = chan->vc;
|
||||
|
||||
if (vc->sc_lastinfovalid == true)
|
||||
audiosetinfo(sc, &vc->sc_lastinfo, true, vc);
|
||||
if (vc->sc_pbus == true && !vc->sc_mpr.pause)
|
||||
@ -5411,7 +5369,6 @@ int
|
||||
mix_read(void *arg)
|
||||
{
|
||||
struct audio_softc *sc = arg;
|
||||
struct audio_chan *chan;
|
||||
struct virtual_channel *vc;
|
||||
stream_filter_t *filter;
|
||||
stream_fetcher_t *fetcher;
|
||||
@ -5419,8 +5376,7 @@ mix_read(void *arg)
|
||||
int cc, cc1, blksize, error;
|
||||
uint8_t *inp;
|
||||
|
||||
chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
|
||||
vc = chan->vc;
|
||||
vc = sc->sc_hwvc;
|
||||
blksize = vc->sc_mrr.blksize;
|
||||
cc = blksize;
|
||||
error = 0;
|
||||
@ -5441,7 +5397,7 @@ mix_read(void *arg)
|
||||
if (error) {
|
||||
/* XXX does this really help? */
|
||||
DPRINTF(("audio_upmix restart failed: %d\n", error));
|
||||
audio_clear(sc, SIMPLEQ_FIRST(&sc->sc_audiochan)->vc);
|
||||
audio_clear(sc, sc->sc_hwvc);
|
||||
sc->sc_rec_started = false;
|
||||
return error;
|
||||
}
|
||||
@ -5479,7 +5435,6 @@ int
|
||||
mix_write(void *arg)
|
||||
{
|
||||
struct audio_softc *sc = arg;
|
||||
struct audio_chan *chan;
|
||||
struct virtual_channel *vc;
|
||||
stream_filter_t *filter;
|
||||
stream_fetcher_t *fetcher;
|
||||
@ -5487,8 +5442,7 @@ mix_write(void *arg)
|
||||
int cc, cc1, cc2, blksize, error, used;
|
||||
uint8_t *inp, *orig, *tocopy;
|
||||
|
||||
chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
|
||||
vc = chan->vc;
|
||||
vc = sc->sc_hwvc;
|
||||
blksize = vc->sc_mpr.blksize;
|
||||
cc = blksize;
|
||||
error = 0;
|
||||
@ -5552,7 +5506,7 @@ done:
|
||||
if (error) {
|
||||
/* XXX does this really help? */
|
||||
DPRINTF(("audio_mix restart failed: %d\n", error));
|
||||
audio_clear(sc, SIMPLEQ_FIRST(&sc->sc_audiochan)->vc);
|
||||
audio_clear(sc, sc->sc_hwvc);
|
||||
sc->sc_trigger_started = false;
|
||||
}
|
||||
|
||||
@ -5689,8 +5643,6 @@ find_vchan_vol(struct audio_softc *sc, int d)
|
||||
|
||||
j = 0;
|
||||
SIMPLEQ_FOREACH(chan, &sc->sc_audiochan, entries) {
|
||||
if (chan == SIMPLEQ_FIRST(&sc->sc_audiochan))
|
||||
continue;
|
||||
if (j == n)
|
||||
break;
|
||||
j++;
|
||||
@ -5791,13 +5743,11 @@ audio_set_params(struct audio_softc *sc, int setmode, int usemode,
|
||||
stream_filter_list_t *pfil, stream_filter_list_t *rfil,
|
||||
const struct virtual_channel *vc)
|
||||
{
|
||||
struct audio_chan *chan;
|
||||
|
||||
chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
|
||||
int error = 0;
|
||||
|
||||
KASSERT(mutex_owned(sc->sc_lock));
|
||||
|
||||
if (vc == chan->vc && sc->hw_if->set_params != NULL) {
|
||||
if (vc == sc->sc_hwvc && sc->hw_if->set_params != NULL) {
|
||||
sc->sc_ready = true;
|
||||
if (sc->sc_vchan_params.precision == 8)
|
||||
play->encoding = rec->encoding = AUDIO_ENCODING_SLINEAR;
|
||||
@ -6014,13 +5964,11 @@ audio_sysctl_channels(SYSCTLFN_ARGS)
|
||||
static int
|
||||
vchan_autoconfig(struct audio_softc *sc)
|
||||
{
|
||||
struct audio_chan *chan;
|
||||
struct virtual_channel *vc;
|
||||
uint i, j, k;
|
||||
int error;
|
||||
|
||||
chan = SIMPLEQ_FIRST(&sc->sc_audiochan);
|
||||
vc = chan->vc;
|
||||
vc = sc->sc_hwvc;
|
||||
error = 0;
|
||||
|
||||
mutex_enter(sc->sc_lock);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: audiovar.h,v 1.62 2017/08/13 05:04:08 isaki Exp $ */
|
||||
/* $NetBSD: audiovar.h,v 1.63 2017/08/15 04:42:56 isaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
@ -183,6 +183,7 @@ struct audio_softc {
|
||||
const struct audio_hw_if *hw_if; /* Hardware interface */
|
||||
device_t sc_dev; /* Hardware device struct */
|
||||
struct chan_queue sc_audiochan; /* queue of open audio chans */
|
||||
struct virtual_channel *sc_hwvc;
|
||||
|
||||
struct audio_encoding_set *sc_encodings;
|
||||
struct selinfo sc_wsel; /* write selector */
|
||||
@ -224,9 +225,9 @@ struct audio_softc {
|
||||
* play_thread
|
||||
* sc_pr
|
||||
* |
|
||||
* vchan[0]->sc_pustream (First element in sc_audiochan)
|
||||
* sc_hwvc->sc_pustream
|
||||
* |
|
||||
* vchan[0]->sc_mpr
|
||||
* sc_hwvc->sc_mpr
|
||||
* |
|
||||
* hardware
|
||||
*/
|
||||
@ -236,10 +237,10 @@ struct audio_softc {
|
||||
/**
|
||||
* hardware
|
||||
* |
|
||||
* oc->sc_mrr oc = sc->sc_vchan[0]
|
||||
* sc_hwvc->sc_mrr
|
||||
* : Transform though filters same process as each
|
||||
* : vc to IF
|
||||
* oc->sc_rustream Audio now in intermediate format (IF)
|
||||
* sc_hwvc->sc_rustream Audio now in intermediate format (IF)
|
||||
* | mix_read();
|
||||
* sc_rr
|
||||
* | audio_upmix vc = sc->sc_vchan[n]
|
||||
|
Loading…
Reference in New Issue
Block a user