bluetooth: Use transport state instead of profile states

The transport state also reflects the state of the audio interface. The
state redundancy can thus be minimized by always using the first one,
and avoiding the use of profile-specific states with the exception of
finding out the initial state of a transport.
This commit is contained in:
Mikel Astiz 2012-12-14 15:14:37 +01:00 committed by Tanu Kaskinen
parent 468c67bb62
commit d2bd3aa444
2 changed files with 14 additions and 3 deletions

View file

@ -1087,7 +1087,7 @@ bool pa_bluetooth_device_any_audio_connected(const pa_bluetooth_device *d) {
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;
@ -1257,6 +1257,7 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
enum profile p;
DBusMessageIter args, props;
DBusMessage *r;
bool old_any_connected;
dbus_message_iter_init(m, &args);
@ -1330,6 +1331,8 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
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);
@ -1343,6 +1346,9 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
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:
@ -1368,12 +1374,17 @@ static DBusMessage *endpoint_clear_configuration(DBusConnection *c, DBusMessage
}
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));