ao_sndio: update buffer status on get_delay

get_delay needs to report the current audio buffer status. It's
important for A/V sync that this information is current, but functions
which update it were called on play() or get_space() calls only.
This commit is contained in:
wm4 2014-09-26 15:46:36 +02:00
parent 3208f8c445
commit da1918b894
1 changed files with 15 additions and 9 deletions

View File

@ -246,22 +246,25 @@ static int play(struct ao *ao, void **data, int samples, int flags)
return n;
}
/*
* make libsndio call movecb()
*/
static void update(struct ao *ao)
{
struct priv *p = ao->priv;
int n = sio_pollfd(p->hdl, p->pfd, POLLOUT);
while (poll(p->pfd, n, 0) < 0 && errno == EINTR) {}
sio_revents(p->hdl, p->pfd);
}
/*
* how many samples can be played without blocking
*/
static int get_space(struct ao *ao)
{
struct priv *p = ao->priv;
int n;
/*
* call poll() and sio_revents(), so the
* delay counter is updated
*/
n = sio_pollfd(p->hdl, p->pfd, POLLOUT);
while (poll(p->pfd, n, 0) < 0 && errno == EINTR)
; /* nothing */
sio_revents(p->hdl, p->pfd);
update(ao);
int samples = p->par.bufsz - p->delay;
return samples / p->par.round * p->par.round;
@ -273,6 +276,9 @@ static int get_space(struct ao *ao)
static float get_delay(struct ao *ao)
{
struct priv *p = ao->priv;
update(ao);
return p->delay / (double)p->par.rate;
}