"Message iterator is in the wrong state: %!+i", _iter)
static inline
-void _set_self_comp_port_input_msg_iterator_state(
+void set_self_comp_port_input_msg_iterator_state(
struct bt_self_component_port_input_message_iterator *iterator,
enum bt_self_component_port_input_message_iterator_state state)
{
iterator->state = state;
}
-#ifdef BT_DEV_MODE
-# define set_self_comp_port_input_msg_iterator_state _set_self_comp_port_input_msg_iterator_state
-#else
-# define set_self_comp_port_input_msg_iterator_state(_a, _b)
-#endif
-
static
void destroy_base_message_iterator(struct bt_object *obj)
{
"%!+i, user-data-addr=%p", iterator, data);
}
-BT_ASSERT_PRE_FUNC
-static inline
-void bt_message_borrow_packet_stream(const struct bt_message *msg,
- const struct bt_stream **stream,
- const struct bt_packet **packet)
-{
- BT_ASSERT(msg);
-
- switch (msg->type) {
- case BT_MESSAGE_TYPE_EVENT:
- *packet = bt_event_borrow_packet_const(
- bt_message_event_borrow_event_const(msg));
- *stream = bt_packet_borrow_stream_const(*packet);
- break;
- case BT_MESSAGE_TYPE_STREAM_BEGINNING:
- *stream = bt_message_stream_beginning_borrow_stream_const(msg);
- break;
- case BT_MESSAGE_TYPE_STREAM_END:
- *stream = bt_message_stream_end_borrow_stream_const(msg);
- break;
- case BT_MESSAGE_TYPE_PACKET_BEGINNING:
- *packet = bt_message_packet_beginning_borrow_packet_const(msg);
- *stream = bt_packet_borrow_stream_const(*packet);
- break;
- case BT_MESSAGE_TYPE_PACKET_END:
- *packet = bt_message_packet_end_borrow_packet_const(msg);
- *stream = bt_packet_borrow_stream_const(*packet);
- break;
- default:
- break;
- }
-}
-
enum bt_message_iterator_status
bt_self_component_port_input_message_iterator_next(
struct bt_self_component_port_input_message_iterator *iterator,
goto end;
}
-#ifdef BT_DEV_MODE
/*
* There is no way that this iterator could have been finalized
* during its "next" method, as the only way to do this is to
*/
BT_ASSERT(iterator->state ==
BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE);
-#endif
switch (status) {
case BT_MESSAGE_ITERATOR_STATUS_OK:
(void *) graph,
"Output port is not part of graph: %![graph-]+g, %![port-]+p",
graph, output_port);
+ BT_ASSERT_PRE(!graph->has_sink,
+ "Graph already has a sink component: %![graph-]+g");
/* Create message iterator */
BT_LIB_LOGD("Creating message iterator on output port: "
*/
bt_graph_set_can_consume(iterator->graph, false);
- /*
- * Also set the graph as being configured: it has no active sink
- * anyway, so we don't need to call bt_graph_configure().
- */
- graph->config_state = BT_GRAPH_CONFIGURATION_STATE_CONFIGURED;
+ /* Also set the graph as being configured. */
+ graph_status = bt_graph_configure(graph);
+ if (graph_status != BT_GRAPH_STATUS_OK) {
+ BT_LIB_LOGW("Cannot configure graph after having added colander: "
+ "%![graph-]+g, status=%s", graph,
+ bt_graph_status_string(graph_status));
+ goto error;
+ }
goto end;
error:
}
static inline
-void _set_iterator_state_after_seeking(
+void set_iterator_state_after_seeking(
struct bt_self_component_port_input_message_iterator *iterator,
enum bt_message_iterator_status status)
{
set_self_comp_port_input_msg_iterator_state(iterator, new_state);
}
-#ifdef BT_DEV_MODE
-# define set_iterator_state_after_seeking _set_iterator_state_after_seeking
-#else
-# define set_iterator_state_after_seeking(_iter, _status)
-#endif
-
enum bt_message_iterator_status
bt_self_component_port_input_message_iterator_seek_beginning(
struct bt_self_component_port_input_message_iterator *iterator)
status == BT_MESSAGE_ITERATOR_STATUS_NOMEM ||
status == BT_MESSAGE_ITERATOR_STATUS_AGAIN,
"Unexpected status: %![iter-]+i, status=%s",
- iterator, bt_self_message_iterator_status_string(status));
+ iterator, bt_common_self_message_iterator_status_string(status));
set_iterator_state_after_seeking(iterator, status);
return status;
}
skip_msg:
bt_object_put_no_null_check(msg);
+ msg = NULL;
goto end;
push_msg:
BT_ASSERT(iterator->methods.next);
- while (true) {
+ while (!got_first) {
/*
* Call the user's "next" method to get the next
* messages and status.
BT_LOGD("User method returned: status=%s",
bt_message_iterator_status_string(status));
-#ifdef BT_DEV_MODE
/*
* The user's "next" method must not do any action which
* would change the iterator's state.
*/
BT_ASSERT(iterator->state ==
BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE);
-#endif
switch (status) {
case BT_MESSAGE_ITERATOR_STATUS_OK:
status = auto_seek_handle_message(iterator,
ns_from_origin, messages[i], &got_first);
if (status == BT_MESSAGE_ITERATOR_STATUS_OK) {
- /* Message was either put or moved */
+ /* Message was either pushed or moved */
messages[i] = NULL;
} else {
goto end;
status == BT_MESSAGE_ITERATOR_STATUS_AGAIN,
"Unexpected status: %![iter-]+i, status=%s",
iterator,
- bt_self_message_iterator_status_string(status));
+ bt_common_self_message_iterator_status_string(status));
} else {
/* Start automatic seeking: seek beginning first */
BT_ASSERT(iterator->methods.can_seek_beginning(iterator));
status == BT_MESSAGE_ITERATOR_STATUS_AGAIN,
"Unexpected status: %![iter-]+i, status=%s",
iterator,
- bt_self_message_iterator_status_string(status));
+ bt_common_self_message_iterator_status_string(status));
switch (status) {
case BT_MESSAGE_ITERATOR_STATUS_OK:
break;