Introduce option to limit A2DP channels
cover Introduce option to limit A2DP channels
This patch adds feature to limit the number of active A2DP connections.
This may be necessary to prevent audio mixing problem when playing from multiple sources using A2DP profile.
Victor Pushkarev (2):
main.conf: Introduce option to limit A2DP channels
a2dp: Reject connection when the channel limit is exceeded
profiles/audio/a2dp.c | 8 ++++++++ src/btd.h | 6 ++++++ src/main.c | 16 ++++++++++++++++ src/main.conf | 5 +++++ 4 files changed, 35 insertions(+)
Signature · 1 line
2.39.3 (Apple Git-145)
PATCH 1/2 main.conf: Introduce option to limit A2DP channels
This introduces Channels which can be used to
limit the number of A2DP channels.
For new option this also adds a new group A2DP to config.
--- src/btd.h | 6 ++++++ src/main.c | 16 ++++++++++++++++ src/main.conf | 5 +++++ 3 files changed, 27 insertions(+)
src/btd.h +6 -0
@@ -104,6 +104,10 @@ struct btd_avdtp_opts {uint8_t stream_mode; }; +struct btd_a2dp_opts { +uint8_t channels; +}; +struct btd_advmon_opts {uint8_t rssi_sampling_period; };
@@ -148,6 +152,8 @@ struct btd_opts {enum jw_repairing_t jw_repairing; +struct btd_a2dp_opts a2dp; +struct btd_advmon_opts advmon;struct btd_csis csis;
src/main.c +16 -0
@@ -162,6 +162,11 @@ static const char *avdtp_options[] = {NULL }; +static const char *a2dp_options[] = { +"Channels" , +NULL +}; +static const char *advmon_options[] = {"RSSISamplingPeriod" ,NULL
@@ -178,6 +183,7 @@ static const struct group_table { { "GATT", gatt_options }, { "CSIS", csip_options }, { "AVDTP", avdtp_options }, + { "A2DP", a2dp_options }, { "AdvMon", advmon_options }, { } };
@@ -1130,6 +1136,13 @@ static void parse_avdtp(GKeyFile *config)parse_avdtp_stream_mode (config); } +static void parse_a2dp (GKeyFile *config) +{ +parse_config_u8 (config,"A2DP" ,"Channels" , + &btd_opts.a2dp.channels, +0 ,UINT8_MAX ); +} +static void parse_advmon (GKeyFile *config) { parse_config_u8(config, "AdvMon", "RSSISamplingPeriod",
@@ -1153,6 +1166,7 @@ static void parse_config(GKeyFile *config)parse_gatt (config);parse_csis (config);parse_avdtp (config); +parse_a2dp (config);parse_advmon (config); }
@@ -1194,6 +1208,8 @@ static void init_defaults(void) btd_opts.avdtp.session_mode =BT_IO_MODE_BASIC ; btd_opts.avdtp.stream_mode =BT_IO_MODE_BASIC ; + btd_opts.a2dp.channels =0 ; + btd_opts.advmon.rssi_sampling_period =0xFF ; btd_opts.csis.encrypt = true; }
src/main.conf +5 -0
@@ -296,6 +296,11 @@ # streaming: Use L2CAP Streaming Mode #StreamMode = basic +[A2DP] +# Maximum number of A2DP channels +# Defaults to 0 (unlimited) +#Channels = 0 + [Policy] # # The ReconnectUUIDs defines the set of remote services that should try
Signature · 1 line
2.39.3 (Apple Git-145)
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=821056
---Test result---
Test Summary:
CheckPatch FAIL 1.20 seconds GitLint PASS 0.64 seconds BuildEll PASS 24.30 seconds BluezMake PASS 744.06 seconds MakeCheck PASS 11.58 seconds MakeDistcheck PASS 164.00 seconds CheckValgrind PASS 227.32 seconds CheckSmatch PASS 333.77 seconds bluezmakeextell PASS 109.57 seconds IncrementalBuild PASS 1374.21 seconds ScanBuild PASS 955.44 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,v1,1/2] main.conf: Introduce option to limit A2DP channels WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const #145: FILE: src/main.c:165:
+static const char *a2dp_options[] = {
/github/workspace/src/src/13536361.patch total: 0 errors, 1 warnings, 75 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/src/13536361.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
[BlueZ,v1,2/2] a2dp: Reject connection when the channel limit is exceeded WARNING:LONG_LINE: line length of 90 exceeds 80 columns
#118: FILE: profiles/audio/a2dp.c:2553:
+ queue_length(server->channels) > btd_opts.a2dp.channels) {
WARNING:LONG_LINE_STRING: line length of 81 exceeds 80 columns #120: FILE: profiles/audio/a2dp.c:2555:
+ DBG("Reject current connection, A2DP channel limit exceeded: %d",
/github/workspace/src/src/13536360.patch total: 0 errors, 2 warnings, 14 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/src/13536360.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
---
Regards,
Linux Bluetooth
PATCH 2/2 a2dp: Reject connection when the channel limit is exceeded
In reply to Victor PushkarevReject incoming connection when the configured limit for A2DP channels is exceeded.
--- profiles/audio/a2dp.c | 8 ++++++++ 1 file changed, 8 insertions(+)
profiles/audio/a2dp.c +8 -0
@@ -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);
Signature · 1 line
2.39.3 (Apple Git-145)
Re: [PATCH BlueZ v1 2/2] a2dp: Reject connection when the channel limit is exceeded
Hi,
Quoted 14 lines · Victor Pushkarev
Reject incoming connection when the configured limit for A2DP channels is exceeded.
Signed-off-by Victor Pushkarev <[email protected]>--- profiles/audio/a2dp.c | 8 ++++++++ 1 file changed, 8 insertions(+)profiles/audio/a2dp.c +0
-0
profiles/audio/a2dp.c static void confirm_cb(GIOChannel *io, gpointer data) · line 2558
Quoted 10 lines
profiles/audio/a2dp.c +7
-0@@ -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; + }
NAK, this is the wrong layer to do this, it is up to the MediaEndpoint implementation to tell how many streams it can handle.
Quoted 7 lines
profiles/audio/a2dp.c +0
-1chan->auth_id =btd_request_authorization (&src, &dst,ADVANCED_AUDIO_UUID , auth_cb, chan); --2.39.3 (Apple Git-145)
Signature · 1 line
Luiz Augusto von Dentz