avrcp_disconnect(dev);
if (dev->sink && priv->sink_state != SINK_STATE_DISCONNECTED)
- sink_disconnect(dev->sink);
+ sink_disconnect(dev, TRUE);
else
priv->disconnecting = FALSE;
}
}
if (dev->sink && priv->sink_state != SINK_STATE_DISCONNECTED)
- sink_disconnect(dev->sink);
+ sink_disconnect(dev, TRUE);
else {
dbus_message_unref(priv->dc_req);
priv->dc_req = NULL;
return TRUE;
}
-gboolean sink_disconnect(struct sink *sink)
+int sink_disconnect(struct audio_device *dev, gboolean shutdown)
{
+ struct sink *sink = dev->sink;
+
if (!sink->session)
- return FALSE;
+ return -ENOTCONN;
- avdtp_set_device_disconnect(sink->session, TRUE);
+ if (shutdown)
+ avdtp_set_device_disconnect(sink->session, TRUE);
/* cancel pending connect */
if (sink->connect) {
avdtp_unref(sink->session);
sink->session = NULL;
- return TRUE;
+ return 0;
}
/* disconnect already ongoing */
if (sink->disconnect)
- return TRUE;
+ return -EBUSY;
if (!sink->stream)
- return FALSE;
-
- if (avdtp_close(sink->session, sink->stream, FALSE) < 0)
- return FALSE;
+ return -ENOTCONN;
- return TRUE;
+ return avdtp_close(sink->session, sink->stream, FALSE);
}
unsigned int sink_add_state_cb(sink_state_cb cb, void *user_data)
gboolean sink_new_stream(struct audio_device *dev, struct avdtp *session,
struct avdtp_stream *stream);
gboolean sink_setup_stream(struct sink *sink, struct avdtp *session);
-gboolean sink_disconnect(struct sink *sink);
+int sink_disconnect(struct audio_device *dev, gboolean shutdown);