]> code.delx.au - pulseaudio/commitdiff
fix up latency before calling into stream code, to make sure we don't ask for too...
authorLennart Poettering <lennart@poettering.net>
Thu, 28 Aug 2008 23:20:25 +0000 (01:20 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 28 Aug 2008 23:20:25 +0000 (01:20 +0200)
src/pulsecore/sink-input.c
src/pulsecore/sink.c
src/pulsecore/source-output.c
src/pulsecore/source.c

index f4e803d0aa110df0a0bfd5bfaa6de8bbf5fb83f0..7d80242f44ea5e0eb6ac85f36b51528a1f62f3a1 100644 (file)
@@ -756,14 +756,11 @@ pa_usec_t pa_sink_input_set_requested_latency(pa_sink_input *i, pa_usec_t usec)
 
     if (PA_SINK_INPUT_IS_LINKED(i->state))
         pa_assert_se(pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INPUT_MESSAGE_SET_REQUESTED_LATENCY, &usec, 0, NULL) == 0);
-    else {
+    else
         /* If this sink input is not realized yet, we have to touch
          * the thread info data directly */
 
-        usec = fixup_latency(i->sink, usec);
         i->thread_info.requested_sink_latency = usec;
-        i->sink->thread_info.requested_latency_valid = FALSE;
-    }
 
     return usec;
 }
index 24fb8913bb809404a9099031d4ff50bc822846b4..6fa22dc246abce69227da4fd42b66229f6821e09 100644 (file)
@@ -1042,11 +1042,15 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse
 
             pa_sink_input_set_state_within_thread(i, i->state);
 
+            /* The requested latency of the sink input needs to be
+             * fixed up and then configured on the sink */
+
+            if (i->thread_info.requested_sink_latency != (pa_usec_t) -1)
+                pa_sink_input_set_requested_latency_within_thread(i, i->thread_info.requested_sink_latency);
+
             pa_sink_input_update_max_rewind(i, s->thread_info.max_rewind);
             pa_sink_input_update_max_request(i, s->thread_info.max_request);
 
-            pa_sink_invalidate_requested_latency(s);
-
             /* We don't rewind here automatically. This is left to the
              * sink input implementor because some sink inputs need a
              * slow start, i.e. need some time to buffer client
@@ -1158,11 +1162,12 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse
             if (i->attach)
                 i->attach(i);
 
+            if (i->thread_info.requested_sink_latency != (pa_usec_t) -1)
+                pa_sink_input_set_requested_latency_within_thread(i, i->thread_info.requested_sink_latency);
+
             pa_sink_input_update_max_rewind(i, s->thread_info.max_rewind);
             pa_sink_input_update_max_request(i, s->thread_info.max_request);
 
-            pa_sink_input_set_requested_latency_within_thread(i, i->thread_info.requested_sink_latency);
-
             if (i->thread_info.state != PA_SINK_INPUT_CORKED) {
                 pa_usec_t usec = 0;
                 size_t nbytes;
@@ -1424,7 +1429,6 @@ void pa_sink_set_max_rewind(pa_sink *s, size_t max_rewind) {
 
 /* Called from IO thread */
 void pa_sink_set_max_request(pa_sink *s, size_t max_request) {
-    pa_sink_input *i;
     void *state = NULL;
 
     pa_sink_assert_ref(s);
@@ -1435,6 +1439,8 @@ void pa_sink_set_max_request(pa_sink *s, size_t max_request) {
     s->thread_info.max_request = max_request;
 
     if (PA_SINK_IS_LINKED(s->thread_info.state)) {
+        pa_sink_input *i;
+
         while ((i = pa_hashmap_iterate(s->thread_info.inputs, &state, NULL)))
             pa_sink_input_update_max_request(i, s->thread_info.max_request);
     }
index 4257154e591653d7705ae9f6ec73d9fc2c54d8e1..5df950a87d22e7e7b5281af2ce012382f210b45d 100644 (file)
@@ -511,14 +511,11 @@ pa_usec_t pa_source_output_set_requested_latency(pa_source_output *o, pa_usec_t
 
     if (PA_SOURCE_OUTPUT_IS_LINKED(o->state))
         pa_assert_se(pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o), PA_SOURCE_OUTPUT_MESSAGE_SET_REQUESTED_LATENCY, &usec, 0, NULL) == 0);
-    else {
+    else
         /* If this source output is not realized yet, we have to touch
          * the thread info data directly */
 
-        usec = fixup_latency(o->source, usec);
         o->thread_info.requested_source_latency = usec;
-        o->source->thread_info.requested_latency_valid = FALSE;
-    }
 
     return usec;
 }
index 7ed32e92e942e934f3181e24f4cdb9e48d0ea995..edbbf017e86af04c81bed97669fa55962a355987 100644 (file)
@@ -670,6 +670,9 @@ int pa_source_process_msg(pa_msgobject *object, int code, void *userdata, int64_
 
             pa_source_output_set_state_within_thread(o, o->state);
 
+            if (o->thread_info.requested_source_latency != (pa_usec_t) -1)
+                pa_source_output_set_requested_latency_within_thread(o, o->thread_info.requested_source_latency);
+
             pa_source_output_update_max_rewind(o, s->thread_info.max_rewind);
 
             /* We don't just invalidate the requested latency here,