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);

Parents Reply Children
  • hello,

    I have two DKs, with  being all broadcast source.

    one DK use button switch form source to sink. (broadcast source off,broadcast sink on)

    The sink is show
    <wrn> broadcast_sink: Unable to sync to broadcast source, ret: -12

  • long20 said:
    <wrn> broadcast_sink: Unable to sync to broadcast source, ret: -12

    I see. -12 means ENOMEM; it is out of memory. It might be interesting to debug it, to figure out exactly where this warning is coming from.

    Are you running into the same issue when just having a source and a sink, and running the default test suggested here?

    Regards,

    Elfving

  • 1.

    -12 means ENOMEM;-->

    it's return from

    ../ncs/v2.6.2/zephyr/subsys/bluetooth/audio/bap_broadcast_sink.c
        
     static int bt_bap_broadcast_sink_setup_stream(struct     bt_bap_broadcast_sink *sink,
                              struct bt_bap_stream *stream,
                              struct bt_audio_codec_cfg *codec_cfg)
              {
        struct bt_bap_iso *iso;
        struct bt_bap_ep *ep;

        if (stream->group != NULL) {
            LOG_DBG("Stream %p already in group %p", stream, stream->group);
            return -EALREADY;
        }

        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;
        }

    2.

    Are you running into the same issue when just having a source and a sink, and running the default test suggested here?-->

    it's sync ok and audio out.

    3.  

    if run broadcast_source_disable() that sink  is sync ok audio out,But then executing broadcast_source_enable() returns a failure.


           

  • Sorry about the wait, I have been OOO for a few days.

    long20 said:

        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;
        }

    Could you check which of these two the error is coming from?

    long20 said:

    if run broadcast_source_disable() that sink  is sync ok audio out,But then executing broadcast_source_enable() returns a failure.

    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?

    Regards,

    Elfving

  • 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 ?

Related