mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
module-ffado: keep the configured rate in sync with params
When we reconfigure rate, make sure we update the EnumFormat and Format params with the new value.
This commit is contained in:
parent
a831a15825
commit
7065023a5f
1 changed files with 34 additions and 8 deletions
|
|
@ -904,6 +904,31 @@ static const struct pw_filter_events source_events = {
|
||||||
.process = source_process,
|
.process = source_process,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int update_stream_format(struct stream *s, uint32_t samplerate)
|
||||||
|
{
|
||||||
|
uint8_t buffer[1024];
|
||||||
|
struct spa_pod_builder b;
|
||||||
|
uint32_t n_params;
|
||||||
|
const struct spa_pod *params[2];
|
||||||
|
|
||||||
|
if (s->info.rate == samplerate)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
s->info.rate = samplerate;
|
||||||
|
|
||||||
|
if (s->filter == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
n_params = 0;
|
||||||
|
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||||
|
params[n_params++] = spa_format_audio_raw_build(&b,
|
||||||
|
SPA_PARAM_EnumFormat, &s->info);
|
||||||
|
params[n_params++] = spa_format_audio_raw_build(&b,
|
||||||
|
SPA_PARAM_Format, &s->info);
|
||||||
|
|
||||||
|
return pw_filter_update_params(s->filter, NULL, params, n_params);
|
||||||
|
}
|
||||||
|
|
||||||
static int make_stream(struct stream *s, const char *name)
|
static int make_stream(struct stream *s, const char *name)
|
||||||
{
|
{
|
||||||
struct impl *impl = s->impl;
|
struct impl *impl = s->impl;
|
||||||
|
|
@ -911,11 +936,6 @@ static int make_stream(struct stream *s, const char *name)
|
||||||
const struct spa_pod *params[4];
|
const struct spa_pod *params[4];
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
struct spa_pod_builder b;
|
struct spa_pod_builder b;
|
||||||
struct spa_latency_info latency;
|
|
||||||
|
|
||||||
spa_zero(latency);
|
|
||||||
n_params = 0;
|
|
||||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
|
||||||
|
|
||||||
s->filter = pw_filter_new(impl->core, name, pw_properties_copy(s->props));
|
s->filter = pw_filter_new(impl->core, name, pw_properties_copy(s->props));
|
||||||
if (s->filter == NULL)
|
if (s->filter == NULL)
|
||||||
|
|
@ -932,6 +952,8 @@ static int make_stream(struct stream *s, const char *name)
|
||||||
|
|
||||||
reset_volume(&s->volume, s->info.channels);
|
reset_volume(&s->volume, s->info.channels);
|
||||||
|
|
||||||
|
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||||
|
|
||||||
n_params = 0;
|
n_params = 0;
|
||||||
params[n_params++] = spa_format_audio_raw_build(&b,
|
params[n_params++] = spa_format_audio_raw_build(&b,
|
||||||
SPA_PARAM_EnumFormat, &s->info);
|
SPA_PARAM_EnumFormat, &s->info);
|
||||||
|
|
@ -1084,6 +1106,10 @@ static int open_ffado_device(struct impl *impl)
|
||||||
if (target_period == 0)
|
if (target_period == 0)
|
||||||
target_period = c->target_duration;
|
target_period = c->target_duration;
|
||||||
}
|
}
|
||||||
|
if (target_rate == 0)
|
||||||
|
target_rate = DEFAULT_SAMPLE_RATE;
|
||||||
|
if (target_period == 0)
|
||||||
|
target_period = DEFAULT_PERIOD_SIZE;
|
||||||
|
|
||||||
spa_zero(impl->device_info);
|
spa_zero(impl->device_info);
|
||||||
impl->device_info.device_spec_strings = impl->devices;
|
impl->device_info.device_spec_strings = impl->devices;
|
||||||
|
|
@ -1114,9 +1140,6 @@ static int open_ffado_device(struct impl *impl)
|
||||||
|
|
||||||
ffado_streaming_set_audio_datatype(impl->dev, ffado_audio_datatype_float);
|
ffado_streaming_set_audio_datatype(impl->dev, ffado_audio_datatype_float);
|
||||||
|
|
||||||
impl->source.info.rate = impl->device_options.sample_rate;
|
|
||||||
impl->sink.info.rate = impl->device_options.sample_rate;
|
|
||||||
|
|
||||||
impl->source.n_ports = ffado_streaming_get_nb_capture_streams(impl->dev);
|
impl->source.n_ports = ffado_streaming_get_nb_capture_streams(impl->dev);
|
||||||
impl->sink.n_ports = ffado_streaming_get_nb_playback_streams(impl->dev);
|
impl->sink.n_ports = ffado_streaming_get_nb_playback_streams(impl->dev);
|
||||||
|
|
||||||
|
|
@ -1125,6 +1148,9 @@ static int open_ffado_device(struct impl *impl)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_stream_format(&impl->source, impl->device_options.sample_rate);
|
||||||
|
update_stream_format(&impl->sink, impl->device_options.sample_rate);
|
||||||
|
|
||||||
pw_log_info("opened FFADO device %s source:%d sink:%d rate:%d period:%d %p",
|
pw_log_info("opened FFADO device %s source:%d sink:%d rate:%d period:%d %p",
|
||||||
impl->devices[0], impl->source.n_ports, impl->sink.n_ports,
|
impl->devices[0], impl->source.n_ports, impl->sink.n_ports,
|
||||||
impl->device_options.sample_rate,
|
impl->device_options.sample_rate,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue