mirror of https://github.com/ericonr/sndio.git
recommit max delta'' fix, backed out by mistake
This commit is contained in:
parent
655364c586
commit
75acc22776
|
@ -25,6 +25,7 @@
|
|||
* implement generic blocking sio_read() and sio_write() with poll(2)
|
||||
* and use non-blocking sio_ops only
|
||||
*/
|
||||
|
||||
#ifdef USE_SUN
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
@ -891,7 +892,7 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
|
|||
{
|
||||
struct sun_hdl *hdl = (struct sun_hdl *)sh;
|
||||
struct audio_offset ao;
|
||||
int xrun, dmove, dierr = 0, doerr = 0, doffset = 0;
|
||||
int xrun, dmove, dierr = 0, doerr = 0, delta;
|
||||
int revents = pfd->revents;
|
||||
|
||||
if (hdl->sio.mode & SIO_PLAY) {
|
||||
|
@ -902,8 +903,8 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
|
|||
}
|
||||
doerr = xrun - hdl->oerr;
|
||||
hdl->oerr = xrun;
|
||||
if (hdl->sio.mode & SIO_REC)
|
||||
doffset += doerr;
|
||||
if (!(hdl->sio.mode & SIO_REC))
|
||||
dierr = doerr;
|
||||
}
|
||||
if (hdl->sio.mode & SIO_REC) {
|
||||
if (ioctl(hdl->fd, AUDIO_RERROR, &xrun) < 0) {
|
||||
|
@ -913,10 +914,10 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
|
|||
}
|
||||
dierr = xrun - hdl->ierr;
|
||||
hdl->ierr = xrun;
|
||||
if (hdl->sio.mode & SIO_PLAY)
|
||||
doffset -= dierr;
|
||||
if (!(hdl->sio.mode & SIO_PLAY))
|
||||
doerr = dierr;
|
||||
}
|
||||
hdl->offset += doffset;
|
||||
hdl->offset += doerr - dierr;
|
||||
dmove = dierr > doerr ? dierr : doerr;
|
||||
hdl->idelta -= dmove;
|
||||
hdl->odelta -= dmove;
|
||||
|
@ -927,25 +928,29 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
|
|||
hdl->sio.eof = 1;
|
||||
return POLLHUP;
|
||||
}
|
||||
hdl->odelta += (ao.samples - hdl->obytes) / hdl->obpf;
|
||||
delta = (ao.samples - hdl->obytes) / hdl->obpf;
|
||||
hdl->obytes = ao.samples;
|
||||
if (hdl->odelta > 0) {
|
||||
sio_onmove_cb(&hdl->sio, hdl->odelta);
|
||||
hdl->odelta = 0;
|
||||
hdl->odelta += delta;
|
||||
if (!(hdl->sio.mode & SIO_REC))
|
||||
hdl->idelta += delta;
|
||||
}
|
||||
}
|
||||
if ((revents & POLLIN) && !(hdl->sio.mode & SIO_PLAY)) {
|
||||
if ((revents & POLLIN) && (hdl->sio.mode & SIO_REC)) {
|
||||
if (ioctl(hdl->fd, AUDIO_GETIOFFS, &ao) < 0) {
|
||||
DPERROR("sun_revents: GETIOFFS");
|
||||
hdl->sio.eof = 1;
|
||||
return POLLHUP;
|
||||
}
|
||||
hdl->idelta += (ao.samples - hdl->ibytes) / hdl->ibpf;
|
||||
delta = (ao.samples - hdl->ibytes) / hdl->ibpf;
|
||||
hdl->ibytes = ao.samples;
|
||||
if (hdl->idelta > 0) {
|
||||
sio_onmove_cb(&hdl->sio, hdl->idelta);
|
||||
hdl->idelta = 0;
|
||||
hdl->idelta += delta;
|
||||
if (!(hdl->sio.mode & SIO_PLAY))
|
||||
hdl->odelta += delta;
|
||||
}
|
||||
delta = (hdl->idelta > hdl->odelta) ? hdl->idelta : hdl->odelta;
|
||||
if (delta > 0) {
|
||||
sio_onmove_cb(&hdl->sio, delta);
|
||||
hdl->idelta -= delta;
|
||||
hdl->odelta -= delta;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue