From 62bd8e75e8399ac01296dcf7495d912d3947eb20 Mon Sep 17 00:00:00 2001 From: Alexandru M Stan Date: Mon, 25 May 2015 02:29:14 -0700 Subject: [PATCH 1/2] Made xrun callbacks a little easier We now pass the delayed_usecs to the callback as an argument. --- jack.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jack.py b/jack.py index d35f407..e587d44 100644 --- a/jack.py +++ b/jack.py @@ -1260,7 +1260,7 @@ def set_xrun_callback(self, callback): User-supplied function that is called whenever an xrun has occured. It must have this signature:: - callback() -> None + callback(delayed_usecs:int) -> None The `callback` is supposed to raise :class:`CallbackExit` on error. @@ -1273,7 +1273,7 @@ def set_xrun_callback(self, callback): @self._callback("JackXRunCallback", error=_FAILURE) def callback_wrapper(_): try: - callback() + callback(self.xrun_delayed_usecs) except CallbackExit: return _FAILURE return _SUCCESS From f98bcc83cd0f8405483e8d42d4c8cc47cbdeacc0 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Tue, 18 Aug 2015 16:21:02 +0200 Subject: [PATCH 2/2] Remove property "xrun_delayed_usecs" This is not needed anymore because it is passed directly to the xrun callback. --- examples/chatty_client.py | 4 ++-- jack.py | 16 ++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/examples/chatty_client.py b/examples/chatty_client.py index b0fd594..33f6439 100755 --- a/examples/chatty_client.py +++ b/examples/chatty_client.py @@ -89,8 +89,8 @@ def graph_order(): @client.set_xrun_callback -def xrun(): - print("xrun; delay", client.xrun_delayed_usecs, "microseconds") +def xrun(delay): + print("xrun; delay", delay, "microseconds") print("activating JACK") diff --git a/jack.py b/jack.py index e587d44..7aa38bd 100644 --- a/jack.py +++ b/jack.py @@ -483,16 +483,6 @@ def last_frame_time(self): """ return _lib.jack_last_frame_time(self._ptr) - @property - def xrun_delayed_usecs(self): - """Delay in microseconds due to the most recent XRUN occurrence. - - This probably only makes sense when queried from a callback - defined using :meth:`set_xrun_callback`. - - """ - return _lib.jack_get_xrun_delayed_usecs(self._ptr) - @property def inports(self): """A list of audio input :class:`Ports`. @@ -1260,8 +1250,10 @@ def set_xrun_callback(self, callback): User-supplied function that is called whenever an xrun has occured. It must have this signature:: - callback(delayed_usecs:int) -> None + callback(delayed_usecs:float) -> None + The callback argument is the delay in microseconds due to + the most recent XRUN occurrence. The `callback` is supposed to raise :class:`CallbackExit` on error. @@ -1273,7 +1265,7 @@ def set_xrun_callback(self, callback): @self._callback("JackXRunCallback", error=_FAILURE) def callback_wrapper(_): try: - callback(self.xrun_delayed_usecs) + callback(_lib.jack_get_xrun_delayed_usecs(self._ptr)) except CallbackExit: return _FAILURE return _SUCCESS