]> code.delx.au - pulseaudio/commitdiff
ladspa/remap: make sure we process all requested rewinds unconditionally
authorLennart Poettering <lennart@poettering.net>
Fri, 7 Aug 2009 21:58:45 +0000 (23:58 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 7 Aug 2009 21:58:45 +0000 (23:58 +0200)
In some situations a rewind request travelling downstream might be
optimized away on its way and an upstream rewind processing might never
come back. Hence, call _process_rewind() before each _render()just to
make sure we processed them all.

src/modules/module-ladspa-sink.c
src/modules/module-remap-sink.c
src/pulsecore/sink.c
src/pulsecore/source.c

index 21f4a8f1ecb2f7e1924158e786b4e4ad5de1b46a..b26330c8613ae8d534e231a7707e17f918a6c646 100644 (file)
@@ -178,6 +178,9 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk
     if (!u->sink || !PA_SINK_IS_OPENED(u->sink->thread_info.state))
         return -1;
 
+    /* Hmm, process any rewind request that might be queued up */
+    pa_sink_process_rewind(u->sink, 0);
+
     while (pa_memblockq_peek(u->memblockq, &tchunk) < 0) {
         pa_memchunk nchunk;
 
index 119f5b9f5bbcc3ef216f0a8256ec2c27aa0264b6..0b7b9b8f900ea5f379619a0141f141da2e9d5591 100644 (file)
@@ -148,6 +148,9 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk
     if (!u->sink || !PA_SINK_IS_OPENED(u->sink->thread_info.state))
         return -1;
 
+    /* Hmm, process any rewind request that might be queued up */
+    pa_sink_process_rewind(u->sink, 0);
+
     pa_sink_render(u->sink, nbytes, chunk);
     return 0;
 }
index 73a70625c88134696fe9e56c757eb15d742b0fb7..5e9662c2b75794b3904a6a41aad99dc286dd2acf 100644 (file)
@@ -665,11 +665,14 @@ void pa_sink_move_all_fail(pa_queue *q) {
 void pa_sink_process_rewind(pa_sink *s, size_t nbytes) {
     pa_sink_input *i;
     void *state = NULL;
+
     pa_sink_assert_ref(s);
     pa_assert(PA_SINK_IS_LINKED(s->thread_info.state));
 
     /* If nobody requested this and this is actually no real rewind
-     * then we can short cut this */
+     * then we can short cut this. Please note that this means that
+     * not all rewind requests triggered upstream will always be
+     * translated in actual requests! */
     if (!s->thread_info.rewind_requested && nbytes <= 0)
         return;
 
@@ -682,7 +685,7 @@ void pa_sink_process_rewind(pa_sink *s, size_t nbytes) {
     if (nbytes > 0)
         pa_log_debug("Processing rewind...");
 
-    while ((i = pa_hashmap_iterate(s->thread_info.inputs, &state, NULL))) {
+    PA_HASHMAP_FOREACH(i, s->thread_info.inputs, state) {
         pa_sink_input_assert_ref(i);
         pa_sink_input_process_rewind(i, nbytes);
     }
index ad7462b18ee1730b8ee97315a8b3cebcbaa5ab74..b8af148fb3ef46e809fb4c6438c61a2a93c8660c 100644 (file)
@@ -592,15 +592,15 @@ void pa_source_process_rewind(pa_source *s, size_t nbytes) {
     pa_source_assert_ref(s);
     pa_assert(PA_SOURCE_IS_LINKED(s->thread_info.state));
 
-    if (s->thread_info.state == PA_SOURCE_SUSPENDED)
+    if (nbytes <= 0)
         return;
 
-    if (nbytes <= 0)
+    if (s->thread_info.state == PA_SOURCE_SUSPENDED)
         return;
 
     pa_log_debug("Processing rewind...");
 
-    while ((o = pa_hashmap_iterate(s->thread_info.outputs, &state, NULL))) {
+    PA_HASHMAP_FOREACH(o, s->thread_info.outputs, state) {
         pa_source_output_assert_ref(o);
         pa_source_output_process_rewind(o, nbytes);
     }