[pulseaudio-commits] 3 commits - src/modules src/pulsecore

Lennart Poettering lennart at kemper.freedesktop.org
Thu Nov 3 13:32:23 PDT 2011


 src/modules/alsa/alsa-sink.c          |   23 +++++++++++++++++++----
 src/modules/alsa/alsa-source.c        |   22 ++++++++++++++++++----
 src/modules/alsa/module-alsa-card.c   |    2 ++
 src/modules/alsa/module-alsa-sink.c   |    4 +++-
 src/modules/alsa/module-alsa-source.c |    4 +++-
 src/modules/module-udev-detect.c      |   13 ++++++++++++-
 src/pulsecore/protocol-native.c       |    4 ++++
 7 files changed, 61 insertions(+), 11 deletions(-)

New commits:
commit 1e6eda8eda615ec1275a1f208e5f3c9b41238f10
Author: Lars R. Damerow <lars at pixar.com>
Date:   Thu Nov 3 21:31:48 2011 +0100

    alsa: fixed_latency_range modarg for module-alsa-card

diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index 5bf6480..344563f 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -64,6 +64,7 @@ PA_MODULE_USAGE(
         "tsched_buffer_size=<buffer size when using timer based scheduling> "
         "tsched_buffer_watermark=<lower fill watermark> "
         "profile=<profile name> "
+        "fixed_latency_range=<disable latency range changes on underrun?> "
         "ignore_dB=<ignore dB information from the device?> "
         "deferred_volume=<Synchronize software and hardware volume changes to avoid momentary jumps?> "
         "profile_set=<profile set configuration file> "
@@ -88,6 +89,7 @@ static const char* const valid_modargs[] = {
     "tsched",
     "tsched_buffer_size",
     "tsched_buffer_watermark",
+    "fixed_latency_range",
     "profile",
     "ignore_dB",
     "deferred_volume",

commit c07c4b353dffe17607fee89e294181bb4e2da40d
Author: Lars R. Damerow <lars at pixar.com>
Date:   Thu Nov 3 21:29:03 2011 +0100

    alsa: fixed latency range handling for udev-detect

diff --git a/src/modules/module-udev-detect.c b/src/modules/module-udev-detect.c
index c5312a8..1192194 100644
--- a/src/modules/module-udev-detect.c
+++ b/src/modules/module-udev-detect.c
@@ -45,6 +45,7 @@ PA_MODULE_VERSION(PACKAGE_VERSION);
 PA_MODULE_LOAD_ONCE(TRUE);
 PA_MODULE_USAGE(
         "tsched=<enable system timer based scheduling mode?> "
+        "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?>");
 
@@ -62,6 +63,7 @@ struct userdata {
     pa_hashmap *devices;
 
     pa_bool_t use_tsched:1;
+    pa_bool_t fixed_latency_range:1;
     pa_bool_t ignore_dB:1;
     pa_bool_t deferred_volume:1;
 
@@ -75,6 +77,7 @@ struct userdata {
 
 static const char* const valid_modargs[] = {
     "tsched",
+    "fixed_latency_range",
     "ignore_dB",
     "deferred_volume",
     NULL
@@ -388,6 +391,7 @@ static void card_changed(struct userdata *u, struct udev_device *dev) {
                                 "card_name=\"%s\" "
                                 "namereg_fail=false "
                                 "tsched=%s "
+                                "fixed_latency_range=%s "
                                 "ignore_dB=%s "
                                 "deferred_volume=%s "
                                 "card_properties=\"module-udev-detect.discovered=1\"",
@@ -395,6 +399,7 @@ static void card_changed(struct userdata *u, struct udev_device *dev) {
                                 n,
                                 d->card_name,
                                 pa_yes_no(u->use_tsched),
+                                pa_yes_no(u->fixed_latency_range),
                                 pa_yes_no(u->ignore_dB),
                                 pa_yes_no(u->deferred_volume));
     pa_xfree(n);
@@ -665,7 +670,7 @@ int pa__init(pa_module *m) {
     struct udev_enumerate *enumerate = NULL;
     struct udev_list_entry *item = NULL, *first = NULL;
     int fd;
-    pa_bool_t use_tsched = TRUE, ignore_dB = FALSE, deferred_volume = m->core->deferred_volume;
+    pa_bool_t use_tsched = TRUE, fixed_latency_range = FALSE, ignore_dB = FALSE, deferred_volume = m->core->deferred_volume;
 
 
     pa_assert(m);
@@ -686,6 +691,12 @@ int pa__init(pa_module *m) {
     }
     u->use_tsched = use_tsched;
 
+    if (pa_modargs_get_value_boolean(ma, "fixed_latency_range", &fixed_latency_range) < 0) {
+        pa_log("Failed to parse fixed_latency_range= argument.");
+        goto fail;
+    }
+    u->fixed_latency_range = fixed_latency_range;
+
     if (pa_modargs_get_value_boolean(ma, "ignore_dB", &ignore_dB) < 0) {
         pa_log("Failed to parse ignore_dB= argument.");
         goto fail;

commit 7a387fed36ed5bc0b925269fb76b5e8e3a738a5f
Author: Lars R. Damerow <lars at pixar.com>
Date:   Thu Nov 3 21:14:45 2011 +0100

    alsa: support fixed latency range in alsa modules
    
    This adds a boolean module parameter to disable automatic dynamic
    latency readjustments on underruns, but leaves automatic dynamic
    watermark readjustments untouched.

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 7b31b1b..1386196 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -134,7 +134,7 @@ struct userdata {
     char *device_name;  /* name of the PCM device */
     char *control_device; /* name of the control device */
 
-    pa_bool_t use_mmap:1, use_tsched:1, deferred_volume:1;
+    pa_bool_t use_mmap:1, use_tsched:1, deferred_volume:1, fixed_latency_range:1;
 
     pa_bool_t first, after_rewind;
 
@@ -331,7 +331,12 @@ static void increase_watermark(struct userdata *u) {
         return;
     }
 
-    /* Hmm, we cannot increase the watermark any further, hence let's raise the latency */
+    /* Hmm, we cannot increase the watermark any further, hence let's
+       raise the latency, unless doing so was disabled in
+       configuration */
+    if (u->fixed_latency_range)
+        return;
+
     old_min_latency = u->sink->thread_info.min_latency;
     new_min_latency = PA_MIN(old_min_latency * 2, old_min_latency + TSCHED_WATERMARK_INC_STEP_USEC);
     new_min_latency = PA_MIN(new_min_latency, u->sink->thread_info.max_latency);
@@ -1969,7 +1974,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
     uint32_t nfrags, frag_size, buffer_size, tsched_size, tsched_watermark, rewind_safeguard;
     snd_pcm_uframes_t period_frames, buffer_frames, tsched_frames;
     size_t frame_size;
-    pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d, ignore_dB = FALSE, namereg_fail = FALSE, deferred_volume = FALSE, set_formats = FALSE;
+    pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d, ignore_dB = FALSE, namereg_fail = FALSE, deferred_volume = FALSE, set_formats = FALSE, fixed_latency_range = FALSE;
     pa_sink_new_data data;
     pa_alsa_profile_set *profile_set = NULL;
 
@@ -2039,6 +2044,11 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
         goto fail;
     }
 
+    if (pa_modargs_get_value_boolean(ma, "fixed_latency_range", &fixed_latency_range) < 0) {
+        pa_log("Failed to parse fixed_latency_range argument.");
+        goto fail;
+    }
+
     use_tsched = pa_alsa_may_tsched(use_tsched);
 
     u = pa_xnew0(struct userdata, 1);
@@ -2047,6 +2057,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
     u->use_mmap = use_mmap;
     u->use_tsched = use_tsched;
     u->deferred_volume = deferred_volume;
+    u->fixed_latency_range = fixed_latency_range;
     u->first = TRUE;
     u->rewind_safeguard = rewind_safeguard;
     u->rtpoll = pa_rtpoll_new();
@@ -2143,9 +2154,13 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
     if (u->use_mmap)
         pa_log_info("Successfully enabled mmap() mode.");
 
-    if (u->use_tsched)
+    if (u->use_tsched) {
         pa_log_info("Successfully enabled timer-based scheduling mode.");
 
+        if (u->fixed_latency_range)
+            pa_log_info("Disabling latency range changes on underrun");
+    }
+
     if (is_iec958(u) || is_hdmi(u))
         set_formats = TRUE;
 
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 7a51572..255a61d 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -121,7 +121,7 @@ struct userdata {
     char *device_name;  /* name of the PCM device */
     char *control_device; /* name of the control device */
 
-    pa_bool_t use_mmap:1, use_tsched:1, deferred_volume:1;
+    pa_bool_t use_mmap:1, use_tsched:1, deferred_volume:1, fixed_latency_range:1;
 
     pa_bool_t first;
 
@@ -306,7 +306,12 @@ static void increase_watermark(struct userdata *u) {
         return;
     }
 
-    /* Hmm, we cannot increase the watermark any further, hence let's raise the latency */
+    /* Hmm, we cannot increase the watermark any further, hence let's
+     raise the latency unless doing so was disabled in
+     configuration */
+    if (u->fixed_latency_range)
+        return;
+
     old_min_latency = u->source->thread_info.min_latency;
     new_min_latency = PA_MIN(old_min_latency * 2, old_min_latency + TSCHED_WATERMARK_INC_STEP_USEC);
     new_min_latency = PA_MIN(new_min_latency, u->source->thread_info.max_latency);
@@ -1710,7 +1715,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
     uint32_t nfrags, frag_size, buffer_size, tsched_size, tsched_watermark;
     snd_pcm_uframes_t period_frames, buffer_frames, tsched_frames;
     size_t frame_size;
-    pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d, ignore_dB = FALSE, namereg_fail = FALSE, deferred_volume = FALSE;
+    pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d, ignore_dB = FALSE, namereg_fail = FALSE, deferred_volume = FALSE, fixed_latency_range = FALSE;
     pa_source_new_data data;
     pa_alsa_profile_set *profile_set = NULL;
 
@@ -1774,6 +1779,11 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
         goto fail;
     }
 
+    if (pa_modargs_get_value_boolean(ma, "fixed_latency_range", &fixed_latency_range) < 0) {
+        pa_log("Failed to parse fixed_latency_range argument.");
+        goto fail;
+    }
+
     use_tsched = pa_alsa_may_tsched(use_tsched);
 
     u = pa_xnew0(struct userdata, 1);
@@ -1782,6 +1792,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
     u->use_mmap = use_mmap;
     u->use_tsched = use_tsched;
     u->deferred_volume = deferred_volume;
+    u->fixed_latency_range = fixed_latency_range;
     u->first = TRUE;
     u->rtpoll = pa_rtpoll_new();
     pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
@@ -1877,8 +1888,11 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
     if (u->use_mmap)
         pa_log_info("Successfully enabled mmap() mode.");
 
-    if (u->use_tsched)
+    if (u->use_tsched) {
         pa_log_info("Successfully enabled timer-based scheduling mode.");
+        if (u->fixed_latency_range)
+            pa_log_info("Disabling latency range changes on overrun");
+    }
 
     u->rates = pa_alsa_get_supported_rates(u->pcm_handle);
     if (!u->rates) {
diff --git a/src/modules/alsa/module-alsa-sink.c b/src/modules/alsa/module-alsa-sink.c
index 019ccf0..927f075 100644
--- a/src/modules/alsa/module-alsa-sink.c
+++ b/src/modules/alsa/module-alsa-sink.c
@@ -59,7 +59,8 @@ PA_MODULE_USAGE(
         "rewind_safeguard=<number of bytes that cannot be rewound> "
         "deferred_volume=<Synchronize software and hardware volume changes to avoid momentary jumps?> "
         "deferred_volume_safety_margin=<usec adjustment depending on volume direction> "
-        "deferred_volume_extra_delay=<usec adjustment to HW volume changes>");
+        "deferred_volume_extra_delay=<usec adjustment to HW volume changes> "
+        "fixed_latency_range=<disable latency range changes on underrun?>");
 
 static const char* const valid_modargs[] = {
     "name",
@@ -85,6 +86,7 @@ static const char* const valid_modargs[] = {
     "deferred_volume",
     "deferred_volume_safety_margin",
     "deferred_volume_extra_delay",
+    "fixed_latency_range",
     NULL
 };
 
diff --git a/src/modules/alsa/module-alsa-source.c b/src/modules/alsa/module-alsa-source.c
index 2d2c8b6..efb2d0c 100644
--- a/src/modules/alsa/module-alsa-source.c
+++ b/src/modules/alsa/module-alsa-source.c
@@ -67,7 +67,8 @@ PA_MODULE_USAGE(
         "control=<name of mixer control>"
         "deferred_volume=<Synchronize software and hardware volume changes to avoid momentary jumps?> "
         "deferred_volume_safety_margin=<usec adjustment depending on volume direction> "
-        "deferred_volume_extra_delay=<usec adjustment to HW volume changes>");
+        "deferred_volume_extra_delay=<usec adjustment to HW volume changes> "
+        "fixed_latency_range=<disable latency range changes on overrun?>");
 
 static const char* const valid_modargs[] = {
     "name",
@@ -92,6 +93,7 @@ static const char* const valid_modargs[] = {
     "deferred_volume",
     "deferred_volume_safety_margin",
     "deferred_volume_extra_delay",
+    "fixed_latency_range",
     NULL
 };
 
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 0ee4ead..d6bff11 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -1008,6 +1008,10 @@ static void fix_playback_buffer_attr(playback_stream *s) {
             tlength_usec -= s->configured_sink_latency;
     }
 
+    pa_log_debug("Requested latency=%0.2f ms, Received latency=%0.2f ms",
+                 (double) sink_usec / PA_USEC_PER_MSEC,
+                 (double) s->configured_sink_latency / PA_USEC_PER_MSEC);
+
     /* FIXME: This is actually larger than necessary, since not all of
      * the sink latency is actually rewritable. */
     if (tlength_usec < s->configured_sink_latency + 2*minreq_usec)



More information about the pulseaudio-commits mailing list