X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fengine_slave.cc;h=451356536aef99189c289bc85b06f58dc0a23726;hb=08d205c533fa3380a97d646b3a50c9f9426f3a80;hp=8b7c3ba510512bf7eb8a031672d28a285ec971a6;hpb=22b07e0233a29d9633ffa825a79503befaf2e16e;p=ardour.git diff --git a/libs/ardour/engine_slave.cc b/libs/ardour/engine_slave.cc index 8b7c3ba510..451356536a 100644 --- a/libs/ardour/engine_slave.cc +++ b/libs/ardour/engine_slave.cc @@ -22,46 +22,113 @@ #include "ardour/audioengine.h" #include "ardour/audio_backend.h" -#include "ardour/slave.h" +#include "ardour/session.h" +#include "ardour/transport_master.h" + +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; -Engine_Slave::Engine_Slave (AudioEngine& e) - : engine (e) +Engine_TransportMaster::Engine_TransportMaster (AudioEngine& e) + : TransportMaster (Engine, X_("JACK")) + , engine (e) + , _starting (false) { - double x; - framepos_t p; - /* call this to initialize things */ - speed_and_position (x, p); + check_backend (); } -Engine_Slave::~Engine_Slave () +Engine_TransportMaster::~Engine_TransportMaster () { } +void +Engine_TransportMaster::init () +{ +} + +void +Engine_TransportMaster::check_backend() +{ + if (AudioEngine::instance()->current_backend_name() == X_("JACK")) { + _connected = true; + } else { + _connected = false; + } +} + bool -Engine_Slave::locked() const +Engine_TransportMaster::locked() const { return true; } bool -Engine_Slave::ok() const +Engine_TransportMaster::ok() const { return true; } +void +Engine_TransportMaster::pre_process (pframes_t, samplepos_t, boost::optional) +{ + /* nothing to do */ +} + bool -Engine_Slave::speed_and_position (double& sp, framepos_t& position) +Engine_TransportMaster::speed_and_position (double& sp, samplepos_t& position, samplepos_t& lp, samplepos_t & when, samplepos_t now) { boost::shared_ptr backend = engine.current_backend(); - if (backend) { - _starting = backend->speed_and_position (sp, position); - } else { - _starting = false; + /* 3rd argument (now) doesn't matter here because we're always being + * called synchronously with the engine. + */ + + if (backend && backend->speed_and_position (sp, position)) { + return true; + } + + lp = now; + when = now; + + _current_delta = 0; + + return false; +} + +std::string +Engine_TransportMaster::position_string () const +{ + if (_session) { + return PBD::to_string (_session->audible_sample()); + } + + return std::string(); +} + +std::string +Engine_TransportMaster::delta_string () const +{ + return string ("0"); +} + +bool +Engine_TransportMaster::allow_request (TransportRequestSource src, TransportRequestType type) const +{ + if (_session) { + if (_session->config.get_jack_time_master()) { + return true; + } else { + return false; + } } return true; } + +samplecnt_t +Engine_TransportMaster::update_interval () const +{ + return AudioEngine::instance()->samples_per_cycle(); +} +