Prepare IOPlug processing as GraphNode

This commit is contained in:
Robin Gareus 2022-05-01 15:57:03 +02:00
parent c45a6b80c7
commit af6f8abdc7
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
5 changed files with 60 additions and 1 deletions

View File

@ -44,6 +44,7 @@ namespace ARDOUR
class GraphNode;
class Graph;
class IOPlug;
class Route;
class Session;
class GraphEdges;
@ -74,6 +75,7 @@ public:
/* 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 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;
uint32_t n_threads () const;
@ -84,6 +86,7 @@ public:
/* called by virtual GraphNode::process() */
void process_one_route (Route* route);
void process_one_ioplug (IOPlug*);
protected:
virtual void session_going_away ();

View File

@ -28,6 +28,7 @@
#include "ardour/automation_control.h"
#include "ardour/buffer_set.h"
#include "ardour/latent.h"
#include "ardour/graphnode.h"
#include "ardour/plugin.h"
#include "ardour/session_object.h"
#include "ardour/plug_insert_base.h"
@ -41,7 +42,7 @@ namespace ARDOUR {
class IO;
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:
IOPlug (Session&, boost::shared_ptr<Plugin> = boost::shared_ptr<Plugin>(), bool pre = true);
@ -92,6 +93,13 @@ public:
/* ControlSet */
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:
std::string describe_parameter (Evoral::Parameter);

View File

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

View File

@ -33,6 +33,7 @@
#include "ardour/audioengine.h"
#include "ardour/debug.h"
#include "ardour/graph.h"
#include "ardour/io_plug.h"
#include "ardour/process_thread.h"
#include "ardour/route.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;
}
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
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
Graph::in_process_thread () const
{

View File

@ -25,6 +25,7 @@
#include "ardour/audio_buffer.h"
#include "ardour/audio_port.h"
#include "ardour/event_type_map.h"
#include "ardour/graph.h"
#include "ardour/io.h"
#include "ardour/io_plug.h"
#include "ardour/lv2_plugin.h"
@ -40,6 +41,7 @@ using namespace std;
IOPlug::IOPlug (Session& s, boost::shared_ptr<Plugin> p, bool pre)
: SessionObject (s, "")
, GraphNode (s._process_graph)
, _plugin (p)
, _pre (pre)
, _plugin_signal_latency (0)
@ -382,6 +384,12 @@ IOPlug::ensure_io ()
return true;
}
void
IOPlug::process ()
{
_graph->process_one_ioplug (this);
}
void
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);
}
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,