module: disable resample when following graph rate

When we don't set a rate, assume both input and output streams are
following the graph rate and so disable the resampler.

This mostly works around an issue where the input and output could
negotiate to different rates in some cases. With the resampler disabled
this would still result in the same amount of samples going in as
comming out instead of a stuttering mismatch.

See #2969
This commit is contained in:
Wim Taymans 2023-06-22 11:18:04 +02:00
parent 3db3e6dacf
commit ad5ac964af
3 changed files with 25 additions and 1 deletions

View file

@ -1375,6 +1375,8 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
pw_properties_set(props, PW_KEY_NODE_VIRTUAL, "true");
if (pw_properties_get(props, "resample.prefill") == NULL)
pw_properties_set(props, "resample.prefill", "true");
if (pw_properties_get(props, "resample.disable") == NULL)
pw_properties_set(props, "resample.disable", "true");
if (pw_properties_get(props, PW_KEY_MEDIA_CLASS) == NULL) {
if (impl->mode == MODE_SINK)

View file

@ -2466,7 +2466,12 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
parse_audio_info(impl->capture_props, &impl->capture_info);
parse_audio_info(impl->playback_props, &impl->playback_info);
if (impl->capture_info.rate && !impl->playback_info.rate)
if (!impl->capture_info.rate && !impl->playback_info.rate) {
if (pw_properties_get(impl->playback_props, "resample.disable") == NULL)
pw_properties_set(impl->playback_props, "resample.disable", "true");
if (pw_properties_get(impl->capture_props, "resample.disable") == NULL)
pw_properties_set(impl->capture_props, "resample.disable", "true");
} else if (impl->capture_info.rate && !impl->playback_info.rate)
impl->playback_info.rate = impl->capture_info.rate;
else if (impl->playback_info.rate && !impl->capture_info.rate)
impl->capture_info.rate = !impl->playback_info.rate;

View file

@ -706,6 +706,23 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
parse_audio_info(impl->capture_props, &impl->capture_info);
parse_audio_info(impl->playback_props, &impl->playback_info);
if (!impl->capture_info.rate && !impl->playback_info.rate) {
if (pw_properties_get(impl->playback_props, "resample.disable") == NULL)
pw_properties_set(impl->playback_props, "resample.disable", "true");
if (pw_properties_get(impl->capture_props, "resample.disable") == NULL)
pw_properties_set(impl->capture_props, "resample.disable", "true");
} else if (impl->capture_info.rate && !impl->playback_info.rate)
impl->playback_info.rate = impl->capture_info.rate;
else if (impl->playback_info.rate && !impl->capture_info.rate)
impl->capture_info.rate = !impl->playback_info.rate;
else if (impl->capture_info.rate != impl->playback_info.rate) {
pw_log_warn("Both capture and playback rate are set, but"
" they are different. Using the highest of two. This behaviour"
" is deprecated, please use equal rates in the module config");
impl->playback_info.rate = impl->capture_info.rate =
SPA_MAX(impl->playback_info.rate, impl->capture_info.rate);
}
if (pw_properties_get(impl->capture_props, PW_KEY_MEDIA_NAME) == NULL)
pw_properties_setf(impl->capture_props, PW_KEY_MEDIA_NAME, "%s input",
pw_properties_get(impl->capture_props, PW_KEY_NODE_DESCRIPTION));