Check for out-of-free-surfaces condition.
authorgb <gb@5584edef-b1fe-4b99-b61b-dd2bab72e969>
Sat, 15 May 2010 05:36:15 +0000 (05:36 +0000)
committerGwenole Beauchesne <gbeauchesne@splitted-desktop.com>
Mon, 20 Sep 2010 10:55:46 +0000 (12:55 +0200)
docs/reference/libs/libs-sections.txt
gst-libs/gst/vaapi/gstvaapicontext.c
gst-libs/gst/vaapi/gstvaapicontext.h
gst-libs/gst/vaapi/gstvaapidecoder.c
gst-libs/gst/vaapi/gstvaapidecoder.h

index d7f6282..3db23a7 100644 (file)
@@ -433,6 +433,7 @@ gst_vaapi_context_set_profile
 gst_vaapi_context_get_entrypoint
 gst_vaapi_context_get_size
 gst_vaapi_context_get_surface
+gst_vaapi_context_get_surface_count
 gst_vaapi_context_put_surface
 gst_vaapi_context_find_surface_by_id
 <SUBSECTION Standard>
index c0caa76..e40fe0b 100644 (file)
@@ -617,6 +617,22 @@ gst_vaapi_context_get_surface(GstVaapiContext *context)
 }
 
 /**
+ * gst_vaapi_context_get_surface_count:
+ * @context: a #GstVaapiContext
+ *
+ * Retrieves the number of free surfaces left in the pool.
+ *
+ * Return value: the number of free surfaces available in the pool
+ */
+guint
+gst_vaapi_context_get_surface_count(GstVaapiContext *context)
+{
+    g_return_val_if_fail(GST_VAAPI_IS_CONTEXT(context), 0);
+
+    return gst_vaapi_video_pool_get_size(context->priv->surfaces_pool);
+}
+
+/**
  * gst_vaapi_context_put_surface:
  * @context: a #GstVaapiContext
  * @surface: the #GstVaapiSurface to release
index 71264a3..e83a991 100644 (file)
@@ -122,6 +122,9 @@ gst_vaapi_context_get_size(
 GstVaapiSurface *
 gst_vaapi_context_get_surface(GstVaapiContext *context);
 
+guint
+gst_vaapi_context_get_surface_count(GstVaapiContext *context);
+
 void
 gst_vaapi_context_put_surface(GstVaapiContext *context, GstVaapiSurface *surface);
 
index 16feb4d..1509463 100644 (file)
@@ -89,9 +89,15 @@ pop_buffer(GstVaapiDecoder *decoder)
 static GstVaapiDecoderStatus
 decode_step(GstVaapiDecoder *decoder)
 {
+    GstVaapiDecoderPrivate * const priv = decoder->priv;
     GstVaapiDecoderStatus status;
     GstBuffer *buffer;
 
+    /* Decoding will fail if there is no surface left */
+    if (priv->context &&
+        gst_vaapi_context_get_surface_count(priv->context) == 0)
+        return GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE;
+
     do {
         buffer = pop_buffer(decoder);
         if (!buffer)
index 3dbfbc5..53a54d3 100644 (file)
@@ -65,6 +65,7 @@ typedef struct _GstVaapiDecoderClass            GstVaapiDecoderClass;
  * @GST_VAAPI_DECODER_STATUS_ERROR_INIT_FAILED: Decoder initialization failure.
  * @GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC: Unsupported codec.
  * @GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA: Not enough input data to decode.
+ * @GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE: No surface left to hold the decoded picture.
  * @GST_VAAPI_DECODER_STATUS_ERROR_INVALID_SURFACE: Invalid surface.
  * @GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN: Unknown error.
  *
@@ -77,6 +78,7 @@ enum _GstVaapiDecoderStatus {
     GST_VAAPI_DECODER_STATUS_ERROR_INIT_FAILED,
     GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC,
     GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA,
+    GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE,
     GST_VAAPI_DECODER_STATUS_ERROR_INVALID_SURFACE,
     GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN = -1
 };