summaryrefslogtreecommitdiff
path: root/drumgizmo/jackclient.cc
diff options
context:
space:
mode:
Diffstat (limited to 'drumgizmo/jackclient.cc')
-rw-r--r--drumgizmo/jackclient.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/drumgizmo/jackclient.cc b/drumgizmo/jackclient.cc
index e493e1b..fb71b1b 100644
--- a/drumgizmo/jackclient.cc
+++ b/drumgizmo/jackclient.cc
@@ -57,6 +57,12 @@ int JackClient::wrapJackProcess(jack_nframes_t nframes, void* arg)
return static_cast<JackClient*>(arg)->process(nframes);
}
+void JackClient::latencyCallback(jack_latency_callback_mode_t mode,
+ void* arg)
+{
+ static_cast<JackClient*>(arg)->jackLatencyCallback(mode);
+}
+
JackClient::JackClient()
: client{nullptr}
, processes{}
@@ -65,6 +71,12 @@ JackClient::JackClient()
jack_status_t status;
client = jack_client_open("DrumGizmo", JackNullOption, &status);
jack_set_process_callback(client, JackClient::wrapJackProcess, this);
+
+ // Register callback which is called by jack when it wants to know about the
+ // current port latency.
+ jack_set_latency_callback(client,
+ JackClient::latencyCallback,
+ this);
}
JackClient::~JackClient()
@@ -103,6 +115,14 @@ int JackClient::process(jack_nframes_t num_frames)
return 0;
}
+void JackClient::jackLatencyCallback(jack_latency_callback_mode_t mode)
+{
+ for(auto& ptr : processes)
+ {
+ ptr->jackLatencyCallback(mode);
+ }
+}
+
std::size_t JackClient::getBufferSize() const
{
return jack_get_buffer_size(client);