mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-30 12:10:37 +00:00
textoverlay: use a class wide mutex to work around pango reentrance issues
Pango is not reentrant. Use a class wide mutex to protect pange use in gst_text_overlay_render_pangocairo(). This works reliable in contrast to the hack in my previous commit. Fixes Bug #412678
This commit is contained in:
parent
3294ecda7d
commit
9ac74c59db
2 changed files with 7 additions and 0 deletions
|
@ -375,6 +375,8 @@ gst_text_overlay_class_init (GstTextOverlayClass * klass)
|
||||||
gstelement_class->change_state =
|
gstelement_class->change_state =
|
||||||
GST_DEBUG_FUNCPTR (gst_text_overlay_change_state);
|
GST_DEBUG_FUNCPTR (gst_text_overlay_change_state);
|
||||||
|
|
||||||
|
klass->pango_lock = g_mutex_new ();
|
||||||
|
|
||||||
klass->get_text = gst_text_overlay_get_text;
|
klass->get_text = gst_text_overlay_get_text;
|
||||||
fontmap = pango_cairo_font_map_get_default ();
|
fontmap = pango_cairo_font_map_get_default ();
|
||||||
klass->pango_context =
|
klass->pango_context =
|
||||||
|
@ -1235,6 +1237,8 @@ gst_text_overlay_render_pangocairo (GstTextOverlay * overlay,
|
||||||
double scalef = 1.0;
|
double scalef = 1.0;
|
||||||
double a, r, g, b;
|
double a, r, g, b;
|
||||||
|
|
||||||
|
g_mutex_lock (GST_TEXT_OVERLAY_GET_CLASS (overlay)->pango_lock);
|
||||||
|
|
||||||
if (overlay->auto_adjust_size) {
|
if (overlay->auto_adjust_size) {
|
||||||
/* 640 pixel is default */
|
/* 640 pixel is default */
|
||||||
scalef = (double) (overlay->width) / DEFAULT_SCALE_BASIS;
|
scalef = (double) (overlay->width) / DEFAULT_SCALE_BASIS;
|
||||||
|
@ -1298,6 +1302,8 @@ gst_text_overlay_render_pangocairo (GstTextOverlay * overlay,
|
||||||
cairo_matrix_init_scale (&cairo_matrix, scalef, scalef);
|
cairo_matrix_init_scale (&cairo_matrix, scalef, scalef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_mutex_unlock (GST_TEXT_OVERLAY_GET_CLASS (overlay)->pango_lock);
|
||||||
|
|
||||||
/* reallocate surface */
|
/* reallocate surface */
|
||||||
overlay->text_image = g_realloc (overlay->text_image, 4 * width * height);
|
overlay->text_image = g_realloc (overlay->text_image, 4 * width * height);
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,7 @@ struct _GstTextOverlayClass {
|
||||||
GstElementClass parent_class;
|
GstElementClass parent_class;
|
||||||
|
|
||||||
PangoContext *pango_context;
|
PangoContext *pango_context;
|
||||||
|
GMutex *pango_lock;
|
||||||
|
|
||||||
gchar * (*get_text) (GstTextOverlay *overlay, GstBuffer *video_frame);
|
gchar * (*get_text) (GstTextOverlay *overlay, GstBuffer *video_frame);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue