@@ -40,7 +40,6 @@ BUILD_ASSERT(CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT > 0 ||
40
40
LOG_MODULE_REGISTER (bt_bap_unicast_client , CONFIG_BT_BAP_UNICAST_CLIENT_LOG_LEVEL );
41
41
42
42
#define PAC_DIR_UNUSED (dir ) ((dir) != BT_AUDIO_DIR_SINK && (dir) != BT_AUDIO_DIR_SOURCE)
43
-
44
43
struct bt_bap_unicast_client_ep {
45
44
uint16_t handle ;
46
45
uint16_t cp_handle ;
@@ -162,44 +161,6 @@ static int unicast_client_send_start(struct bt_bap_ep *ep)
162
161
163
162
static int unicast_client_ep_idle_state (struct bt_bap_ep * ep );
164
163
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
-
203
164
static struct bt_bap_stream * audio_stream_by_ep_id (const struct bt_conn * conn ,
204
165
uint8_t id )
205
166
{
@@ -581,7 +542,7 @@ static int unicast_client_ep_idle_state(struct bt_bap_ep *ep)
581
542
}
582
543
583
544
/* 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 )) {
585
546
int err ;
586
547
587
548
LOG_DBG ("Disconnecting stream" );
@@ -652,11 +613,19 @@ static void unicast_client_ep_qos_update(struct bt_bap_ep *ep,
652
613
653
614
static void unicast_client_ep_config_state (struct bt_bap_ep * ep , struct net_buf_simple * buf )
654
615
{
616
+ struct bt_bap_unicast_client_ep * client_ep =
617
+ CONTAINER_OF (ep , struct bt_bap_unicast_client_ep , ep );
655
618
struct bt_ascs_ase_status_config * cfg ;
656
619
struct bt_codec_qos_pref * pref ;
657
620
struct bt_bap_stream * stream ;
658
621
void * cc ;
659
622
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
+
660
629
if (buf -> len < sizeof (* cfg )) {
661
630
LOG_ERR ("Config status too short" );
662
631
return ;
@@ -768,7 +737,7 @@ static void unicast_client_ep_qos_state(struct bt_bap_ep *ep, struct net_buf_sim
768
737
stream -> qos -> latency , stream -> qos -> pd );
769
738
770
739
/* Disconnect ISO if connected */
771
- if (unicast_client_can_disconnect_stream (stream )) {
740
+ if (bt_bap_stream_can_disconnect (stream )) {
772
741
const int err = bt_bap_stream_disconnect (stream );
773
742
774
743
if (err != 0 ) {
@@ -931,7 +900,7 @@ static void unicast_client_ep_releasing_state(struct bt_bap_ep *ep, struct net_b
931
900
932
901
LOG_DBG ("dir %s" , bt_audio_dir_str (ep -> dir ));
933
902
934
- if (unicast_client_can_disconnect_stream (stream )) {
903
+ if (bt_bap_stream_can_disconnect (stream )) {
935
904
/* The Unicast Client shall terminate any CIS established for
936
905
* that ASE by following the Connected Isochronous Stream
937
906
* Terminate procedure defined in Volume 3, Part C,
0 commit comments