From 3208f8c44517630c6ffc800b47159c012304266c Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 26 Sep 2014 15:46:33 +0200 Subject: ao_sndio: change p->delay to samples This was in bytes, but it's more convenient to use samples (or frames; in any case the smallest unit of audio that includes all channels). Remove the ao->bps line too; it will be set after init() returns. --- audio/out/ao_sndio.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'audio/out/ao_sndio.c') diff --git a/audio/out/ao_sndio.c b/audio/out/ao_sndio.c index b698f9880a..9d4949d69f 100644 --- a/audio/out/ao_sndio.c +++ b/audio/out/ao_sndio.c @@ -74,7 +74,7 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg) static void movecb(void *addr, int delta) { struct priv *p = addr; - p->delay -= delta * (int)(p->par.bps * p->par.pchan); + p->delay -= delta; } /* @@ -186,10 +186,8 @@ static int init(struct ao *ao) goto error; } - ao->bps = p->par.bps * p->par.pchan * p->par.rate; p->havevol = sio_onvol(p->hdl, volcb, p); sio_onmove(p->hdl, movecb, p); - p->delay = 0; if (!sio_start(p->hdl)) MP_ERR(ao, "init: couldn't start\n"); @@ -241,11 +239,11 @@ static int play(struct ao *ao, void **data, int samples, int flags) struct priv *p = ao->priv; int n; - n = sio_write(p->hdl, data[0], samples * ao->sstride); + n = sio_write(p->hdl, data[0], samples * ao->sstride) / ao->sstride; p->delay += n; if (flags & AOPLAY_FINAL_CHUNK) reset(ao); - return n / ao->sstride; + return n; } /* @@ -265,7 +263,7 @@ static int get_space(struct ao *ao) ; /* nothing */ sio_revents(p->hdl, p->pfd); - int samples = (p->par.bufsz * p->par.pchan * p->par.bps - p->delay) / ao->sstride; + int samples = p->par.bufsz - p->delay; return samples / p->par.round * p->par.round; } @@ -275,7 +273,7 @@ static int get_space(struct ao *ao) static float get_delay(struct ao *ao) { struct priv *p = ao->priv; - return (float)p->delay / (p->par.bps * p->par.pchan * p->par.rate); + return p->delay / (double)p->par.rate; } /* -- cgit v1.2.3