mirror of https://github.com/ericonr/sndio.git
move data outside dsp states, generate silence with enc_sil_do
This commit is contained in:
parent
b4b6aa1844
commit
41b3188fd4
38
sndiod/dev.c
38
sndiod/dev.c
|
@ -444,7 +444,7 @@ dev_midi_omsg(void *arg, unsigned char *msg, int len)
|
||||||
fps = 30;
|
fps = 30;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* XXX: should dev_mmcstop() here */
|
dev_mmcstop(d);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dev_mmcloc(d,
|
dev_mmcloc(d,
|
||||||
|
@ -509,7 +509,9 @@ slot_sub_sil(struct slot *s)
|
||||||
log_puts(": inserted a rec block of silence\n");
|
log_puts(": inserted a rec block of silence\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* XXX: this is not silence for all encodings */
|
if (s->sub.encbuf)
|
||||||
|
enc_sil_do(&s->sub.enc, data, s->round);
|
||||||
|
else
|
||||||
memset(data, 0, s->round * s->sub.buf.bpf);
|
memset(data, 0, s->round * s->sub.buf.bpf);
|
||||||
abuf_wcommit(&s->sub.buf, s->round);
|
abuf_wcommit(&s->sub.buf, s->round);
|
||||||
s->sub.silence--;
|
s->sub.silence--;
|
||||||
|
@ -531,10 +533,10 @@ play_filt_resamp(struct slot *s, void *res_in, void *out, int todo)
|
||||||
int i, offs, vol, nch;
|
int i, offs, vol, nch;
|
||||||
void *in;
|
void *in;
|
||||||
|
|
||||||
if (s->mix.resamp.data) {
|
if (s->mix.resampbuf) {
|
||||||
todo = resamp_do(&s->mix.resamp,
|
todo = resamp_do(&s->mix.resamp,
|
||||||
res_in, s->mix.resamp.data, todo);
|
res_in, s->mix.resampbuf, todo);
|
||||||
in = s->mix.resamp.data;
|
in = s->mix.resampbuf;
|
||||||
} else
|
} else
|
||||||
in = res_in;
|
in = res_in;
|
||||||
|
|
||||||
|
@ -564,7 +566,7 @@ play_filt_dec(struct slot *s, void *in, void *out, int todo)
|
||||||
{
|
{
|
||||||
void *tmp;
|
void *tmp;
|
||||||
|
|
||||||
tmp = s->mix.dec.data;
|
tmp = s->mix.decbuf;
|
||||||
if (tmp)
|
if (tmp)
|
||||||
dec_do(&s->mix.dec, in, tmp, todo);
|
dec_do(&s->mix.dec, in, tmp, todo);
|
||||||
return play_filt_resamp(s, tmp ? tmp : in, out, todo);
|
return play_filt_resamp(s, tmp ? tmp : in, out, todo);
|
||||||
|
@ -735,7 +737,7 @@ rec_filt_resamp(struct slot *s, void *in, void *res_out, int todo)
|
||||||
int i, vol, offs, nch;
|
int i, vol, offs, nch;
|
||||||
void *out = res_out;
|
void *out = res_out;
|
||||||
|
|
||||||
out = (s->sub.resamp.data) ? s->sub.resamp.data : res_out;
|
out = (s->sub.resampbuf) ? s->sub.resampbuf : res_out;
|
||||||
|
|
||||||
nch = s->sub.slot_cmax - s->sub.slot_cmin + 1;
|
nch = s->sub.slot_cmax - s->sub.slot_cmin + 1;
|
||||||
vol = ADATA_UNIT / s->sub.join;
|
vol = ADATA_UNIT / s->sub.join;
|
||||||
|
@ -751,9 +753,9 @@ rec_filt_resamp(struct slot *s, void *in, void *res_out, int todo)
|
||||||
offs += nch;
|
offs += nch;
|
||||||
cmap_copy(&s->sub.cmap, in, (adata_t *)out + offs, vol, todo);
|
cmap_copy(&s->sub.cmap, in, (adata_t *)out + offs, vol, todo);
|
||||||
}
|
}
|
||||||
if (s->sub.resamp.data) {
|
if (s->sub.resampbuf) {
|
||||||
todo = resamp_do(&s->sub.resamp,
|
todo = resamp_do(&s->sub.resamp,
|
||||||
s->sub.resamp.data, res_out, todo);
|
s->sub.resampbuf, res_out, todo);
|
||||||
}
|
}
|
||||||
return todo;
|
return todo;
|
||||||
}
|
}
|
||||||
|
@ -763,7 +765,7 @@ rec_filt_enc(struct slot *s, void *in, void *out, int todo)
|
||||||
{
|
{
|
||||||
void *tmp;
|
void *tmp;
|
||||||
|
|
||||||
tmp = s->sub.enc.data;
|
tmp = s->sub.encbuf;
|
||||||
todo = rec_filt_resamp(s, in, tmp ? tmp : out, todo);
|
todo = rec_filt_resamp(s, in, tmp ? tmp : out, todo);
|
||||||
if (tmp)
|
if (tmp)
|
||||||
enc_do(&s->sub.enc, tmp, out, todo);
|
enc_do(&s->sub.enc, tmp, out, todo);
|
||||||
|
@ -1641,8 +1643,8 @@ slot_attach(struct slot *s)
|
||||||
round = dev_roundof(d, s->rate);
|
round = dev_roundof(d, s->rate);
|
||||||
slot_nch = s->mix.slot_cmax - s->mix.slot_cmin + 1;
|
slot_nch = s->mix.slot_cmax - s->mix.slot_cmin + 1;
|
||||||
dev_nch = s->mix.dev_cmax - s->mix.dev_cmin + 1;
|
dev_nch = s->mix.dev_cmax - s->mix.dev_cmin + 1;
|
||||||
s->mix.dec.data = NULL;
|
s->mix.decbuf = NULL;
|
||||||
s->mix.resamp.data = NULL;
|
s->mix.resampbuf = NULL;
|
||||||
s->mix.join = 1;
|
s->mix.join = 1;
|
||||||
s->mix.expand = 1;
|
s->mix.expand = 1;
|
||||||
if (s->dup) {
|
if (s->dup) {
|
||||||
|
@ -1658,12 +1660,12 @@ slot_attach(struct slot *s)
|
||||||
s->mix.dev_cmin, s->mix.dev_cmax);
|
s->mix.dev_cmin, s->mix.dev_cmax);
|
||||||
if (!aparams_native(&s->par)) {
|
if (!aparams_native(&s->par)) {
|
||||||
dec_init(&s->mix.dec, &s->par, slot_nch);
|
dec_init(&s->mix.dec, &s->par, slot_nch);
|
||||||
s->mix.dec.data =
|
s->mix.decbuf =
|
||||||
xmalloc(d->round * slot_nch * sizeof(adata_t));
|
xmalloc(d->round * slot_nch * sizeof(adata_t));
|
||||||
}
|
}
|
||||||
if (s->rate != d->rate) {
|
if (s->rate != d->rate) {
|
||||||
resamp_init(&s->mix.resamp, s->round, d->round, slot_nch);
|
resamp_init(&s->mix.resamp, s->round, d->round, slot_nch);
|
||||||
s->mix.resamp.data =
|
s->mix.resampbuf =
|
||||||
xmalloc(d->round * slot_nch * sizeof(adata_t));
|
xmalloc(d->round * slot_nch * sizeof(adata_t));
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -1696,8 +1698,8 @@ slot_attach(struct slot *s)
|
||||||
nblk = (d->bufsz / d->round + 3) / 4;
|
nblk = (d->bufsz / d->round + 3) / 4;
|
||||||
slot_nch = s->sub.slot_cmax - s->sub.slot_cmin + 1;
|
slot_nch = s->sub.slot_cmax - s->sub.slot_cmin + 1;
|
||||||
dev_nch = s->sub.dev_cmax - s->sub.dev_cmin + 1;
|
dev_nch = s->sub.dev_cmax - s->sub.dev_cmin + 1;
|
||||||
s->sub.enc.data = NULL;
|
s->sub.encbuf = NULL;
|
||||||
s->sub.resamp.data = NULL;
|
s->sub.resampbuf = NULL;
|
||||||
s->sub.join = 1;
|
s->sub.join = 1;
|
||||||
s->sub.expand = 1;
|
s->sub.expand = 1;
|
||||||
if (s->dup) {
|
if (s->dup) {
|
||||||
|
@ -1714,12 +1716,12 @@ slot_attach(struct slot *s)
|
||||||
if (s->rate != d->rate) {
|
if (s->rate != d->rate) {
|
||||||
resamp_init(&s->sub.resamp, d->round, s->round,
|
resamp_init(&s->sub.resamp, d->round, s->round,
|
||||||
slot_nch);
|
slot_nch);
|
||||||
s->sub.resamp.data =
|
s->sub.resampbuf =
|
||||||
xmalloc(d->round * slot_nch * sizeof(adata_t));
|
xmalloc(d->round * slot_nch * sizeof(adata_t));
|
||||||
}
|
}
|
||||||
if (!aparams_native(&s->par)) {
|
if (!aparams_native(&s->par)) {
|
||||||
enc_init(&s->sub.enc, &s->par, slot_nch);
|
enc_init(&s->sub.enc, &s->par, slot_nch);
|
||||||
s->sub.enc.data =
|
s->sub.encbuf =
|
||||||
xmalloc(d->round * slot_nch * sizeof(adata_t));
|
xmalloc(d->round * slot_nch * sizeof(adata_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
sndiod/dev.h
10
sndiod/dev.h
|
@ -56,8 +56,9 @@ struct slot {
|
||||||
struct cmap cmap; /* channel mapper state */
|
struct cmap cmap; /* channel mapper state */
|
||||||
struct resamp resamp; /* resampler state */
|
struct resamp resamp; /* resampler state */
|
||||||
struct conv dec; /* format decoder params */
|
struct conv dec; /* format decoder params */
|
||||||
int join; /* remix count */
|
int join; /* channel join factor */
|
||||||
int expand; /* remix count */
|
int expand; /* channel expand factor */
|
||||||
|
void *resampbuf, *decbuf; /* tmp buffers */
|
||||||
} mix;
|
} mix;
|
||||||
struct {
|
struct {
|
||||||
int silence; /* to add on next write */
|
int silence; /* to add on next write */
|
||||||
|
@ -67,8 +68,9 @@ struct slot {
|
||||||
struct cmap cmap; /* channel mapper state */
|
struct cmap cmap; /* channel mapper state */
|
||||||
struct resamp resamp; /* buffer for resampling */
|
struct resamp resamp; /* buffer for resampling */
|
||||||
struct conv enc; /* buffer for encoding */
|
struct conv enc; /* buffer for encoding */
|
||||||
int join; /* remix count */
|
int join; /* channel join factor */
|
||||||
int expand; /* remix count */
|
int expand; /* channel expand factor */
|
||||||
|
void *resampbuf, *encbuf; /* tmp buffers */
|
||||||
} sub;
|
} sub;
|
||||||
int xrun; /* underrun policy */
|
int xrun; /* underrun policy */
|
||||||
int dup; /* mono-to-stereo and alike */
|
int dup; /* mono-to-stereo and alike */
|
||||||
|
|
|
@ -111,7 +111,6 @@ struct aparams {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct resamp {
|
struct resamp {
|
||||||
void *data;
|
|
||||||
#define RESAMP_NCTX 2
|
#define RESAMP_NCTX 2
|
||||||
unsigned int ctx_start;
|
unsigned int ctx_start;
|
||||||
adata_t ctx[NCHAN_MAX * RESAMP_NCTX];
|
adata_t ctx[NCHAN_MAX * RESAMP_NCTX];
|
||||||
|
@ -122,7 +121,6 @@ struct resamp {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct conv {
|
struct conv {
|
||||||
void *data;
|
|
||||||
int bfirst; /* bytes to skip at startup */
|
int bfirst; /* bytes to skip at startup */
|
||||||
unsigned int bps; /* bytes per sample */
|
unsigned int bps; /* bytes per sample */
|
||||||
unsigned int shift; /* shift to get 32bit MSB */
|
unsigned int shift; /* shift to get 32bit MSB */
|
||||||
|
|
Loading…
Reference in New Issue