本文整理汇总了C++中pending_request_free函数的典型用法代码示例。如果您正苦于以下问题:C++ pending_request_free函数的具体用法?C++ pending_request_free怎么用?C++ pending_request_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pending_request_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sink_free
static void sink_free(struct audio_device *dev)
{
struct sink *sink = dev->sink;
if (sink->cb_id)
avdtp_stream_remove_cb(sink->session, sink->stream,
sink->cb_id);
if (sink->dc_id)
device_remove_disconnect_watch(dev->btd_dev, sink->dc_id);
if (sink->session)
avdtp_unref(sink->session);
if (sink->connect)
pending_request_free(dev, sink->connect);
if (sink->disconnect)
pending_request_free(dev, sink->disconnect);
if (sink->retry_id)
g_source_remove(sink->retry_id);
g_free(sink);
dev->sink = NULL;
}
示例2: stream_setup_complete
static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep,
struct avdtp_stream *stream,
struct avdtp_error *err, void *user_data)
{
struct sink *sink = user_data;
struct pending_request *pending;
pending = sink->connect;
if (stream) {
DBusMessage *reply;
sink->connect = NULL;
reply = dbus_message_new_method_return(pending->msg);
dbus_connection_send(pending->conn, reply, NULL);
dbus_message_unref(reply);
pending_request_free(pending);
debug("Stream successfully created");
} else {
avdtp_unref(sink->session);
sink->session = NULL;
if (avdtp_error_type(err) == AVDTP_ERROR_ERRNO
&& avdtp_error_posix_errno(err) != EHOSTDOWN) {
debug("connect:connect XCASE detected");
g_timeout_add(STREAM_SETUP_RETRY_TIMER,
stream_setup_retry, sink);
} else {
sink->connect = NULL;
error_failed(pending->conn, pending->msg, "Stream setup failed");
pending_request_free(pending);
debug("Stream setup failed : %s", avdtp_strerror(err));
}
}
}
示例3: sink_shutdown
gboolean sink_shutdown(struct sink *sink)
{
if (!sink->session)
return FALSE;
avdtp_set_device_disconnect(sink->session, TRUE);
/* cancel pending connect */
if (sink->connect) {
struct pending_request *pending = sink->connect;
if (pending->msg)
error_failed(pending->conn, pending->msg,
"Stream setup failed");
pending_request_free(sink->dev, pending);
sink->connect = NULL;
avdtp_unref(sink->session);
sink->session = NULL;
return TRUE;
}
/* disconnect already ongoing */
if (sink->disconnect)
return TRUE;
if (!sink->stream)
return FALSE;
if (avdtp_close(sink->session, sink->stream, FALSE) < 0)
return FALSE;
return TRUE;
}
示例4: stream_state_changed
static void stream_state_changed(struct avdtp_stream *stream,
avdtp_state_t old_state,
avdtp_state_t new_state,
struct avdtp_error *err,
void *user_data)
{
struct audio_device *dev = user_data;
struct source *source = dev->source;
if (err)
return;
switch (new_state) {
case AVDTP_STATE_IDLE:
if (source->disconnect) {
DBusMessage *reply;
struct pending_request *p;
p = source->disconnect;
source->disconnect = NULL;
reply = dbus_message_new_method_return(p->msg);
g_dbus_send_message(p->conn, reply);
pending_request_free(dev, p);
}
if (source->dc_id) {
device_remove_disconnect_watch(dev->btd_dev,
source->dc_id);
source->dc_id = 0;
}
if (source->session) {
avdtp_unref(source->session);
source->session = NULL;
}
source->stream = NULL;
source->cb_id = 0;
break;
case AVDTP_STATE_OPEN:
if (old_state == AVDTP_STATE_CONFIGURED &&
source->state == SOURCE_STATE_CONNECTING) {
source->dc_id = device_add_disconnect_watch(dev->btd_dev,
disconnect_cb,
dev, NULL);
}
source_set_state(dev, SOURCE_STATE_CONNECTED);
break;
case AVDTP_STATE_STREAMING:
source_set_state(dev, SOURCE_STATE_PLAYING);
break;
case AVDTP_STATE_CONFIGURED:
case AVDTP_STATE_CLOSING:
case AVDTP_STATE_ABORTING:
default:
break;
}
source->stream_state = new_state;
}
示例5: async_cb
static void async_cb(GObex *obex, GError *err, GObexPacket *rsp,
gpointer user_data)
{
struct pending_request *p = user_data;
struct obc_session *session = p->session;
GError *gerr = NULL;
uint8_t code;
p->req_id = 0;
if (err != NULL) {
if (p->func)
p->func(p->session, NULL, err, p->data);
goto done;
}
code = g_obex_packet_get_operation(rsp, NULL);
if (code != G_OBEX_RSP_SUCCESS)
g_set_error(&gerr, OBEX_IO_ERROR, code, "%s",
g_obex_strerror(code));
if (p->func)
p->func(p->session, NULL, gerr, p->data);
if (gerr != NULL)
g_clear_error(&gerr);
done:
pending_request_free(p);
session->p = NULL;
session_process_queue(session);
}
示例6: session_terminate_transfer
static void session_terminate_transfer(struct obc_session *session,
struct obc_transfer *transfer,
GError *gerr)
{
struct pending_request *p = session->p;
if (p == NULL || p->transfer != transfer) {
GList *match;
match = g_list_find_custom(session->queue->head, transfer,
pending_transfer_cmptransfer);
if (match == NULL)
return;
p = match->data;
g_queue_delete_link(session->queue, match);
} else
session->p = NULL;
obc_session_ref(session);
if (p->func)
p->func(session, p->transfer, gerr, p->data);
pending_request_free(p);
if (session->p == NULL)
session_process_queue(session);
obc_session_unref(session);
}
示例7: obc_session_mkdir
guint obc_session_mkdir(struct obc_session *session, const char *folder,
session_callback_t func, void *user_data,
GError **err)
{
struct pending_request *p;
if (session->obex == NULL) {
g_set_error(err, OBEX_IO_ERROR, OBEX_IO_DISCONNECTED,
"Session disconnected");
return 0;
}
if (session->p != NULL) {
g_set_error(err, OBEX_IO_ERROR, OBEX_IO_BUSY, "Session busy");
return 0;
}
p = pending_request_new(session, NULL, func, user_data);
p->req_id = g_obex_mkdir(session->obex, folder, async_cb, p, err);
if (*err != NULL) {
pending_request_free(p);
return 0;
}
session->p = p;
return p->id;
}
示例8: session_process_queue
static void session_process_queue(struct obc_session *session)
{
struct pending_request *p;
if (session->p != NULL)
return;
if (session->queue == NULL || g_queue_is_empty(session->queue))
return;
obc_session_ref(session);
while ((p = g_queue_pop_head(session->queue))) {
GError *gerr = NULL;
if (p->process(p, &gerr) == 0)
break;
if (p->func)
p->func(session, p->transfer, gerr, p->data);
g_clear_error(&gerr);
pending_request_free(p);
}
obc_session_unref(session);
}
示例9: stream_setup_retry
static gboolean stream_setup_retry(gpointer user_data)
{
struct sink *sink = user_data;
struct pending_request *pending = sink->connect;
sink->retry_id = 0;
if (sink->stream_state >= AVDTP_STATE_OPEN) {
DBG("Stream successfully created, after XCASE connect:connect");
if (pending->msg) {
DBusMessage *reply;
reply = dbus_message_new_method_return(pending->msg);
g_dbus_send_message(pending->conn, reply);
}
} else {
DBG("Stream setup failed, after XCASE connect:connect");
if (pending->msg)
error_failed(pending->conn, pending->msg, "Stream setup failed");
}
sink->connect = NULL;
pending_request_free(sink->dev, pending);
return FALSE;
}
示例10: select_complete
static void select_complete(struct avdtp *session, struct a2dp_sep *sep,
GSList *caps, void *user_data)
{
struct sink *sink = user_data;
struct pending_request *pending;
int id;
pending = sink->connect;
pending->id = 0;
id = a2dp_config(session, sep, stream_setup_complete, caps, sink);
if (id == 0)
goto failed;
pending->id = id;
return;
failed:
if (pending->msg)
error_failed(pending->conn, pending->msg, "Stream setup failed");
pending_request_free(sink->dev, pending);
sink->connect = NULL;
avdtp_unref(sink->session);
sink->session = NULL;
}
示例11: session_process_queue
static void session_process_queue(struct obc_session *session)
{
struct pending_request *p;
if (session->p != NULL)
return;
if (session->queue == NULL || g_queue_is_empty(session->queue))
return;
obc_session_ref(session);
while ((p = g_queue_pop_head(session->queue))) {
GError *gerr = NULL;
DBG("Transfer(%p) started", p->transfer);
if (obc_transfer_start(p->transfer, session->obex, &gerr)) {
session->p = p;
break;
}
if (p->func)
p->func(session, p->transfer, gerr, p->data);
g_clear_error(&gerr);
pending_request_free(p);
}
obc_session_unref(session);
}
示例12: obc_session_shutdown
void obc_session_shutdown(struct obc_session *session)
{
struct pending_request *p;
GError *err;
DBG("%p", session);
obc_session_ref(session);
/* Unregister any pending transfer */
err = g_error_new(OBEX_IO_ERROR, OBEX_IO_DISCONNECTED,
"Session closed by user");
if (session->p != NULL && session->p->id != 0) {
p = session->p;
session->p = NULL;
if (p->func)
p->func(session, p->transfer, err, p->data);
pending_request_free(p);
}
while ((p = g_queue_pop_head(session->queue))) {
if (p->func)
p->func(session, p->transfer, err, p->data);
pending_request_free(p);
}
g_error_free(err);
/* Unregister interfaces */
if (session->path)
session_unregistered(session);
/* Disconnect transport */
if (session->id > 0 && session->transport != NULL) {
session->transport->disconnect(session->id);
session->id = 0;
}
obc_session_unref(session);
}
示例13: stream_setup_complete
static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep,
struct avdtp_stream *stream,
struct avdtp_error *err, void *user_data)
{
struct sink *sink = user_data;
struct pending_request *pending;
pending = sink->connect;
pending->id = 0;
if (stream) {
DBG("Stream successfully created");
if (pending->msg) {
DBusMessage *reply;
reply = dbus_message_new_method_return(pending->msg);
g_dbus_send_message(pending->conn, reply);
}
sink->connect = NULL;
pending_request_free(sink->dev, pending);
return;
}
avdtp_unref(sink->session);
sink->session = NULL;
if (avdtp_error_category(err) == AVDTP_ERRNO
&& avdtp_error_posix_errno(err) != EHOSTDOWN) {
DBG("connect:connect XCASE detected");
sink->retry_id = g_timeout_add_seconds(STREAM_SETUP_RETRY_TIMER,
stream_setup_retry,
sink);
} else {
if (pending->msg)
error_failed(pending->conn, pending->msg, "Stream setup failed");
sink->connect = NULL;
pending_request_free(sink->dev, pending);
DBG("Stream setup failed : %s", avdtp_strerror(err));
}
}
示例14: sink_free
void sink_free(struct audio_device *dev)
{
struct sink *sink = dev->sink;
if (sink->cb_id)
avdtp_stream_remove_cb(sink->session, sink->stream,
sink->cb_id);
if (sink->session)
avdtp_unref(sink->session);
if (sink->connect)
pending_request_free(sink->connect);
if (sink->disconnect)
pending_request_free(sink->disconnect);
g_free(sink);
dev->sink = NULL;
}
示例15: discovery_complete
static void discovery_complete(struct avdtp *session, GSList *seps, struct avdtp_error *err,
void *user_data)
{
struct sink *sink = user_data;
struct pending_request *pending;
struct avdtp_local_sep *lsep;
struct avdtp_remote_sep *rsep;
GSList *caps = NULL;
int id;
pending = sink->connect;
if (err) {
avdtp_unref(sink->session);
sink->session = NULL;
if (avdtp_error_type(err) == AVDTP_ERROR_ERRNO
&& avdtp_error_posix_errno(err) != EHOSTDOWN) {
debug("connect:connect XCASE detected");
g_timeout_add(STREAM_SETUP_RETRY_TIMER,
stream_setup_retry, sink);
} else
goto failed;
return;
}
debug("Discovery complete");
if (avdtp_get_seps(session, AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
A2DP_CODEC_SBC, &lsep, &rsep) < 0) {
error("No matching ACP and INT SEPs found");
goto failed;
}
if (!select_capabilities(session, rsep, &caps)) {
error("Unable to select remote SEP capabilities");
goto failed;
}
id = a2dp_source_config(sink->session, stream_setup_complete,
caps, sink);
if (id == 0)
goto failed;
pending->id = id;
return;
failed:
pending_request_free(pending);
sink->connect = NULL;
avdtp_unref(sink->session);
sink->session = NULL;
error_failed(pending->conn, pending->msg, "Stream setup failed");
}