rendered paste bodyFrom 475647674ee796417311a1e6b05f243c3261c2c8 Mon Sep 17 00:00:00 2001
From: Philippe Normand <pnormand@igalia.com>
Date: Fri, 2 Oct 2009 11:09:12 +0200
Subject: [PATCH] sink: replace the idle with a timeout
---
.../platform/graphics/gtk/VideoSinkGStreamer.cpp | 24 +++++++++++++++----
1 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/WebCore/platform/graphics/gtk/VideoSinkGStreamer.cpp b/WebCore/platform/graphics/gtk/VideoSinkGStreamer.cpp
index bb269cd..92e17a6 100644
--- a/WebCore/platform/graphics/gtk/VideoSinkGStreamer.cpp
+++ b/WebCore/platform/graphics/gtk/VideoSinkGStreamer.cpp
@@ -73,6 +73,8 @@ struct _WebKitVideoSinkPrivate {
int fps_d;
int par_n;
int par_d;
+ int timeout_id;
+ int rendered_frames;
};
#define _do_init(bla) \
@@ -103,10 +105,12 @@ webkit_video_sink_init(WebKitVideoSink* sink, WebKitVideoSinkClass* klass)
sink->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE(sink, WEBKIT_TYPE_VIDEO_SINK, WebKitVideoSinkPrivate);
priv->async_queue = g_async_queue_new();
+ priv->rendered_frames = 0;
+ g_object_set(sink, "render-delay", 100 * GST_MSECOND, NULL);
}
static gboolean
-webkit_video_sink_idle_func(gpointer data)
+webkit_video_sink_timeout_func(gpointer data)
{
WebKitVideoSink* sink = reinterpret_cast<WebKitVideoSink*>(data);
WebKitVideoSinkPrivate* priv = sink->priv;
@@ -131,12 +135,18 @@ webkit_video_sink_idle_func(gpointer data)
return FALSE;
}
+ priv->rendered_frames++;
+
+ if (priv->rendered_frames < 3) {
+ g_signal_emit(sink, webkit_video_sink_signals[REPAINT_REQUESTED], 0);
+ return TRUE;
+ }
+
if (!gst_video_parse_caps_pixel_aspect_ratio(caps, &par_n, &par_d))
par_n = par_d = 1;
par = (gfloat) par_n / (gfloat) par_d;
- // TODO: consider priv->rgb_ordering?
cairo_surface_t* src = cairo_image_surface_create_for_data(GST_BUFFER_DATA(buffer),
CAIRO_FORMAT_RGB24,
bwidth, bheight,
@@ -156,7 +166,7 @@ webkit_video_sink_idle_func(gpointer data)
g_signal_emit(sink, webkit_video_sink_signals[REPAINT_REQUESTED], 0);
- return FALSE;
+ return TRUE;
}
static GstFlowReturn
@@ -167,7 +177,9 @@ webkit_video_sink_render(GstBaseSink* bsink, GstBuffer* buffer)
g_async_queue_ref(priv->async_queue);
g_async_queue_push(priv->async_queue, gst_buffer_ref(buffer));
- g_idle_add_full(G_PRIORITY_HIGH_IDLE, webkit_video_sink_idle_func, sink, 0);
+ priv->timeout_id = g_timeout_add_full(G_PRIORITY_HIGH_IDLE, 100,
+ webkit_video_sink_timeout_func,
+ sink, 0);
return GST_FLOW_OK;
}
@@ -230,6 +242,8 @@ webkit_video_sink_dispose(GObject* object)
priv->async_queue = 0;
}
+ priv->rendered_frames = 0;
+
G_OBJECT_CLASS(parent_class)->dispose(object);
}
@@ -285,7 +299,7 @@ webkit_video_sink_stop(GstBaseSink* base_sink)
g_async_queue_unlock(priv->async_queue);
- g_idle_remove_by_data(base_sink);
+ g_source_remove(priv->timeout_id);
return TRUE;
}
--
1.6.0.4