Check for out-of-free-surfaces condition.

This commit is contained in:
gb 2010-05-15 05:36:15 +00:00 committed by Gwenole Beauchesne
parent 0047bb1553
commit 5e8e268e26
5 changed files with 28 additions and 0 deletions

View 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>

View file

@ -616,6 +616,22 @@ gst_vaapi_context_get_surface(GstVaapiContext *context)
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:
* @context: a #GstVaapiContext

View 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);

View 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)

View 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
};