Bluetooth: BAP: Fix bt_bap_scan_delegator_find_state
The bt_bap_scan_delegator_find_state did not properly return the correct receive state due to confusing return value of the iterator function. Modify it to use a simple bool. This fixes all issues with "Failed to find receive state for sink" when using the Broadcast Sink. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
2b74450544
commit
82e5eba817
|
@ -1844,20 +1844,17 @@ int bt_bap_scan_delegator_mod_src(const struct bt_bap_scan_delegator_mod_src_par
|
|||
*/
|
||||
int bt_bap_scan_delegator_rem_src(uint8_t src_id);
|
||||
|
||||
enum bt_bap_scan_delegator_iter {
|
||||
BT_BAP_SCAN_DELEGATOR_ITER_STOP = 0,
|
||||
BT_BAP_SCAN_DELEGATOR_ITER_CONTINUE,
|
||||
};
|
||||
|
||||
/** Callback function for Scan Delegator receive state search functions
|
||||
*
|
||||
* @param recv_state The receive state.
|
||||
* @param user_data User data.
|
||||
*
|
||||
* @return @ref BT_BAP_SCAN_DELEGATOR_ITER_STOP to stop iterating or
|
||||
* @ref BT_BAP_SCAN_DELEGATOR_ITER_CONTINUE to continue.
|
||||
* @retval true to stop iterating. If this is used in the context of
|
||||
* bt_bap_scan_delegator_find_state(), the recv_state will be returned by
|
||||
* bt_bap_scan_delegator_find_state()
|
||||
* @retval false to continue iterating
|
||||
*/
|
||||
typedef enum bt_bap_scan_delegator_iter (*bt_bap_scan_delegator_state_func_t)(
|
||||
typedef bool (*bt_bap_scan_delegator_state_func_t)(
|
||||
const struct bt_bap_scan_delegator_recv_state *recv_state, void *user_data);
|
||||
|
||||
/** @brief Iterate through all existing receive states
|
||||
|
|
|
@ -55,23 +55,21 @@ static sys_slist_t sink_cbs = SYS_SLIST_STATIC_INIT(&sink_cbs);
|
|||
|
||||
static void broadcast_sink_cleanup(struct bt_bap_broadcast_sink *sink);
|
||||
|
||||
static enum bt_bap_scan_delegator_iter
|
||||
find_recv_state_by_sink_cb(const struct bt_bap_scan_delegator_recv_state *recv_state,
|
||||
void *user_data)
|
||||
static bool find_recv_state_by_sink_cb(const struct bt_bap_scan_delegator_recv_state *recv_state,
|
||||
void *user_data)
|
||||
{
|
||||
const struct bt_bap_broadcast_sink *sink = user_data;
|
||||
|
||||
if (atomic_test_bit(sink->flags, BT_BAP_BROADCAST_SINK_FLAG_SRC_ID_VALID) &&
|
||||
sink->bass_src_id == recv_state->src_id) {
|
||||
return BT_BAP_SCAN_DELEGATOR_ITER_STOP;
|
||||
return true;
|
||||
}
|
||||
|
||||
return BT_BAP_SCAN_DELEGATOR_ITER_CONTINUE;
|
||||
return false;
|
||||
}
|
||||
|
||||
static enum bt_bap_scan_delegator_iter
|
||||
find_recv_state_by_pa_sync_cb(const struct bt_bap_scan_delegator_recv_state *recv_state,
|
||||
void *user_data)
|
||||
static bool find_recv_state_by_pa_sync_cb(const struct bt_bap_scan_delegator_recv_state *recv_state,
|
||||
void *user_data)
|
||||
{
|
||||
struct bt_le_per_adv_sync *sync = user_data;
|
||||
struct bt_le_per_adv_sync_info sync_info;
|
||||
|
@ -81,15 +79,15 @@ find_recv_state_by_pa_sync_cb(const struct bt_bap_scan_delegator_recv_state *rec
|
|||
if (err != 0) {
|
||||
LOG_DBG("Failed to get sync info: %d", err);
|
||||
|
||||
return BT_BAP_SCAN_DELEGATOR_ITER_CONTINUE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bt_addr_le_eq(&recv_state->addr, &sync_info.addr) &&
|
||||
recv_state->adv_sid == sync_info.sid) {
|
||||
return BT_BAP_SCAN_DELEGATOR_ITER_STOP;
|
||||
return true;
|
||||
}
|
||||
|
||||
return BT_BAP_SCAN_DELEGATOR_ITER_CONTINUE;
|
||||
return false;
|
||||
};
|
||||
|
||||
static void update_recv_state_big_synced(const struct bt_bap_broadcast_sink *sink)
|
||||
|
|
|
@ -1390,10 +1390,10 @@ void bt_bap_scan_delegator_foreach_state(bt_bap_scan_delegator_state_func_t func
|
|||
{
|
||||
for (size_t i = 0U; i < ARRAY_SIZE(scan_delegator.recv_states); i++) {
|
||||
if (scan_delegator.recv_states[i].active) {
|
||||
enum bt_bap_scan_delegator_iter iter;
|
||||
bool stop;
|
||||
|
||||
iter = func(&scan_delegator.recv_states[i].state, user_data);
|
||||
if (iter == BT_BAP_SCAN_DELEGATOR_ITER_STOP) {
|
||||
stop = func(&scan_delegator.recv_states[i].state, user_data);
|
||||
if (stop) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1406,7 +1406,7 @@ struct scan_delegator_state_find_state_param {
|
|||
void *user_data;
|
||||
};
|
||||
|
||||
static enum bt_bap_scan_delegator_iter
|
||||
static bool
|
||||
scan_delegator_state_find_state_cb(const struct bt_bap_scan_delegator_recv_state *recv_state,
|
||||
void *user_data)
|
||||
{
|
||||
|
@ -1417,10 +1417,10 @@ scan_delegator_state_find_state_cb(const struct bt_bap_scan_delegator_recv_state
|
|||
if (found) {
|
||||
param->recv_state = recv_state;
|
||||
|
||||
return BT_BAP_SCAN_DELEGATOR_ITER_STOP;
|
||||
return true;
|
||||
}
|
||||
|
||||
return BT_BAP_SCAN_DELEGATOR_ITER_CONTINUE;
|
||||
return false;
|
||||
}
|
||||
|
||||
const struct bt_bap_scan_delegator_recv_state *
|
||||
|
|
|
@ -120,6 +120,8 @@ CONFIG_BT_TMAP=y
|
|||
|
||||
# DEBUGGING
|
||||
CONFIG_LOG=y
|
||||
CONFIG_LOG_FUNC_NAME_PREFIX_ERR=y
|
||||
CONFIG_LOG_FUNC_NAME_PREFIX_WRN=y
|
||||
CONFIG_BT_VCP_VOL_REND_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_VCP_VOL_CTLR_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_AICS_LOG_LEVEL_DBG=y
|
||||
|
|
Loading…
Reference in a new issue