mirror of https://github.com/ericonr/sndio.git
dont use rec buffers when in the SLOT_STOP state
This commit is contained in:
parent
de206b94f5
commit
556d5f075b
56
sndiod/dev.c
56
sndiod/dev.c
|
@ -548,7 +548,7 @@ slot_skip(struct slot *s)
|
||||||
|
|
||||||
max = s->skip;
|
max = s->skip;
|
||||||
while (s->skip > 0) {
|
while (s->skip > 0) {
|
||||||
if (s->mode & MODE_RECMASK) {
|
if (s->pstate != SLOT_STOP && (s->mode & MODE_RECMASK)) {
|
||||||
data = abuf_wgetblk(&s->sub.buf, &count);
|
data = abuf_wgetblk(&s->sub.buf, &count);
|
||||||
if (count < s->round * s->sub.bpf)
|
if (count < s->round * s->sub.bpf)
|
||||||
break;
|
break;
|
||||||
|
@ -563,7 +563,7 @@ slot_skip(struct slot *s)
|
||||||
log_puts(": skipped a cycle\n");
|
log_puts(": skipped a cycle\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (s->mode & MODE_RECMASK) {
|
if (s->pstate != SLOT_STOP && (s->mode & MODE_RECMASK)) {
|
||||||
if (s->sub.encbuf)
|
if (s->sub.encbuf)
|
||||||
enc_sil_do(&s->sub.enc, data, s->round);
|
enc_sil_do(&s->sub.enc, data, s->round);
|
||||||
else
|
else
|
||||||
|
@ -811,6 +811,9 @@ dev_full_cycle(struct dev *d)
|
||||||
log_puts("\n");
|
log_puts("\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/*
|
||||||
|
* skip cycles for XRUN_SYNC correction
|
||||||
|
*/
|
||||||
slot_skip(s);
|
slot_skip(s);
|
||||||
if (s->skip < 0) {
|
if (s->skip < 0) {
|
||||||
s->skip++;
|
s->skip++;
|
||||||
|
@ -818,39 +821,40 @@ dev_full_cycle(struct dev *d)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (s->pstate == SLOT_STOP && !(s->mode & MODE_PLAY)) {
|
||||||
|
slot_log(s);
|
||||||
|
log_puts(": rec-only slots can't be drained\n");
|
||||||
|
panic();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* check if stopped stream finished draining
|
* check if stopped stream finished draining
|
||||||
*/
|
*/
|
||||||
if (s->pstate == SLOT_STOP) {
|
if (s->pstate == SLOT_STOP &&
|
||||||
if (s->mode & MODE_PLAY) {
|
s->mix.buf.used < s->round * s->mix.bpf) {
|
||||||
if (s->mix.buf.used < s->round * s->mix.bpf) {
|
/*
|
||||||
/*
|
* partial blocks are zero-filled by socket
|
||||||
* partial blocks are
|
* layer, so s->mix.buf.used == 0 and we can
|
||||||
* zero-filled by socket layer
|
* destroy the buffer
|
||||||
*/
|
*/
|
||||||
s->pstate = SLOT_INIT;
|
s->pstate = SLOT_INIT;
|
||||||
abuf_done(&s->mix.buf);
|
abuf_done(&s->mix.buf);
|
||||||
if (s->mix.decbuf)
|
if (s->mix.decbuf)
|
||||||
xfree(s->mix.decbuf);
|
xfree(s->mix.decbuf);
|
||||||
if (s->mix.resampbuf)
|
if (s->mix.resampbuf)
|
||||||
xfree(s->mix.resampbuf);
|
xfree(s->mix.resampbuf);
|
||||||
s->ops->eof(s->arg);
|
s->ops->eof(s->arg);
|
||||||
*ps = s->next;
|
*ps = s->next;
|
||||||
dev_mix_adjvol(d);
|
dev_mix_adjvol(d);
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ps = &s->next;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check for xruns
|
* check for xruns
|
||||||
*/
|
*/
|
||||||
if (((s->mode & MODE_PLAY) &&
|
if (((s->mode & MODE_PLAY) &&
|
||||||
s->mix.buf.used < s->round * s->mix.bpf &&
|
s->mix.buf.used < s->round * s->mix.bpf) ||
|
||||||
!(s->pstate == SLOT_STOP)) ||
|
|
||||||
((s->mode & MODE_RECMASK) &&
|
((s->mode & MODE_RECMASK) &&
|
||||||
s->sub.buf.len - s->sub.buf.used <
|
s->sub.buf.len - s->sub.buf.used <
|
||||||
s->round * s->sub.bpf)) {
|
s->round * s->sub.bpf)) {
|
||||||
|
|
Loading…
Reference in New Issue