static int bluez5_sco_acquire_cb(pa_bluetooth_transport *t, bool optional, size_t *imtu, size_t *omtu) {
pa_bluetooth_device *d = t->device;
struct sockaddr_sco addr;
- struct sco_options sco_opt;
socklen_t len;
int err, i;
int sock;
goto fail_close;
}
- len = sizeof(sco_opt);
- memset(&sco_opt, 0, len);
+ if (imtu) *imtu = 48;
+ if (omtu) *omtu = 48;
- if (getsockopt(sock, SOL_SCO, SCO_OPTIONS, &sco_opt, &len) < 0) {
- pa_log_warn("getsockopt(SCO_OPTIONS) failed, loading defaults");
+ if (t->device->autodetect_mtu) {
+ struct sco_options sco_opt;
- /* Setting defaults in case of error */
- if (imtu) *imtu = 48;
- if (omtu) *omtu = 48;
- } else {
- if (imtu) *imtu = sco_opt.mtu;
- if (omtu) *omtu = sco_opt.mtu;
+ len = sizeof(sco_opt);
+ memset(&sco_opt, 0, len);
+
+ if (getsockopt(sock, SOL_SCO, SCO_OPTIONS, &sco_opt, &len) < 0)
+ pa_log_warn("getsockopt(SCO_OPTIONS) failed, loading defaults");
+ else {
+ if (imtu) *imtu = sco_opt.mtu;
+ if (omtu) *omtu = sco_opt.mtu;
+ }
}
return sock;
bool properties_received;
bool tried_to_link_with_adapter;
bool valid;
+ bool autodetect_mtu;
/* Device information */
char *path;
PA_MODULE_LOAD_ONCE(true);
PA_MODULE_USAGE(
"headset=ofono|native|auto (bluez 5 only)"
+ "autodetect_mtu=<boolean> (bluez 5 only)"
);
struct userdata {
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>");
+PA_MODULE_USAGE("path=<device object path>"
+ "autodetect_mtu=<boolean>");
#define MAX_PLAYBACK_CATCH_UP_USEC (100 * PA_USEC_PER_MSEC)
#define FIXED_LATENCY_PLAYBACK_A2DP (25 * PA_USEC_PER_MSEC)
static const char* const valid_modargs[] = {
"path",
+ "autodetect_mtu",
NULL
};
struct userdata *u;
const char *path;
pa_modargs *ma;
+ bool autodetect_mtu;
pa_assert(m);
goto fail_free_modargs;
}
+ autodetect_mtu = true;
+ 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 =
static const char* const valid_modargs[] = {
"headset",
+ "autodetect_mtu",
NULL
};
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) {
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", d->path);
+ char *args = pa_sprintf_malloc("path=%s autodetect_mtu=%i", d->path, (int)u->autodetect_mtu);
pa_log_debug("Loading module-bluez5-device %s", args);
m = pa_module_load(u->module->core, "module-bluez5-device", args);
pa_modargs *ma;
const char *headset_str;
int headset_backend;
+ bool autodetect_mtu;
pa_assert(m);
goto fail;
}
+ autodetect_mtu = true;
+ 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, headset_backend)))