summaryrefslogtreecommitdiffstats
path: root/gst/udp/gstmultiudpsink.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst/udp/gstmultiudpsink.c')
-rw-r--r--gst/udp/gstmultiudpsink.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/gst/udp/gstmultiudpsink.c b/gst/udp/gstmultiudpsink.c
index 1188b31a..e08613ea 100644
--- a/gst/udp/gstmultiudpsink.c
+++ b/gst/udp/gstmultiudpsink.c
@@ -105,9 +105,14 @@ enum
};
#define CLOSE_IF_REQUESTED(udpctx) \
- if ((!udpctx->externalfd) || (udpctx->externalfd && udpctx->closefd)) \
+G_STMT_START { \
+ if ((!udpctx->externalfd) || (udpctx->externalfd && udpctx->closefd)) { \
CLOSE_SOCKET(udpctx->sock); \
- udpctx->sock = -1;
+ if (udpctx->sock == udpctx->sockfd) \
+ udpctx->sockfd = DEFAULT_SOCKFD; \
+ } \
+ udpctx->sock = DEFAULT_SOCK; \
+} G_STMT_END
static void gst_multiudpsink_base_init (gpointer g_class);
static void gst_multiudpsink_class_init (GstMultiUDPSinkClass * klass);
@@ -332,7 +337,7 @@ gst_multiudpsink_init (GstMultiUDPSink * sink)
WSA_STARTUP (sink);
sink->client_lock = g_mutex_new ();
- sink->sock = -1;
+ sink->sock = DEFAULT_SOCK;
sink->sockfd = DEFAULT_SOCKFD;
sink->closefd = DEFAULT_CLOSEFD;
sink->externalfd = (sink->sockfd != -1);
@@ -352,6 +357,9 @@ gst_multiudpsink_finalize (GObject * object)
g_list_foreach (sink->clients, (GFunc) free_client, NULL);
g_list_free (sink->clients);
+ if (sink->sockfd >= 0 && sink->closefd)
+ CLOSE_SOCKET (sink->sockfd);
+
g_mutex_free (sink->client_lock);
WSA_CLEANUP (object);
@@ -517,6 +525,9 @@ gst_multiudpsink_set_property (GObject * object, guint prop_id,
switch (prop_id) {
case PROP_SOCKFD:
+ if (udpsink->sockfd >= 0 && udpsink->sockfd != udpsink->sock &&
+ udpsink->closefd)
+ CLOSE_SOCKET (udpsink->sockfd);
udpsink->sockfd = g_value_get_int (value);
GST_DEBUG_OBJECT (udpsink, "setting SOCKFD to %d", udpsink->sockfd);
break;