mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
spa: Implement latency reporting
Implement latency reporting in alsa Implement latency reporting on audioconf by passing on the latency from the follower to outside of the adapter.
This commit is contained in:
parent
1a8f274a80
commit
1cd6d7b01d
8 changed files with 212 additions and 4 deletions
|
|
@ -456,6 +456,21 @@ impl_node_port_enum_params(void *object, int seq,
|
|||
}
|
||||
break;
|
||||
|
||||
case SPA_PARAM_Latency:
|
||||
switch (result.index) {
|
||||
case 0:
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamLatency, id,
|
||||
SPA_PARAM_LATENCY_direction, SPA_POD_Id(direction),
|
||||
SPA_PARAM_LATENCY_quantum, SPA_POD_Float(this->latency_quantum),
|
||||
SPA_PARAM_LATENCY_min, SPA_POD_Int(this->latency),
|
||||
SPA_PARAM_LATENCY_max, SPA_POD_Int(this->latency));
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return -ENOENT;
|
||||
}
|
||||
|
|
@ -526,6 +541,7 @@ static int port_set_format(void *object,
|
|||
if (this->have_format) {
|
||||
this->port_params[IDX_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_READWRITE);
|
||||
this->port_params[IDX_Buffers] = SPA_PARAM_INFO(SPA_PARAM_Buffers, SPA_PARAM_INFO_READ);
|
||||
this->port_params[IDX_Latency].flags ^= SPA_PARAM_INFO_SERIAL;
|
||||
} else {
|
||||
this->port_params[IDX_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
||||
this->port_params[IDX_Buffers] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
||||
|
|
@ -759,6 +775,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
spa_hook_list_init(&this->hooks);
|
||||
|
||||
this->stream = SND_PCM_STREAM_PLAYBACK;
|
||||
this->latency_quantum = 1.0f;
|
||||
|
||||
this->info_all = SPA_NODE_CHANGE_MASK_FLAGS |
|
||||
SPA_NODE_CHANGE_MASK_PROPS |
|
||||
|
|
@ -785,6 +802,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
this->port_params[IDX_IO] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);
|
||||
this->port_params[IDX_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
||||
this->port_params[IDX_Buffers] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
||||
this->port_params[IDX_Latency] = SPA_PARAM_INFO(SPA_PARAM_Latency, SPA_PARAM_INFO_READWRITE);
|
||||
this->port_info.params = this->port_params;
|
||||
this->port_info.n_params = N_PORT_PARAMS;
|
||||
|
||||
|
|
|
|||
|
|
@ -454,6 +454,21 @@ impl_node_port_enum_params(void *object, int seq,
|
|||
}
|
||||
break;
|
||||
|
||||
case SPA_PARAM_Latency:
|
||||
switch (result.index) {
|
||||
case 0:
|
||||
param = spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamLatency, id,
|
||||
SPA_PARAM_LATENCY_direction, SPA_POD_Id(direction),
|
||||
SPA_PARAM_LATENCY_quantum, SPA_POD_Float(this->latency_quantum),
|
||||
SPA_PARAM_LATENCY_min, SPA_POD_Int(this->latency),
|
||||
SPA_PARAM_LATENCY_max, SPA_POD_Int(this->latency));
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return -ENOENT;
|
||||
}
|
||||
|
|
@ -523,6 +538,7 @@ static int port_set_format(void *object,
|
|||
if (this->have_format) {
|
||||
this->port_params[IDX_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_READWRITE);
|
||||
this->port_params[IDX_Buffers] = SPA_PARAM_INFO(SPA_PARAM_Buffers, SPA_PARAM_INFO_READ);
|
||||
this->port_params[IDX_Latency].flags ^= SPA_PARAM_INFO_SERIAL;
|
||||
} else {
|
||||
this->port_params[IDX_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
||||
this->port_params[IDX_Buffers] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
||||
|
|
@ -779,6 +795,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
spa_hook_list_init(&this->hooks);
|
||||
this->stream = SND_PCM_STREAM_CAPTURE;
|
||||
|
||||
this->latency_quantum = 1.0f;
|
||||
|
||||
this->info_all = SPA_NODE_CHANGE_MASK_FLAGS |
|
||||
SPA_NODE_CHANGE_MASK_PROPS |
|
||||
SPA_NODE_CHANGE_MASK_PARAMS;
|
||||
|
|
@ -802,6 +820,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
this->port_params[IDX_IO] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);
|
||||
this->port_params[IDX_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
||||
this->port_params[IDX_Buffers] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
||||
this->port_params[IDX_Latency] = SPA_PARAM_INFO(SPA_PARAM_Latency, SPA_PARAM_INFO_READWRITE);
|
||||
this->port_info.params = this->port_params;
|
||||
this->port_info.n_params = N_PORT_PARAMS;
|
||||
|
||||
|
|
|
|||
|
|
@ -630,6 +630,8 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_
|
|||
state->headroom = SPA_MIN(state->headroom, state->buffer_frames);
|
||||
state->start_delay = state->default_start_delay;
|
||||
|
||||
state->latency = state->headroom;
|
||||
|
||||
state->period_frames = period_size;
|
||||
periods = state->buffer_frames / state->period_frames;
|
||||
|
||||
|
|
|
|||
|
|
@ -143,7 +143,8 @@ struct state {
|
|||
#define IDX_IO 2
|
||||
#define IDX_Format 3
|
||||
#define IDX_Buffers 4
|
||||
#define N_PORT_PARAMS 5
|
||||
#define IDX_Latency 5
|
||||
#define N_PORT_PARAMS 6
|
||||
struct spa_param_info port_params[N_PORT_PARAMS];
|
||||
struct spa_io_buffers *io;
|
||||
struct spa_io_clock *clock;
|
||||
|
|
@ -190,6 +191,9 @@ struct state {
|
|||
|
||||
struct spa_dll dll;
|
||||
double max_error;
|
||||
|
||||
float latency_quantum;
|
||||
uint32_t latency;
|
||||
};
|
||||
|
||||
int
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue