@@ -653,7 +653,12 @@ static void bap_io_close(struct bap_ep *ep)
DBG("ep %p", ep);
fd = g_io_channel_unix_get_fd(ep->io);
- close(fd);
+ if (bt_bap_stream_get_type(ep->stream) ==
+ BT_BAP_STREAM_TYPE_BCAST) {
+ shutdown(fd, SHUT_RDWR);
+ } else {
+ close(fd);
+ }
g_io_channel_unref(ep->io);
ep->io = NULL;
@@ -1176,6 +1181,10 @@ static void iso_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
fd = g_io_channel_unix_get_fd(chan);
if (bt_bap_stream_set_io(stream, fd)) {
+ if (bt_bap_stream_get_type(stream) ==
+ BT_BAP_STREAM_TYPE_BCAST) {
+ bt_bap_stream_streaming(stream);
+ }
g_io_channel_set_close_on_unref(chan, FALSE);
return;
}
@@ -1712,6 +1721,12 @@ static void bap_state(struct bt_bap_stream *stream, uint8_t old_state,
} else
queue_remove(data->streams, stream);
break;
+ case BT_BAP_STREAM_STATE_RELEASING:
+ if (bt_bap_stream_get_type(stream) ==
+ BT_BAP_STREAM_TYPE_BCAST) {
+ bap_io_close(ep);
+ }
+ break;
case BT_BAP_STREAM_STATE_CONFIG:
if (ep && !ep->id) {
bap_create_io(data, ep, stream, true);
@@ -1735,18 +1750,16 @@ static void bap_state(struct bt_bap_stream *stream, uint8_t old_state,
}
break;
case BT_BAP_STREAM_STATE_QOS:
- bap_create_io(data, ep, stream, true);
+ if (bt_bap_stream_get_type(stream) ==
+ BT_BAP_STREAM_TYPE_UCAST) {
+ bap_create_io(data, ep, stream, true);
+ }
break;
case BT_BAP_STREAM_STATE_ENABLING:
if (ep)
bap_create_io(data, ep, stream, false);
break;
case BT_BAP_STREAM_STATE_STREAMING:
- if (bt_bap_stream_get_type(stream) ==
- BT_BAP_STREAM_TYPE_BCAST) {
- if (ep)
- bap_create_io(data, ep, stream, false);
- }
break;
}
}
@@ -606,11 +606,38 @@ static DBusMessage *try_acquire(DBusConnection *conn, DBusMessage *msg,
return NULL;
}
+static void bap_stop_complete(struct bt_bap_stream *stream,
+ uint8_t code, uint8_t reason,
+ void *user_data)
+{
+ struct media_owner *owner = user_data;
+ struct media_request *req = owner->pending;
+ struct media_transport *transport = owner->transport;
+
+ /* Release always succeeds */
+ if (req) {
+ req->id = 0;
+ media_request_reply(req, 0);
+ media_owner_remove(owner);
+ }
+
+ transport_set_state(transport, TRANSPORT_STATE_IDLE);
+ media_transport_remove_owner(transport);
+}
+
+static void bap_disable_complete(struct bt_bap_stream *stream,
+ uint8_t code, uint8_t reason,
+ void *user_data)
+{
+ bap_stop_complete(stream, code, reason, user_data);
+}
+
static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
void *data)
{
struct media_transport *transport = data;
struct media_owner *owner = transport->owner;
+ struct bap_transport *bap = transport->data;
const char *sender;
struct media_request *req;
guint id;
@@ -642,6 +669,11 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
req = media_request_create(msg, id);
media_owner_add(owner, req);
+ if (bt_bap_stream_get_type(bap->stream) ==
+ BT_BAP_STREAM_TYPE_BCAST) {
+ bap_disable_complete(bap->stream, 0x00, 0x00, owner);
+ }
+
return NULL;
}
@@ -1631,32 +1663,6 @@ static guint resume_bap(struct media_transport *transport,
return id;
}
-static void bap_stop_complete(struct bt_bap_stream *stream,
- uint8_t code, uint8_t reason,
- void *user_data)
-{
- struct media_owner *owner = user_data;
- struct media_request *req = owner->pending;
- struct media_transport *transport = owner->transport;
-
- /* Release always succeeds */
- if (req) {
- req->id = 0;
- media_request_reply(req, 0);
- media_owner_remove(owner);
- }
-
- transport_set_state(transport, TRANSPORT_STATE_IDLE);
- media_transport_remove_owner(transport);
-}
-
-static void bap_disable_complete(struct bt_bap_stream *stream,
- uint8_t code, uint8_t reason,
- void *user_data)
-{
- bap_stop_complete(stream, code, reason, user_data);
-}
-
static guint suspend_bap(struct media_transport *transport,
struct media_owner *owner)
{
@@ -1763,6 +1769,10 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state,
if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE)
bap_update_bcast_qos(transport);
break;
+ case BT_BAP_STREAM_STATE_RELEASING:
+ if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SINK)
+ return;
+ break;
}
io = bt_bap_stream_get_io(stream);