mbox series

[BlueZ,00/14] Add Scan Delegator support for Add Source op

Message ID 20240821145602.92083-1-iulia.tanasescu@nxp.com
Headers show
Series Add Scan Delegator support for Add Source op | expand

Message

Iulia Tanasescu Aug. 21, 2024, 2:55 p.m. UTC
This adds support for the BAP Scan Delegator role to handle the
Add Source command received from a Broadcast Assistant.

The Broadcast Assistant informs a Scan Delegator about a Broadcaster
by sending a GATT write command for the BASS Broadcast Audio Scan
Control Point characteristic with the "Add Source" opcode. Using
the parameters received through GATT, the Scan Delegator creates
a device for the Broadcaster and adds the BCAA service UUID, so the
device will be probed by BAP as if the Delegator scanned the Broadcaster
autonomously. The BAP plugin will then perform PA sync and it will
create streams for each BIS required by the Assistant. The transports
can then be acquired/released, and the Assistant will be notified
about each change in the state of the streams.

The bluetoothctl and btmon logs below show an example of this scenario:

client/bluetoothctl
[bluetooth]# endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06
[/local/endpoint/ep0] Auto Accept (yes/no): y
[/local/endpoint/ep0] Max Transports (auto/value): a
[/local/endpoint/ep0] Locations: 1
[/local/endpoint/ep0] Supported Context (value): 1
[bluetooth]# Endpoint /local/endpoint/ep0 registered
[bluetooth]# advertise on
[bluetooth]# [NEW] Device 00:60:37:31:7E:3F 00-60-37-31-7E-3F
[00-60-37-31-7E-3F]# [NEW] Device 03:E2:C0:11:57:DA 03-E2-C0-11-57-DA
[00-60-37-31-7E-3F]# [NEW] Transport
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0
[00-60-37-31-7E-3F]# Endpoint: SetConfiguration
[00-60-37-31-7E-3F]# Transport
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0
[00-60-37-31-7E-3F]# Properties.Device:
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA
[00-60-37-31-7E-3F]# Auto Accepting...
[00-60-37-31-7E-3F]# transport.select
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0
[00-60-37-31-7E-3F]# [CHG] Transport
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 State: broadcasting
[00-60-37-31-7E-3F]# transport.acquire
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0
auto acquiring...
Transport /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 acquiring
[00-60-37-31-7E-3F]# Transport
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 acquiring complete
[00-60-37-31-7E-3F]# Acquire successful: fd 8 MTU 40:0
[00-60-37-31-7E-3F]# [CHG] Transport
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 State: active
[00-60-37-31-7E-3F]# transport.release
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0
[00-60-37-31-7E-3F]# Transport fd disconnected
[00-60-37-31-7E-3F]# [CHG] Transport
    /org/bluez/hci1/dev_03_E2_C0_11_57_DA/bis1/fd0 State: idle
[00-60-37-31-7E-3F]# Release successful

> ACL Data RX: Handle 0 flags 0x01 dlen 1
      ATT: Write Command (0x52) len 23
        Handle: 0x0040 Type: Broadcast Audio Scan Control Point (0x2bc7)
          Data[21]: 0201da5711c0e203001a2d5602ffff010100000000
            Opcode: Add Source (0x02)
            Source_Address_Type: 1
            Source_Address: 03:E2:C0:11:57:DA
            Source_Adv_SID: 0
            Broadcast_ID: 0x562d1a
            PA_Sync_State: Synchronize to PA - PAST not available
            PA_Interval: 0xffff
            Num_Subgroups: 1
            Subgroup #0:
              BIS_Sync State: 0x00000001
< HCI Command: LE Periodic Advertising Create Sync (0x08|0x0044)
        Options: 0x0000
        Use advertising SID, Advertiser Address Type and address
        Reporting initially enabled
        SID: 0x00
        Adv address type: Random (0x01)
        Adv address: 03:E2:C0:11:57:DA (Non-Resolvable)
        Skip: 0x0000
        Sync timeout: 20000 msec (0x07d0)
        Sync CTE type: 0x0000
