Skip to content

Commit fd6041b

Browse files
alexsvenrlubos
authored andcommitted
applications: nrf5340_audio: Handle pref_pres_dly of 0
- Some devices set their preferred pres delay to 0, in those cases we need to set pres delay to common minimum Signed-off-by: Alexander Svensen <[email protected]>
1 parent c31231a commit fd6041b

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

applications/nrf5340_audio/src/bluetooth/bt_stream/unicast/unicast_client.c

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ static int headset_pres_delay_find(uint8_t index, uint32_t *pres_dly_us)
225225
uint32_t pref_dly_min = headsets[index].sink_ep->qos_pref.pref_pd_min;
226226
uint32_t pref_dly_max = headsets[index].sink_ep->qos_pref.pref_pd_max;
227227

228+
LOG_DBG("Index: %d, Pref min: %d, pref max: %d, pres_min: %d, pres_max: %d", index,
229+
pref_dly_min, pref_dly_max, pres_dly_min, pres_dly_max);
230+
228231
for (int i = 0; i < ARRAY_SIZE(headsets); i++) {
229232
if (headsets[i].sink_ep != NULL) {
230233
pres_dly_min = MAX(pres_dly_min, headsets[i].sink_ep->qos_pref.pd_min);
@@ -247,38 +250,29 @@ static int headset_pres_delay_find(uint8_t index, uint32_t *pres_dly_us)
247250
}
248251

249252
if (IS_ENABLED(CONFIG_BT_AUDIO_PRES_DELAY_SRCH_PREF_MIN)) {
250-
*pres_dly_us = pref_dly_min;
253+
/* Preferred min is 0, so we set min supported */
254+
if (pref_dly_min == 0) {
255+
*pres_dly_us = pres_dly_min;
256+
} else {
257+
*pres_dly_us = pref_dly_min;
258+
}
251259

252260
return 0;
253261
}
254262

255263
if (IS_ENABLED(CONFIG_BT_AUDIO_PRES_DELAY_SRCH_PREF_MAX)) {
256-
*pres_dly_us = pref_dly_max;
257-
258-
return 0;
259-
}
260-
261-
if (IS_ENABLED(CONFIG_BT_AUDIO_PRES_DELAY_SRCH_PREF_MIN)) {
262-
if (IN_RANGE(CONFIG_BT_AUDIO_PRESENTATION_DELAY_US, pres_dly_min, pres_dly_max)) {
263-
*pres_dly_us = CONFIG_BT_AUDIO_PRESENTATION_DELAY_US;
264+
/* Preferred max is 0, so we set max supported */
265+
if (pref_dly_max == 0) {
266+
*pres_dly_us = pres_dly_max;
264267
} else {
265-
LOG_WRN("Preferred local presentation delay outside of range");
266-
267-
if (pres_dly_max < CONFIG_BT_AUDIO_PRESENTATION_DELAY_US) {
268-
*pres_dly_us = pres_dly_max;
269-
270-
LOG_WRN("Selecting maximum common delay: %d us ", pres_dly_max);
271-
} else {
272-
*pres_dly_us = pres_dly_min;
273-
274-
LOG_WRN("Selecting minimum common delay: %d us ", pres_dly_min);
275-
}
268+
*pres_dly_us = pref_dly_max;
276269
}
277270

278271
return 0;
279272
}
280273

281274
LOG_ERR("Trying to use unrecognized search mode");
275+
282276
return -EINVAL;
283277
}
284278

0 commit comments

Comments
 (0)