summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.co.uk>2010-03-25 21:56:19 (GMT)
committerOlivier CrĂȘte <olivier.crete@collabora.co.uk>2010-09-09 08:24:39 (GMT)
commit7dc21db02f773510a4de9fdf011dfd41219f57ef (patch)
tree96d3d16dbdce07b2d9e19a3d5a676422274fe162
parentd06506bbfeead08ee793c0f71f3bfca5c197f5b0 (diff)
downloadtelepathy-stream-engine-7dc21db02f773510a4de9fdf011dfd41219f57ef.tar.gz
telepathy-stream-engine-7dc21db02f773510a4de9fdf011dfd41219f57ef.tar.xz
Use thread tracking data struct everywhere instead of big stream-engine one
-rw-r--r--src/tp-stream-engine.c67
1 files changed, 33 insertions, 34 deletions
diff --git a/src/tp-stream-engine.c b/src/tp-stream-engine.c
index d20a7f2..b83c16f 100644
--- a/src/tp-stream-engine.c
+++ b/src/tp-stream-engine.c
@@ -156,11 +156,10 @@ struct ThreadTrackingData {
};
struct ObjectTrackingData {
- TpStreamEngine *self;
+ struct ThreadTrackingData *ttd;
GPtrArray *objects;
void (*setup_thread_prio) (pthread_t thread, pid_t tid);
-
};
/* private structure */
@@ -294,19 +293,22 @@ tp_stream_engine_init (TpStreamEngine *self)
priv->thread_tracking_data.object_threads = g_hash_table_new (g_direct_hash, g_direct_equal);
priv->thread_tracking_data.object_tids = g_hash_table_new (g_direct_hash, g_direct_equal);
+
+ priv->mutex = g_mutex_new ();
+
priv->thread_tracking_data.otds = g_ptr_array_new ();
+ priv->thread_tracking_data.mutex = priv->mutex;
- priv->audio_object_data.self = self;
+ priv->audio_object_data.ttd = &priv->thread_tracking_data;
priv->audio_object_data.objects = g_ptr_array_new ();
priv->audio_object_data.setup_thread_prio = setup_realtime_thread;
g_ptr_array_add (priv->thread_tracking_data.otds, &priv->audio_object_data);
- priv->video_object_data.self = self;
+ priv->video_object_data.ttd = &priv->thread_tracking_data;
priv->video_object_data.objects = g_ptr_array_new ();
priv->video_object_data.setup_thread_prio = low_prio_thread;
g_ptr_array_add (priv->thread_tracking_data.otds, &priv->video_object_data);
- priv->mutex = g_mutex_new ();
priv->notifier = fs_element_added_notifier_new ();
@@ -874,9 +876,9 @@ remove_object (gpointer data, GObject *where_the_obj_was)
{
struct ObjectTrackingData *otd = data;
- g_mutex_lock (otd->self->priv->mutex);
+ g_mutex_lock (otd->ttd->mutex);
g_ptr_array_remove (otd->objects, where_the_obj_was);
- g_mutex_unlock (otd->self->priv->mutex);
+ g_mutex_unlock (otd->ttd->mutex);
}
static void
@@ -902,9 +904,9 @@ insert_object_locked (struct ObjectTrackingData *otd, gpointer object)
thread = GPOINTER_TO_UINT (
- g_hash_table_lookup (otd->self->priv->thread_tracking_data.object_threads, object));
+ g_hash_table_lookup (otd->ttd->object_threads, object));
tid = GPOINTER_TO_UINT (
- g_hash_table_lookup (otd->self->priv->thread_tracking_data.object_tids, object));
+ g_hash_table_lookup (otd->ttd->object_tids, object));
if (thread && tid)
otd->setup_thread_prio (thread, tid);
@@ -936,7 +938,7 @@ add_pad_locked (struct ObjectTrackingData *otd, GstPad *pad)
{
if (GST_IS_PAD (parent))
{
- add_pad_locked (otd, parent);
+ add_pad_locked (otd, GST_PAD_CAST (parent));
}
else
{
@@ -989,7 +991,7 @@ pad_iter_locked (gpointer data, gpointer user_data)
static void
pad_linked (GstPad *pad, GstPad *peer, struct ObjectTrackingData *otd)
{
- g_mutex_lock (otd->self->priv->mutex);
+ g_mutex_lock (otd->ttd->mutex);
if (add_pad_locked (otd, peer))
{
GstIterator *iter = gst_pad_iterate_internal_links (peer);
@@ -1003,7 +1005,7 @@ pad_linked (GstPad *pad, GstPad *peer, struct ObjectTrackingData *otd)
gst_iterator_free (iter);
}
}
- g_mutex_unlock (otd->self->priv->mutex);
+ g_mutex_unlock (otd->ttd->mutex);
}
static void
@@ -1028,7 +1030,7 @@ sink_added_cb (gpointer stream,
{
GstIterator *iter;
- g_mutex_lock (otd->self->priv->mutex);
+ g_mutex_lock (otd->ttd->mutex);
iter = gst_element_iterate_sink_pads (sink);
while (gst_iterator_foreach (iter, pad_iter_locked, otd) ==
@@ -1041,7 +1043,7 @@ sink_added_cb (gpointer stream,
gst_iterator_resync (iter);
gst_iterator_free (iter);
- g_mutex_unlock (otd->self->priv->mutex);
+ g_mutex_unlock (otd->ttd->mutex);
}
static void
@@ -1477,24 +1479,19 @@ low_prio_thread (pthread_t thread, pid_t tid)
}
static void
-enter_thread (TpStreamEngine *self, GstObject *src, GstElement *owner)
+enter_thread (struct ThreadTrackingData *ttd, GstObject *src, GstElement *owner)
{
pthread_t thread = pthread_self ();
pid_t tid = syscall (__NR_gettid);
guint i, j;
- g_mutex_lock (self->priv->mutex);
- g_hash_table_insert (self->priv->thread_tracking_data.object_threads, src,
- GINT_TO_POINTER (thread));
- g_hash_table_insert (self->priv->thread_tracking_data.object_tids, src,
- GINT_TO_POINTER (tid));
-
- for (i = 0;
- g_ptr_array_index (self->priv->thread_tracking_data.otds, i);
- i++)
+ g_mutex_lock (ttd->mutex);
+ g_hash_table_insert (ttd->object_threads, src, GINT_TO_POINTER (thread));
+ g_hash_table_insert (ttd->object_tids, src, GINT_TO_POINTER (tid));
+
+ for (i = 0; g_ptr_array_index (ttd->otds, i); i++)
{
- struct ObjectTrackingData *otd =
- g_ptr_array_index (self->priv->thread_tracking_data.otds, i);
+ struct ObjectTrackingData *otd = g_ptr_array_index (ttd->otds, i);
for (j = 0; j < otd->objects->len; j++)
{
@@ -1504,20 +1501,20 @@ enter_thread (TpStreamEngine *self, GstObject *src, GstElement *owner)
}
}
- g_mutex_unlock (self->priv->mutex);
+ g_mutex_unlock (ttd->mutex);
}
static void
-leave_thread (TpStreamEngine *self, GstObject *src, GstElement *owner)
+leave_thread (struct ThreadTrackingData *ttd, GstObject *src, GstElement *owner)
{
pthread_t thread = pthread_self ();
pid_t tid = syscall (__NR_gettid);
struct sched_param param;
- g_mutex_lock (self->priv->mutex);
- g_hash_table_remove (self->priv->thread_tracking_data.object_threads, src);
- g_hash_table_remove (self->priv->thread_tracking_data.object_tids, src);
- g_mutex_unlock (self->priv->mutex);
+ g_mutex_lock (ttd->mutex);
+ g_hash_table_remove (ttd->object_threads, src);
+ g_hash_table_remove (ttd->object_tids, src);
+ g_mutex_unlock (ttd->mutex);
if (setpriority (PRIO_PROCESS, tid, 0))
g_warning ("Could not restore thread priority to 0: %lX %s", (unsigned long int) thread, strerror (errno));
@@ -1594,10 +1591,12 @@ bus_sync_handler (GstBus *bus G_GNUC_UNUSED, GstMessage *message, gpointer data)
switch (type)
{
case GST_STREAM_STATUS_TYPE_ENTER:
- enter_thread (self, GST_MESSAGE_SRC (message), owner);
+ enter_thread (&self->priv->thread_tracking_data,
+ GST_MESSAGE_SRC (message), owner);
break;
case GST_STREAM_STATUS_TYPE_LEAVE:
- leave_thread (self, GST_MESSAGE_SRC (message), owner);
+ leave_thread (&self->priv->thread_tracking_data,
+ GST_MESSAGE_SRC (message), owner);
break;
default:
break;