[pulseaudio-discuss] [PATCH v1 2/3] bluetooth: Generalize module-bluetooth-policy
Tanu Kaskinen
tanuk at iki.fi
Tue Aug 21 09:12:24 PDT 2012
On Fri, 2012-08-17 at 08:12 +0200, Mikel Astiz wrote:
> From: Mikel Astiz <mikel.astiz at bmw-carit.de>
>
> Instead of focusing on a2dp_source only, prepare the module to support
> several profiles. It will be possible to enable/disable each of them
> using module arguments.
> ---
> src/modules/bluetooth/module-bluetooth-policy.c | 34 ++++++++++++++++++++---
> 1 files changed, 30 insertions(+), 4 deletions(-)
>
> diff --git a/src/modules/bluetooth/module-bluetooth-policy.c b/src/modules/bluetooth/module-bluetooth-policy.c
> index 7f19447..98a949c 100644
> --- a/src/modules/bluetooth/module-bluetooth-policy.c
> +++ b/src/modules/bluetooth/module-bluetooth-policy.c
> @@ -28,6 +28,7 @@
> #include <pulse/xmalloc.h>
>
> #include <pulsecore/core.h>
> +#include <pulsecore/modargs.h>
> #include <pulsecore/source-output.h>
> #include <pulsecore/source.h>
> #include <pulsecore/core-util.h>
> @@ -35,16 +36,25 @@
> #include "module-bluetooth-policy-symdef.h"
>
> PA_MODULE_AUTHOR("Frédéric Dalleau");
> -PA_MODULE_DESCRIPTION("When an A2DP source is added, load module-loopback");
> +PA_MODULE_DESCRIPTION("When a bluetooth sink or source is added, load module-loopback");
> PA_MODULE_VERSION(PACKAGE_VERSION);
> PA_MODULE_LOAD_ONCE(TRUE);
> +PA_MODULE_USAGE(
> + "a2dp_source=<Handle a2dp_source card profile (sink role)?>");
> +
> +static const char* const valid_modargs[] = {
> + "a2dp_source",
> + NULL
> +};
>
> struct userdata {
> - pa_hook_slot *source_put_slot;
> + pa_bool_t enable_a2dp_source;
pa_bool_t is deprecated; just use bool.
> + pa_hook_slot *source_put_slot;
> };
>
> /* When a source is created, loopback it to default sink */
> static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source, void* userdata) {
> + struct userdata *u = userdata;
> const char *s;
> const char *role;
> char *args;
> @@ -60,12 +70,11 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source,
> if (!pa_streq(s, "bluetooth"))
> return PA_HOOK_OK;
>
> - /* Restrict to A2DP profile (sink role) */
> s = pa_proplist_gets(source->proplist, "bluetooth.protocol");
Not a fault of this patch (so you don't need to fix this if you don't
want to), but I think this code shouldn't use the proplist for figuring
out the device profile. In my opinion using proplists for logic should
be avoided, because converting to and from strings is ugly.
I'd like the bluetooth discovery API to have a function that takes a
pa_source pointer and returns the associated pa_bluetooth_device object.
The profile could then be found from the pa_bluetooth_device object.
--
Tanu
More information about the pulseaudio-discuss
mailing list