mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
bluez5: remove mtu hardcoding
Hardcoding MTU is no longer necessary with the reworked SCO i/o, which guesses suitable write sizes based on rx.
This commit is contained in:
parent
368182d963
commit
073217ae63
3 changed files with 18 additions and 59 deletions
|
|
@ -234,10 +234,12 @@ static int sco_acquire_cb(void *data, bool optional)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
t->fd = sock;
|
t->fd = sock;
|
||||||
|
|
||||||
|
/* Fallback value */
|
||||||
t->read_mtu = 48;
|
t->read_mtu = 48;
|
||||||
t->write_mtu = 48;
|
t->write_mtu = 48;
|
||||||
|
|
||||||
if (false) {
|
if (true) {
|
||||||
struct sco_options sco_opt;
|
struct sco_options sco_opt;
|
||||||
|
|
||||||
len = sizeof(sco_opt);
|
len = sizeof(sco_opt);
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,6 @@ struct spa_bt_backend {
|
||||||
|
|
||||||
unsigned int filters_added:1;
|
unsigned int filters_added:1;
|
||||||
unsigned int msbc_supported:1;
|
unsigned int msbc_supported:1;
|
||||||
int msbc_force_mtu;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum hsphfpd_volume_control {
|
enum hsphfpd_volume_control {
|
||||||
|
|
@ -713,27 +712,9 @@ static DBusHandlerResult hsphfpd_new_audio_connection(DBusConnection *conn, DBus
|
||||||
pa_hook_fire(pa_bluetooth_discovery_hook(hsphfpd->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_TX_VOLUME_GAIN_CHANGED), transport);
|
pa_hook_fire(pa_bluetooth_discovery_hook(hsphfpd->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_TX_VOLUME_GAIN_CHANGED), transport);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (transport->codec == HFP_AUDIO_CODEC_CVSD) {
|
transport->read_mtu = mtu;
|
||||||
transport->read_mtu = 48;
|
transport->write_mtu = mtu;
|
||||||
transport->write_mtu = 48;
|
|
||||||
} else if (transport->codec == HFP_AUDIO_CODEC_MSBC && backend->msbc_force_mtu != 0) {
|
|
||||||
transport->read_mtu = mtu;
|
|
||||||
|
|
||||||
/* Force low write packet size, as kernel (at least <= 5.9) does not
|
|
||||||
* provide correct values for userspace. The value 24 should be
|
|
||||||
* right for bluetooth ALT1 mode. See
|
|
||||||
* https://lore.kernel.org/linux-bluetooth/20201210003528.3pmaxvubiwegxmhl@pali/T/
|
|
||||||
*
|
|
||||||
* XXX: revise when hsphfpd/kernel reports correct numbers
|
|
||||||
*/
|
|
||||||
transport->write_mtu = (backend->msbc_force_mtu > 0) ? backend->msbc_force_mtu : 24;
|
|
||||||
spa_log_warn(backend->log, "hsphfpd: forcing write_mtu = %d for mSBC; "
|
|
||||||
"set bluez5.msbc-force-mtu=0 to use autodetected (%d)",
|
|
||||||
(int) transport->write_mtu, (int) mtu);
|
|
||||||
} else {
|
|
||||||
transport->read_mtu = mtu;
|
|
||||||
transport->write_mtu = mtu;
|
|
||||||
}
|
|
||||||
transport->fd = fd;
|
transport->fd = fd;
|
||||||
|
|
||||||
if ((r = dbus_message_new_method_return(m)) == NULL)
|
if ((r = dbus_message_new_method_return(m)) == NULL)
|
||||||
|
|
@ -1507,10 +1488,6 @@ struct spa_bt_backend *backend_hsphfpd_new(struct spa_bt_monitor *monitor,
|
||||||
backend->msbc_supported = strcmp(str, "true") == 0 || atoi(str) == 1;
|
backend->msbc_supported = strcmp(str, "true") == 0 || atoi(str) == 1;
|
||||||
else
|
else
|
||||||
backend->msbc_supported = false;
|
backend->msbc_supported = false;
|
||||||
if (info && (str = spa_dict_lookup(info, "bluez5.msbc-force-mtu")))
|
|
||||||
backend->msbc_force_mtu = atoi(str);
|
|
||||||
else
|
|
||||||
backend->msbc_force_mtu = -1;
|
|
||||||
|
|
||||||
spa_list_init(&backend->endpoint_list);
|
spa_list_init(&backend->endpoint_list);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,6 @@ struct spa_bt_backend {
|
||||||
|
|
||||||
unsigned int filters_added:1;
|
unsigned int filters_added:1;
|
||||||
unsigned int msbc_supported:1;
|
unsigned int msbc_supported:1;
|
||||||
int msbc_force_mtu;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define OFONO_SERVICE "org.ofono"
|
#define OFONO_SERVICE "org.ofono"
|
||||||
|
|
@ -85,37 +84,22 @@ struct spa_bt_backend {
|
||||||
|
|
||||||
static void ofono_transport_get_mtu(struct spa_bt_backend *backend, struct spa_bt_transport *t)
|
static void ofono_transport_get_mtu(struct spa_bt_backend *backend, struct spa_bt_transport *t)
|
||||||
{
|
{
|
||||||
if (t->codec == HFP_AUDIO_CODEC_CVSD) {
|
struct sco_options sco_opt;
|
||||||
t->read_mtu = 48;
|
socklen_t len;
|
||||||
t->write_mtu = 48;
|
|
||||||
} else {
|
|
||||||
struct sco_options sco_opt;
|
|
||||||
socklen_t len;
|
|
||||||
|
|
||||||
len = sizeof(sco_opt);
|
/* Fallback values */
|
||||||
memset(&sco_opt, 0, len);
|
t->read_mtu = 48;
|
||||||
|
t->write_mtu = 48;
|
||||||
|
|
||||||
if (getsockopt(t->fd, SOL_SCO, SCO_OPTIONS, &sco_opt, &len) < 0)
|
len = sizeof(sco_opt);
|
||||||
spa_log_warn(backend->log, NAME": getsockopt(SCO_OPTIONS) failed, loading defaults");
|
memset(&sco_opt, 0, len);
|
||||||
else {
|
|
||||||
spa_log_debug(backend->log, NAME" : autodetected mtu = %u", sco_opt.mtu);
|
|
||||||
t->read_mtu = sco_opt.mtu;
|
|
||||||
t->write_mtu = sco_opt.mtu;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (backend->msbc_force_mtu != 0 && t->codec == HFP_AUDIO_CODEC_MSBC) {
|
if (getsockopt(t->fd, SOL_SCO, SCO_OPTIONS, &sco_opt, &len) < 0)
|
||||||
/* Force low write packet size, as kernel (at least <= 5.9) does not
|
spa_log_warn(backend->log, NAME": getsockopt(SCO_OPTIONS) failed, loading defaults");
|
||||||
* provide correct values for userspace. The value 24 should be
|
else {
|
||||||
* right for bluetooth ALT1 mode. See
|
spa_log_debug(backend->log, NAME" : autodetected mtu = %u", sco_opt.mtu);
|
||||||
* https://lore.kernel.org/linux-bluetooth/20201210003528.3pmaxvubiwegxmhl@pali/T/
|
t->read_mtu = sco_opt.mtu;
|
||||||
*
|
t->write_mtu = sco_opt.mtu;
|
||||||
* XXX: revise when kernel reports correct numbers
|
|
||||||
*/
|
|
||||||
t->write_mtu = (backend->msbc_force_mtu > 0) ? backend->msbc_force_mtu : 24;
|
|
||||||
spa_log_warn(backend->log, NAME": forcing write_mtu = %d for mSBC; "
|
|
||||||
"set bluez5.msbc-force-mtu=0 to autodetect",
|
|
||||||
(int) t->write_mtu);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -719,10 +703,6 @@ struct spa_bt_backend *backend_ofono_new(struct spa_bt_monitor *monitor,
|
||||||
backend->msbc_supported = strcmp(str, "true") == 0 || atoi(str) == 1;
|
backend->msbc_supported = strcmp(str, "true") == 0 || atoi(str) == 1;
|
||||||
else
|
else
|
||||||
backend->msbc_supported = false;
|
backend->msbc_supported = false;
|
||||||
if (info && (str = spa_dict_lookup(info, "bluez5.msbc-force-mtu")))
|
|
||||||
backend->msbc_force_mtu = atoi(str);
|
|
||||||
else
|
|
||||||
backend->msbc_force_mtu = -1;
|
|
||||||
|
|
||||||
if (!dbus_connection_register_object_path(backend->conn,
|
if (!dbus_connection_register_object_path(backend->conn,
|
||||||
OFONO_AUDIO_CLIENT,
|
OFONO_AUDIO_CLIENT,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue