mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-16 06:59:55 -05:00
set request/rewind sizes only via accessor functions
This commit is contained in:
parent
aa92ff408c
commit
2f9a784167
9 changed files with 52 additions and 17 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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.");
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue