[pulseaudio-commits] r2291 - in /branches/glitch-free/src: modules/module-alsa-sink.c modules/module-alsa-source.c pulsecore/sink-input.c pulsecore/sink.c pulsecore/source-output.c pulsecore/source.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Mon Apr 21 18:04:31 PDT 2008


Author: lennart
Date: Tue Apr 22 03:04:27 2008
New Revision: 2291

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2291&root=pulseaudio&view=rev
Log:
- Change meaning of special values of latency request: 0 -> "minimal latency, please"; (pa_usec_t)-1 -> "don't care"
- Remove "source" word from monitor source description
- Increase default tsched watermark to 20ms again
- For the first iteration after snd_pcm_start() halve the sleep time as workaround for USB devices with quick starts

Modified:
    branches/glitch-free/src/modules/module-alsa-sink.c
    branches/glitch-free/src/modules/module-alsa-source.c
    branches/glitch-free/src/pulsecore/sink-input.c
    branches/glitch-free/src/pulsecore/sink.c
    branches/glitch-free/src/pulsecore/source-output.c
    branches/glitch-free/src/pulsecore/source.c

Modified: branches/glitch-free/src/modules/module-alsa-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/modules/module-alsa-sink.c?rev=2291&root=pulseaudio&r1=2290&r2=2291&view=diff
==============================================================================
--- branches/glitch-free/src/modules/module-alsa-sink.c (original)
+++ branches/glitch-free/src/modules/module-alsa-sink.c Tue Apr 22 03:04:27 2008
@@ -93,7 +93,7 @@
 
 #define DEFAULT_DEVICE "default"
 #define DEFAULT_TSCHED_BUFFER_USEC (10*PA_USEC_PER_SEC)           /* 10s */
-#define DEFAULT_TSCHED_WATERMARK_USEC (10*PA_USEC_PER_MSEC)       /* 20ms */
+#define DEFAULT_TSCHED_WATERMARK_USEC (20*PA_USEC_PER_MSEC)       /* 20ms */
 
 struct userdata {
     pa_core *core;
@@ -476,7 +476,7 @@
 
     usec = pa_sink_get_requested_latency_within_thread(u->sink);
 
-    if (usec <= 0)
+    if (usec == (pa_usec_t) -1)
         usec = pa_bytes_to_usec(u->hwbuf_size, &u->sink->sample_spec);
 
 /*     pa_log_debug("hw buffer time: %u ms", (unsigned) (usec / PA_USEC_PER_MSEC)); */
@@ -488,6 +488,11 @@
     else
         usec /= 2;
 
+    if (u->first) {
+        pa_log_debug("Decreasing wakeup time for the first iteration by half.");
+        usec /= 2;
+    }
+
 /*     pa_log_debug("after watermark: %u ms", (unsigned) (usec / PA_USEC_PER_MSEC)); */
 
     return usec;
@@ -503,10 +508,10 @@
     u->hwbuf_unused_frames = 0;
 
     if (u->use_tsched)
-        if ((latency = pa_sink_get_requested_latency_within_thread(u->sink)) > 0) {
+        if ((latency = pa_sink_get_requested_latency_within_thread(u->sink)) != (pa_usec_t) -1) {
             size_t b;
 
-            pa_log("latency set to %llu", (unsigned long long) latency);
+            pa_log_debug("latency set to %llu", (unsigned long long) latency);
 
             b = pa_usec_to_bytes(latency, &u->sink->sample_spec);
 
@@ -520,7 +525,7 @@
                 ((u->hwbuf_size - b) / u->frame_size) : 0;
         }
 
-    pa_log("hwbuf_unused_frames=%lu", (unsigned long) u->hwbuf_unused_frames);
+    pa_log_debug("hwbuf_unused_frames=%lu", (unsigned long) u->hwbuf_unused_frames);
 
     /* We need at last one frame in the used part of the buffer */
     u->avail_min_frames = u->hwbuf_unused_frames + 1;
@@ -533,7 +538,7 @@
         u->avail_min_frames += (pa_usec_to_bytes(usec, &u->sink->sample_spec) / u->frame_size);
     }
 
-    pa_log("setting avail_min=%lu", (unsigned long) u->avail_min_frames);
+    pa_log_debug("setting avail_min=%lu", (unsigned long) u->avail_min_frames);
 
     if ((err = pa_alsa_set_sw_params(u->pcm_handle, u->avail_min_frames)) < 0) {
         pa_log("Failed to set software parameters: %s", snd_strerror(err));
@@ -918,7 +923,6 @@
                 if (u->first) {
                     pa_log_info("Starting playback.");
                     snd_pcm_start(u->pcm_handle);
-                    u->first = FALSE;
 
                     pa_smoother_resume(u->smoother, pa_rtclock_usec());
                 }
@@ -945,6 +949,8 @@
                 /* We don't trust the conversion, so we wake up whatever comes first */
                 pa_rtpoll_set_timer_relative(u->rtpoll, PA_MIN(usec, cusec));
             }
+
+            u->first = FALSE;
 
         } else if (u->use_tsched)
 
