diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index edefedc..8162417 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
return NULL;
}
+static void endpoint_remove_transport(struct media_endpoint *endpoint,
+ struct media_transport *transport)
+{
+ if (!endpoint || !transport)
+ return;
+
+ endpoint->transports = g_slist_remove(endpoint->transports, transport);
+ media_transport_destroy(transport);
+}
+
static void clear_configuration(struct media_endpoint *endpoint,
struct media_transport *transport)
{
DBUS_TYPE_INVALID);
g_dbus_send_message(btd_get_dbus_connection(), msg);
done:
- endpoint->transports = g_slist_remove(endpoint->transports, transport);
- media_transport_destroy(transport);
+ endpoint_remove_transport(endpoint, transport);
}
static void clear_endpoint(struct media_endpoint *endpoint)
if (dbus_message_is_method_call(request->msg,
MEDIA_ENDPOINT_INTERFACE,
- "SetConfiguration")) {
- if (request->transport == NULL)
- error("Expected to destroy transport");
- else
- media_transport_destroy(request->transport);
- }
+ "SetConfiguration"))
+ endpoint_remove_transport(endpoint, request->transport);
dbus_error_free(&err);
goto done;