From 36c4ffb4bfcb19c9a4e3472a57e3b81f59481303 Mon Sep 17 00:00:00 2001 From: Tom Yan Date: Thu, 26 Jul 2018 06:17:26 +0800 Subject: [PATCH] libpulseaudio: make latency configurable --- packages/libpulseaudio/module-sles-sink.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/libpulseaudio/module-sles-sink.c b/packages/libpulseaudio/module-sles-sink.c index ed26e2fab..0aef01f50 100644 --- a/packages/libpulseaudio/module-sles-sink.c +++ b/packages/libpulseaudio/module-sles-sink.c @@ -70,6 +70,7 @@ PA_MODULE_USAGE( "sink_name= " "sink_properties= " "rate= " + "latency= " ); #define DEFAULT_SINK_NAME "OpenSL ES sink" @@ -104,6 +105,7 @@ static const char* const valid_modargs[] = { "sink_name", "sink_properties", "rate", + "latency", NULL }; @@ -282,6 +284,7 @@ int pa__init(pa_module*m) { pa_modargs *ma = NULL; pa_sink_new_data data; size_t nbytes; + uint32_t latency = 0; pa_assert(m); @@ -340,7 +343,13 @@ int pa__init(pa_module*m) { pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq); pa_sink_set_rtpoll(u->sink, u->rtpoll); - u->block_usec = BLOCK_USEC; + pa_modargs_get_value_u32(ma, "latency", &latency); + if (latency) + u->block_usec = latency * PA_USEC_PER_MSEC; + else + u->block_usec = BLOCK_USEC; + pa_sink_set_fixed_latency(u->sink, u->block_usec); + nbytes = pa_usec_to_bytes(u->block_usec, &u->sink->sample_spec); pa_sink_set_max_rewind(u->sink, nbytes); pa_sink_set_max_request(u->sink, nbytes); @@ -350,8 +359,6 @@ int pa__init(pa_module*m) { goto fail; } - pa_sink_set_fixed_latency(u->sink, u->block_usec); - pa_sink_put(u->sink); pa_modargs_free(ma);