mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
thread-pool: store thread type in thread
This commit is contained in:
parent
4e9c4d8bb7
commit
8cec0f8a46
2 changed files with 23 additions and 19 deletions
|
@ -70,19 +70,21 @@ gst_rtsp_thread_init (GstRTSPThreadImpl * impl)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_rtsp_thread_new:
|
* gst_rtsp_thread_new:
|
||||||
|
* @type: the thread type
|
||||||
*
|
*
|
||||||
* Create a new thread object that can run a mainloop.
|
* Create a new thread object that can run a mainloop.
|
||||||
*
|
*
|
||||||
* Returns: a #GstRTSPThread.
|
* Returns: a #GstRTSPThread.
|
||||||
*/
|
*/
|
||||||
GstRTSPThread *
|
GstRTSPThread *
|
||||||
gst_rtsp_thread_new (void)
|
gst_rtsp_thread_new (GstRTSPThreadType type)
|
||||||
{
|
{
|
||||||
GstRTSPThreadImpl *impl;
|
GstRTSPThreadImpl *impl;
|
||||||
|
|
||||||
impl = g_slice_new0 (GstRTSPThreadImpl);
|
impl = g_slice_new0 (GstRTSPThreadImpl);
|
||||||
|
|
||||||
gst_rtsp_thread_init (impl);
|
gst_rtsp_thread_init (impl);
|
||||||
|
impl->thread.type = type;
|
||||||
impl->thread.context = g_main_context_new ();
|
impl->thread.context = g_main_context_new ();
|
||||||
impl->thread.loop = g_main_loop_new (impl->thread.context, TRUE);
|
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 *
|
static GstRTSPThread *
|
||||||
make_thread (GstRTSPThreadPool * pool, GstRTSPClientState * state)
|
make_thread (GstRTSPThreadPool * pool, GstRTSPThreadType type,
|
||||||
|
GstRTSPClientState * state)
|
||||||
{
|
{
|
||||||
GstRTSPThreadPoolClass *klass;
|
GstRTSPThreadPoolClass *klass;
|
||||||
GstRTSPThread *thread;
|
GstRTSPThread *thread;
|
||||||
|
|
||||||
klass = GST_RTSP_THREAD_POOL_GET_CLASS (pool);
|
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,
|
gst_mini_object_set_qdata (GST_MINI_OBJECT (thread), thread_pool,
|
||||||
g_object_ref (pool), g_object_unref);
|
g_object_ref (pool), g_object_unref);
|
||||||
|
|
||||||
|
@ -401,7 +404,7 @@ default_get_thread (GstRTSPThreadPool * pool,
|
||||||
} else {
|
} else {
|
||||||
/* make more threads */
|
/* make more threads */
|
||||||
GST_DEBUG_OBJECT (pool, "make new client thread");
|
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))
|
if (!g_thread_pool_push (klass->pool, thread, &error))
|
||||||
goto thread_error;
|
goto thread_error;
|
||||||
|
@ -411,7 +414,7 @@ default_get_thread (GstRTSPThreadPool * pool,
|
||||||
break;
|
break;
|
||||||
case GST_RTSP_THREAD_TYPE_MEDIA:
|
case GST_RTSP_THREAD_TYPE_MEDIA:
|
||||||
GST_DEBUG_OBJECT (pool, "make new media thread");
|
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))
|
if (!g_thread_pool_push (klass->pool, thread, &error))
|
||||||
goto thread_error;
|
goto thread_error;
|
||||||
|
|
|
@ -47,6 +47,19 @@ GType gst_rtsp_thread_get_type (void);
|
||||||
#define GST_RTSP_THREAD_CAST(obj) ((GstRTSPThread*)(obj))
|
#define GST_RTSP_THREAD_CAST(obj) ((GstRTSPThread*)(obj))
|
||||||
#define GST_RTSP_THREAD(obj) (GST_RTSP_THREAD_CAST(obj))
|
#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:
|
* GstRTSPThread:
|
||||||
*
|
*
|
||||||
|
@ -55,11 +68,12 @@ GType gst_rtsp_thread_get_type (void);
|
||||||
struct _GstRTSPThread {
|
struct _GstRTSPThread {
|
||||||
GstMiniObject mini_object;
|
GstMiniObject mini_object;
|
||||||
|
|
||||||
|
GstRTSPThreadType type;
|
||||||
GMainContext *context;
|
GMainContext *context;
|
||||||
GMainLoop *loop;
|
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_reuse (GstRTSPThread * thread);
|
||||||
void gst_rtsp_thread_stop (GstRTSPThread * thread);
|
void gst_rtsp_thread_stop (GstRTSPThread * thread);
|
||||||
|
@ -99,19 +113,6 @@ gst_rtsp_thread_unref (GstRTSPThread * thread)
|
||||||
gst_mini_object_unref (GST_MINI_OBJECT_CAST (thread));
|
gst_mini_object_unref (GST_MINI_OBJECT_CAST (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:
|
* GstRTSPThreadPool:
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue