summaryrefslogtreecommitdiffstats
path: root/audio/out
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-06 12:59:00 +0200
committerwm4 <wm4@nowhere>2014-09-06 12:59:00 +0200
commit769ac6fb7bb39cb04933e1dede32cdbec4f74098 (patch)
tree0afa5a9dc8591c105d19b7a72800fce1a3ae37dd /audio/out
parentd9941e01ccafd5fc3fc87581dcbae5cacfa8f171 (diff)
downloadmpv-769ac6fb7bb39cb04933e1dede32cdbec4f74098.tar.bz2
mpv-769ac6fb7bb39cb04933e1dede32cdbec4f74098.tar.xz
audio/out: always round get_space on period size
Round get_space() results in the same way play() rounds the input size. Some audio APIs do this for various reasons. This affects only "push" based AOs. Some of these need no change, because they either do it already right (like ao_openal), or they seem not to have any such requirements (like ao_pulse). Needed for the following commit.
Diffstat (limited to 'audio/out')
-rw-r--r--audio/out/ao_alsa.c2
-rw-r--r--audio/out/ao_dsound.c2
-rw-r--r--audio/out/ao_null.c3
-rw-r--r--audio/out/ao_sndio.c3
4 files changed, 6 insertions, 4 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index 10580ffbff..6b0c34e320 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -675,7 +675,7 @@ static int get_space(struct ao *ao)
unsigned space = snd_pcm_status_get_avail(status);
if (space > p->buffersize) // Buffer underrun?
space = p->buffersize;
- return space;
+ return space / p->outburst * p->outburst;
alsa_error:
return 0;
diff --git a/audio/out/ao_dsound.c b/audio/out/ao_dsound.c
index 126989936e..da1742e077 100644
--- a/audio/out/ao_dsound.c
+++ b/audio/out/ao_dsound.c
@@ -585,7 +585,7 @@ static int get_space(struct ao *ao)
int space = check_free_buffer_size(ao);
if (space < p->min_free_space)
return 0;
- return (space - p->min_free_space) / ao->sstride;
+ return (space - p->min_free_space) / p->outburst * p->outburst / ao->sstride;
}
/**
diff --git a/audio/out/ao_null.c b/audio/out/ao_null.c
index 2c93cc273b..f12cbdede5 100644
--- a/audio/out/ao_null.c
+++ b/audio/out/ao_null.c
@@ -148,7 +148,8 @@ static int get_space(struct ao *ao)
struct priv *priv = ao->priv;
drain(ao);
- return priv->buffersize - priv->latency - priv->buffered;
+ int samples = priv->buffersize - priv->latency - priv->buffered;
+ return samples / priv->outburst * priv->outburst;
}
static int play(struct ao *ao, void **data, int samples, int flags)
diff --git a/audio/out/ao_sndio.c b/audio/out/ao_sndio.c
index 457da588a1..c75027dffc 100644
--- a/audio/out/ao_sndio.c
+++ b/audio/out/ao_sndio.c
@@ -273,7 +273,8 @@ static int get_space(struct ao *ao)
; /* nothing */
sio_revents(p->hdl, p->pfd);
- return (p->par.bufsz * p->par.pchan * p->par.bps - p->delay) / ao->sstride;
+ int samples = (p->par.bufsz * p->par.pchan * p->par.bps - p->delay) / ao->sstride;
+ return samples / p->par.round * p->par.round;
}
/*