diff options
-rw-r--r-- | src/modules/alsa/alsa-sink.c | 2 | ||||
-rw-r--r-- | src/modules/module-combine.c | 2 | ||||
-rw-r--r-- | src/modules/module-ladspa-sink.c | 4 | ||||
-rw-r--r-- | src/modules/module-null-sink.c | 9 | ||||
-rw-r--r-- | src/modules/module-remap-sink.c | 4 | ||||
-rw-r--r-- | src/modules/module-solaris.c | 4 | ||||
-rw-r--r-- | src/modules/oss/module-oss.c | 2 | ||||
-rw-r--r-- | src/pulsecore/sink.c | 34 | ||||
-rw-r--r-- | src/pulsecore/sink.h | 8 |
9 files changed, 52 insertions, 17 deletions
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index a770f0f57..bcca57d4c 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -756,7 +756,7 @@ static int update_sw_params(struct userdata *u) { return err; } - pa_sink_set_max_request(u->sink, u->hwbuf_size - u->hwbuf_unused); + pa_sink_set_max_request_within_thread(u->sink, u->hwbuf_size - u->hwbuf_unused); return 0; } diff --git a/src/modules/module-combine.c b/src/modules/module-combine.c index 4b2d6f9b3..f72223d96 100644 --- a/src/modules/module-combine.c +++ b/src/modules/module-combine.c @@ -649,7 +649,7 @@ static void update_max_request(struct userdata *u) { if (max_request <= 0) max_request = pa_usec_to_bytes(u->block_usec, &u->sink->sample_spec); - pa_sink_set_max_request(u->sink, max_request); + pa_sink_set_max_request_within_thread(u->sink, max_request); } /* Called from thread context of the io thread */ diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c index 54a4e6cb3..81546ff4a 100644 --- a/src/modules/module-ladspa-sink.c +++ b/src/modules/module-ladspa-sink.c @@ -264,7 +264,7 @@ static void sink_input_update_max_rewind_cb(pa_sink_input *i, size_t nbytes) { return; pa_memblockq_set_maxrewind(u->memblockq, nbytes); - pa_sink_set_max_rewind(u->sink, nbytes); + pa_sink_set_max_rewind_within_thread(u->sink, nbytes); } /* Called from I/O thread context */ @@ -277,7 +277,7 @@ static void sink_input_update_max_request_cb(pa_sink_input *i, size_t nbytes) { if (!u->sink || !PA_SINK_IS_LINKED(u->sink->thread_info.state)) return; - pa_sink_set_max_request(u->sink, nbytes); + pa_sink_set_max_request_within_thread(u->sink, nbytes); } /* Called from I/O thread context */ diff --git a/src/modules/module-null-sink.c b/src/modules/module-null-sink.c index 183d4b2e0..c8edd0c77 100644 --- a/src/modules/module-null-sink.c +++ b/src/modules/module-null-sink.c @@ -253,6 +253,7 @@ int pa__init(pa_module*m) { pa_channel_map map; pa_modargs *ma = NULL; pa_sink_new_data data; + size_t nbytes; pa_assert(m); @@ -299,11 +300,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->thread_info.max_latency; - u->sink->thread_info.max_rewind = - u->sink->thread_info.max_request = - pa_usec_to_bytes(u->block_usec, &u->sink->sample_spec); + u->block_usec = u->sink->thread_info.max_latency; + 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); if (!(u->thread = pa_thread_new(thread_func, u))) { pa_log("Failed to create thread."); diff --git a/src/modules/module-remap-sink.c b/src/modules/module-remap-sink.c index 7ab81b636..8c43a72e6 100644 --- a/src/modules/module-remap-sink.c +++ b/src/modules/module-remap-sink.c @@ -179,7 +179,7 @@ static void sink_input_update_max_rewind_cb(pa_sink_input *i, size_t nbytes) { if (!u->sink || !PA_SINK_IS_LINKED(u->sink->thread_info.state)) return; - pa_sink_set_max_rewind(u->sink, nbytes); + pa_sink_set_max_rewind_within_thread(u->sink, nbytes); } /* Called from I/O thread context */ @@ -192,7 +192,7 @@ static void sink_input_update_max_request_cb(pa_sink_input *i, size_t nbytes) { if (!u->sink || !PA_SINK_IS_LINKED(u->sink->thread_info.state)) return; - pa_sink_set_max_request(u->sink, nbytes); + pa_sink_set_max_request_within_thread(u->sink, nbytes); } /* Called from I/O thread context */ diff --git a/src/modules/module-solaris.c b/src/modules/module-solaris.c index 995b3c631..e7dfc05ef 100644 --- a/src/modules/module-solaris.c +++ b/src/modules/module-solaris.c @@ -653,7 +653,7 @@ static void thread_func(void *userdata) { u->buffer_size = u->buffer_size * 18 / 25; u->buffer_size -= u->buffer_size % u->frame_size; u->buffer_size = PA_MAX(u->buffer_size, (int32_t)MIN_BUFFER_SIZE); - pa_sink_set_max_request(u->sink, u->buffer_size); + pa_sink_set_max_request_within_thread(u->sink, u->buffer_size); pa_log("EAGAIN. Buffer size is now %u bytes (%llu buffered)", u->buffer_size, buffered_bytes); break; default: @@ -946,7 +946,7 @@ int pa__init(pa_module *m) { u->sink->set_mute = sink_set_mute; u->sink->refresh_volume = u->sink->refresh_muted = TRUE; - u->sink->thread_info.max_request = u->buffer_size; + pa_sink_set_max_request(u->sink, u->buffer_size); u->min_request = pa_usec_to_bytes(PA_USEC_PER_SEC / MAX_RENDER_HZ, &ss); } else u->sink = NULL; diff --git a/src/modules/oss/module-oss.c b/src/modules/oss/module-oss.c index 7bce8d006..f67f47e1b 100644 --- a/src/modules/oss/module-oss.c +++ b/src/modules/oss/module-oss.c @@ -1388,7 +1388,7 @@ 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; + pa_sink_set_max_request(u->sink, u->out_hwbuf_size); if (use_mmap) u->out_mmap_memblocks = pa_xnew0(pa_memblock*, u->out_nfrags); diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 7c43a8e97..308a4e578 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -1616,6 +1616,16 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse *((size_t*) userdata) = s->thread_info.max_request; return 0; + case PA_SINK_MESSAGE_SET_MAX_REWIND: + + pa_sink_set_max_rewind_within_thread(s, (size_t) offset); + return 0; + + case PA_SINK_MESSAGE_SET_MAX_REQUEST: + + pa_sink_set_max_request_within_thread(s, (size_t) offset); + return 0; + case PA_SINK_MESSAGE_GET_LATENCY: case PA_SINK_MESSAGE_MAX: ; @@ -1767,7 +1777,7 @@ pa_usec_t pa_sink_get_requested_latency(pa_sink *s) { } /* Called from IO as well as the main thread -- the latter only before the IO thread started up */ -void pa_sink_set_max_rewind(pa_sink *s, size_t max_rewind) { +void pa_sink_set_max_rewind_within_thread(pa_sink *s, size_t max_rewind) { pa_sink_input *i; void *state = NULL; @@ -1787,8 +1797,18 @@ void pa_sink_set_max_rewind(pa_sink *s, size_t max_rewind) { pa_source_set_max_rewind(s->monitor_source, s->thread_info.max_rewind); } +/* Called from main thread */ +void pa_sink_set_max_rewind(pa_sink *s, size_t max_rewind) { + pa_sink_assert_ref(s); + + if (PA_SINK_IS_LINKED(s->state)) + pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_SET_MAX_REWIND, NULL, max_rewind, NULL) == 0); + else + pa_sink_set_max_rewind_within_thread(s, max_rewind); +} + /* Called from IO as well as the main thread -- the latter only before the IO thread started up */ -void pa_sink_set_max_request(pa_sink *s, size_t max_request) { +void pa_sink_set_max_request_within_thread(pa_sink *s, size_t max_request) { void *state = NULL; pa_sink_assert_ref(s); @@ -1806,6 +1826,16 @@ void pa_sink_set_max_request(pa_sink *s, size_t max_request) { } } +/* Called from main thread */ +void pa_sink_set_max_request(pa_sink *s, size_t max_request) { + pa_sink_assert_ref(s); + + if (PA_SINK_IS_LINKED(s->state)) + pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_SET_MAX_REQUEST, NULL, max_request, NULL) == 0); + else + pa_sink_set_max_request_within_thread(s, max_request); +} + /* Called from IO thread */ void pa_sink_invalidate_requested_latency(pa_sink *s) { pa_sink_input *i; diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h index 260b2722c..f3f254278 100644 --- a/src/pulsecore/sink.h +++ b/src/pulsecore/sink.h @@ -172,6 +172,8 @@ typedef enum pa_sink_message { PA_SINK_MESSAGE_GET_LATENCY_RANGE, PA_SINK_MESSAGE_GET_MAX_REWIND, PA_SINK_MESSAGE_GET_MAX_REQUEST, + PA_SINK_MESSAGE_SET_MAX_REWIND, + PA_SINK_MESSAGE_SET_MAX_REQUEST, PA_SINK_MESSAGE_MAX } pa_sink_message_t; @@ -217,6 +219,8 @@ void pa_sink_unlink(pa_sink* s); void pa_sink_set_description(pa_sink *s, const char *description); void pa_sink_set_asyncmsgq(pa_sink *s, pa_asyncmsgq *q); void pa_sink_set_rtpoll(pa_sink *s, pa_rtpoll *p); +void pa_sink_set_max_rewind(pa_sink *s, size_t max_rewind); +void pa_sink_set_max_request(pa_sink *s, size_t max_request); void pa_sink_set_latency_range(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency); @@ -280,8 +284,8 @@ void pa_sink_detach_within_thread(pa_sink *s); pa_usec_t pa_sink_get_requested_latency_within_thread(pa_sink *s); -void pa_sink_set_max_rewind(pa_sink *s, size_t max_rewind); -void pa_sink_set_max_request(pa_sink *s, size_t max_request); +void pa_sink_set_max_rewind_within_thread(pa_sink *s, size_t max_rewind); +void pa_sink_set_max_request_within_thread(pa_sink *s, size_t max_request); void pa_sink_set_latency_range_within_thread(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency); |