]> code.delx.au - pulseaudio/commitdiff
introduce pa_{sink|source}_get_latency_within_thread()
authorLennart Poettering <lennart@poettering.net>
Sun, 5 Apr 2009 00:46:38 +0000 (02:46 +0200)
committerLennart Poettering <lennart@poettering.net>
Sun, 5 Apr 2009 00:46:38 +0000 (02:46 +0200)
src/pulsecore/sink.c
src/pulsecore/sink.h
src/pulsecore/source.c
src/pulsecore/source.h

index 73ad247df45d5df7935b83480925524ec9af1b62..a0f0ea7e6a82205bb4907b252700b16657f876e1 100644 (file)
@@ -958,6 +958,32 @@ pa_usec_t pa_sink_get_latency(pa_sink *s) {
     return usec;
 }
 
+/* Called from IO thread */
+pa_usec_t pa_sink_get_latency_within_thread(pa_sink *s) {
+    pa_usec_t usec = 0;
+    pa_msgobject *o;
+
+    pa_sink_assert_ref(s);
+    pa_assert(PA_SINK_IS_LINKED(s->thread_info.state));
+
+    /* The returned value is supposed to be in the time domain of the sound card! */
+
+    if (s->thread_info.state == PA_SINK_SUSPENDED)
+        return 0;
+
+    if (!(s->flags & PA_SINK_LATENCY))
+        return 0;
+
+    o = PA_MSGOBJECT(s);
+
+    /* We probably should make this a proper vtable callback instead of going through process_msg() */
+
+    if (o->process_msg(o, PA_SINK_MESSAGE_GET_LATENCY, &usec, 0, NULL) < 0)
+        return -1;
+
+    return usec;
+}
+
 /* Called from main thread */
 void pa_sink_update_flat_volume(pa_sink *s, pa_cvolume *new_volume) {
     pa_sink_input *i;
index 7d1e11efb58db54015f14a16dac286599365d5a6..634bf3ef7df612557dd29e386eca9ac258bf8f5d 100644 (file)
@@ -295,4 +295,6 @@ void pa_sink_request_rewind(pa_sink*s, size_t nbytes);
 
 void pa_sink_invalidate_requested_latency(pa_sink *s);
 
+pa_usec_t pa_sink_get_latency_within_thread(pa_sink *s);
+
 #endif
index 1c3377be03c62e27241f7b7967238eb030a2255f..252e23abe8edcd9d851c77826db0fb0a2e25f8a5 100644 (file)
@@ -617,6 +617,32 @@ pa_usec_t pa_source_get_latency(pa_source *s) {
     return usec;
 }
 
+/* Called from IO thread */
+pa_usec_t pa_source_get_latency_within_thread(pa_source *s) {
+    pa_usec_t usec = 0;
+    pa_msgobject *o;
+
+    pa_source_assert_ref(s);
+    pa_assert(PA_SOURCE_IS_LINKED(s->thread_info.state));
+
+    /* The returned value is supposed to be in the time domain of the sound card! */
+
+    if (s->thread_info.state == PA_SOURCE_SUSPENDED)
+        return 0;
+
+    if (!(s->flags & PA_SOURCE_LATENCY))
+        return 0;
+
+    o = PA_MSGOBJECT(s);
+
+    /* We probably should make this a proper vtable callback instead of going through process_msg() */
+
+    if (o->process_msg(o, PA_SOURCE_MESSAGE_GET_LATENCY, &usec, 0, NULL) < 0)
+        return -1;
+
+    return usec;
+}
+
 /* Called from main thread */
 void pa_source_set_volume(pa_source *s, const pa_cvolume *volume) {
     pa_cvolume old_virtual_volume;
index 210f5340f01e485c6ae45a4a1e9b15c11892d1a9..652783efc894e4aa6b86402bec026462708945a0 100644 (file)
@@ -267,5 +267,6 @@ void pa_source_set_latency_range_within_thread(pa_source *s, pa_usec_t min_laten
 /*** To be called exclusively by source output drivers, from IO context */
 
 void pa_source_invalidate_requested_latency(pa_source *s);
+pa_usec_t pa_source_get_latency_within_thread(pa_source *s);
 
 #endif