mirror of
https://github.com/ericonr/sndio.git
synced 2024-02-18 04:45:21 -06:00
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)
|
* implement generic blocking sio_read() and sio_write() with poll(2)
|
||||||
* and use non-blocking sio_ops only
|
* and use non-blocking sio_ops only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef USE_SUN
|
#ifdef USE_SUN
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/ioctl.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 sun_hdl *hdl = (struct sun_hdl *)sh;
|
||||||
struct audio_offset ao;
|
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;
|
int revents = pfd->revents;
|
||||||
|
|
||||||
if (hdl->sio.mode & SIO_PLAY) {
|
if (hdl->sio.mode & SIO_PLAY) {
|
||||||
@ -902,8 +903,8 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
|
|||||||
}
|
}
|
||||||
doerr = xrun - hdl->oerr;
|
doerr = xrun - hdl->oerr;
|
||||||
hdl->oerr = xrun;
|
hdl->oerr = xrun;
|
||||||
if (hdl->sio.mode & SIO_REC)
|
if (!(hdl->sio.mode & SIO_REC))
|
||||||
doffset += doerr;
|
dierr = doerr;
|
||||||
}
|
}
|
||||||
if (hdl->sio.mode & SIO_REC) {
|
if (hdl->sio.mode & SIO_REC) {
|
||||||
if (ioctl(hdl->fd, AUDIO_RERROR, &xrun) < 0) {
|
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;
|
dierr = xrun - hdl->ierr;
|
||||||
hdl->ierr = xrun;
|
hdl->ierr = xrun;
|
||||||
if (hdl->sio.mode & SIO_PLAY)
|
if (!(hdl->sio.mode & SIO_PLAY))
|
||||||
doffset -= dierr;
|
doerr = dierr;
|
||||||
}
|
}
|
||||||
hdl->offset += doffset;
|
hdl->offset += doerr - dierr;
|
||||||
dmove = dierr > doerr ? dierr : doerr;
|
dmove = dierr > doerr ? dierr : doerr;
|
||||||
hdl->idelta -= dmove;
|
hdl->idelta -= dmove;
|
||||||
hdl->odelta -= dmove;
|
hdl->odelta -= dmove;
|
||||||
@ -927,25 +928,29 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
|
|||||||
hdl->sio.eof = 1;
|
hdl->sio.eof = 1;
|
||||||
return POLLHUP;
|
return POLLHUP;
|
||||||
}
|
}
|
||||||
hdl->odelta += (ao.samples - hdl->obytes) / hdl->obpf;
|
delta = (ao.samples - hdl->obytes) / hdl->obpf;
|
||||||
hdl->obytes = ao.samples;
|
hdl->obytes = ao.samples;
|
||||||
if (hdl->odelta > 0) {
|
hdl->odelta += delta;
|
||||||
sio_onmove_cb(&hdl->sio, hdl->odelta);
|
if (!(hdl->sio.mode & SIO_REC))
|
||||||
hdl->odelta = 0;
|
hdl->idelta += delta;
|
||||||
}
|
}
|
||||||
}
|
if ((revents & POLLIN) && (hdl->sio.mode & SIO_REC)) {
|
||||||
if ((revents & POLLIN) && !(hdl->sio.mode & SIO_PLAY)) {
|
|
||||||
if (ioctl(hdl->fd, AUDIO_GETIOFFS, &ao) < 0) {
|
if (ioctl(hdl->fd, AUDIO_GETIOFFS, &ao) < 0) {
|
||||||
DPERROR("sun_revents: GETIOFFS");
|
DPERROR("sun_revents: GETIOFFS");
|
||||||
hdl->sio.eof = 1;
|
hdl->sio.eof = 1;
|
||||||
return POLLHUP;
|
return POLLHUP;
|
||||||
}
|
}
|
||||||
hdl->idelta += (ao.samples - hdl->ibytes) / hdl->ibpf;
|
delta = (ao.samples - hdl->ibytes) / hdl->ibpf;
|
||||||
hdl->ibytes = ao.samples;
|
hdl->ibytes = ao.samples;
|
||||||
if (hdl->idelta > 0) {
|
hdl->idelta += delta;
|
||||||
sio_onmove_cb(&hdl->sio, hdl->idelta);
|
if (!(hdl->sio.mode & SIO_PLAY))
|
||||||
hdl->idelta = 0;
|
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
Block a user