From 84071d2cacc0773a21524211a20e6068989d3883 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 22 Aug 2019 13:25:01 +0200 Subject: [PATCH] jack: implement statistics --- src/meson.build | 1 - src/pipewire-jack.c | 2 ++ src/statistics.c | 34 +++++++++++++++++++--------------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/meson.build b/src/meson.build index f8e80625e..a2269e7b4 100644 --- a/src/meson.build +++ b/src/meson.build @@ -2,7 +2,6 @@ pipewire_jack_sources = [ 'pipewire-jack.c', 'metadata.c', 'ringbuffer.c', - 'statistics.c', 'uuid.c', ] diff --git a/src/pipewire-jack.c b/src/pipewire-jack.c index 0aeff5ed9..bc549d5df 100644 --- a/src/pipewire-jack.c +++ b/src/pipewire-jack.c @@ -2246,6 +2246,8 @@ float jack_cpu_load (jack_client_t *client) return res; } +#include "statistics.c" + SPA_EXPORT jack_port_t * jack_port_register (jack_client_t *client, const char *port_name, diff --git a/src/statistics.c b/src/statistics.c index a99f7ee77..260b10b8e 100644 --- a/src/statistics.c +++ b/src/statistics.c @@ -17,34 +17,38 @@ * Boston, MA 02110-1301, USA. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - #include -#include - SPA_EXPORT float jack_get_max_delayed_usecs (jack_client_t *client) { - pw_log_warn("not implemented"); - return 0.0f; + struct client *c = (struct client *) client; + float res = 0.0f; + + if (c->driver_activation) + res = (float)c->driver_activation->max_delay / SPA_USEC_PER_SEC; + + pw_log_trace(NAME" %p: max delay %f", client, res); + return res; } SPA_EXPORT float jack_get_xrun_delayed_usecs (jack_client_t *client) { - pw_log_warn("not implemented"); - return 0.0f; + struct client *c = (struct client *) client; + float res = 0.0f; + + if (c->driver_activation) + res = (float)c->driver_activation->xrun_delay / SPA_USEC_PER_SEC; + + pw_log_trace(NAME" %p: xrun delay %f", client, res); + return res; } SPA_EXPORT void jack_reset_max_delayed_usecs (jack_client_t *client) { - pw_log_warn("not implemented"); + struct client *c = (struct client *) client; + if (c->driver_activation) + c->driver_activation->max_delay = 0; }