bluez5: reduce quirks logspam

There's no need to log quirks every time they are used, it's enough to
log them once when a device connects.
This commit is contained in:
Pauli Virtanen 2024-06-30 17:09:43 +03:00
parent 726234c82f
commit 8504e58120
3 changed files with 40 additions and 10 deletions

View file

@ -2075,9 +2075,10 @@ static void device_set_connected(struct spa_bt_device *device, int connected)
if (device->connected && !connected)
device->connected_profiles = 0;
if (connected)
if (connected) {
spa_bt_quirks_log_features(monitor->quirks, device->adapter, device);
spa_bt_device_check_profiles(device, false);
else {
} else {
/* Stop codec switch on disconnect */
struct spa_bt_media_codec_switch *sw;
spa_list_consume(sw, &device->codec_switch_list, device_link)

View file

@ -778,6 +778,9 @@ int spa_bt_quirks_get_features(const struct spa_bt_quirks *quirks,
const struct spa_bt_adapter *adapter,
const struct spa_bt_device *device,
uint32_t *features);
void spa_bt_quirks_log_features(const struct spa_bt_quirks *this,
const struct spa_bt_adapter *adapter,
const struct spa_bt_device *device);
void spa_bt_quirks_destroy(struct spa_bt_quirks *quirks);
int spa_bt_adapter_has_msbc(struct spa_bt_adapter *adapter);

View file

@ -278,10 +278,11 @@ static void strtolower(char *src, char *dst, int maxsize)
*dst = '\0';
}
int spa_bt_quirks_get_features(const struct spa_bt_quirks *this,
static int get_features(const struct spa_bt_quirks *this,
const struct spa_bt_adapter *adapter,
const struct spa_bt_device *device,
uint32_t *features)
uint32_t *features,
bool debug)
{
struct spa_dict props;
struct spa_dict_item items[5];
@ -294,14 +295,17 @@ int spa_bt_quirks_get_features(const struct spa_bt_quirks *this,
uint32_t no_features = 0;
int nitems = 0;
struct utsname name;
if ((res = uname(&name)) < 0)
return res;
items[nitems++] = SPA_DICT_ITEM_INIT("sysname", name.sysname);
items[nitems++] = SPA_DICT_ITEM_INIT("release", name.release);
items[nitems++] = SPA_DICT_ITEM_INIT("version", name.version);
props = SPA_DICT_INIT(items, nitems);
if (debug)
log_props(this->log, &props);
do_match(this->kernel_rules, &props, &no_features);
if (debug)
spa_log_debug(this->log, "kernel quirks:%08x", no_features);
*features &= ~no_features;
}
@ -325,8 +329,10 @@ int spa_bt_quirks_get_features(const struct spa_bt_quirks *this,
items[nitems++] = SPA_DICT_ITEM_INIT("address", address);
}
props = SPA_DICT_INIT(items, nitems);
if (debug)
log_props(this->log, &props);
do_match(this->adapter_rules, &props, &no_features);
if (debug)
spa_log_debug(this->log, "adapter quirks:%08x", no_features);
*features &= ~no_features;
}
@ -352,8 +358,10 @@ int spa_bt_quirks_get_features(const struct spa_bt_quirks *this,
items[nitems++] = SPA_DICT_ITEM_INIT("address", address);
}
props = SPA_DICT_INIT(items, nitems);
if (debug)
log_props(this->log, &props);
do_match(this->device_rules, &props, &no_features);
if (debug)
spa_log_debug(this->log, "device quirks:%08x", no_features);
*features &= ~no_features;
}
@ -379,3 +387,21 @@ int spa_bt_quirks_get_features(const struct spa_bt_quirks *this,
return 0;
}
int spa_bt_quirks_get_features(const struct spa_bt_quirks *this,
const struct spa_bt_adapter *adapter,
const struct spa_bt_device *device,
uint32_t *features)
{
return get_features(this, adapter, device, features, false);
}
void spa_bt_quirks_log_features(const struct spa_bt_quirks *this,
const struct spa_bt_adapter *adapter,
const struct spa_bt_device *device)
{
uint32_t features = 0;
get_features(this, adapter, device, &features, true);
spa_log_debug(this->log, "features:%08x", features);
}