mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 17:50:36 +00:00
[780/906] up/download: check return values
So we fail properly
This commit is contained in:
parent
13d487741a
commit
7c4d51edf4
3 changed files with 94 additions and 41 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue