udev-detect, alsa-card: Adopt avoid resampling option from daemon.conf

Previously, the "avoid-resampling" option of daemon.conf is to make the
daemon try to use the stream sample rate if possible for all sinks or
sources.

This patch applies this option to module-udev-detect and module-alsa-card
as a module argument in order to override the default value of daemon.conf.

As a result, user can use this argument for more fine-grained control.
e.g.) set it false in daemon.conf and set it true for module-udev-detect
or a particular module-alsa-card in default.pa.(or vice versa)

To set it, use "avoid_resampling=true or false" as the module argument.

Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
This commit is contained in:
Sangchul Lee 2018-05-25 01:29:53 +09:00 committed by Arun Raghavan
parent 3b2a5bdc10
commit ef094638f5
8 changed files with 64 additions and 8 deletions

View file

@ -46,7 +46,8 @@ PA_MODULE_USAGE(
"fixed_latency_range=<disable latency range changes on underrun?> "
"ignore_dB=<ignore dB information from the device?> "
"deferred_volume=<syncronize sw and hw volume changes in IO-thread?> "
"use_ucm=<use ALSA UCM for card configuration?>");
"use_ucm=<use ALSA UCM for card configuration?> "
"avoid_resampling=<use stream original sample rate if possible?>");
struct device {
char *path;
@ -67,6 +68,7 @@ struct userdata {
bool ignore_dB:1;
bool deferred_volume:1;
bool use_ucm:1;
bool avoid_resampling:1;
uint32_t tsched_buffer_size;
@ -85,6 +87,7 @@ static const char* const valid_modargs[] = {
"ignore_dB",
"deferred_volume",
"use_ucm",
"avoid_resampling",
NULL
};
@ -401,6 +404,7 @@ static void card_changed(struct userdata *u, struct udev_device *dev) {
"ignore_dB=%s "
"deferred_volume=%s "
"use_ucm=%s "
"avoid_resampling=%s "
"card_properties=\"module-udev-detect.discovered=1\"",
path_get_card_id(path),
n,
@ -409,7 +413,8 @@ static void card_changed(struct userdata *u, struct udev_device *dev) {
pa_yes_no(u->fixed_latency_range),
pa_yes_no(u->ignore_dB),
pa_yes_no(u->deferred_volume),
pa_yes_no(u->use_ucm));
pa_yes_no(u->use_ucm),
pa_yes_no(u->avoid_resampling));
pa_xfree(n);
if (u->tsched_buffer_size_valid)
@ -682,6 +687,7 @@ int pa__init(pa_module *m) {
int fd;
bool use_tsched = true, fixed_latency_range = false, ignore_dB = false, deferred_volume = m->core->deferred_volume;
bool use_ucm = true;
bool avoid_resampling;
pa_assert(m);
@ -734,6 +740,13 @@ int pa__init(pa_module *m) {
}
u->use_ucm = use_ucm;
avoid_resampling = m->core->avoid_resampling;
if (pa_modargs_get_value_boolean(ma, "avoid_resampling", &avoid_resampling) < 0) {
pa_log("Failed to parse avoid_resampling= argument.");
goto fail;
}
u->avoid_resampling = avoid_resampling;
if (!(u->udev = udev_new())) {
pa_log("Failed to initialize udev library.");
goto fail;