bluetooth: Remove BlueZ 4 support

BlueZ 4 is no longer supported by BlueZ community for a long long time,
also by moving to BlueZ 5 it should make it even more clearer that
BlueZ 4 is no longer an option.
This commit is contained in:
Luiz Augusto von Dentz 2018-03-26 17:15:50 +03:00 committed by Arun Raghavan
parent fb600395e1
commit 3b1093c0ad
27 changed files with 61 additions and 5505 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,160 +0,0 @@
#ifndef foobluez4utilhfoo
#define foobluez4utilhfoo
/***
This file is part of PulseAudio.
Copyright 2008-2013 João Paulo Rechi Vita
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
***/
#include <dbus/dbus.h>
#include <pulsecore/llist.h>
#include <pulsecore/macro.h>
#define PA_BLUEZ4_ERROR_NOT_SUPPORTED "org.bluez.Error.NotSupported"
#define PA_BLUEZ4_UUID_A2DP_SOURCE "0000110a-0000-1000-8000-00805f9b34fb"
#define PA_BLUEZ4_UUID_A2DP_SINK "0000110b-0000-1000-8000-00805f9b34fb"
#define PA_BLUEZ4_UUID_HSP_HS "00001108-0000-1000-8000-00805f9b34fb"
#define PA_BLUEZ4_UUID_HSP_AG "00001112-0000-1000-8000-00805f9b34fb"
#define PA_BLUEZ4_UUID_HFP_HF "0000111e-0000-1000-8000-00805f9b34fb"
#define PA_BLUEZ4_UUID_HFP_AG "0000111f-0000-1000-8000-00805f9b34fb"
#define HSP_MAX_GAIN 15
typedef struct pa_bluez4_device pa_bluez4_device;
typedef struct pa_bluez4_discovery pa_bluez4_discovery;
typedef struct pa_bluez4_transport pa_bluez4_transport;
struct userdata;
typedef enum pa_bluez4_profile {
PA_BLUEZ4_PROFILE_A2DP_SINK,
PA_BLUEZ4_PROFILE_A2DP_SOURCE,
PA_BLUEZ4_PROFILE_HEADSET_HEAD_UNIT,
PA_BLUEZ4_PROFILE_HEADSET_AUDIO_GATEWAY,
PA_BLUEZ4_PROFILE_OFF
} pa_bluez4_profile_t;
#define PA_BLUEZ4_PROFILE_COUNT PA_BLUEZ4_PROFILE_OFF
struct pa_bluez4_hook_uuid_data {
pa_bluez4_device *device;
const char *uuid;
};
/* Hook data: pa_bluez4_discovery pointer. */
typedef enum pa_bluez4_hook {
PA_BLUEZ4_HOOK_DEVICE_CONNECTION_CHANGED, /* Call data: pa_bluez4_device */
PA_BLUEZ4_HOOK_DEVICE_UUID_ADDED, /* Call data: pa_bluez4_hook_uuid_data */
PA_BLUEZ4_HOOK_TRANSPORT_STATE_CHANGED, /* Call data: pa_bluez4_transport */
PA_BLUEZ4_HOOK_TRANSPORT_NREC_CHANGED, /* Call data: pa_bluez4_transport */
PA_BLUEZ4_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED, /* Call data: pa_bluez4_transport */
PA_BLUEZ4_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED, /* Call data: pa_bluez4_transport */
PA_BLUEZ4_HOOK_MAX
} pa_bluez4_hook_t;
typedef enum pa_bluez4_transport_state {
PA_BLUEZ4_TRANSPORT_STATE_DISCONNECTED,
PA_BLUEZ4_TRANSPORT_STATE_IDLE, /* Connected but not playing */
PA_BLUEZ4_TRANSPORT_STATE_PLAYING
} pa_bluez4_transport_state_t;
struct pa_bluez4_transport {
pa_bluez4_device *device;
char *owner;
char *path;
pa_bluez4_profile_t profile;
uint8_t codec;
uint8_t *config;
int config_size;
pa_bluez4_transport_state_t state;
bool nrec;
uint16_t microphone_gain; /* Used for HSP/HFP */
uint16_t speaker_gain; /* Used for HSP/HFP */
};
/* This enum is shared among Audio, Headset, AudioSink, and AudioSource, although not all values are acceptable in all profiles */
typedef enum pa_bluez4_audio_state {
PA_BLUEZ4_AUDIO_STATE_INVALID = -1,
PA_BLUEZ4_AUDIO_STATE_DISCONNECTED,
PA_BLUEZ4_AUDIO_STATE_CONNECTING,
PA_BLUEZ4_AUDIO_STATE_CONNECTED,
PA_BLUEZ4_AUDIO_STATE_PLAYING
} pa_bluez4_audio_state_t;
struct pa_bluez4_device {
pa_bluez4_discovery *discovery;
bool dead;
int device_info_valid; /* 0: no results yet; 1: good results; -1: bad results ... */
/* Device information */
char *name;
char *path;
pa_bluez4_transport *transports[PA_BLUEZ4_PROFILE_COUNT];
int paired;
char *alias;
char *address;
int class;
pa_hashmap *uuids; /* char* -> char* (hashmap-as-a-set) */
int trusted;
/* Audio state */
pa_bluez4_audio_state_t audio_state;
/* AudioSink, AudioSource, Headset and HandsfreeGateway states */
pa_bluez4_audio_state_t profile_state[PA_BLUEZ4_PROFILE_COUNT];
};
pa_bluez4_discovery* pa_bluez4_discovery_get(pa_core *core);
pa_bluez4_discovery* pa_bluez4_discovery_ref(pa_bluez4_discovery *y);
void pa_bluez4_discovery_unref(pa_bluez4_discovery *d);
pa_bluez4_device* pa_bluez4_discovery_get_by_path(pa_bluez4_discovery *d, const char* path);
pa_bluez4_device* pa_bluez4_discovery_get_by_address(pa_bluez4_discovery *d, const char* address);
bool pa_bluez4_device_any_audio_connected(const pa_bluez4_device *d);
int pa_bluez4_transport_acquire(pa_bluez4_transport *t, bool optional, size_t *imtu, size_t *omtu);
void pa_bluez4_transport_release(pa_bluez4_transport *t);
void pa_bluez4_transport_set_microphone_gain(pa_bluez4_transport *t, uint16_t value);
void pa_bluez4_transport_set_speaker_gain(pa_bluez4_transport *t, uint16_t value);
pa_hook* pa_bluez4_discovery_hook(pa_bluez4_discovery *y, pa_bluez4_hook_t hook);
typedef enum pa_bluez4_form_factor {
PA_BLUEZ4_FORM_FACTOR_UNKNOWN,
PA_BLUEZ4_FORM_FACTOR_HEADSET,
PA_BLUEZ4_FORM_FACTOR_HANDSFREE,
PA_BLUEZ4_FORM_FACTOR_MICROPHONE,
PA_BLUEZ4_FORM_FACTOR_SPEAKER,
PA_BLUEZ4_FORM_FACTOR_HEADPHONE,
PA_BLUEZ4_FORM_FACTOR_PORTABLE,
PA_BLUEZ4_FORM_FACTOR_CAR,
PA_BLUEZ4_FORM_FACTOR_HIFI,
PA_BLUEZ4_FORM_FACTOR_PHONE,
} pa_bluez4_form_factor_t;
pa_bluez4_form_factor_t pa_bluez4_get_form_factor(uint32_t class);
const char *pa_bluez4_form_factor_to_string(pa_bluez4_form_factor_t ff);
const char *pa_bluez4_profile_to_string(pa_bluez4_profile_t profile);
#endif

