ardour
graph.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 Paul Davis
3  Author: Torben Hohn
4 
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.
9 
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.
14 
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.
18 */
19 
20 
21 #ifndef __ardour_graph_h__
22 #define __ardour_graph_h__
23 
24 #include <list>
25 #include <set>
26 #include <vector>
27 #include <string>
28 
29 #include <boost/shared_ptr.hpp>
30 
31 #include <glib.h>
32 
33 #include "pbd/semutils.h"
34 
36 #include "ardour/types.h"
37 #include "ardour/audio_backend.h"
38 #include "ardour/session_handle.h"
39 
40 namespace ARDOUR
41 {
42 
43 class GraphNode;
44 class Graph;
45 
46 class Route;
47 class Session;
48 class GraphEdges;
49 
51 
52 typedef std::list< node_ptr_t > node_list_t;
53 typedef std::set< node_ptr_t > node_set_t;
54 
56 {
57 public:
58  Graph (Session & session);
59 
60  void prep();
61  void trigger (GraphNode * n);
62  void rechain (boost::shared_ptr<RouteList>, GraphEdges const &);
63 
64  void dump (int chain);
65  void process();
66  void dec_ref();
67  void restart_cycle();
68 
69  bool run_one();
70  void helper_thread();
71  void main_thread();
72 
73  int silent_process_routes (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
74  bool& need_butler);
75 
76  int process_routes (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick,
77  bool& need_butler);
78 
79  int routes_no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
80  bool non_rt_pending, int declick);
81 
82  void process_one_route (Route * route);
83 
84  void clear_other_chain ();
85 
86  bool in_process_thread () const;
87 
88 protected:
89  virtual void session_going_away ();
90 
91 private:
92  volatile bool _threads_active;
93 
94  void reset_thread_list ();
95  void drop_threads ();
96 
97  node_list_t _nodes_rt[2];
98 
99  node_list_t _init_trigger_list[2];
100 
101  std::vector<GraphNode *> _trigger_queue;
102  pthread_mutex_t _trigger_mutex;
103 
105 
110 
112  volatile gint _execution_tokens;
114  volatile gint _finished_refcount;
116  volatile gint _init_finished_refcount[2];
117 
119 
120  // chain swapping
121  Glib::Threads::Mutex _swap_mutex;
122  Glib::Threads::Cond _cleanup_cond;
123  volatile int _current_chain;
124  volatile int _pending_chain;
125  volatile int _setup_chain;
126 
127  // parameter caches.
134 
139 
140  // enginer / thread connection
142  void engine_stopped ();
143 };
144 
145 } // namespace
146 
147 #endif /* __ardour_graph_h__ */
PBD::ProcessSemaphore _cleanup_sem
Definition: graph.h:109
framepos_t _process_start_frame
Definition: graph.h:129
volatile bool _threads_active
Definition: graph.h:92
volatile int _setup_chain
Definition: graph.h:125
PBD::ProcessSemaphore _callback_start_sem
Definition: graph.h:107
bool _graph_empty
Definition: graph.h:118
uint32_t pframes_t
Definition: types.h:61
int _process_declick
Definition: graph.h:133
int _process_retval
Definition: graph.h:137
framepos_t _process_end_frame
Definition: graph.h:130
bool _process_non_rt_pending
Definition: graph.h:132
Glib::Threads::Cond _cleanup_cond
Definition: graph.h:122
volatile gint _execution_tokens
Definition: graph.h:112
PBD::ScopedConnectionList engine_connections
Definition: graph.h:141
bool _process_need_butler
Definition: graph.h:138
Definition: amp.h:29
Glib::Threads::Mutex _swap_mutex
Definition: graph.h:121
bool _process_noroll
Definition: graph.h:136
int64_t framepos_t
Definition: types.h:66
LIBARDOUR_API uint64_t Graph
Definition: graphnode.h:54
pframes_t _process_nframes
Definition: graph.h:128
PBD::ProcessSemaphore _callback_done_sem
Definition: graph.h:108
PBD::ProcessSemaphore _execution_sem
Definition: graph.h:104
bool _process_silent
Definition: graph.h:135
bool _process_can_record
Definition: graph.h:131
boost::shared_ptr< GraphNode > node_ptr_t
Definition: graph.h:48
#define LIBARDOUR_API
std::vector< GraphNode * > _trigger_queue
Definition: graph.h:101
volatile int _current_chain
Definition: graph.h:123
std::list< node_ptr_t > node_list_t
Definition: graph.h:52
volatile int _pending_chain
Definition: graph.h:124
volatile gint _finished_refcount
Definition: graph.h:114
A node in the hierarchical graph that represents a multiplicatable export item.
std::set< node_ptr_t > node_set_t
Definition: graph.h:53
pthread_mutex_t _trigger_mutex
Definition: graph.h:102