[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] sink, source: Use the global configuration for the avoid_resampling default
Arun Raghavan
gitlab at gitlab.freedesktop.org
Mon Jun 22 14:52:21 UTC 2020
Arun Raghavan pushed to branch master at PulseAudio / pulseaudio
Commits:
04c554b7 by Tanu Kaskinen at 2020-06-22T14:47:42+00:00
sink, source: Use the global configuration for the avoid_resampling default
Previously avoid_resampling was always false unless the sink or source
implementation explicitly configured the variable. The null sink doesn't
explicitly configure it, so it didn't switch the sample rate as
expected when avoid_resampling was enabled.
This change means that also sinks that don't support rate switching can
have avoid_resampling set to true, but I think that's fine, because
pa_sink_reconfigure() doesn't try to do anything if the reconfigure()
callback isn't set.
Fixes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/923
- - - - -
6 changed files:
- src/modules/alsa/alsa-sink.c
- src/modules/alsa/alsa-source.c
- src/pulsecore/sink.c
- src/pulsecore/sink.h
- src/pulsecore/source.c
- src/pulsecore/source.h
Changes:
=====================================
src/modules/alsa/alsa-sink.c
=====================================
@@ -2534,7 +2534,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
pa_sink_new_data_done(&data);
goto fail;
}
- data.avoid_resampling = avoid_resampling;
+ pa_sink_new_data_set_avoid_resampling(&data, avoid_resampling);
pa_sink_new_data_set_sample_spec(&data, &ss);
pa_sink_new_data_set_channel_map(&data, &map);
=====================================
src/modules/alsa/alsa-source.c
=====================================
@@ -2221,7 +2221,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
pa_source_new_data_done(&data);
goto fail;
}
- data.avoid_resampling = avoid_resampling;
+ pa_source_new_data_set_avoid_resampling(&data, avoid_resampling);
pa_source_new_data_set_sample_spec(&data, &ss);
pa_source_new_data_set_channel_map(&data, &map);
=====================================
src/pulsecore/sink.c
=====================================
@@ -113,6 +113,13 @@ void pa_sink_new_data_set_alternate_sample_rate(pa_sink_new_data *data, const ui
data->alternate_sample_rate = alternate_sample_rate;
}
+void pa_sink_new_data_set_avoid_resampling(pa_sink_new_data *data, bool avoid_resampling) {
+ pa_assert(data);
+
+ data->avoid_resampling_is_set = true;
+ data->avoid_resampling = avoid_resampling;
+}
+
void pa_sink_new_data_set_volume(pa_sink_new_data *data, const pa_cvolume *volume) {
pa_assert(data);
@@ -271,7 +278,10 @@ pa_sink* pa_sink_new(
else
s->alternate_sample_rate = s->core->alternate_sample_rate;
- s->avoid_resampling = data->avoid_resampling;
+ if (data->avoid_resampling_is_set)
+ s->avoid_resampling = data->avoid_resampling;
+ else
+ s->avoid_resampling = s->core->avoid_resampling;
s->inputs = pa_idxset_new(NULL, NULL);
s->n_corked = 0;
@@ -363,11 +373,11 @@ pa_sink* pa_sink_new(
pa_source_new_data_set_sample_spec(&source_data, &s->sample_spec);
pa_source_new_data_set_channel_map(&source_data, &s->channel_map);
pa_source_new_data_set_alternate_sample_rate(&source_data, s->alternate_sample_rate);
+ pa_source_new_data_set_avoid_resampling(&source_data, s->avoid_resampling);
source_data.name = pa_sprintf_malloc("%s.monitor", name);
source_data.driver = data->driver;
source_data.module = data->module;
source_data.card = data->card;
- source_data.avoid_resampling = data->avoid_resampling;
dn = pa_proplist_gets(s->proplist, PA_PROP_DEVICE_DESCRIPTION);
pa_proplist_setf(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Monitor of %s", dn ? dn : s->name);
=====================================
src/pulsecore/sink.h
=====================================
@@ -384,6 +384,7 @@ typedef struct pa_sink_new_data {
bool sample_spec_is_set:1;
bool channel_map_is_set:1;
bool alternate_sample_rate_is_set:1;
+ bool avoid_resampling_is_set:1;
bool volume_is_set:1;
bool muted_is_set:1;
@@ -399,6 +400,7 @@ void pa_sink_new_data_set_name(pa_sink_new_data *data, const char *name);
void pa_sink_new_data_set_sample_spec(pa_sink_new_data *data, const pa_sample_spec *spec);
void pa_sink_new_data_set_channel_map(pa_sink_new_data *data, const pa_channel_map *map);
void pa_sink_new_data_set_alternate_sample_rate(pa_sink_new_data *data, const uint32_t alternate_sample_rate);
+void pa_sink_new_data_set_avoid_resampling(pa_sink_new_data *data, bool avoid_resampling);
void pa_sink_new_data_set_volume(pa_sink_new_data *data, const pa_cvolume *volume);
void pa_sink_new_data_set_muted(pa_sink_new_data *data, bool mute);
void pa_sink_new_data_set_port(pa_sink_new_data *data, const char *port);
=====================================
src/pulsecore/source.c
=====================================
@@ -104,6 +104,13 @@ void pa_source_new_data_set_alternate_sample_rate(pa_source_new_data *data, cons
data->alternate_sample_rate = alternate_sample_rate;
}
+void pa_source_new_data_set_avoid_resampling(pa_source_new_data *data, bool avoid_resampling) {
+ pa_assert(data);
+
+ data->avoid_resampling_is_set = true;
+ data->avoid_resampling = avoid_resampling;
+}
+
void pa_source_new_data_set_volume(pa_source_new_data *data, const pa_cvolume *volume) {
pa_assert(data);
@@ -258,7 +265,10 @@ pa_source* pa_source_new(
else
s->alternate_sample_rate = s->core->alternate_sample_rate;
- s->avoid_resampling = data->avoid_resampling;
+ if (data->avoid_resampling_is_set)
+ s->avoid_resampling = data->avoid_resampling;
+ else
+ s->avoid_resampling = s->core->avoid_resampling;
s->outputs = pa_idxset_new(NULL, NULL);
s->n_corked = 0;
=====================================
src/pulsecore/source.h
=====================================
@@ -324,6 +324,7 @@ typedef struct pa_source_new_data {
bool sample_spec_is_set:1;
bool channel_map_is_set:1;
bool alternate_sample_rate_is_set:1;
+ bool avoid_resampling_is_set:1;
bool namereg_fail:1;
@@ -337,6 +338,7 @@ void pa_source_new_data_set_name(pa_source_new_data *data, const char *name);
void pa_source_new_data_set_sample_spec(pa_source_new_data *data, const pa_sample_spec *spec);
void pa_source_new_data_set_channel_map(pa_source_new_data *data, const pa_channel_map *map);
void pa_source_new_data_set_alternate_sample_rate(pa_source_new_data *data, const uint32_t alternate_sample_rate);
+void pa_source_new_data_set_avoid_resampling(pa_source_new_data *data, bool avoid_resampling);
void pa_source_new_data_set_volume(pa_source_new_data *data, const pa_cvolume *volume);
void pa_source_new_data_set_muted(pa_source_new_data *data, bool mute);
void pa_source_new_data_set_port(pa_source_new_data *data, const char *port);
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/04c554b7d5ece918e4c5456bec491380b8d24791
--
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/04c554b7d5ece918e4c5456bec491380b8d24791
You're receiving this email because of your account on gitlab.freedesktop.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20200622/ab004806/attachment-0001.htm>
More information about the pulseaudio-commits
mailing list