diff --git a/audio/avdtp.c b/audio/avdtp.c
index 83b1aa2..23281ac 100644
--- a/audio/avdtp.c
+++ b/audio/avdtp.c
old_state = sep->state;
sep->state = state;
- for (l = stream->callbacks; l != NULL; l = g_slist_next(l)) {
- struct stream_callback *cb = l->data;
- cb->cb(stream, old_state, state, err_ptr, cb->user_data);
- }
-
switch (state) {
case AVDTP_STATE_CONFIGURED:
if (sep->info.type == AVDTP_SEP_TYPE_SINK)
handle_unanswered_req(session, stream);
/* Remove pending commands for this stream from the queue */
cleanup_queue(session, stream);
- stream_free(stream);
break;
default:
break;
}
+
+ for (l = stream->callbacks; l != NULL; l = g_slist_next(l)) {
+ struct stream_callback *cb = l->data;
+ cb->cb(stream, old_state, state, err_ptr, cb->user_data);
+ }
+
+ if (state == AVDTP_STATE_IDLE)
+ stream_free(stream);
}
static void finalize_discovery(struct avdtp *session, int err)
diff --git a/audio/transport.c b/audio/transport.c
index 8ff6c85..aa3308d 100644
--- a/audio/transport.c
+++ b/audio/transport.c
return TRUE;
}
-static gboolean remove_owner(gpointer data)
-{
- struct media_owner *owner = data;
-
- media_transport_remove(owner->transport, owner);
-
- return FALSE;
-}
-
static void a2dp_resume_complete(struct avdtp *session,
struct avdtp_error *err, void *user_data)
{
return;
fail:
- /* Let the stream state change before removing the owner */
- g_idle_add(remove_owner, owner);
+ media_transport_remove(transport, owner);
}
static guint resume_a2dp(struct media_transport *transport,