core: make fixed latency dynamically changeable

This of course makes the name 'fixed' a bit of a misnomer. However the
definitions are now like this:

fixed latency: the latency may change during runtime, but is solely
controlled by the backend, the client has no influence.

dynamic latency: the latency may change during runtime, influenced by
the requests of the clients.

i.e. fixed vs. dynamic is from the perspective of the client.
This commit is contained in:
Lennart Poettering 2009-08-15 00:48:14 +02:00
parent 4eb59fb90e
commit 350a2bc846
10 changed files with 212 additions and 52 deletions

View file

@ -105,8 +105,6 @@ struct pa_sink {
pa_memchunk silence;
pa_usec_t fixed_latency; /* for sinks with PA_SINK_DYNAMIC_LATENCY this is 0 */
pa_hashmap *ports;
pa_device_port *active_port;
@ -160,6 +158,9 @@ struct pa_sink {
pa_cvolume soft_volume;
pa_bool_t soft_muted:1;
/* The requested latency is used for dynamic latency
* sinks. For fixed latency sinks it is always identical to
* the fixed_latency. See below. */
pa_bool_t requested_latency_valid:1;
pa_usec_t requested_latency;
@ -175,8 +176,15 @@ struct pa_sink {
size_t rewind_nbytes;
pa_bool_t rewind_requested;
/* Both dynamic and fixed latencies will be clamped to this
* range. */
pa_usec_t min_latency; /* we won't go below this latency */
pa_usec_t max_latency; /* An upper limit for the latencies */
/* 'Fixed' simply means that the latency is exclusively
* decided on by the sink, and the clients have no influence
* in changing it */
pa_usec_t fixed_latency; /* for sinks with PA_SINK_DYNAMIC_LATENCY this is 0 */
} thread_info;
void *userdata;
@ -202,6 +210,8 @@ typedef enum pa_sink_message {
PA_SINK_MESSAGE_DETACH,
PA_SINK_MESSAGE_SET_LATENCY_RANGE,
PA_SINK_MESSAGE_GET_LATENCY_RANGE,
PA_SINK_MESSAGE_SET_FIXED_LATENCY,
PA_SINK_MESSAGE_GET_FIXED_LATENCY,
PA_SINK_MESSAGE_GET_MAX_REWIND,
PA_SINK_MESSAGE_GET_MAX_REQUEST,
PA_SINK_MESSAGE_SET_MAX_REWIND,
@ -282,6 +292,7 @@ pa_bool_t pa_device_init_intended_roles(pa_proplist *p);
pa_usec_t pa_sink_get_latency(pa_sink *s);
pa_usec_t pa_sink_get_requested_latency(pa_sink *s);
void pa_sink_get_latency_range(pa_sink *s, pa_usec_t *min_latency, pa_usec_t *max_latency);
pa_usec_t pa_sink_get_fixed_latency(pa_sink *s);
size_t pa_sink_get_max_rewind(pa_sink *s);
size_t pa_sink_get_max_request(pa_sink *s);
@ -333,12 +344,13 @@ 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);
void pa_sink_set_fixed_latency_within_thread(pa_sink *s, pa_usec_t latency);
/*** To be called exclusively by sink input drivers, from IO context */
void pa_sink_request_rewind(pa_sink*s, size_t nbytes);
void pa_sink_invalidate_requested_latency(pa_sink *s);
void pa_sink_invalidate_requested_latency(pa_sink *s, pa_bool_t dynamic);
pa_usec_t pa_sink_get_latency_within_thread(pa_sink *s);