2 Copyright (C) 2010 Paul Davis
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __ardour_graph_h__
22 #define __ardour_graph_h__
29 #include <boost/shared_ptr.hpp>
34 #include "pbd/semutils.h"
36 #include "ardour/types.h"
37 #include "ardour/audio_backend.h"
38 #include "ardour/session_handle.h"
50 class AudioBackendThread;
52 typedef boost::shared_ptr<GraphNode> node_ptr_t;
54 typedef std::list< node_ptr_t > node_list_t;
55 typedef std::set< node_ptr_t > node_set_t;
57 class Graph : public SessionHandleRef
60 Graph (Session & session);
62 uint32_t threads_in_use () const { return _thread_list.size(); }
65 void trigger (GraphNode * n);
66 void rechain (boost::shared_ptr<RouteList>, GraphEdges const &);
68 void dump (int chain);
77 int silent_process_routes (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
80 int process_routes (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick,
83 int routes_no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
84 bool non_rt_pending, int declick);
86 void process_one_route (Route * route);
88 void clear_other_chain ();
90 bool in_process_thread () const;
93 virtual void session_going_away ();
96 std::list<AudioBackendThread*> _thread_list;
97 volatile bool _quit_threads;
99 void reset_thread_list ();
100 void drop_threads ();
102 node_list_t _nodes_rt[2];
104 node_list_t _init_trigger_list[2];
106 std::vector<GraphNode *> _trigger_queue;
107 pthread_mutex_t _trigger_mutex;
109 PBD::ProcessSemaphore _execution_sem;
111 /** Signalled to start a run of the graph for a process callback */
112 PBD::ProcessSemaphore _callback_start_sem;
113 PBD::ProcessSemaphore _callback_done_sem;
114 PBD::ProcessSemaphore _cleanup_sem;
116 /** The number of processing threads that are asleep */
117 volatile gint _execution_tokens;
118 /** The number of unprocessed nodes that do not feed any other node; updated during processing */
119 volatile gint _finished_refcount;
120 /** The initial number of nodes that do not feed any other node (for each chain) */
121 volatile gint _init_finished_refcount[2];
126 Glib::Threads::Mutex _swap_mutex;
127 Glib::Threads::Cond _cleanup_cond;
128 volatile int _current_chain;
129 volatile int _pending_chain;
130 volatile int _setup_chain;
133 pframes_t _process_nframes;
134 framepos_t _process_start_frame;
135 framepos_t _process_end_frame;
136 bool _process_can_record;
137 bool _process_non_rt_pending;
138 int _process_declick;
140 bool _process_silent;
141 bool _process_noroll;
143 bool _process_need_butler;
148 #endif /* __ardour_graph_h__ */