diff options
author | David Robillard <d@drobilla.net> | 2024-07-17 17:27:04 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-07-17 17:37:07 -0400 |
commit | 7fc7fa33c85017ba21391a9d6d30f88fca952ad3 (patch) | |
tree | 86e53e7d406c7af20a2038ec2a5a8a9020f8eb18 | |
parent | 3b3ff5422167991ce0ad2707c479f5054a565bbd (diff) | |
download | ingen-7fc7fa33c85017ba21391a9d6d30f88fca952ad3.tar.gz ingen-7fc7fa33c85017ba21391a9d6d30f88fca952ad3.tar.bz2 ingen-7fc7fa33c85017ba21391a9d6d30f88fca952ad3.zip |
Avoid use of jack_frame_time()
This seems to be broken on the pipewire implementation of Jack, but we use
FrameTimer for this on other drivers anyway, so just use that for Jack as well
and avoid the issue entirely.
Conveniently also exercises the clock and timestamp DLL code, which as it turns
out, was itself broken.
-rw-r--r-- | src/server/JackDriver.cpp | 11 | ||||
-rw-r--r-- | src/server/JackDriver.hpp | 44 |
2 files changed, 33 insertions, 22 deletions
diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index 0589a021..a2a7f951 100644 --- a/src/server/JackDriver.cpp +++ b/src/server/JackDriver.cpp @@ -21,6 +21,7 @@ #include "BufferRef.hpp" #include "DuplexPort.hpp" #include "Engine.hpp" +#include "FrameTimer.hpp" #include "GraphImpl.hpp" #include "PortType.hpp" #include "RunContext.hpp" @@ -42,6 +43,7 @@ #include "raul/Path.hpp" #include "raul/Semaphore.hpp" +#include <jack/jack.h> #include <jack/midiport.h> #include <jack/transport.h> @@ -126,6 +128,8 @@ JackDriver::attach(const std::string& server_name, register_port(p); } + _timer = std::make_unique<FrameTimer>(_block_length, _sample_rate); + return true; } @@ -459,6 +463,12 @@ JackDriver::append_time_events(RunContext& ctx, Buffer& buffer) static_cast<const uint8_t*>(LV2_ATOM_BODY_CONST(lpos))); } +SampleCount +JackDriver::frame_time() const +{ + return _timer->frame_time(_engine.current_time()) + _engine.block_length(); +} + /**** Jack Callbacks ****/ /** Jack process callback, drives entire audio thread. @@ -481,6 +491,7 @@ JackDriver::_process_cb(jack_nframes_t nframes) _transport_state = jack_transport_query(_client, &_position); + _timer->update(_engine.current_time(), start_of_current_cycle - _engine.block_length()); _engine.locate(start_of_current_cycle, nframes); // Read input diff --git a/src/server/JackDriver.hpp b/src/server/JackDriver.hpp index 28931e9e..e811e9c1 100644 --- a/src/server/JackDriver.hpp +++ b/src/server/JackDriver.hpp @@ -28,10 +28,10 @@ #include <boost/intrusive/options.hpp> #include <boost/intrusive/slist.hpp> -#include <jack/jack.h> -#include <jack/thread.h> #include <jack/types.h> +#include <jack/thread.h> + #include <atomic> #include <cstdint> #include <exception> @@ -51,6 +51,7 @@ namespace server { class Buffer; class DuplexPort; class Engine; +class FrameTimer; class RunContext; /** The Jack Driver. @@ -102,9 +103,7 @@ public: uint32_t seq_size() const override { return _seq_size; } SampleCount sample_rate() const override { return _sample_rate; } - SampleCount frame_time() const override { - return _client ? jack_frame_time(_client) : 0; - } + SampleCount frame_time() const override; class PortRegistrationFailedException : public std::exception {}; @@ -148,23 +147,24 @@ protected: using AudioBufPtr = std::unique_ptr<float, FreeDeleter<float>>; - Engine& _engine; - Ports _ports; - AudioBufPtr _fallback_buffer; - LV2_Atom_Forge _forge; - raul::Semaphore _sem{0}; - std::atomic<bool> _flag{false}; - jack_client_t* _client{nullptr}; - jack_nframes_t _block_length{0}; - uint32_t _seq_size{0}; - jack_nframes_t _sample_rate{0}; - uint32_t _midi_event_type; - bool _is_activated{false}; - jack_position_t _position{}; - jack_transport_state_t _transport_state{}; - double _old_bpm{120.0}; - jack_nframes_t _old_frame{0}; - bool _old_rolling{false}; + Engine& _engine; + Ports _ports; + AudioBufPtr _fallback_buffer; + LV2_Atom_Forge _forge; + raul::Semaphore _sem{0}; + std::unique_ptr<FrameTimer> _timer; + std::atomic<bool> _flag{false}; + jack_client_t* _client{nullptr}; + jack_nframes_t _block_length{0}; + uint32_t _seq_size{0}; + jack_nframes_t _sample_rate{0}; + uint32_t _midi_event_type; + bool _is_activated{false}; + jack_position_t _position{}; + jack_transport_state_t _transport_state{}; + double _old_bpm{120.0}; + jack_nframes_t _old_frame{0}; + bool _old_rolling{false}; }; } // namespace server |