audio: Track connections to AVRCP roles separately

Currently the code assumes when one role connects the other must be
connected as well which is bogus and can create problems.
This commit is contained in:
Luiz Augusto von Dentz 2013-03-18 10:03:26 -03:00 committed by Johan Hedberg
parent e63b0f9035
commit bfe5f61794
4 changed files with 29 additions and 14 deletions

View File

@ -2667,6 +2667,8 @@ static void session_tg_init_control(struct avrcp *session)
if (session->version >= 0x0104)
avrcp_register_notification(session,
AVRCP_EVENT_VOLUME_CHANGED);
audio_controller_connected(session->dev->btd_dev, 0);
}
static void session_ct_init_browsing(struct avrcp *session)
@ -2692,6 +2694,8 @@ static void session_ct_init_control(struct avrcp *session)
if (session->version >= 0x0104)
session->supported_events = (1 << AVRCP_EVENT_VOLUME_CHANGED);
audio_target_connected(session->dev->btd_dev, 0);
player = create_ct_player(session, 0);
if (player == NULL)
return;
@ -2726,6 +2730,11 @@ static void session_tg_destroy(struct avrcp *session)
if (player != NULL)
player->sessions = g_slist_remove(player->sessions, session);
if (session->control_id == 0)
audio_controller_connected(session->dev->btd_dev, -EIO);
audio_controller_disconnected(session->dev->btd_dev, 0);
session_destroy(session);
}
@ -2735,6 +2744,11 @@ static void session_ct_destroy(struct avrcp *session)
g_slist_free_full(session->players, player_destroy);
if (session->control_id == 0)
audio_target_connected(session->dev->btd_dev, -EIO);
audio_target_disconnected(session->dev->btd_dev, 0);
session_destroy(session);
}

View File

@ -76,13 +76,6 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
case AVCTP_STATE_DISCONNECTED:
control->session = NULL;
if (old_state != AVCTP_STATE_CONNECTED) {
audio_control_connected(dev->btd_dev, -EIO);
break;
}
audio_control_disconnected(dev->btd_dev, 0);
g_dbus_emit_property_changed(conn, path,
AUDIO_CONTROL_INTERFACE, "Connected");
@ -95,8 +88,6 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
break;
case AVCTP_STATE_CONNECTED:
audio_control_connected(dev->btd_dev, 0);
g_dbus_emit_property_changed(conn, path,
AUDIO_CONTROL_INTERFACE, "Connected");
break;

View File

@ -419,15 +419,23 @@ void audio_source_disconnected(struct btd_device *dev, int err)
device_profile_disconnected(dev, &a2dp_source_profile, err);
}
void audio_control_connected(struct btd_device *dev, int err)
void audio_target_connected(struct btd_device *dev, int err)
{
device_profile_connected(dev, &avrcp_target_profile, err);
}
void audio_target_disconnected(struct btd_device *dev, int err)
{
device_profile_disconnected(dev, &avrcp_target_profile, err);
}
void audio_controller_connected(struct btd_device *dev, int err)
{
device_profile_connected(dev, &avrcp_remote_profile, err);
}
void audio_control_disconnected(struct btd_device *dev, int err)
void audio_controller_disconnected(struct btd_device *dev, int err)
{
device_profile_disconnected(dev, &avrcp_target_profile, err);
device_profile_disconnected(dev, &avrcp_remote_profile, err);
}

View File

@ -33,8 +33,10 @@ void audio_sink_connected(struct btd_device *dev, int err);
void audio_sink_disconnected(struct btd_device *dev, int err);
void audio_source_connected(struct btd_device *dev, int err);
void audio_source_disconnected(struct btd_device *dev, int err);
void audio_control_connected(struct btd_device *dev, int err);
void audio_control_disconnected(struct btd_device *dev, int err);
void audio_target_connected(struct btd_device *dev, int err);
void audio_target_disconnected(struct btd_device *dev, int err);
void audio_controller_connected(struct btd_device *dev, int err);
void audio_controller_disconnected(struct btd_device *dev, int err);
int audio_manager_init(GKeyFile *config);
void audio_manager_exit(void);