[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] bluetooth: Fix unregistering of the message handler

PulseAudio Marge Bot gitlab at gitlab.freedesktop.org
Thu Jan 21 13:54:09 UTC 2021



PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio


Commits:
8816b6b0 by Sanchayan Maity at 2021-01-21T18:41:25+05:30
bluetooth: Fix unregistering of the message handler

In cases, where codec initialisation may fail, we still try
unregistering the message handler. Do not try unregistering
the handler if it was not registered in the first place.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/483>

- - - - -


1 changed file:

- src/modules/bluetooth/module-bluez5-device.c


Changes:

=====================================
src/modules/bluetooth/module-bluez5-device.c
=====================================
@@ -145,6 +145,8 @@ struct userdata {
     pa_sample_spec decoder_sample_spec;
     void *decoder_buffer;                        /* Codec transfer buffer */
     size_t decoder_buffer_size;                  /* Size of the buffer */
+
+    bool message_handler_registered;
 };
 
 typedef enum pa_bluetooth_form_factor {
@@ -2492,6 +2494,7 @@ int pa__init(pa_module* m) {
     m->userdata = u = pa_xnew0(struct userdata, 1);
     u->module = m;
     u->core = m->core;
+    u->message_handler_registered = false;
 
     if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
         pa_log_error("Failed to parse module arguments");
@@ -2562,6 +2565,7 @@ int pa__init(pa_module* m) {
             bluez5_device_message_handler, (void *) u);
     pa_log_info("Bluez5 device message handler registered at path: %s", message_handler_path);
     pa_xfree(message_handler_path);
+    u->message_handler_registered = true;
 
     return 0;
 
@@ -2593,9 +2597,11 @@ void pa__done(pa_module *m) {
     if (!(u = m->userdata))
         return;
 
-    message_handler_path = make_message_handler_path(u->card->name);
-    pa_message_handler_unregister(m->core, message_handler_path);
-    pa_xfree(message_handler_path);
+    if (u->message_handler_registered) {
+        message_handler_path = make_message_handler_path(u->card->name);
+        pa_message_handler_unregister(m->core, message_handler_path);
+        pa_xfree(message_handler_path);
+    }
 
     stop_thread(u);
 



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/8816b6b05bca6069a77e7068957b0eb041fb4055

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/8816b6b05bca6069a77e7068957b0eb041fb4055
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20210121/9690b74a/attachment-0001.htm>


More information about the pulseaudio-commits mailing list