Bluetooth: Audio: Standadize the use of enum bt_audio_dir

Many functions and struct fields had the directory/type
value, but named in different ways and stored in different ways.

This change updates all uses of it to use the same name
and type.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2022-03-29 17:55:51 +02:00 committed by Carles Cufí
parent 6b41e9991d
commit 19d7420f07
12 changed files with 157 additions and 151 deletions

View File

@ -921,7 +921,7 @@ struct bt_audio_unicast_server_cb {
*
* @param[in] conn Connection object.
* @param[in] ep Local Audio Endpoint being configured.
* @param[in] type Type of the endpoint.
* @param[in] dir Direction of the endpoint.
* @param[in] codec Codec configuration.
* @param[out] stream Pointer to stream that will be configured for
* the endpoint.
@ -933,7 +933,7 @@ struct bt_audio_unicast_server_cb {
*/
int (*config)(struct bt_conn *conn,
const struct bt_audio_ep *ep,
enum bt_audio_dir type,
enum bt_audio_dir dir,
const struct bt_codec *codec,
struct bt_audio_stream **stream,
struct bt_codec_qos_pref *const pref);
@ -944,7 +944,7 @@ struct bt_audio_unicast_server_cb {
* reconfigured with different codec configuration.
*
* @param[in] stream Stream object being reconfigured.
* @param[in] type Type of the endpoint.
* @param[in] dir Direction of the endpoint.
* @param[in] codec Codec configuration.
* @param[out] pref Pointer to a QoS preference object that shall
* be populated with values. Invalid values will
@ -953,7 +953,7 @@ struct bt_audio_unicast_server_cb {
* @return 0 in case of success or negative value in case of error.
*/
int (*reconfig)(struct bt_audio_stream *stream,
uint8_t type,
enum bt_audio_dir dir,
const struct bt_codec *codec,
struct bt_codec_qos_pref *const pref);
@ -1082,13 +1082,13 @@ struct bt_audio_unicast_server_cb {
* for sending a notification, as a result of
* calling
* bt_audio_unicast_server_location_changed().
* @param[in] type Type of the endpoint.
* @param[in] dir Direction of the endpoint.
* @param[out] location Pointer to the location that needs to be set.
*
* @return 0 in case of success or negative value in case of error.
*/
int (*publish_location)(struct bt_conn *conn,
enum bt_audio_dir type,
enum bt_audio_dir dir,
enum bt_audio_location *location);
#if defined(CONFIG_BT_PAC_SNK_LOC_WRITEABLE) || defined(CONFIG_BT_PAC_SRC_LOC_WRITEABLE)
@ -1098,12 +1098,12 @@ struct bt_audio_unicast_server_cb {
* requests to write the Published Audio Capabilities (PAC) location.
*
* @param conn The connection that requests the write.
* @param type Type of the endpoint.
* @param dir Direction of the endpoint.
* @param location The location being written.
*
* @return 0 in case of success or negative value in case of error.
*/
int (*write_location)(struct bt_conn *conn, enum bt_audio_dir type,
int (*write_location)(struct bt_conn *conn, enum bt_audio_dir dir,
enum bt_audio_location location);
#endif /* CONFIG_BT_PAC_SNK_LOC_WRITEABLE || CONFIG_BT_PAC_SRC_LOC_WRITEABLE */
#endif /* CONFIG_BT_PAC_SNK_LOC || CONFIG_BT_PAC_SRC_LOC */
@ -1340,9 +1340,11 @@ int bt_audio_unicast_server_unregister_cb(const struct bt_audio_unicast_server_c
*
* Notify connected clients that the location has changed
*
* @param dir Direction of the endpoint.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_audio_unicast_server_location_changed(enum bt_audio_dir type);
int bt_audio_unicast_server_location_changed(enum bt_audio_dir dir);
/** @} */ /* End of group bt_audio_server */
@ -1366,7 +1368,7 @@ typedef void (*bt_audio_discover_func_t)(struct bt_conn *conn,
struct bt_audio_discover_params {
/** Capabilities type */
uint8_t type;
enum bt_audio_dir dir;
/** Callback function */
bt_audio_discover_func_t func;
/** Number of capabilities found */

View File

@ -17,7 +17,7 @@ extern "C" {
#endif
/* Get list of capabilities by type */
sys_slist_t *bt_audio_capability_get(uint8_t type);
sys_slist_t *bt_audio_capability_get(enum bt_audio_dir dir);
/** @brief Audio Capability type */
@ -107,7 +107,7 @@ struct bt_audio_capability_ops {
*
* @param conn Connection object
* @param ep Remote Audio Endpoint being configured
* @param type Type of the endpoint.
* @param dir Direction of the endpoint.
* @param cap Local Audio Capability being configured
* @param codec Codec configuration
*
@ -115,7 +115,7 @@ struct bt_audio_capability_ops {
*/
struct bt_audio_stream *(*config)(struct bt_conn *conn,
struct bt_audio_ep *ep,
enum bt_audio_dir type,
enum bt_audio_dir dir,
struct bt_audio_capability *cap,
struct bt_codec *codec);
@ -228,8 +228,8 @@ struct bt_audio_capability_ops {
*
*/
struct bt_audio_capability {
/** Capability type */
uint8_t type;
/** Capability direction */
enum bt_audio_dir dir;
/** Supported Audio Contexts */
uint16_t context;
/** Capability codec reference */
@ -263,11 +263,11 @@ int bt_audio_capability_unregister(struct bt_audio_capability *cap);
/** @brief Set the location for an endpoint type
*
* @param type Type of the endpoint.
* @param dir Direction of the endpoints to change location for.
* @param location The location to be set.
*
*/
int bt_audio_capability_set_location(enum bt_audio_dir type,
int bt_audio_capability_set_location(enum bt_audio_dir dir,
enum bt_audio_location location);
#ifdef __cplusplus

View File

@ -465,13 +465,14 @@ static void add_remote_sink(struct bt_audio_ep *ep, uint8_t index)
}
static void add_remote_codec(struct bt_codec *codec_capabilities, int index,
uint8_t type)
enum bt_audio_dir dir)
{
printk("#%u: codec %p type 0x%02x\n", index, codec_capabilities, type);
printk("#%u: codec_capabilities %p dir 0x%02x\n",
index, codec_capabilities, dir);
print_codec_capabilities(codec_capabilities);
if (type != BT_AUDIO_SINK && type != BT_AUDIO_SOURCE) {
if (dir != BT_AUDIO_SINK && dir != BT_AUDIO_SOURCE) {
return;
}
@ -491,15 +492,15 @@ static void discover_sink_cb(struct bt_conn *conn,
}
if (codec != NULL) {
add_remote_codec(codec, params->num_caps, params->type);
add_remote_codec(codec, params->num_caps, params->dir);
return;
}
if (ep != NULL) {
if (params->type == BT_AUDIO_SINK) {
if (params->dir == BT_AUDIO_SINK) {
add_remote_sink(ep, params->num_eps);
} else {
printk("Invalid param type: %u\n", params->type);
printk("Invalid param dir: %u\n", params->dir);
}
return;
@ -601,7 +602,7 @@ static int discover_sink(void)
int err;
params.func = discover_sink_cb;
params.type = BT_AUDIO_SINK;
params.dir = BT_AUDIO_SINK;
err = bt_audio_discover(default_conn, &params);
if (err != 0) {

View File

@ -131,12 +131,12 @@ static void print_qos(struct bt_codec_qos *qos)
static struct bt_audio_stream *lc3_config(struct bt_conn *conn,
struct bt_audio_ep *ep,
enum bt_audio_dir type,
enum bt_audio_dir dir,
struct bt_audio_capability *cap,
struct bt_codec *codec)
{
printk("ASE Codec Config: conn %p ep %p type %u, cap %p\n",
conn, ep, type, cap);
printk("ASE Codec Config: conn %p ep %p dir %u, cap %p\n",
conn, ep, dir, cap);
print_codec(codec);
@ -378,7 +378,7 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
static struct bt_audio_capability caps[] = {
{
.type = BT_AUDIO_SINK,
.dir = BT_AUDIO_SINK,
.pref = BT_AUDIO_CAPABILITY_PREF(
BT_AUDIO_CAPABILITY_UNFRAMED_SUPPORTED,
BT_GAP_LE_PHY_2M, 0x02, 10, 40000, 40000,

View File

@ -35,7 +35,7 @@ static sys_slist_t srcs;
*/
static int unicast_server_config_cb(struct bt_conn *conn,
const struct bt_audio_ep *ep,
enum bt_audio_dir type,
enum bt_audio_dir dir,
const struct bt_codec *codec,
struct bt_audio_stream **stream,
struct bt_codec_qos_pref *const pref)
@ -43,12 +43,12 @@ static int unicast_server_config_cb(struct bt_conn *conn,
struct bt_audio_capability *cap;
sys_slist_t *lst;
if (type == BT_AUDIO_SINK) {
if (dir == BT_AUDIO_SINK) {
lst = &snks;
} else if (type == BT_AUDIO_SOURCE) {
} else if (dir == BT_AUDIO_SOURCE) {
lst = &srcs;
} else {
BT_ERR("Invalid endpoint type: %u", type);
BT_ERR("Invalid endpoint dir: %u", dir);
return -EINVAL;
}
@ -63,7 +63,7 @@ static int unicast_server_config_cb(struct bt_conn *conn,
}
*stream = cap->ops->config(conn, (struct bt_audio_ep *)ep,
type, cap, (struct bt_codec *)codec);
dir, cap, (struct bt_codec *)codec);
if (*stream == NULL) {
return -ENOMEM;
@ -84,25 +84,25 @@ static int unicast_server_config_cb(struct bt_conn *conn,
return 0;
}
BT_ERR("No capability for type %u and codec ID %u", type, codec->id);
BT_ERR("No capability for dir %u and codec ID %u", dir, codec->id);
return -EOPNOTSUPP;
}
static int unicast_server_reconfig_cb(struct bt_audio_stream *stream,
uint8_t type,
enum bt_audio_dir dir,
const struct bt_codec *codec,
struct bt_codec_qos_pref *const pref)
{
struct bt_audio_capability *cap;
sys_slist_t *lst;
if (type == BT_AUDIO_SINK) {
if (dir == BT_AUDIO_SINK) {
lst = &snks;
} else if (type == BT_AUDIO_SOURCE) {
} else if (dir == BT_AUDIO_SOURCE) {
lst = &srcs;
} else {
BT_ERR("Invalid endpoint type: %u", type);
BT_ERR("Invalid endpoint dir: %u", dir);
return -EINVAL;
}
@ -138,7 +138,7 @@ static int unicast_server_reconfig_cb(struct bt_audio_stream *stream,
return 0;
}
BT_ERR("No capability for type %u and codec ID %u", type, codec->id);
BT_ERR("No capability for dir %u and codec ID %u", dir, codec->id);
return -EOPNOTSUPP;
}
@ -227,19 +227,19 @@ static int unicast_server_release_cb(struct bt_audio_stream *stream)
return cap->ops->release(stream);
}
static int publish_capability_cb(struct bt_conn *conn, uint8_t type,
static int publish_capability_cb(struct bt_conn *conn, uint8_t dir,
uint8_t index, struct bt_codec *codec)
{
struct bt_audio_capability *cap;
sys_slist_t *lst;
uint8_t i;
if (type == BT_AUDIO_SINK) {
if (dir == BT_AUDIO_SINK) {
lst = &snks;
} else if (type == BT_AUDIO_SOURCE) {
} else if (dir == BT_AUDIO_SOURCE) {
lst = &srcs;
} else {
BT_ERR("Invalid endpoint type: %u", type);
BT_ERR("Invalid endpoint dir: %u", dir);
return -EINVAL;
}
@ -268,20 +268,20 @@ static enum bt_audio_location source_location;
#endif /* CONFIG_BT_PAC_SRC_LOC */
static int publish_location_cb(struct bt_conn *conn,
enum bt_audio_dir type,
enum bt_audio_dir dir,
enum bt_audio_location *location)
{
if (0) {
#if defined(CONFIG_BT_PAC_SNK_LOC)
} else if (type == BT_AUDIO_SINK) {
} else if (dir == BT_AUDIO_SINK) {
*location = sink_location;
#endif /* CONFIG_BT_PAC_SNK_LOC */
#if defined(CONFIG_BT_PAC_SRC_LOC)
} else if (type == BT_AUDIO_SOURCE) {
} else if (dir == BT_AUDIO_SOURCE) {
*location = source_location;
#endif /* CONFIG_BT_PAC_SRC_LOC */
} else {
BT_ERR("Invalid endpoint type: %u", type);
BT_ERR("Invalid endpoint dir: %u", dir);
return -EINVAL;
}
@ -290,10 +290,10 @@ static int publish_location_cb(struct bt_conn *conn,
}
#if defined(CONFIG_BT_PAC_SNK_LOC_WRITEABLE) || defined(CONFIG_BT_PAC_SRC_LOC_WRITEABLE)
static int write_location_cb(struct bt_conn *conn, enum bt_audio_dir type,
static int write_location_cb(struct bt_conn *conn, enum bt_audio_dir dir,
enum bt_audio_location location)
{
return bt_audio_capability_set_location(type, location);
return bt_audio_capability_set_location(dir, location);
}
#endif /* CONFIG_BT_PAC_SNK_LOC_WRITEABLE || CONFIG_BT_PAC_SRC_LOC_WRITEABLE */
#endif /* CONFIG_BT_PAC_SNK_LOC || CONFIG_BT_PAC_SRC_LOC */
@ -318,9 +318,9 @@ static struct bt_audio_unicast_server_cb unicast_server_cb = {
};
#endif /* CONFIG_BT_AUDIO_UNICAST_SERVER && CONFIG_BT_ASCS */
sys_slist_t *bt_audio_capability_get(uint8_t type)
sys_slist_t *bt_audio_capability_get(enum bt_audio_dir dir)
{
switch (type) {
switch (dir) {
case BT_AUDIO_SINK:
return &snks;
case BT_AUDIO_SOURCE:
@ -339,13 +339,13 @@ int bt_audio_capability_register(struct bt_audio_capability *cap)
return -EINVAL;
}
lst = bt_audio_capability_get(cap->type);
lst = bt_audio_capability_get(cap->dir);
if (!lst) {
return -EINVAL;
}
BT_DBG("cap %p type 0x%02x codec 0x%02x codec cid 0x%04x "
"codec vid 0x%04x", cap, cap->type, cap->codec->id,
BT_DBG("cap %p dir 0x%02x codec 0x%02x codec cid 0x%04x "
"codec vid 0x%04x", cap, cap->dir, cap->codec->id,
cap->codec->cid, cap->codec->vid);
#if defined(CONFIG_BT_AUDIO_UNICAST_SERVER) && defined(CONFIG_BT_ASCS)
@ -373,7 +373,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->type);
bt_pacs_add_capability(cap->dir);
#endif /* CONFIG_BT_PACS */
return 0;
@ -388,12 +388,12 @@ int bt_audio_capability_unregister(struct bt_audio_capability *cap)
return -EINVAL;
}
lst = bt_audio_capability_get(cap->type);
lst = bt_audio_capability_get(cap->dir);
if (!lst) {
return -EINVAL;
}
BT_DBG("cap %p type 0x%02x", cap, cap->type);
BT_DBG("cap %p dir 0x%02x", cap, cap->dir);
if (!sys_slist_find_and_remove(lst, &cap->node)) {
return -ENOENT;
@ -416,38 +416,38 @@ 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->type);
bt_pacs_remove_capability(cap->dir);
#endif /* CONFIG_BT_PACS */
return 0;
}
#if defined(CONFIG_BT_PAC_SNK_LOC) || defined(CONFIG_BT_PAC_SRC_LOC)
int bt_audio_capability_set_location(enum bt_audio_dir type,
int bt_audio_capability_set_location(enum bt_audio_dir dir,
enum bt_audio_location location)
{
int err;
if (0) {
#if defined(CONFIG_BT_PAC_SNK_LOC)
} else if (type == BT_AUDIO_SINK) {
} else if (dir == BT_AUDIO_SINK) {
sink_location = location;
#endif /* CONFIG_BT_PAC_SNK_LOC */
#if defined(CONFIG_BT_PAC_SRC_LOC)
} else if (type == BT_AUDIO_SOURCE) {
} else if (dir == BT_AUDIO_SOURCE) {
source_location = location;
#endif /* CONFIG_BT_PAC_SRC_LOC */
} else {
BT_ERR("Invalid endpoint type: %u", type);
BT_ERR("Invalid endpoint dir: %u", dir);
return -EINVAL;
}
if (IS_ENABLED(CONFIG_BT_AUDIO_UNICAST_SERVER)) {
err = bt_audio_unicast_server_location_changed(type);
err = bt_audio_unicast_server_location_changed(dir);
if (err) {
BT_DBG("Location for type %d wasn't notified: %d",
type, err);
BT_DBG("Location for dir %d wasn't notified: %d",
dir, err);
}
}

View File

@ -50,7 +50,7 @@ static void pac_data_add(struct net_buf_simple *buf, uint8_t num,
}
}
static void get_pac_records(struct bt_conn *conn, uint8_t type,
static void get_pac_records(struct bt_conn *conn, enum bt_audio_dir dir,
struct net_buf_simple *buf)
{
struct bt_pacs_read_rsp *rsp;
@ -72,7 +72,7 @@ static void get_pac_records(struct bt_conn *conn, uint8_t type,
struct bt_pac *pac;
int err;
err = unicast_server_cb->publish_capability(conn, type,
err = unicast_server_cb->publish_capability(conn, dir,
rsp->num_pac,
&codec);
if (err != 0) {
@ -110,15 +110,15 @@ static void get_pac_records(struct bt_conn *conn, uint8_t type,
static ssize_t pac_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset)
{
uint8_t type;
enum bt_audio_dir dir;
if (!bt_uuid_cmp(attr->uuid, BT_UUID_PACS_SNK)) {
type = BT_AUDIO_SINK;
dir = BT_AUDIO_SINK;
} else {
type = BT_AUDIO_SOURCE;
dir = BT_AUDIO_SOURCE;
}
get_pac_records(conn, type, &read_buf);
get_pac_records(conn, dir, &read_buf);
return bt_gatt_attr_read(conn, attr, buf, len, offset, read_buf.data,
read_buf.len);
@ -173,7 +173,7 @@ static ssize_t supported_context_read(struct bt_conn *conn,
}
#if defined(CONFIG_BT_PAC_SNK_LOC) || defined(CONFIG_BT_PAC_SRC_LOC)
static int get_pac_loc(struct bt_conn *conn, enum bt_audio_dir type,
static int get_pac_loc(struct bt_conn *conn, enum bt_audio_dir dir,
enum bt_audio_location *location)
{
int err;
@ -184,7 +184,7 @@ static int get_pac_loc(struct bt_conn *conn, enum bt_audio_dir type,
return -ENODATA;
}
err = unicast_server_cb->publish_location(conn, type, location);
err = unicast_server_cb->publish_location(conn, dir, location);
if (err != 0 || *location == 0) {
BT_DBG("err (%d) or invalid location value (%u)",
err, *location);
@ -454,9 +454,9 @@ BT_GATT_SERVICE_DEFINE(pacs_svc,
);
#endif /* CONFIG_BT_PAC_SNK || CONFIG_BT_PAC_SRC */
static struct k_work_delayable *bt_pacs_get_work(uint8_t type)
static struct k_work_delayable *bt_pacs_get_work(enum bt_audio_dir dir)
{
switch (type) {
switch (dir) {
#if defined(CONFIG_BT_PAC_SNK)
case BT_AUDIO_SINK:
return &snks_work;
@ -465,15 +465,15 @@ static struct k_work_delayable *bt_pacs_get_work(uint8_t type)
case BT_AUDIO_SOURCE:
return &srcs_work;
#endif /* CONFIG_BT_PAC_SNK */
default:
return NULL;
}
return NULL;
}
#if defined(CONFIG_BT_PAC_SNK_LOC) || defined(CONFIG_BT_PAC_SRC_LOC)
static struct k_work_delayable *bt_pacs_get_loc_work(uint8_t type)
static struct k_work_delayable *bt_pacs_get_loc_work(enum bt_audio_dir dir)
{
switch (type) {
switch (dir) {
#if defined(CONFIG_BT_PAC_SNK)
case BT_AUDIO_SINK:
return &snks_loc_work;
@ -482,9 +482,9 @@ static struct k_work_delayable *bt_pacs_get_loc_work(uint8_t type)
case BT_AUDIO_SOURCE:
return &srcs_loc_work;
#endif /* CONFIG_BT_PAC_SNK */
default:
return NULL;
}
return NULL;
}
static void pac_notify_loc(struct k_work *work)
@ -492,25 +492,25 @@ static void pac_notify_loc(struct k_work *work)
#if defined(CONFIG_BT_PAC_SNK) || defined(CONFIG_BT_PAC_SRC)
uint32_t location;
struct bt_uuid *uuid;
enum bt_audio_dir type;
enum bt_audio_dir dir;
int err;
#if defined(CONFIG_BT_PAC_SNK)
if (work == &snks_loc_work.work) {
type = BT_AUDIO_SINK;
dir = BT_AUDIO_SINK;
uuid = BT_UUID_PACS_SNK_LOC;
}
#endif /* CONFIG_BT_PAC_SNK */
#if defined(CONFIG_BT_PAC_SRC)
if (work == &srcs_loc_work.work) {
type = BT_AUDIO_SOURCE;
dir = BT_AUDIO_SOURCE;
uuid = BT_UUID_PACS_SRC_LOC;
}
#endif /* CONFIG_BT_PAC_SRC */
/* TODO: We can skip this if we are not connected to any devices */
err = get_pac_loc(NULL, type, &location);
err = get_pac_loc(NULL, dir, &location);
if (err != 0) {
BT_DBG("get_pac_loc returned %d, won't notify", err);
return;
@ -530,25 +530,25 @@ static void pac_notify(struct k_work *work)
{
#if defined(CONFIG_BT_PAC_SNK) || defined(CONFIG_BT_PAC_SRC)
struct bt_uuid *uuid;
uint8_t type;
enum bt_audio_dir dir;
int err;
#if defined(CONFIG_BT_PAC_SNK)
if (work == &snks_work.work) {
type = BT_AUDIO_SINK;
dir = BT_AUDIO_SINK;
uuid = BT_UUID_PACS_SNK;
}
#endif /* CONFIG_BT_PAC_SNK */
#if defined(CONFIG_BT_PAC_SRC)
if (work == &srcs_work.work) {
type = BT_AUDIO_SOURCE;
dir = BT_AUDIO_SOURCE;
uuid = BT_UUID_PACS_SRC;
}
#endif /* CONFIG_BT_PAC_SRC */
/* TODO: We can skip this if we are not connected to any devices */
get_pac_records(NULL, type, &read_buf);
get_pac_records(NULL, dir, &read_buf);
err = bt_gatt_notify_uuid(NULL, uuid, pacs_svc.attrs, read_buf.data,
read_buf.len);
@ -558,11 +558,11 @@ static void pac_notify(struct k_work *work)
#endif /* CONFIG_BT_PAC_SNK || CONFIG_BT_PAC_SRC */
}
void bt_pacs_add_capability(uint8_t type)
void bt_pacs_add_capability(enum bt_audio_dir dir)
{
struct k_work_delayable *work;
work = bt_pacs_get_work(type);
work = bt_pacs_get_work(dir);
if (!work) {
return;
}
@ -575,11 +575,11 @@ void bt_pacs_add_capability(uint8_t type)
k_work_reschedule(work, PAC_NOTIFY_TIMEOUT);
}
void bt_pacs_remove_capability(uint8_t type)
void bt_pacs_remove_capability(enum bt_audio_dir dir)
{
struct k_work_delayable *work;
work = bt_pacs_get_work(type);
work = bt_pacs_get_work(dir);
if (!work) {
return;
}
@ -588,11 +588,11 @@ void bt_pacs_remove_capability(uint8_t type)
}
#if defined(CONFIG_BT_PAC_SNK_LOC) || defined(CONFIG_BT_PAC_SRC_LOC)
int bt_pacs_location_changed(enum bt_audio_dir type)
int bt_pacs_location_changed(enum bt_audio_dir dir)
{
struct k_work_delayable *work;
work = bt_pacs_get_loc_work(type);
work = bt_pacs_get_loc_work(dir);
if (!work) {
return -EINVAL;
}

View File

@ -50,6 +50,6 @@ struct bt_pacs_context {
uint16_t src;
} __packed;
void bt_pacs_add_capability(uint8_t type);
void bt_pacs_remove_capability(uint8_t type);
int bt_pacs_location_changed(enum bt_audio_dir type);
void bt_pacs_add_capability(enum bt_audio_dir dir);
void bt_pacs_remove_capability(enum bt_audio_dir dir);
int bt_pacs_location_changed(enum bt_audio_dir dir);

View File

@ -35,7 +35,7 @@
#define EP_ISO(_iso) CONTAINER_OF(_iso, struct bt_audio_ep, iso)
static struct unicast_client_pac {
uint8_t type; /* type == PAC_TYPE_UNUSED means unused */
enum bt_audio_dir dir; /* type == PAC_TYPE_UNUSED means unused */
uint16_t context;
struct bt_codec codec;
} cache[CONFIG_BT_MAX_CONN][CONFIG_BT_AUDIO_UNICAST_CLIENT_PAC_COUNT];
@ -139,7 +139,7 @@ static struct bt_iso_chan_ops unicast_client_iso_ops = {
};
static void unicast_client_ep_init(struct bt_audio_ep *ep, uint16_t handle,
uint8_t dir)
enum bt_audio_dir dir)
{
BT_DBG("ep %p dir 0x%02x handle 0x%04x", ep, dir, handle);
@ -183,7 +183,8 @@ static struct bt_audio_ep *unicast_client_ep_find(struct bt_conn *conn,
}
static struct bt_audio_ep *unicast_client_ep_new(struct bt_conn *conn,
uint8_t dir, uint16_t handle)
enum bt_audio_dir dir,
uint16_t handle)
{
size_t i, size;
uint8_t index;
@ -217,7 +218,8 @@ static struct bt_audio_ep *unicast_client_ep_new(struct bt_conn *conn,
}
static struct bt_audio_ep *unicast_client_ep_get(struct bt_conn *conn,
uint8_t dir, uint16_t handle)
enum bt_audio_dir dir,
uint16_t handle)
{
struct bt_audio_ep *ep;
@ -1610,7 +1612,7 @@ static uint8_t unicast_client_ase_read_func(struct bt_conn *conn, uint8_t err,
goto fail;
}
ep = unicast_client_ep_get(conn, params->type,
ep = unicast_client_ep_get(conn, params->dir,
read->by_uuid.start_handle);
if (!ep) {
BT_WARN("No space left to parse ASE");
@ -1647,9 +1649,9 @@ static int unicast_client_ase_discover(struct bt_conn *conn,
params->read.func = unicast_client_ase_read_func;
params->read.handle_count = 0u;
if (params->type == BT_AUDIO_SINK) {
if (params->dir == BT_AUDIO_SINK) {
params->read.by_uuid.uuid = ase_snk_uuid;
} else if (params->type == BT_AUDIO_SOURCE) {
} else if (params->dir == BT_AUDIO_SOURCE) {
params->read.by_uuid.uuid = ase_src_uuid;
} else {
return -EINVAL;
@ -1688,11 +1690,11 @@ static uint8_t unicast_client_pacs_context_read_func(struct bt_conn *conn,
for (i = 0; i < CONFIG_BT_AUDIO_UNICAST_CLIENT_PAC_COUNT; i++) {
struct unicast_client_pac *pac = &cache[index][i];
if (pac->type == PAC_TYPE_UNUSED) {
if (pac->dir == PAC_TYPE_UNUSED) {
continue;
}
switch (pac->type) {
switch (pac->dir) {
case BT_AUDIO_SINK:
pac->context = sys_le16_to_cpu(context->snk);
break;
@ -1700,8 +1702,8 @@ static uint8_t unicast_client_pacs_context_read_func(struct bt_conn *conn,
pac->context = sys_le16_to_cpu(context->src);
break;
default:
BT_WARN("Cached pac with invalid type: %u",
pac->type);
BT_WARN("Cached pac with invalid dir: %u",
pac->dir);
}
BT_DBG("pac %p context 0x%04x", pac, pac->context);
@ -1733,7 +1735,7 @@ static int unicast_client_pacs_context_discover(struct bt_conn *conn,
}
static struct unicast_client_pac *unicast_client_pac_alloc(struct bt_conn *conn,
uint8_t type)
enum bt_audio_dir dir)
{
int i, index;
@ -1742,8 +1744,8 @@ static struct unicast_client_pac *unicast_client_pac_alloc(struct bt_conn *conn,
for (i = 0; i < CONFIG_BT_AUDIO_UNICAST_CLIENT_PAC_COUNT; i++) {
struct unicast_client_pac *pac = &cache[index][i];
if (pac->type == PAC_TYPE_UNUSED) {
pac->type = type;
if (pac->dir == PAC_TYPE_UNUSED) {
pac->dir = dir;
return pac;
}
}
@ -1805,7 +1807,7 @@ static uint8_t unicast_client_read_func(struct bt_conn *conn, uint8_t err,
break;
}
bpac = unicast_client_pac_alloc(conn, params->type);
bpac = unicast_client_pac_alloc(conn, params->dir);
if (!bpac) {
BT_WARN("No space left to parse PAC");
break;
@ -1873,7 +1875,7 @@ static void unicast_client_pac_reset(struct bt_conn *conn)
for (i = 0; i < CONFIG_BT_AUDIO_UNICAST_CLIENT_PAC_COUNT; i++) {
struct unicast_client_pac *pac = &cache[index][i];
if (pac->type != PAC_TYPE_UNUSED) {
if (pac->dir != PAC_TYPE_UNUSED) {
(void)memset(pac, 0, sizeof(*pac));
}
}
@ -1907,9 +1909,9 @@ int bt_audio_discover(struct bt_conn *conn,
return -EINVAL;
}
if (params->type == BT_AUDIO_SINK) {
if (params->dir == BT_AUDIO_SINK) {
params->read.by_uuid.uuid = snk_uuid;
} else if (params->type == BT_AUDIO_SOURCE) {
} else if (params->dir == BT_AUDIO_SOURCE) {
params->read.by_uuid.uuid = src_uuid;
} else {
return -EINVAL;

View File

@ -53,8 +53,8 @@ int bt_audio_unicast_server_unregister_cb(const struct bt_audio_unicast_server_c
}
#if defined(CONFIG_BT_PAC_SNK_LOC) || defined(CONFIG_BT_PAC_SRC_LOC)
int bt_audio_unicast_server_location_changed(enum bt_audio_dir type)
int bt_audio_unicast_server_location_changed(enum bt_audio_dir dir)
{
return bt_pacs_location_changed(type);
return bt_pacs_location_changed(dir);
}
#endif /* CONFIG_BT_PAC_SNK_LOC || CONFIG_BT_PAC_SRC_LOC */

View File

@ -269,14 +269,14 @@ static int cmd_select_unicast(const struct shell *sh, size_t argc, char *argv[])
static struct bt_audio_stream *lc3_config(struct bt_conn *conn,
struct bt_audio_ep *ep,
enum bt_audio_dir type,
enum bt_audio_dir dir,
struct bt_audio_capability *cap,
struct bt_codec *codec)
{
int i;
shell_print(ctx_shell, "ASE Codec Config: conn %p ep %p type %u, cap %p",
conn, ep, type, cap);
shell_print(ctx_shell, "ASE Codec Config: conn %p ep %p dir %u, cap %p",
conn, ep, dir, cap);
print_codec(codec);
@ -437,7 +437,7 @@ static struct bt_audio_capability_ops lc3_ops = {
static struct bt_audio_capability caps[MAX_PAC] = {
{
.type = BT_AUDIO_SOURCE,
.dir = BT_AUDIO_SOURCE,
.pref = BT_AUDIO_CAPABILITY_PREF(
BT_AUDIO_CAPABILITY_UNFRAMED_SUPPORTED,
BT_GAP_LE_PHY_2M, 0u, 60u, 20000u, 40000u,
@ -446,7 +446,7 @@ static struct bt_audio_capability caps[MAX_PAC] = {
.ops = &lc3_ops,
},
{
.type = BT_AUDIO_SINK,
.dir = BT_AUDIO_SINK,
.pref = BT_AUDIO_CAPABILITY_PREF(
BT_AUDIO_CAPABILITY_UNFRAMED_SUPPORTED,
BT_GAP_LE_PHY_2M, 0u, 60u, 20000u, 40000u,
@ -476,18 +476,18 @@ static uint8_t stream_dir(const struct bt_audio_stream *stream)
return 0;
}
static void add_codec(struct bt_codec *codec, uint8_t index, uint8_t type)
static void add_codec(struct bt_codec *codec, uint8_t index, enum bt_audio_dir dir)
{
shell_print(ctx_shell, "#%u: codec %p type 0x%02x", index, codec, type);
shell_print(ctx_shell, "#%u: codec %p dir 0x%02x", index, codec, dir);
print_codec(codec);
if (type != BT_AUDIO_SINK && type != BT_AUDIO_SOURCE) {
if (dir != BT_AUDIO_SINK && dir != BT_AUDIO_SOURCE) {
return;
}
if (index < CONFIG_BT_AUDIO_UNICAST_CLIENT_PAC_COUNT) {
rcodecs[type - 1][index] = codec;
rcodecs[dir - 1][index] = codec;
}
}
@ -510,14 +510,14 @@ static void discover_cb(struct bt_conn *conn, struct bt_codec *codec,
struct bt_audio_discover_params *params)
{
if (codec != NULL) {
add_codec(codec, params->num_caps, params->type);
add_codec(codec, params->num_caps, params->dir);
return;
}
if (ep) {
if (params->type == BT_AUDIO_SINK) {
if (params->dir == BT_AUDIO_SINK) {
add_sink(ep, params->num_eps);
} else if (params->type == BT_AUDIO_SOURCE) {
} else if (params->dir == BT_AUDIO_SOURCE) {
add_source(ep, params->num_eps);
}
@ -534,14 +534,14 @@ static void discover_all(struct bt_conn *conn, struct bt_codec *codec,
struct bt_audio_discover_params *params)
{
if (codec != NULL) {
add_codec(codec, params->num_caps, params->type);
add_codec(codec, params->num_caps, params->dir);
return;
}
if (ep) {
if (params->type == BT_AUDIO_SINK) {
if (params->dir == BT_AUDIO_SINK) {
add_sink(ep, params->num_eps);
} else if (params->type == BT_AUDIO_SOURCE) {
} else if (params->dir == BT_AUDIO_SOURCE) {
add_source(ep, params->num_eps);
}
@ -549,11 +549,11 @@ static void discover_all(struct bt_conn *conn, struct bt_codec *codec,
}
/* Sinks discovery complete, now discover sources */
if (params->type == BT_AUDIO_SINK) {
if (params->dir == BT_AUDIO_SINK) {
int err;
params->func = discover_cb;
params->type = BT_AUDIO_SOURCE;
params->dir = BT_AUDIO_SOURCE;
err = bt_audio_discover(default_conn, params);
if (err) {
@ -578,16 +578,16 @@ static int cmd_discover(const struct shell *sh, size_t argc, char *argv[])
}
params.func = discover_all;
params.type = BT_AUDIO_SINK;
params.dir = BT_AUDIO_SINK;
if (argc > 1) {
if (!strcmp(argv[1], "sink")) {
params.func = discover_cb;
} else if (!strcmp(argv[1], "source")) {
params.func = discover_cb;
params.type = BT_AUDIO_SOURCE;
params.dir = BT_AUDIO_SOURCE;
} else {
shell_error(sh, "Unsupported type: %s", argv[1]);
shell_error(sh, "Unsupported dir: %s", argv[1]);
return -ENOEXEC;
}
}
@ -642,7 +642,7 @@ static int cmd_config(const struct shell *sh, size_t argc, char *argv[])
dir = BT_AUDIO_SOURCE;
ep = srcs[index];
} else {
shell_error(sh, "Unsupported type: %s", argv[1]);
shell_error(sh, "Unsupported dir: %s", argv[1]);
return -ENOEXEC;
}
@ -1432,7 +1432,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(audio_cmds,
cmd_term_broadcast_sink, 1, 0),
#endif /* CONFIG_BT_AUDIO_BROADCAST_SINK */
#if defined(CONFIG_BT_AUDIO_UNICAST_CLIENT)
SHELL_CMD_ARG(discover, NULL, "[type: sink, source]",
SHELL_CMD_ARG(discover, NULL, "[dir: sink, source]",
cmd_discover, 1, 1),
SHELL_CMD_ARG(preset, NULL, "[preset]", cmd_preset, 1, 1),
SHELL_CMD_ARG(config, NULL,

View File

@ -100,13 +100,14 @@ static void add_remote_sink(struct bt_audio_ep *ep, uint8_t index)
g_sinks[index] = ep;
}
static void add_remote_codec(struct bt_codec *codec, int index, uint8_t type)
static void add_remote_codec(struct bt_codec *codec, int index,
enum bt_audio_dir dir)
{
printk("#%u: codec %p type 0x%02x\n", index, codec, type);
printk("#%u: codec %p dir 0x%02x\n", index, codec, dir);
print_codec(codec);
if (type != BT_AUDIO_SINK && type != BT_AUDIO_SOURCE) {
if (dir != BT_AUDIO_SINK && dir != BT_AUDIO_SOURCE) {
return;
}
@ -129,17 +130,17 @@ static void discover_sink_cb(struct bt_conn *conn,
}
if (codec != NULL) {
add_remote_codec(codec, params->num_caps, params->type);
add_remote_codec(codec, params->num_caps, params->dir);
codec_found = true;
return;
}
if (ep != NULL) {
if (params->type == BT_AUDIO_SINK) {
if (params->dir == BT_AUDIO_SINK) {
add_remote_sink(ep, params->num_eps);
endpoint_found = true;
} else {
FAIL("Invalid param type: %u\n", params->type);
FAIL("Invalid param dir: %u\n", params->dir);
}
return;
@ -231,7 +232,7 @@ static void discover_sink(void)
int err;
params.func = discover_sink_cb;
params.type = BT_AUDIO_SINK;
params.dir = BT_AUDIO_SINK;
err = bt_audio_discover(default_conn, &params);
if (err != 0) {

View File

@ -34,12 +34,12 @@ CREATE_FLAG(flag_stream_configured);
static struct bt_audio_stream *lc3_config(struct bt_conn *conn,
struct bt_audio_ep *ep,
enum bt_audio_dir type,
enum bt_audio_dir dir,
struct bt_audio_capability *cap,
struct bt_codec *codec)
{
printk("ASE Codec Config: conn %p ep %p type %u, cap %p\n",
conn, ep, type, cap);
printk("ASE Codec Config: conn %p ep %p dir %u, cap %p\n",
conn, ep, dir, cap);
print_codec(codec);
@ -169,7 +169,7 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
static void init(void)
{
static struct bt_audio_capability caps = {
.type = BT_AUDIO_SINK,
.dir = BT_AUDIO_SINK,
.pref = BT_AUDIO_CAPABILITY_PREF(
BT_AUDIO_CAPABILITY_UNFRAMED_SUPPORTED,
BT_GAP_LE_PHY_2M, 0x02, 10, 40000, 40000, 40000, 40000),