Commit ff8c2a99 authored by pali's avatar pali
Browse files

bluetooth: Enable autodetect of MTU by default

Remove legacy parameter for old ofono code. hsphpfd already provides MTU
and MTU autodetect is working fine. For legacy HSP profile stick with 48
value as it is needed for CVSD/PCM codec.
parent c95129bd
......@@ -116,7 +116,6 @@ struct pa_bluetooth_device {
bool properties_received;
bool tried_to_link_with_adapter;
bool valid;
bool autodetect_mtu;
pa_bluetooth_profile_t new_profile_in_progress;
/* Device information */
......
......@@ -209,8 +209,6 @@ fail_close:
static int sco_acquire_cb(pa_bluetooth_transport *t, size_t *imtu, size_t *omtu) {
struct transport_data *trd = t->userdata;
struct sco_options sco_opt;
socklen_t len;
int ret;
if (trd->sco_connect_io)
......@@ -228,22 +226,11 @@ static int sco_acquire_cb(pa_bluetooth_transport *t, size_t *imtu, size_t *omtu)
return ret;
}
/* Legacy HSP profile implementation supports only CVSD air codec with
* PCM s16le 8kHz local codec which requies 48 bytes length packet size */
if (imtu) *imtu = 48;
if (omtu) *omtu = 48;
if (t->device->autodetect_mtu) {
len = sizeof(sco_opt);
memset(&sco_opt, 0, len);
if (getsockopt(trd->sco_fd, SOL_SCO, SCO_OPTIONS, &sco_opt, &len) < 0)
pa_log_warn("getsockopt(SCO_OPTIONS) failed, loading defaults");
else {
pa_log_debug("autodetected imtu = omtu = %u", sco_opt.mtu);
if (imtu) *imtu = sco_opt.mtu;
if (omtu) *omtu = sco_opt.mtu;
}
}
return trd->sco_fd;
}
......
......@@ -29,9 +29,6 @@ PA_MODULE_AUTHOR("João Paulo Rechi Vita");
PA_MODULE_DESCRIPTION("Detect available Bluetooth daemon and load the corresponding discovery module");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(true);
PA_MODULE_USAGE(
"autodetect_mtu=<boolean>"
);
struct userdata {
uint32_t bluez5_module_idx;
......
......@@ -54,8 +54,7 @@ PA_MODULE_AUTHOR("João Paulo Rechi Vita");
PA_MODULE_DESCRIPTION("BlueZ 5 Bluetooth audio sink and source");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(false);
PA_MODULE_USAGE("path=<device object path>"
"autodetect_mtu=<boolean>");
PA_MODULE_USAGE("path=<device object path>");
#define FIXED_LATENCY_PLAYBACK_A2DP (25 * PA_USEC_PER_MSEC)
#define FIXED_LATENCY_PLAYBACK_SCO (25 * PA_USEC_PER_MSEC)
......@@ -64,7 +63,6 @@ PA_MODULE_USAGE("path=<device object path>"
static const char* const valid_modargs[] = {
"path",
"autodetect_mtu",
NULL
};
......@@ -2519,7 +2517,6 @@ int pa__init(pa_module* m) {
struct userdata *u;
const char *path;
pa_modargs *ma;
bool autodetect_mtu;
pa_assert(m);
......@@ -2549,14 +2546,6 @@ int pa__init(pa_module* m) {
goto fail_free_modargs;
}
autodetect_mtu = false;
if (pa_modargs_get_value_boolean(ma, "autodetect_mtu", &autodetect_mtu) < 0) {
pa_log("Invalid boolean value for autodetect_mtu parameter");
goto fail_free_modargs;
}
u->device->autodetect_mtu = autodetect_mtu;
pa_modargs_free(ma);
u->device_connection_changed_slot =
......
......@@ -34,14 +34,6 @@ PA_MODULE_AUTHOR("João Paulo Rechi Vita");
PA_MODULE_DESCRIPTION("Detect available BlueZ 5 Bluetooth audio devices and load BlueZ 5 Bluetooth audio drivers");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(true);
PA_MODULE_USAGE(
"autodetect_mtu=<boolean>"
);
static const char* const valid_modargs[] = {
"autodetect_mtu",
NULL
};
struct userdata {
pa_module *module;
......@@ -49,7 +41,6 @@ struct userdata {
pa_hashmap *loaded_device_paths;
pa_hook_slot *device_connection_changed_slot;
pa_bluetooth_discovery *discovery;
bool autodetect_mtu;
};
static pa_hook_result_t device_connection_changed_cb(pa_bluetooth_discovery *y, const pa_bluetooth_device *d, struct userdata *u) {
......@@ -71,7 +62,7 @@ static pa_hook_result_t device_connection_changed_cb(pa_bluetooth_discovery *y,
if (!module_loaded && pa_bluetooth_device_any_transport_connected(d)) {
/* a new device has been connected */
pa_module *m;
char *args = pa_sprintf_malloc("path=%s autodetect_mtu=%i", d->path, (int)u->autodetect_mtu);
char *args = pa_sprintf_malloc("path=%s", d->path);
pa_log_debug("Loading module-bluez5-device %s", args);
pa_module_load(&m, u->module->core, "module-bluez5-device", args);
......@@ -93,25 +84,17 @@ static pa_hook_result_t device_connection_changed_cb(pa_bluetooth_discovery *y,
int pa__init(pa_module *m) {
struct userdata *u;
pa_modargs *ma;
bool autodetect_mtu;
pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
if (!(ma = pa_modargs_new(m->argument, NULL))) {
pa_log("failed to parse module arguments.");
goto fail;
}
autodetect_mtu = false;
if (pa_modargs_get_value_boolean(ma, "autodetect_mtu", &autodetect_mtu) < 0) {
pa_log("Invalid boolean value for autodetect_mtu parameter");
goto fail;
}
m->userdata = u = pa_xnew0(struct userdata, 1);
u->module = m;
u->core = m->core;
u->autodetect_mtu = autodetect_mtu;
u->loaded_device_paths = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
if (!(u->discovery = pa_bluetooth_discovery_get(u->core)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment