gst_rtsp_thread_reuse (GstRTSPThread * thread)
{
GstRTSPThreadImpl *impl = (GstRTSPThreadImpl *) thread;
+ gboolean res;
g_return_val_if_fail (GST_IS_RTSP_THREAD (thread), FALSE);
GST_DEBUG ("reuse thread %p", thread);
- return g_atomic_int_add (&impl->reused, 1) > 0;
+ res = g_atomic_int_add (&impl->reused, 1) > 0;
+ if (res)
+ gst_rtsp_thread_ref (thread);
+
+ return res;
}
static gboolean
thread, (GDestroyNotify) gst_rtsp_thread_unref);
g_source_attach (source, thread->context);
g_source_unref (source);
- }
+ } else
+ gst_rtsp_thread_unref (thread);
}
#define GST_RTSP_THREAD_POOL_GET_PRIVATE(obj) \
* stops. */
goto retry;
}
- gst_rtsp_thread_ref (thread);
} else {
/* make more threads */
GST_DEBUG_OBJECT (pool, "make new client thread");
thread = gst_rtsp_thread_pool_get_thread (pool, GST_RTSP_THREAD_TYPE_CLIENT,
NULL);
fail_unless (thread != NULL);
+ /* one ref is hold by the pool */
+ fail_unless (GST_MINI_OBJECT_REFCOUNT (thread) == 2);
gst_rtsp_thread_stop (thread);
g_object_unref (pool);
fail_unless (thread2 != NULL);
fail_unless (thread == thread2);
+ /* one ref is hold by the pool */
+ fail_unless (GST_MINI_OBJECT_REFCOUNT (thread) == 3);
gst_rtsp_thread_stop (thread);
gst_rtsp_thread_stop (thread2);