From a220a3aae6975d1a6c5e0b1325ee07040b0f701b Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 7 Jan 2014 23:50:22 +0100 Subject: ao_pulse: add suboption to control buffer size --- DOCS/man/en/ao.rst | 6 ++++++ audio/out/ao_pulse.c | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/DOCS/man/en/ao.rst b/DOCS/man/en/ao.rst index df2c33e119..ef28c0771c 100644 --- a/DOCS/man/en/ao.rst +++ b/DOCS/man/en/ao.rst @@ -126,6 +126,12 @@ Available audio output drivers are: string uses a local connection, "localhost" uses network transfer (most likely not what you want). + ``buffer=<1-2000|native>`` + Set the audio buffer size in milliseconds. A higher value buffers + more data, and has a lower probability of buffer underruns. A smaller + value makes the audio stream react faster, e.g. to playback speed + changes. Default: 1000. + ``portaudio`` PortAudio audio output driver. This works on all platforms, and has extensive MS Windows support. diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c index f3bce40574..a573738deb 100644 --- a/audio/out/ao_pulse.c +++ b/audio/out/ao_pulse.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -55,6 +56,7 @@ struct priv { char *cfg_host; char *cfg_sink; + int cfg_buffer; }; #define GENERIC_ERR_MSG(str) \ @@ -328,7 +330,8 @@ static int init(struct ao *ao) stream_latency_update_cb, ao); pa_buffer_attr bufattr = { .maxlength = -1, - .tlength = pa_usec_to_bytes(1000000, &ss), + .tlength = priv->cfg_buffer > 0 ? + pa_usec_to_bytes(priv->cfg_buffer * 1000, &ss) : (uint32_t)-1, .prebuf = -1, .minreq = -1, .fragsize = -1, @@ -617,9 +620,13 @@ const struct ao_driver audio_out_pulse = { .pause = pause, .resume = resume, .priv_size = sizeof(struct priv), + .priv_defaults = &(const struct priv) { + .cfg_buffer = 1000, + }, .options = (const struct m_option[]) { OPT_STRING("host", cfg_host, 0), OPT_STRING("sink", cfg_sink, 0), + OPT_CHOICE_OR_INT("buffer", cfg_buffer, 0, 1, 2000, ({"native", -1})), {0} }, }; -- cgit v1.2.3