diff mbox series

[BlueZ,v1,2/2] a2dp: Reject connection when the channel limit is exceeded

Message ID 20240129204154.95773-3-VAnPushkarev@salutedevices.com
State New
Headers show
Series Introduce option to limit A2DP channels | expand

Commit Message

Victor Pushkarev Jan. 29, 2024, 8:41 p.m. UTC
Reject incoming connection when the configured limit
for A2DP channels is exceeded.

Signed-off-by: Victor Pushkarev <VAnPushkarev@salutedevices.com>
---
 profiles/audio/a2dp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index b43161a13..117b27db3 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -2549,6 +2549,14 @@  static void confirm_cb(GIOChannel *io, gpointer data)
 	if (!chan)
 		goto drop;
 
+	if (btd_opts.a2dp.channels &&
+				queue_length(server->channels) > btd_opts.a2dp.channels) {
+		device_request_disconnect(device, NULL);
+		DBG("Reject current connection, A2DP channel limit exceeded: %d",
+						btd_opts.a2dp.channels);
+		goto drop;
+	}
+
 	chan->auth_id = btd_request_authorization(&src, &dst,
 							ADVANCED_AUDIO_UUID,
 							auth_cb, chan);