Skip to content

Commit 7743c7c

Browse files
committed
gvstream: mark buffer status as underrun if buffer was late in input queue
1 parent e7238be commit 7743c7c

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/arvbuffer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ G_BEGIN_DECLS
4444
* @ARV_BUFFER_STATUS_FILLING: the image is currently being filled
4545
* @ARV_BUFFER_STATUS_ABORTED: the filling was aborted before completion
4646
* @ARV_BUFFER_STATUS_PAYLOAD_NOT_SUPPORTED: payload not yet supported
47+
* @ARV_BUFFER_STATUS_UNDERRUN: buffer found late in input queue and timeout reached before all packets are received
4748
*/
4849

4950
typedef enum {
@@ -56,7 +57,8 @@ typedef enum {
5657
ARV_BUFFER_STATUS_SIZE_MISMATCH,
5758
ARV_BUFFER_STATUS_FILLING,
5859
ARV_BUFFER_STATUS_ABORTED,
59-
ARV_BUFFER_STATUS_PAYLOAD_NOT_SUPPORTED
60+
ARV_BUFFER_STATUS_PAYLOAD_NOT_SUPPORTED,
61+
ARV_BUFFER_STATUS_UNDERRUN
6062
} ArvBufferStatus;
6163

6264
/**

src/arvgvstream.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ typedef struct {
123123
gboolean resend_ratio_reached;
124124

125125
gboolean extended_ids;
126+
gboolean underrun;
126127
} ArvGvStreamFrameData;
127128

128129
struct _ArvGvStreamThreadData {
@@ -382,7 +383,6 @@ _find_frame_data (ArvGvStreamThreadData *thread_data,
382383
}
383384
return NULL;
384385
}
385-
thread_data->underrun_frame_id = 0;
386386

387387
n_packets = _compute_n_expected_packets (packet,
388388
buffer->priv->allocated_size,
@@ -394,11 +394,13 @@ _find_frame_data (ArvGvStreamThreadData *thread_data,
394394
thread_data->callback (thread_data->callback_data,
395395
ARV_STREAM_CALLBACK_TYPE_BUFFER_DONE,
396396
buffer);
397+
thread_data->underrun_frame_id = 0;
397398
return NULL;
398399
}
399400

400401
frame = g_new0 (ArvGvStreamFrameData, 1);
401402

403+
frame->underrun = thread_data->underrun_frame_id == frame_id;
402404
frame->disable_resend_request = FALSE;
403405

404406
frame->frame_id = frame_id;
@@ -437,6 +439,8 @@ _find_frame_data (ArvGvStreamThreadData *thread_data,
437439

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

442+
thread_data->underrun_frame_id = 0;
443+
440444
return frame;
441445
}
442446

@@ -839,7 +843,9 @@ _check_frame_completion (ArvGvStreamThreadData *thread_data,
839843
* acquisition start. */
840844
(frame->frame_id != thread_data->last_frame_id || frame->last_valid_packet != 0) &&
841845
time_us - frame->last_packet_time_us >= thread_data->frame_retention_us) {
842-
frame->buffer->priv->status = ARV_BUFFER_STATUS_TIMEOUT;
846+
frame->buffer->priv->status = frame->underrun ?
847+
ARV_BUFFER_STATUS_UNDERRUN :
848+
ARV_BUFFER_STATUS_TIMEOUT;
843849
arv_warning_stream_thread ("[GvStream::check_frame_completion] Timeout for frame %"
844850
G_GUINT64_FORMAT " at dt = %" G_GUINT64_FORMAT,
845851
frame->frame_id, time_us - frame->first_packet_time_us);

0 commit comments

Comments
 (0)