static void discover_cb(struct avdtp *session, GSList *seps, struct avdtp_error *err, void *user_data) { struct a2dp_device *dev = user_data; struct a2dp_endpoint *endpoint = NULL; struct avdtp_remote_sep *rsep = NULL; GSList *l; for (l = endpoints; l; l = g_slist_next(l)) { endpoint = l->data; rsep = avdtp_find_remote_sep(session, endpoint->sep); if (rsep) break; } if (!rsep) { error("Unable to find matching endpoint"); goto failed; } if (select_configuration(dev, endpoint, rsep) < 0) goto failed; return; failed: avdtp_shutdown(session); }
static int select_config(struct a2dp_sep *sep, uint8_t *capabilities, size_t length, struct a2dp_setup *setup, a2dp_endpoint_select_t cb, void *user_data) { struct media_endpoint *endpoint = user_data; struct a2dp_select_data *data; data = g_new0(struct a2dp_select_data, 1); data->setup = setup; data->cb = cb; if (select_configuration(endpoint, capabilities, length, select_cb, data, g_free) == TRUE) return 0; g_free(data); return -ENOMEM; }