return false;
for (i = 0; i < PA_BLUETOOTH_PROFILE_COUNT; i++)
- if (d->profile_state[i] >= PA_BT_AUDIO_STATE_CONNECTED)
+ if (d->transports[i])
return true;
return false;
enum profile p;
DBusMessageIter args, props;
DBusMessage *r;
+ bool old_any_connected;
dbus_message_iter_init(m, &args);
goto fail;
}
+ old_any_connected = pa_bluetooth_device_any_audio_connected(d);
+
sender = dbus_message_get_sender(m);
t = transport_new(d, sender, path, p, config, size);
pa_assert_se(r = dbus_message_new_method_return(m));
+ if (old_any_connected != pa_bluetooth_device_any_audio_connected(d))
+ run_callback(d, FALSE);
+
return r;
fail:
}
if ((t = pa_hashmap_get(y->transports, path))) {
+ bool old_any_connected = t->device ? pa_bluetooth_device_any_audio_connected(t->device) : false;
+
pa_log_debug("Clearing transport %s profile %d", t->path, t->profile);
t->device->transports[t->profile] = NULL;
pa_hashmap_remove(y->transports, t->path);
t->state = PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED;
pa_hook_fire(&y->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED], t);
transport_free(t);
+
+ if (t->device && old_any_connected != pa_bluetooth_device_any_audio_connected(t->device))
+ run_callback(t->device, FALSE);
}
pa_assert_se(r = dbus_message_new_method_return(m));
if (*d != PROFILE_OFF) {
const pa_bluetooth_device *device = u->device;
- if (device->profile_state[*d] < PA_BT_AUDIO_STATE_CONNECTED) {
+ if (!device->transports[*d]) {
pa_log_warn("Profile not connected, refused to switch profile to %s", new_profile->name);
return -PA_ERR_IO;
}
d = PA_CARD_PROFILE_DATA(u->card->active_profile);
- if (*d != PROFILE_OFF && (device->profile_state[*d] < PA_BT_AUDIO_STATE_CONNECTED)) {
+ if (*d != PROFILE_OFF && !device->transports[*d]) {
pa_log_warn("Default profile not connected, selecting off profile");
u->card->active_profile = pa_hashmap_get(u->card->profiles, "off");
u->card->save_profile = FALSE;