Commit 20a5868e authored by Philip Withnall's avatar Philip Withnall

agent: Add debug output for lifetime of Components and Streams

parent 28d1c100
...@@ -42,6 +42,11 @@ ...@@ -42,6 +42,11 @@
* @brief ICE component functions * @brief ICE component functions
*/ */
/* Simple tracking for the number of alive components. These must be accessed
* atomically. */
static volatile unsigned int n_components_created = 0;
static volatile unsigned int n_components_destroyed = 0;
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif
...@@ -121,6 +126,10 @@ component_new (guint id, NiceAgent *agent, Stream *stream) ...@@ -121,6 +126,10 @@ component_new (guint id, NiceAgent *agent, Stream *stream)
{ {
Component *component; Component *component;
g_atomic_int_inc (&n_components_created);
nice_debug ("Created NiceComponent (%u created, %u destroyed)",
n_components_created, n_components_destroyed);
component = g_slice_new0 (Component); component = g_slice_new0 (Component);
component->id = id; component->id = id;
component->state = NICE_COMPONENT_STATE_DISCONNECTED; component->state = NICE_COMPONENT_STATE_DISCONNECTED;
...@@ -318,6 +327,10 @@ component_free (Component *cmp) ...@@ -318,6 +327,10 @@ component_free (Component *cmp)
g_main_context_unref (cmp->own_ctx); g_main_context_unref (cmp->own_ctx);
g_slice_free (Component, cmp); g_slice_free (Component, cmp);
g_atomic_int_inc (&n_components_destroyed);
nice_debug ("Destroyed NiceComponent (%u created, %u destroyed)",
n_components_created, n_components_destroyed);
} }
/* /*
......
...@@ -43,6 +43,11 @@ ...@@ -43,6 +43,11 @@
#include "stream.h" #include "stream.h"
/* Simple tracking for the number of alive streams. These must be accessed
* atomically. */
static volatile unsigned int n_streams_created = 0;
static volatile unsigned int n_streams_destroyed = 0;
/* /*
* @file stream.c * @file stream.c
* @brief ICE stream functionality * @brief ICE stream functionality
...@@ -54,6 +59,10 @@ stream_new (guint n_components, NiceAgent *agent) ...@@ -54,6 +59,10 @@ stream_new (guint n_components, NiceAgent *agent)
guint n; guint n;
Component *component; Component *component;
g_atomic_int_inc (&n_streams_created);
nice_debug ("Created NiceStream (%u created, %u destroyed)",
n_streams_created, n_streams_destroyed);
stream = g_slice_new0 (Stream); stream = g_slice_new0 (Stream);
for (n = 0; n < n_components; n++) { for (n = 0; n < n_components; n++) {
component = component_new (n + 1, agent, stream); component = component_new (n + 1, agent, stream);
...@@ -83,6 +92,10 @@ stream_free (Stream *stream) ...@@ -83,6 +92,10 @@ stream_free (Stream *stream)
g_free (stream->name); g_free (stream->name);
g_slist_free_full (stream->components, (GDestroyNotify) component_free); g_slist_free_full (stream->components, (GDestroyNotify) component_free);
g_slice_free (Stream, stream); g_slice_free (Stream, stream);
g_atomic_int_inc (&n_streams_destroyed);
nice_debug ("Destroyed NiceStream (%u created, %u destroyed)",
n_streams_created, n_streams_destroyed);
} }
Component * Component *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment