diff options
author | Jan Schmidt <thaytan@noraisin.net> | 2018-07-16 12:49:21 +0300 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2020-07-10 18:46:33 +0300 |
commit | 3c5327ae6412ba51df8013b6b1db22e14d196c9e (patch) | |
tree | 4eb0d9a9fb51a7a64576b07273432805c6947499 /sys | |
parent | c907deb15fda4fe07eadc93f4a83611f4581e2f2 (diff) |
rpicamsrc: Attempt to workaround MMAL timeout bug
mmal_queue_timedwait() might spuriously return immediately
if called at exactly the wrong instant due to an internal
off-by-one bug. Attempt to work around that and just retry.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/rpicamsrc/RaspiCapture.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sys/rpicamsrc/RaspiCapture.c b/sys/rpicamsrc/RaspiCapture.c index 96c4692b0..975078f29 100644 --- a/sys/rpicamsrc/RaspiCapture.c +++ b/sys/rpicamsrc/RaspiCapture.c @@ -937,9 +937,16 @@ raspi_capture_fill_buffer(RASPIVID_STATE *state, GstBuffer **bufp, /* No timestamps if no clockm or invalid PTS */ GstClockTime gst_pts = GST_CLOCK_TIME_NONE; - /* FIXME: Use our own interruptible cond wait: */ - - buffer = mmal_queue_timedwait(state->encoded_buffer_q, 500); + do { + buffer = mmal_queue_timedwait(state->encoded_buffer_q, 500); + // Work around a bug where mmal_queue_timedwait() might return + // immediately if the internal timeout time aligns exactly + // with a 1 second rollover boundary by checking errno. + if (errno == EINVAL) { + GST_WARNING ("Retrying mmal_queue_timedwait() due to spurious failure."); + continue; + } + } while (0); if (G_UNLIKELY(buffer == NULL)) { return GST_FLOW_ERROR_TIMEOUT; |