diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index 58e1534..cf00400 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
gboolean reconfigure;
gboolean start;
GSList *cb;
+ GIOChannel *io;
int ref;
};
{
DBG("%p", s);
+ if (s->io) {
+ g_io_channel_shutdown(s->io, TRUE, NULL);
+ g_io_channel_unref(s->io);
+ }
+
setups = g_slist_remove(setups, s);
if (s->session)
avdtp_unref(s->session);
if (err) {
error("%s", err->message);
+ if (err)
goto drop;
}
g_io_channel_set_close_on_unref(io, FALSE);
+ g_io_channel_unref(setup->io);
+ setup->io = NULL;
+
setup_unref(setup);
return;
if (!setup || !setup->stream)
goto drop;
+ if (setup->io) {
+ error("transport channel already exists");
+ goto drop;
+ }
+
if (!bt_io_accept(io, transport_cb, setup, NULL, &err)) {
error("bt_io_accept: %s", err->message);
g_error_free(err);
goto drop;
}
+ /*
+ * Reference the channel so it can be shutdown properly
+ * stopping bt_io_accept from calling the callback with invalid
+ * setup pointer.
+ */
+ setup->io = g_io_channel_ref(io);
+
return;
}