summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_pulse.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-10 23:24:21 +0100
committerwm4 <wm4@nowhere>2013-11-12 23:27:51 +0100
commit380fc765e4ad4e3ff828c9b0bd4a565ea2ba79ed (patch)
tree6cc32f550b219c903a932692f477c8b8b4f8cfc2 /audio/out/ao_pulse.c
parentd115fb3b0eed9145817a20bc0070590f7428bddd (diff)
downloadmpv-380fc765e4ad4e3ff828c9b0bd4a565ea2ba79ed.tar.bz2
mpv-380fc765e4ad4e3ff828c9b0bd4a565ea2ba79ed.tar.xz
audio/out: prepare for non-interleaved audio
This comes with two internal AO API changes: 1. ao_driver.play now can take non-interleaved audio. For this purpose, the data pointer is changed to void **data, where data[0] corresponds to the pointer in the old API. Also, the len argument as well as the return value are now in samples, not bytes. "Sample" in this context means the unit of the smallest possible audio frame, i.e. sample_size * channels. 2. ao_driver.get_space now returns samples instead of bytes. (Similar to the play function.) Change all AOs to use the new API. The AO API as exposed to the rest of the player still uses the old API. It's emulated in ao.c. This is purely to split the commits changing all AOs and the commits adding actual support for outputting N-I audio.
Diffstat (limited to 'audio/out/ao_pulse.c')
-rw-r--r--audio/out/ao_pulse.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c
index 1d7fcdd382..f1800f279c 100644
--- a/audio/out/ao_pulse.c
+++ b/audio/out/ao_pulse.c
@@ -377,14 +377,14 @@ static void cork(struct ao *ao, bool pause)
}
// Play the specified data to the pulseaudio server
-static int play(struct ao *ao, void *data, int len, int flags)
+static int play(struct ao *ao, void **data, int samples, int flags)
{
struct priv *priv = ao->priv;
pa_threaded_mainloop_lock(priv->mainloop);
- if (pa_stream_write(priv->stream, data, len, NULL, 0,
+ if (pa_stream_write(priv->stream, data[0], samples * ao->sstride, NULL, 0,
PA_SEEK_RELATIVE) < 0) {
GENERIC_ERR_MSG("pa_stream_write() failed");
- len = -1;
+ samples = -1;
}
if (flags & AOPLAY_FINAL_CHUNK) {
// Force start in case the stream was too short for prebuf
@@ -392,7 +392,7 @@ static int play(struct ao *ao, void *data, int len, int flags)
pa_operation_unref(op);
}
pa_threaded_mainloop_unlock(priv->mainloop);
- return len;
+ return samples;
}
// Reset the audio stream, i.e. flush the playback buffer on the server side
@@ -427,14 +427,14 @@ static void resume(struct ao *ao)
cork(ao, false);
}
-// Return number of bytes that may be written to the server without blocking
+// Return number of samples that may be written to the server without blocking
static int get_space(struct ao *ao)
{
struct priv *priv = ao->priv;
pa_threaded_mainloop_lock(priv->mainloop);
size_t space = pa_stream_writable_size(priv->stream);
pa_threaded_mainloop_unlock(priv->mainloop);
- return space;
+ return space / ao->sstride;
}
// Return the current latency in seconds