mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
Rework module-combine to work with glitch-free core; add new max_request field to pa_sink
This commit is contained in:
parent
1420e1d1b5
commit
add6c0361a
17 changed files with 1084 additions and 511 deletions
|
|
@ -600,6 +600,8 @@ static int update_sw_params(struct userdata *u) {
|
|||
return err;
|
||||
}
|
||||
|
||||
pa_sink_set_max_request(u->sink, u->hwbuf_size - u->hwbuf_unused_frames * u->frame_size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1316,6 +1318,7 @@ int pa__init(pa_module*m) {
|
|||
fix_tsched_watermark(u);
|
||||
|
||||
u->sink->thread_info.max_rewind = use_tsched ? u->hwbuf_size : 0;
|
||||
u->sink->thread_info.max_request = u->hwbuf_size;
|
||||
|
||||
pa_sink_set_latency_range(u->sink,
|
||||
!use_tsched ? pa_bytes_to_usec(u->hwbuf_size, &ss) : (pa_usec_t) -1,
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -260,13 +260,39 @@ static void sink_input_update_max_rewind_cb(pa_sink_input *i, size_t nbytes) {
|
|||
pa_sink_input_assert_ref(i);
|
||||
pa_assert_se(u = i->userdata);
|
||||
|
||||
if (!u->sink || !PA_SINK_IS_OPENED(u->sink->thread_info.state))
|
||||
if (!u->sink)
|
||||
return;
|
||||
|
||||
pa_memblockq_set_maxrewind(u->memblockq, nbytes);
|
||||
pa_sink_set_max_rewind(u->sink, nbytes);
|
||||
}
|
||||
|
||||
/* Called from I/O thread context */
|
||||
static void sink_input_update_max_request_cb(pa_sink_input *i, size_t nbytes) {
|
||||
struct userdata *u;
|
||||
|
||||
pa_sink_input_assert_ref(i);
|
||||
pa_assert_se(u = i->userdata);
|
||||
|
||||
if (!u->sink)
|
||||
return;
|
||||
|
||||
pa_sink_set_max_request(u->sink, nbytes);
|
||||
}
|
||||
|
||||
/* Called from I/O thread context */
|
||||
static void sink_input_update_sink_latency_range_cb(pa_sink_input *i) {
|
||||
struct userdata *u;
|
||||
|
||||
pa_sink_input_assert_ref(i);
|
||||
pa_assert_se(u = i->userdata);
|
||||
|
||||
if (!u->sink)
|
||||
return;
|
||||
|
||||
pa_sink_update_latency_range(u->sink, i->sink->thread_info.min_latency, i->sink->thread_info.max_latency);
|
||||
}
|
||||
|
||||
/* Called from I/O thread context */
|
||||
static void sink_input_detach_cb(pa_sink_input *i) {
|
||||
struct userdata *u;
|
||||
|
|
@ -274,7 +300,7 @@ static void sink_input_detach_cb(pa_sink_input *i) {
|
|||
pa_sink_input_assert_ref(i);
|
||||
pa_assert_se(u = i->userdata);
|
||||
|
||||
if (!u->sink || !PA_SINK_IS_OPENED(u->sink->thread_info.state))
|
||||
if (!u->sink)
|
||||
return;
|
||||
|
||||
pa_sink_detach_within_thread(u->sink);
|
||||
|
|
@ -289,14 +315,14 @@ static void sink_input_attach_cb(pa_sink_input *i) {
|
|||
pa_sink_input_assert_ref(i);
|
||||
pa_assert_se(u = i->userdata);
|
||||
|
||||
if (!u->sink || !PA_SINK_IS_OPENED(u->sink->thread_info.state))
|
||||
if (!u->sink)
|
||||
return;
|
||||
|
||||
pa_sink_set_asyncmsgq(u->sink, i->sink->asyncmsgq);
|
||||
pa_sink_set_rtpoll(u->sink, i->sink->rtpoll);
|
||||
pa_sink_attach_within_thread(u->sink);
|
||||
|
||||
pa_sink_set_latency_range(u->sink, u->master->min_latency, u->master->max_latency);
|
||||
pa_sink_set_latency_range(u->sink, u->master->thread_info.min_latency, u->master->thread_info.max_latency);
|
||||
}
|
||||
|
||||
/* Called from main context */
|
||||
|
|
@ -705,6 +731,8 @@ int pa__init(pa_module*m) {
|
|||
u->sink_input->pop = sink_input_pop_cb;
|
||||
u->sink_input->process_rewind = sink_input_process_rewind_cb;
|
||||
u->sink_input->update_max_rewind = sink_input_update_max_rewind_cb;
|
||||
u->sink_input->update_max_request = sink_input_update_max_request_cb;
|
||||
u->sink_input->update_sink_latency_range = sink_input_update_sink_latency_range_cb;
|
||||
u->sink_input->kill = sink_input_kill_cb;
|
||||
u->sink_input->attach = sink_input_attach_cb;
|
||||
u->sink_input->detach = sink_input_detach_cb;
|
||||
|
|
|
|||
|
|
@ -155,34 +155,32 @@ static void process_rewind(struct userdata *u, pa_usec_t now) {
|
|||
}
|
||||
|
||||
static void process_render(struct userdata *u, pa_usec_t now) {
|
||||
size_t nbytes;
|
||||
size_t ate = 0;
|
||||
|
||||
pa_assert(u);
|
||||
|
||||
/* This is the configured latency. Sink inputs connected to us
|
||||
might not have a single frame more than this value queued. Hence:
|
||||
at maximum read this many bytes from the sink inputs. */
|
||||
|
||||
nbytes = pa_usec_to_bytes(u->block_usec, &u->sink->sample_spec);
|
||||
might not have a single frame more than the maxrequest value
|
||||
queed. Hence: at maximum read this many bytes from the sink
|
||||
inputs. */
|
||||
|
||||
/* Fill the buffer up the the latency size */
|
||||
while (u->timestamp < now + u->block_usec) {
|
||||
pa_memchunk chunk;
|
||||
|
||||
pa_sink_render(u->sink, nbytes, &chunk);
|
||||
pa_sink_render(u->sink, u->sink->thread_info.max_request, &chunk);
|
||||
pa_memblock_unref(chunk.memblock);
|
||||
|
||||
pa_log_debug("Ate %lu bytes.", (unsigned long) chunk.length);
|
||||
/* pa_log_debug("Ate %lu bytes.", (unsigned long) chunk.length); */
|
||||
u->timestamp += pa_bytes_to_usec(chunk.length, &u->sink->sample_spec);
|
||||
|
||||
ate += chunk.length;
|
||||
|
||||
if (ate >= nbytes)
|
||||
if (ate >= u->sink->thread_info.max_request)
|
||||
break;
|
||||
}
|
||||
|
||||
pa_log_debug("Ate in sum %lu bytes (of %lu)", (unsigned long) ate, (unsigned long) nbytes);
|
||||
/* pa_log_debug("Ate in sum %lu bytes (of %lu)", (unsigned long) ate, (unsigned long) nbytes); */
|
||||
}
|
||||
|
||||
static void thread_func(void *userdata) {
|
||||
|
|
@ -201,7 +199,7 @@ static void thread_func(void *userdata) {
|
|||
int ret;
|
||||
|
||||
/* Render some data and drop it immediately */
|
||||
if (u->sink->thread_info.state == PA_SINK_RUNNING) {
|
||||
if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
|
||||
pa_usec_t now;
|
||||
|
||||
now = pa_rtclock_usec();
|
||||
|
|
@ -254,10 +252,9 @@ int pa__init(pa_module*m) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
u = pa_xnew0(struct userdata, 1);
|
||||
m->userdata = u = pa_xnew0(struct userdata, 1);
|
||||
u->core = m->core;
|
||||
u->module = m;
|
||||
m->userdata = u;
|
||||
u->rtpoll = pa_rtpoll_new();
|
||||
pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
|
||||
|
||||
|
|
@ -268,6 +265,7 @@ int pa__init(pa_module*m) {
|
|||
pa_sink_new_data_set_sample_spec(&data, &ss);
|
||||
pa_sink_new_data_set_channel_map(&data, &map);
|
||||
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_DESCRIPTION, pa_modargs_get_value(ma, "description", "Null Output"));
|
||||
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_CLASS, "abstract");
|
||||
|
||||
u->sink = pa_sink_new(m->core, &data, PA_SINK_LATENCY);
|
||||
pa_sink_new_data_done(&data);
|
||||
|
|
@ -285,9 +283,11 @@ int pa__init(pa_module*m) {
|
|||
pa_sink_set_rtpoll(u->sink, u->rtpoll);
|
||||
|
||||
pa_sink_set_latency_range(u->sink, (pa_usec_t) -1, MAX_LATENCY_USEC);
|
||||
u->block_usec = u->sink->max_latency;
|
||||
u->block_usec = u->sink->thread_info.max_latency;
|
||||
|
||||
u->sink->thread_info.max_rewind = pa_usec_to_bytes(u->block_usec, &u->sink->sample_spec);
|
||||
u->sink->thread_info.max_rewind =
|
||||
u->sink->thread_info.max_request =
|
||||
pa_usec_to_bytes(u->block_usec, &u->sink->sample_spec);
|
||||
|
||||
if (!(u->thread = pa_thread_new(thread_func, u))) {
|
||||
pa_log("Failed to create thread.");
|
||||
|
|
|
|||
|
|
@ -1366,6 +1366,8 @@ int pa__init(pa_module*m) {
|
|||
pa_sink_set_rtpoll(u->sink, u->rtpoll);
|
||||
u->sink->refresh_volume = TRUE;
|
||||
|
||||
u->sink->thread_info.max_request = u->out_hwbuf_size;
|
||||
|
||||
if (use_mmap)
|
||||
u->out_mmap_memblocks = pa_xnew0(pa_memblock*, u->out_nfrags);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,12 +179,38 @@ static void sink_input_update_max_rewind_cb(pa_sink_input *i, size_t nbytes) {
|
|||
pa_sink_input_assert_ref(i);
|
||||
pa_assert_se(u = i->userdata);
|
||||
|
||||
if (!u->sink || !PA_SINK_IS_OPENED(u->sink->thread_info.state))
|
||||
if (!u->sink)
|
||||
return;
|
||||
|
||||
pa_sink_set_max_rewind(u->sink, nbytes);
|
||||
}
|
||||
|
||||
/* Called from I/O thread context */
|
||||
static void sink_input_update_max_request_cb(pa_sink_input *i, size_t nbytes) {
|
||||
struct userdata *u;
|
||||
|
||||
pa_sink_input_assert_ref(i);
|
||||
pa_assert_se(u = i->userdata);
|
||||
|
||||
if (!u->sink)
|
||||
return;
|
||||
|
||||
pa_sink_set_max_request(u->sink, nbytes);
|
||||
}
|
||||
|
||||
/* Called from I/O thread context */
|
||||
static void sink_input_update_sink_latency_range_cb(pa_sink_input *i) {
|
||||
struct userdata *u;
|
||||
|
||||
pa_sink_input_assert_ref(i);
|
||||
pa_assert_se(u = i->userdata);
|
||||
|
||||
if (!u->sink)
|
||||
return;
|
||||
|
||||
pa_sink_update_latency_range(u->sink, i->sink->thread_info.min_latency, i->sink->thread_info.max_latency);
|
||||
}
|
||||
|
||||
/* Called from I/O thread context */
|
||||
static void sink_input_detach_cb(pa_sink_input *i) {
|
||||
struct userdata *u;
|
||||
|
|
@ -192,7 +218,7 @@ static void sink_input_detach_cb(pa_sink_input *i) {
|
|||
pa_sink_input_assert_ref(i);
|
||||
pa_assert_se(u = i->userdata);
|
||||
|
||||
if (!u->sink || !PA_SINK_IS_OPENED(u->sink->thread_info.state))
|
||||
if (!u->sink)
|
||||
return;
|
||||
|
||||
pa_sink_detach_within_thread(u->sink);
|
||||
|
|
@ -207,14 +233,14 @@ static void sink_input_attach_cb(pa_sink_input *i) {
|
|||
pa_sink_input_assert_ref(i);
|
||||
pa_assert_se(u = i->userdata);
|
||||
|
||||
if (!u->sink || !PA_SINK_IS_OPENED(u->sink->thread_info.state))
|
||||
if (!u->sink)
|
||||
return;
|
||||
|
||||
pa_sink_set_asyncmsgq(u->sink, i->sink->asyncmsgq);
|
||||
pa_sink_set_rtpoll(u->sink, i->sink->rtpoll);
|
||||
pa_sink_attach_within_thread(u->sink);
|
||||
|
||||
pa_sink_set_latency_range(u->sink, u->master->min_latency, u->master->max_latency);
|
||||
pa_sink_set_latency_range(u->sink, u->master->thread_info.min_latency, u->master->thread_info.max_latency);
|
||||
}
|
||||
|
||||
/* Called from main context */
|
||||
|
|
@ -357,9 +383,11 @@ int pa__init(pa_module*m) {
|
|||
u->sink_input->pop = sink_input_pop_cb;
|
||||
u->sink_input->process_rewind = sink_input_process_rewind_cb;
|
||||
u->sink_input->update_max_rewind = sink_input_update_max_rewind_cb;
|
||||
u->sink_input->kill = sink_input_kill_cb;
|
||||
u->sink_input->update_max_request = sink_input_update_max_request_cb;
|
||||
u->sink_input->update_sink_latency_range = sink_input_update_sink_latency_range_cb;
|
||||
u->sink_input->attach = sink_input_attach_cb;
|
||||
u->sink_input->detach = sink_input_detach_cb;
|
||||
u->sink_input->kill = sink_input_kill_cb;
|
||||
u->sink_input->state_change = sink_input_state_change_cb;
|
||||
u->sink_input->userdata = u;
|
||||
|
||||
|
|
|
|||
|
|
@ -1699,8 +1699,8 @@ int pa__init(pa_module*m) {
|
|||
}
|
||||
|
||||
m->userdata = u = pa_xnew0(struct userdata, 1);
|
||||
u->module = m;
|
||||
u->core = m->core;
|
||||
u->module = m;
|
||||
u->client = NULL;
|
||||
u->pdispatch = NULL;
|
||||
u->pstream = NULL;
|
||||
|
|
@ -1779,7 +1779,7 @@ int pa__init(pa_module*m) {
|
|||
u->sink->set_volume = sink_set_volume;
|
||||
u->sink->set_mute = sink_set_mute;
|
||||
|
||||
u->sink->refresh_volume = u->sink->refresh_mute = FALSE;
|
||||
u->sink->refresh_volume = u->sink->refresh_muted = FALSE;
|
||||
|
||||
pa_sink_set_latency_range(u->sink, MIN_NETWORK_LATENCY_USEC, 0);
|
||||
|
||||
|
|
@ -1812,8 +1812,8 @@ int pa__init(pa_module*m) {
|
|||
}
|
||||
|
||||
u->source->parent.process_msg = source_process_msg;
|
||||
u->source->userdata = u;
|
||||
u->source->set_state = source_set_state;
|
||||
u->source->userdata = u;
|
||||
|
||||
pa_source_set_latency_range(u->source, MIN_NETWORK_LATENCY_USEC, 0);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue