[780/906] up/download: check return values
authorMatthew Waters <ystreet00@gmail.com>
Thu, 18 Jul 2013 10:21:57 +0000 (20:21 +1000)
committerMatthew Waters <ystreet00@gmail.com>
Sat, 15 Mar 2014 17:37:00 +0000 (18:37 +0100)
So we fail properly

gst-libs/gst/gl/gstglfilter.c
gst-libs/gst/gl/gstglmemory.c
gst-libs/gst/gl/gstglmixer.c
gst/gl/gstglimagesink.c
gst/gl/gstgltestsrc.c

index cd6eba5..65a4796 100644 (file)
@@ -947,12 +947,16 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
     if (!filter->upload) {
       filter->upload = gst_gl_upload_new (filter->display);
 
-      gst_gl_upload_init_format (filter->upload,
-          GST_VIDEO_FRAME_FORMAT (&in_frame),
-          GST_VIDEO_FRAME_WIDTH (&in_frame),
-          GST_VIDEO_FRAME_HEIGHT (&in_frame),
-          GST_VIDEO_FRAME_WIDTH (&out_frame),
-          GST_VIDEO_FRAME_HEIGHT (&out_frame));
+      if (!gst_gl_upload_init_format (filter->upload,
+              GST_VIDEO_FRAME_FORMAT (&in_frame),
+              GST_VIDEO_FRAME_WIDTH (&in_frame),
+              GST_VIDEO_FRAME_HEIGHT (&in_frame),
+              GST_VIDEO_FRAME_WIDTH (&out_frame),
+              GST_VIDEO_FRAME_HEIGHT (&out_frame))) {
+        GST_ELEMENT_ERROR (filter, RESOURCE, NOT_FOUND,
+            ("%s", "Failed to init upload format"), (NULL));
+        return FALSE;
+      }
     }
 
     in_tex = filter->in_tex_id;
@@ -964,10 +968,14 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
     if (!filter->download) {
       filter->download = gst_gl_download_new (filter->display);
 
-      gst_gl_download_init_format (filter->download,
-          GST_VIDEO_FRAME_FORMAT (&out_frame),
-          GST_VIDEO_FRAME_WIDTH (&out_frame),
-          GST_VIDEO_FRAME_HEIGHT (&out_frame));
+      if (!gst_gl_download_init_format (filter->download,
+              GST_VIDEO_FRAME_FORMAT (&out_frame),
+              GST_VIDEO_FRAME_WIDTH (&out_frame),
+              GST_VIDEO_FRAME_HEIGHT (&out_frame))) {
+        GST_ELEMENT_ERROR (filter, RESOURCE, NOT_FOUND,
+            ("%s", "Failed to init download format"), (NULL));
+        return FALSE;
+      }
     }
 
     in_tex = *(guint *) in_frame.data[0];
@@ -976,32 +984,42 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
     if (!filter->upload) {
       filter->upload = gst_gl_upload_new (filter->display);
 
-      gst_gl_upload_init_format (filter->upload,
-          GST_VIDEO_FRAME_FORMAT (&in_frame),
-          GST_VIDEO_FRAME_WIDTH (&in_frame),
-          GST_VIDEO_FRAME_HEIGHT (&in_frame),
-          GST_VIDEO_FRAME_WIDTH (&out_frame),
-          GST_VIDEO_FRAME_HEIGHT (&out_frame));
+      if (!gst_gl_upload_init_format (filter->upload,
+              GST_VIDEO_FRAME_FORMAT (&in_frame),
+              GST_VIDEO_FRAME_WIDTH (&in_frame),
+              GST_VIDEO_FRAME_HEIGHT (&in_frame),
+              GST_VIDEO_FRAME_WIDTH (&out_frame),
+              GST_VIDEO_FRAME_HEIGHT (&out_frame))) {
+        GST_ELEMENT_ERROR (filter, RESOURCE, NOT_FOUND,
+            ("%s", "Failed to init upload format"), (NULL));
+        return FALSE;
+      }
     }
 
     if (!filter->download) {
       filter->download = gst_gl_download_new (filter->display);
 
-      gst_gl_download_init_format (filter->download,
-          GST_VIDEO_FRAME_FORMAT (&out_frame),
-          GST_VIDEO_FRAME_WIDTH (&out_frame),
-          GST_VIDEO_FRAME_HEIGHT (&out_frame));
+      if (!gst_gl_download_init_format (filter->download,
+              GST_VIDEO_FRAME_FORMAT (&out_frame),
+              GST_VIDEO_FRAME_WIDTH (&out_frame),
+              GST_VIDEO_FRAME_HEIGHT (&out_frame))) {
+        GST_ELEMENT_ERROR (filter, RESOURCE, NOT_FOUND,
+            ("%s", "Failed to init download format"), (NULL));
+        return FALSE;
+      }
     }
 
-    gst_gl_upload_perform_with_data (filter->upload, filter->in_tex_id,
-        in_frame.data);
-
     out_tex = filter->out_tex_id;
     in_tex = filter->in_tex_id;
   }
 
   if (in_gl_wrapped) {
-    gst_gl_upload_perform_with_data (filter->upload, in_tex, in_frame.data);
+    if (!gst_gl_upload_perform_with_data (filter->upload, in_tex,
+            in_frame.data)) {
+      GST_ELEMENT_ERROR (filter, RESOURCE, NOT_FOUND, ("%s",
+              "Failed to upload video frame"), (NULL));
+      return FALSE;
+    }
   }
 
   GST_DEBUG ("calling filter_texture with textures in:%i out:%i", in_tex,
@@ -1011,8 +1029,12 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
   ret = filter_class->filter_texture (filter, in_tex, out_tex);
 
   if (out_gl_wrapped) {
-    gst_gl_download_perform_with_data (filter->download, out_tex,
-        out_frame.data);
+    if (!gst_gl_download_perform_with_data (filter->download, out_tex,
+            out_frame.data)) {
+      GST_ELEMENT_ERROR (filter, RESOURCE, NOT_FOUND,
+          ("%s", "Failed to download video frame"), (NULL));
+      return FALSE;
+    }
   }
 
   gst_video_frame_unmap (&in_frame);
index 0cdf8e5..6108ca7 100644 (file)
@@ -129,12 +129,17 @@ _gl_mem_map (GstGLMemory * gl_mem, gsize maxsize, GstMapFlags flags)
       if (GST_GL_MEMORY_FLAG_IS_SET (gl_mem, GST_GL_MEMORY_FLAG_NEED_UPLOAD)) {
         if (!GST_GL_MEMORY_FLAG_IS_SET (gl_mem,
                 GST_GL_MEMORY_FLAG_UPLOAD_INITTED)) {
-          gst_gl_upload_init_format (gl_mem->upload, gl_mem->v_format,
-              gl_mem->width, gl_mem->height, gl_mem->width, gl_mem->height);
+          if (!gst_gl_upload_init_format (gl_mem->upload, gl_mem->v_format,
+                  gl_mem->width, gl_mem->height, gl_mem->width,
+                  gl_mem->height)) {
+            goto error;
+          }
           GST_GL_MEMORY_FLAG_SET (gl_mem, GST_GL_MEMORY_FLAG_UPLOAD_INITTED);
         }
 
-        gst_gl_upload_perform_with_memory (gl_mem->upload, gl_mem);
+        if (!gst_gl_upload_perform_with_memory (gl_mem->upload, gl_mem)) {
+          goto error;
+        }
       }
     } else {
       GST_CAT_TRACE (GST_CAT_GL_MEMORY, "mapping GL texture:%u for writing",
@@ -150,12 +155,16 @@ _gl_mem_map (GstGLMemory * gl_mem, gsize maxsize, GstMapFlags flags)
       if (GST_GL_MEMORY_FLAG_IS_SET (gl_mem, GST_GL_MEMORY_FLAG_NEED_DOWNLOAD)) {
         if (!GST_GL_MEMORY_FLAG_IS_SET (gl_mem,
                 GST_GL_MEMORY_FLAG_DOWNLOAD_INITTED)) {
-          gst_gl_download_init_format (gl_mem->download, gl_mem->v_format,
-              gl_mem->width, gl_mem->height);
+          if (!gst_gl_download_init_format (gl_mem->download, gl_mem->v_format,
+                  gl_mem->width, gl_mem->height)) {
+            goto error;
+          }
           GST_GL_MEMORY_FLAG_SET (gl_mem, GST_GL_MEMORY_FLAG_DOWNLOAD_INITTED);
         }
 
-        gst_gl_download_perform_with_memory (gl_mem->download, gl_mem);
+        if (!gst_gl_download_perform_with_memory (gl_mem->download, gl_mem)) {
+          goto error;
+        }
       }
     } else {
       GST_CAT_TRACE (GST_CAT_GL_MEMORY,
@@ -168,6 +177,11 @@ _gl_mem_map (GstGLMemory * gl_mem, gsize maxsize, GstMapFlags flags)
   gl_mem->map_flags = flags;
 
   return data;
+
+error:
+  {
+    return NULL;
+  }
 }
 
 void
index 512ba1e..748e5a8 100644 (file)
@@ -1451,10 +1451,14 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
 
     if (!mix->download) {
       mix->download = gst_gl_download_new (mix->display);
-      gst_gl_download_init_format (mix->download,
-          GST_VIDEO_FRAME_FORMAT (&out_frame),
-          GST_VIDEO_FRAME_WIDTH (&out_frame),
-          GST_VIDEO_FRAME_HEIGHT (&out_frame));
+      if (!gst_gl_download_init_format (mix->download,
+              GST_VIDEO_FRAME_FORMAT (&out_frame),
+              GST_VIDEO_FRAME_WIDTH (&out_frame),
+              GST_VIDEO_FRAME_HEIGHT (&out_frame))) {
+        GST_ELEMENT_ERROR (mix, RESOURCE, NOT_FOUND,
+            ("%s", "Failed to init upload format"), (NULL));
+        return FALSE;
+      }
     }
 
     out_gl_wrapped = TRUE;
@@ -1510,16 +1514,24 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
         if (!pad->upload) {
           pad->upload = gst_gl_upload_new (mix->display);
 
-          gst_gl_upload_init_format (pad->upload, in_format,
-              in_width, in_height, in_width, in_height);
+          if (!gst_gl_upload_init_format (pad->upload, in_format,
+                  in_width, in_height, in_width, in_height)) {
+            GST_ELEMENT_ERROR (mix, RESOURCE, NOT_FOUND,
+                ("%s", "Failed to init upload format"), (NULL));
+            return FALSE;
+          }
 
           if (!pad->in_tex_id)
             gst_gl_display_gen_texture (mix->display, &pad->in_tex_id,
                 GST_VIDEO_FORMAT_RGBA, out_width, out_height);
         }
 
-        gst_gl_upload_perform_with_data (pad->upload, pad->in_tex_id,
-            in_frame->data);
+        if (!gst_gl_upload_perform_with_data (pad->upload, pad->in_tex_id,
+                in_frame->data)) {
+          GST_ELEMENT_ERROR (mix, RESOURCE, NOT_FOUND,
+              ("%s", "Failed to upload video frame"), (NULL));
+          return FALSE;
+        }
 
         in_tex = pad->in_tex_id;
         pad->mapped = TRUE;
@@ -1534,7 +1546,12 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
       out_tex);
 
   if (out_gl_wrapped) {
-    gst_gl_download_perform_with_data (mix->download, out_tex, out_frame.data);
+    if (gst_gl_download_perform_with_data (mix->download, out_tex,
+            out_frame.data)) {
+      GST_ELEMENT_ERROR (mix, RESOURCE, NOT_FOUND, ("%s",
+              "Failed to download video frame"), (NULL));
+      return FALSE;
+    }
   }
 
   i = 0;
index c96f867..43208b2 100644 (file)
@@ -671,14 +671,22 @@ gst_glimage_sink_render (GstBaseSink * bsink, GstBuffer * buf)
     if (!glimage_sink->upload) {
       glimage_sink->upload = gst_gl_upload_new (glimage_sink->display);
 
-      gst_gl_upload_init_format (glimage_sink->upload,
-          GST_VIDEO_FRAME_FORMAT (&frame), GST_VIDEO_FRAME_WIDTH (&frame),
-          GST_VIDEO_FRAME_HEIGHT (&frame), GST_VIDEO_FRAME_WIDTH (&frame),
-          GST_VIDEO_FRAME_HEIGHT (&frame));
+      if (!gst_gl_upload_init_format (glimage_sink->upload,
+              GST_VIDEO_FRAME_FORMAT (&frame), GST_VIDEO_FRAME_WIDTH (&frame),
+              GST_VIDEO_FRAME_HEIGHT (&frame), GST_VIDEO_FRAME_WIDTH (&frame),
+              GST_VIDEO_FRAME_HEIGHT (&frame))) {
+        GST_ELEMENT_ERROR (glimage_sink, RESOURCE, NOT_FOUND,
+            ("%s", "Failed to init upload format"), (NULL));
+        return GST_FLOW_ERROR;
+      }
     }
 
-    gst_gl_upload_perform_with_data (glimage_sink->upload,
-        glimage_sink->tex_id, frame.data);
+    if (!gst_gl_upload_perform_with_data (glimage_sink->upload,
+            glimage_sink->tex_id, frame.data)) {
+      GST_ELEMENT_ERROR (glimage_sink, RESOURCE, NOT_FOUND,
+          ("%s", "Failed to init upload format"), (NULL));
+      return FALSE;
+    }
 
     tex_id = glimage_sink->tex_id;
   }
