playback: port to new GLib thread API

This commit is contained in:
Tim-Philipp Müller 2012-09-10 01:10:24 +01:00
parent 5bb8021fc9
commit 952f347146
4 changed files with 22 additions and 29 deletions

View file

@ -500,7 +500,7 @@ gst_play_sink_convert_bin_finalize (GObject * object)
GstPlaySinkConvertBin *self = GST_PLAY_SINK_CONVERT_BIN_CAST (object); GstPlaySinkConvertBin *self = GST_PLAY_SINK_CONVERT_BIN_CAST (object);
gst_object_unref (self->sink_proxypad); gst_object_unref (self->sink_proxypad);
g_mutex_free (self->lock); g_mutex_clear (&self->lock);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -616,7 +616,7 @@ gst_play_sink_convert_bin_init (GstPlaySinkConvertBin * self)
{ {
GstPadTemplate *templ; GstPadTemplate *templ;
self->lock = g_mutex_new (); g_mutex_init (&self->lock);
gst_segment_init (&self->segment, GST_FORMAT_UNDEFINED); gst_segment_init (&self->segment, GST_FORMAT_UNDEFINED);
templ = gst_static_pad_template_get (&sinktemplate); templ = gst_static_pad_template_get (&sinktemplate);

View file

@ -41,7 +41,7 @@ G_BEGIN_DECLS
GST_LOG_OBJECT (obj, \ GST_LOG_OBJECT (obj, \
"locking from thread %p", \ "locking from thread %p", \
g_thread_self ()); \ g_thread_self ()); \
g_mutex_lock (GST_PLAY_SINK_CONVERT_BIN_CAST(obj)->lock); \ g_mutex_lock (&GST_PLAY_SINK_CONVERT_BIN_CAST(obj)->lock); \
GST_LOG_OBJECT (obj, \ GST_LOG_OBJECT (obj, \
"locked from thread %p", \ "locked from thread %p", \
g_thread_self ()); \ g_thread_self ()); \
@ -51,7 +51,7 @@ G_BEGIN_DECLS
GST_LOG_OBJECT (obj, \ GST_LOG_OBJECT (obj, \
"unlocking from thread %p", \ "unlocking from thread %p", \
g_thread_self ()); \ g_thread_self ()); \
g_mutex_unlock (GST_PLAY_SINK_CONVERT_BIN_CAST(obj)->lock); \ g_mutex_unlock (&GST_PLAY_SINK_CONVERT_BIN_CAST(obj)->lock); \
} G_STMT_END } G_STMT_END
typedef struct _GstPlaySinkConvertBin GstPlaySinkConvertBin; typedef struct _GstPlaySinkConvertBin GstPlaySinkConvertBin;
@ -62,7 +62,7 @@ struct _GstPlaySinkConvertBin
GstBin parent; GstBin parent;
/* < private > */ /* < private > */
GMutex *lock; GMutex lock;
GstPad *sinkpad, *sink_proxypad; GstPad *sinkpad, *sink_proxypad;
guint sink_proxypad_block_id; guint sink_proxypad_block_id;

View file

