thread-pool: store thread type in thread
authorWim Taymans <wim.taymans@collabora.co.uk>
Wed, 10 Jul 2013 18:48:18 +0000 (20:48 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Wed, 10 Jul 2013 18:48:18 +0000 (20:48 +0200)
gst/rtsp-server/rtsp-thread-pool.c
gst/rtsp-server/rtsp-thread-pool.h

index 5f81213..d22d665 100644 (file)
@@ -70,19 +70,21 @@ gst_rtsp_thread_init (GstRTSPThreadImpl * impl)
 
 /**
  * gst_rtsp_thread_new:
+ * @type: the thread type
  *
  * Create a new thread object that can run a mainloop.
  *
  * Returns: a #GstRTSPThread.
  */
 GstRTSPThread *
-gst_rtsp_thread_new (void)
+gst_rtsp_thread_new (GstRTSPThreadType type)
 {
   GstRTSPThreadImpl *impl;
 
   impl = g_slice_new0 (GstRTSPThreadImpl);
 
   gst_rtsp_thread_init (impl);
+  impl->thread.type = type;
   impl->thread.context = g_main_context_new ();
   impl->thread.loop = g_main_loop_new (impl->thread.context, TRUE);
 
@@ -355,14 +357,15 @@ gst_rtsp_thread_pool_get_max_threads (GstRTSPThreadPool * pool)
 }
 
 static GstRTSPThread *
-make_thread (GstRTSPThreadPool * pool, GstRTSPClientState * state)
+make_thread (GstRTSPThreadPool * pool, GstRTSPThreadType type,
+    GstRTSPClientState * state)
 {
   GstRTSPThreadPoolClass *klass;
   GstRTSPThread *thread;
 
   klass = GST_RTSP_THREAD_POOL_GET_CLASS (pool);
 
-  thread = gst_rtsp_thread_new ();
+  thread = gst_rtsp_thread_new (type);
   gst_mini_object_set_qdata (GST_MINI_OBJECT (thread), thread_pool,
       g_object_ref (pool), g_object_unref);
 
@@ -401,7 +404,7 @@ default_get_thread (GstRTSPThreadPool * pool,
         } else {
           /* make more threads */
           GST_DEBUG_OBJECT (pool, "make new client thread");
-          thread = make_thread (pool, state);
+          thread = make_thread (pool, type, state);
 
           if (!g_thread_pool_push (klass->pool, thread, &error))
             goto thread_error;
@@ -411,7 +414,7 @@ default_get_thread (GstRTSPThreadPool * pool,
       break;
     case GST_RTSP_THREAD_TYPE_MEDIA:
       GST_DEBUG_OBJECT (pool, "make new media thread");
-      thread = make_thread (pool, state);
+      thread = make_thread (pool, type, state);
 
       if (!g_thread_pool_push (klass->pool, thread, &error))
         goto thread_error;
index 301b8a1..a9c013b 100644 (file)
@@ -48,6 +48,19 @@ GType gst_rtsp_thread_get_type (void);
 #define GST_RTSP_THREAD(obj)        (GST_RTSP_THREAD_CAST(obj))
 
 /**
+ * GstRTSPThreadType:
+ * @GST_RTSP_THREAD_TYPE_CLIENT: a thread to handle the client communication
+ * @GST_RTSP_THREAD_TYPE_MEDIA: a thread to handle media 
+ *
+ * Different thread types
+ */
+typedef enum
+{
+  GST_RTSP_THREAD_TYPE_CLIENT,
+  GST_RTSP_THREAD_TYPE_MEDIA
+} GstRTSPThreadType;
+
+/**
  * GstRTSPThread:
  *
  * Structure holding info about a mainloop running in a thread
@@ -55,11 +68,12 @@ GType gst_rtsp_thread_get_type (void);
 struct _GstRTSPThread {
   GstMiniObject mini_object;
 
+  GstRTSPThreadType type;
   GMainContext *context;
   GMainLoop *loop;
 };
 
-GstRTSPThread *   gst_rtsp_thread_new      (void);
+GstRTSPThread *   gst_rtsp_thread_new      (GstRTSPThreadType type);
 
 void              gst_rtsp_thread_reuse    (GstRTSPThread * thread);
 void              gst_rtsp_thread_stop     (GstRTSPThread * thread);
@@ -100,19 +114,6 @@ gst_rtsp_thread_unref (GstRTSPThread * thread)
 }
 
 /**
- * GstRTSPThreadType:
- * @GST_RTSP_THREAD_TYPE_CLIENT: a thread to handle the client communication
- * @GST_RTSP_THREAD_TYPE_MEDIA: a thread to handle media 
- *
- * Different thread types
- */
-typedef enum
-{
-  GST_RTSP_THREAD_TYPE_CLIENT,
-  GST_RTSP_THREAD_TYPE_MEDIA
-} GstRTSPThreadType;
-
-/**
  * GstRTSPThreadPool:
  *
  * The thread pool structure.