From da1918b89451905255e2ad05790c944615e2a51c Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 26 Sep 2014 15:46:36 +0200 Subject: 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. --- audio/out/ao_sndio.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/audio/out/ao_sndio.c b/audio/out/ao_sndio.c index 9d4949d69f..5777aa4aac 100644 --- a/audio/out/ao_sndio.c +++ b/audio/out/ao_sndio.c @@ -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; } -- cgit v1.2.3