1068
1069
case AVDTP_STATE_OPEN:
1069
1070
stream->starting = FALSE;
1070
if (old_state > AVDTP_STATE_OPEN && session->auto_dc)
1071
if ((old_state > AVDTP_STATE_OPEN && session->auto_dc) ||
1071
1073
stream->idle_timer = g_timeout_add_seconds(STREAM_TIMEOUT,
1072
1074
stream_timeout,
1075
1077
case AVDTP_STATE_STREAMING:
1078
if (stream->idle_timer) {
1079
g_source_remove(stream->idle_timer);
1080
stream->idle_timer = 0;
1082
stream->open_acp = FALSE;
1076
1084
case AVDTP_STATE_CLOSING:
1077
1085
case AVDTP_STATE_ABORTING:
1078
1086
if (stream->idle_timer) {
1634
1642
static gboolean avdtp_reconf_cmd(struct avdtp *session, uint8_t transaction,
1635
1643
struct seid_req *req, int size)
1637
return avdtp_unknown_cmd(session, transaction, AVDTP_RECONFIGURE);
1645
struct conf_rej rej;
1647
rej.error = AVDTP_NOT_SUPPORTED_COMMAND;
1648
rej.category = 0x00;
1650
return avdtp_send(session, transaction, AVDTP_MSG_TYPE_REJECT,
1651
AVDTP_RECONFIGURE, &rej, sizeof(rej));
1654
static void check_seid_collision(struct pending_req *req, uint8_t id)
1656
struct seid_req *seid = req->data;
1658
if (seid->acp_seid == id)
1659
req->collided = TRUE;
1662
static void check_start_collision(struct pending_req *req, uint8_t id)
1664
struct start_req *start = req->data;
1665
struct seid *seid = &start->first_seid;
1666
int count = 1 + req->data_size - sizeof(struct start_req);
1669
for (i = 0; i < count; i++, seid++) {
1670
if (seid->seid == id) {
1671
req->collided = TRUE;
1677
static void check_suspend_collision(struct pending_req *req, uint8_t id)
1679
struct suspend_req *suspend = req->data;
1680
struct seid *seid = &suspend->first_seid;
1681
int count = 1 + req->data_size - sizeof(struct suspend_req);
1684
for (i = 0; i < count; i++, seid++) {
1685
if (seid->seid == id) {
1686
req->collided = TRUE;
1692
static void avdtp_check_collision(struct avdtp *session, uint8_t cmd,
1693
struct avdtp_stream *stream)
1695
struct pending_req *req = session->req;
1697
if (req == NULL || (req->signal_id != cmd && cmd != AVDTP_ABORT))
1700
if (cmd == AVDTP_ABORT)
1701
cmd = req->signal_id;
1706
check_seid_collision(req, stream->rseid);
1709
check_start_collision(req, stream->rseid);
1712
check_suspend_collision(req, stream->rseid);
1640
1717
static gboolean avdtp_open_cmd(struct avdtp *session, uint8_t transaction,
1748
avdtp_check_collision(session, AVDTP_OPEN, stream);
1671
1750
if (!avdtp_send(session, transaction, AVDTP_MSG_TYPE_ACCEPT,
1672
1751
AVDTP_OPEN, NULL, 0))
1717
1796
stream = sep->stream;
1719
/* Also reject start cmd if we already initiated start */
1720
if (sep->state != AVDTP_STATE_OPEN ||
1721
stream->starting == TRUE) {
1798
/* Also reject start cmd if state is not open */
1799
if (sep->state != AVDTP_STATE_OPEN) {
1722
1800
err = AVDTP_BAD_STATE;
1860
avdtp_check_collision(session, AVDTP_CLOSE, stream);
1780
1862
avdtp_sep_set_state(session, sep, AVDTP_STATE_CLOSING);
1782
1864
if (!avdtp_send(session, transaction, AVDTP_MSG_TYPE_ACCEPT,
1865
1949
sep = find_local_sep_by_seid(session->server, req->acp_seid);
1866
if (!sep || !sep->stream) {
1867
err = AVDTP_BAD_ACP_SEID;
1871
if (sep->ind && sep->ind->abort) {
1872
if (!sep->ind->abort(session, sep, sep->stream, &err,
1950
if (!sep || !sep->stream)
1953
if (sep->ind && sep->ind->abort)
1954
sep->ind->abort(session, sep, sep->stream, &err,
1957
avdtp_check_collision(session, AVDTP_ABORT, sep->stream);
1877
1959
ret = avdtp_send(session, transaction, AVDTP_MSG_TYPE_ACCEPT,
1878
1960
AVDTP_ABORT, NULL, 0);
1880
1962
avdtp_sep_set_state(session, sep, AVDTP_STATE_ABORTING);
1885
return avdtp_send(session, transaction, AVDTP_MSG_TYPE_REJECT,
1886
AVDTP_ABORT, &err, sizeof(err));
1889
1967
static gboolean avdtp_secctl_cmd(struct avdtp *session, uint8_t transaction,
3574
3658
if (stream->lsep->state != AVDTP_STATE_OPEN)
3575
3659
return -EINVAL;
3661
/* Recommendation 12:
3662
* If the RD has configured and opened a stream it is also responsible
3663
* to start the streaming via GAVDP_START.
3665
if (stream->open_acp) {
3666
stream->starting = TRUE;
3577
3670
if (stream->close_int == TRUE) {
3578
3671
error("avdtp_start: rejecting start since close is initiated");
3579
3672
return -EINVAL;