Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions subsys/bluetooth/audio/capabilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ int bt_audio_capability_register(struct bt_audio_capability *cap)
sys_slist_append(lst, &cap->_node);

#if defined(CONFIG_BT_PACS)
bt_pacs_add_capability(cap->dir);
bt_pacs_capabilities_changed(cap->dir);
#endif /* CONFIG_BT_PACS */

return 0;
Expand Down Expand Up @@ -445,7 +445,7 @@ int bt_audio_capability_unregister(struct bt_audio_capability *cap)
#endif /* CONFIG_BT_AUDIO_UNICAST_SERVER && CONFIG_BT_ASCS */

#if defined(CONFIG_BT_PACS)
bt_pacs_remove_capability(cap->dir);
bt_pacs_capabilities_changed(cap->dir);
#endif /* CONFIG_BT_PACS */

return 0;
Expand Down
36 changes: 9 additions & 27 deletions subsys/bluetooth/audio/pacs.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ static ssize_t supported_context_read(struct bt_conn *conn,
}

#if defined(CONFIG_BT_PAC_SNK_LOC) || defined(CONFIG_BT_PAC_SRC_LOC)
static void pac_notify_loc(struct k_work *work);

static int get_pac_loc(struct bt_conn *conn, enum bt_audio_dir dir,
enum bt_audio_location *location)
{
Expand All @@ -244,8 +246,10 @@ static int get_pac_loc(struct bt_conn *conn, enum bt_audio_dir dir,
}
#endif /* CONFIG_BT_PAC_SNK_LOC || CONFIG_BT_PAC_SRC_LOC */

static void pac_notify(struct k_work *work);

#if defined(CONFIG_BT_PAC_SNK)
static struct k_work_delayable snks_work;
static K_WORK_DELAYABLE_DEFINE(snks_work, pac_notify);

static ssize_t snk_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset)
Expand All @@ -262,7 +266,7 @@ static void snk_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value)
}

#if defined(CONFIG_BT_PAC_SNK_LOC)
static struct k_work_delayable snks_loc_work;
static K_WORK_DELAYABLE_DEFINE(snks_loc_work, pac_notify_loc);

static ssize_t snk_loc_read(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
Expand Down Expand Up @@ -341,7 +345,7 @@ static void snk_loc_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value)
#endif /* CONFIG_BT_PAC_SNK */

#if defined(CONFIG_BT_PAC_SRC)
static struct k_work_delayable srcs_work;
static K_WORK_DELAYABLE_DEFINE(srcs_work, pac_notify);

static ssize_t src_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset)
Expand All @@ -358,7 +362,7 @@ static void src_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value)
}

#if defined(CONFIG_BT_PAC_SRC_LOC)
static struct k_work_delayable srcs_loc_work;
static K_WORK_DELAYABLE_DEFINE(srcs_loc_work, pac_notify_loc);

static ssize_t src_loc_read(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf,
Expand Down Expand Up @@ -588,24 +592,7 @@ static void pac_notify(struct k_work *work)
}
}

void bt_pacs_add_capability(enum bt_audio_dir dir)
{
struct k_work_delayable *work;

work = bt_pacs_get_work(dir);
if (!work) {
return;
}

/* Initialize handler if it hasn't been initialized */
if (!work->work.handler) {
k_work_init_delayable(work, pac_notify);
}

k_work_reschedule(work, PAC_NOTIFY_TIMEOUT);
}

void bt_pacs_remove_capability(enum bt_audio_dir dir)
void bt_pacs_capabilities_changed(enum bt_audio_dir dir)
{
struct k_work_delayable *work;

Expand All @@ -628,11 +615,6 @@ int bt_audio_pacs_location_changed(enum bt_audio_dir dir)
return -EINVAL;
}

/* Initialize handler if it hasn't been initialized */
if (!work->work.handler) {
k_work_init_delayable(work, pac_notify_loc);
}

k_work_reschedule(work, PAC_NOTIFY_TIMEOUT);

return 0;
Expand Down
3 changes: 1 addition & 2 deletions subsys/bluetooth/audio/pacs_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ struct bt_pacs_context {
uint16_t src;
} __packed;

void bt_pacs_add_capability(enum bt_audio_dir dir);
void bt_pacs_remove_capability(enum bt_audio_dir dir);
void bt_pacs_capabilities_changed(enum bt_audio_dir dir);
int bt_pacs_available_contexts_changed(void);
bool bt_pacs_context_available(enum bt_audio_dir dir, uint16_t context);