@@ -1018,7 +1024,7 @@
             }
 
             if (revents)
-                pa_log_info("Wakeup from ALSA! (%i)", revents);
+                pa_log_debug("Wakeup from ALSA! (%i)", revents);
         }
     }
 

Modified: branches/glitch-free/src/modules/module-alsa-source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/modules/module-alsa-source.c?rev=2291&root=pulseaudio&r1=2290&r2=2291&view=diff
==============================================================================
--- branches/glitch-free/src/modules/module-alsa-source.c (original)
+++ branches/glitch-free/src/modules/module-alsa-source.c Tue Apr 22 03:04:27 2008
@@ -415,7 +415,7 @@
 
     usec = pa_source_get_requested_latency_within_thread(u->source);
 
-    if (usec <= 0)
+    if (usec == (pa_usec_t) -1)
         usec = pa_bytes_to_usec(u->hwbuf_size, &u->source->sample_spec);
 
     pa_log_debug("hw buffer time: %u ms", (unsigned) (usec / PA_USEC_PER_MSEC));
@@ -850,6 +850,9 @@
 
                 snd_pcm_start(u->pcm_handle);
             }
+
+            if (revents)
+                pa_log_debug("Wakeup from ALSA! (%i)", revents);
         }
     }
 

Modified: branches/glitch-free/src/pulsecore/sink-input.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/pulsecore/sink-input.c?rev=2291&root=pulseaudio&r1=2290&r2=2291&view=diff
==============================================================================
--- branches/glitch-free/src/pulsecore/sink-input.c (original)
+++ branches/glitch-free/src/pulsecore/sink-input.c Tue Apr 22 03:04:27 2008
@@ -247,7 +247,7 @@
     i->thread_info.resampler = resampler;
     i->thread_info.volume = i->volume;
     i->thread_info.muted = i->muted;
-    i->thread_info.requested_sink_latency = 0;
+    i->thread_info.requested_sink_latency = (pa_usec_t) -1;
     i->thread_info.rewrite_nbytes = 0;
     i->thread_info.since_underrun = 0;
     i->thread_info.ignore_rewind = FALSE;