index f5e2708..00df7f1 100644 (file)
@@ -476,10 +476,14 @@ gst_gl_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer)
     if (!src->download) {
       src->download = gst_gl_download_new (src->display);
 
-      gst_gl_download_init_format (src->download,
-          GST_VIDEO_FRAME_FORMAT (&out_frame),
-          GST_VIDEO_FRAME_WIDTH (&out_frame),
-          GST_VIDEO_FRAME_HEIGHT (&out_frame));
+      if (!gst_gl_download_init_format (src->download,
+              GST_VIDEO_FRAME_FORMAT (&out_frame),
+              GST_VIDEO_FRAME_WIDTH (&out_frame),
+              GST_VIDEO_FRAME_HEIGHT (&out_frame))) {
+        GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
+            ("%s", "Failed to init download format"), (NULL));
+        return FALSE;
+      }
     }
 
     out_gl_wrapped = TRUE;
@@ -495,7 +499,12 @@ gst_gl_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer)
   }
 
   if (out_gl_wrapped) {
-    gst_gl_download_perform_with_data (src->download, out_tex, out_frame.data);
+    if (!gst_gl_download_perform_with_data (src->download, out_tex,
+            out_frame.data)) {
+      GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, ("%s",
+              "Failed to init upload format"), (NULL));
+      return FALSE;
+    }
   }
   gst_video_frame_unmap (&out_frame);