broadcast_sink and broadcast_source simultaneously.

hi:

I am use broadcast_sink and broadcast_source of nrf5340_audio simultaneously.
use a button to switch source or sink. i am use NCS v2.6.2
if switch to sink mode is show below.
<wrn> broadcast_sink: Unable to sync to broadcast source, ret: -12

it can help me or support sample code.

                                                     thank

////////////////////////////////////////////////////////////////

HL [00:00:12.831,207] <dbg> broadcast_sink: base_recv_cb: Subgroup: 0 BIS: 0 index = 1
HL [00:00:12.831,237] <dbg> broadcast_sink: get_codec_info: Retrieve the codec configuration for LC3
HL [00:00:12.831,237] <dbg> broadcast_sink: base_recv_cb: Stream 0 in subgroup 0 from broadcast sink
HL [00:00:12.831,268] <dbg> broadcast_sink: base_recv_cb: Subgroup: 0 BIS: 1 index = 2
HL [00:00:12.831,268] <dbg> broadcast_sink: get_codec_info: Retrieve the codec configuration for LC3
HL [00:00:12.831,298] <dbg> broadcast_sink: base_recv_cb: Stream 1 in subgroup 0 from broadcast sink
HL [00:00:12.831,359] <dbg> broadcast_sink: base_recv_cb: Channel HL active
HL [00:00:12.831,359] <dbg> broadcast_sink: base_recv_cb: Waiting for syncable
HL [00:00:12.831,451] <dbg> broadcast_sink: syncable_cb: Broadcast sink is syncable
HL [00:00:12.831,451] <inf> broadcast_sink: Syncing to broadcast stream index 0

HL [00:00:12.831,481] <wrn> broadcast_sink: Unable to sync to broadcast source, ret: -12

HL [00:00:12.831,573] <inf> main: Presentation delay 20000 us is set
HL [00:00:13.231,201] <dbg> broadcast_sink: base_recv_cb: Received BASE with 1 subgroup(s) from broadcast sink


int main(void)
{
LOG_DBG("nRF5340 BPT APP core started");

ret = nrf5340_audio_dk_init();
ERR_CHK(ret);

ret = nrf5340_audio_common_init();
ERR_CHK(ret);

ret = zbus_subscribers_create();
ERR_CHK_MSG(ret, "Failed to create zbus subscriber threads");

ret = zbus_link_producers_observers();
ERR_CHK_MSG(ret, "Failed to link zbus producers and observers");

ret = broadcast_source_enable();
ERR_CHK_MSG(ret, "Failed to enable broadcaster");

ret = audio_system_config_set(
bt_audio_codec_cfg_freq_to_freq_hz(CONFIG_BT_AUDIO_PREF_SAMPLE_RATE_VALUE),
CONFIG_BT_AUDIO_BITRATE_BROADCAST_SRC, VALUE_NOT_SET);
ERR_CHK_MSG(ret, "Failed to set sample- and bitrate");

broadcast_source_adv_get(&ext_adv, &ext_adv_size, &per_adv, &per_adv_size);

ret = bt_mgmt_adv_start(ext_adv, ext_adv_size, per_adv, per_adv_size, false);
ERR_CHK_MSG(ret, "Failed to start advertiser");

ret = le_audio_rx_init();
ERR_CHK_MSG(ret, "Failed to initialize rx path");
}


case BUTTON_5:

bt_le_ext_adv_stop(ext_adv);

broadcast_source_stop();

k_msleep(100);

ret = broadcast_sink_enable(le_audio_rx_data_handler);

ret = bt_mgmt_scan_start(0, 0, BT_MGMT_SCAN_TYPE_BROADCAST,
CONFIG_BT_AUDIO_BROADCAST_NAME,
BRDCAST_ID_NOT_USED);

  • 1.

    ep = broadcast_sink_new_ep(sink->index);
        if (ep == NULL) {
            LOG_DBG("Could not allocate new broadcast endpoint");
            return -ENOMEM;
        }

        iso = bt_bap_iso_new();
        if (iso == NULL) {
            LOG_DBG("Could not allocate iso");
            return -ENOMEM;
        }

    I have corrected this error.

    2.

      So if I am understanding you correctly, you are not only getting this issue when you disable source and enable sink, but you also get this when you try to disable source and and then re-enable it?

    yes. The reasons are as followsv:

    int bt_le_audio_tx_init(void)
    {
        if (initialized)
        {
            return -EALREADY;
        }
        
        ....

    3.

    If source to sink, synchronization will fail.
    The reasons are as followsv:

    audio_sync_lf_timer_instance.p_reg.CC[0] -->Stop updating

    <inf> audio_datapath: Drft comp state: INIT\033[0m
    <inf> audio_datapath: Drft comp state: CALIB\033[0m
    <inf> audio_datapath: Pres comp state: INIT\033[0m
    <inf> audio_datapath: Drft comp state: OFFSET\033[0m
    <wrn> audio_datapath: Requested presentation delay out of range: pres_adj_us=47945453

    What could cause this problem ?

  • long20 said:
    int bt_le_audio_tx_init(void)
    {
        if (initialized)
        {
            return -EALREADY;
        }

    Hmm I would assume broadcast_source_disable() would take care of this, as it sets initialized to false.

    long20 said:
    audio_sync_lf_timer_instance.p_reg.CC[0] -->Stop updating

    <inf> audio_datapath: Drft comp state: INIT\033[0m
    <inf> audio_datapath: Drft comp state: CALIB\033[0m
    <inf> audio_datapath: Pres comp state: INIT\033[0m
    <inf> audio_datapath: Drft comp state: OFFSET\033[0m
    <wrn> audio_datapath: Requested presentation delay out of range: pres_adj_us=47945453

    I'll forward this the relevant team and ask. But there is no real error there then, right? I am only seeing inf (info) and wrn (warnings) here.

    long20 said:
    audio_sync_lf_timer_instance.p_reg.CC[0] -->Stop updating

    How are you seeing it stopping the updating? Does it end up not functioning in the end?

    Regards,

    Elfving

Related