mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
v4l2codecs: Poll inside set_done()
This removes the need for the gst_v4l2_decoder_is_done() helper and simplify slightly the subclass code. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1881>
This commit is contained in:
parent
1c2f391b57
commit
13a40b1da9
4 changed files with 11 additions and 32 deletions
|
@ -836,10 +836,7 @@ gst_v4l2_codec_h264_dec_output_picture (GstH264Decoder * decoder,
|
|||
|
||||
GST_DEBUG_OBJECT (self, "Output picture %u", picture->system_frame_number);
|
||||
|
||||
if (gst_v4l2_request_is_done (request))
|
||||
goto finish_frame;
|
||||
|
||||
ret = gst_v4l2_request_poll (request, GST_SECOND);
|
||||
ret = gst_v4l2_request_set_done (request);
|
||||
if (ret == 0) {
|
||||
GST_ELEMENT_ERROR (self, STREAM, DECODE,
|
||||
("Decoding frame %u took too long", picture->system_frame_number),
|
||||
|
@ -850,11 +847,8 @@ gst_v4l2_codec_h264_dec_output_picture (GstH264Decoder * decoder,
|
|||
("Decoding request failed: %s", g_strerror (errno)), (NULL));
|
||||
goto error;
|
||||
}
|
||||
|
||||
gst_v4l2_request_set_done (request);
|
||||
g_return_val_if_fail (frame->output_buffer, GST_FLOW_ERROR);
|
||||
|
||||
finish_frame:
|
||||
if (gst_v4l2_request_failed (request)) {
|
||||
GST_ELEMENT_ERROR (self, STREAM, DECODE,
|
||||
("Failed to decode frame %u", picture->system_frame_number), (NULL));
|
||||
|
|
|
@ -653,11 +653,7 @@ gst_v4l2_codec_vp8_dec_output_picture (GstVp8Decoder * decoder,
|
|||
|
||||
GST_DEBUG_OBJECT (self, "Output picture %u", picture->system_frame_number);
|
||||
|
||||
/* Unlikely, but it would not break this decoding flow */
|
||||
if (gst_v4l2_request_is_done (request))
|
||||
goto finish_frame;
|
||||
|
||||
ret = gst_v4l2_request_poll (request, GST_SECOND);
|
||||
ret = gst_v4l2_request_set_done (request);
|
||||
if (ret == 0) {
|
||||
GST_ELEMENT_ERROR (self, STREAM, DECODE,
|
||||
("Decoding frame took too long"), (NULL));
|
||||
|
@ -668,10 +664,8 @@ gst_v4l2_codec_vp8_dec_output_picture (GstVp8Decoder * decoder,
|
|||
goto error;
|
||||
}
|
||||
|
||||
gst_v4l2_request_set_done (request);
|
||||
g_return_val_if_fail (frame->output_buffer, GST_FLOW_ERROR);
|
||||
|
||||
finish_frame:
|
||||
if (gst_v4l2_request_failed (request)) {
|
||||
GST_ELEMENT_ERROR (self, STREAM, DECODE,
|
||||
("Failed to decode frame %u", picture->system_frame_number), (NULL));
|
||||
|
|
|
@ -1021,28 +1021,25 @@ gst_v4l2_request_queue (GstV4l2Request * request, guint flags)
|
|||
GstV4l2Request *pending_req;
|
||||
|
||||
pending_req = gst_queue_array_peek_head (decoder->pending_requests);
|
||||
ret = gst_v4l2_request_poll (pending_req, GST_SECOND);
|
||||
if (ret > 0)
|
||||
gst_v4l2_request_set_done (pending_req);
|
||||
gst_v4l2_request_set_done (pending_req);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gint
|
||||
gst_v4l2_request_poll (GstV4l2Request * request, GstClockTime timeout)
|
||||
{
|
||||
return gst_poll_wait (request->poll, timeout);
|
||||
}
|
||||
|
||||
void
|
||||
gst_v4l2_request_set_done (GstV4l2Request * request)
|
||||
{
|
||||
GstV4l2Decoder *decoder = request->decoder;
|
||||
GstV4l2Request *pending_req = NULL;
|
||||
gint ret;
|
||||
|
||||
if (!request->pending)
|
||||
return;
|
||||
return 1;
|
||||
|
||||
ret = gst_poll_wait (request->poll, GST_SECOND);
|
||||
if (ret <= 0)
|
||||
return ret;
|
||||
|
||||
while ((pending_req = gst_queue_array_pop_head (decoder->pending_requests))) {
|
||||
gst_v4l2_decoder_dequeue_sink (decoder);
|
||||
|
@ -1071,12 +1068,8 @@ gst_v4l2_request_set_done (GstV4l2Request * request)
|
|||
|
||||
/* Pending request must be in the pending request list */
|
||||
g_assert (pending_req == request);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_v4l2_request_is_done (GstV4l2Request * request)
|
||||
{
|
||||
return !request->pending;
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
@ -118,9 +118,7 @@ gboolean gst_v4l2_request_queue (GstV4l2Request * request,
|
|||
gint gst_v4l2_request_poll (GstV4l2Request * request,
|
||||
GstClockTime timeout);
|
||||
|
||||
void gst_v4l2_request_set_done (GstV4l2Request * request);
|
||||
|
||||
gboolean gst_v4l2_request_is_done (GstV4l2Request * request);
|
||||
gint gst_v4l2_request_set_done (GstV4l2Request * request);
|
||||
|
||||
gboolean gst_v4l2_request_failed (GstV4l2Request * request);
|
||||
|
||||
|
|
Loading…
Reference in a new issue