socketsrc: Tidy up usage of g_object_unref/g_clear_object and locking

This is clearer, and should make future changes safer.  No functional
change intended.

See https://bugzilla.gnome.org/show_bug.cgi?id=739546
This commit is contained in:
William Manley 2015-03-13 13:43:59 +00:00 committed by Wim Taymans
parent 0c054aa00d
commit a19ac4b85c

View file

@ -137,12 +137,8 @@ gst_socket_src_finalize (GObject * gobject)
{
GstSocketSrc *this = GST_SOCKET_SRC (gobject);
if (this->cancellable)
g_object_unref (this->cancellable);
this->cancellable = NULL;
if (this->socket)
g_object_unref (this->socket);
this->socket = NULL;
g_clear_object (&this->cancellable);
g_clear_object (&this->socket);
G_OBJECT_CLASS (parent_class)->finalize (gobject);
}
@ -155,21 +151,20 @@ gst_socket_src_fill (GstPushSrc * psrc, GstBuffer * outbuf)
gssize rret;
GError *err = NULL;
GstMapInfo map;
GSocket *socket;
GSocket *socket = NULL;
src = GST_SOCKET_SRC (psrc);
GST_OBJECT_LOCK (src);
socket = src->socket;
if (socket == NULL) {
GST_OBJECT_UNLOCK (src);
goto no_socket;
}
g_object_ref (socket);
if (src->socket)
socket = g_object_ref (src->socket);
GST_OBJECT_UNLOCK (src);
if (socket == NULL)
goto no_socket;
GST_LOG_OBJECT (src, "asked for a buffer");
gst_buffer_map (outbuf, &map, GST_MAP_READWRITE);
@ -203,8 +198,8 @@ gst_socket_src_fill (GstPushSrc * psrc, GstBuffer * outbuf)
GST_BUFFER_OFFSET (outbuf), GST_BUFFER_OFFSET_END (outbuf));
}
g_clear_error (&err);
g_clear_object (&socket);
g_object_unref (socket);
return ret;
no_socket: