From 18ab7ebf220fda158a9b4437aa4cebd26c686ae5 Mon Sep 17 00:00:00 2001 From: Mariusz Skamra Date: Wed, 11 Jan 2023 14:22:39 +0100 Subject: [PATCH] samples: unicast_audio_client: Fix enabling the streams This fixes the application that was not waiting for QoS configuration of all streams in the group. The QoS operation is done on group of streams, while the status of each one of the streams is received separately. Meaning that the application has to control which streams were already configured before enabling them. Signed-off-by: Mariusz Skamra --- samples/bluetooth/unicast_audio_client/src/main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/samples/bluetooth/unicast_audio_client/src/main.c b/samples/bluetooth/unicast_audio_client/src/main.c index 6fefc990203..f7c8a2991f8 100644 --- a/samples/bluetooth/unicast_audio_client/src/main.c +++ b/samples/bluetooth/unicast_audio_client/src/main.c @@ -53,7 +53,7 @@ static K_SEM_DEFINE(sem_security_updated, 0, 1); static K_SEM_DEFINE(sem_sinks_discovered, 0, 1); static K_SEM_DEFINE(sem_sources_discovered, 0, 1); static K_SEM_DEFINE(sem_stream_configured, 0, 1); -static K_SEM_DEFINE(sem_stream_qos, 0, 1); +static K_SEM_DEFINE(sem_stream_qos, 0, ARRAY_SIZE(sinks) + ARRAY_SIZE(sources)); static K_SEM_DEFINE(sem_stream_enabled, 0, 1); static K_SEM_DEFINE(sem_stream_started, 0, 1); @@ -952,10 +952,9 @@ static int set_stream_qos(void) return err; } - err = k_sem_take(&sem_stream_qos, K_FOREVER); - if (err != 0) { - printk("failed to take sem_stream_qos (err %d)\n", err); - return err; + for (size_t i = 0U; i < configured_stream_count; i++) { + printk("QoS: waiting for %zu streams\n", configured_stream_count); + k_sem_take(&sem_stream_qos, K_FOREVER); } return 0;