@@ -40,7 +40,6 @@ BUILD_ASSERT(CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT > 0 ||
4040LOG_MODULE_REGISTER (bt_bap_unicast_client , CONFIG_BT_BAP_UNICAST_CLIENT_LOG_LEVEL );
4141
4242#define PAC_DIR_UNUSED (dir ) ((dir) != BT_AUDIO_DIR_SINK && (dir) != BT_AUDIO_DIR_SOURCE)
43-
4443struct bt_bap_unicast_client_ep {
4544 uint16_t handle ;
4645 uint16_t cp_handle ;
@@ -162,44 +161,6 @@ static int unicast_client_send_start(struct bt_bap_ep *ep)
162161
163162static int unicast_client_ep_idle_state (struct bt_bap_ep * ep );
164163
165- /** Checks if the stream can terminate the CIS
166- *
167- * If the CIS is used for another stream, or if the CIS is not in the connected
168- * state it will return false.
169- */
170- static bool unicast_client_can_disconnect_stream (const struct bt_bap_stream * stream )
171- {
172- const struct bt_bap_ep * stream_ep ;
173- enum bt_iso_state iso_state ;
174-
175- if (stream == NULL ) {
176- return false;
177- }
178-
179- stream_ep = stream -> ep ;
180-
181- if (stream_ep == NULL || stream_ep -> iso == NULL ) {
182- return false;
183- }
184-
185- iso_state = stream_ep -> iso -> chan .state ;
186-
187- if (iso_state == BT_ISO_STATE_CONNECTED || iso_state == BT_ISO_STATE_CONNECTING ) {
188- const struct bt_bap_ep * pair_ep ;
189-
190- pair_ep = bt_bap_iso_get_paired_ep (stream_ep );
191-
192- /* If there are no paired endpoint, or the paired endpoint is
193- * not in the streaming state, we can disconnect the CIS
194- */
195- if (pair_ep == NULL || pair_ep -> status .state != BT_BAP_EP_STATE_STREAMING ) {
196- return true;
197- }
198- }
199-
200- return false;
201- }
202-
203164static struct bt_bap_stream * audio_stream_by_ep_id (const struct bt_conn * conn ,
204165 uint8_t id )
205166{
@@ -581,7 +542,7 @@ static int unicast_client_ep_idle_state(struct bt_bap_ep *ep)
581542 }
582543
583544 /* If CIS is connected, disconnect and wait for CIS disconnection */
584- if (unicast_client_can_disconnect_stream (stream )) {
545+ if (bt_bap_stream_can_disconnect (stream )) {
585546 int err ;
586547
587548 LOG_DBG ("Disconnecting stream" );
@@ -652,11 +613,19 @@ static void unicast_client_ep_qos_update(struct bt_bap_ep *ep,
652613
653614static void unicast_client_ep_config_state (struct bt_bap_ep * ep , struct net_buf_simple * buf )
654615{
616+ struct bt_bap_unicast_client_ep * client_ep =
617+ CONTAINER_OF (ep , struct bt_bap_unicast_client_ep , ep );
655618 struct bt_ascs_ase_status_config * cfg ;
656619 struct bt_codec_qos_pref * pref ;
657620 struct bt_bap_stream * stream ;
658621 void * cc ;
659622
623+ if (client_ep -> release_requested ) {
624+ LOG_DBG ("Released was requested, change local state to idle" );
625+ ep -> status .state = BT_BAP_EP_STATE_IDLE ;
626+ unicast_client_ep_idle_state (ep );
627+ }
628+
660629 if (buf -> len < sizeof (* cfg )) {
661630 LOG_ERR ("Config status too short" );
662631 return ;
@@ -768,7 +737,7 @@ static void unicast_client_ep_qos_state(struct bt_bap_ep *ep, struct net_buf_sim
768737 stream -> qos -> latency , stream -> qos -> pd );
769738
770739 /* Disconnect ISO if connected */
771- if (unicast_client_can_disconnect_stream (stream )) {
740+ if (bt_bap_stream_can_disconnect (stream )) {
772741 const int err = bt_bap_stream_disconnect (stream );
773742
774743 if (err != 0 ) {
@@ -931,7 +900,7 @@ static void unicast_client_ep_releasing_state(struct bt_bap_ep *ep, struct net_b
931900
932901 LOG_DBG ("dir %s" , bt_audio_dir_str (ep -> dir ));
933902
934- if (unicast_client_can_disconnect_stream (stream )) {
903+ if (bt_bap_stream_can_disconnect (stream )) {
935904 /* The Unicast Client shall terminate any CIS established for
936905 * that ASE by following the Connected Isochronous Stream
937906 * Terminate procedure defined in Volume 3, Part C,
0 commit comments