bt2: add bt2.get_{greatest_operative,maximal}_mip_version()
[babeltrace.git] / src / lib / graph / graph.c
CommitLineData
c0418dd9 1/*
e2f7325d 2 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
f60c8b34 3 * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
c0418dd9
JG
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
350ad6c1 24#define BT_LOG_TAG "LIB/GRAPH"
c2d9d9cf 25#include "lib/logging.h"
262e5473 26
578e048b
MJ
27#include "common/assert.h"
28#include "lib/assert-pre.h"
f6f301d7 29#include "lib/assert-post.h"
3fadfbc0
MJ
30#include <babeltrace2/graph/graph.h>
31#include <babeltrace2/graph/graph-const.h>
3fadfbc0
MJ
32#include <babeltrace2/graph/component-source-const.h>
33#include <babeltrace2/graph/component-filter-const.h>
34#include <babeltrace2/graph/port-const.h>
578e048b
MJ
35#include "lib/graph/message/message.h"
36#include "compat/compiler.h"
37#include "common/common.h"
3fadfbc0
MJ
38#include <babeltrace2/types.h>
39#include <babeltrace2/value.h>
40#include <babeltrace2/value-const.h>
578e048b 41#include "lib/value.h"
f60c8b34 42#include <unistd.h>
1bf957a0
PP
43#include <glib.h>
44
078033ed 45#include "component-class-sink-simple.h"
578e048b
MJ
46#include "component.h"
47#include "component-sink.h"
48#include "connection.h"
49#include "graph.h"
9b4f9b42 50#include "interrupter.h"
578e048b
MJ
51#include "message/event.h"
52#include "message/packet.h"
53
d24d5663
PP
54typedef enum bt_graph_listener_func_status
55(*port_added_func_t)(const void *, const void *, void *);
0d72b8c3 56
d24d5663
PP
57typedef enum bt_graph_listener_func_status
58(*ports_connected_func_t)(const void *, const void *, const void *,
0d72b8c3 59 const void *, void *);
d94d92ac 60
d24d5663
PP
61typedef enum bt_component_class_init_method_status
62(*comp_init_method_t)(const void *, const void *, void *);
63
1bf957a0 64struct bt_graph_listener {
0d72b8c3 65 bt_graph_listener_removed_func removed;
1bf957a0
PP
66 void *data;
67};
c0418dd9 68
d94d92ac
PP
69struct bt_graph_listener_port_added {
70 struct bt_graph_listener base;
71 port_added_func_t func;
72};
8cc092c9 73
d94d92ac
PP
74struct bt_graph_listener_ports_connected {
75 struct bt_graph_listener base;
76 ports_connected_func_t func;
77};
8cc092c9 78
d94d92ac
PP
79#define INIT_LISTENERS_ARRAY(_type, _listeners) \
80 do { \
81 _listeners = g_array_new(FALSE, TRUE, sizeof(_type)); \
82 if (!(_listeners)) { \
870631a2
PP
83 BT_LIB_LOGE_APPEND_CAUSE( \
84 "Failed to allocate one GArray."); \
d94d92ac
PP
85 } \
86 } while (0)
87
88#define CALL_REMOVE_LISTENERS(_type, _listeners) \
89 do { \
90 size_t i; \
91 \
9fde7203
FD
92 if (!_listeners) { \
93 break; \
94 } \
d94d92ac
PP
95 for (i = 0; i < (_listeners)->len; i++) { \
96 _type *listener = \
97 &g_array_index((_listeners), _type, i); \
98 \
99 if (listener->base.removed) { \
100 listener->base.removed(listener->base.data); \
101 } \
102 } \
103 } while (0)
8cc092c9 104
f60c8b34 105static
d94d92ac 106void destroy_graph(struct bt_object *obj)
c0418dd9 107{
0d72b8c3 108 struct bt_graph *graph = container_of(obj, struct bt_graph, base);
c0418dd9 109
bd14d768
PP
110 /*
111 * The graph's reference count is 0 if we're here. Increment
112 * it to avoid a double-destroy (possibly infinitely recursive)
113 * in this situation:
114 *
115 * 1. We put and destroy a connection.
d0fea130
PP
116 * 2. This connection's destructor finalizes its active message
117 * iterators.
118 * 3. A message iterator's finalization function gets a new
119 * reference on its component (reference count goes from 0 to
120 * 1).
bd14d768
PP
121 * 4. Since this component's reference count goes to 1, it takes
122 * a reference on its parent (this graph). This graph's
123 * reference count goes from 0 to 1.
d6e69534 124 * 5. The message iterator's finalization function puts its
bd14d768
PP
125 * component reference (reference count goes from 1 to 0).
126 * 6. Since this component's reference count goes from 1 to 0,
127 * it puts its parent (this graph). This graph's reference
128 * count goes from 1 to 0.
d0fea130
PP
129 * 7. Since this graph's reference count goes from 1 to 0, its
130 * destructor is called (this function).
bd14d768
PP
131 *
132 * With the incrementation below, the graph's reference count at
133 * step 4 goes from 1 to 2, and from 2 to 1 at step 6. This
134 * ensures that this function is not called two times.
135 */
3f7d4d90 136 BT_LIB_LOGI("Destroying graph: %!+g", graph);
3fea54f6 137 obj->ref_count++;
9b4f9b42 138 graph->config_state = BT_GRAPH_CONFIGURATION_STATE_DESTROYING;
49682acd 139
8cc092c9 140 /* Call all remove listeners */
d94d92ac
PP
141 CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_added,
142 graph->listeners.source_output_port_added);
143 CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_added,
144 graph->listeners.filter_output_port_added);
145 CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_added,
146 graph->listeners.filter_input_port_added);
147 CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_added,
148 graph->listeners.sink_input_port_added);
d94d92ac
PP
149 CALL_REMOVE_LISTENERS(struct bt_graph_listener_ports_connected,
150 graph->listeners.source_filter_ports_connected);
9c0a126a
PP
151 CALL_REMOVE_LISTENERS(struct bt_graph_listener_ports_connected,
152 graph->listeners.filter_filter_ports_connected);
d94d92ac
PP
153 CALL_REMOVE_LISTENERS(struct bt_graph_listener_ports_connected,
154 graph->listeners.source_sink_ports_connected);
155 CALL_REMOVE_LISTENERS(struct bt_graph_listener_ports_connected,
156 graph->listeners.filter_sink_ports_connected);
8cc092c9 157
d6e69534
PP
158 if (graph->messages) {
159 g_ptr_array_free(graph->messages, TRUE);
160 graph->messages = NULL;
5c563278
PP
161 }
162
c0418dd9 163 if (graph->connections) {
262e5473 164 BT_LOGD_STR("Destroying connections.");
c0418dd9 165 g_ptr_array_free(graph->connections, TRUE);
d94d92ac 166 graph->connections = NULL;
c0418dd9 167 }
5c563278 168
bd14d768 169 if (graph->components) {
262e5473 170 BT_LOGD_STR("Destroying components.");
bd14d768 171 g_ptr_array_free(graph->components, TRUE);
d94d92ac 172 graph->components = NULL;
bd14d768 173 }
5c563278 174
9b4f9b42
PP
175 if (graph->interrupters) {
176 BT_LOGD_STR("Putting interrupters.");
177 g_ptr_array_free(graph->interrupters, TRUE);
178 graph->interrupters = NULL;
179 }
180
181 BT_OBJECT_PUT_REF_AND_RESET(graph->default_interrupter);
182
f60c8b34
JG
183 if (graph->sinks_to_consume) {
184 g_queue_free(graph->sinks_to_consume);
d94d92ac
PP
185 graph->sinks_to_consume = NULL;
186 }
187
188 if (graph->listeners.source_output_port_added) {
189 g_array_free(graph->listeners.source_output_port_added, TRUE);
190 graph->listeners.source_output_port_added = NULL;
191 }
192
193 if (graph->listeners.filter_output_port_added) {
194 g_array_free(graph->listeners.filter_output_port_added, TRUE);
195 graph->listeners.filter_output_port_added = NULL;
196 }
197
198 if (graph->listeners.filter_input_port_added) {
199 g_array_free(graph->listeners.filter_input_port_added, TRUE);
200 graph->listeners.filter_input_port_added = NULL;
c0418dd9 201 }
1bf957a0 202
d94d92ac
PP
203 if (graph->listeners.sink_input_port_added) {
204 g_array_free(graph->listeners.sink_input_port_added, TRUE);
205 graph->listeners.sink_input_port_added = NULL;
1bf957a0
PP
206 }
207
d94d92ac
PP
208 if (graph->listeners.source_filter_ports_connected) {
209 g_array_free(graph->listeners.source_filter_ports_connected,
210 TRUE);
211 graph->listeners.source_filter_ports_connected = NULL;
212 }
213
9c0a126a
PP
214 if (graph->listeners.filter_filter_ports_connected) {
215 g_array_free(graph->listeners.filter_filter_ports_connected,
216 TRUE);
217 graph->listeners.filter_filter_ports_connected = NULL;
218 }
219
d94d92ac
PP
220 if (graph->listeners.source_sink_ports_connected) {
221 g_array_free(graph->listeners.source_sink_ports_connected,
222 TRUE);
223 graph->listeners.source_sink_ports_connected = NULL;
224 }
225
226 if (graph->listeners.filter_sink_ports_connected) {
227 g_array_free(graph->listeners.filter_sink_ports_connected,
228 TRUE);
229 graph->listeners.filter_sink_ports_connected = NULL;
230 }
231
d6e69534
PP
232 bt_object_pool_finalize(&graph->event_msg_pool);
233 bt_object_pool_finalize(&graph->packet_begin_msg_pool);
234 bt_object_pool_finalize(&graph->packet_end_msg_pool);
c0418dd9
JG
235 g_free(graph);
236}
237
5c563278 238static
d6e69534 239void destroy_message_event(struct bt_message *msg,
5c563278
PP
240 struct bt_graph *graph)
241{
d6e69534 242 bt_message_event_destroy(msg);
5c563278
PP
243}
244
245static
d6e69534 246void destroy_message_packet_begin(struct bt_message *msg,
5c563278
PP
247 struct bt_graph *graph)
248{
5df26c89 249 bt_message_packet_destroy(msg);
5c563278
PP
250}
251
252static
d6e69534 253void destroy_message_packet_end(struct bt_message *msg,
5c563278
PP
254 struct bt_graph *graph)
255{
5df26c89 256 bt_message_packet_destroy(msg);
5c563278
PP
257}
258
259static
d6e69534 260void notify_message_graph_is_destroyed(struct bt_message *msg)
5c563278 261{
d6e69534 262 bt_message_unlink_graph(msg);
5c563278
PP
263}
264
0d72b8c3 265struct bt_graph *bt_graph_create(void)
c0418dd9 266{
f60c8b34 267 struct bt_graph *graph;
1bf957a0 268 int ret;
c0418dd9 269
3f7d4d90 270 BT_LOGI_STR("Creating graph object.");
f60c8b34 271 graph = g_new0(struct bt_graph, 1);
c0418dd9 272 if (!graph) {
870631a2 273 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one graph.");
c0418dd9
JG
274 goto end;
275 }
276
d94d92ac 277 bt_object_init_shared(&graph->base, destroy_graph);
3fea54f6
PP
278 graph->connections = g_ptr_array_new_with_free_func(
279 (GDestroyNotify) bt_object_try_spec_release);
c0418dd9 280 if (!graph->connections) {
870631a2 281 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one GPtrArray.");
c0418dd9
JG
282 goto error;
283 }
3fea54f6
PP
284 graph->components = g_ptr_array_new_with_free_func(
285 (GDestroyNotify) bt_object_try_spec_release);
f60c8b34 286 if (!graph->components) {
870631a2 287 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one GPtrArray.");
f60c8b34
JG
288 goto error;
289 }
290 graph->sinks_to_consume = g_queue_new();
291 if (!graph->sinks_to_consume) {
870631a2 292 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one GQueue.");
c0418dd9
JG
293 goto error;
294 }
1bf957a0 295
d94d92ac
PP
296 bt_graph_set_can_consume(graph, true);
297 INIT_LISTENERS_ARRAY(struct bt_graph_listener_port_added,
298 graph->listeners.source_output_port_added);
299
300 if (!graph->listeners.source_output_port_added) {
301 ret = -1;
1bf957a0
PP
302 goto error;
303 }
304
d94d92ac
PP
305 INIT_LISTENERS_ARRAY(struct bt_graph_listener_port_added,
306 graph->listeners.filter_output_port_added);
307
308 if (!graph->listeners.filter_output_port_added) {
309 ret = -1;
1bf957a0
PP
310 goto error;
311 }
312
d94d92ac
PP
313 INIT_LISTENERS_ARRAY(struct bt_graph_listener_port_added,
314 graph->listeners.filter_input_port_added);
315
316 if (!graph->listeners.filter_input_port_added) {
317 ret = -1;
1bf957a0
PP
318 goto error;
319 }
320
d94d92ac
PP
321 INIT_LISTENERS_ARRAY(struct bt_graph_listener_port_added,
322 graph->listeners.sink_input_port_added);
323
324 if (!graph->listeners.sink_input_port_added) {
325 ret = -1;
326 goto error;
327 }
328
d94d92ac
PP
329 INIT_LISTENERS_ARRAY(struct bt_graph_listener_ports_connected,
330 graph->listeners.source_filter_ports_connected);
331
332 if (!graph->listeners.source_filter_ports_connected) {
333 ret = -1;
334 goto error;
335 }
336
337 INIT_LISTENERS_ARRAY(struct bt_graph_listener_ports_connected,
338 graph->listeners.source_sink_ports_connected);
339
340 if (!graph->listeners.source_sink_ports_connected) {
341 ret = -1;
342 goto error;
343 }
344
9c0a126a
PP
345 INIT_LISTENERS_ARRAY(struct bt_graph_listener_ports_connected,
346 graph->listeners.filter_filter_ports_connected);
347
348 if (!graph->listeners.filter_filter_ports_connected) {
349 ret = -1;
350 goto error;
351 }
352
d94d92ac
PP
353 INIT_LISTENERS_ARRAY(struct bt_graph_listener_ports_connected,
354 graph->listeners.filter_sink_ports_connected);
355
356 if (!graph->listeners.filter_sink_ports_connected) {
357 ret = -1;
358 goto error;
359 }
360
9b4f9b42
PP
361 graph->interrupters = g_ptr_array_new_with_free_func(
362 (GDestroyNotify) bt_object_put_no_null_check);
363 if (!graph->interrupters) {
364 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one GPtrArray.");
365 goto error;
366 }
367
368 graph->default_interrupter = bt_interrupter_create();
369 if (!graph->default_interrupter) {
370 BT_LIB_LOGE_APPEND_CAUSE(
371 "Failed to create one interrupter object.");
372 goto error;
373 }
374
375 bt_graph_add_interrupter(graph, graph->default_interrupter);
d6e69534
PP
376 ret = bt_object_pool_initialize(&graph->event_msg_pool,
377 (bt_object_pool_new_object_func) bt_message_event_new,
378 (bt_object_pool_destroy_object_func) destroy_message_event,
5c563278
PP
379 graph);
380 if (ret) {
870631a2
PP
381 BT_LIB_LOGE_APPEND_CAUSE(
382 "Failed to initialize event message pool: ret=%d",
5c563278
PP
383 ret);
384 goto error;
385 }
386
d6e69534
PP
387 ret = bt_object_pool_initialize(&graph->packet_begin_msg_pool,
388 (bt_object_pool_new_object_func) bt_message_packet_beginning_new,
389 (bt_object_pool_destroy_object_func) destroy_message_packet_begin,
5c563278
PP
390 graph);
391 if (ret) {
870631a2
PP
392 BT_LIB_LOGE_APPEND_CAUSE(
393 "Failed to initialize packet beginning message pool: ret=%d",
5c563278
PP
394 ret);
395 goto error;
396 }
397
d6e69534
PP
398 ret = bt_object_pool_initialize(&graph->packet_end_msg_pool,
399 (bt_object_pool_new_object_func) bt_message_packet_end_new,
400 (bt_object_pool_destroy_object_func) destroy_message_packet_end,
5c563278
PP
401 graph);
402 if (ret) {
870631a2
PP
403 BT_LIB_LOGE_APPEND_CAUSE(
404 "Failed to initialize packet end message pool: ret=%d",
5c563278
PP
405 ret);
406 goto error;
407 }
408
d6e69534
PP
409 graph->messages = g_ptr_array_new_with_free_func(
410 (GDestroyNotify) notify_message_graph_is_destroyed);
3f7d4d90 411 BT_LIB_LOGI("Created graph object: %!+g", graph);
262e5473 412
c0418dd9 413end:
a2d06fd5 414 return (void *) graph;
d94d92ac 415
c0418dd9 416error:
65300d60 417 BT_OBJECT_PUT_REF_AND_RESET(graph);
c0418dd9
JG
418 goto end;
419}
420
d24d5663 421enum bt_graph_connect_ports_status bt_graph_connect_ports(
0d72b8c3
PP
422 struct bt_graph *graph,
423 const struct bt_port_output *upstream_port_out,
424 const struct bt_port_input *downstream_port_in,
425 const struct bt_connection **user_connection)
f60c8b34 426{
d24d5663
PP
427 enum bt_graph_connect_ports_status status = BT_FUNC_STATUS_OK;
428 enum bt_graph_listener_func_status listener_status;
f60c8b34 429 struct bt_connection *connection = NULL;
d94d92ac
PP
430 struct bt_port *upstream_port = (void *) upstream_port_out;
431 struct bt_port *downstream_port = (void *) downstream_port_in;
f60c8b34
JG
432 struct bt_component *upstream_component = NULL;
433 struct bt_component *downstream_component = NULL;
d24d5663 434 enum bt_component_class_port_connected_method_status port_connected_status;
d94d92ac 435 bool init_can_consume;
f60c8b34 436
d94d92ac
PP
437 BT_ASSERT_PRE_NON_NULL(graph, "Graph");
438 BT_ASSERT_PRE_NON_NULL(upstream_port, "Upstream port");
439 BT_ASSERT_PRE_NON_NULL(downstream_port, "Downstream port port");
5badd463
PP
440 BT_ASSERT_PRE(
441 graph->config_state == BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
38cda5da 442 "Graph is not in the \"configuring\" state: %!+g", graph);
d94d92ac
PP
443 BT_ASSERT_PRE(!bt_port_is_connected(upstream_port),
444 "Upstream port is already connected: %!+p", upstream_port);
445 BT_ASSERT_PRE(!bt_port_is_connected(downstream_port),
446 "Downstream port is already connected: %!+p", downstream_port);
0d72b8c3 447 BT_ASSERT_PRE(bt_port_borrow_component_inline((void *) upstream_port),
d94d92ac
PP
448 "Upstream port does not belong to a component: %!+p",
449 upstream_port);
0d72b8c3 450 BT_ASSERT_PRE(bt_port_borrow_component_inline((void *) downstream_port),
d94d92ac
PP
451 "Downstream port does not belong to a component: %!+p",
452 downstream_port);
4aa7981f 453 init_can_consume = graph->can_consume;
3f7d4d90 454 BT_LIB_LOGI("Connecting component ports within graph: "
d94d92ac
PP
455 "%![graph-]+g, %![up-port-]+p, %![down-port-]+p",
456 graph, upstream_port, downstream_port);
457 bt_graph_set_can_consume(graph, false);
0d72b8c3 458 upstream_component = bt_port_borrow_component_inline(
d94d92ac 459 (void *) upstream_port);
0d72b8c3 460 downstream_component = bt_port_borrow_component_inline(
d94d92ac 461 (void *) downstream_port);
262e5473 462
262e5473 463 BT_LOGD_STR("Creating connection.");
d94d92ac
PP
464 connection = bt_connection_create(graph, (void *) upstream_port,
465 (void *) downstream_port);
f60c8b34 466 if (!connection) {
870631a2 467 BT_LIB_LOGE_APPEND_CAUSE("Cannot create connection object.");
d24d5663 468 status = BT_FUNC_STATUS_MEMORY_ERROR;
a256a42d 469 goto end;
f60c8b34
JG
470 }
471
d94d92ac 472 BT_LIB_LOGD("Connection object created: %!+x", connection);
262e5473 473
f60c8b34 474 /*
72b913fb
PP
475 * Ownership of upstream_component/downstream_component and of
476 * the connection object is transferred to the graph.
f60c8b34
JG
477 */
478 g_ptr_array_add(graph->connections, connection);
ffeb0eed 479
f60c8b34 480 /*
0d8b4d8e 481 * Notify both components that their port is connected.
f60c8b34 482 */
d94d92ac
PP
483 BT_LIB_LOGD("Notifying upstream component that its port is connected: "
484 "%![comp-]+c, %![port-]+p", upstream_component, upstream_port);
d24d5663 485 port_connected_status = bt_component_port_connected(upstream_component,
d94d92ac 486 (void *) upstream_port, (void *) downstream_port);
d24d5663 487 if (port_connected_status != BT_FUNC_STATUS_OK) {
870631a2
PP
488 if (port_connected_status < 0) {
489 BT_LIB_LOGW_APPEND_CAUSE(
490 "Upstream component's \"port connected\" method failed: "
491 "status=%s, %![graph-]+g, %![up-comp-]+c, "
492 "%![down-comp-]+c, %![up-port-]+p, %![down-port-]+p",
493 bt_common_func_status_string(
494 port_connected_status),
495 graph, upstream_component, downstream_component,
496 upstream_port, downstream_port);
497 }
498
bf55043c 499 bt_connection_end(connection, true);
d24d5663 500 status = (int) port_connected_status;
bf55043c
PP
501 goto end;
502 }
503
85031ceb 504 connection->notified_upstream_port_connected = true;
d94d92ac
PP
505 BT_LIB_LOGD("Notifying downstream component that its port is connected: "
506 "%![comp-]+c, %![port-]+p", downstream_component,
507 downstream_port);
d24d5663 508 port_connected_status = bt_component_port_connected(downstream_component,
d94d92ac 509 (void *) downstream_port, (void *) upstream_port);
d24d5663 510 if (port_connected_status != BT_FUNC_STATUS_OK) {
870631a2
PP
511 if (port_connected_status < 0) {
512 BT_LIB_LOGW_APPEND_CAUSE(
513 "Downstream component's \"port connected\" method failed: "
514 "status=%s, %![graph-]+g, %![up-comp-]+c, "
515 "%![down-comp-]+c, %![up-port-]+p, %![down-port-]+p",
516 bt_common_func_status_string(
517 port_connected_status),
518 graph, upstream_component, downstream_component,
519 upstream_port, downstream_port);
520 }
521
bf55043c 522 bt_connection_end(connection, true);
d24d5663 523 status = (int) port_connected_status;
bf55043c
PP
524 goto end;
525 }
526
85031ceb 527 connection->notified_downstream_port_connected = true;
1bf957a0
PP
528
529 /*
0d8b4d8e 530 * Notify the graph's creator that both ports are connected.
1bf957a0 531 */
262e5473 532 BT_LOGD_STR("Notifying graph's user that new component ports are connected.");
8cc56726 533 listener_status = bt_graph_notify_ports_connected(graph, upstream_port, downstream_port);
d24d5663 534 if (listener_status != BT_FUNC_STATUS_OK) {
870631a2
PP
535 if (listener_status < 0) {
536 BT_LIB_LOGW_APPEND_CAUSE(
537 "Graph \"ports connected\" listener failed: "
538 "status=%d, %![graph-]+g, %![up-comp-]+c, "
539 "%![down-comp-]+c, %![up-port-]+p, %![down-port-]+p",
540 listener_status, graph,
541 upstream_component, downstream_component,
542 upstream_port, downstream_port);
543 }
544
8cc56726
SM
545 status = (int) listener_status;
546 goto end;
547 }
548
85031ceb 549 connection->notified_graph_ports_connected = true;
3f7d4d90 550 BT_LIB_LOGI("Connected component ports within graph: "
d94d92ac
PP
551 "%![graph-]+g, %![up-comp-]+c, %![down-comp-]+c, "
552 "%![up-port-]+p, %![down-port-]+p",
553 graph, upstream_component, downstream_component,
554 upstream_port, downstream_port);
1bf957a0 555
a256a42d 556 if (user_connection) {
1a6a376a
PP
557 /* Move reference to user */
558 *user_connection = connection;
559 connection = NULL;
a256a42d
PP
560 }
561
f60c8b34 562end:
d24d5663 563 if (status != BT_FUNC_STATUS_OK) {
8cc56726 564 bt_graph_make_faulty(graph);
38cda5da
PP
565 }
566
65300d60 567 bt_object_put_ref(connection);
d94d92ac
PP
568 (void) init_can_consume;
569 bt_graph_set_can_consume(graph, init_can_consume);
a256a42d 570 return status;
f60c8b34
JG
571}
572
ad847455 573static inline
d24d5663 574int consume_graph_sink(struct bt_component_sink *comp)
c0418dd9 575{
d24d5663 576 enum bt_component_class_sink_consume_method_status consume_status;
d94d92ac
PP
577 struct bt_component_class_sink *sink_class = NULL;
578
579 BT_ASSERT(comp);
580 sink_class = (void *) comp->parent.class;
581 BT_ASSERT(sink_class->methods.consume);
582 BT_LIB_LOGD("Calling user's consume method: %!+c", comp);
d24d5663 583 consume_status = sink_class->methods.consume((void *) comp);
d94d92ac 584 BT_LOGD("User method returned: status=%s",
d24d5663 585 bt_common_func_status_string(consume_status));
bdb288b3 586 BT_ASSERT_POST_DEV(consume_status == BT_FUNC_STATUS_OK ||
d24d5663
PP
587 consume_status == BT_FUNC_STATUS_END ||
588 consume_status == BT_FUNC_STATUS_AGAIN ||
589 consume_status == BT_FUNC_STATUS_ERROR ||
590 consume_status == BT_FUNC_STATUS_MEMORY_ERROR,
d94d92ac 591 "Invalid component status returned by consuming method: "
d24d5663 592 "status=%s", bt_common_func_status_string(consume_status));
870631a2
PP
593 if (consume_status) {
594 if (consume_status < 0) {
595 BT_LIB_LOGW_APPEND_CAUSE(
596 "Component's \"consume\" method failed: "
597 "status=%s, %![comp-]+c",
598 bt_common_func_status_string(consume_status),
599 comp);
600 }
601
d94d92ac
PP
602 goto end;
603 }
604
3f7d4d90 605 BT_LIB_LOGD("Consumed from sink: %![comp-]+c, status=%s",
d24d5663 606 comp, bt_common_func_status_string(consume_status));
d94d92ac
PP
607
608end:
d24d5663 609 return consume_status;
8ed535b5
PP
610}
611
612/*
613 * `node` is removed from the queue of sinks to consume when passed to
614 * this function. This function adds it back to the queue if there's
615 * still something to consume afterwards.
616 */
ad847455 617static inline
d24d5663 618int consume_sink_node(struct bt_graph *graph, GList *node)
8ed535b5 619{
d24d5663 620 int status;
d94d92ac 621 struct bt_component_sink *sink;
8ed535b5
PP
622
623 sink = node->data;
624 status = consume_graph_sink(sink);
d24d5663 625 if (G_UNLIKELY(status != BT_FUNC_STATUS_END)) {
8ed535b5 626 g_queue_push_tail_link(graph->sinks_to_consume, node);
f60c8b34
JG
627 goto end;
628 }
629
630 /* End reached, the node is not added back to the queue and free'd. */
8ed535b5 631 g_queue_delete_link(graph->sinks_to_consume, node);
f60c8b34
JG
632
633 /* Don't forward an END status if there are sinks left to consume. */
634 if (!g_queue_is_empty(graph->sinks_to_consume)) {
d24d5663 635 status = BT_FUNC_STATUS_OK;
f60c8b34
JG
636 goto end;
637 }
8ed535b5
PP
638
639end:
3f7d4d90 640 BT_LIB_LOGD("Consumed sink node: %![comp-]+c, status=%s",
d24d5663 641 sink, bt_common_func_status_string(status));
8ed535b5
PP
642 return status;
643}
644
645BT_HIDDEN
d24d5663 646int bt_graph_consume_sink_no_check(struct bt_graph *graph,
d94d92ac 647 struct bt_component_sink *sink)
8ed535b5 648{
d24d5663 649 int status;
8ed535b5
PP
650 GList *sink_node;
651 int index;
652
3f7d4d90 653 BT_LIB_LOGD("Making specific sink consume: %![comp-]+c", sink);
d94d92ac 654 BT_ASSERT(bt_component_borrow_graph((void *) sink) == graph);
8ed535b5
PP
655
656 if (g_queue_is_empty(graph->sinks_to_consume)) {
3f7d4d90 657 BT_LOGD_STR("Graph's sink queue is empty: end of graph.");
d24d5663 658 status = BT_FUNC_STATUS_END;
8ed535b5
PP
659 goto end;
660 }
661
662 index = g_queue_index(graph->sinks_to_consume, sink);
663 if (index < 0) {
3f7d4d90
PP
664 BT_LIB_LOGD("Sink component is not marked as consumable: "
665 "component sink is ended: %![comp-]+c", sink);
d24d5663 666 status = BT_FUNC_STATUS_END;
8ed535b5
PP
667 goto end;
668 }
669
670 sink_node = g_queue_pop_nth_link(graph->sinks_to_consume, index);
f6ccaed9 671 BT_ASSERT(sink_node);
8ed535b5
PP
672 status = consume_sink_node(graph, sink_node);
673
674end:
675 return status;
676}
677
ad847455 678static inline
d24d5663 679int consume_no_check(struct bt_graph *graph)
8ed535b5 680{
d24d5663 681 int status = BT_FUNC_STATUS_OK;
8ed535b5
PP
682 struct bt_component *sink;
683 GList *current_node;
684
bdb288b3 685 BT_ASSERT_PRE_DEV(graph->has_sink,
f6ccaed9 686 "Graph has no sink component: %!+g", graph);
3f7d4d90 687 BT_LIB_LOGD("Making next sink component consume: %![graph-]+g", graph);
8ed535b5 688
91d81473 689 if (G_UNLIKELY(g_queue_is_empty(graph->sinks_to_consume))) {
3f7d4d90 690 BT_LOGD_STR("Graph's sink queue is empty: end of graph.");
d24d5663 691 status = BT_FUNC_STATUS_END;
8ed535b5
PP
692 goto end;
693 }
694
695 current_node = g_queue_pop_head_link(graph->sinks_to_consume);
696 sink = current_node->data;
3f7d4d90 697 BT_LIB_LOGD("Chose next sink to consume: %!+c", sink);
8ed535b5
PP
698 status = consume_sink_node(graph, current_node);
699
f60c8b34
JG
700end:
701 return status;
c0418dd9
JG
702}
703
648dab91 704enum bt_graph_run_once_status bt_graph_run_once(struct bt_graph *graph)
851b70bd 705{
648dab91 706 enum bt_graph_run_once_status status;
1d915789 707
bdb288b3 708 BT_ASSERT_PRE_DEV_NON_NULL(graph, "Graph");
bdb288b3 709 BT_ASSERT_PRE_DEV(graph->can_consume,
f6ccaed9 710 "Cannot consume graph in its current state: %!+g", graph);
bdb288b3
PP
711 BT_ASSERT_PRE_DEV(graph->config_state !=
712 BT_GRAPH_CONFIGURATION_STATE_FAULTY,
38cda5da 713 "Graph is in a faulty state: %!+g", graph);
4725a201 714 bt_graph_set_can_consume(graph, false);
5badd463 715 status = bt_graph_configure(graph);
91d81473 716 if (G_UNLIKELY(status)) {
5badd463
PP
717 /* bt_graph_configure() logs errors */
718 goto end;
719 }
720
d94d92ac 721 status = consume_no_check(graph);
4725a201 722 bt_graph_set_can_consume(graph, true);
5badd463
PP
723
724end:
26a15756 725 return status;
851b70bd
PP
726}
727
d24d5663 728enum bt_graph_run_status bt_graph_run(struct bt_graph *graph)
f60c8b34 729{
d24d5663 730 enum bt_graph_run_status status;
f60c8b34 731
d94d92ac 732 BT_ASSERT_PRE_NON_NULL(graph, "Graph");
ad847455
PP
733 BT_ASSERT_PRE(graph->can_consume,
734 "Cannot consume graph in its current state: %!+g", graph);
38cda5da
PP
735 BT_ASSERT_PRE(graph->config_state != BT_GRAPH_CONFIGURATION_STATE_FAULTY,
736 "Graph is in a faulty state: %!+g", graph);
4725a201 737 bt_graph_set_can_consume(graph, false);
5badd463 738 status = bt_graph_configure(graph);
91d81473 739 if (G_UNLIKELY(status)) {
5badd463
PP
740 /* bt_graph_configure() logs errors */
741 goto end;
742 }
743
3f7d4d90 744 BT_LIB_LOGI("Running graph: %!+g", graph);
262e5473 745
f60c8b34 746 do {
851b70bd 747 /*
9b4f9b42
PP
748 * Check if the graph is interrupted at each iteration.
749 * If the graph was interrupted by another thread or by
750 * a signal handler, this is NOT a warning nor an error;
751 * it was intentional: log with an INFO level only.
851b70bd 752 */
9b4f9b42
PP
753 if (G_UNLIKELY(bt_graph_is_interrupted(graph))) {
754 BT_LIB_LOGI("Stopping the graph: "
755 "graph was interrupted: %!+g", graph);
756 status = BT_FUNC_STATUS_AGAIN;
851b70bd
PP
757 goto end;
758 }
759
d94d92ac 760 status = consume_no_check(graph);
d24d5663 761 if (G_UNLIKELY(status == BT_FUNC_STATUS_AGAIN)) {
f60c8b34 762 /*
202a3a13
PP
763 * If AGAIN is received and there are multiple
764 * sinks, go ahead and consume from the next
765 * sink.
f60c8b34 766 *
202a3a13
PP
767 * However, in the case where a single sink is
768 * left, the caller can decide to busy-wait and
0d72b8c3 769 * call bt_graph_run() continuously
d94d92ac
PP
770 * until the source is ready or it can decide to
771 * sleep for an arbitrary amount of time.
f60c8b34
JG
772 */
773 if (graph->sinks_to_consume->length > 1) {
d24d5663 774 status = BT_FUNC_STATUS_OK;
f60c8b34
JG
775 }
776 }
d24d5663 777 } while (status == BT_FUNC_STATUS_OK);
f60c8b34
JG
778
779 if (g_queue_is_empty(graph->sinks_to_consume)) {
d24d5663 780 status = BT_FUNC_STATUS_END;
f60c8b34 781 }
262e5473 782
202a3a13 783end:
3f7d4d90 784 BT_LIB_LOGI("Graph ran: %![graph-]+g, status=%s", graph,
d24d5663 785 bt_common_func_status_string(status));
4725a201 786 bt_graph_set_can_consume(graph, true);
72b913fb 787 return status;
f60c8b34 788}
1bf957a0 789
d24d5663 790enum bt_graph_add_listener_status
0d72b8c3
PP
791bt_graph_add_source_component_output_port_added_listener(
792 struct bt_graph *graph,
793 bt_graph_source_component_output_port_added_listener_func func,
794 bt_graph_listener_removed_func listener_removed, void *data,
2054a0d1 795 bt_listener_id *out_listener_id)
1bf957a0 796{
d94d92ac
PP
797 struct bt_graph_listener_port_added listener = {
798 .base = {
799 .removed = listener_removed,
800 .data = data,
801 },
802 .func = (port_added_func_t) func,
1bf957a0 803 };
2054a0d1 804 bt_listener_id listener_id;
1bf957a0 805
d94d92ac
PP
806 BT_ASSERT_PRE_NON_NULL(graph, "Graph");
807 BT_ASSERT_PRE_NON_NULL(func, "Listener");
808 BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
809 BT_ASSERT_PRE(!graph->in_remove_listener,
810 "Graph currently executing a \"listener removed\" listener: "
811 "%!+g", graph);
812 g_array_append_val(graph->listeners.source_output_port_added, listener);
813 listener_id = graph->listeners.source_output_port_added->len - 1;
3f7d4d90 814 BT_LIB_LOGD("Added \"source component output port added\" listener to graph: "
d94d92ac
PP
815 "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
816 listener_id);
817
818 if (listener_id) {
819 *out_listener_id = listener_id;
820 }
821
d24d5663 822 return BT_FUNC_STATUS_OK;
1bf957a0
PP
823}
824
d24d5663 825enum bt_graph_add_listener_status
0d72b8c3
PP
826bt_graph_add_filter_component_output_port_added_listener(
827 struct bt_graph *graph,
828 bt_graph_filter_component_output_port_added_listener_func func,
829 bt_graph_listener_removed_func listener_removed, void *data,
2054a0d1 830 bt_listener_id *out_listener_id)
1bf957a0 831{
d94d92ac
PP
832 struct bt_graph_listener_port_added listener = {
833 .base = {
834 .removed = listener_removed,
835 .data = data,
836 },
837 .func = (port_added_func_t) func,
838 };
2054a0d1 839 bt_listener_id listener_id;
1bf957a0 840
d94d92ac
PP
841 BT_ASSERT_PRE_NON_NULL(graph, "Graph");
842 BT_ASSERT_PRE_NON_NULL(func, "Listener");
843 BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
844 BT_ASSERT_PRE(!graph->in_remove_listener,
845 "Graph currently executing a \"listener removed\" listener: "
846 "%!+g", graph);
847 g_array_append_val(graph->listeners.filter_output_port_added, listener);
848 listener_id = graph->listeners.filter_output_port_added->len - 1;
3f7d4d90 849 BT_LIB_LOGD("Added \"filter component output port added\" listener to graph: "
d94d92ac
PP
850 "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
851 listener_id);
852
853 if (listener_id) {
854 *out_listener_id = listener_id;
855 }
856
d24d5663 857 return BT_FUNC_STATUS_OK;
d94d92ac 858}
262e5473 859
d24d5663 860enum bt_graph_add_listener_status
0d72b8c3
PP
861bt_graph_add_filter_component_input_port_added_listener(
862 struct bt_graph *graph,
863 bt_graph_filter_component_input_port_added_listener_func func,
864 bt_graph_listener_removed_func listener_removed, void *data,
2054a0d1 865 bt_listener_id *out_listener_id)
d94d92ac 866{
d94d92ac
PP
867 struct bt_graph_listener_port_added listener = {
868 .base = {
869 .removed = listener_removed,
870 .data = data,
871 },
872 .func = (port_added_func_t) func,
873 };
2054a0d1 874 bt_listener_id listener_id;
8cc092c9 875
d94d92ac
PP
876 BT_ASSERT_PRE_NON_NULL(graph, "Graph");
877 BT_ASSERT_PRE_NON_NULL(func, "Listener");
878 BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
879 BT_ASSERT_PRE(!graph->in_remove_listener,
880 "Graph currently executing a \"listener removed\" listener: "
881 "%!+g", graph);
882 g_array_append_val(graph->listeners.filter_input_port_added, listener);
883 listener_id = graph->listeners.filter_input_port_added->len - 1;
3f7d4d90 884 BT_LIB_LOGD("Added \"filter component input port added\" listener to graph: "
d94d92ac
PP
885 "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
886 listener_id);
887
888 if (listener_id) {
889 *out_listener_id = listener_id;
890 }
891
d24d5663 892 return BT_FUNC_STATUS_OK;
d94d92ac 893}
1bf957a0 894
d24d5663 895enum bt_graph_add_listener_status
0d72b8c3
PP
896bt_graph_add_sink_component_input_port_added_listener(
897 struct bt_graph *graph,
898 bt_graph_sink_component_input_port_added_listener_func func,
899 bt_graph_listener_removed_func listener_removed, void *data,
2054a0d1 900 bt_listener_id *out_listener_id)
d94d92ac 901{
d94d92ac
PP
902 struct bt_graph_listener_port_added listener = {
903 .base = {
904 .removed = listener_removed,
905 .data = data,
906 },
907 .func = (port_added_func_t) func,
908 };
2054a0d1 909 bt_listener_id listener_id;
1bf957a0 910
d94d92ac
PP
911 BT_ASSERT_PRE_NON_NULL(graph, "Graph");
912 BT_ASSERT_PRE_NON_NULL(func, "Listener");
913 BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
914 BT_ASSERT_PRE(!graph->in_remove_listener,
915 "Graph currently executing a \"listener removed\" listener: "
916 "%!+g", graph);
917 g_array_append_val(graph->listeners.sink_input_port_added, listener);
918 listener_id = graph->listeners.sink_input_port_added->len - 1;
3f7d4d90 919 BT_LIB_LOGD("Added \"sink component input port added\" listener to graph: "
d94d92ac
PP
920 "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
921 listener_id);
922
923 if (listener_id) {
924 *out_listener_id = listener_id;
925 }
926
d24d5663 927 return BT_FUNC_STATUS_OK;
1bf957a0
PP
928}
929
d24d5663 930enum bt_graph_add_listener_status
0d72b8c3
PP
931bt_graph_add_source_filter_component_ports_connected_listener(
932 struct bt_graph *graph,
933 bt_graph_source_filter_component_ports_connected_listener_func func,
934 bt_graph_listener_removed_func listener_removed, void *data,
2054a0d1 935 bt_listener_id *out_listener_id)
d94d92ac 936{
d94d92ac
PP
937 struct bt_graph_listener_ports_connected listener = {
938 .base = {
939 .removed = listener_removed,
940 .data = data,
941 },
942 .func = (ports_connected_func_t) func,
943 };
2054a0d1 944 bt_listener_id listener_id;
8cc092c9 945
d94d92ac
PP
946 BT_ASSERT_PRE_NON_NULL(graph, "Graph");
947 BT_ASSERT_PRE_NON_NULL(func, "Listener");
948 BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
949 BT_ASSERT_PRE(!graph->in_remove_listener,
950 "Graph currently executing a \"listener removed\" listener: "
951 "%!+g", graph);
952 g_array_append_val(graph->listeners.source_filter_ports_connected,
953 listener);
954 listener_id = graph->listeners.source_filter_ports_connected->len - 1;
3f7d4d90 955 BT_LIB_LOGD("Added \"source to filter component ports connected\" listener to graph: "
d94d92ac
PP
956 "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
957 listener_id);
958
959 if (listener_id) {
960 *out_listener_id = listener_id;
961 }
962
d24d5663 963 return BT_FUNC_STATUS_OK;
d94d92ac 964}
1bf957a0 965
d24d5663 966enum bt_graph_add_listener_status
0d72b8c3
PP
967bt_graph_add_source_sink_component_ports_connected_listener(
968 struct bt_graph *graph,
969 bt_graph_source_sink_component_ports_connected_listener_func func,
970 bt_graph_listener_removed_func listener_removed, void *data,
2054a0d1 971 bt_listener_id *out_listener_id)
d94d92ac 972{
d94d92ac
PP
973 struct bt_graph_listener_ports_connected listener = {
974 .base = {
975 .removed = listener_removed,
976 .data = data,
977 },
978 .func = (ports_connected_func_t) func,
979 };
2054a0d1 980 bt_listener_id listener_id;
1bf957a0 981
d94d92ac
PP
982 BT_ASSERT_PRE_NON_NULL(graph, "Graph");
983 BT_ASSERT_PRE_NON_NULL(func, "Listener");
984 BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
985 BT_ASSERT_PRE(!graph->in_remove_listener,
986 "Graph currently executing a \"listener removed\" listener: "
987 "%!+g", graph);
988 g_array_append_val(graph->listeners.source_sink_ports_connected,
989 listener);
990 listener_id = graph->listeners.source_sink_ports_connected->len - 1;
3f7d4d90 991 BT_LIB_LOGD("Added \"source to sink component ports connected\" listener to graph: "
d94d92ac
PP
992 "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
993 listener_id);
994
995 if (listener_id) {
996 *out_listener_id = listener_id;
997 }
998
d24d5663 999 return BT_FUNC_STATUS_OK;
1bf957a0
PP
1000}
1001
d24d5663 1002enum bt_graph_add_listener_status
9c0a126a
PP
1003bt_graph_add_filter_filter_component_ports_connected_listener(
1004 struct bt_graph *graph,
1005 bt_graph_filter_filter_component_ports_connected_listener_func func,
1006 bt_graph_listener_removed_func listener_removed, void *data,
2054a0d1 1007 bt_listener_id *out_listener_id)
9c0a126a
PP
1008{
1009 struct bt_graph_listener_ports_connected listener = {
1010 .base = {
1011 .removed = listener_removed,
1012 .data = data,
1013 },
1014 .func = (ports_connected_func_t) func,
1015 };
2054a0d1 1016 bt_listener_id listener_id;
9c0a126a
PP
1017
1018 BT_ASSERT_PRE_NON_NULL(graph, "Graph");
1019 BT_ASSERT_PRE_NON_NULL(func, "Listener");
1020 BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
1021 BT_ASSERT_PRE(!graph->in_remove_listener,
1022 "Graph currently executing a \"listener removed\" listener: "
1023 "%!+g", graph);
1024 g_array_append_val(graph->listeners.filter_filter_ports_connected,
1025 listener);
1026 listener_id = graph->listeners.filter_filter_ports_connected->len - 1;
3f7d4d90 1027 BT_LIB_LOGD("Added \"filter to filter component ports connected\" listener to graph: "
9c0a126a
PP
1028 "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
1029 listener_id);
1030
1031 if (listener_id) {
1032 *out_listener_id = listener_id;
1033 }
1034
d24d5663 1035 return BT_FUNC_STATUS_OK;
9c0a126a
PP
1036}
1037
d24d5663 1038enum bt_graph_add_listener_status
0d72b8c3
PP
1039bt_graph_add_filter_sink_component_ports_connected_listener(
1040 struct bt_graph *graph,
1041 bt_graph_filter_sink_component_ports_connected_listener_func func,
1042 bt_graph_listener_removed_func listener_removed, void *data,
2054a0d1 1043 bt_listener_id *out_listener_id)
1bf957a0 1044{
d94d92ac
PP
1045 struct bt_graph_listener_ports_connected listener = {
1046 .base = {
1047 .removed = listener_removed,
1048 .data = data,
1049 },
1050 .func = (ports_connected_func_t) func,
1051 };
2054a0d1 1052 bt_listener_id listener_id;
1bf957a0 1053
d94d92ac
PP
1054 BT_ASSERT_PRE_NON_NULL(graph, "Graph");
1055 BT_ASSERT_PRE_NON_NULL(func, "Listener");
1056 BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
1057 BT_ASSERT_PRE(!graph->in_remove_listener,
1058 "Graph currently executing a \"listener removed\" listener: "
1059 "%!+g", graph);
1060 g_array_append_val(graph->listeners.filter_sink_ports_connected,
1061 listener);
1062 listener_id = graph->listeners.filter_sink_ports_connected->len - 1;
3f7d4d90 1063 BT_LIB_LOGD("Added \"filter to sink component ports connected\" listener to graph: "
d94d92ac
PP
1064 "%![graph-]+g, listener-addr=%p, id=%d", graph, listener,
1065 listener_id);
1066
1067 if (listener_id) {
1068 *out_listener_id = listener_id;
1069 }
1070
d24d5663 1071 return BT_FUNC_STATUS_OK;
d94d92ac 1072}
262e5473 1073
1bf957a0 1074BT_HIDDEN
d24d5663 1075enum bt_graph_listener_func_status bt_graph_notify_port_added(
8cc56726 1076 struct bt_graph *graph, struct bt_port *port)
1bf957a0 1077{
d94d92ac
PP
1078 uint64_t i;
1079 GArray *listeners;
1080 struct bt_component *comp;
d24d5663 1081 enum bt_graph_listener_func_status status = BT_FUNC_STATUS_OK;
1bf957a0 1082
d94d92ac
PP
1083 BT_ASSERT(graph);
1084 BT_ASSERT(port);
3f7d4d90 1085 BT_LIB_LOGD("Notifying graph listeners that a port was added: "
d94d92ac 1086 "%![graph-]+g, %![port-]+p", graph, port);
0d72b8c3 1087 comp = bt_port_borrow_component_inline(port);
d94d92ac
PP
1088 BT_ASSERT(comp);
1089
1090 switch (comp->class->type) {
1091 case BT_COMPONENT_CLASS_TYPE_SOURCE:
1092 {
1093 switch (port->type) {
1094 case BT_PORT_TYPE_OUTPUT:
1095 listeners = graph->listeners.source_output_port_added;
1096 break;
1097 default:
1098 abort();
1099 }
1100
1101 break;
1102 }
1103 case BT_COMPONENT_CLASS_TYPE_FILTER:
1104 {
1105 switch (port->type) {
1106 case BT_PORT_TYPE_INPUT:
1107 listeners = graph->listeners.filter_input_port_added;
1108 break;
1109 case BT_PORT_TYPE_OUTPUT:
1110 listeners = graph->listeners.filter_output_port_added;
1111 break;
1112 default:
1113 abort();
1114 }
262e5473 1115
d94d92ac
PP
1116 break;
1117 }
1118 case BT_COMPONENT_CLASS_TYPE_SINK:
1119 {
1120 switch (port->type) {
1121 case BT_PORT_TYPE_INPUT:
1122 listeners = graph->listeners.sink_input_port_added;
1123 break;
1124 default:
1125 abort();
1126 }
1bf957a0 1127
d94d92ac
PP
1128 break;
1129 }
1130 default:
1131 abort();
1132 }
1133
1134 for (i = 0; i < listeners->len; i++) {
1135 struct bt_graph_listener_port_added *listener =
1136 &g_array_index(listeners,
1137 struct bt_graph_listener_port_added, i);
1138
8cc56726 1139
d94d92ac 1140 BT_ASSERT(listener->func);
8cc56726 1141 status = listener->func(comp, port, listener->base.data);
d24d5663 1142 if (status != BT_FUNC_STATUS_OK) {
8cc56726
SM
1143 goto end;
1144 }
1bf957a0 1145 }
8cc56726
SM
1146
1147end:
1148 return status;
1bf957a0
PP
1149}
1150
1bf957a0 1151BT_HIDDEN
d24d5663 1152enum bt_graph_listener_func_status bt_graph_notify_ports_connected(
8cc56726
SM
1153 struct bt_graph *graph, struct bt_port *upstream_port,
1154 struct bt_port *downstream_port)
1bf957a0 1155{
d94d92ac
PP
1156 uint64_t i;
1157 GArray *listeners;
1158 struct bt_component *upstream_comp;
1159 struct bt_component *downstream_comp;
d24d5663 1160 enum bt_graph_listener_func_status status = BT_FUNC_STATUS_OK;
1bf957a0 1161
d94d92ac
PP
1162 BT_ASSERT(graph);
1163 BT_ASSERT(upstream_port);
1164 BT_ASSERT(downstream_port);
3f7d4d90 1165 BT_LIB_LOGD("Notifying graph listeners that ports were connected: "
d94d92ac
PP
1166 "%![graph-]+g, %![up-port-]+p, %![down-port-]+p",
1167 graph, upstream_port, downstream_port);
0d72b8c3 1168 upstream_comp = bt_port_borrow_component_inline(upstream_port);
d94d92ac 1169 BT_ASSERT(upstream_comp);
0d72b8c3 1170 downstream_comp = bt_port_borrow_component_inline(downstream_port);
d94d92ac
PP
1171 BT_ASSERT(downstream_comp);
1172
1173 switch (upstream_comp->class->type) {
1174 case BT_COMPONENT_CLASS_TYPE_SOURCE:
1175 {
1176 switch (downstream_comp->class->type) {
1177 case BT_COMPONENT_CLASS_TYPE_FILTER:
1178 listeners =
1179 graph->listeners.source_filter_ports_connected;
1180 break;
1181 case BT_COMPONENT_CLASS_TYPE_SINK:
1182 listeners =
1183 graph->listeners.source_sink_ports_connected;
1184 break;
1185 default:
1186 abort();
1187 }
262e5473 1188
d94d92ac
PP
1189 break;
1190 }
1191 case BT_COMPONENT_CLASS_TYPE_FILTER:
1192 {
1193 switch (downstream_comp->class->type) {
9c0a126a
PP
1194 case BT_COMPONENT_CLASS_TYPE_FILTER:
1195 listeners =
1196 graph->listeners.filter_filter_ports_connected;
1197 break;
d94d92ac
PP
1198 case BT_COMPONENT_CLASS_TYPE_SINK:
1199 listeners =
1200 graph->listeners.filter_sink_ports_connected;
1201 break;
1202 default:
1203 abort();
1204 }
1bf957a0 1205
d94d92ac
PP
1206 break;
1207 }
1208 default:
1209 abort();
1210 }
1211
1212 for (i = 0; i < listeners->len; i++) {
1213 struct bt_graph_listener_ports_connected *listener =
1214 &g_array_index(listeners,
1215 struct bt_graph_listener_ports_connected, i);
1216
1217 BT_ASSERT(listener->func);
8cc56726 1218 status = listener->func(upstream_comp, downstream_comp,
d94d92ac 1219 upstream_port, downstream_port, listener->base.data);
d24d5663 1220 if (status != BT_FUNC_STATUS_OK) {
8cc56726
SM
1221 goto end;
1222 }
1bf957a0 1223 }
8cc56726
SM
1224
1225end:
1226 return status;
1bf957a0
PP
1227}
1228
f167d3c0
PP
1229BT_HIDDEN
1230void bt_graph_remove_connection(struct bt_graph *graph,
1231 struct bt_connection *connection)
1232{
f6ccaed9
PP
1233 BT_ASSERT(graph);
1234 BT_ASSERT(connection);
3f7d4d90 1235 BT_LIB_LOGD("Removing graph's connection: %![graph-]+g, %![conn-]+x",
262e5473 1236 graph, connection);
f167d3c0
PP
1237 g_ptr_array_remove(graph->connections, connection);
1238}
36712f1d 1239
d94d92ac
PP
1240static inline
1241bool component_name_exists(struct bt_graph *graph, const char *name)
1242{
1243 bool exists = false;
1244 uint64_t i;
1245
1246 for (i = 0; i < graph->components->len; i++) {
1247 struct bt_component *other_comp = graph->components->pdata[i];
1248
1249 if (strcmp(name, bt_component_get_name(other_comp)) == 0) {
1250 BT_ASSERT_PRE_MSG("Another component with the same name already exists in the graph: "
1251 "%![other-comp-]+c, name=\"%s\"",
1252 other_comp, name);
1253 exists = true;
1254 goto end;
1255 }
1256 }
1257
1258end:
1259 return exists;
1260}
1261
1262static
d24d5663 1263int add_component_with_init_method_data(
0d72b8c3 1264 struct bt_graph *graph,
d94d92ac
PP
1265 struct bt_component_class *comp_cls,
1266 comp_init_method_t init_method,
05e21286 1267 const char *name, const struct bt_value *params,
e874da19 1268 void *init_method_data, bt_logging_level log_level,
9628043c 1269 const struct bt_component **user_component)
36712f1d 1270{
d24d5663
PP
1271 int status = BT_FUNC_STATUS_OK;
1272 enum bt_component_class_init_method_status init_status;
36712f1d 1273 struct bt_component *component = NULL;
d94d92ac
PP
1274 int ret;
1275 bool init_can_consume;
05e21286 1276 struct bt_value *new_params = NULL;
36712f1d 1277
d94d92ac
PP
1278 BT_ASSERT(comp_cls);
1279 BT_ASSERT_PRE_NON_NULL(graph, "Graph");
1280 BT_ASSERT_PRE_NON_NULL(name, "Name");
5badd463
PP
1281 BT_ASSERT_PRE(
1282 graph->config_state == BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
38cda5da 1283 "Graph is not in the \"configuring\" state: %!+g", graph);
d94d92ac
PP
1284 BT_ASSERT_PRE(!component_name_exists(graph, name),
1285 "Duplicate component name: %!+g, name=\"%s\"", graph, name);
1286 BT_ASSERT_PRE(!params || bt_value_is_map(params),
1287 "Parameter value is not a map value: %!+v", params);
4aa7981f 1288 init_can_consume = graph->can_consume;
d94d92ac 1289 bt_graph_set_can_consume(graph, false);
3f7d4d90 1290 BT_LIB_LOGI("Adding component to graph: "
e874da19
PP
1291 "%![graph-]+g, %![cc-]+C, name=\"%s\", log-level=%s, "
1292 "%![params-]+v, init-method-data-addr=%p",
1293 graph, comp_cls, name,
1294 bt_common_logging_level_string(log_level), params,
1295 init_method_data);
36712f1d 1296
d94d92ac 1297 if (!params) {
05e21286
PP
1298 new_params = bt_value_map_create();
1299 if (!new_params) {
870631a2
PP
1300 BT_LIB_LOGE_APPEND_CAUSE(
1301 "Cannot create empty map value object.");
d24d5663 1302 status = BT_FUNC_STATUS_MEMORY_ERROR;
36712f1d
PP
1303 goto end;
1304 }
05e21286
PP
1305
1306 params = new_params;
36712f1d
PP
1307 }
1308
e874da19 1309 ret = bt_component_create(comp_cls, name, log_level, &component);
d94d92ac 1310 if (ret) {
870631a2
PP
1311 BT_LIB_LOGE_APPEND_CAUSE(
1312 "Cannot create empty component object: ret=%d",
d94d92ac 1313 ret);
d24d5663 1314 status = BT_FUNC_STATUS_MEMORY_ERROR;
36712f1d
PP
1315 goto end;
1316 }
1317
1318 /*
1319 * The user's initialization method needs to see that this
1320 * component is part of the graph. If the user method fails, we
1321 * immediately remove the component from the graph's components.
1322 */
1323 g_ptr_array_add(graph->components, component);
1324 bt_component_set_graph(component, graph);
0d47d31b 1325 bt_value_freeze(params);
36712f1d 1326
d94d92ac 1327 if (init_method) {
36712f1d 1328 BT_LOGD_STR("Calling user's initialization method.");
d24d5663 1329 init_status = init_method(component, params, init_method_data);
36712f1d 1330 BT_LOGD("User method returned: status=%s",
d24d5663
PP
1331 bt_common_func_status_string(init_status));
1332 if (init_status != BT_FUNC_STATUS_OK) {
870631a2
PP
1333 if (init_status < 0) {
1334 BT_LIB_LOGW_APPEND_CAUSE(
1335 "Component initialization method failed: "
1336 "status=%s, %![comp-]+c",
1337 bt_common_func_status_string(init_status),
1338 component);
1339 }
1340
d24d5663 1341 status = init_status;
36712f1d
PP
1342 bt_component_set_graph(component, NULL);
1343 g_ptr_array_remove_fast(graph->components, component);
1344 goto end;
1345 }
1346 }
1347
1348 /*
1349 * Mark the component as initialized so that its finalization
1350 * method is called when it is destroyed.
1351 */
1352 component->initialized = true;
1353
1354 /*
1355 * If it's a sink component, it needs to be part of the graph's
648dab91
PP
1356 * sink queue to be consumed by bt_graph_run() or
1357 * bt_graph_run_once().
36712f1d
PP
1358 */
1359 if (bt_component_is_sink(component)) {
d94d92ac 1360 graph->has_sink = true;
36712f1d
PP
1361 g_queue_push_tail(graph->sinks_to_consume, component);
1362 }
1363
1364 /*
1365 * Freeze the component class now that it's instantiated at
1366 * least once.
1367 */
1368 BT_LOGD_STR("Freezing component class.");
d94d92ac 1369 bt_component_class_freeze(comp_cls);
3f7d4d90 1370 BT_LIB_LOGI("Added component to graph: "
e874da19
PP
1371 "%![graph-]+g, %![cc-]+C, name=\"%s\", log-level=%s, "
1372 "%![params-]+v, init-method-data-addr=%p, %![comp-]+c",
1373 graph, comp_cls, name,
1374 bt_common_logging_level_string(log_level), params,
1375 init_method_data, component);
36712f1d
PP
1376
1377 if (user_component) {
1378 /* Move reference to user */
1379 *user_component = component;
1380 component = NULL;
1381 }
1382
1383end:
d24d5663 1384 if (status != BT_FUNC_STATUS_OK) {
8cc56726 1385 bt_graph_make_faulty(graph);
38cda5da
PP
1386 }
1387
65300d60 1388 bt_object_put_ref(component);
05e21286 1389 bt_object_put_ref(new_params);
d94d92ac
PP
1390 (void) init_can_consume;
1391 bt_graph_set_can_consume(graph, init_can_consume);
d24d5663 1392 return status;
36712f1d
PP
1393}
1394
d24d5663 1395enum bt_graph_add_component_status
0d72b8c3
PP
1396bt_graph_add_source_component_with_init_method_data(
1397 struct bt_graph *graph,
1398 const struct bt_component_class_source *comp_cls,
05e21286 1399 const char *name, const struct bt_value *params,
e874da19 1400 void *init_method_data, bt_logging_level log_level,
0d72b8c3 1401 const struct bt_component_source **component)
d94d92ac
PP
1402{
1403 BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
1404 return add_component_with_init_method_data(graph,
1405 (void *) comp_cls, (comp_init_method_t) comp_cls->methods.init,
e874da19 1406 name, params, init_method_data, log_level, (void *) component);
d94d92ac
PP
1407}
1408
d24d5663 1409enum bt_graph_add_component_status bt_graph_add_source_component(
0d72b8c3
PP
1410 struct bt_graph *graph,
1411 const struct bt_component_class_source *comp_cls,
05e21286 1412 const char *name, const struct bt_value *params,
9628043c 1413 enum bt_logging_level log_level,
0d72b8c3 1414 const struct bt_component_source **component)
d94d92ac 1415{
0d72b8c3 1416 return bt_graph_add_source_component_with_init_method_data(
e874da19 1417 graph, comp_cls, name, params, NULL, log_level, component);
d94d92ac
PP
1418}
1419
d24d5663 1420enum bt_graph_add_component_status
0d72b8c3
PP
1421bt_graph_add_filter_component_with_init_method_data(
1422 struct bt_graph *graph,
1423 const struct bt_component_class_filter *comp_cls,
05e21286 1424 const char *name, const struct bt_value *params,
9628043c 1425 void *init_method_data, enum bt_logging_level log_level,
0d72b8c3 1426 const struct bt_component_filter **component)
d94d92ac
PP
1427{
1428 BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
1429 return add_component_with_init_method_data(graph,
1430 (void *) comp_cls, (comp_init_method_t) comp_cls->methods.init,
e874da19 1431 name, params, init_method_data, log_level, (void *) component);
d94d92ac
PP
1432}
1433
d24d5663 1434enum bt_graph_add_component_status bt_graph_add_filter_component(
0d72b8c3
PP
1435 struct bt_graph *graph,
1436 const struct bt_component_class_filter *comp_cls,
05e21286 1437 const char *name, const struct bt_value *params,
9628043c 1438 enum bt_logging_level log_level,
0d72b8c3 1439 const struct bt_component_filter **component)
d94d92ac 1440{
0d72b8c3 1441 return bt_graph_add_filter_component_with_init_method_data(
e874da19 1442 graph, comp_cls, name, params, NULL, log_level, component);
d94d92ac
PP
1443}
1444
d24d5663 1445enum bt_graph_add_component_status
0d72b8c3
PP
1446bt_graph_add_sink_component_with_init_method_data(
1447 struct bt_graph *graph,
1448 const struct bt_component_class_sink *comp_cls,
05e21286 1449 const char *name, const struct bt_value *params,
9628043c 1450 void *init_method_data, enum bt_logging_level log_level,
0d72b8c3 1451 const struct bt_component_sink **component)
36712f1d 1452{
d94d92ac
PP
1453 BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class");
1454 return add_component_with_init_method_data(graph,
1455 (void *) comp_cls, (comp_init_method_t) comp_cls->methods.init,
e874da19 1456 name, params, init_method_data, log_level, (void *) component);
d94d92ac
PP
1457}
1458
d24d5663 1459enum bt_graph_add_component_status bt_graph_add_sink_component(
0d72b8c3
PP
1460 struct bt_graph *graph,
1461 const struct bt_component_class_sink *comp_cls,
05e21286 1462 const char *name, const struct bt_value *params,
9628043c 1463 enum bt_logging_level log_level,
0d72b8c3 1464 const struct bt_component_sink **component)
d94d92ac 1465{
0d72b8c3 1466 return bt_graph_add_sink_component_with_init_method_data(
e874da19 1467 graph, comp_cls, name, params, NULL, log_level, component);
36712f1d 1468}
8ed535b5 1469
078033ed
PP
1470enum bt_graph_add_component_status
1471bt_graph_add_simple_sink_component(struct bt_graph *graph, const char *name,
1472 bt_graph_simple_sink_component_init_func init_func,
1473 bt_graph_simple_sink_component_consume_func consume_func,
1474 bt_graph_simple_sink_component_finalize_func finalize_func,
1475 void *user_data, const bt_component_sink **component)
1476{
1477 enum bt_graph_add_component_status status;
1478 struct bt_component_class_sink *comp_cls;
1479 struct simple_sink_init_method_data init_method_data = {
1480 .init_func = init_func,
1481 .consume_func = consume_func,
1482 .finalize_func = finalize_func,
1483 .user_data = user_data,
1484 };
1485
1486 /*
1487 * Other preconditions are checked by
1488 * bt_graph_add_sink_component_with_init_method_data().
1489 */
1490 BT_ASSERT_PRE_NON_NULL(consume_func, "Consume function");
1491
1492 comp_cls = bt_component_class_sink_simple_borrow();
1493 if (!comp_cls) {
1494 BT_LIB_LOGE_APPEND_CAUSE(
1495 "Cannot borrow simple sink component class.");
1496 status = BT_FUNC_STATUS_MEMORY_ERROR;
1497 goto end;
1498 }
1499
1500 status = bt_graph_add_sink_component_with_init_method_data(graph,
1501 comp_cls, name, NULL, &init_method_data,
1502 BT_LOGGING_LEVEL_NONE, component);
1503
1504end:
1505 return status;
1506}
1507
8ed535b5
PP
1508BT_HIDDEN
1509int bt_graph_remove_unconnected_component(struct bt_graph *graph,
1510 struct bt_component *component)
1511{
d94d92ac
PP
1512 bool init_can_consume;
1513 uint64_t count;
8ed535b5
PP
1514 uint64_t i;
1515 int ret = 0;
1516
f6ccaed9
PP
1517 BT_ASSERT(graph);
1518 BT_ASSERT(component);
3fea54f6 1519 BT_ASSERT(component->base.ref_count == 0);
f6ccaed9 1520 BT_ASSERT(bt_component_borrow_graph(component) == graph);
8ed535b5 1521
4aa7981f 1522 init_can_consume = graph->can_consume;
8ed535b5
PP
1523 count = bt_component_get_input_port_count(component);
1524
1525 for (i = 0; i < count; i++) {
d94d92ac
PP
1526 struct bt_port *port = (void *)
1527 bt_component_borrow_input_port_by_index(component, i);
8ed535b5 1528
f6ccaed9 1529 BT_ASSERT(port);
8ed535b5
PP
1530
1531 if (bt_port_is_connected(port)) {
870631a2
PP
1532 BT_LIB_LOGW_APPEND_CAUSE(
1533 "Cannot remove component from graph: "
8ed535b5 1534 "an input port is connected: "
d94d92ac
PP
1535 "%![graph-]+g, %![comp-]+c, %![port-]+p",
1536 graph, component, port);
8ed535b5
PP
1537 goto error;
1538 }
1539 }
1540
1541 count = bt_component_get_output_port_count(component);
1542
1543 for (i = 0; i < count; i++) {
d94d92ac
PP
1544 struct bt_port *port = (void *)
1545 bt_component_borrow_output_port_by_index(component, i);
8ed535b5 1546
f6ccaed9 1547 BT_ASSERT(port);
8ed535b5
PP
1548
1549 if (bt_port_is_connected(port)) {
870631a2
PP
1550 BT_LIB_LOGW_APPEND_CAUSE(
1551 "Cannot remove component from graph: "
8ed535b5 1552 "an output port is connected: "
d94d92ac
PP
1553 "%![graph-]+g, %![comp-]+c, %![port-]+p",
1554 graph, component, port);
8ed535b5
PP
1555 goto error;
1556 }
1557 }
1558
d94d92ac 1559 bt_graph_set_can_consume(graph, false);
8ed535b5
PP
1560
1561 /* Possibly remove from sinks to consume */
1562 (void) g_queue_remove(graph->sinks_to_consume, component);
1563
1564 if (graph->sinks_to_consume->length == 0) {
d94d92ac 1565 graph->has_sink = false;
8ed535b5
PP
1566 }
1567
1568 /*
3fea54f6
PP
1569 * This calls bt_object_try_spec_release() on the component, and
1570 * since its reference count is 0, its destructor is called. Its
8ed535b5
PP
1571 * destructor calls the user's finalization method (if set).
1572 */
1573 g_ptr_array_remove(graph->components, component);
1574 goto end;
1575
1576error:
1577 ret = -1;
1578
1579end:
d94d92ac
PP
1580 (void) init_can_consume;
1581 bt_graph_set_can_consume(graph, init_can_consume);
8ed535b5
PP
1582 return ret;
1583}
5c563278
PP
1584
1585BT_HIDDEN
d6e69534
PP
1586void bt_graph_add_message(struct bt_graph *graph,
1587 struct bt_message *msg)
5c563278
PP
1588{
1589 BT_ASSERT(graph);
d6e69534 1590 BT_ASSERT(msg);
5c563278
PP
1591
1592 /*
1593 * It's okay not to take a reference because, when a
d6e69534 1594 * message's reference count drops to 0, either:
5c563278
PP
1595 *
1596 * * It is recycled back to one of this graph's pool.
1597 * * It is destroyed because it doesn't have any link to any
1598 * graph, which means the original graph is already destroyed.
1599 */
d6e69534 1600 g_ptr_array_add(graph->messages, msg);
5c563278 1601}
c5b9b441 1602
9b4f9b42
PP
1603BT_HIDDEN
1604bool bt_graph_is_interrupted(const struct bt_graph *graph)
1605{
1606 BT_ASSERT(graph);
1607 return bt_interrupter_array_any_is_set(graph->interrupters);
1608}
1609
1610enum bt_graph_add_interrupter_status bt_graph_add_interrupter(
1611 struct bt_graph *graph, const struct bt_interrupter *intr)
1612{
1613 BT_ASSERT_PRE_NON_NULL(graph, "Graph");
1614 BT_ASSERT_PRE_NON_NULL(intr, "Interrupter");
1615 g_ptr_array_add(graph->interrupters, (void *) intr);
1616 bt_object_get_no_null_check(intr);
1617 BT_LIB_LOGD("Added interrupter to graph: %![graph-]+g, %![intr-]+z",
1618 graph, intr);
1619 return BT_FUNC_STATUS_OK;
1620}
1621
1622void bt_graph_interrupt(struct bt_graph *graph)
1623{
1624 BT_ASSERT_PRE_NON_NULL(graph, "Graph");
1625 bt_interrupter_set(graph->default_interrupter);
1626 BT_LIB_LOGI("Interrupted graph: %!+g", graph);
1627}
1628
c5b9b441
PP
1629void bt_graph_get_ref(const struct bt_graph *graph)
1630{
1631 bt_object_get_ref(graph);
1632}
1633
1634void bt_graph_put_ref(const struct bt_graph *graph)
1635{
1636 bt_object_put_ref(graph);
1637}
This page took 0.134645 seconds and 4 git commands to generate.