summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_sndio.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-26 15:46:33 +0200
committerwm4 <wm4@nowhere>2014-09-26 15:46:33 +0200
commit3208f8c44517630c6ffc800b47159c012304266c (patch)
tree5ab96dfdb853c6a6f5873a43d15e29bc5605e0cf /audio/out/ao_sndio.c
parent12d93fdfef211185ca57093bad9c95fb74067c93 (diff)
downloadmpv-3208f8c44517630c6ffc800b47159c012304266c.tar.bz2
mpv-3208f8c44517630c6ffc800b47159c012304266c.tar.xz
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.
Diffstat (limited to 'audio/out/ao_sndio.c')
-rw-r--r--audio/out/ao_sndio.c12
1 files changed, 5 insertions, 7 deletions
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;
}
/*