diff --git a/src/arvbuffer.h b/src/arvbuffer.h index 580cfb8fb..e7dacef1a 100644 --- a/src/arvbuffer.h +++ b/src/arvbuffer.h @@ -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 { @@ -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; /** diff --git a/src/arvgvstream.c b/src/arvgvstream.c index 13296a48b..ba52b61b8 100644 --- a/src/arvgvstream.c +++ b/src/arvgvstream.c @@ -123,6 +123,7 @@ typedef struct { gboolean resend_ratio_reached; gboolean extended_ids; + gboolean underrun; } ArvGvStreamFrameData; struct _ArvGvStreamThreadData { @@ -162,6 +163,8 @@ struct _ArvGvStreamThreadData { gboolean use_packet_socket; + guint64 underrun_frame_id; + /* Statistics */ guint64 n_completed_buffers; @@ -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; } @@ -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; @@ -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; } @@ -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);