mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
rtspconnection: Only create writesrc when it is actually needed
Creating a GSource and not attaching it to a context will cause a leak of it's child sources. That is why we create writesrc right before attaching it to a context. https://bugzilla.gnome.org/show_bug.cgi?id=708667
This commit is contained in:
parent
663f71a5dd
commit
8ba90931ae
1 changed files with 14 additions and 28 deletions
|
@ -2785,7 +2785,6 @@ struct _GstRTSPWatch
|
||||||
|
|
||||||
GSource *readsrc;
|
GSource *readsrc;
|
||||||
GSource *writesrc;
|
GSource *writesrc;
|
||||||
gboolean write_added;
|
|
||||||
|
|
||||||
gboolean keep_running;
|
gboolean keep_running;
|
||||||
|
|
||||||
|
@ -2975,19 +2974,12 @@ gst_rtsp_source_dispatch_write (GPollableOutputStream * stream,
|
||||||
/* get a new message from the queue */
|
/* get a new message from the queue */
|
||||||
rec = g_queue_pop_tail (watch->messages);
|
rec = g_queue_pop_tail (watch->messages);
|
||||||
if (rec == NULL) {
|
if (rec == NULL) {
|
||||||
if (watch->write_added) {
|
if (watch->writesrc) {
|
||||||
g_source_remove_child_source ((GSource *) watch, watch->writesrc);
|
g_source_remove_child_source ((GSource *) watch, watch->writesrc);
|
||||||
watch->write_added = FALSE;
|
|
||||||
|
|
||||||
/* Need to create a new source as once removed/destroyed sources
|
|
||||||
* can't be attached again later */
|
|
||||||
g_source_unref (watch->writesrc);
|
g_source_unref (watch->writesrc);
|
||||||
watch->writesrc =
|
watch->writesrc = NULL;
|
||||||
g_pollable_output_stream_create_source (G_POLLABLE_OUTPUT_STREAM
|
/* we create and add the write source again when we actually have
|
||||||
(watch->conn->output_stream), NULL);
|
* something to write */
|
||||||
g_source_set_callback (watch->writesrc,
|
|
||||||
(GSourceFunc) gst_rtsp_source_dispatch_write, watch, NULL);
|
|
||||||
/* we add the write source when we actually have something to write */
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3147,11 +3139,9 @@ gst_rtsp_watch_reset (GstRTSPWatch * watch)
|
||||||
g_source_unref (watch->readsrc);
|
g_source_unref (watch->readsrc);
|
||||||
}
|
}
|
||||||
if (watch->writesrc) {
|
if (watch->writesrc) {
|
||||||
if (watch->write_added) {
|
|
||||||
g_source_remove_child_source ((GSource *) watch, watch->writesrc);
|
g_source_remove_child_source ((GSource *) watch, watch->writesrc);
|
||||||
watch->write_added = FALSE;
|
|
||||||
}
|
|
||||||
g_source_unref (watch->writesrc);
|
g_source_unref (watch->writesrc);
|
||||||
|
watch->writesrc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (watch->conn->input_stream) {
|
if (watch->conn->input_stream) {
|
||||||
|
@ -3165,16 +3155,8 @@ gst_rtsp_watch_reset (GstRTSPWatch * watch)
|
||||||
watch->readsrc = NULL;
|
watch->readsrc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (watch->conn->output_stream) {
|
/* we create and add the write source when we actually have something to
|
||||||
watch->writesrc =
|
* write */
|
||||||
g_pollable_output_stream_create_source (G_POLLABLE_OUTPUT_STREAM
|
|
||||||
(watch->conn->output_stream), NULL);
|
|
||||||
g_source_set_callback (watch->writesrc,
|
|
||||||
(GSourceFunc) gst_rtsp_source_dispatch_write, watch, NULL);
|
|
||||||
/* we add the write source when we actually have something to write */
|
|
||||||
} else {
|
|
||||||
watch->writesrc = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3343,9 +3325,13 @@ gst_rtsp_watch_write_data (GstRTSPWatch * watch, const guint8 * data,
|
||||||
/* make sure the main context will now also check for writability on the
|
/* make sure the main context will now also check for writability on the
|
||||||
* socket */
|
* socket */
|
||||||
context = ((GSource *) watch)->context;
|
context = ((GSource *) watch)->context;
|
||||||
if (!watch->write_added) {
|
if (!watch->writesrc) {
|
||||||
|
watch->writesrc =
|
||||||
|
g_pollable_output_stream_create_source (G_POLLABLE_OUTPUT_STREAM
|
||||||
|
(watch->conn->output_stream), NULL);
|
||||||
|
g_source_set_callback (watch->writesrc,
|
||||||
|
(GSourceFunc) gst_rtsp_source_dispatch_write, watch, NULL);
|
||||||
g_source_add_child_source ((GSource *) watch, watch->writesrc);
|
g_source_add_child_source ((GSource *) watch, watch->writesrc);
|
||||||
watch->write_added = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id != NULL)
|
if (id != NULL)
|
||||||
|
|
Loading…
Reference in a new issue