rtsp-server: No need to store the GMainContext in the client context
authorOlivier CrĂȘte <olivier.crete@collabora.com>
Tue, 19 Feb 2013 17:31:23 +0000 (12:31 -0500)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 11 Mar 2013 10:07:20 +0000 (11:07 +0100)
gst/rtsp-server/rtsp-server.c

index f41b390..9ab709e 100644 (file)
@@ -916,14 +916,12 @@ struct _ClientContext
 {
   GstRTSPServer *server;
   GMainLoop *loop;
-  GMainContext *context;
   GstRTSPClient *client;
 };
 
 static void
 free_client_context (ClientContext * ctx)
 {
-  g_main_context_unref (ctx->context);
   if (ctx->loop)
     g_main_loop_unref (ctx->loop);
   g_object_unref (ctx->client);
@@ -971,6 +969,7 @@ manage_client (GstRTSPServer * server, GstRTSPClient * client)
 {
   ClientContext *ctx;
   GstRTSPServerPrivate *priv = server->priv;
+  GMainContext *mainctx;
 
   GST_DEBUG_OBJECT (server, "manage client %p", client);
 
@@ -982,14 +981,15 @@ manage_client (GstRTSPServer * server, GstRTSPClient * client)
 
     /* find the context to add the watch */
     if ((source = g_main_current_source ()))
-      ctx->context = g_main_context_ref (g_source_get_context (source));
+      mainctx = g_source_get_context (source);
     else
-      ctx->context = NULL;
+      mainctx = NULL;
   } else {
-    ctx->context = g_main_context_new ();
-    ctx->loop = g_main_loop_new (ctx->context, TRUE);
+    mainctx = g_main_context_new ();
+    ctx->loop = g_main_loop_new (mainctx, TRUE);
+    g_main_context_unref (mainctx);
   }
-  gst_rtsp_client_attach (client, ctx->context);
+  gst_rtsp_client_attach (client, mainctx);
 
   GST_RTSP_SERVER_LOCK (server);
   g_signal_connect (client, "closed", (GCallback) unmanage_client, ctx);