summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.co.uk>2010-03-25 21:38:41 (GMT)
committerOlivier CrĂȘte <olivier.crete@collabora.co.uk>2010-09-09 08:24:39 (GMT)
commitd06506bbfeead08ee793c0f71f3bfca5c197f5b0 (patch)
tree7737700ba777a5a09616ae23d4093209ee107fe0
parent3d19ba7854899891f8bdf01acb754f1636ab0dcd (diff)
downloadtelepathy-stream-engine-d06506bbfeead08ee793c0f71f3bfca5c197f5b0.tar.gz
telepathy-stream-engine-d06506bbfeead08ee793c0f71f3bfca5c197f5b0.tar.xz
Put thread tracking data into own structure
-rw-r--r--src/tp-stream-engine.c66
1 files changed, 40 insertions, 26 deletions
diff --git a/src/tp-stream-engine.c b/src/tp-stream-engine.c
index b48ec7e..d20a7f2 100644
--- a/src/tp-stream-engine.c
+++ b/src/tp-stream-engine.c
@@ -145,6 +145,16 @@ enum
static guint signals[LAST_SIGNAL] = {0};
+
+struct ThreadTrackingData {
+ GMutex *mutex;
+
+ GHashTable *object_threads;
+ GHashTable *object_tids;
+
+ GPtrArray *otds;
+};
+
struct ObjectTrackingData {
TpStreamEngine *self;
GPtrArray *objects;
@@ -192,9 +202,7 @@ struct _TpStreamEnginePrivate
struct ObjectTrackingData audio_object_data;
struct ObjectTrackingData video_object_data;
-
- GHashTable *object_threads;
- GHashTable *object_tids;
+ struct ThreadTrackingData thread_tracking_data;
DBusGConnection *system_bus_connection;
LibHalContext *libhal_ctx;
@@ -283,16 +291,20 @@ tp_stream_engine_init (TpStreamEngine *self)
priv->channels_by_path = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
- priv->object_threads = g_hash_table_new (g_direct_hash, g_direct_equal);
- priv->object_tids = g_hash_table_new (g_direct_hash, g_direct_equal);
+ 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->thread_tracking_data.otds = g_ptr_array_new ();
priv->audio_object_data.self = self;
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.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 ();
@@ -488,8 +500,9 @@ tp_stream_engine_finalize (GObject *object)
g_ptr_array_free (self->priv->audio_object_data.objects, TRUE);
g_ptr_array_free (self->priv->video_object_data.objects, TRUE);
- g_hash_table_destroy (self->priv->object_threads);
- g_hash_table_destroy (self->priv->object_tids);
+ g_hash_table_destroy (self->priv->thread_tracking_data.object_threads);
+ g_hash_table_destroy (self->priv->thread_tracking_data.object_tids);
+ g_ptr_array_free (self->priv->thread_tracking_data.otds, TRUE);
G_OBJECT_CLASS (tp_stream_engine_parent_class)->finalize (object);
}
@@ -889,9 +902,9 @@ insert_object_locked (struct ObjectTrackingData *otd, gpointer object)
thread = GPOINTER_TO_UINT (
- g_hash_table_lookup (otd->self->priv->object_threads, object));
+ g_hash_table_lookup (otd->self->priv->thread_tracking_data.object_threads, object));
tid = GPOINTER_TO_UINT (
- g_hash_table_lookup (otd->self->priv->object_tids, object));
+ g_hash_table_lookup (otd->self->priv->thread_tracking_data.object_tids, object));
if (thread && tid)
otd->setup_thread_prio (thread, tid);
@@ -1468,27 +1481,28 @@ enter_thread (TpStreamEngine *self, GstObject *src, GstElement *owner)
{
pthread_t thread = pthread_self ();
pid_t tid = syscall (__NR_gettid);
- guint i;
+ guint i, j;
g_mutex_lock (self->priv->mutex);
- g_hash_table_insert (self->priv->object_threads, src,
+ g_hash_table_insert (self->priv->thread_tracking_data.object_threads, src,
GINT_TO_POINTER (thread));
- g_hash_table_insert (self->priv->object_tids, src,
+ g_hash_table_insert (self->priv->thread_tracking_data.object_tids, src,
GINT_TO_POINTER (tid));
- for (i = 0; i < self->priv->audio_object_data.objects->len; i++)
- if (g_ptr_array_index (self->priv->audio_object_data.objects, i) == src)
- {
- self->priv->audio_object_data.setup_thread_prio (thread, tid);
- break;
- }
+ for (i = 0;
+ g_ptr_array_index (self->priv->thread_tracking_data.otds, i);
+ i++)
+ {
+ struct ObjectTrackingData *otd =
+ g_ptr_array_index (self->priv->thread_tracking_data.otds, i);
- for (i = 0; i < self->priv->video_object_data.objects->len; i++)
- if (g_ptr_array_index (self->priv->video_object_data.objects, i) == src)
- {
- self->priv->video_object_data.setup_thread_prio (thread, tid);
- break;
- }
+ for (j = 0; j < otd->objects->len; j++)
+ {
+ if (g_ptr_array_index (otd->objects, j) == src)
+ otd->setup_thread_prio (thread, tid);
+ break;
+ }
+ }
g_mutex_unlock (self->priv->mutex);
}
@@ -1501,8 +1515,8 @@ leave_thread (TpStreamEngine *self, GstObject *src, GstElement *owner)
struct sched_param param;
g_mutex_lock (self->priv->mutex);
- g_hash_table_remove (self->priv->object_threads, src);
- g_hash_table_remove (self->priv->object_tids, src);
+ 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);
if (setpriority (PRIO_PROCESS, tid, 0))