@@ -534,8 +534,6 @@
             if (do_volume_adj_here && !volume_is_norm) {
                 pa_memchunk_make_writable(&wchunk, 0);
 
-                pa_log_debug("adjusting volume!");
-
                 if (i->thread_info.muted)
                     pa_silence_memchunk(&wchunk, &i->thread_info.sample_spec);
                 else
@@ -682,7 +680,7 @@
 pa_usec_t pa_sink_input_set_requested_latency(pa_sink_input *i, pa_usec_t usec) {
     pa_sink_input_assert_ref(i);
 
-    if (usec > 0) {
+    if (usec != (pa_usec_t) -1) {
 
         if (i->sink->max_latency > 0 && usec > i->sink->max_latency)
             usec = i->sink->max_latency;

Modified: branches/glitch-free/src/pulsecore/sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/pulsecore/sink.c?rev=2291&root=pulseaudio&r1=2290&r2=2291&view=diff
==============================================================================
--- branches/glitch-free/src/pulsecore/sink.c (original)
+++ branches/glitch-free/src/pulsecore/sink.c Tue Apr 22 03:04:27 2008
@@ -217,7 +217,7 @@
     s->thread_info.state = s->state;
     s->thread_info.rewind_nbytes = 0;
     s->thread_info.max_rewind = 0;
-    s->thread_info.requested_latency_valid = TRUE;
+    s->thread_info.requested_latency_valid = FALSE;
     s->thread_info.requested_latency = 0;
 
     pa_assert_se(pa_idxset_put(core->sinks, s, &s->index) >= 0);
@@ -236,7 +236,7 @@
     source_data.module = data->module;
 
     dn = pa_proplist_gets(s->proplist, PA_PROP_DEVICE_DESCRIPTION);
-    pa_proplist_setf(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Monitor Source of %s", dn ? dn : s->name);
+    pa_proplist_setf(source_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Monitor of %s", dn ? dn : s->name);
     pa_proplist_sets(source_data.proplist, PA_PROP_DEVICE_CLASS, "monitor");
 
     s->monitor_source = pa_source_new(core, &source_data, 0);
@@ -1257,7 +1257,7 @@
 }
 
 pa_usec_t pa_sink_get_requested_latency_within_thread(pa_sink *s) {
-    pa_usec_t result = 0;
+    pa_usec_t result = (pa_usec_t) -1;
     pa_sink_input *i;
     void *state = NULL;
 
@@ -1268,11 +1268,11 @@
 
     while ((i = pa_hashmap_iterate(s->thread_info.inputs, &state, NULL)))
 
-        if (i->thread_info.requested_sink_latency > 0 &&
-            (!result || result > i->thread_info.requested_sink_latency))
+        if (i->thread_info.requested_sink_latency != (pa_usec_t) -1 &&
+            (result == (pa_usec_t) -1 || result > i->thread_info.requested_sink_latency))
             result = i->thread_info.requested_sink_latency;
 
-    if (result > 0) {
+    if (result != (pa_usec_t) -1) {
         if (s->max_latency > 0 && result > s->max_latency)
             result = s->max_latency;
 

Modified: branches/glitch-free/src/pulsecore/source-output.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/pulsecore/source-output.c?rev=2291&root=pulseaudio&r1=2290&r2=2291&view=diff
==============================================================================
--- branches/glitch-free/src/pulsecore/source-output.c (original)
+++ branches/glitch-free/src/pulsecore/source-output.c Tue Apr 22 03:04:27 2008
@@ -198,7 +198,7 @@
     o->thread_info.attached = FALSE;
     o->thread_info.sample_spec = o->sample_spec;
     o->thread_info.resampler = resampler;
-    o->thread_info.requested_source_latency = 0;
+    o->thread_info.requested_source_latency = (pa_usec_t) -1;
 
     o->thread_info.delay_memblockq = pa_memblockq_new(
             0,
@@ -449,7 +449,7 @@
 pa_usec_t pa_source_output_set_requested_latency(pa_source_output *o, pa_usec_t usec) {
     pa_source_output_assert_ref(o);
 
-    if (usec > 0) {
+    if (usec != (pa_usec_t) -1) {
 
         if (o->source->max_latency > 0 && usec > o->source->max_latency)
             usec = o->source->max_latency;

Modified: branches/glitch-free/src/pulsecore/source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/pulsecore/source.c?rev=2291&root=pulseaudio&r1=2290&r2=2291&view=diff
==============================================================================
--- branches/glitch-free/src/pulsecore/source.c (original)
+++ branches/glitch-free/src/pulsecore/source.c Tue Apr 22 03:04:27 2008
@@ -204,7 +204,7 @@
     s->thread_info.soft_muted = s->muted;
     s->thread_info.state = s->state;
     s->thread_info.max_rewind = 0;
-    s->thread_info.requested_latency_valid = TRUE;
+    s->thread_info.requested_latency_valid = FALSE;
     s->thread_info.requested_latency = 0;
 
     pa_assert_se(pa_idxset_put(core->sources, s, &s->index) >= 0);
@@ -713,7 +713,7 @@
 }
 
 pa_usec_t pa_source_get_requested_latency_within_thread(pa_source *s) {
-    pa_usec_t result = 0;
+    pa_usec_t result = (pa_usec_t) -1;
     pa_source_output *o;
     void *state = NULL;
 
@@ -724,11 +724,11 @@
 
     while ((o = pa_hashmap_iterate(s->thread_info.outputs, &state, NULL)))
 
-        if (o->thread_info.requested_source_latency > 0 &&
-            (!result || result > o->thread_info.requested_source_latency))
+        if (o->thread_info.requested_source_latency != (pa_usec_t) -1 &&
+            (result == (pa_usec_t) -1 || result > o->thread_info.requested_source_latency))
             result = o->thread_info.requested_source_latency;
 
-    if (result > 0) {
+    if (result != (pa_usec_t) -1) {
         if (s->max_latency > 0 && result > s->max_latency)
             result = s->max_latency;
 




More information about the pulseaudio-commits mailing list