mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-12 02:15:31 +00:00
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:
parent
0c054aa00d
commit
a19ac4b85c
1 changed files with 9 additions and 14 deletions
|
@ -137,12 +137,8 @@ gst_socket_src_finalize (GObject * gobject)
|
||||||
{
|
{
|
||||||
GstSocketSrc *this = GST_SOCKET_SRC (gobject);
|
GstSocketSrc *this = GST_SOCKET_SRC (gobject);
|
||||||
|
|
||||||
if (this->cancellable)
|
g_clear_object (&this->cancellable);
|
||||||
g_object_unref (this->cancellable);
|
g_clear_object (&this->socket);
|
||||||
this->cancellable = NULL;
|
|
||||||
if (this->socket)
|
|
||||||
g_object_unref (this->socket);
|
|
||||||
this->socket = NULL;
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (gobject);
|
G_OBJECT_CLASS (parent_class)->finalize (gobject);
|
||||||
}
|
}
|
||||||
|
@ -155,21 +151,20 @@ gst_socket_src_fill (GstPushSrc * psrc, GstBuffer * outbuf)
|
||||||
gssize rret;
|
gssize rret;
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
GstMapInfo map;
|
GstMapInfo map;
|
||||||
GSocket *socket;
|
GSocket *socket = NULL;
|
||||||
|
|
||||||
src = GST_SOCKET_SRC (psrc);
|
src = GST_SOCKET_SRC (psrc);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (src);
|
GST_OBJECT_LOCK (src);
|
||||||
|
|
||||||
socket = src->socket;
|
if (src->socket)
|
||||||
if (socket == NULL) {
|
socket = g_object_ref (src->socket);
|
||||||
GST_OBJECT_UNLOCK (src);
|
|
||||||
goto no_socket;
|
|
||||||
}
|
|
||||||
g_object_ref (socket);
|
|
||||||
|
|
||||||
GST_OBJECT_UNLOCK (src);
|
GST_OBJECT_UNLOCK (src);
|
||||||
|
|
||||||
|
if (socket == NULL)
|
||||||
|
goto no_socket;
|
||||||
|
|
||||||
GST_LOG_OBJECT (src, "asked for a buffer");
|
GST_LOG_OBJECT (src, "asked for a buffer");
|
||||||
|
|
||||||
gst_buffer_map (outbuf, &map, GST_MAP_READWRITE);
|
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));
|
GST_BUFFER_OFFSET (outbuf), GST_BUFFER_OFFSET_END (outbuf));
|
||||||
}
|
}
|
||||||
g_clear_error (&err);
|
g_clear_error (&err);
|
||||||
|
g_clear_object (&socket);
|
||||||
|
|
||||||
g_object_unref (socket);
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
no_socket:
|
no_socket:
|
||||||
|
|
Loading…
Reference in a new issue