mirror of https://github.com/ericonr/sndio.git
ensure ralign is in the [1:round] range
This commit is contained in:
parent
ea50057bb6
commit
a225f02ed3
|
@ -974,8 +974,8 @@ sock_execmsg(struct sock *f)
|
||||||
{
|
{
|
||||||
struct slot *s = f->slot;
|
struct slot *s = f->slot;
|
||||||
struct amsg *m = &f->rmsg;
|
struct amsg *m = &f->rmsg;
|
||||||
unsigned int size, ctl;
|
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
int size, ctl;
|
||||||
|
|
||||||
switch (ntohl(m->cmd)) {
|
switch (ntohl(m->cmd)) {
|
||||||
case AMSG_DATA:
|
case AMSG_DATA:
|
||||||
|
@ -1007,7 +1007,7 @@ sock_execmsg(struct sock *f)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
size = ntohl(m->u.data.size);
|
size = ntohl(m->u.data.size);
|
||||||
if (size == 0) {
|
if (size <= 0) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (log_level >= 1) {
|
if (log_level >= 1) {
|
||||||
sock_log(f);
|
sock_log(f);
|
||||||
|
@ -1027,8 +1027,6 @@ sock_execmsg(struct sock *f)
|
||||||
sock_close(f);
|
sock_close(f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (f->ralign == 0)
|
|
||||||
f->ralign = s->round * s->mix.bpf;
|
|
||||||
if (s != NULL && size > f->ralign) {
|
if (s != NULL && size > f->ralign) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (log_level >= 1) {
|
if (log_level >= 1) {
|
||||||
|
@ -1047,6 +1045,8 @@ sock_execmsg(struct sock *f)
|
||||||
f->rsize = f->rtodo = size;
|
f->rsize = f->rtodo = size;
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
f->ralign -= size;
|
f->ralign -= size;
|
||||||
|
if (f->ralign == 0)
|
||||||
|
f->ralign = s->round * s->mix.bpf;
|
||||||
}
|
}
|
||||||
if (f->rtodo > f->rmax) {
|
if (f->rtodo > f->rmax) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -1096,7 +1096,7 @@ sock_execmsg(struct sock *f)
|
||||||
slot_start(s);
|
slot_start(s);
|
||||||
if (s->mode & MODE_PLAY) {
|
if (s->mode & MODE_PLAY) {
|
||||||
f->fillpending = s->appbufsz;
|
f->fillpending = s->appbufsz;
|
||||||
f->ralign = 0;
|
f->ralign = s->round * s->mix.bpf;
|
||||||
f->rmax = 0;
|
f->rmax = 0;
|
||||||
}
|
}
|
||||||
if (s->mode & MODE_RECMASK) {
|
if (s->mode & MODE_RECMASK) {
|
||||||
|
@ -1155,6 +1155,7 @@ sock_execmsg(struct sock *f)
|
||||||
f->rstate = SOCK_RMSG;
|
f->rstate = SOCK_RMSG;
|
||||||
f->rtodo = sizeof(struct amsg);
|
f->rtodo = sizeof(struct amsg);
|
||||||
if (s->mode & MODE_PLAY) {
|
if (s->mode & MODE_PLAY) {
|
||||||
|
if (f->ralign < s->round * s->mix.bpf) {
|
||||||
data = abuf_wgetblk(&s->mix.buf, &size);
|
data = abuf_wgetblk(&s->mix.buf, &size);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (size < f->ralign) {
|
if (size < f->ralign) {
|
||||||
|
@ -1169,7 +1170,8 @@ sock_execmsg(struct sock *f)
|
||||||
#endif
|
#endif
|
||||||
memset(data, 0, f->ralign);
|
memset(data, 0, f->ralign);
|
||||||
abuf_wcommit(&s->mix.buf, f->ralign);
|
abuf_wcommit(&s->mix.buf, f->ralign);
|
||||||
f->ralign = 0;
|
f->ralign = s->round * s->mix.bpf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
slot_stop(s);
|
slot_stop(s);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue