diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-07-13 11:25:59 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-07-13 11:25:59 +0200 |
commit | 633bac9e82aef192a803666aaf3d3dcff920ac0c (patch) | |
tree | b4b253162c0dcdbace27807e11e5915ebce1cfab /drumgizmo/output/jackaudio.cc | |
parent | 7557e5d1713337f4acc3f531e5b88a1195476eec (diff) |
Use the latency reported by the engine in the jack and wavfile output modules.
Diffstat (limited to 'drumgizmo/output/jackaudio.cc')
-rw-r--r-- | drumgizmo/output/jackaudio.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/drumgizmo/output/jackaudio.cc b/drumgizmo/output/jackaudio.cc index abd7d4f..75766d1 100644 --- a/drumgizmo/output/jackaudio.cc +++ b/drumgizmo/output/jackaudio.cc @@ -33,6 +33,7 @@ JackAudioOutputEngine::JackAudioOutputEngine(JackClient& client) : AudioOutputEngine{} , client(client) , channels{} + , latency{0} { client.add(*this); } @@ -122,6 +123,11 @@ size_t JackAudioOutputEngine::getSamplerate() const return client.getSampleRate(); } +void JackAudioOutputEngine::onLatencyChange(std::size_t latency) +{ + this->latency = latency; +} + JackAudioOutputEngine::Channel::Channel(JackClient& client, const std::string& name, std::size_t buffer_size) @@ -130,3 +136,33 @@ JackAudioOutputEngine::Channel::Channel(JackClient& client, { samples.resize(buffer_size); } + +void JackAudioOutputEngine::jackLatencyCallback(jack_latency_callback_mode_t mode) +{ + jack_latency_range_t range; + switch(mode) + { + case JackCaptureLatency: + // We do not have any audio input ports. Use this for when we do... +// jack_port_get_latency_range(port_feeding_input_port, +// JackPlaybackLatency, +// &range); +// range.min += 0; +// range.max += 0; +// jack_port_set_latency_range(input_port, JackPlaybackLatency, &range); + break; + case JackPlaybackLatency: + for(auto& channel : channels) + { + jack_port_get_latency_range(channel.port.port, + JackPlaybackLatency, + &range); + range.min += latency; + range.max += latency; + jack_port_set_latency_range(channel.port.port, + JackPlaybackLatency, + &range); + } + break; + } +} |