Beast - Music Synthesizer and Composer  0.11.1+10.g2da35
bseenginenode.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __BSE_ENGINE_NODE_H__
3 #define __BSE_ENGINE_NODE_H__
4 
5 #include "bseengine.hh"
6 #include "gslcommon.hh"
7 
8 #define ENGINE_NODE(module) ((EngineNode*) (module))
9 #define ENGINE_NODE_N_OSTREAMS(node) ((node)->module.klass->n_ostreams)
10 #define ENGINE_NODE_N_ISTREAMS(node) ((node)->module.klass->n_istreams)
11 #define ENGINE_NODE_N_JSTREAMS(node) ((node)->module.klass->n_jstreams)
12 #define ENGINE_NODE_IS_CONSUMER(node) ((node)->is_consumer && \
13  (node)->output_nodes == NULL)
14 #define ENGINE_NODE_IS_INTEGRATED(node) ((node)->integrated)
15 #define ENGINE_NODE_IS_VIRTUAL(node) ((node)->virtual_node)
16 #define ENGINE_NODE_IS_SUSPENDED(nod,s) ((s) < (nod)->next_active)
17 #define ENGINE_NODE_IS_DEFERRED(node) (FALSE)
18 #define ENGINE_NODE_IS_SCHEDULED(node) (ENGINE_NODE (node)->sched_tag)
19 #define ENGINE_NODE_IS_CHEAP(node) (((node)->module.klass->mflags & BSE_COST_CHEAP) != 0)
20 #define ENGINE_NODE_IS_EXPENSIVE(node) (((node)->module.klass->mflags & BSE_COST_EXPENSIVE) != 0)
21 #define ENGINE_NODE_LOCK(node) (node)->rec_mutex.lock()
22 #define ENGINE_NODE_UNLOCK(node) (node)->rec_mutex.unlock()
23 #define ENGINE_MODULE_IS_VIRTUAL(mod) (ENGINE_NODE_IS_VIRTUAL (ENGINE_NODE (mod)))
24 
25 
26 /* --- typedefs --- */
27 typedef struct _EngineNode EngineNode;
28 typedef struct _EngineSchedule EngineSchedule;
29 
30 /* --- transactions --- */
31 typedef union _EngineTimedJob EngineTimedJob;
32 typedef enum /*< skip >*/
33 {
34  ENGINE_JOB_NOP,
35  ENGINE_JOB_SYNC,
36  ENGINE_JOB_INTEGRATE,
37  ENGINE_JOB_DISCARD,
38  ENGINE_JOB_ICONNECT,
39  ENGINE_JOB_JCONNECT,
40  ENGINE_JOB_IDISCONNECT,
41  ENGINE_JOB_JDISCONNECT,
42  ENGINE_JOB_KILL_INPUTS,
43  ENGINE_JOB_KILL_OUTPUTS,
44  ENGINE_JOB_SET_CONSUMER,
45  ENGINE_JOB_UNSET_CONSUMER,
46  ENGINE_JOB_FORCE_RESET,
47  ENGINE_JOB_ACCESS,
48  ENGINE_JOB_SUSPEND,
49  ENGINE_JOB_RESUME,
50  ENGINE_JOB_ADD_POLL,
51  ENGINE_JOB_REMOVE_POLL,
52  ENGINE_JOB_ADD_TIMER,
53  ENGINE_JOB_PROBE_JOB,
54  ENGINE_JOB_FLOW_JOB,
55  ENGINE_JOB_BOUNDARY_JOB,
56  ENGINE_JOB_MESSAGE,
57  ENGINE_JOB_LAST
58 } EngineJobType;
59 struct _BseJob
60 {
61  EngineJobType job_id;
62  BseJob *next;
63  union {
64  struct {
65  EngineNode *node;
66  gboolean free_with_job;
67  gchar *message;
68  } data;
69  struct {
70  Bse::Mutex *lock_mutex;
71  Bse::Cond *lock_cond;
72  gboolean *lock_p;
73  } sync;
74  struct {
75  EngineNode *node;
76  guint64 stamp;
77  } tick;
78  struct {
79  EngineNode *dest_node;
80  guint dest_ijstream;
81  EngineNode *src_node;
82  guint src_ostream;
83  } connection;
84  struct {
85  EngineNode *node;
86  BseEngineAccessFunc access_func;
87  gpointer data;
88  BseFreeFunc free_func;
89  } access;
90  struct {
91  BseEnginePollFunc poll_func;
92  gpointer data;
93  BseFreeFunc free_func;
94  guint n_fds;
95  GPollFD *fds;
96  } poll;
97  struct {
98  BseEngineTimerFunc timer_func;
99  gpointer data;
100  BseFreeFunc free_func;
101  } timer;
102  struct {
103  EngineNode *node;
104  EngineTimedJob *tjob;
105  } timed_job;
106  };
107 };
108 struct _BseTrans
109 {
110  BseJob *jobs_head;
111  BseJob *jobs_tail;
112  guint comitted : 1;
113  BseTrans *cqt_next; /* com-thread-queue */
114 };
116 {
117  struct {
118  EngineJobType type; /* common */
119  EngineTimedJob *next; /* common */
120  guint64 tick_stamp; /* common */
121  };
122  struct {
123  EngineJobType type; /* common */
124  EngineTimedJob *next; /* common */
125  guint64 tick_stamp; /* common */
126  gpointer data;
127  BseEngineProbeFunc probe_func;
128  BseOStream *ostreams;
129  guint n_ostreams;
130  } probe;
131  struct {
132  EngineJobType type; /* common */
133  EngineTimedJob *next; /* common */
134  guint64 tick_stamp; /* common */
135  gpointer data;
136  BseFreeFunc free_func;
137  BseEngineAccessFunc access_func;
138  } access;
139 };
140 
141 
142 /* --- module nodes --- */
143 typedef struct
144 {
145  EngineNode *src_node;
146  guint src_stream; /* ostream of src_node */
147  /* valid if istream[].connected, setup by scheduler */
148  EngineNode *real_node; /* set to NULL if !connected */
149  guint real_stream; /* ostream of real_node */
150 } EngineInput;
151 typedef struct
152 {
153  EngineNode *src_node;
154  guint src_stream; /* ostream of src_node */
155  /* valid if < jstream[].n_connections, setup by scheduler */
156  EngineNode *real_node;
157  guint real_stream; /* ostream of real_node */
158 } EngineJInput;
159 typedef struct
160 {
161  gfloat *buffer;
162  guint n_outputs;
163 } EngineOutput;
164 struct _EngineNode /* fields sorted by order of processing access */
165 {
166  BseModule module;
167  Bse::Mutex rec_mutex; /* processing lock */
168  guint64 counter; /* <= Bse::TickStamp::current() */
169  EngineInput *inputs; /* [ENGINE_NODE_N_ISTREAMS()] */
170  EngineJInput **jinputs; /* [ENGINE_NODE_N_JSTREAMS()][jstream->jcount] */
171  EngineOutput *outputs; /* [ENGINE_NODE_N_OSTREAMS()] */
172  /* timed jobs */
173  EngineTimedJob *flow_jobs; /* active jobs */
174  EngineTimedJob *probe_jobs; /* probe requests */
175  EngineTimedJob *boundary_jobs; /* active jobs */
176  EngineTimedJob *tjob_head, *tjob_tail; /* trash list */
177  /* suspend/activation time */
178  guint64 next_active; /* result of suspend state updates */
179  /* master-node-list */
180  EngineNode *mnl_next;
181  EngineNode *mnl_prev;
182  guint integrated : 1;
183  guint virtual_node : 1;
184  guint is_consumer : 1;
185  /* suspension */
186  guint update_suspend : 1; /* whether suspend state needs updating */
187  guint in_suspend_call : 1; /* recursion barrier during suspend state updates */
188  guint needs_reset : 1; /* flagged at resumption */
189  /* scheduler */
190  guint cleared_ostreams : 1; /* whether ostream[].connected was cleared already */
191  guint sched_tag : 1; /* whether this node is contained in the schedule */
192  guint sched_recurse_tag : 1; /* recursion flag used during scheduling */
193  guint sched_leaf_level;
194  guint64 local_active; /* local suspend state stamp */
195  EngineNode *toplevel_next; /* master-consumer-list, FIXME: overkill, using a SfiRing is good enough */
196  SfiRing *output_nodes; /* EngineNode* ring of nodes in ->outputs[] */
197 };
198 
199 #endif /* __BSE_ENGINE_NODE_H__ */
void(* BseEngineProbeFunc)(gpointer data, guint n_values, guint64 tick_stamp, guint n_ostreams, BseOStream **ostreams_p)
Definition: bseengine.hh:36
Definition: bseenginenode.hh:143
Definition: bseenginenode.hh:159
Definition: bseenginenode.hh:59
Definition: bseengineschedule.hh:19
void(* BseEngineAccessFunc)(BseModule *module, gpointer data)
Definition: bsedefs.hh:130
Definition: bseenginenode.hh:151
Definition: bseenginenode.hh:164
Definition: sfiring.hh:21
Definition: bseenginenode.hh:108
gboolean(* BseEnginePollFunc)(gpointer data, guint n_values, glong *timeout_p, guint n_fds, const GPollFD *fds, gboolean revents_filled)
Definition: bseengine.hh:28
access
Definition: bseenginenode.hh:115