> HCI Event: Command Status (0x0f) plen 4
      LE Periodic Advertising Create Sync (0x08|0x0044) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 16
      LE Periodic Advertising Sync Established (0x0e)
        Status: Success (0x00)
        Sync handle: 0
        Advertising SID: 0x00
        Advertiser address type: Random (0x01)
        Advertiser address: 03:E2:C0:11:57:DA (Non-Resolvable)
        Advertiser PHY: LE 2M (0x02)
        Periodic advertising interval: 10.00 msec (0x0008)
        Advertiser clock accuracy: 0x07
> HCI Event: LE Meta Event (0x3e) plen 42
      LE Periodic Advertising Report (0x0f)
        Sync handle: 0
        TX power: 127 dbm (0x7f)
        RSSI: -64 dBm (0xc0)
        CTE Type: No Constant Tone Extension (0xff)
        Data status: Complete
        Data length: 0x22
        Service Data: Basic Audio Announcement (0x1851)
          Presetation Delay: 40000
          Number of Subgroups: 1
            Subgroup #0:
            Number of BIS(s): 1
            Codec: LC3 (0x06)
            Codec Specific Configuration: #0: len 0x02 type 0x01
            Codec Specific Configuration: Sampling Frequency: 16 Khz
            Codec Specific Configuration: #1: len 0x02 type 0x02
            Codec Specific Configuration: Frame Duration: 10 ms (0x01)
            Codec Specific Configuration: #2: len 0x03 type 0x04
            Codec Specific Configuration: Frame Length: 40 (0x0028)
            Codec Specific Configuration: #3: len 0x05 type 0x03
            Codec Specific Configuration: Location: 0x00000001
            Codec Specific Configuration: Location: Front Left
              BIS #0:
              Index: 1
> HCI Event: LE Meta Event (0x3e) plen 20
      LE Broadcast Isochronous Group Info Advertising Report (0x22)
        Sync Handle: 0x0000
        Number BIS: 1
        NSE: 3
        ISO Interval: 10.00 msec (0x0008)
        BN: 1
        PTO: 1
        IRC: 3
        Maximum PDU: 40
        SDU Interval: 10000 us (0x002710)
        Maximum SDU: 40
        PHY: LE 2M (0x02)
        Framing: Unframed (0x00)
        Encryption: 0x00
bluetoothd[4636]: < ACL Data TX: Handle 0 flags 0x00 dlen 29
      ATT: Handle Multiple Value Notification (0x23) len 24
        Length: 0x0014
        Handle: 0x003a Type: Broadcast Receive State (0x2bc8)
          Data[20]: 0101da5711c0e203001a2d560200010000000000
          Source_ID: 1
          Source_Address_Type: 1
          Source_Address: 03:E2:C0:11:57:DA
          Source_Adv_SID: 0
          Broadcast_ID: 0x562d1a
          PA_Sync_State: Synchronized to PA
          BIG_Encryption: Not encrypted
          Num_Subgroups: 1
          Subgroup #0:
            BIS_Sync State: 0x00000000
< HCI Command: LE Broadcast Isochronous Group Create Sync (0x08|0x006b)
        BIG Handle: 0x00
        BIG Sync Handle: 0x0000
        Encryption: Unencrypted (0x00)
        Broadcast Code[16]: 00000000000000000000000000000000
        Maximum Number Subevents: 0x00
        Timeout: 20000 ms (0x07d0)
        Number of BIS: 1
        BIS ID: 0x01
