Browse Source

libpulseaudio: make latency configurable

android-5
Tom Yan 7 years ago
committed by Fredrik Fornwall
parent
commit
842fd3a609
  1. 13
      packages/libpulseaudio/module-sles-sink.c

13
packages/libpulseaudio/module-sles-sink.c

@ -70,6 +70,7 @@ PA_MODULE_USAGE(
"sink_name=<name for the sink> " "sink_name=<name for the sink> "
"sink_properties=<properties for the sink> " "sink_properties=<properties for the sink> "
"rate=<sampling rate> " "rate=<sampling rate> "
"latency=<buffer length> "
); );
#define DEFAULT_SINK_NAME "OpenSL ES sink" #define DEFAULT_SINK_NAME "OpenSL ES sink"
@ -104,6 +105,7 @@ static const char* const valid_modargs[] = {
"sink_name", "sink_name",
"sink_properties", "sink_properties",
"rate", "rate",
"latency",
NULL NULL
}; };
@ -282,6 +284,7 @@ int pa__init(pa_module*m) {
pa_modargs *ma = NULL; pa_modargs *ma = NULL;
pa_sink_new_data data; pa_sink_new_data data;
size_t nbytes; size_t nbytes;
uint32_t latency = 0;
pa_assert(m); 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_asyncmsgq(u->sink, u->thread_mq.inq);
pa_sink_set_rtpoll(u->sink, u->rtpoll); 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); nbytes = pa_usec_to_bytes(u->block_usec, &u->sink->sample_spec);
pa_sink_set_max_rewind(u->sink, nbytes); pa_sink_set_max_rewind(u->sink, nbytes);
pa_sink_set_max_request(u->sink, nbytes); pa_sink_set_max_request(u->sink, nbytes);
@ -350,8 +359,6 @@ int pa__init(pa_module*m) {
goto fail; goto fail;
} }
pa_sink_set_fixed_latency(u->sink, u->block_usec);
pa_sink_put(u->sink); pa_sink_put(u->sink);
pa_modargs_free(ma); pa_modargs_free(ma);

Loading…
Cancel
Save