@ -162,15 +162,8 @@ gst_subtitle_overlay_finalize (GObject * object)
{ {
GstSubtitleOverlay *self = GST_SUBTITLE_OVERLAY (object); GstSubtitleOverlay *self = GST_SUBTITLE_OVERLAY (object);
if (self->lock) { g_mutex_clear (&self->lock);
g_mutex_free (self->lock); g_mutex_clear (&self->factories_lock);
self->lock = NULL;
}
if (self->factories_lock) {
g_mutex_free (self->factories_lock);
self->factories_lock = NULL;
}
if (self->factories) if (self->factories)
gst_plugin_feature_list_free (self->factories); gst_plugin_feature_list_free (self->factories);
@ -1181,7 +1174,7 @@ _pad_blocked_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
self->subtitle_flush = FALSE; self->subtitle_flush = FALSE;
/* Find our factories */ /* Find our factories */
g_mutex_lock (self->factories_lock); g_mutex_lock (&self->factories_lock);
gst_subtitle_overlay_update_factory_list (self); gst_subtitle_overlay_update_factory_list (self);
if (subcaps) { if (subcaps) {
factories = factories =
@ -1197,7 +1190,7 @@ _pad_blocked_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
self->subtitle_error = TRUE; self->subtitle_error = TRUE;
} }
} }
g_mutex_unlock (self->factories_lock); g_mutex_unlock (&self->factories_lock);
if (!subcaps) { if (!subcaps) {
_setup_passthrough (self); _setup_passthrough (self);
@ -1254,14 +1247,14 @@ _pad_blocked_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
g_assert (parser_caps != NULL); g_assert (parser_caps != NULL);
g_mutex_lock (self->factories_lock); g_mutex_lock (&self->factories_lock);
gst_subtitle_overlay_update_factory_list (self); gst_subtitle_overlay_update_factory_list (self);
GST_DEBUG_OBJECT (self, GST_DEBUG_OBJECT (self,
"Searching overlay factories for caps %" GST_PTR_FORMAT, parser_caps); "Searching overlay factories for caps %" GST_PTR_FORMAT, parser_caps);
overlay_factories = overlay_factories =
gst_subtitle_overlay_get_factories_for_caps (self->factories, gst_subtitle_overlay_get_factories_for_caps (self->factories,
parser_caps); parser_caps);
g_mutex_unlock (self->factories_lock); g_mutex_unlock (&self->factories_lock);
if (!overlay_factories) { if (!overlay_factories) {
GST_WARNING_OBJECT (self, GST_WARNING_OBJECT (self,
@ -1427,12 +1420,12 @@ gst_subtitle_overlay_change_state (GstElement * element,
switch (transition) { switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY: case GST_STATE_CHANGE_NULL_TO_READY:
GST_DEBUG_OBJECT (self, "State change NULL->READY"); GST_DEBUG_OBJECT (self, "State change NULL->READY");
g_mutex_lock (self->factories_lock); g_mutex_lock (&self->factories_lock);
if (G_UNLIKELY (!gst_subtitle_overlay_update_factory_list (self))) { if (G_UNLIKELY (!gst_subtitle_overlay_update_factory_list (self))) {
g_mutex_unlock (self->factories_lock); g_mutex_unlock (&self->factories_lock);
return GST_STATE_CHANGE_FAILURE; return GST_STATE_CHANGE_FAILURE;
} }
g_mutex_unlock (self->factories_lock); g_mutex_unlock (&self->factories_lock);
GST_SUBTITLE_OVERLAY_LOCK (self); GST_SUBTITLE_OVERLAY_LOCK (self);
/* Set the internal pads to blocking */ /* Set the internal pads to blocking */
@ -1940,7 +1933,7 @@ gst_subtitle_overlay_subtitle_sink_getcaps (GstPad * pad, GstCaps * filter)
GstSubtitleOverlay *self = GST_SUBTITLE_OVERLAY (gst_pad_get_parent (pad)); GstSubtitleOverlay *self = GST_SUBTITLE_OVERLAY (gst_pad_get_parent (pad));
GstCaps *ret; GstCaps *ret;
g_mutex_lock (self->factories_lock); g_mutex_lock (&self->factories_lock);
if (G_UNLIKELY (!gst_subtitle_overlay_update_factory_list (self))) if (G_UNLIKELY (!gst_subtitle_overlay_update_factory_list (self)))
ret = gst_caps_new_empty (); ret = gst_caps_new_empty ();
else if (filter) else if (filter)
@ -1949,7 +1942,7 @@ gst_subtitle_overlay_subtitle_sink_getcaps (GstPad * pad, GstCaps * filter)
GST_CAPS_INTERSECT_FIRST); GST_CAPS_INTERSECT_FIRST);
else else
ret = gst_caps_ref (self->factory_caps); ret = gst_caps_ref (self->factory_caps);
g_mutex_unlock (self->factories_lock); g_mutex_unlock (&self->factories_lock);
GST_DEBUG_OBJECT (pad, "Returning subtitle caps %" GST_PTR_FORMAT, ret); GST_DEBUG_OBJECT (pad, "Returning subtitle caps %" GST_PTR_FORMAT, ret);
@ -2229,8 +2222,8 @@ gst_subtitle_overlay_init (GstSubtitleOverlay * self)
GstPadTemplate *templ; GstPadTemplate *templ;
GstPad *proxypad = NULL; GstPad *proxypad = NULL;
self->lock = g_mutex_new (); g_mutex_init (&self->lock);
self->factories_lock = g_mutex_new (); g_mutex_init (&self->factories_lock);
templ = gst_static_pad_template_get (&srctemplate); templ = gst_static_pad_template_get (&srctemplate);
self->srcpad = gst_ghost_pad_new_no_target_from_template ("src", templ); self->srcpad = gst_ghost_pad_new_no_target_from_template ("src", templ);

View file

@ -40,7 +40,7 @@ G_BEGIN_DECLS
GST_LOG_OBJECT (obj, \ GST_LOG_OBJECT (obj, \
"locking from thread %p", \ "locking from thread %p", \
g_thread_self ()); \ g_thread_self ()); \
g_mutex_lock (GST_SUBTITLE_OVERLAY_CAST(obj)->lock); \ g_mutex_lock (&GST_SUBTITLE_OVERLAY_CAST(obj)->lock); \
GST_LOG_OBJECT (obj, \ GST_LOG_OBJECT (obj, \
"locked from thread %p", \ "locked from thread %p", \
g_thread_self ()); \ g_thread_self ()); \
@ -50,7 +50,7 @@ G_BEGIN_DECLS
GST_LOG_OBJECT (obj, \ GST_LOG_OBJECT (obj, \
"unlocking from thread %p", \ "unlocking from thread %p", \
g_thread_self ()); \ g_thread_self ()); \
g_mutex_unlock (GST_SUBTITLE_OVERLAY_CAST(obj)->lock); \ g_mutex_unlock (&GST_SUBTITLE_OVERLAY_CAST(obj)->lock); \
} G_STMT_END } G_STMT_END
typedef struct _GstSubtitleOverlay GstSubtitleOverlay; typedef struct _GstSubtitleOverlay GstSubtitleOverlay;
@ -85,12 +85,12 @@ struct _GstSubtitleOverlay
gboolean subtitle_flush; gboolean subtitle_flush;
gboolean subtitle_error; gboolean subtitle_error;
GMutex *factories_lock; GMutex factories_lock;
GList *factories; GList *factories;
guint32 factories_cookie; guint32 factories_cookie;
GstCaps *factory_caps; GstCaps *factory_caps;
GMutex *lock; GMutex lock;
GstCaps *subcaps; GstCaps *subcaps;
GstElement *passthrough_identity; GstElement *passthrough_identity;