- if (stream_state->cur_packet) {
- /* End of the current packet */
- ret = add_action_push_notif_packet_end(iterator,
- stream_state->cur_packet);
- if (ret) {
- goto error;
- }
- }
-
- /* Beginning of the new packet */
- if (packet_begin_notif) {
- add_action_push_notif(iterator, packet_begin_notif);
- } else if (new_packet) {
- ret = add_action_push_notif_packet_begin(iterator,
- new_packet);
- if (ret) {
- goto error;
- }
- }
-
- add_action_set_stream_state_cur_packet(iterator, stream_state,
- new_packet);
- goto end;
-
-error:
- ret = -1;
-
-end:
- return ret;
-}
-
-static
-int handle_notif_stream_begin(
- struct bt_notification_iterator *iterator,
- struct bt_notification *notif,
- struct bt_ctf_stream *notif_stream)
-{
- int ret = 0;
- struct stream_state *stream_state;
-
- assert(notif->type == BT_NOTIFICATION_TYPE_STREAM_BEGIN);
- assert(notif_stream);
- ret = ensure_stream_state_exists(iterator, notif, notif_stream,
- &stream_state);
- if (ret) {
- goto error;
- }
-
- goto end;
-
-error:
- ret = -1;
-
-end:
- return ret;
-}
-
-static
-int handle_notif_stream_end(
- struct bt_notification_iterator *iterator,
- struct bt_notification *notif,
- struct bt_ctf_stream *notif_stream)
-{
- int ret = 0;
- struct stream_state *stream_state;
-
- assert(notif->type == BT_NOTIFICATION_TYPE_STREAM_END);
- assert(notif_stream);
- ret = ensure_stream_state_exists(iterator, NULL, notif_stream,
- &stream_state);
- if (ret) {
- goto error;
- }
-
- ret = handle_packet_switch(iterator, NULL, NULL, stream_state);
- if (ret) {
- goto error;
- }
-
- add_action_push_notif(iterator, notif);
- add_action_set_stream_state_is_ended(iterator, stream_state);
- goto end;
-
-error:
- ret = -1;
-
-end:
- return ret;
-}
-
-static
-int handle_notif_packet_begin(
- struct bt_notification_iterator *iterator,
- struct bt_notification *notif,
- struct bt_ctf_stream *notif_stream,
- struct bt_ctf_packet *notif_packet)
-{
- int ret = 0;
- struct stream_state *stream_state;
-
- assert(notif->type == BT_NOTIFICATION_TYPE_PACKET_BEGIN);
- assert(notif_packet);
- ret = ensure_stream_state_exists(iterator, NULL, notif_stream,
- &stream_state);
- if (ret) {
- goto error;
- }
-
- ret = handle_packet_switch(iterator, notif, notif_packet, stream_state);
- if (ret) {
- goto error;
- }
-
- goto end;
-
-error:
- ret = -1;
-
-end:
- return ret;
-}
-
-static
-int handle_notif_packet_end(
- struct bt_notification_iterator *iterator,
- struct bt_notification *notif,
- struct bt_ctf_stream *notif_stream,
- struct bt_ctf_packet *notif_packet)
-{
- int ret = 0;
- struct stream_state *stream_state;
-
- assert(notif->type == BT_NOTIFICATION_TYPE_PACKET_END);
- assert(notif_packet);
- ret = ensure_stream_state_exists(iterator, NULL, notif_stream,
- &stream_state);
- if (ret) {
- goto error;
- }
-
- ret = handle_packet_switch(iterator, NULL, notif_packet, stream_state);
- if (ret) {
- goto error;
- }
-
- /* End of the current packet */
- add_action_push_notif(iterator, notif);
- add_action_set_stream_state_cur_packet(iterator, stream_state, NULL);
- goto end;
-
-error:
- ret = -1;
-
-end:
- return ret;
-}
-
-static
-int handle_notif_event(
- struct bt_notification_iterator *iterator,
- struct bt_notification *notif,
- struct bt_ctf_stream *notif_stream,
- struct bt_ctf_packet *notif_packet)
-{
- int ret = 0;
- struct stream_state *stream_state;
-
- assert(notif->type == BT_NOTIFICATION_TYPE_EVENT);
- assert(notif_packet);
- ret = ensure_stream_state_exists(iterator, NULL, notif_stream,
- &stream_state);
- if (ret) {
- goto error;
- }
-
- ret = handle_packet_switch(iterator, NULL, notif_packet, stream_state);
- if (ret) {
- goto error;
+ switch (status) {
+ case BT_NOTIFICATION_ITERATOR_STATUS_OK:
+ BT_ASSERT_PRE(validate_notifications(iterator, *user_count),
+ "Notifications are invalid at this point: "
+ "%![notif-iter-]+i, count=%" PRIu64,
+ iterator, *user_count);
+ *user_notifs = (void *) user_iterator->notifs->pdata;
+ break;
+ case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
+ status = BT_NOTIFICATION_ITERATOR_STATUS_AGAIN;
+ goto end;
+ case BT_NOTIFICATION_ITERATOR_STATUS_END:
+ BT_ASSERT_PRE(priv_conn_notif_iter_can_end(iterator),
+ "Notification iterator cannot end at this point: "
+ "%!+i", iterator);
+ BT_ASSERT(iterator->state ==
+ BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ACTIVE);
+ iterator->state = BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ENDED;
+ status = BT_NOTIFICATION_ITERATOR_STATUS_END;
+ BT_LOGD("Set new status: status=%s",
+ bt_notification_iterator_status_string(status));
+ goto end;
+ default:
+ /* Unknown non-error status */
+ abort();