static DBusMessage *sink_suspend(DBusConnection *conn, DBusMessage *msg, void *data) { struct audio_device *device = data; struct sink *sink = device->sink; struct pending_request *pending; int err; if (!sink->session) return g_dbus_create_error(msg, ERROR_INTERFACE ".NotConnected", "Device not Connected"); if (sink->connect || sink->disconnect) return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed", "%s", strerror(EBUSY)); if (sink->state < AVDTP_STATE_OPEN) { DBusMessage *reply = dbus_message_new_method_return(msg); if (!reply) return NULL; avdtp_unref(sink->session); sink->session = NULL; return reply; } err = avdtp_suspend(sink->session, sink->stream); if (err < 0) return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed", "%s", strerror(-err)); return NULL; }
static void bt_stream_suspend(const void *buf, uint16_t len) { const struct audio_cmd_suspend_stream *cmd = buf; struct a2dp_setup *setup; int err; DBG(""); setup = find_setup(cmd->id); if (!setup) { error("Unable to find stream for endpoint %u", cmd->id); goto failed; } err = avdtp_suspend(setup->dev->session, setup->stream); if (err < 0) { error("avdtp_suspend: %s", strerror(-err)); goto failed; } ipc_send_rsp(audio_ipc, AUDIO_SERVICE_ID, AUDIO_OP_SUSPEND_STREAM, AUDIO_STATUS_SUCCESS); return; failed: ipc_send_rsp(audio_ipc, AUDIO_SERVICE_ID, AUDIO_OP_SUSPEND_STREAM, AUDIO_STATUS_FAILED); }
static void send_command(void) { avdtp_state_t state = avdtp_sep_get_state(local_sep); switch (command) { case CMD_GET_CONF: avdtp_get_configuration(avdtp, avdtp_stream); break; case CMD_OPEN: if (state == AVDTP_STATE_CONFIGURED) avdtp_open(avdtp, avdtp_stream); break; case CMD_START: if (state == AVDTP_STATE_OPEN) avdtp_start(avdtp, avdtp_stream); break; case CMD_SUSPEND: if (state == AVDTP_STATE_STREAMING) avdtp_suspend(avdtp , avdtp_stream); break; case CMD_CLOSE: if (state == AVDTP_STATE_STREAMING) avdtp_close(avdtp, avdtp_stream, FALSE); break; case CMD_ABORT: avdtp_abort(avdtp , avdtp_stream); break; case CMD_DELAY: avdtp_delay_report(avdtp , avdtp_stream , 250); break; default: break; } }
static gboolean suspend_timeout(struct a2dp_sep *sep) { if (avdtp_suspend(sep->session, sep->stream) == 0) sep->suspending = TRUE; sep->suspend_timer = 0; avdtp_unref(sep->session); sep->session = NULL; return FALSE; }