Bluetooth: Audio: Fix issue with registering AICS callbacks

When registering AICS callbacks via bt_vcs_client_cb_register
or bt_micp_mic_ctlr_cb_register it could fail if the application
did not reset the aics_cb.discover as that is set internally.

This commit adds a simple check to also allow the
aics_cb.discover to be the callback they expect/want it to be.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2022-08-09 14:26:15 +02:00 committed by Carles Cufí
commit 2b0f98b4fc
2 changed files with 6 additions and 2 deletions

View file

@ -456,7 +456,9 @@ int bt_micp_mic_ctlr_cb_register(struct bt_micp_mic_ctlr_cb *cb)
struct bt_aics_cb *aics_cb = NULL; struct bt_aics_cb *aics_cb = NULL;
if (cb != NULL) { if (cb != NULL) {
CHECKIF(cb->aics_cb.discover != NULL) { /* Ensure that the cb->aics_cb.discover is the aics_discover_cb */
CHECKIF(cb->aics_cb.discover != NULL &&
cb->aics_cb.discover != aics_discover_cb) {
BT_ERR("AICS discover callback shall not be set"); BT_ERR("AICS discover callback shall not be set");
return -EINVAL; return -EINVAL;
} }

View file

@ -837,7 +837,9 @@ int bt_vcs_client_cb_register(struct bt_vcs_cb *cb)
struct bt_aics_cb *aics_cb = NULL; struct bt_aics_cb *aics_cb = NULL;
if (cb != NULL) { if (cb != NULL) {
CHECKIF(cb->aics_cb.discover) { /* Ensure that the cb->aics_cb.discover is the aics_discover_cb */
CHECKIF(cb->aics_cb.discover != NULL &&
cb->aics_cb.discover != aics_discover_cb) {
BT_ERR("AICS discover callback shall not be set"); BT_ERR("AICS discover callback shall not be set");
return -EINVAL; return -EINVAL;
} }