summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/androidmedia/gstamc.c28
-rw-r--r--sys/androidmedia/gstamcaudiodec.c14
-rw-r--r--sys/androidmedia/gstamcvideodec.c13
-rw-r--r--sys/androidmedia/gstamcvideoenc.c11
4 files changed, 50 insertions, 16 deletions
diff --git a/sys/androidmedia/gstamc.c b/sys/androidmedia/gstamc.c
index 84c91b907..c86e51975 100644
--- a/sys/androidmedia/gstamc.c
+++ b/sys/androidmedia/gstamc.c
@@ -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:
diff --git a/sys/androidmedia/gstamcaudiodec.c b/sys/androidmedia/gstamcaudiodec.c
index fbd6d0969..9a34c375c 100644
--- a/sys/androidmedia/gstamcaudiodec.c
+++ b/sys/androidmedia/gstamcaudiodec.c
@@ -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);
diff --git a/sys/androidmedia/gstamcvideodec.c b/sys/androidmedia/gstamcvideodec.c
index 395fd28dc..7c99be098 100644
--- a/sys/androidmedia/gstamcvideodec.c
+++ b/sys/androidmedia/gstamcvideodec.c
@@ -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);
diff --git a/sys/androidmedia/gstamcvideoenc.c b/sys/androidmedia/gstamcvideoenc.c
index fc4436c24..5ef480bf8 100644
--- a/sys/androidmedia/gstamcvideoenc.c
+++ b/sys/androidmedia/gstamcvideoenc.c
@@ -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),