Fix not aborting sink stream configuration on disconnect
If stream configuration is not complete it should be aborted so we can
proceed with disconnection process.
diff --git a/audio/sink.c b/audio/sink.c
index a9f6307..cb3ca74 100644
--- a/audio/sink.c
+++ b/audio/sink.c
@@ -351,6 +351,12 @@
struct pending_request *pending;
int id;
+ if (!sink->connect) {
+ avdtp_unref(sink->session);
+ sink->session = NULL;
+ return;
+ }
+
pending = sink->connect;
if (err) {
@@ -669,11 +675,31 @@
gboolean sink_shutdown(struct sink *sink)
{
- if (!sink->stream)
+ if (!sink->session)
return FALSE;
avdtp_set_device_disconnect(sink->session, TRUE);
+ /* cancel pending connect */
+ if (sink->connect) {
+ struct pending_request *pending = sink->connect;
+
+ if (pending->msg)
+ error_failed(pending->conn, pending->msg,
+ "Stream setup failed");
+ pending_request_free(sink->dev, pending);
+ sink->connect = NULL;
+
+ return TRUE;
+ }
+
+ /* disconnect already ongoing */
+ if (sink->disconnect)
+ return TRUE;
+
+ if (!sink->stream)
+ return FALSE;
+
if (avdtp_close(sink->session, sink->stream, FALSE) < 0)
return FALSE;