> HCI Event: Command Status (0x0f) plen 4
      LE Broadcast Isochronous Group Create Sync (0x08|0x006b) ncmd 1
        Status: Success (0x00
> HCI Event: LE Meta Event (0x3e) plen 17
      LE Broadcast Isochronous Group Sync Estabilished (0x1d)
        Status: Success (0x00)
        BIG Handle: 0x00
        Transport Latency: 912 us (0x000390)
        NSE: 3
        BN: 1
        PTO: 1
        IRC: 3
        Maximum PDU: 40
        ISO Interval: 10.00 msec (0x0008)
        Connection Handle #0: 10
< HCI Command: LE Setup Isochronous Data Path (0x08|0x006e) plen 13
        Handle: 10
        Data Path Direction: Output (Controller to Host) (0x01)
        Data Path: HCI (0x00)
        Coding Format: Transparent (0x03)
        Company Codec ID: Ericsson Technology Licensing (0)
        Vendor Codec ID: 0
        Controller Delay: 0 us (0x000000)
        Codec Configuration Length: 0
        Codec Configuration[0]:
> HCI Event: Command Complete (0x0e) plen 6
      LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1
        Status: Success (0x00)
        Handle: 10
bluetoothd[4636]: < ACL Data TX: Handle 0 flags 0x00 dlen 29
      ATT: Handle Multiple Value Notification (0x23) len 24
        Length: 0x0014
        Handle: 0x003a Type: Broadcast Receive State (0x2bc8)
          Data[20]: 0101da5711c0e203001a2d560200010100000000
          Source_ID: 1
          Source_Address_Type: 1
          Source_Address: 03:E2:C0:11:57:DA
          Source_Adv_SID: 0
          Broadcast_ID: 0x562d1a
          PA_Sync_State: Synchronized to PA
          BIG_Encryption: Not encrypted
          Num_Subgroups: 1
          Subgroup #0:
            BIS_Sync State: 0x00000001
bluetoothd[4636]: < ACL Data TX: Handle 0 flags 0x00 dlen 29
      ATT: Handle Multiple Value Notification (0x23) len 24
        Length: 0x0014
        Handle: 0x003a Type: Broadcast Receive State (0x2bc8)
          Data[20]: 0101da5711c0e203001a2d560200010000000000
          Source_ID: 1
          Source_Address_Type: 1
          Source_Address: 03:E2:C0:11:57:DA
          Source_Adv_SID: 0
          Broadcast_ID: 0x562d1a
          PA_Sync_State: Synchronized to PA
          BIG_Encryption: Not encrypted
          Num_Subgroups: 1
          Subgroup #0:
            BIS_Sync State: 0x00000000
< HCI Command: LE Broadcast Isochronous Group Terminate Sync (0x08|0x006c)
        BIG Handle: 0x00
> HCI Event: Command Complete (0x0e) plen 5
      LE Broadcast Isochronous Group Terminate Sync (0x08|0x006c) ncmd 1
        Status: Success (0x00)

Iulia Tanasescu (14):
  shared/bass: Register ATT disconnect cb
  shared/bass: Make bt_bcast_src private
  shared/bass: Remove io handling
  shared/bass: Add support to register cp handlers
  shared/bass: Call cp handler for the Add Source op
  bass: Register cp handler for Add Source cmd
  shared/bass: Add API to set PA sync state
  bass: Add APIs to probe/remove Broadcasters
  bap: Probe Broadcasters with BASS
  shared/bass: Add APIs to set/clear BIS sync bits
  bass: Register BAP state changed cb
  shared/bass: Add API to check BIS required for sync
  bass: Add API to check BIS required for sync
  bap: Create streams for required BISes

 profiles/audio/bap.c  | 137 +++++++---
 profiles/audio/bass.c | 204 +++++++++++++++
 profiles/audio/bass.h |   5 +
 src/shared/bass.c     | 587 +++++++++++++++++++-----------------------
 src/shared/bass.h     |  43 +---
 5 files changed, 594 insertions(+), 382 deletions(-)


base-commit: 2f3f63467d72a19b4414907a1ce5dbb870e4e2f2

Comments

Luiz Augusto von Dentz Aug. 21, 2024, 3:01 p.m. UTC | #1
Hi Iulia,

On Wed, Aug 21, 2024 at 10:56 AM Iulia Tanasescu
<iulia.tanasescu@nxp.com> wrote:
>
> IO procedures should not be handled inside src/shared. The BASS plugin
> should be the one to handle socket operations. This removes IO handling
> from shared/bass.

I'd change this description to say it is the connection procedure that
shall not be handled within shared helpers since that would prevent
unit testing with use of socketpair.

> ---
>  src/shared/bass.c | 312 +---------------------------------------------
>  1 file changed, 2 insertions(+), 310 deletions(-)
>
> diff --git a/src/shared/bass.c b/src/shared/bass.c
> index ce13f2c24..636eb24fd 100644
> --- a/src/shared/bass.c
> +++ b/src/shared/bass.c
> @@ -14,13 +14,9 @@
>  #include <stdbool.h>
>  #include <unistd.h>
>  #include <errno.h>
> -#include <poll.h>
>
>  #include "lib/bluetooth.h"
>  #include "lib/uuid.h"
> -#include "lib/iso.h"
> -
> -#include "btio/btio.h"
>
>  #include "src/shared/queue.h"
>  #include "src/shared/util.h"
> @@ -29,8 +25,6 @@
>  #include "src/shared/gatt-client.h"
>  #include "src/shared/bass.h"
>
> -#define MAX_BIS_BITMASK_IDX            31
> -
>  #define DBG(_bass, fmt, arg...) \
>         bass_debug(_bass, "%s:%s() " fmt, __FILE__, __func__, ## arg)
>
> @@ -119,35 +113,6 @@ static struct queue *bass_db;
>  static struct queue *bass_cbs;
>  static struct queue *sessions;
>
> -#define DEFAULT_IO_QOS \
> -{ \
> -       .interval       = 10000, \
> -       .latency        = 10, \
> -       .sdu            = 40, \
> -       .phy            = 0x02, \
> -       .rtn            = 2, \
> -}
> -
> -static struct bt_iso_qos default_qos = {
> -       .bcast = {
> -               .big                    = BT_ISO_QOS_BIG_UNSET,
> -               .bis                    = BT_ISO_QOS_BIS_UNSET,
> -               .sync_factor            = 0x07,
> -               .packing                = 0x00,
> -               .framing                = 0x00,
> -               .in                     = DEFAULT_IO_QOS,
> -               .out                    = DEFAULT_IO_QOS,
> -               .encryption             = 0x00,
> -               .bcode                  = {0x00},
> -               .options                = 0x00,
> -               .skip                   = 0x0000,
> -               .sync_timeout           = BT_ISO_SYNC_TIMEOUT,
> -               .sync_cte_type          = 0x00,
> -               .mse                    = 0x00,
> -               .timeout                = BT_ISO_SYNC_TIMEOUT,
> -       }
> -};
> -
>  struct bt_bass_src_changed {
>         unsigned int id;
>         bt_bass_src_func_t cb;
> @@ -643,115 +608,6 @@ static bool bass_src_attr_match(const void *data, const void *match_data)
>         return (bcast_src->attr == attr);
>  }
>
> -static gboolean check_io_err(GIOChannel *io)
> -{
> -       struct pollfd fds;
> -
> -       memset(&fds, 0, sizeof(fds));
> -       fds.fd = g_io_channel_unix_get_fd(io);
> -       fds.events = POLLERR;
> -
> -       if (poll(&fds, 1, 0) > 0 && (fds.revents & POLLERR))
> -               return TRUE;
> -
> -       return FALSE;
> -}
> -
> -static void bass_bis_unref(void *data)
> -{
> -       GIOChannel *io = data;
> -
> -       g_io_channel_unref(io);
> -}
> -
> -static void connect_cb(GIOChannel *io, GError *gerr,
> -                               gpointer user_data)
> -{
> -       struct bt_bcast_src *bcast_src = user_data;
> -       struct iovec *notif;
> -       int bis_idx;
> -       int i;
> -
> -       /* Keep io reference */
> -       g_io_channel_ref(io);
> -       queue_push_tail(bcast_src->bises, io);
> -
> -       for (i = 0; i < bcast_src->num_subgroups; i++) {
> -               struct bt_bass_subgroup_data *data =
> -                               &bcast_src->subgroup_data[i];
> -
> -               for (bis_idx = 0; bis_idx < MAX_BIS_BITMASK_IDX; bis_idx++) {
> -                       if (data->pending_bis_sync & (1 << bis_idx)) {
> -                               data->bis_sync |= (1 << bis_idx);
> -                               data->pending_bis_sync &= ~(1 << bis_idx);
> -                               break;
> -                       }
> -               }
> -
> -               if (bis_idx < MAX_BIS_BITMASK_IDX)
> -                       break;
> -       }
> -
> -       for (i = 0; i < bcast_src->num_subgroups; i++) {
> -               if (bcast_src->subgroup_data[i].pending_bis_sync)
> -                       break;
> -       }
> -
> -       /* If there are still pending bises, wait for their
> -        * notifications also before sending notification to
> -        * client
> -        */
> -       if (i != bcast_src->num_subgroups)
> -               return;
> -
> -       /* All connections have been notified */
> -       if (check_io_err(io)) {
> -               DBG(bcast_src->bass, "BIG sync failed");
> -
> -               /* Close all connected bises */
> -               queue_destroy(bcast_src->bises, bass_bis_unref);
> -               bcast_src->bises = NULL;
> -
> -               /* Close listen io */
> -               g_io_channel_shutdown(bcast_src->listen_io, TRUE, NULL);
> -               g_io_channel_unref(bcast_src->listen_io);
> -               bcast_src->listen_io = NULL;
> -
> -               /* Close pa sync io */
> -               if (bcast_src->pa_sync_io) {
> -                       g_io_channel_shutdown(bcast_src->pa_sync_io,
> -                                       TRUE, NULL);
> -                       g_io_channel_unref(bcast_src->pa_sync_io);
> -                       bcast_src->pa_sync_io = NULL;
> -               }
> -
> -               for (i = 0; i < bcast_src->num_subgroups; i++)
> -                       bcast_src->subgroup_data[i].bis_sync =
> -                               BT_BASS_BIG_SYNC_FAILED_BITMASK;
> -
> -               /* If BIG sync failed because of an incorrect broadcast code,
> -                * inform client
> -                */
> -               if (bcast_src->enc == BT_BASS_BIG_ENC_STATE_BCODE_REQ)
> -                       bcast_src->enc = BT_BASS_BIG_ENC_STATE_BAD_CODE;
> -       } else {
> -               if (bcast_src->enc == BT_BASS_BIG_ENC_STATE_BCODE_REQ)
> -                       bcast_src->enc = BT_BASS_BIG_ENC_STATE_DEC;
> -       }
> -
> -       /* Send notification to client */
> -       notif = bass_parse_bcast_src(bcast_src);
> -       if (!notif)
> -               return;
> -
> -       gatt_db_attribute_notify(bcast_src->attr,
> -                                       notif->iov_base, notif->iov_len,
> -                                       bt_bass_get_att(bcast_src->bass));
> -
> -       free(notif->iov_base);
> -       free(notif);
> -}
> -
>  static bool bass_trigger_big_sync(struct bt_bcast_src *bcast_src)
>  {
>         for (int i = 0; i < bcast_src->num_subgroups; i++) {
> @@ -766,73 +622,6 @@ static bool bass_trigger_big_sync(struct bt_bcast_src *bcast_src)
>         return false;
>  }
>
> -
> -static void confirm_cb(GIOChannel *io, gpointer user_data)
> -{
> -       struct bt_bcast_src *bcast_src = user_data;
> -       int sk, err;
> -       socklen_t len;
> -       struct bt_iso_qos qos;
> -       struct iovec *notif;
> -       GError *gerr = NULL;
> -
> -       if (check_io_err(io)) {
> -               DBG(bcast_src->bass, "PA sync failed");
> -
> -               /* Mark PA sync as failed and notify client */
> -               bcast_src->sync_state = BT_BASS_FAILED_TO_SYNCHRONIZE_TO_PA;
> -               goto notify;
> -       }
> -
> -       bcast_src->sync_state = BT_BASS_SYNCHRONIZED_TO_PA;
> -       bcast_src->pa_sync_io = io;
> -       g_io_channel_ref(bcast_src->pa_sync_io);
> -
> -       len = sizeof(qos);
> -       memset(&qos, 0, len);
> -
> -       sk = g_io_channel_unix_get_fd(io);
> -
> -       err = getsockopt(sk, SOL_BLUETOOTH, BT_ISO_QOS, &qos, &len);
> -       if (err < 0) {
> -               DBG(bcast_src->bass, "Failed to get iso qos");
> -               return;
> -       }
> -
> -       if (!qos.bcast.encryption) {
> -               /* BIG is not encrypted. Try to synchronize */
> -               bcast_src->enc = BT_BASS_BIG_ENC_STATE_NO_ENC;
> -
> -               if (bass_trigger_big_sync(bcast_src)) {
> -                       if (!bt_io_bcast_accept(bcast_src->pa_sync_io,
> -                               connect_cb, bcast_src, NULL, &gerr,
> -                               BT_IO_OPT_INVALID)) {
> -                               DBG(bcast_src->bass, "bt_io_bcast_accept: %s",
> -                               gerr->message);
> -                               g_error_free(gerr);
> -                       }
> -                       return;
> -               }
> -
> -               goto notify;
> -       }
> -
> -       /* BIG is encrypted. Wait for Client to provide the Broadcast_Code */
> -       bcast_src->enc = BT_BASS_BIG_ENC_STATE_BCODE_REQ;
> -
> -notify:
> -       notif = bass_parse_bcast_src(bcast_src);
> -       if (!notif)
> -               return;
> -
> -       gatt_db_attribute_notify(bcast_src->attr,
> -                                       notif->iov_base, notif->iov_len,
> -                                       bt_bass_get_att(bcast_src->bass));
> -
> -       free(notif->iov_base);
> -       free(notif);
> -}
> -
>  static struct bt_bass *bass_get_session(struct bt_att *att, struct gatt_db *db,
>                 const bdaddr_t *adapter_bdaddr)
>  {
> @@ -919,13 +708,7 @@ static void bass_handle_add_src_op(struct bt_bass *bass,
>         uint8_t src_id = 0;
>         struct gatt_db_attribute *attr;
>         uint8_t pa_sync;
> -       GIOChannel *io;
> -       GError *err = NULL;
> -       struct bt_iso_qos iso_qos = default_qos;
> -       uint8_t num_bis = 0;
> -       uint8_t bis[ISO_MAX_NUM_BIS];
>         struct iovec *notif;
> -       uint8_t addr_type;
>
>         gatt_db_attribute_write_result(attrib, id, 0x00);
>
> @@ -942,8 +725,6 @@ static void bass_handle_add_src_op(struct bt_bass *bass,
>
>         queue_push_tail(bass->ldb->bcast_srcs, bcast_src);
>
> -       memset(bis, 0, ISO_MAX_NUM_BIS);
> -
>         bcast_src->bass = bass;
>
>         /* Map the source to a Broadcast Receive State characteristic */
> @@ -1025,18 +806,6 @@ static void bass_handle_add_src_op(struct bt_bass *bass,
>
>                 util_iov_pull_le32(iov, &data->pending_bis_sync);
>
> -               if (data->pending_bis_sync != BIS_SYNC_NO_PREF)
> -                       /* Iterate through the bis sync bitmask written
> -                        * by the client and store the bis indexes that
> -                        * the BASS server will try to synchronize to
> -                        */
> -                       for (int bis_idx = 0; bis_idx < 31; bis_idx++) {
> -                               if (data->pending_bis_sync & (1 << bis_idx)) {
> -                                       bis[num_bis] = bis_idx + 1;
> -                                       num_bis++;
> -                               }
> -                       }
> -
>                 data->meta_len = *(uint8_t *)util_iov_pull_mem(iov,
>                                                 sizeof(data->meta_len));
>                 if (!data->meta_len)
> @@ -1051,38 +820,7 @@ static void bass_handle_add_src_op(struct bt_bass *bass,
>         }
>
>         if (pa_sync != PA_SYNC_NO_SYNC) {
> -               /* Convert to three-value type */
> -               if (bcast_src->addr_type)
> -                       addr_type = BDADDR_LE_RANDOM;
> -               else
> -                       addr_type = BDADDR_LE_PUBLIC;
> -
> -               /* If requested by client, try to synchronize to the source */
> -               io = bt_io_listen(NULL, confirm_cb, bcast_src, NULL, &err,
> -                                       BT_IO_OPT_SOURCE_BDADDR,
> -                                       &bass->ldb->adapter_bdaddr,
> -                                       BT_IO_OPT_DEST_BDADDR,
> -                                       &bcast_src->addr,
> -                                       BT_IO_OPT_DEST_TYPE,
> -                                       addr_type,
> -                                       BT_IO_OPT_MODE, BT_IO_MODE_ISO,
> -                                       BT_IO_OPT_QOS, &iso_qos,
> -                                       BT_IO_OPT_ISO_BC_SID, bcast_src->sid,
> -                                       BT_IO_OPT_ISO_BC_NUM_BIS, num_bis,
> -                                       BT_IO_OPT_ISO_BC_BIS, bis,
> -                                       BT_IO_OPT_INVALID);
> -
> -               if (!io) {
> -                       DBG(bass, "%s", err->message);
> -                       g_error_free(err);
> -                       goto err;
> -               }
> -
> -               bcast_src->listen_io = io;
> -               g_io_channel_ref(bcast_src->listen_io);
> -
> -               if (num_bis > 0 && !bcast_src->bises)
> -                       bcast_src->bises = queue_new();
> +               /* TODO: call BASS plugin callback to establish PA/BIG sync */
>         } else {
>                 for (int i = 0; i < bcast_src->num_subgroups; i++)
>                         bcast_src->subgroup_data[i].bis_sync =
> @@ -1122,10 +860,6 @@ static void bass_handle_set_bcast_code_op(struct bt_bass *bass,
>  {
>         struct bt_bass_set_bcast_code_params *params;
>         struct bt_bcast_src *bcast_src;
> -       int sk, err;
> -       socklen_t len;
> -       struct bt_iso_qos qos;
> -       GError *gerr = NULL;
>         struct iovec *notif;
>
>         /* Get Set Broadcast Code command parameters */
> @@ -1161,37 +895,7 @@ static void bass_handle_set_bcast_code_op(struct bt_bass *bass,
>                 return;
>         }
>
> -       /* Try to sync to the source using the
> -        * received broadcast code
> -        */
> -       len = sizeof(qos);
> -       memset(&qos, 0, len);
> -
> -       if (!bcast_src->pa_sync_io)
> -               return;
> -
> -       sk = g_io_channel_unix_get_fd(bcast_src->pa_sync_io);
> -
> -       err = getsockopt(sk, SOL_BLUETOOTH, BT_ISO_QOS, &qos, &len);
> -       if (err < 0) {
> -               DBG(bcast_src->bass, "Failed to get iso qos");
> -               return;
> -       }
> -
> -       /* Update socket QoS with Broadcast Code */
> -       memcpy(qos.bcast.bcode, params->bcast_code, BT_BASS_BCAST_CODE_SIZE);
> -
> -       if (setsockopt(sk, SOL_BLUETOOTH, BT_ISO_QOS, &qos,
> -                               sizeof(qos)) < 0) {
> -               DBG(bcast_src->bass, "Failed to set iso qos");
> -               return;
> -       }
> -
> -       if (!bt_io_bcast_accept(bcast_src->pa_sync_io, connect_cb,
> -               bcast_src, NULL, &gerr,  BT_IO_OPT_INVALID)) {
> -               DBG(bcast_src->bass, "bt_io_bcast_accept: %s", gerr->message);
> -               g_error_free(gerr);
> -       }
> +       /* TODO: Call BASS plugin callback to sync with required BIS */
>  }
>
>  #define BASS_OP(_str, _op, _size, _func) \
> @@ -1375,18 +1079,6 @@ static void bass_bcast_src_free(void *data)
>
>         free(bcast_src->subgroup_data);
>
> -       if (bcast_src->listen_io) {
> -               g_io_channel_shutdown(bcast_src->listen_io, TRUE, NULL);
> -               g_io_channel_unref(bcast_src->listen_io);
> -       }
> -
> -       if (bcast_src->pa_sync_io) {
> -               g_io_channel_shutdown(bcast_src->pa_sync_io, TRUE, NULL);
> -               g_io_channel_unref(bcast_src->pa_sync_io);
> -       }
> -
> -       queue_destroy(bcast_src->bises, bass_bis_unref);
> -
>         free(bcast_src);
>  }
>
> --
> 2.39.2
>