diff options
Diffstat (limited to 'src/server/JackDriver.cpp')
-rw-r--r-- | src/server/JackDriver.cpp | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index eafa0fa7..e508c850 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" @@ -28,19 +29,21 @@ #include "ingen_config.h" #include "util.hpp" -#include "ingen/Atom.hpp" -#include "ingen/Configuration.hpp" -#include "ingen/Log.hpp" -#include "ingen/Properties.hpp" -#include "ingen/URI.hpp" -#include "ingen/URIMap.hpp" -#include "ingen/URIs.hpp" -#include "ingen/World.hpp" -#include "lv2/atom/atom.h" -#include "lv2/atom/forge.h" -#include "lv2/atom/util.h" -#include "raul/Path.hpp" - +#include <ingen/Atom.hpp> +#include <ingen/Configuration.hpp> +#include <ingen/Log.hpp> +#include <ingen/Properties.hpp> +#include <ingen/URI.hpp> +#include <ingen/URIMap.hpp> +#include <ingen/URIs.hpp> +#include <ingen/World.hpp> +#include <lv2/atom/atom.h> +#include <lv2/atom/forge.h> +#include <lv2/atom/util.h> +#include <raul/Path.hpp> +#include <raul/Semaphore.hpp> + +#include <jack/jack.h> #include <jack/midiport.h> #include <jack/transport.h> @@ -51,6 +54,7 @@ #include <cassert> #include <chrono> +#include <cstdint> #include <map> #include <string> #include <utility> @@ -108,7 +112,8 @@ JackDriver::attach(const std::string& server_name, _sample_rate = jack_get_sample_rate(_client); _block_length = jack_get_buffer_size(_client); - _seq_size = jack_port_type_get_buffer_size(_client, JACK_DEFAULT_MIDI_TYPE); + _seq_size = static_cast<uint32_t>( + jack_port_type_get_buffer_size(_client, JACK_DEFAULT_MIDI_TYPE)); _fallback_buffer = AudioBufPtr( static_cast<float*>( @@ -123,6 +128,8 @@ JackDriver::attach(const std::string& server_name, register_port(p); } + _timer = std::make_unique<FrameTimer>(_block_length, _sample_rate); + return true; } @@ -256,14 +263,14 @@ void JackDriver::rename_port(const raul::Path& old_path, const raul::Path& new_path) { - EnginePort* eport = get_port(old_path); + const EnginePort* eport = get_port(old_path); if (eport) { #if USE_JACK_PORT_RENAME jack_port_rename(_client, static_cast<jack_port_t*>(eport->handle()), new_path.substr(1).c_str()); #else - jack_port_set_name((jack_port_t*)eport->handle(), + jack_port_set_name(static_cast<jack_port_t*>(eport->handle()), new_path.substr(1).c_str()); #endif } @@ -456,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. @@ -478,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 @@ -519,14 +533,19 @@ JackDriver::_shutdown_cb() int JackDriver::_block_length_cb(jack_nframes_t nframes) { + const URIs& uris = _engine.world().uris(); + if (_engine.root_graph()) { _block_length = nframes; - _seq_size = jack_port_type_get_buffer_size(_client, JACK_DEFAULT_MIDI_TYPE); + _seq_size = static_cast<uint32_t>( + jack_port_type_get_buffer_size(_client, JACK_DEFAULT_MIDI_TYPE)); _engine.root_graph()->set_buffer_size( - _engine.run_context(), *_engine.buffer_factory(), PortType::AUDIO, + _engine.run_context(), *_engine.buffer_factory(), + uris.atom_Sound, _engine.buffer_factory()->audio_buffer_size(nframes)); _engine.root_graph()->set_buffer_size( - _engine.run_context(), *_engine.buffer_factory(), PortType::ATOM, + _engine.run_context(), *_engine.buffer_factory(), + uris.atom_Sequence, _seq_size); } return 0; |