View file

@ -36,7 +36,6 @@ PA_MODULE_USAGE(
struct userdata {
uint32_t bluez5_module_idx;
uint32_t bluez4_module_idx;
};
int pa__init(pa_module* m) {
@ -47,7 +46,6 @@ int pa__init(pa_module* m) {
m->userdata = u = pa_xnew0(struct userdata, 1);
u->bluez5_module_idx = PA_INVALID_INDEX;
u->bluez4_module_idx = PA_INVALID_INDEX;
if (pa_module_exists("module-bluez5-discover")) {
pa_module_load(&mm, m->core, "module-bluez5-discover", m->argument);
@ -55,13 +53,7 @@ int pa__init(pa_module* m) {
u->bluez5_module_idx = mm->index;
}
if (pa_module_exists("module-bluez4-discover")) {
pa_module_load(&mm, m->core, "module-bluez4-discover", NULL);
if (mm)
u->bluez4_module_idx = mm->index;
}
if (u->bluez5_module_idx == PA_INVALID_INDEX && u->bluez4_module_idx == PA_INVALID_INDEX) {
if (u->bluez5_module_idx == PA_INVALID_INDEX) {
pa_xfree(u);
return -1;
}
@ -80,8 +72,5 @@ void pa__done(pa_module* m) {
if (u->bluez5_module_idx != PA_INVALID_INDEX)
pa_module_unload_by_index(m->core, u->bluez5_module_idx, true);
if (u->bluez4_module_idx != PA_INVALID_INDEX)
pa_module_unload_by_index(m->core, u->bluez4_module_idx, true);
pa_xfree(u);
}

File diff suppressed because it is too large Load diff

View file

@ -1,187 +0,0 @@
/***
This file is part of PulseAudio.
Copyright 2008-2013 João Paulo Rechi Vita
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
***/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <pulse/xmalloc.h>
#include <pulsecore/module.h>
#include <pulsecore/core-util.h>
#include <pulsecore/modargs.h>
#include <pulsecore/macro.h>
#include <pulsecore/core-util.h>
#include <pulsecore/dbus-shared.h>
#include "bluez4-util.h"
PA_MODULE_AUTHOR("João Paulo Rechi Vita");
PA_MODULE_DESCRIPTION("Detect available BlueZ 4 Bluetooth audio devices and load BlueZ 4 Bluetooth audio drivers");
PA_MODULE_VERSION(PACKAGE_VERSION);
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", /* deprecated */
NULL
};
struct userdata {
pa_module *module;
pa_modargs *modargs;
pa_core *core;
pa_bluez4_discovery *discovery;
pa_hook_slot *slot;
pa_hashmap *hashmap;
};
struct pa_module_info {
char *path;
uint32_t module;
};
static pa_hook_result_t load_module_for_device(pa_bluez4_discovery *y, const pa_bluez4_device *d, struct userdata *u) {
struct pa_module_info *mi;
pa_assert(u);
pa_assert(d);
mi = pa_hashmap_get(u->hashmap, d->path);
if (pa_bluez4_device_any_audio_connected(d)) {
if (!mi) {
pa_module *m = NULL;
char *args;
/* Oh, awesome, a new device has shown up and been connected! */
args = pa_sprintf_malloc("address=\"%s\" path=\"%s\"", d->address, d->path);
if (pa_modargs_get_value(u->modargs, "sco_sink", NULL) &&
pa_modargs_get_value(u->modargs, "sco_source", NULL)) {
char *tmp;
tmp = pa_sprintf_malloc("%s sco_sink=\"%s\" sco_source=\"%s\"", args,
pa_modargs_get_value(u->modargs, "sco_sink", NULL),
pa_modargs_get_value(u->modargs, "sco_source", NULL));
pa_xfree(args);
args = tmp;
}
pa_log_debug("Loading module-bluez4-device %s", args);
pa_module_load(&m, u->module->core, "module-bluez4-device", args);
pa_xfree(args);
if (m) {
mi = pa_xnew(struct pa_module_info, 1);
mi->module = m->index;
mi->path = pa_xstrdup(d->path);
pa_hashmap_put(u->hashmap, mi->path, mi);
} else
pa_log_debug("Failed to load module for device %s", d->path);
}
} else {
if (mi) {
/* Hmm, disconnection? Then the module unloads itself */
pa_log_debug("Unregistering module for %s", d->path);
pa_hashmap_remove(u->hashmap, mi->path);
pa_xfree(mi->path);
pa_xfree(mi);
}
}
return PA_HOOK_OK;
}
int pa__init(pa_module* m) {
struct userdata *u;
pa_modargs *ma;
pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments");
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;
u->core = m->core;
u->modargs = ma;
u->hashmap = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
if (!(u->discovery = pa_bluez4_discovery_get(u->core)))
goto fail;
u->slot = pa_hook_connect(pa_bluez4_discovery_hook(u->discovery, PA_BLUEZ4_HOOK_DEVICE_CONNECTION_CHANGED),
PA_HOOK_NORMAL, (pa_hook_cb_t) load_module_for_device, u);
return 0;
fail:
pa__done(m);
return -1;
}
void pa__done(pa_module* m) {
struct userdata *u;
pa_assert(m);
if (!(u = m->userdata))
return;
if (u->slot)
pa_hook_slot_free(u->slot);
if (u->discovery)
pa_bluez4_discovery_unref(u->discovery);
if (u->hashmap) {
struct pa_module_info *mi;
while ((mi = pa_hashmap_steal_first(u->hashmap))) {
pa_xfree(mi->path);
pa_xfree(mi);
}
pa_hashmap_free(u->hashmap);
}
if (u->modargs)
pa_modargs_free(u->modargs);
pa_xfree(u);
}