mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 23:28:16 +00:00
amc: Correctly handle NULL input buffers
https://bugzilla.gnome.org/show_bug.cgi?id=763401
This commit is contained in:
parent
9132b72c32
commit
610705cbb4
4 changed files with 50 additions and 16 deletions
|
@ -453,21 +453,23 @@ gst_amc_codec_get_input_buffer (GstAmcCodec * codec, gint index, GError ** err)
|
|||
media_codec.get_input_buffer, &buffer, index))
|
||||
goto done;
|
||||
|
||||
ret = g_new0 (GstAmcBuffer, 1);
|
||||
ret->object = gst_amc_jni_object_make_global (env, buffer);
|
||||
if (!ret->object) {
|
||||
gst_amc_jni_set_error (env, err, GST_LIBRARY_ERROR,
|
||||
GST_LIBRARY_ERROR_FAILED, "Failed to create global buffer reference");
|
||||
goto error;
|
||||
}
|
||||
if (buffer != NULL) {
|
||||
ret = g_new0 (GstAmcBuffer, 1);
|
||||
ret->object = gst_amc_jni_object_make_global (env, buffer);
|
||||
if (!ret->object) {
|
||||
gst_amc_jni_set_error (env, err, GST_LIBRARY_ERROR,
|
||||
GST_LIBRARY_ERROR_FAILED, "Failed to create global buffer reference");
|
||||
goto error;
|
||||
}
|
||||
|
||||
ret->data = (*env)->GetDirectBufferAddress (env, ret->object);
|
||||
if (!ret->data) {
|
||||
gst_amc_jni_set_error (env, err, GST_LIBRARY_ERROR,
|
||||
GST_LIBRARY_ERROR_FAILED, "Failed to get buffer address");
|
||||
goto error;
|
||||
ret->data = (*env)->GetDirectBufferAddress (env, ret->object);
|
||||
if (!ret->data) {
|
||||
gst_amc_jni_set_error (env, err, GST_LIBRARY_ERROR,
|
||||
GST_LIBRARY_ERROR_FAILED, "Failed to get buffer address");
|
||||
goto error;
|
||||
}
|
||||
ret->size = (*env)->GetDirectBufferCapacity (env, ret->object);
|
||||
}
|
||||
ret->size = (*env)->GetDirectBufferCapacity (env, ret->object);
|
||||
|
||||
done:
|
||||
|
||||
|
|
|
@ -1128,8 +1128,10 @@ gst_amc_audio_dec_handle_frame (GstAudioDecoder * decoder, GstBuffer * inbuf)
|
|||
/* Copy the buffer content in chunks of size as requested
|
||||
* by the port */
|
||||
buf = gst_amc_codec_get_input_buffer (self->codec, idx, &err);
|
||||
if (!buf)
|
||||
if (err)
|
||||
goto failed_to_get_input_buffer;
|
||||
else if (!buf)
|
||||
goto got_null_input_buffer;
|
||||
|
||||
memset (&buffer_info, 0, sizeof (buffer_info));
|
||||
buffer_info.offset = 0;
|
||||
|
@ -1200,6 +1202,16 @@ failed_to_get_input_buffer:
|
|||
gst_buffer_unref (inbuf);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
got_null_input_buffer:
|
||||
{
|
||||
GST_ELEMENT_ERROR (self, LIBRARY, SETTINGS, (NULL),
|
||||
("Got no input buffer"));
|
||||
if (minfo.data)
|
||||
gst_buffer_unmap (inbuf, &minfo);
|
||||
if (inbuf)
|
||||
gst_buffer_unref (inbuf);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
dequeue_error:
|
||||
{
|
||||
GST_ELEMENT_ERROR_FROM_ERROR (self, err);
|
||||
|
|
|
@ -2193,8 +2193,10 @@ gst_amc_video_dec_handle_frame (GstVideoDecoder * decoder,
|
|||
/* Copy the buffer content in chunks of size as requested
|
||||
* by the port */
|
||||
buf = gst_amc_codec_get_input_buffer (self->codec, idx, &err);
|
||||
if (!buf)
|
||||
if (err)
|
||||
goto failed_to_get_input_buffer;
|
||||
else if (!buf)
|
||||
goto got_null_input_buffer;
|
||||
|
||||
memset (&buffer_info, 0, sizeof (buffer_info));
|
||||
buffer_info.offset = 0;
|
||||
|
@ -2268,6 +2270,15 @@ failed_to_get_input_buffer:
|
|||
gst_video_codec_frame_unref (frame);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
got_null_input_buffer:
|
||||
{
|
||||
GST_ELEMENT_ERROR (self, LIBRARY, SETTINGS, (NULL),
|
||||
("Got no input buffer"));
|
||||
if (minfo.data)
|
||||
gst_buffer_unmap (frame->input_buffer, &minfo);
|
||||
gst_video_codec_frame_unref (frame);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
dequeue_error:
|
||||
{
|
||||
GST_ELEMENT_ERROR_FROM_ERROR (self, err);
|
||||
|
|
|
@ -1469,8 +1469,10 @@ again:
|
|||
/* Copy the buffer content in chunks of size as requested
|
||||
* by the port */
|
||||
buf = gst_amc_codec_get_input_buffer (self->codec, idx, &err);
|
||||
if (!buf)
|
||||
if (err)
|
||||
goto failed_to_get_input_buffer;
|
||||
else if (!buf)
|
||||
goto got_null_input_buffer;
|
||||
|
||||
memset (&buffer_info, 0, sizeof (buffer_info));
|
||||
buffer_info.offset = 0;
|
||||
|
@ -1539,6 +1541,13 @@ failed_to_get_input_buffer:
|
|||
gst_video_codec_frame_unref (frame);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
got_null_input_buffer:
|
||||
{
|
||||
GST_ELEMENT_ERROR (self, LIBRARY, SETTINGS, (NULL),
|
||||
("Got no input buffer"));
|
||||
gst_video_codec_frame_unref (frame);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
buffer_fill_error:
|
||||
{
|
||||
GST_ELEMENT_ERROR (self, RESOURCE, WRITE, (NULL),
|
||||
|
|
Loading…
Reference in a new issue