static guint suspend_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); if (!owner) { a2dp_sep_unlock(sep, a2dp->session); transport->in_use = FALSE; return 0; } return a2dp_suspend(a2dp->session, sep, a2dp_suspend_complete, owner); }
static guint suspend_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); if (owner != NULL) return a2dp_suspend(a2dp->session, sep, a2dp_suspend_complete, owner); transport_set_state(transport, TRANSPORT_STATE_IDLE); a2dp_sep_unlock(sep, a2dp->session); return 0; }
static void start_suspend(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("Unable to get a sep"); goto failed; } id = a2dp_suspend(a2dp->session, a2dp->sep, a2dp_suspend_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_suspend_stream(dev, headset_suspend_complete, client); client->cancel = headset_cancel_stream; break; case TYPE_GATEWAY: gateway_suspend_stream(dev); client->cancel = gateway_cancel_stream; headset_suspend_complete(dev, client); id = 1; break; default: error("No known services for device"); goto failed; } if (id == 0) { error("suspend failed"); goto failed; } return; failed: if (unref_avdtp_on_fail && a2dp->session) { avdtp_unref(a2dp->session); a2dp->session = NULL; } unix_ipc_error(client, BT_STOP_STREAM, EIO); }