mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-16 08:56:40 -05:00
simplify latency range by not allowing stored 'wildcard' ranges anymore
This commit is contained in:
parent
e6be9481dc
commit
aa92ff408c
8 changed files with 42 additions and 27 deletions
|
|
@ -240,7 +240,7 @@ static void adjust_after_underrun(struct userdata *u) {
|
||||||
pa_log_notice("Increasing minimal latency to %0.2f ms",
|
pa_log_notice("Increasing minimal latency to %0.2f ms",
|
||||||
(double) new_min_latency / PA_USEC_PER_MSEC);
|
(double) new_min_latency / PA_USEC_PER_MSEC);
|
||||||
|
|
||||||
pa_sink_update_latency_range(u->sink, new_min_latency, u->sink->thread_info.max_latency);
|
pa_sink_set_latency_range_within_thread(u->sink, new_min_latency, u->sink->thread_info.max_latency);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,7 @@ static void adjust_after_overrun(struct userdata *u) {
|
||||||
pa_log_notice("Increasing minimal latency to %0.2f ms",
|
pa_log_notice("Increasing minimal latency to %0.2f ms",
|
||||||
(double) new_min_latency / PA_USEC_PER_MSEC);
|
(double) new_min_latency / PA_USEC_PER_MSEC);
|
||||||
|
|
||||||
pa_source_update_latency_range(u->source, new_min_latency, u->source->thread_info.max_latency);
|
pa_source_set_latency_range_within_thread(u->source, new_min_latency, u->source->thread_info.max_latency);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -290,7 +290,7 @@ static void sink_input_update_sink_latency_range_cb(pa_sink_input *i) {
|
||||||
if (!u->sink || !PA_SINK_IS_LINKED(u->sink->thread_info.state))
|
if (!u->sink || !PA_SINK_IS_LINKED(u->sink->thread_info.state))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pa_sink_update_latency_range(u->sink, i->sink->thread_info.min_latency, i->sink->thread_info.max_latency);
|
pa_sink_set_latency_range_within_thread(u->sink, i->sink->thread_info.min_latency, i->sink->thread_info.max_latency);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called from I/O thread context */
|
/* Called from I/O thread context */
|
||||||
|
|
@ -322,7 +322,7 @@ static void sink_input_attach_cb(pa_sink_input *i) {
|
||||||
pa_sink_set_rtpoll(u->sink, i->sink->rtpoll);
|
pa_sink_set_rtpoll(u->sink, i->sink->rtpoll);
|
||||||
pa_sink_attach_within_thread(u->sink);
|
pa_sink_attach_within_thread(u->sink);
|
||||||
|
|
||||||
pa_sink_update_latency_range(u->sink, u->master->thread_info.min_latency, u->master->thread_info.max_latency);
|
pa_sink_set_latency_range_within_thread(u->sink, u->master->thread_info.min_latency, u->master->thread_info.max_latency);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called from main context */
|
/* Called from main context */
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ static void sink_input_update_sink_latency_range_cb(pa_sink_input *i) {
|
||||||
if (!u->sink || !PA_SINK_IS_LINKED(u->sink->thread_info.state))
|
if (!u->sink || !PA_SINK_IS_LINKED(u->sink->thread_info.state))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pa_sink_update_latency_range(u->sink, i->sink->thread_info.min_latency, i->sink->thread_info.max_latency);
|
pa_sink_set_latency_range_within_thread(u->sink, i->sink->thread_info.min_latency, i->sink->thread_info.max_latency);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called from I/O thread context */
|
/* Called from I/O thread context */
|
||||||
|
|
@ -237,7 +237,7 @@ static void sink_input_attach_cb(pa_sink_input *i) {
|
||||||
pa_sink_set_rtpoll(u->sink, i->sink->rtpoll);
|
pa_sink_set_rtpoll(u->sink, i->sink->rtpoll);
|
||||||
pa_sink_attach_within_thread(u->sink);
|
pa_sink_attach_within_thread(u->sink);
|
||||||
|
|
||||||
pa_sink_update_latency_range(u->sink, u->master->thread_info.min_latency, u->master->thread_info.max_latency);
|
pa_sink_set_latency_range_within_thread(u->sink, u->master->thread_info.min_latency, u->master->thread_info.max_latency);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called from main context */
|
/* Called from main context */
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,9 @@
|
||||||
|
|
||||||
#define MAX_MIX_CHANNELS 32
|
#define MAX_MIX_CHANNELS 32
|
||||||
#define MIX_BUFFER_LENGTH (PA_PAGE_SIZE)
|
#define MIX_BUFFER_LENGTH (PA_PAGE_SIZE)
|
||||||
|
#define ABSOLUTE_MIN_LATENCY (500)
|
||||||
#define DEFAULT_MIN_LATENCY (4*PA_USEC_PER_MSEC)
|
#define DEFAULT_MIN_LATENCY (4*PA_USEC_PER_MSEC)
|
||||||
|
#define ABSOLUTE_MAX_LATENCY (10*PA_USEC_PER_SEC)
|
||||||
|
|
||||||
static PA_DEFINE_CHECK_TYPE(pa_sink, pa_msgobject);
|
static PA_DEFINE_CHECK_TYPE(pa_sink, pa_msgobject);
|
||||||
|
|
||||||
|
|
@ -231,7 +233,7 @@ pa_sink* pa_sink_new(
|
||||||
s->thread_info.requested_latency_valid = FALSE;
|
s->thread_info.requested_latency_valid = FALSE;
|
||||||
s->thread_info.requested_latency = 0;
|
s->thread_info.requested_latency = 0;
|
||||||
s->thread_info.min_latency = DEFAULT_MIN_LATENCY;
|
s->thread_info.min_latency = DEFAULT_MIN_LATENCY;
|
||||||
s->thread_info.max_latency = 0;
|
s->thread_info.max_latency = DEFAULT_MIN_LATENCY;
|
||||||
|
|
||||||
pa_assert_se(pa_idxset_put(core->sinks, s, &s->index) >= 0);
|
pa_assert_se(pa_idxset_put(core->sinks, s, &s->index) >= 0);
|
||||||
|
|
||||||
|
|
@ -343,8 +345,7 @@ void pa_sink_put(pa_sink* s) {
|
||||||
/* The following fields must be initialized properly when calling _put() */
|
/* The following fields must be initialized properly when calling _put() */
|
||||||
pa_assert(s->asyncmsgq);
|
pa_assert(s->asyncmsgq);
|
||||||
pa_assert(s->rtpoll);
|
pa_assert(s->rtpoll);
|
||||||
pa_assert(!s->thread_info.min_latency || !s->thread_info.max_latency ||
|
pa_assert(s->thread_info.min_latency <= s->thread_info.max_latency);
|
||||||
s->thread_info.min_latency <= s->thread_info.max_latency);
|
|
||||||
|
|
||||||
if (!(s->flags & PA_SINK_HW_VOLUME_CTRL)) {
|
if (!(s->flags & PA_SINK_HW_VOLUME_CTRL)) {
|
||||||
s->flags |= PA_SINK_DECIBEL_VOLUME;
|
s->flags |= PA_SINK_DECIBEL_VOLUME;
|
||||||
|
|
@ -1591,7 +1592,7 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse
|
||||||
case PA_SINK_MESSAGE_SET_LATENCY_RANGE: {
|
case PA_SINK_MESSAGE_SET_LATENCY_RANGE: {
|
||||||
pa_usec_t *r = userdata;
|
pa_usec_t *r = userdata;
|
||||||
|
|
||||||
pa_sink_update_latency_range(s, r[0], r[1]);
|
pa_sink_set_latency_range_within_thread(s, r[0], r[1]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1738,10 +1739,10 @@ pa_usec_t pa_sink_get_requested_latency_within_thread(pa_sink *s) {
|
||||||
result = monitor_latency;
|
result = monitor_latency;
|
||||||
|
|
||||||
if (result != (pa_usec_t) -1) {
|
if (result != (pa_usec_t) -1) {
|
||||||
if (s->thread_info.max_latency > 0 && result > s->thread_info.max_latency)
|
if (result > s->thread_info.max_latency)
|
||||||
result = s->thread_info.max_latency;
|
result = s->thread_info.max_latency;
|
||||||
|
|
||||||
if (s->thread_info.min_latency > 0 && result < s->thread_info.min_latency)
|
if (result < s->thread_info.min_latency)
|
||||||
result = s->thread_info.min_latency;
|
result = s->thread_info.min_latency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1835,11 +1836,16 @@ void pa_sink_set_latency_range(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_
|
||||||
if (min_latency == (pa_usec_t) -1)
|
if (min_latency == (pa_usec_t) -1)
|
||||||
min_latency = DEFAULT_MIN_LATENCY;
|
min_latency = DEFAULT_MIN_LATENCY;
|
||||||
|
|
||||||
|
if (min_latency < ABSOLUTE_MIN_LATENCY)
|
||||||
|
min_latency = ABSOLUTE_MIN_LATENCY;
|
||||||
|
|
||||||
if (max_latency == (pa_usec_t) -1)
|
if (max_latency == (pa_usec_t) -1)
|
||||||
max_latency = min_latency;
|
max_latency = min_latency;
|
||||||
|
|
||||||
pa_assert(!min_latency || !max_latency ||
|
if (max_latency > ABSOLUTE_MAX_LATENCY || max_latency <= 0)
|
||||||
min_latency <= max_latency);
|
max_latency = ABSOLUTE_MAX_LATENCY;
|
||||||
|
|
||||||
|
pa_assert(min_latency <= max_latency);
|
||||||
|
|
||||||
if (PA_SINK_IS_LINKED(s->state)) {
|
if (PA_SINK_IS_LINKED(s->state)) {
|
||||||
pa_usec_t r[2];
|
pa_usec_t r[2];
|
||||||
|
|
@ -1879,14 +1885,15 @@ void pa_sink_get_latency_range(pa_sink *s, pa_usec_t *min_latency, pa_usec_t *ma
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called from IO thread */
|
/* Called from IO thread */
|
||||||
void pa_sink_update_latency_range(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency) {
|
void pa_sink_set_latency_range_within_thread(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency) {
|
||||||
pa_sink_input *i;
|
pa_sink_input *i;
|
||||||
void *state = NULL;
|
void *state = NULL;
|
||||||
|
|
||||||
pa_sink_assert_ref(s);
|
pa_sink_assert_ref(s);
|
||||||
|
|
||||||
pa_assert(!min_latency || !max_latency ||
|
pa_assert(min_latency >= ABSOLUTE_MIN_LATENCY);
|
||||||
min_latency <= max_latency);
|
pa_assert(max_latency <= ABSOLUTE_MAX_LATENCY);
|
||||||
|
pa_assert(min_latency <= max_latency);
|
||||||
|
|
||||||
s->thread_info.min_latency = min_latency;
|
s->thread_info.min_latency = min_latency;
|
||||||
s->thread_info.max_latency = max_latency;
|
s->thread_info.max_latency = max_latency;
|
||||||
|
|
@ -1897,7 +1904,7 @@ void pa_sink_update_latency_range(pa_sink *s, pa_usec_t min_latency, pa_usec_t m
|
||||||
|
|
||||||
pa_sink_invalidate_requested_latency(s);
|
pa_sink_invalidate_requested_latency(s);
|
||||||
|
|
||||||
pa_source_update_latency_range(s->monitor_source, min_latency, max_latency);
|
pa_source_set_latency_range_within_thread(s->monitor_source, min_latency, max_latency);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called from main context */
|
/* Called from main context */
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,7 @@ 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_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_request(pa_sink *s, size_t max_request);
|
||||||
|
|
||||||
void pa_sink_update_latency_range(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency);
|
void pa_sink_set_latency_range_within_thread(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency);
|
||||||
|
|
||||||
/*** To be called exclusively by sink input drivers, from IO context */
|
/*** To be called exclusively by sink input drivers, from IO context */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,9 @@
|
||||||
|
|
||||||
#include "source.h"
|
#include "source.h"
|
||||||
|
|
||||||
|
#define ABSOLUTE_MIN_LATENCY (500)
|
||||||
#define DEFAULT_MIN_LATENCY (4*PA_USEC_PER_MSEC)
|
#define DEFAULT_MIN_LATENCY (4*PA_USEC_PER_MSEC)
|
||||||
|
#define ABSOLUTE_MAX_LATENCY (10*PA_USEC_PER_SEC)
|
||||||
|
|
||||||
static PA_DEFINE_CHECK_TYPE(pa_source, pa_msgobject);
|
static PA_DEFINE_CHECK_TYPE(pa_source, pa_msgobject);
|
||||||
|
|
||||||
|
|
@ -219,7 +221,7 @@ pa_source* pa_source_new(
|
||||||
s->thread_info.requested_latency_valid = FALSE;
|
s->thread_info.requested_latency_valid = FALSE;
|
||||||
s->thread_info.requested_latency = 0;
|
s->thread_info.requested_latency = 0;
|
||||||
s->thread_info.min_latency = DEFAULT_MIN_LATENCY;
|
s->thread_info.min_latency = DEFAULT_MIN_LATENCY;
|
||||||
s->thread_info.max_latency = 0;
|
s->thread_info.max_latency = DEFAULT_MIN_LATENCY;
|
||||||
|
|
||||||
pa_assert_se(pa_idxset_put(core->sources, s, &s->index) >= 0);
|
pa_assert_se(pa_idxset_put(core->sources, s, &s->index) >= 0);
|
||||||
|
|
||||||
|
|
@ -936,7 +938,7 @@ int pa_source_process_msg(pa_msgobject *object, int code, void *userdata, int64_
|
||||||
case PA_SOURCE_MESSAGE_SET_LATENCY_RANGE: {
|
case PA_SOURCE_MESSAGE_SET_LATENCY_RANGE: {
|
||||||
pa_usec_t *r = userdata;
|
pa_usec_t *r = userdata;
|
||||||
|
|
||||||
pa_source_update_latency_range(s, r[0], r[1]);
|
pa_source_set_latency_range_within_thread(s, r[0], r[1]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1130,11 +1132,16 @@ void pa_source_set_latency_range(pa_source *s, pa_usec_t min_latency, pa_usec_t
|
||||||
if (min_latency == (pa_usec_t) -1)
|
if (min_latency == (pa_usec_t) -1)
|
||||||
min_latency = DEFAULT_MIN_LATENCY;
|
min_latency = DEFAULT_MIN_LATENCY;
|
||||||
|
|
||||||
|
if (min_latency < ABSOLUTE_MIN_LATENCY)
|
||||||
|
min_latency = ABSOLUTE_MIN_LATENCY;
|
||||||
|
|
||||||
if (max_latency == (pa_usec_t) -1)
|
if (max_latency == (pa_usec_t) -1)
|
||||||
max_latency = min_latency;
|
max_latency = min_latency;
|
||||||
|
|
||||||
pa_assert(!min_latency || !max_latency ||
|
if (max_latency > ABSOLUTE_MAX_LATENCY || max_latency <= 0)
|
||||||
min_latency <= max_latency);
|
max_latency = ABSOLUTE_MAX_LATENCY;
|
||||||
|
|
||||||
|
pa_assert(min_latency <= max_latency);
|
||||||
|
|
||||||
if (PA_SOURCE_IS_LINKED(s->state)) {
|
if (PA_SOURCE_IS_LINKED(s->state)) {
|
||||||
pa_usec_t r[2];
|
pa_usec_t r[2];
|
||||||
|
|
@ -1170,14 +1177,15 @@ void pa_source_get_latency_range(pa_source *s, pa_usec_t *min_latency, pa_usec_t
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called from IO thread */
|
/* Called from IO thread */
|
||||||
void pa_source_update_latency_range(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency) {
|
void pa_source_set_latency_range_within_thread(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency) {
|
||||||
pa_source_output *o;
|
pa_source_output *o;
|
||||||
void *state = NULL;
|
void *state = NULL;
|
||||||
|
|
||||||
pa_source_assert_ref(s);
|
pa_source_assert_ref(s);
|
||||||
|
|
||||||
pa_assert(!min_latency || !max_latency ||
|
pa_assert(min_latency >= ABSOLUTE_MIN_LATENCY);
|
||||||
min_latency <= max_latency);
|
pa_assert(max_latency <= ABSOLUTE_MAX_LATENCY);
|
||||||
|
pa_assert(min_latency <= max_latency);
|
||||||
|
|
||||||
s->thread_info.min_latency = min_latency;
|
s->thread_info.min_latency = min_latency;
|
||||||
s->thread_info.max_latency = max_latency;
|
s->thread_info.max_latency = max_latency;
|
||||||
|
|
|
||||||
|
|
@ -260,7 +260,7 @@ void pa_source_detach_within_thread(pa_source *s);
|
||||||
pa_usec_t pa_source_get_requested_latency_within_thread(pa_source *s);
|
pa_usec_t pa_source_get_requested_latency_within_thread(pa_source *s);
|
||||||
|
|
||||||
void pa_source_set_max_rewind(pa_source *s, size_t max_rewind);
|
void pa_source_set_max_rewind(pa_source *s, size_t max_rewind);
|
||||||
void pa_source_update_latency_range(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency);
|
void pa_source_set_latency_range_within_thread(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency);
|
||||||
|
|
||||||
/*** To be called exclusively by source output drivers, from IO context */
|
/*** To be called exclusively by source output drivers, from IO context */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue