Prepare IOPlug processing as GraphNode

This commit is contained in:
Robin Gareus 2022-05-01 15:57:03 +02:00
parent c45a6b80c7
commit af6f8abdc7
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
5 changed files with 60 additions and 1 deletions

View file

@ -44,6 +44,7 @@ namespace ARDOUR
class GraphNode; class GraphNode;
class Graph; class Graph;
class IOPlug;
class Route; class Route;
class Session; class Session;
class GraphEdges; class GraphEdges;
@ -74,6 +75,7 @@ public:
/* public API for use by session-process */ /* public API for use by session-process */
int process_routes (boost::shared_ptr<GraphChain> chain, pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool& need_butler); int process_routes (boost::shared_ptr<GraphChain> chain, pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool& need_butler);
int routes_no_roll (boost::shared_ptr<GraphChain> chain, pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool non_rt_pending); int routes_no_roll (boost::shared_ptr<GraphChain> chain, pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool non_rt_pending);
int process_io_plugs (boost::shared_ptr<GraphChain> chain, pframes_t nframes, samplepos_t start_sample);
bool in_process_thread () const; bool in_process_thread () const;
uint32_t n_threads () const; uint32_t n_threads () const;
@ -84,6 +86,7 @@ public:
/* called by virtual GraphNode::process() */ /* called by virtual GraphNode::process() */
void process_one_route (Route* route); void process_one_route (Route* route);
void process_one_ioplug (IOPlug*);
protected: protected:
virtual void session_going_away (); virtual void session_going_away ();

View file

@ -28,6 +28,7 @@
#include "ardour/automation_control.h" #include "ardour/automation_control.h"
#include "ardour/buffer_set.h" #include "ardour/buffer_set.h"
#include "ardour/latent.h" #include "ardour/latent.h"
#include "ardour/graphnode.h"
#include "ardour/plugin.h" #include "ardour/plugin.h"
#include "ardour/session_object.h" #include "ardour/session_object.h"
#include "ardour/plug_insert_base.h" #include "ardour/plug_insert_base.h"
@ -41,7 +42,7 @@ namespace ARDOUR {
class IO; class IO;
class ReadOnlyControl; class ReadOnlyControl;
class LIBARDOUR_API IOPlug : public SessionObject, public PlugInsertBase, public Latent class LIBARDOUR_API IOPlug : public SessionObject, public PlugInsertBase, public Latent, public GraphNode
{ {
public: public:
IOPlug (Session&, boost::shared_ptr<Plugin> = boost::shared_ptr<Plugin>(), bool pre = true); IOPlug (Session&, boost::shared_ptr<Plugin> = boost::shared_ptr<Plugin>(), bool pre = true);
@ -92,6 +93,13 @@ public:
/* ControlSet */ /* ControlSet */
boost::shared_ptr<Evoral::Control> control_factory (const Evoral::Parameter& id); boost::shared_ptr<Evoral::Control> control_factory (const Evoral::Parameter& id);
/* GraphNode */
std::string graph_node_name () const {
return name ();
}
bool direct_feeds_according_to_reality (boost::shared_ptr<GraphNode>, bool* via_send_only = 0);
void process ();
protected: protected:
std::string describe_parameter (Evoral::Parameter); std::string describe_parameter (Evoral::Parameter);

View file

@ -2275,6 +2275,7 @@ private:
*/ */
GraphEdges _current_route_graph; GraphEdges _current_route_graph;
friend class IOPlug;
boost::shared_ptr<Graph> _process_graph; boost::shared_ptr<Graph> _process_graph;
boost::shared_ptr<GraphChain> _graph_chain; boost::shared_ptr<GraphChain> _graph_chain;

View file

@ -33,6 +33,7 @@
#include "ardour/audioengine.h" #include "ardour/audioengine.h"
#include "ardour/debug.h" #include "ardour/debug.h"
#include "ardour/graph.h" #include "ardour/graph.h"
#include "ardour/io_plug.h"
#include "ardour/process_thread.h" #include "ardour/process_thread.h"
#include "ardour/route.h" #include "ardour/route.h"
#include "ardour/session.h" #include "ardour/session.h"
@ -477,6 +478,27 @@ Graph::routes_no_roll (boost::shared_ptr<GraphChain> chain, pframes_t nframes, s
return _process_retval; return _process_retval;
} }
int
Graph::process_io_plugs (boost::shared_ptr<GraphChain> chain, pframes_t nframes, samplepos_t start_sample)
{
DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("IOPlug graph execution at %1 for %2\n", start_sample, nframes));
if (g_atomic_int_get (&_terminate)) {
return 0;
}
_graph_chain = chain.get ();
_process_nframes = nframes;
_process_start_sample = start_sample;
DEBUG_TRACE (DEBUG::ProcessThreads, "wake graph for IOPlug processing\n");
_callback_start_sem.signal ();
_callback_done_sem.wait ();
DEBUG_TRACE (DEBUG::ProcessThreads, "graph execution complete\n");
return _process_retval;
}
void void
Graph::process_one_route (Route* route) Graph::process_one_route (Route* route)
{ {
@ -502,6 +524,12 @@ Graph::process_one_route (Route* route)
} }
} }
void
Graph::process_one_ioplug (IOPlug* ioplug)
{
ioplug->run (_process_start_sample, _process_nframes);
}
bool bool
Graph::in_process_thread () const Graph::in_process_thread () const
{ {

View file

@ -25,6 +25,7 @@
#include "ardour/audio_buffer.h" #include "ardour/audio_buffer.h"
#include "ardour/audio_port.h" #include "ardour/audio_port.h"
#include "ardour/event_type_map.h" #include "ardour/event_type_map.h"
#include "ardour/graph.h"
#include "ardour/io.h" #include "ardour/io.h"
#include "ardour/io_plug.h" #include "ardour/io_plug.h"
#include "ardour/lv2_plugin.h" #include "ardour/lv2_plugin.h"
@ -40,6 +41,7 @@ using namespace std;
IOPlug::IOPlug (Session& s, boost::shared_ptr<Plugin> p, bool pre) IOPlug::IOPlug (Session& s, boost::shared_ptr<Plugin> p, bool pre)
: SessionObject (s, "") : SessionObject (s, "")
, GraphNode (s._process_graph)
, _plugin (p) , _plugin (p)
, _pre (pre) , _pre (pre)
, _plugin_signal_latency (0) , _plugin_signal_latency (0)
@ -382,6 +384,12 @@ IOPlug::ensure_io ()
return true; return true;
} }
void
IOPlug::process ()
{
_graph->process_one_ioplug (this);
}
void void
IOPlug::run (samplepos_t start, pframes_t n_samples) IOPlug::run (samplepos_t start, pframes_t n_samples)
{ {
@ -509,6 +517,17 @@ IOPlug::describe_parameter (Evoral::Parameter param)
return EventTypeMap::instance ().to_symbol (param); return EventTypeMap::instance ().to_symbol (param);
} }
bool
IOPlug::direct_feeds_according_to_reality (boost::shared_ptr<GraphNode> node, bool* via_send_only)
{
boost::shared_ptr<IOPlug> other (boost::dynamic_pointer_cast<IOPlug> (node));
assert (other && other->_pre == _pre);
if (via_send_only) {
*via_send_only = false;
}
return other->input()->connected_to (_output);
}
/* ****************************************************************************/ /* ****************************************************************************/
IOPlug::PluginControl::PluginControl (IOPlug* p, IOPlug::PluginControl::PluginControl (IOPlug* p,