From: Wim Taymans Date: Wed, 10 Jul 2013 18:48:18 +0000 (+0200) Subject: thread-pool: store thread type in thread X-Git-Tag: 1.19.3~495^2~1056 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8cec0f8a4690bd1146102eef6a914aa6c5830534;p=platform%2Fupstream%2Fgstreamer.git thread-pool: store thread type in thread --- diff --git a/gst/rtsp-server/rtsp-thread-pool.c b/gst/rtsp-server/rtsp-thread-pool.c index 5f81213..d22d665 100644 --- a/gst/rtsp-server/rtsp-thread-pool.c +++ b/gst/rtsp-server/rtsp-thread-pool.c @@ -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; diff --git a/gst/rtsp-server/rtsp-thread-pool.h b/gst/rtsp-server/rtsp-thread-pool.h index 301b8a1..a9c013b 100644 --- a/gst/rtsp-server/rtsp-thread-pool.h +++ b/gst/rtsp-server/rtsp-thread-pool.h @@ -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.