Fix confusion between processed samples by the hardware (as reported

by GET{I,O}OFFS) and samples played as reported by GETINFO(). Fixes
incorrect delta propagated after xruns.
This commit is contained in:
Alexandre Ratchov 2014-03-04 23:24:52 +01:00
parent 0d773f998a
commit cbecd3ea8d
1 changed files with 10 additions and 4 deletions

View File

@ -877,16 +877,22 @@ sio_sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
if (dierr > 0)
DPRINTFN(2, "rec xrun %d\n", dierr);
}
/*
* GET{I,O}OFFS report positions including xruns,
* so we have to substract to get the real position
*/
hdl->idelta -= dierr;
hdl->odelta -= doerr;
offset = doerr - dierr;
if (offset > 0) {
hdl->sio.rdrop += offset * hdl->ibpf;
hdl->idelta -= doerr;
hdl->odelta -= doerr;
hdl->idelta -= offset;
DPRINTFN(2, "will drop %d and pause %d\n", offset, doerr);
} else if (offset < 0) {
hdl->sio.wsil += -offset * hdl->obpf;
hdl->idelta -= dierr;
hdl->odelta -= dierr;
hdl->odelta -= offset;
DPRINTFN(2, "will insert %d and pause %d\n", -offset, dierr);
}