Commit 5c67198b authored by Benjamin Berg's avatar Benjamin Berg
Browse files

wfd: Unregister idle/timeout handlers on object destruction

Othwerise free'ed memory might be accessed.
parent 0b93d97d
......@@ -21,6 +21,7 @@ struct _WfdClient
GstRTSPClient parent_instance;
guint keep_alive_source_id;
guint idle_source_id;
WfdClientInitState init_state;
WfdParams *params;
......@@ -50,6 +51,28 @@ static const gchar * supported_rtsp_features[] = {
NULL
};
void
idle_handler_destroy (gpointer user_data)
{
WfdClient *self = WFD_CLIENT (user_data);
self->idle_source_id = 0;
}
static void
register_idle_handler (WfdClient *self, GSourceFunc callback)
{
if (self->idle_source_id)
{
g_warning ("WfdClient: Already have one idle handler scheduled, removing it");
g_source_remove (self->idle_source_id);
}
self->idle_source_id = g_idle_add_full (G_PRIORITY_DEFAULT,
callback,
self,
idle_handler_destroy);
}
WfdClient *
wfd_client_new (void)
{
......@@ -67,6 +90,10 @@ wfd_client_finalize (GObject *object)
g_source_remove (self->keep_alive_source_id);
self->keep_alive_source_id = 0;
if (self->idle_source_id)
g_source_remove (self->idle_source_id);
self->idle_source_id = 0;
G_OBJECT_CLASS (wfd_client_parent_class)->finalize (object);
}
......@@ -308,12 +335,12 @@ wfd_client_handle_response (GstRTSPClient * client, GstRTSPContext *ctx)
/* XXX: Pick the better profile if we have an encoder that supports it! */
wfd_client_select_codec_and_resolution (self, WFD_H264_PROFILE_BASE);
g_idle_add (wfd_client_idle_set_params, client);
register_idle_handler (self, wfd_client_idle_set_params);
break;
case INIT_STATE_M4_SOURCE_SET_PARAMS:
g_debug ("WfdClient: SET_PARAMS done");
g_idle_add (wfd_client_trigger_setup_idle, self);
register_idle_handler (self, wfd_client_trigger_setup_idle);
break;
case INIT_STATE_M5_SOURCE_TRIGGER_SETUP:
......
......@@ -96,15 +96,43 @@ timeout_query_wfd_support (gpointer user_data)
{
WfdClient *client = WFD_CLIENT (user_data);
g_object_set_data (G_OBJECT (client),
"wfd-query-support-timeout",
NULL);
wfd_client_query_support (client);
return G_SOURCE_REMOVE;
}
static void
wfd_server_client_closed (GstRTSPServer *server, GstRTSPClient *client)
{
guint query_support_id;
query_support_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (client),
"wfd-query-support-timeout"));
if (query_support_id)
g_source_remove (query_support_id);
}
static void
wfd_server_client_connected (GstRTSPServer *server, GstRTSPClient *client)
{
g_timeout_add (500, timeout_query_wfd_support, client);
guint query_support_id;
query_support_id = g_timeout_add (500, timeout_query_wfd_support, client);
g_object_set_data (G_OBJECT (client),
"wfd-query-support-timeout",
GUINT_TO_POINTER (query_support_id));
g_signal_connect_object (client,
"closed",
(GCallback) wfd_server_client_closed,
server,
G_CONNECT_SWAPPED);
}
static void
......
Supports Markdown
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