a2dp: Remove Endpoints cache entries on device removal
PATCH 1/1 a2dp: Remove Endpoints cache entries on device removal
When a device is removed, currently the endpoints and last used info are kept in cache:
[General]
Name=Frederic's Phone
[Endpoints]
01=00:00:01:29f50235
02=00:02:01:80010484e200
LastUsed=01:02
This may prevent future connection, after a new pairing, to use the best codec available.
--- profiles/audio/a2dp.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
profiles/audio/a2dp.c +40 -0
@@ -880,6 +880,44 @@ static void store_remote_seps(struct a2dp_channel *chan)g_key_file_free (key_file); } +static void remove_endpoints_cache (struct btd_service *service) +{ +struct btd_device *device =btd_service_get_device (service); +char filename[PATH_MAX ]; +char dst_addr[18 ]; +GKeyFile *key_file; +GError *gerr =NULL ; +char *data; +gsize length =0 ; + +ba2str (device_get_address (device), dst_addr); + +create_filename (filename,PATH_MAX ,"/%s/cache/%s" , +btd_adapter_get_storage_dir (device_get_adapter (device)), + dst_addr); + + key_file =g_key_file_new (); +if (!g_key_file_load_from_file (key_file, filename,0 , &gerr)) { +g_error_free (gerr); +g_key_file_free (key_file); +return ; + } +g_key_file_remove_group (key_file,"Endpoints" ,NULL ); + + data =g_key_file_to_data (key_file, &length,NULL ); +if (length >0 ) { +create_file (filename,0600 ); +if (!g_file_set_contents (filename, data, length, &gerr)) { +error ("Unable set contents for %s: (%s)" , filename, + gerr->message); +g_error_free (gerr); + } + } + +g_free (data); +g_key_file_free (key_file); +} +static void invalidate_remote_cache (struct a2dp_setup *setup,struct avdtp_error *err) {
@@ -3352,6 +3390,7 @@ static int a2dp_source_probe(struct btd_service *service)static void a2dp_source_remove (struct btd_service *service) {source_unregister (service); +remove_endpoints_cache (service); }static int a2dp_sink_probe (struct btd_service *service)
@@ -3366,6 +3405,7 @@ static int a2dp_sink_probe(struct btd_service *service)static void a2dp_sink_remove (struct btd_service *service) {sink_unregister (service); +remove_endpoints_cache (service); }static int a2dp_source_connect (struct btd_service *service)
Signature · 1 line
2.43.0
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=934674
---Test result---
Test Summary:
CheckPatch PENDING 0.46 seconds GitLint PENDING 0.31 seconds BuildEll PASS 20.67 seconds BluezMake PASS 1595.63 seconds MakeCheck PASS 39.34 seconds MakeDistcheck PASS 161.52 seconds CheckValgrind PASS 215.86 seconds CheckSmatch PASS 286.32 seconds bluezmakeextell PASS 102.52 seconds IncrementalBuild PENDING 0.38 seconds ScanBuild PASS 897.58 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 11 lines · On Mon, 17 Feb 2025 12:48:02 +0100 you wrote:
When a device is removed, currently the endpoints and last used info are kept in cache:
[General]
Name=Frederic's Phone[Endpoints]
01=00:00:01:29f50235
02=00:02:01:80010484e200
LastUsed=01:02[...]
Here is the summary with links:
- [BlueZ] a2dp: Remove Endpoints cache entries on device removal
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=ea3f4047e452
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html