/* check if profile has a transport */
t = u->device->transports[u->profile];
- if (t == NULL) {
+ if (!t || t->state == PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED) {
pa_log_warn("Profile has no transport");
return -1;
}
if (*d != PROFILE_OFF) {
const pa_bluetooth_device *device = u->device;
- if (!device->transports[*d]) {
+ if (!device->transports[*d] || device->transports[*d]->state == PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED) {
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->transports[*d]) {
+ if (*d != PROFILE_OFF && (!device->transports[*d] ||
+ device->transports[*d]->state == PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED)) {
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;