v4l2codecs: Fix renegotiation
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 1 Dec 2021 14:51:57 +0000 (09:51 -0500)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Thu, 2 Dec 2021 20:45:26 +0000 (15:45 -0500)
If we hold the last reference to the allocator, leaving the device
streaming will cause an EBUSY error when trying to free the allocate
buffers.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1404>

subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codech264dec.c
subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecmpeg2dec.c
subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp8dec.c
subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecvp9dec.c

index 73b7f9f..00adb23 100644 (file)
@@ -322,11 +322,11 @@ gst_v4l2_codec_h264_dec_negotiate (GstVideoDecoder * decoder)
 
   GST_DEBUG_OBJECT (self, "Negotiate");
 
-  gst_v4l2_codec_h264_dec_reset_allocation (self);
-
   gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
   gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
 
+  gst_v4l2_codec_h264_dec_reset_allocation (self);
+
   if (!gst_v4l2_decoder_set_sink_fmt (self->decoder, V4L2_PIX_FMT_H264_SLICE,
           self->coded_width, self->coded_height, get_pixel_bitdepth (self))) {
     GST_ELEMENT_ERROR (self, CORE, NEGOTIATION,
index 3e0e802..0d26b28 100644 (file)
@@ -241,11 +241,11 @@ gst_v4l2_codec_mpeg2_dec_negotiate (GstVideoDecoder * decoder)
 
   GST_DEBUG_OBJECT (self, "Negotiate");
 
-  gst_v4l2_codec_mpeg2_dec_reset_allocation (self);
-
   gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
   gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
 
+  gst_v4l2_codec_mpeg2_dec_reset_allocation (self);
+
   if (!gst_v4l2_decoder_set_sink_fmt (self->decoder, V4L2_PIX_FMT_MPEG2_SLICE,
           self->width, self->height, get_pixel_bitdepth (self))) {
     GST_ELEMENT_ERROR (self, CORE, NEGOTIATION,
index 02b8eac..8a0634a 100644 (file)
@@ -191,11 +191,11 @@ gst_v4l2_codec_vp8_dec_negotiate (GstVideoDecoder * decoder)
 
   GST_DEBUG_OBJECT (self, "Negotiate");
 
-  gst_v4l2_codec_vp8_dec_reset_allocation (self);
-
   gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
   gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
 
+  gst_v4l2_codec_vp8_dec_reset_allocation (self);
+
   if (!gst_v4l2_decoder_set_sink_fmt (self->decoder, V4L2_PIX_FMT_VP8_FRAME,
           self->width, self->height, 12 /* 8 bits 4:2:0 */ )) {
     GST_ELEMENT_ERROR (self, CORE, NEGOTIATION,
index 0f65de1..ee10a24 100644 (file)
@@ -429,11 +429,11 @@ gst_v4l2_codec_vp9_dec_negotiate (GstVideoDecoder * decoder)
 
   GST_DEBUG_OBJECT (self, "Negotiate");
 
-  gst_v4l2_codec_vp9_dec_reset_allocation (self);
-
   gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SINK);
   gst_v4l2_decoder_streamoff (self->decoder, GST_PAD_SRC);
 
+  gst_v4l2_codec_vp9_dec_reset_allocation (self);
+
   if (!gst_v4l2_decoder_set_sink_fmt (self->decoder, V4L2_PIX_FMT_VP9_FRAME,
           self->width, self->height, self->bit_depth)) {
     GST_ELEMENT_ERROR (self, CORE, NEGOTIATION,
@@ -562,11 +562,6 @@ gst_v4l2_codec_vp9_dec_new_sequence (GstVp9Decoder * decoder,
 
   /* TODO Check if current buffers are large enough, and reuse them */
   if (self->width != frame_hdr->width || self->height != frame_hdr->height) {
-    if (self->width > 0 || self->height > 0) {
-      GST_ERROR_OBJECT (self,
-          "Dynamic resolution changes are not yet supported in v4l2");
-      return GST_FLOW_ERROR;
-    }
     self->width = frame_hdr->width;
     self->height = frame_hdr->height;
     negotiation_needed = TRUE;