[pulseaudio-discuss] [PATCH] bluetooth: Remove pa_bluetooth_discovery_sync().

Tanu Kaskinen tanuk at iki.fi
Thu Dec 20 03:03:01 PST 2012


On Tue, 2012-12-18 at 09:14 +0100, Mikel Astiz wrote:
> Hi Tanu,
> 
> On Mon, Dec 17, 2012 at 8:01 AM, Tanu Kaskinen <tanuk at iki.fi> wrote:
> > pa_bluetooth_discovery_sync() waited until all pending method calls
> > had completed. I don't understand what the benefit of that could be,
> > so I removed the function. We should avoid blocking as much as
> > possible, and the code that used pa_bluetooth_discovery_sync() didn't
> > look like it really needed to wait for anything.
> > ---
> >  src/modules/bluetooth/bluetooth-util.c            |   13 -------------
> >  src/modules/bluetooth/bluetooth-util.h            |    2 --
> >  src/modules/bluetooth/module-bluetooth-discover.c |   15 ++++-----------
> >  3 files changed, 4 insertions(+), 26 deletions(-)
> >
> > diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
> > index 392f4a5..b87a87c 100644
> > --- a/src/modules/bluetooth/bluetooth-util.c
> > +++ b/src/modules/bluetooth/bluetooth-util.c
> > @@ -1049,9 +1049,6 @@ pa_bluetooth_device* pa_bluetooth_discovery_get_by_address(pa_bluetooth_discover
> >      pa_assert(PA_REFCNT_VALUE(y) > 0);
> >      pa_assert(address);
> >
> > -    if (!pa_hook_is_firing(&y->hooks[PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED]))
> > -        pa_bluetooth_discovery_sync(y);
> > -
> >      while ((d = pa_hashmap_iterate(y->devices, &state, NULL)))
> >          if (pa_streq(d->address, address))
> >              return device_is_audio_ready(d) ? d : NULL;
> > @@ -1066,9 +1063,6 @@ pa_bluetooth_device* pa_bluetooth_discovery_get_by_path(pa_bluetooth_discovery *
> >      pa_assert(PA_REFCNT_VALUE(y) > 0);
> >      pa_assert(path);
> >
> > -    if (!pa_hook_is_firing(&y->hooks[PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED]))
> > -        pa_bluetooth_discovery_sync(y);
> > -
> >      if ((d = pa_hashmap_get(y->devices, path)))
> >          if (device_is_audio_ready(d))
> >              return d;
> > @@ -1763,13 +1757,6 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
> >      pa_xfree(y);
> >  }
> >
> > -void pa_bluetooth_discovery_sync(pa_bluetooth_discovery *y) {
> > -    pa_assert(y);
> > -    pa_assert(PA_REFCNT_VALUE(y) > 0);
> > -
> > -    pa_dbus_sync_pending_list(&y->pending);
> > -}
> > -
> >  pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y, pa_bluetooth_hook_t hook) {
> >      pa_assert(y);
> >      pa_assert(PA_REFCNT_VALUE(y) > 0);
> > diff --git a/src/modules/bluetooth/bluetooth-util.h b/src/modules/bluetooth/bluetooth-util.h
> > index 59db33c..b7c5973 100644
> > --- a/src/modules/bluetooth/bluetooth-util.h
> > +++ b/src/modules/bluetooth/bluetooth-util.h
> > @@ -141,8 +141,6 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core);
> >  pa_bluetooth_discovery* pa_bluetooth_discovery_ref(pa_bluetooth_discovery *y);
> >  void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *d);
> >
> > -void pa_bluetooth_discovery_sync(pa_bluetooth_discovery *d);
> > -
> >  pa_bluetooth_device* pa_bluetooth_discovery_get_by_path(pa_bluetooth_discovery *d, const char* path);
> >  pa_bluetooth_device* pa_bluetooth_discovery_get_by_address(pa_bluetooth_discovery *d, const char* address);
> >
> > diff --git a/src/modules/bluetooth/module-bluetooth-discover.c b/src/modules/bluetooth/module-bluetooth-discover.c
> > index 41981f6..f6e3b83 100644
> > --- a/src/modules/bluetooth/module-bluetooth-discover.c
> > +++ b/src/modules/bluetooth/module-bluetooth-discover.c
> > @@ -40,15 +40,14 @@
> >  PA_MODULE_AUTHOR("Joao Paulo Rechi Vita");
> >  PA_MODULE_DESCRIPTION("Detect available bluetooth audio devices and load bluetooth audio drivers");
> >  PA_MODULE_VERSION(PACKAGE_VERSION);
> > -PA_MODULE_USAGE("async=<Asynchronous initialization?> "
> > -                "sco_sink=<name of sink> "
> > +PA_MODULE_USAGE("sco_sink=<name of sink> "
> >                  "sco_source=<name of source> ");
> >  PA_MODULE_LOAD_ONCE(TRUE);
> >
> >  static const char* const valid_modargs[] = {
> >      "sco_sink",
> >      "sco_source",
> > -    "async",
> > +    "async", /* deprecated */
> >      NULL
> >  };
> >
> > @@ -128,7 +127,6 @@ static pa_hook_result_t load_module_for_device(pa_bluetooth_discovery *y, const
> >  int pa__init(pa_module* m) {
> >      struct userdata *u;
> >      pa_modargs *ma = NULL;
> > -    pa_bool_t async = FALSE;
> >
> >      pa_assert(m);
> >
> > @@ -137,10 +135,8 @@ int pa__init(pa_module* m) {
> >          goto fail;
> >      }
> >
> > -    if (pa_modargs_get_value_boolean(ma, "async", &async) < 0) {
> > -        pa_log("Failed to parse async argument.");
> > -        goto fail;
> > -    }
> > +    if (pa_modargs_get_value(ma, "async", NULL))
> > +        pa_log_warn("The 'async' argument is deprecated and does nothing.");
> >
> >      m->userdata = u = pa_xnew0(struct userdata, 1);
> >      u->module = m;
> > @@ -155,9 +151,6 @@ int pa__init(pa_module* m) {
> >      u->slot = pa_hook_connect(pa_bluetooth_discovery_hook(u->discovery, PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED),
> >                                PA_HOOK_NORMAL, (pa_hook_cb_t) load_module_for_device, u);
> >
> > -    if (!async)
> > -        pa_bluetooth_discovery_sync(u->discovery);
> > -
> >      return 0;
> >
> >  fail:
> > --
> > 1.7.10.4
> >
> 
> Ack from my side, I don't see the purpose of such sync.

Thanks for reviewing, I have now applied this patch.

-- 
Tanu



More information about the pulseaudio-discuss mailing list