Skip to content

Commit afd8a4b

Browse files
committed
gvstream: mark buffer status as underrun if buffer was late in input queue
1 parent a0616bc commit afd8a4b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

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 {
@@ -381,7 +382,6 @@ _find_frame_data (ArvGvStreamThreadData *thread_data,
381382
}
382383
return NULL;
383384
}
384-
thread_data->underrun_frame_id = 0;
385385

386386
n_packets = _compute_n_expected_packets (packet,
387387
buffer->priv->allocated_size,
@@ -393,11 +393,13 @@ _find_frame_data (ArvGvStreamThreadData *thread_data,
393393
thread_data->callback (thread_data->callback_data,
394394
ARV_STREAM_CALLBACK_TYPE_BUFFER_DONE,
395395
buffer);
396+
thread_data->underrun_frame_id = 0;
396397
return NULL;
397398
}
398399

399400
frame = g_new0 (ArvGvStreamFrameData, 1);
400401

402+
frame->underrun = thread_data->underrun_frame_id == frame_id;
401403
frame->disable_resend_request = FALSE;
402404

403405
frame->frame_id = frame_id;
@@ -436,6 +438,8 @@ _find_frame_data (ArvGvStreamThreadData *thread_data,
436438

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

441+
thread_data->underrun_frame_id = 0;
442+
439443
return frame;
440444
}
441445

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

0 commit comments

Comments
 (0)