[PATCH 2/2] alsa-mixer/sink/source: Apply avoid resampling option to alsa mapping

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The coverage of the previous "avoid-resampling" option application can
be now narrowed down to the unit of alsa mapping in an alsa profile set.

To set it, specify "avoid-resampling = true" to "[Mapping xxx]" entity
in an alsa profile set configuration file.

Signed-off-by: Sangchul Lee <sc11.lee at samsung.com>
---
 src/modules/alsa/alsa-mixer.c  | 30 ++++++++++++++++++++++++++++--
 src/modules/alsa/alsa-mixer.h  |  1 +
 src/modules/alsa/alsa-sink.c   |  1 +
 src/modules/alsa/alsa-source.c |  1 +
 4 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index a524d6d..17f03bd 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -3708,6 +3708,30 @@ static int mapping_parse_exact_channels(pa_config_parser_state *state) {
     return 0;
 }
 
+static int mapping_parse_avoid_resampling(pa_config_parser_state *state) {
+    pa_alsa_profile_set *ps;
+    pa_alsa_mapping *m;
+    int b;
+
+    pa_assert(state);
+
+    ps = state->userdata;
+
+    if (!(m = pa_alsa_mapping_get(ps, state->section))) {
+        pa_log("[%s:%u] %s invalid in section %s", state->filename, state->lineno, state->lvalue, state->section);
+        return -1;
+    }
+
+    if ((b = pa_parse_boolean(state->rvalue)) < 0) {
+        pa_log("[%s:%u] %s has invalid value '%s'", state->filename, state->lineno, state->lvalue, state->section);
+        return -1;
+    }
+
+    m->avoid_resampling = b;
+
+    return 0;
+}
+
 static int mapping_parse_element(pa_config_parser_state *state) {
     pa_alsa_profile_set *ps;
     pa_alsa_mapping *m;
@@ -4129,13 +4153,14 @@ void pa_alsa_mapping_dump(pa_alsa_mapping *m) {
 
     pa_assert(m);
 
-    pa_log_debug("Mapping %s (%s), priority=%u, channel_map=%s, supported=%s, direction=%i",
+    pa_log_debug("Mapping %s (%s), priority=%u, channel_map=%s, supported=%s, direction=%i, avoid_resampling=%d",
                  m->name,
                  pa_strnull(m->description),
                  m->priority,
                  pa_channel_map_snprint(cm, sizeof(cm), &m->channel_map),
                  pa_yes_no(m->supported),
-                 m->direction);
+                 m->direction,
+                 m->avoid_resampling);
 }
 
 static void profile_set_add_auto_pair(
@@ -4426,6 +4451,7 @@ pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel
         { "element-output",         mapping_parse_element,        NULL, NULL },
         { "direction",              mapping_parse_direction,      NULL, NULL },
         { "exact-channels",         mapping_parse_exact_channels, NULL, NULL },
+        { "avoid-resampling",       mapping_parse_avoid_resampling, NULL, NULL},
 
         /* Shared by [Mapping ...] and [Profile ...] */
         { "description",            mapping_parse_description,    NULL, NULL },
diff --git a/src/modules/alsa/alsa-mixer.h b/src/modules/alsa/alsa-mixer.h
index 3ea4d73..1089273 100644
--- a/src/modules/alsa/alsa-mixer.h
+++ b/src/modules/alsa/alsa-mixer.h
@@ -277,6 +277,7 @@ struct pa_alsa_mapping {
     unsigned supported;
     bool exact_channels:1;
     bool fallback:1;
+    bool avoid_resampling:1;
 
     /* The "y" in "hw:x,y". This is set to -1 before the device index has been
      * queried, or if the query failed. */
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 464eb17..feb3aaa 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -2373,6 +2373,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;
     }
+    avoid_resampling = avoid_resampling || (mapping ? mapping->avoid_resampling : false);
     data.avoid_resampling = avoid_resampling;
 
     pa_sink_new_data_set_sample_spec(&data, &ss);
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index aa54eaa..23905aa 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -2050,6 +2050,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;
     }
+    avoid_resampling = avoid_resampling || (mapping ? mapping->avoid_resampling : false);
     data.avoid_resampling = avoid_resampling;
 
     pa_source_new_data_set_sample_spec(&data, &ss);
-- 
2.7.4



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux