From 4b2f81a36f49c85b0c20f81a5d46b1059f493796 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 6 Oct 2014 21:46:44 +0200 Subject: ao_pulse: don't use pa_format_info_to_sample_spec() This function is available starting with PulseAudio 2.0, while we only require 1.0. This broke compilation on Ubuntu 12.04.5 LTS. Use our own function to calculate the buffer size, which is actually simpler and needs slightly less code. Hopefully fixes #1154. CC: @mpv-player/stable --- audio/out/ao_pulse.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c index edbb009729..cadd032e58 100644 --- a/audio/out/ao_pulse.c +++ b/audio/out/ao_pulse.c @@ -381,20 +381,15 @@ static int init(struct ao *ao) pa_proplist_free(proplist); proplist = NULL; - pa_sample_spec ss; - pa_channel_map map2; - - if (pa_format_info_to_sample_spec(format, &ss, &map2) < 0) - goto unlock_and_fail; - pa_stream_set_state_callback(priv->stream, stream_state_cb, ao); pa_stream_set_write_callback(priv->stream, stream_request_cb, ao); pa_stream_set_latency_update_callback(priv->stream, stream_latency_update_cb, ao); + int buf_size = af_fmt_seconds_to_bytes(ao->format, priv->cfg_buffer / 1000.0, + ao->channels.num, ao->samplerate); pa_buffer_attr bufattr = { .maxlength = -1, - .tlength = priv->cfg_buffer > 0 ? - pa_usec_to_bytes(priv->cfg_buffer * 1000, &ss) : (uint32_t)-1, + .tlength = buf_size > 0 ? buf_size : (uint32_t)-1, .prebuf = -1, .minreq = -1, .fragsize = -1, @@ -733,7 +728,7 @@ const struct ao_driver audio_out_pulse = { .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})), + OPT_CHOICE_OR_INT("buffer", cfg_buffer, 0, 1, 2000, ({"native", 0})), OPT_FLAG("latency-hacks", cfg_latency_hacks, 0), {0} }, -- cgit v1.2.3