diff --git a/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_control.c b/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_control.c index 732ab503f8..814b408c9f 100644 --- a/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_control.c +++ b/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_control.c @@ -1,16 +1,8 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /***************************************************************************** * @@ -33,7 +25,7 @@ #if BTC_AV_INCLUDED typedef struct { - BOOLEAN data_channel_open; + BOOLEAN data_channel_open; /* used only by A2DP sink */ UINT8 a2dp_cmd_pending; /* we can have max one command pending */ } tBTC_AA_CTRL_CB; @@ -83,7 +75,9 @@ static void btc_a2dp_datapath_open(void) btc_a2dp_source_encoder_update(); } #endif +#if (BTC_AV_SINK_INCLUDED == TRUE) btc_aa_ctrl_cb.data_channel_open = TRUE; +#endif } BOOLEAN btc_a2dp_control_get_datachnl_stat(void) @@ -96,22 +90,6 @@ void btc_a2dp_control_set_datachnl_stat(BOOLEAN open) btc_aa_ctrl_cb.data_channel_open = open; } -static void btc_a2dp_dispatch_datapath_evt(uint32_t dp_evt) -{ - btc_msg_t msg; - msg.sig = BTC_SIG_API_CALL; - msg.pid = BTC_PID_A2DP; - msg.act = BTC_AV_DATAPATH_CTRL_EVT; - - btc_av_args_t arg; - memset(&arg, 0, sizeof(btc_av_args_t)); - arg.dp_evt = dp_evt; - - /* Switch to BTC context */ - APPL_TRACE_DEBUG("%s sig %u act %u, dp_evt %u\n", __func__, msg.sig, msg.act, arg.dp_evt); - btc_transfer_context(&msg, &arg, sizeof(btc_av_args_t), NULL); -} - void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl) { APPL_TRACE_DEBUG("BTC MEDIA (A2DP-DATA) EVENT %u", ctrl); @@ -146,17 +124,14 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl) break; case ESP_A2D_MEDIA_CTRL_START: if (btc_av_stream_ready() == TRUE ) { - /* post start event and wait for audio path to open */ + /* post start event */ btc_dispatch_sm_event(BTC_AV_START_STREAM_REQ_EVT, NULL, 0); - - btc_a2dp_dispatch_datapath_evt(BTC_AV_DATAPATH_OPEN_EVT); #if (BTC_AV_SINK_INCLUDED == TRUE) if (btc_av_get_peer_sep() == AVDT_TSEP_SRC && btc_av_get_service_id() == BTA_A2DP_SINK_SERVICE_ID) { btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS); } #endif } else if (btc_av_stream_started_ready()) { - btc_a2dp_dispatch_datapath_evt(BTC_AV_DATAPATH_OPEN_EVT); btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS); } else { btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE); diff --git a/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c b/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c index 8accd9b550..b35ac83fa5 100644 --- a/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c +++ b/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c @@ -1,16 +1,8 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /****************************************************************************** ** @@ -1579,7 +1571,6 @@ static void btc_a2dp_source_thread_init(UNUSED_ATTR void *context) static void btc_a2dp_source_thread_cleanup(UNUSED_ATTR void *context) { - btc_a2dp_control_set_datachnl_stat(FALSE); /* Clear media task flag */ btc_a2dp_source_state = BTC_A2DP_SOURCE_STATE_OFF; diff --git a/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_av.c b/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_av.c index 52003751a2..f198294d50 100644 --- a/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_av.c +++ b/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_av.c @@ -1,16 +1,8 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /***************************************************************************** * @@ -681,6 +673,9 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data) /* pending start flag will be cleared when exit current state */ } #endif /* BTC_AV_SRC_INCLUDED */ + /* wait for audio path to open */ + btc_a2dp_control_datapath_ctrl(BTC_AV_DATAPATH_OPEN_EVT); + btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_STARTED); } break; @@ -1509,10 +1504,6 @@ void btc_a2dp_call_handler(btc_msg_t *msg) btc_a2dp_control_media_ctrl(arg->ctrl); break; } - case BTC_AV_DATAPATH_CTRL_EVT: { - btc_a2dp_control_datapath_ctrl(arg->dp_evt); - break; - } case BTC_AV_CONNECT_REQ_EVT: btc_sm_dispatch(btc_av_cb.sm_handle, msg->act, (char *)msg->arg); break; diff --git a/components/bt/host/bluedroid/btc/profile/std/include/btc_av.h b/components/bt/host/bluedroid/btc/profile/std/include/btc_av.h index 553f0ddec7..c4fd1ac16b 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/btc_av.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/btc_av.h @@ -1,16 +1,8 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /******************************************************************************* @@ -79,7 +71,6 @@ typedef enum { BTC_AV_SRC_API_REG_DATA_CB_EVT, #endif /* BTC_AV_SRC_INCLUDED */ BTC_AV_API_MEDIA_CTRL_EVT, - BTC_AV_DATAPATH_CTRL_EVT, } btc_av_act_t; /* btc_av_args_t */ @@ -104,8 +95,6 @@ typedef union { #endif /* BTC_AV_SRC_INCLUDED */ // BTC_AV_API_MEDIA_CTRL_EVT esp_a2d_media_ctrl_t ctrl; - // BTC_AV_DATAPATH_CTRL_EVT - uint32_t dp_evt; } btc_av_args_t; /*******************************************************************************