static guint resume_headset(struct media_transport *transport, struct media_owner *owner) { struct audio_device *device = transport->device; if (transport->in_use == TRUE) goto done; transport->in_use = headset_lock(device, HEADSET_LOCK_READ | HEADSET_LOCK_WRITE); if (transport->in_use == FALSE) return 0; done: return headset_request_stream(device, headset_resume_complete, owner); }
static void start_open(struct audio_device *dev, struct unix_client *client) { struct a2dp_data *a2dp; struct headset_data *hs; struct avdtp_remote_sep *rsep; 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("Client already has an opened session"); goto failed; } rsep = avdtp_get_remote_sep(a2dp->session, client->seid); if (!rsep) { error("Invalid seid %d", client->seid); goto failed; } a2dp->sep = a2dp_get(a2dp->session, rsep); if (!a2dp->sep) { error("seid %d not available or locked", client->seid); goto failed; } if (!a2dp_sep_lock(a2dp->sep, a2dp->session)) { error("Unable to open seid %d", client->seid); a2dp->sep = NULL; goto failed; } break; case TYPE_HEADSET: hs = &client->d.hs; if (hs->locked) { error("Client already has an opened session"); goto failed; } hs->locked = headset_lock(dev, client->lock); if (!hs->locked) { error("Unable to open seid %d", client->seid); goto failed; } break; case TYPE_GATEWAY: break; default: error("No known services for device"); goto failed; } client->dev = dev; open_complete(dev, client); return; failed: if (unref_avdtp_on_fail && a2dp->session) { avdtp_unref(a2dp->session); a2dp->session = NULL; } unix_ipc_error(client, BT_OPEN, EINVAL); }