summaryrefslogtreecommitdiff
path: root/drumgizmo/jackclient.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-07-13 11:25:59 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-07-13 11:25:59 +0200
commit633bac9e82aef192a803666aaf3d3dcff920ac0c (patch)
treeb4b253162c0dcdbace27807e11e5915ebce1cfab /drumgizmo/jackclient.cc
parent7557e5d1713337f4acc3f531e5b88a1195476eec (diff)
Use the latency reported by the engine in the jack and wavfile output modules.
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);