mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
spa: bluez: use some more spa_auto*
This commit is contained in:
parent
ca85872e83
commit
4083502e03
7 changed files with 119 additions and 198 deletions
|
|
@ -29,10 +29,12 @@ int spa_bt_adapter_has_msbc(struct spa_bt_adapter *adapter)
|
|||
#include <bluetooth/hci.h>
|
||||
#include <bluetooth/hci_lib.h>
|
||||
|
||||
#include <spa/utils/cleanup.h>
|
||||
|
||||
int spa_bt_adapter_has_msbc(struct spa_bt_adapter *adapter)
|
||||
{
|
||||
int hci_id, res;
|
||||
int sock = -1;
|
||||
int hci_id;
|
||||
spa_autoclose int sock = -1;
|
||||
uint8_t features[8], max_page = 0;
|
||||
struct sockaddr_hci a;
|
||||
const char *str;
|
||||
|
|
@ -46,28 +48,20 @@ int spa_bt_adapter_has_msbc(struct spa_bt_adapter *adapter)
|
|||
|
||||
sock = socket(AF_BLUETOOTH, SOCK_RAW | SOCK_CLOEXEC, BTPROTO_HCI);
|
||||
if (sock < 0)
|
||||
goto error;
|
||||
return -errno;
|
||||
|
||||
memset(&a, 0, sizeof(a));
|
||||
a.hci_family = AF_BLUETOOTH;
|
||||
a.hci_dev = hci_id;
|
||||
if (bind(sock, (struct sockaddr *) &a, sizeof(a)) < 0)
|
||||
goto error;
|
||||
return -errno;
|
||||
|
||||
if (hci_read_local_ext_features(sock, 0, &max_page, features, 1000) < 0)
|
||||
goto error;
|
||||
|
||||
close(sock);
|
||||
return -errno;
|
||||
|
||||
adapter->msbc_probed = true;
|
||||
adapter->has_msbc = ((features[2] & LMP_TRSP_SCO) && (features[3] & LMP_ESCO)) ? 1 : 0;
|
||||
return adapter->has_msbc;
|
||||
|
||||
error:
|
||||
res = -errno;
|
||||
if (sock >= 0)
|
||||
close(sock);
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue