summaryrefslogtreecommitdiff
path: root/jack
diff options
context:
space:
mode:
authortorben <torben@0c269be4-1314-0410-8aa9-9f06e86f4224>2011-01-12 01:35:47 +0000
committertorben <torben@0c269be4-1314-0410-8aa9-9f06e86f4224>2011-01-12 01:35:47 +0000
commit6a76e7ba49a5c7b528f5c39c67e98c7486de8823 (patch)
treebe227c5fbc83fef92937a51c73968fa82049130d /jack
parent81705fc63ba757968768a65bf6c72fa88f086c54 (diff)
downloadjack1-6a76e7ba49a5c7b528f5c39c67e98c7486de8823.tar.gz
[latency api] Add the new latency api.
This commit adds jack_port_set_latency_range() jack_port_get_latency_range() jack_set_latency_callback() It also extends jack_port_set_latency() to set the playback or capture latency range of the port. git-svn-id: svn+ssh://jackaudio.org/trunk/jack@4098 0c269be4-1314-0410-8aa9-9f06e86f4224
Diffstat (limited to 'jack')
-rw-r--r--jack/internal.h4
-rw-r--r--jack/jack.h22
-rw-r--r--jack/port.h2
-rw-r--r--jack/types.h54
4 files changed, 81 insertions, 1 deletions
diff --git a/jack/internal.h b/jack/internal.h
index c6107c8..c2009e7 100644
--- a/jack/internal.h
+++ b/jack/internal.h
@@ -219,7 +219,8 @@ typedef enum {
StopFreewheel,
ClientRegistered,
ClientUnregistered,
- SaveSession
+ SaveSession,
+ LatencyCallback
} JackEventType;
typedef struct {
@@ -298,6 +299,7 @@ typedef volatile struct {
volatile uint8_t client_register_cbset;
volatile uint8_t thread_cb_cbset;
volatile uint8_t session_cbset;
+ volatile uint8_t latency_cbset;
} POST_PACKED_STRUCTURE jack_client_control_t;
diff --git a/jack/jack.h b/jack/jack.h
index c80f879..f634a8b 100644
--- a/jack/jack.h
+++ b/jack/jack.h
@@ -406,6 +406,16 @@ int jack_set_graph_order_callback (jack_client_t *,
*/
int jack_set_xrun_callback (jack_client_t *,
JackXRunCallback xrun_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT;
+
+/**
+ * Tell the JACK server to call @a latency_callback whenever the
+ * port latencies need to be recalculated.
+ *
+ * @return 0 on success, otherwise a non-zero error code
+ */
+int jack_set_latency_callback (jack_client_t *,
+ JackLatencyCallback latency_callback,
+ void *) JACK_WEAK_EXPORT;
/*@}*/
/**
@@ -691,6 +701,18 @@ jack_nframes_t jack_port_get_total_latency (jack_client_t *,
void jack_port_set_latency (jack_port_t *, jack_nframes_t) JACK_OPTIONAL_WEAK_EXPORT;
/**
+ * get the new latency, either capture latency or playback latency.
+ * this is normally used in the LatencyCallback.
+ * and therefor safe to execute from callbacks.
+ */
+void jack_port_get_latency_range (jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range) JACK_WEAK_EXPORT;
+
+/**
+ * set the new latency, either capture latency or playback latency.
+ */
+void jack_port_set_latency_range (jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range) JACK_WEAK_EXPORT;
+
+/**
* Request a complete recomputation of a port's total latency. This
* can be called by a client that has just changed the internal
* latency of its port using jack_port_set_latency
diff --git a/jack/port.h b/jack/port.h
index 796a19a..4447f74 100644
--- a/jack/port.h
+++ b/jack/port.h
@@ -121,6 +121,8 @@ typedef struct _jack_port_shared {
volatile jack_nframes_t latency;
volatile jack_nframes_t total_latency;
+ volatile jack_latency_range_t playback_latency;
+ volatile jack_latency_range_t capture_latency;
volatile uint8_t monitor_requests;
char has_mixdown; /* port has a mixdown function */
diff --git a/jack/types.h b/jack/types.h
index 91d2523..859d693 100644
--- a/jack/types.h
+++ b/jack/types.h
@@ -220,6 +220,60 @@ enum JackStatus {
typedef enum JackStatus jack_status_t;
/**
+ * @ref jack_latency_callback_mode_t
+ */
+enum JackLatencyCallbackMode {
+
+ /**
+ * Latency Callback for Capture Latency.
+ * Input Ports have their latency value setup.
+ * In the Callback the client needs to set the latency of the output ports
+ */
+ JackCaptureLatency,
+
+ /**
+ * Latency Callback for Playback Latency.
+ * Output Ports have their latency value setup.
+ * In the Callback the client needs to set the latency of the input ports
+ */
+ JackPlaybackLatency
+
+};
+
+/**
+ * Type of Latency Callback (Capture or Playback)
+ */
+typedef enum JackLatencyCallbackMode jack_latency_callback_mode_t;
+
+/**
+ * Prototype for the client supplied function that is called
+ * by the engine when port latencies need to be recalculated
+ *
+ * @param mode playback or capture latency
+ * @param arg pointer to a client supplied data
+ *
+ * @return zero on success, non-zero on error
+ */
+typedef int (*JackLatencyCallback)(jack_latency_callback_mode_t mode, void *arg);
+
+/**
+ * the new latency API operates on Ranges.
+ */
+struct _jack_latency_range
+{
+ /**
+ * minimum latency
+ */
+ jack_nframes_t min;
+ /**
+ * maximum latency
+ */
+ jack_nframes_t max;
+};
+
+typedef struct _jack_latency_range jack_latency_range_t;
+
+/**
* Prototype for the client supplied function that is called
* by the engine anytime there is work to be done.
*