switch back into using a single "filling" flag to determine

whether playback is started
This commit is contained in:
Alexandre Ratchov 2016-05-16 07:53:05 +02:00
parent 8070eb6272
commit 20a7e3c46e
1 changed files with 10 additions and 7 deletions

View File

@ -42,7 +42,7 @@
struct sio_sun_hdl { struct sio_sun_hdl {
struct sio_hdl sio; struct sio_hdl sio;
int fd; int fd;
int filltodo; int filling;
unsigned int ibpf, obpf; /* bytes per frame */ unsigned int ibpf, obpf; /* bytes per frame */
unsigned int ibytes, obytes; /* bytes the hw transferred */ unsigned int ibytes, obytes; /* bytes the hw transferred */
unsigned int ierr, oerr; /* frames the hw dropped */ unsigned int ierr, oerr; /* frames the hw dropped */
@ -326,6 +326,7 @@ sio_sun_fdopen(int fd, unsigned int mode, int nbio)
return NULL; return NULL;
} }
hdl->fd = fd; hdl->fd = fd;
hdl->filling = 0;
return (struct sio_hdl *)hdl; return (struct sio_hdl *)hdl;
} }
@ -372,10 +373,10 @@ sio_sun_start(struct sio_hdl *sh)
if (hdl->sio.mode & SIO_PLAY) { if (hdl->sio.mode & SIO_PLAY) {
/* /*
* keep the device paused and let sio_sun_write() trigger the * keep the device paused and let sio_sun_pollfd() trigger the
* start later, to avoid buffer underruns * start later, to avoid buffer underruns
*/ */
hdl->filltodo = hdl->sio.par.bufsz * hdl->obpf; hdl->filling = 1;
} else { } else {
/* /*
* no play buffers to fill, start now! * no play buffers to fill, start now!
@ -385,7 +386,6 @@ sio_sun_start(struct sio_hdl *sh)
hdl->sio.eof = 1; hdl->sio.eof = 1;
return 0; return 0;
} }
hdl->filltodo = 0;
_sio_onmove_cb(&hdl->sio, 0); _sio_onmove_cb(&hdl->sio, 0);
} }
return 1; return 1;
@ -396,8 +396,10 @@ sio_sun_stop(struct sio_hdl *sh)
{ {
struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh; struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh;
if (hdl->filltodo > 0) if (hdl->filling) {
hdl->filling = 0;
return 1; return 1;
}
if (ioctl(hdl->fd, AUDIO_STOP) < 0) { if (ioctl(hdl->fd, AUDIO_STOP) < 0) {
DPERROR("AUDIO_STOP"); DPERROR("AUDIO_STOP");
hdl->sio.eof = 1; hdl->sio.eof = 1;
@ -522,8 +524,9 @@ sio_sun_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events)
pfd->fd = hdl->fd; pfd->fd = hdl->fd;
pfd->events = events; pfd->events = events;
if (hdl->filltodo > 0 && hdl->sio.wused == hdl->filltodo) { if (hdl->filling && hdl->sio.wused == hdl->sio.par.bufsz *
hdl->filltodo = 0; hdl->sio.par.pchan * hdl->sio.par.bps) {
hdl->filling = 0;
if (ioctl(hdl->fd, AUDIO_START) < 0) { if (ioctl(hdl->fd, AUDIO_START) < 0) {
DPERROR("AUDIO_START"); DPERROR("AUDIO_START");
hdl->sio.eof = 1; hdl->sio.eof = 1;