if (!iter_pos)
return;
- if (iter_pos->u.restore) {
+ if (iter_pos->type == BT_SEEK_RESTORE && iter_pos->u.restore) {
if (iter_pos->u.restore->stream_saved_pos) {
g_array_free(
iter_pos->u.restore->stream_saved_pos,
*/
stream->timestamp = saved_pos->current_timestamp;
stream_pos->offset = saved_pos->offset;
- stream_pos->last_offset = saved_pos->offset;
+ stream_pos->last_offset = LAST_OFFSET_POISON;
stream->prev_timestamp = 0;
stream->prev_timestamp_end = 0;
- stream->consumed = 0;
printf_debug("restored to cur_index = %zd and "
"offset = %zd, timestamp = %" PRIu64 "\n",
if (ret)
goto error;
}
+ return 0;
case BT_SEEK_TIME:
tc = iter->ctx->tc;
int i, stream_class_id, stream_id;
pos = g_new0(struct bt_iter_pos, 1);
+ pos->type = BT_SEEK_RESTORE;
pos->u.restore = g_new0(struct bt_saved_pos, 1);
pos->u.restore->tc = tc;
pos->u.restore->stream_saved_pos = g_array_new(FALSE, TRUE,
saved_pos.file_stream = cfs;
saved_pos.cur_index = cfs->pos.cur_index;
-
- /*
- * It is possible that an event was read during
- * the last restore, never consumed and its
- * position saved again. For this case, we
- * need to check if the event really was
- * consumed by the caller otherwise it is lost.
- */
- if (stream->consumed)
- saved_pos.offset = cfs->pos.offset;
- else
- saved_pos.offset = cfs->pos.last_offset;
-
+ saved_pos.offset = cfs->pos.last_offset;
saved_pos.current_timestamp = stream->timestamp;
g_array_append_val(