Commit 5e8e268e authored by gb's avatar gb Committed by Gwenole Beauchesne

Check for out-of-free-surfaces condition.

parent 0047bb15
...@@ -433,6 +433,7 @@ gst_vaapi_context_set_profile ...@@ -433,6 +433,7 @@ gst_vaapi_context_set_profile
gst_vaapi_context_get_entrypoint gst_vaapi_context_get_entrypoint
gst_vaapi_context_get_size gst_vaapi_context_get_size
gst_vaapi_context_get_surface gst_vaapi_context_get_surface
gst_vaapi_context_get_surface_count
gst_vaapi_context_put_surface gst_vaapi_context_put_surface
gst_vaapi_context_find_surface_by_id gst_vaapi_context_find_surface_by_id
<SUBSECTION Standard> <SUBSECTION Standard>
......
...@@ -616,6 +616,22 @@ gst_vaapi_context_get_surface(GstVaapiContext *context) ...@@ -616,6 +616,22 @@ gst_vaapi_context_get_surface(GstVaapiContext *context)
return gst_vaapi_video_pool_get_object(context->priv->surfaces_pool); return gst_vaapi_video_pool_get_object(context->priv->surfaces_pool);
} }
/**
* 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: * gst_vaapi_context_put_surface:
* @context: a #GstVaapiContext * @context: a #GstVaapiContext
......
...@@ -122,6 +122,9 @@ gst_vaapi_context_get_size( ...@@ -122,6 +122,9 @@ gst_vaapi_context_get_size(
GstVaapiSurface * GstVaapiSurface *
gst_vaapi_context_get_surface(GstVaapiContext *context); gst_vaapi_context_get_surface(GstVaapiContext *context);
guint
gst_vaapi_context_get_surface_count(GstVaapiContext *context);
void void
gst_vaapi_context_put_surface(GstVaapiContext *context, GstVaapiSurface *surface); gst_vaapi_context_put_surface(GstVaapiContext *context, GstVaapiSurface *surface);
......
...@@ -89,9 +89,15 @@ pop_buffer(GstVaapiDecoder *decoder) ...@@ -89,9 +89,15 @@ pop_buffer(GstVaapiDecoder *decoder)
static GstVaapiDecoderStatus static GstVaapiDecoderStatus
decode_step(GstVaapiDecoder *decoder) decode_step(GstVaapiDecoder *decoder)
{ {
GstVaapiDecoderPrivate * const priv = decoder->priv;
GstVaapiDecoderStatus status; GstVaapiDecoderStatus status;
GstBuffer *buffer; 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 { do {
buffer = pop_buffer(decoder); buffer = pop_buffer(decoder);
if (!buffer) if (!buffer)
......
...@@ -65,6 +65,7 @@ typedef struct _GstVaapiDecoderClass GstVaapiDecoderClass; ...@@ -65,6 +65,7 @@ typedef struct _GstVaapiDecoderClass GstVaapiDecoderClass;
* @GST_VAAPI_DECODER_STATUS_ERROR_INIT_FAILED: Decoder initialization failure. * @GST_VAAPI_DECODER_STATUS_ERROR_INIT_FAILED: Decoder initialization failure.
* @GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC: Unsupported codec. * @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_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_INVALID_SURFACE: Invalid surface.
* @GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN: Unknown error. * @GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN: Unknown error.
* *
...@@ -77,6 +78,7 @@ enum _GstVaapiDecoderStatus { ...@@ -77,6 +78,7 @@ enum _GstVaapiDecoderStatus {
GST_VAAPI_DECODER_STATUS_ERROR_INIT_FAILED, GST_VAAPI_DECODER_STATUS_ERROR_INIT_FAILED,
GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC, GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CODEC,
GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA, 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_INVALID_SURFACE,
GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN = -1 GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN = -1
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment