struct avdtp_stream *stream;
struct avdtp_error *err;
avdtp_set_configuration_cb setconf_cb;
- GSList *client_caps;
+ GSList *caps;
gboolean reconfigure;
gboolean start;
GSList *cb;
avdtp_unref(s->session);
g_slist_foreach(s->cb, (GFunc) g_free, NULL);
g_slist_free(s->cb);
+ g_slist_foreach(s->caps, (GFunc) g_free, NULL);
+ g_slist_free(s->caps);
g_free(s);
}
return finalize_suspend(s);
}
-static gboolean finalize_select(struct a2dp_setup *s, GSList *caps)
+static gboolean finalize_select(struct a2dp_setup *s)
{
GSList *l;
if (!cb->select_cb)
continue;
- cb->select_cb(s->session, s->sep, caps, cb->user_data);
+ cb->select_cb(s->session, s->sep, s->caps, cb->user_data);
setup_cb_free(cb);
}
posix_err = avdtp_set_configuration(setup->session, setup->rsep,
sep->lsep,
- setup->client_caps,
+ setup->caps,
&setup->stream);
if (posix_err < 0) {
error("avdtp_set_configuration: %s", strerror(-posix_err));
struct a2dp_setup *setup = user_data;
struct avdtp_service_capability *media_transport, *media_codec;
struct avdtp_media_codec_capability *cap;
- GSList *caps = NULL;
if (size < 0) {
DBG("Endpoint replied an invalid configuration");
media_transport = avdtp_service_cap_new(AVDTP_MEDIA_TRANSPORT,
NULL, 0);
- caps = g_slist_append(caps, media_transport);
+ setup->caps = g_slist_append(setup->caps, media_transport);
cap = g_malloc0(sizeof(*cap) + size);
cap->media_type = AVDTP_MEDIA_TYPE_AUDIO;
media_codec = avdtp_service_cap_new(AVDTP_MEDIA_CODEC, cap,
sizeof(*cap) + size);
- caps = g_slist_append(caps, media_codec);
+ setup->caps = g_slist_append(setup->caps, media_codec);
done:
- finalize_select(setup, caps);
+ finalize_select(setup);
}
static gboolean auto_select(gpointer data)
{
struct a2dp_setup *setup = data;
- finalize_select(setup, setup->client_caps);
+ finalize_select(setup);
return FALSE;
}
endpoint in the configuration file */
if (sep->endpoint == NULL) {
if (!select_capabilities(session, setup->rsep,
- &setup->client_caps)) {
+ &setup->caps)) {
error("Unable to auto select remote SEP capabilities");
goto fail;
}
setup->sep = sep;
setup->stream = sep->stream;
- setup->client_caps = caps;
+
+ /* Copy given caps if they are different than current caps */
+ if (setup->caps != caps) {
+ g_slist_foreach(setup->caps, (GFunc) g_free, NULL);
+ g_slist_free(setup->caps);
+ setup->caps = g_slist_copy(caps);
+ }
switch (avdtp_sep_get_state(sep->lsep)) {
case AVDTP_STATE_IDLE: