diff options
author | wm4 <wm4@nowhere> | 2014-09-26 15:46:36 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-09-26 15:46:36 +0200 |
commit | da1918b89451905255e2ad05790c944615e2a51c (patch) | |
tree | 7bd83b3d4682fa6efcdd67553795f3e4a7c2eab1 | |
parent | 3208f8c44517630c6ffc800b47159c012304266c (diff) |
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.
-rw-r--r-- | audio/out/ao_sndio.c | 24 |
1 files 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 @@ -247,21 +247,24 @@ static int play(struct ao *ao, void **data, int samples, int flags) } /* + * 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; } |