mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
bluetooth: Add "valid" flag to pa_bluetooth_adapter
This is a cosmetic change. There are a couple of places where we check whether the adapter object is valid, and while checking whether the address property is set works just fine, I find it nicer to have a dedicated flag for the object validity. This improves maintainability too, because if there will ever be more adapter properties that affect the adapter validity, the places that check if the adapter is valid don't need to be updated.
This commit is contained in:
parent
26b9d22dd2
commit
a61d065dcc
2 changed files with 5 additions and 2 deletions
|
|
@ -674,6 +674,7 @@ static void parse_adapter_properties(pa_bluetooth_adapter *a, DBusMessageIter *i
|
|||
|
||||
dbus_message_iter_get_basic(&variant_i, &value);
|
||||
a->address = pa_xstrdup(value);
|
||||
a->valid = true;
|
||||
}
|
||||
|
||||
dbus_message_iter_next(&element_i);
|
||||
|
|
@ -787,7 +788,7 @@ static void parse_interfaces_and_properties(pa_bluetooth_discovery *y, DBusMessa
|
|||
pa_log_debug("Adapter %s found", path);
|
||||
|
||||
parse_adapter_properties(a, &iface_i, false);
|
||||
if (!a->address)
|
||||
if (!a->valid)
|
||||
return;
|
||||
|
||||
register_endpoint(y, path, A2DP_SOURCE_ENDPOINT, PA_BLUETOOTH_UUID_A2DP_SOURCE);
|
||||
|
|
@ -819,7 +820,7 @@ static void parse_interfaces_and_properties(pa_bluetooth_discovery *y, DBusMessa
|
|||
|
||||
if (!d->adapter && d->adapter_path) {
|
||||
d->adapter = pa_hashmap_get(d->discovery->adapters, d->adapter_path);
|
||||
if (!d->adapter || !d->adapter->address) {
|
||||
if (!d->adapter || !d->adapter->valid) {
|
||||
pa_log_error("Device %s is child of nonexistent or corrupted adapter %s", d->path, d->adapter_path);
|
||||
set_device_info_valid(d, -1);
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -93,6 +93,8 @@ struct pa_bluetooth_adapter {
|
|||
pa_bluetooth_discovery *discovery;
|
||||
char *path;
|
||||
char *address;
|
||||
|
||||
bool valid;
|
||||
};
|
||||
|
||||
pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const char *owner, const char *path,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue