summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-09-11 15:54:20 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-09-11 17:08:47 +0200
commit9afe700005ff47a6368734814fd58bbfaed62f04 (patch)
treef77330871b31385f9634e25b24d732b16f52ed78 /gst
parent6c19849cd2d273fdc67b6e8f6befd17e1fbb68fc (diff)
vaapidecode: improve "no free surface" conditions.
Previously, vaapidecode would wait up to one second until a free surface is available, or it aborts decoding. Now, vaapidecode waits until the last decoded surface was to be presented, plus one second. Besides, end times are now expressed relative to the monotonic clock.
Diffstat (limited to 'gst')
-rw-r--r--gst/vaapi/gstvaapidecode.c35
-rw-r--r--gst/vaapi/gstvaapidecode.h2
2 files changed, 24 insertions, 13 deletions
diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c
index 0b9643fa..4a4f4e74 100644
--- a/gst/vaapi/gstvaapidecode.c
+++ b/gst/vaapi/gstvaapidecode.c
@@ -189,28 +189,30 @@ gst_vaapidecode_step(GstVaapiDecode *decode)
GstVaapiDecoderStatus status;
GstBuffer *buffer;
GstFlowReturn ret;
- guint tries;
+ GstClockTime timestamp;
+ gint64 end_time;
for (;;) {
- tries = 0;
- again:
+ end_time = decode->render_time_base;
+ if (!end_time)
+ end_time = g_get_monotonic_time();
+ end_time += GST_TIME_AS_USECONDS(decode->last_buffer_time);
+ end_time += G_TIME_SPAN_SECOND;
+
proxy = gst_vaapi_decoder_get_surface(decode->decoder, &status);
if (!proxy) {
if (status == GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE) {
- /* Wait for a VA surface to be displayed and free'd */
- if (++tries > 100)
- goto error_decode_timeout;
- GTimeVal timeout;
- g_get_current_time(&timeout);
- g_time_val_add(&timeout, 10000); /* 10 ms each step */
+ gboolean was_signalled;
g_mutex_lock(decode->decoder_mutex);
- g_cond_timed_wait(
+ was_signalled = g_cond_wait_until(
decode->decoder_ready,
decode->decoder_mutex,
- &timeout
+ end_time
);
g_mutex_unlock(decode->decoder_mutex);
- goto again;
+ if (was_signalled)
+ continue;
+ goto error_decode_timeout;
}
if (status != GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA)
goto error_decode;
@@ -228,7 +230,12 @@ gst_vaapidecode_step(GstVaapiDecode *decode)
if (!buffer)
goto error_create_buffer;
- GST_BUFFER_TIMESTAMP(buffer) = GST_VAAPI_SURFACE_PROXY_TIMESTAMP(proxy);
+ timestamp = GST_VAAPI_SURFACE_PROXY_TIMESTAMP(proxy);
+ if (!decode->render_time_base)
+ decode->render_time_base = g_get_monotonic_time();
+ decode->last_buffer_time = timestamp;
+
+ GST_BUFFER_TIMESTAMP(buffer) = timestamp;
GST_BUFFER_DURATION(buffer) = GST_VAAPI_SURFACE_PROXY_DURATION(proxy);
gst_buffer_set_caps(buffer, GST_PAD_CAPS(decode->srcpad));
@@ -710,6 +717,8 @@ gst_vaapidecode_init(GstVaapiDecode *decode)
decode->decoder_caps = NULL;
decode->allowed_caps = NULL;
decode->delayed_new_seg = NULL;
+ decode->render_time_base = 0;
+ decode->last_buffer_time = 0;
decode->is_ready = FALSE;
/* Pad through which data comes in to the element */
diff --git a/gst/vaapi/gstvaapidecode.h b/gst/vaapi/gstvaapidecode.h
index 408ee08c..68799df5 100644
--- a/gst/vaapi/gstvaapidecode.h
+++ b/gst/vaapi/gstvaapidecode.h
@@ -72,6 +72,8 @@ struct _GstVaapiDecode {
GstCaps *decoder_caps;
GstCaps *allowed_caps;
GstEvent *delayed_new_seg;
+ gint64 render_time_base;
+ GstClockTime last_buffer_time;
unsigned int is_ready : 1;
};