Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/arvbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ G_BEGIN_DECLS
* @ARV_BUFFER_STATUS_FILLING: the image is currently being filled
* @ARV_BUFFER_STATUS_ABORTED: the filling was aborted before completion
* @ARV_BUFFER_STATUS_PAYLOAD_NOT_SUPPORTED: payload not yet supported
* @ARV_BUFFER_STATUS_UNDERRUN: buffer found late in input queue and timeout reached before all packets are received
*/

typedef enum {
Expand All @@ -56,7 +57,8 @@ typedef enum {
ARV_BUFFER_STATUS_SIZE_MISMATCH,
ARV_BUFFER_STATUS_FILLING,
ARV_BUFFER_STATUS_ABORTED,
ARV_BUFFER_STATUS_PAYLOAD_NOT_SUPPORTED
ARV_BUFFER_STATUS_PAYLOAD_NOT_SUPPORTED,
ARV_BUFFER_STATUS_UNDERRUN
} ArvBufferStatus;

/**
Expand Down
17 changes: 14 additions & 3 deletions src/arvgvstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ typedef struct {
gboolean resend_ratio_reached;

gboolean extended_ids;
gboolean underrun;
} ArvGvStreamFrameData;

struct _ArvGvStreamThreadData {
Expand Down Expand Up @@ -162,6 +163,8 @@ struct _ArvGvStreamThreadData {

gboolean use_packet_socket;

guint64 underrun_frame_id;

/* Statistics */

guint64 n_completed_buffers;
Expand Down Expand Up @@ -373,8 +376,10 @@ _find_frame_data (ArvGvStreamThreadData *thread_data,

buffer = arv_stream_pop_input_buffer (thread_data->stream);
if (buffer == NULL) {
thread_data->n_underruns++;

if (thread_data->underrun_frame_id != frame_id) {
thread_data->n_underruns++;
thread_data->underrun_frame_id = frame_id;
}
return NULL;
}

Expand All @@ -388,11 +393,13 @@ _find_frame_data (ArvGvStreamThreadData *thread_data,
thread_data->callback (thread_data->callback_data,
ARV_STREAM_CALLBACK_TYPE_BUFFER_DONE,
buffer);
thread_data->underrun_frame_id = 0;
return NULL;
}

frame = g_new0 (ArvGvStreamFrameData, 1);

frame->underrun = thread_data->underrun_frame_id == frame_id;
frame->disable_resend_request = FALSE;

frame->frame_id = frame_id;
Expand Down Expand Up @@ -431,6 +438,8 @@ _find_frame_data (ArvGvStreamThreadData *thread_data,

arv_histogram_fill (thread_data->histogram, 1, 0);

thread_data->underrun_frame_id = 0;

return frame;
}

Expand Down Expand Up @@ -833,7 +842,9 @@ _check_frame_completion (ArvGvStreamThreadData *thread_data,
* acquisition start. */
(frame->frame_id != thread_data->last_frame_id || frame->last_valid_packet != 0) &&
time_us - frame->last_packet_time_us >= thread_data->frame_retention_us) {
frame->buffer->priv->status = ARV_BUFFER_STATUS_TIMEOUT;
frame->buffer->priv->status = frame->underrun ?
ARV_BUFFER_STATUS_UNDERRUN :
ARV_BUFFER_STATUS_TIMEOUT;
arv_warning_stream_thread ("[GvStream::check_frame_completion] Timeout for frame %"
G_GUINT64_FORMAT " at dt = %" G_GUINT64_FORMAT,
frame->frame_id, time_us - frame->first_packet_time_us);
Expand Down
Loading