const bt_port_output *upstream_port,
const bt_port_input *downstream_port, void *data);
-typedef void (* bt_graph_listener_removed_func)(void *data);
-
typedef enum bt_graph_simple_sink_component_initialize_func_status {
BT_GRAPH_SIMPLE_SINK_COMPONENT_INITIALIZE_FUNC_STATUS_OK = __BT_FUNC_STATUS_OK,
BT_GRAPH_SIMPLE_SINK_COMPONENT_INITIALIZE_FUNC_STATUS_ERROR = __BT_FUNC_STATUS_ERROR,
bt_graph_add_filter_component_input_port_added_listener(
bt_graph *graph,
bt_graph_filter_component_input_port_added_listener_func listener,
- bt_graph_listener_removed_func listener_removed, void *data,
- bt_listener_id *listener_id);
+ void *data, bt_listener_id *listener_id);
extern bt_graph_add_listener_status
bt_graph_add_sink_component_input_port_added_listener(
bt_graph *graph,
bt_graph_sink_component_input_port_added_listener_func listener,
- bt_graph_listener_removed_func listener_removed, void *data,
- bt_listener_id *listener_id);
+ void *data, bt_listener_id *listener_id);
extern bt_graph_add_listener_status
bt_graph_add_source_component_output_port_added_listener(
bt_graph *graph,
bt_graph_source_component_output_port_added_listener_func listener,
- bt_graph_listener_removed_func listener_removed, void *data,
- bt_listener_id *listener_id);
+ void *data, bt_listener_id *listener_id);
extern bt_graph_add_listener_status
bt_graph_add_filter_component_output_port_added_listener(
bt_graph *graph,
bt_graph_filter_component_output_port_added_listener_func listener,
- bt_graph_listener_removed_func listener_removed, void *data,
- bt_listener_id *listener_id);
+ void *data, bt_listener_id *listener_id);
typedef enum bt_graph_add_interrupter_status {
BT_GRAPH_ADD_INTERRUPTER_STATUS_OK = __BT_FUNC_STATUS_OK,
* THE SOFTWARE.
*/
-static
-void graph_listener_removed(void *py_callable)
-{
- BT_ASSERT(py_callable);
- Py_DECREF(py_callable);
-}
-
static bt_graph_listener_func_status port_added_listener(
const void *component,
swig_type_info *component_swig_type,
/* source output port */
status = bt_graph_add_source_component_output_port_added_listener(
graph, source_component_output_port_added_listener,
- graph_listener_removed, py_callable, &listener_id);
+ py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
/*
* bt_graph_add_source_component_output_port_added_listener has
/* filter input port */
status = bt_graph_add_filter_component_input_port_added_listener(
graph, filter_component_input_port_added_listener,
- graph_listener_removed, py_callable, &listener_id);
+ py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
/*
* bt_graph_add_filter_component_input_port_added_listener has
/* filter output port */
status = bt_graph_add_filter_component_output_port_added_listener(
graph, filter_component_output_port_added_listener,
- graph_listener_removed, py_callable, &listener_id);
+ py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
/*
* bt_graph_add_filter_component_output_port_added_listener has
/* sink input port */
status = bt_graph_add_sink_component_input_port_added_listener(
graph, sink_component_input_port_added_listener,
- graph_listener_removed, py_callable, &listener_id);
+ py_callable, &listener_id);
if (status != __BT_FUNC_STATUS_OK) {
/*
* bt_graph_add_sink_component_input_port_added_listener has
PyTuple_SET_ITEM(py_listener_ids, 3, py_listener_id);
py_listener_id = NULL;
-
- Py_INCREF(py_callable);
- Py_INCREF(py_callable);
- Py_INCREF(py_callable);
- Py_INCREF(py_callable);
-
goto end;
error:
typedef enum bt_component_class_initialize_method_status
(*comp_init_method_t)(const void *, void *, const void *, void *);
-struct bt_graph_listener {
- bt_graph_listener_removed_func removed;
- void *data;
-};
-
struct bt_graph_listener_port_added {
- struct bt_graph_listener base;
port_added_func_t func;
+ void *data;
};
#define INIT_LISTENERS_ARRAY(_type, _listeners) \
} \
} while (0)
-#define CALL_REMOVE_LISTENERS(_type, _listeners) \
- do { \
- size_t i; \
- \
- if (!_listeners) { \
- break; \
- } \
- for (i = 0; i < (_listeners)->len; i++) { \
- _type *listener = \
- &g_array_index((_listeners), _type, i); \
- \
- if (listener->base.removed) { \
- listener->base.removed(listener->base.data); \
- } \
- } \
- } while (0)
-
static
void destroy_graph(struct bt_object *obj)
{
obj->ref_count++;
graph->config_state = BT_GRAPH_CONFIGURATION_STATE_DESTROYING;
- /* Call all remove listeners */
- CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_added,
- graph->listeners.source_output_port_added);
- CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_added,
- graph->listeners.filter_output_port_added);
- CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_added,
- graph->listeners.filter_input_port_added);
- CALL_REMOVE_LISTENERS(struct bt_graph_listener_port_added,
- graph->listeners.sink_input_port_added);
-
if (graph->messages) {
g_ptr_array_free(graph->messages, TRUE);
graph->messages = NULL;
bt_graph_add_source_component_output_port_added_listener(
struct bt_graph *graph,
bt_graph_source_component_output_port_added_listener_func func,
- bt_graph_listener_removed_func listener_removed, void *data,
- bt_listener_id *out_listener_id)
+ void *data, bt_listener_id *out_listener_id)
{
struct bt_graph_listener_port_added listener = {
- .base = {
- .removed = listener_removed,
- .data = data,
- },
.func = (port_added_func_t) func,
+ .data = data,
};
bt_listener_id listener_id;
BT_ASSERT_PRE_NO_ERROR();
BT_ASSERT_PRE_NON_NULL(graph, "Graph");
BT_ASSERT_PRE_NON_NULL(func, "Listener");
- BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
- BT_ASSERT_PRE(!graph->in_remove_listener,
- "Graph currently executing a \"listener removed\" listener: "
- "%!+g", graph);
g_array_append_val(graph->listeners.source_output_port_added, listener);
listener_id = graph->listeners.source_output_port_added->len - 1;
BT_LIB_LOGD("Added \"source component output port added\" listener to graph: "
bt_graph_add_filter_component_output_port_added_listener(
struct bt_graph *graph,
bt_graph_filter_component_output_port_added_listener_func func,
- bt_graph_listener_removed_func listener_removed, void *data,
- bt_listener_id *out_listener_id)
+ void *data, bt_listener_id *out_listener_id)
{
struct bt_graph_listener_port_added listener = {
- .base = {
- .removed = listener_removed,
- .data = data,
- },
.func = (port_added_func_t) func,
+ .data = data,
};
bt_listener_id listener_id;
BT_ASSERT_PRE_NO_ERROR();
BT_ASSERT_PRE_NON_NULL(graph, "Graph");
BT_ASSERT_PRE_NON_NULL(func, "Listener");
- BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
- BT_ASSERT_PRE(!graph->in_remove_listener,
- "Graph currently executing a \"listener removed\" listener: "
- "%!+g", graph);
g_array_append_val(graph->listeners.filter_output_port_added, listener);
listener_id = graph->listeners.filter_output_port_added->len - 1;
BT_LIB_LOGD("Added \"filter component output port added\" listener to graph: "
bt_graph_add_filter_component_input_port_added_listener(
struct bt_graph *graph,
bt_graph_filter_component_input_port_added_listener_func func,
- bt_graph_listener_removed_func listener_removed, void *data,
- bt_listener_id *out_listener_id)
+ void *data, bt_listener_id *out_listener_id)
{
struct bt_graph_listener_port_added listener = {
- .base = {
- .removed = listener_removed,
- .data = data,
- },
.func = (port_added_func_t) func,
+ .data = data,
};
bt_listener_id listener_id;
BT_ASSERT_PRE_NO_ERROR();
BT_ASSERT_PRE_NON_NULL(graph, "Graph");
BT_ASSERT_PRE_NON_NULL(func, "Listener");
- BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
- BT_ASSERT_PRE(!graph->in_remove_listener,
- "Graph currently executing a \"listener removed\" listener: "
- "%!+g", graph);
g_array_append_val(graph->listeners.filter_input_port_added, listener);
listener_id = graph->listeners.filter_input_port_added->len - 1;
BT_LIB_LOGD("Added \"filter component input port added\" listener to graph: "
bt_graph_add_sink_component_input_port_added_listener(
struct bt_graph *graph,
bt_graph_sink_component_input_port_added_listener_func func,
- bt_graph_listener_removed_func listener_removed, void *data,
- bt_listener_id *out_listener_id)
+ void *data, bt_listener_id *out_listener_id)
{
struct bt_graph_listener_port_added listener = {
- .base = {
- .removed = listener_removed,
- .data = data,
- },
.func = (port_added_func_t) func,
+ .data = data,
};
bt_listener_id listener_id;
BT_ASSERT_PRE_NO_ERROR();
BT_ASSERT_PRE_NON_NULL(graph, "Graph");
BT_ASSERT_PRE_NON_NULL(func, "Listener");
- BT_ASSERT_PRE_NON_NULL(func, "\"Listener removed\" listener");
- BT_ASSERT_PRE(!graph->in_remove_listener,
- "Graph currently executing a \"listener removed\" listener: "
- "%!+g", graph);
g_array_append_val(graph->listeners.sink_input_port_added, listener);
listener_id = graph->listeners.sink_input_port_added->len - 1;
BT_LIB_LOGD("Added \"sink component input port added\" listener to graph: "
BT_ASSERT(listener->func);
- status = listener->func(comp, port, listener->base.data);
+ status = listener->func(comp, port, listener->data);
BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(status);
if (status != BT_FUNC_STATUS_OK) {
goto end;