static guint resume_a2dp(struct media_transport *transport, struct media_owner *owner) { struct a2dp_transport *a2dp = transport->data; struct media_endpoint *endpoint = transport->endpoint; struct a2dp_sep *sep = media_endpoint_get_sep(endpoint); guint id; if (a2dp->session == NULL) { a2dp->session = avdtp_get(transport->device); if (a2dp->session == NULL) return 0; } if (state_in_use(transport->state)) return a2dp_resume(a2dp->session, sep, a2dp_resume_complete, owner); if (a2dp_sep_lock(sep, a2dp->session) == FALSE) return 0; id = a2dp_resume(a2dp->session, sep, a2dp_resume_complete, owner); if (id == 0) { a2dp_sep_unlock(sep, a2dp->session); return 0; } if (transport->state == TRANSPORT_STATE_IDLE) transport_set_state(transport, TRANSPORT_STATE_REQUESTING); return id; }
static guint resume_a2dp(struct media_transport *transport, struct media_owner *owner) { struct a2dp_transport *a2dp = transport->data; struct media_endpoint *endpoint = transport->endpoint; struct audio_device *device = transport->device; struct a2dp_sep *sep = media_endpoint_get_sep(endpoint); if (a2dp->session == NULL) { a2dp->session = avdtp_get(&device->src, &device->dst); if (a2dp->session == NULL) return 0; } if (transport->in_use == TRUE) goto done; transport->in_use = a2dp_sep_lock(sep, a2dp->session); if (transport->in_use == FALSE) return 0; done: return a2dp_resume(a2dp->session, sep, a2dp_resume_complete, owner); }
static void start_resume(struct audio_device *dev, struct unix_client *client) { struct a2dp_data *a2dp; struct headset_data *hs; unsigned int id; gboolean unref_avdtp_on_fail = FALSE; switch (client->type) { case TYPE_SINK: case TYPE_SOURCE: a2dp = &client->d.a2dp; if (!a2dp->session) { a2dp->session = avdtp_get(&dev->src, &dev->dst); unref_avdtp_on_fail = TRUE; } if (!a2dp->session) { error("Unable to get a session"); goto failed; } if (!a2dp->sep) { error("seid not opened"); goto failed; } id = a2dp_resume(a2dp->session, a2dp->sep, a2dp_resume_complete, client); client->cancel = a2dp_cancel; break; case TYPE_HEADSET: hs = &client->d.hs; if (!hs->locked) { error("seid not opened"); goto failed; } id = headset_request_stream(dev, headset_resume_complete, client); client->cancel = headset_cancel_stream; break; case TYPE_GATEWAY: if (gateway_request_stream(dev, gateway_resume_complete, client)) id = 1; else id = 0; client->cancel = gateway_cancel_stream; break; default: error("No known services for device"); goto failed; } if (id == 0) { error("start_resume: resume failed"); goto failed; } client->req_id = id; return; failed: if (unref_avdtp_on_fail && a2dp->session) { avdtp_unref(a2dp->session); a2dp->session = NULL; } unix_ipc_error(client, BT_START_STREAM, EIO); }