Bluetooth: Audio: Use endpoint dir value
Remove functions and and macro uses that otherwise determined the direction of an audio stream, and instead use the direction (dir) field of the endpoint instead. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
b880637231
commit
23c1d6c3da
4 changed files with 21 additions and 53 deletions
|
@ -143,7 +143,7 @@ static void ascs_ep_get_status_config(struct bt_audio_ep *ep,
|
||||||
|
|
||||||
BT_DBG("dir 0x%02x unframed_supported 0x%02x phy 0x%02x rtn %u "
|
BT_DBG("dir 0x%02x unframed_supported 0x%02x phy 0x%02x rtn %u "
|
||||||
"latency %u pd_min %u pd_max %u codec 0x%02x",
|
"latency %u pd_min %u pd_max %u codec 0x%02x",
|
||||||
ASE_DIR(ep->status.id), pref->unframed_supported, pref->phy,
|
ep->dir, pref->unframed_supported, pref->phy,
|
||||||
pref->rtn, pref->latency, pref->pd_min, pref->pd_max,
|
pref->rtn, pref->latency, pref->pd_min, pref->pd_max,
|
||||||
ep->stream->codec->id);
|
ep->stream->codec->id);
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ static void ascs_ep_get_status_qos(struct bt_audio_ep *ep,
|
||||||
|
|
||||||
BT_DBG("dir 0x%02x codec 0x%02x interval %u framing 0x%02x phy 0x%02x "
|
BT_DBG("dir 0x%02x codec 0x%02x interval %u framing 0x%02x phy 0x%02x "
|
||||||
"rtn %u latency %u pd %u",
|
"rtn %u latency %u pd %u",
|
||||||
ASE_DIR(ep->status.id), ep->stream->codec->id,
|
ep->dir, ep->stream->codec->id,
|
||||||
ep->stream->qos->interval, ep->stream->qos->framing,
|
ep->stream->qos->interval, ep->stream->qos->framing,
|
||||||
ep->stream->qos->phy, ep->stream->qos->rtn,
|
ep->stream->qos->phy, ep->stream->qos->rtn,
|
||||||
ep->stream->qos->latency, ep->stream->qos->pd);
|
ep->stream->qos->latency, ep->stream->qos->pd);
|
||||||
|
@ -190,7 +190,7 @@ static void ascs_ep_get_status_enable(struct bt_audio_ep *ep,
|
||||||
enable->metadata_len = buf->len - enable->metadata_len;
|
enable->metadata_len = buf->len - enable->metadata_len;
|
||||||
|
|
||||||
BT_DBG("dir 0x%02x cig 0x%02x cis 0x%02x",
|
BT_DBG("dir 0x%02x cig 0x%02x cis 0x%02x",
|
||||||
ASE_DIR(ep->status.id), ep->cig_id, ep->cis_id);
|
ep->dir, ep->cig_id, ep->cis_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ascs_ep_get_status(struct bt_audio_ep *ep,
|
static int ascs_ep_get_status(struct bt_audio_ep *ep,
|
||||||
|
@ -516,7 +516,7 @@ static void ase_disable(struct bt_ascs_ase *ase)
|
||||||
/* The ASE state machine goes into different states from this operation
|
/* The ASE state machine goes into different states from this operation
|
||||||
* based on whether it is a source or a sink ASE.
|
* based on whether it is a source or a sink ASE.
|
||||||
*/
|
*/
|
||||||
if (ASE_DIR(ep->status.id) == BT_AUDIO_SOURCE) {
|
if (ep->dir == BT_AUDIO_SOURCE) {
|
||||||
ascs_ep_set_state(ep, BT_AUDIO_EP_STATE_DISABLING);
|
ascs_ep_set_state(ep, BT_AUDIO_EP_STATE_DISABLING);
|
||||||
} else {
|
} else {
|
||||||
ascs_ep_set_state(ep, BT_AUDIO_EP_STATE_QOS_CONFIGURED);
|
ascs_ep_set_state(ep, BT_AUDIO_EP_STATE_QOS_CONFIGURED);
|
||||||
|
@ -973,7 +973,7 @@ static int ase_config(struct bt_ascs *ascs, struct bt_ascs_ase *ase,
|
||||||
if (unicast_server_cb != NULL &&
|
if (unicast_server_cb != NULL &&
|
||||||
unicast_server_cb->reconfig != NULL) {
|
unicast_server_cb->reconfig != NULL) {
|
||||||
err = unicast_server_cb->reconfig(ase->ep.stream,
|
err = unicast_server_cb->reconfig(ase->ep.stream,
|
||||||
ASE_DIR(ase->ep.status.id),
|
ase->ep.dir,
|
||||||
&ase->ep.codec,
|
&ase->ep.codec,
|
||||||
&ase->ep.qos_pref);
|
&ase->ep.qos_pref);
|
||||||
} else {
|
} else {
|
||||||
|
@ -998,7 +998,7 @@ static int ase_config(struct bt_ascs *ascs, struct bt_ascs_ase *ase,
|
||||||
if (unicast_server_cb != NULL &&
|
if (unicast_server_cb != NULL &&
|
||||||
unicast_server_cb->config != NULL) {
|
unicast_server_cb->config != NULL) {
|
||||||
err = unicast_server_cb->config(ascs->conn, &ase->ep,
|
err = unicast_server_cb->config(ascs->conn, &ase->ep,
|
||||||
ASE_DIR(ase->ep.status.id),
|
ase->ep.dir,
|
||||||
&ase->ep.codec, &stream,
|
&ase->ep.codec, &stream,
|
||||||
&ase->ep.qos_pref);
|
&ase->ep.qos_pref);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1439,7 +1439,7 @@ static int ase_enable(struct bt_ascs_ase *ase, struct bt_ascs_metadata *meta,
|
||||||
ascs_ep_set_state(ep, BT_AUDIO_EP_STATE_ENABLING);
|
ascs_ep_set_state(ep, BT_AUDIO_EP_STATE_ENABLING);
|
||||||
|
|
||||||
|
|
||||||
if (ASE_DIR(ep->status.id) == BT_AUDIO_SINK) {
|
if (ep->dir == BT_AUDIO_SINK) {
|
||||||
/* SINK ASEs can autonomously go into the streaming state if
|
/* SINK ASEs can autonomously go into the streaming state if
|
||||||
* the CIS is connected
|
* the CIS is connected
|
||||||
*/
|
*/
|
||||||
|
@ -1526,7 +1526,7 @@ static void ase_start(struct bt_ascs_ase *ase)
|
||||||
* characteristic to the client, and the server shall set the
|
* characteristic to the client, and the server shall set the
|
||||||
* Response_Code value for that ASE to 0x05 (Invalid ASE direction).
|
* Response_Code value for that ASE to 0x05 (Invalid ASE direction).
|
||||||
*/
|
*/
|
||||||
if (ASE_DIR(ep->status.id) == BT_AUDIO_SINK) {
|
if (ep->dir == BT_AUDIO_SINK) {
|
||||||
BT_ERR("Start failed: invalid operation for Sink");
|
BT_ERR("Start failed: invalid operation for Sink");
|
||||||
ascs_cp_rsp_add(ASE_ID(ase), BT_ASCS_START_OP,
|
ascs_cp_rsp_add(ASE_ID(ase), BT_ASCS_START_OP,
|
||||||
BT_ASCS_RSP_INVALID_DIR, BT_ASCS_REASON_NONE);
|
BT_ASCS_RSP_INVALID_DIR, BT_ASCS_REASON_NONE);
|
||||||
|
@ -1650,7 +1650,7 @@ static void ase_stop(struct bt_ascs_ase *ase)
|
||||||
* characteristic to the client, and the server shall set the
|
* characteristic to the client, and the server shall set the
|
||||||
* Response_Code value for that ASE to 0x05 (Invalid ASE direction).
|
* Response_Code value for that ASE to 0x05 (Invalid ASE direction).
|
||||||
*/
|
*/
|
||||||
if (ASE_DIR(ase->ep.status.id) == BT_AUDIO_SINK) {
|
if (ase->ep.dir == BT_AUDIO_SINK) {
|
||||||
BT_ERR("Stop failed: invalid operation for Sink");
|
BT_ERR("Stop failed: invalid operation for Sink");
|
||||||
ascs_cp_rsp_add(ASE_ID(ase), BT_ASCS_STOP_OP,
|
ascs_cp_rsp_add(ASE_ID(ase), BT_ASCS_STOP_OP,
|
||||||
BT_ASCS_RSP_INVALID_DIR, BT_ASCS_REASON_NONE);
|
BT_ASCS_RSP_INVALID_DIR, BT_ASCS_REASON_NONE);
|
||||||
|
|
|
@ -676,7 +676,7 @@ int bt_audio_stream_enable(struct bt_audio_stream *stream,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bt_unicast_client_ep_is_src(stream->ep)) {
|
if (stream->ep->dir == BT_AUDIO_SOURCE) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -779,7 +779,7 @@ int bt_audio_stream_disable(struct bt_audio_stream *stream)
|
||||||
|
|
||||||
bt_unicast_client_ep_set_state(stream->ep, BT_AUDIO_EP_STATE_DISABLING);
|
bt_unicast_client_ep_set_state(stream->ep, BT_AUDIO_EP_STATE_DISABLING);
|
||||||
|
|
||||||
if (bt_unicast_client_ep_is_src(stream->ep)) {
|
if (stream->ep->dir == BT_AUDIO_SOURCE) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,30 +210,6 @@ static struct bt_audio_ep *unicast_client_ep_new(struct bt_conn *conn,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool unicast_client_ep_is_snk(const struct bt_audio_ep *ep)
|
|
||||||
{
|
|
||||||
#if SNK_SIZE > 0
|
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(snks); i++) {
|
|
||||||
if (PART_OF_ARRAY(snks[i], ep)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* SNK_SIZE > 0 */
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bt_unicast_client_ep_is_src(const struct bt_audio_ep *ep)
|
|
||||||
{
|
|
||||||
#if SRC_SIZE > 0
|
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(srcs); i++) {
|
|
||||||
if (PART_OF_ARRAY(srcs[i], ep)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* SRC_SIZE > 0 */
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct bt_audio_ep *unicast_client_ep_get(struct bt_conn *conn,
|
static struct bt_audio_ep *unicast_client_ep_get(struct bt_conn *conn,
|
||||||
uint8_t dir, uint16_t handle)
|
uint8_t dir, uint16_t handle)
|
||||||
{
|
{
|
||||||
|
@ -319,9 +295,8 @@ static void unicast_client_ep_config_state(struct bt_audio_ep *ep,
|
||||||
|
|
||||||
BT_DBG("dir 0x%02x unframed_supported 0x%02x phy 0x%02x rtn %u "
|
BT_DBG("dir 0x%02x unframed_supported 0x%02x phy 0x%02x rtn %u "
|
||||||
"latency %u pd_min %u pd_max %u codec 0x%02x ",
|
"latency %u pd_min %u pd_max %u codec 0x%02x ",
|
||||||
unicast_client_ep_is_snk(ep) ? BT_AUDIO_SINK : BT_AUDIO_SOURCE,
|
ep->dir, pref->unframed_supported, pref->phy, pref->rtn,
|
||||||
pref->unframed_supported, pref->phy, pref->rtn, pref->latency,
|
pref->latency, pref->pd_min, pref->pd_max, stream->codec->id);
|
||||||
pref->pd_min, pref->pd_max, stream->codec->id);
|
|
||||||
|
|
||||||
unicast_client_ep_set_codec(ep, cfg->codec.id,
|
unicast_client_ep_set_codec(ep, cfg->codec.id,
|
||||||
sys_le16_to_cpu(cfg->codec.cid),
|
sys_le16_to_cpu(cfg->codec.cid),
|
||||||
|
@ -369,8 +344,7 @@ static void unicast_client_ep_qos_state(struct bt_audio_ep *ep,
|
||||||
|
|
||||||
BT_DBG("dir 0x%02x cig 0x%02x cis 0x%02x codec 0x%02x interval %u "
|
BT_DBG("dir 0x%02x cig 0x%02x cis 0x%02x codec 0x%02x interval %u "
|
||||||
"framing 0x%02x phy 0x%02x rtn %u latency %u pd %u",
|
"framing 0x%02x phy 0x%02x rtn %u latency %u pd %u",
|
||||||
unicast_client_ep_is_snk(ep) ? BT_AUDIO_SINK : BT_AUDIO_SOURCE,
|
ep->dir, ep->cig_id, ep->cis_id, stream->codec->id,
|
||||||
ep->cig_id, ep->cis_id, stream->codec->id,
|
|
||||||
stream->qos->interval, stream->qos->framing,
|
stream->qos->interval, stream->qos->framing,
|
||||||
stream->qos->phy, stream->qos->rtn, stream->qos->latency,
|
stream->qos->phy, stream->qos->rtn, stream->qos->latency,
|
||||||
stream->qos->pd);
|
stream->qos->pd);
|
||||||
|
@ -408,8 +382,7 @@ static void unicast_client_ep_enabling_state(struct bt_audio_ep *ep,
|
||||||
enable = net_buf_simple_pull_mem(buf, sizeof(*enable));
|
enable = net_buf_simple_pull_mem(buf, sizeof(*enable));
|
||||||
|
|
||||||
BT_DBG("dir 0x%02x cig 0x%02x cis 0x%02x",
|
BT_DBG("dir 0x%02x cig 0x%02x cis 0x%02x",
|
||||||
unicast_client_ep_is_snk(ep) ? BT_AUDIO_SINK : BT_AUDIO_SOURCE,
|
ep->dir, ep->cig_id, ep->cis_id);
|
||||||
ep->cig_id, ep->cis_id);
|
|
||||||
|
|
||||||
unicast_client_ep_set_metadata(ep, buf, enable->metadata_len, NULL);
|
unicast_client_ep_set_metadata(ep, buf, enable->metadata_len, NULL);
|
||||||
|
|
||||||
|
@ -441,8 +414,7 @@ static void unicast_client_ep_streaming_state(struct bt_audio_ep *ep,
|
||||||
stream_status = net_buf_simple_pull_mem(buf, sizeof(*stream_status));
|
stream_status = net_buf_simple_pull_mem(buf, sizeof(*stream_status));
|
||||||
|
|
||||||
BT_DBG("dir 0x%02x cig 0x%02x cis 0x%02x",
|
BT_DBG("dir 0x%02x cig 0x%02x cis 0x%02x",
|
||||||
unicast_client_ep_is_snk(ep) ? BT_AUDIO_SINK : BT_AUDIO_SOURCE,
|
ep->dir, ep->cig_id, ep->cis_id);
|
||||||
ep->cig_id, ep->cis_id);
|
|
||||||
|
|
||||||
/* Notify upper layer */
|
/* Notify upper layer */
|
||||||
if (stream->ops != NULL && stream->ops->started != NULL) {
|
if (stream->ops != NULL && stream->ops->started != NULL) {
|
||||||
|
@ -472,8 +444,7 @@ static void unicast_client_ep_disabling_state(struct bt_audio_ep *ep,
|
||||||
disable = net_buf_simple_pull_mem(buf, sizeof(*disable));
|
disable = net_buf_simple_pull_mem(buf, sizeof(*disable));
|
||||||
|
|
||||||
BT_DBG("dir 0x%02x cig 0x%02x cis 0x%02x",
|
BT_DBG("dir 0x%02x cig 0x%02x cis 0x%02x",
|
||||||
unicast_client_ep_is_snk(ep) ? BT_AUDIO_SINK : BT_AUDIO_SOURCE,
|
ep->dir, ep->cig_id, ep->cis_id);
|
||||||
ep->cig_id, ep->cis_id);
|
|
||||||
|
|
||||||
/* Notify upper layer */
|
/* Notify upper layer */
|
||||||
if (stream->ops != NULL && stream->ops->disabled != NULL) {
|
if (stream->ops != NULL && stream->ops->disabled != NULL) {
|
||||||
|
@ -494,8 +465,7 @@ static void unicast_client_ep_releasing_state(struct bt_audio_ep *ep,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BT_DBG("dir 0x%02x",
|
BT_DBG("dir 0x%02x", ep->dir);
|
||||||
unicast_client_ep_is_snk(ep) ? BT_AUDIO_SINK : BT_AUDIO_SOURCE);
|
|
||||||
|
|
||||||
/* The Unicast Client shall terminate any CIS established for that ASE
|
/* The Unicast Client shall terminate any CIS established for that ASE
|
||||||
* by following the Connected Isochronous Stream Terminate procedure
|
* by following the Connected Isochronous Stream Terminate procedure
|
||||||
|
@ -1013,8 +983,7 @@ static int unicast_client_ep_config(struct bt_audio_ep *ep,
|
||||||
}
|
}
|
||||||
|
|
||||||
BT_DBG("id 0x%02x dir 0x%02x codec 0x%02x", ep->status.id,
|
BT_DBG("id 0x%02x dir 0x%02x codec 0x%02x", ep->status.id,
|
||||||
unicast_client_ep_is_snk(ep) ? BT_AUDIO_SINK : BT_AUDIO_SOURCE,
|
ep->dir, codec->id);
|
||||||
codec->id);
|
|
||||||
|
|
||||||
req = net_buf_simple_add(buf, sizeof(*req));
|
req = net_buf_simple_add(buf, sizeof(*req));
|
||||||
req->ase = ep->status.id;
|
req->ase = ep->status.id;
|
||||||
|
@ -1438,7 +1407,7 @@ int bt_unicast_client_start(struct bt_audio_stream *stream)
|
||||||
/* When initiated by the client, valid only if Direction field
|
/* When initiated by the client, valid only if Direction field
|
||||||
* parameter value = 0x02 (Server is Audio Source)
|
* parameter value = 0x02 (Server is Audio Source)
|
||||||
*/
|
*/
|
||||||
if (bt_unicast_client_ep_is_src(ep)) {
|
if (ep->dir == BT_AUDIO_SOURCE) {
|
||||||
err = unicast_client_ep_start(ep, buf);
|
err = unicast_client_ep_start(ep, buf);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
|
@ -1490,7 +1459,7 @@ int bt_unicast_client_stop(struct bt_audio_stream *stream)
|
||||||
/* When initiated by the client, valid only if Direction field
|
/* When initiated by the client, valid only if Direction field
|
||||||
* parameter value = 0x02 (Server is Audio Source)
|
* parameter value = 0x02 (Server is Audio Source)
|
||||||
*/
|
*/
|
||||||
if (bt_unicast_client_ep_is_src(ep)) {
|
if (ep->dir == BT_AUDIO_SOURCE) {
|
||||||
err = unicast_client_ep_stop(ep, buf);
|
err = unicast_client_ep_stop(ep, buf);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -25,7 +25,6 @@ int bt_unicast_client_stop(struct bt_audio_stream *stream);
|
||||||
|
|
||||||
int bt_unicast_client_release(struct bt_audio_stream *stream);
|
int bt_unicast_client_release(struct bt_audio_stream *stream);
|
||||||
|
|
||||||
bool bt_unicast_client_ep_is_src(const struct bt_audio_ep *ep);
|
|
||||||
|
|
||||||
void bt_unicast_client_ep_set_state(struct bt_audio_ep *ep, uint8_t state);
|
void bt_unicast_client_ep_set_state(struct bt_audio_ep *ep, uint8_t state);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue