iterator->connection = NULL;
}
- if (iterator->auto_seek_msgs) {
- while (!g_queue_is_empty(iterator->auto_seek_msgs)) {
+ if (iterator->auto_seek.msgs) {
+ while (!g_queue_is_empty(iterator->auto_seek.msgs)) {
bt_object_put_no_null_check(
- g_queue_pop_tail(iterator->auto_seek_msgs));
+ g_queue_pop_tail(iterator->auto_seek.msgs));
}
- g_queue_free(iterator->auto_seek_msgs);
- iterator->auto_seek_msgs = NULL;
+ g_queue_free(iterator->auto_seek.msgs);
+ iterator->auto_seek.msgs = NULL;
}
destroy_base_message_iterator(obj);
goto end;
}
- iterator->auto_seek_msgs = g_queue_new();
- if (!iterator->auto_seek_msgs) {
+ iterator->auto_seek.msgs = g_queue_new();
+ if (!iterator->auto_seek.msgs) {
BT_LOGE_STR("Failed to allocate a GQueue.");
ret = -1;
goto end;
goto end;
push_msg:
- g_queue_push_tail(iterator->auto_seek_msgs, (void *) msg);
+ g_queue_push_tail(iterator->auto_seek.msgs, (void *) msg);
msg = NULL;
end:
for (i = 0; i < user_count; i++) {
if (got_first) {
- g_queue_push_tail(iterator->auto_seek_msgs,
+ g_queue_push_tail(iterator->auto_seek.msgs,
(void *) messages[i]);
messages[i] = NULL;
continue;
bt_message_array_const msgs, uint64_t capacity,
uint64_t *count)
{
- BT_ASSERT(!g_queue_is_empty(iterator->auto_seek_msgs));
+ BT_ASSERT(!g_queue_is_empty(iterator->auto_seek.msgs));
*count = 0;
/*
* Move auto-seek messages to the output array (which is this
* iterator's base message array).
*/
- while (capacity > 0 && !g_queue_is_empty(iterator->auto_seek_msgs)) {
- msgs[*count] = g_queue_pop_head(iterator->auto_seek_msgs);
+ while (capacity > 0 && !g_queue_is_empty(iterator->auto_seek.msgs)) {
+ msgs[*count] = g_queue_pop_head(iterator->auto_seek.msgs);
capacity--;
(*count)++;
}
BT_ASSERT(*count > 0);
- if (g_queue_is_empty(iterator->auto_seek_msgs)) {
+ if (g_queue_is_empty(iterator->auto_seek.msgs)) {
/* No more auto-seek messages */
switch (iterator->upstream_component->class->type) {
case BT_COMPONENT_CLASS_TYPE_SOURCE:
* this point in the batch to this iterator's auto-seek
* message queue.
*/
- while (!g_queue_is_empty(iterator->auto_seek_msgs)) {
+ while (!g_queue_is_empty(iterator->auto_seek.msgs)) {
bt_object_put_no_null_check(
- g_queue_pop_tail(iterator->auto_seek_msgs));
+ g_queue_pop_tail(iterator->auto_seek.msgs));
}
status = find_message_ge_ns_from_origin(iterator,
* method with a custom, temporary "next" method
* which returns them.
*/
- if (!g_queue_is_empty(iterator->auto_seek_msgs)) {
+ if (!g_queue_is_empty(iterator->auto_seek.msgs)) {
iterator->methods.next =
(bt_self_component_port_input_message_iterator_next_method)
post_auto_seek_next;
} methods;
enum bt_self_component_port_input_message_iterator_state state;
- GQueue *auto_seek_msgs;
+
+ /*
+ * Data necessary for auto seek (the seek-to-beginning then fast-forward
+ * seek strategy).
+ */
+ struct {
+ /*
+ * Queue of `const bt_message *` (owned by this queue).
+ *
+ * When fast-forwarding, we get the messages from upstream in
+ * batches. Once we have found the first message with timestamp
+ * greater or equal to the seek time, we put it and all of the
+ * following message of the batch in this queue. They will be
+ * sent on the next "next" call on this iterator.
+ *
+ * The messages are in chronological order (i.e. the first to
+ * send is the first of the queue).
+ */
+ GQueue *msgs;
+ } auto_seek;
+
void *user_data;
};