Commit Graph

196 Commits

Author SHA1 Message Date
Luiz Augusto von Dentz
f87e1bed13 Add initial implementation of org.bluez.Media spec 2010-09-15 15:21:53 +03:00
Luiz Augusto von Dentz
368b35aaee Fix crash when there is no enough space to fragment avdtp packet
This was catch when running codenomicon tests when the output mtu is not
big enough to stuff fragmented packets.
2010-08-19 14:06:51 +03:00
Luiz Augusto von Dentz
0f775bfff6 Remove redundant information that is already present in DBG 2010-06-29 10:29:10 +03:00
Johan Hedberg
331c7dfa40 Add an error log when avdtp_close fails in stream_timeout 2010-06-17 12:26:31 +03:00
Johan Hedberg
bac81ba536 Coding style cleanup 2010-05-26 13:14:25 +03:00
Gustavo F. Padovan
8e58667ef0 Move debug() to DBG()
Use the new dynamic debug feature
2010-05-21 18:21:48 +02:00
Gustavo F. Padovan
e891f7df62 Move logging.{c,h} to log.{c,h}
Try to make log stuff more similar to ConnMan and oFono.
2010-05-21 14:40:36 +02:00
Luiz Augusto Von Dentz
ab816e6549 Add immediate parameter to avdtp_close
When TRUE if there is an outstanding command in the sending queue it will
cause abort which cancel any pending command.
2010-03-24 23:32:24 +02:00
Luiz Augusto Von Dentz
f8d790861c Send abort on while cancelling a2dp setup
This should guarantee that any outstanding command in the queue is
cancelled, accourding to the avdtp spec:

"6.16 Abort
Because AVDTP is typically used on unreliable channels, signaling messages
can be lost due to L2CAP Flush Timeouts. To react to inconsistencies
between the INT and ACP states, the Abort Command may be used."

It also says abort can be send regardless of the state even in case of
packet fragmantation:

"Note that it is permitted to breakdown a packet sequence (command or
response message) to send an Abort command message in the same direction.
The remaining packets consecutive to an aborted message shall be flushed by
the sender."
2010-03-24 23:32:24 +02:00
Luiz Augusto Von Dentz
abe8bb2d3b Make abort requests to have a shorter timeout
Regular request takes 4 secs to timeout, but this may be too long to wait
for abort command so it is now reduced to 2 secs.
2010-03-24 23:32:24 +02:00
Luiz Augusto Von Dentz
43830baea4 Fix avdtp_abort not canceling pending requests 2010-03-24 23:32:24 +02:00
Luiz Augusto Von Dentz
0085717ed4 Drop connection if abort is rejected
Make it consistent with the logic when abort timeout since the original
intent is to cancel a pending request there is no point in keeping the
connection if it is in an unrecoverable state.
2010-03-24 23:23:37 +02:00
Daniel Orstadius
c63916361c Fix double free on AVDTP Abort response
The pending request might be freed twice when receiving an Abort
response, in handle_unanswered_req and session_cb. Avoid freeing
it in handle_unanswered_req.
2010-02-21 10:44:08 -03:00
Luiz Augusto Von Dentz
3a16e6d242 Mark inuse flag whenever a stream is configured
Currently it was only marked when acting as the initiator.
2010-02-18 14:08:17 -03:00
Luiz Augusto Von Dentz
28d337cd21 Fix possible crash while verifying avdtp version
Reproducible with Codenomicon A2DP testsuite 1.4.2.
2010-02-17 02:01:07 -08:00
Daniel Orstadius
e9b1a8f726 Handle unanswered AVDTP request on disconnect
If the connection is lost when there is an AVDTP request the remote has
not replied to and which has not timed out, then at least in some cases
the callback for the request is not called leading to no Error response
being sent on the Audio API.

This patch checks if there is an outstanding request when the stream
state goes to idle and in that case triggers the corresponding callback
with an error.
2010-02-10 05:29:40 -05:00
Johan Hedberg
5592142cb9 Update Nokia copyrights 2010-01-07 01:11:05 -08:00
Marcel Holtmann
9184e2eeb7 Update copyright information 2010-01-01 17:08:17 -08:00
Johan Hedberg
45442bb290 Fix sending incorrect AVDTP commands after a timeout occurs
Since request_timeout() does callbacks into a2dp.c before sending the
ABORT command we need to make sure that none of the callbacks can
trigger sending any further AVDTP commands. This is easiest done by
setting the stream->abort_int flag early in the request_timeout function
and then checking for it in the send_request function.
2009-11-20 14:25:01 +02:00
Johan Hedberg
5f8a274881 Add support for AVDTP 1.3 Delay Reporting
This patch adds support for the new Delay Report command in AVDTP 1.3.
2009-10-06 19:18:53 +02:00
Johan Hedberg
9c39d108d8 Fix off-by-one issue with AVDTP capability parsing 2009-10-06 16:49:21 +02:00
Johan Hedberg
28648cc398 Fix error code handling for AVDTP SetConfiguration response
Make sure to always set the error code to some valid value (the most
generic one is BAD_STATE).
2009-10-02 11:18:45 +02:00
Johan Hedberg
9cec7f8d2f Fix AVDTP suspend while closing
We should reject any suspend request if we've already started the close
procedure for a stream.
2009-09-16 14:15:22 +03:00
Johan Hedberg
d165bb2387 Fix command timeout handling when there's no stream
The media stream could be gone by the time that the AVDTP command timeout
expires (e.g. if the media transport channel gets closed prematurely). In
such a case there's no need to send a separate ABORT command but we can
directly proceed with closing the signalling channel.
2009-09-15 21:12:04 +03:00
Johan Hedberg
4694093ca9 Fix AVDTP ABORTING state transition
The transition to ABORTING state when acting as initiator should happen
when we receive the ABORT reply and not when we send the initial ABORT
command. The reply handling is already correct but since there's a state
change also in the sending part the later state change request would fail.
This patch fixes the issue by removing the state change when sending the
ABORT command.
2009-09-15 17:17:07 +03:00
Johan Hedberg
cadf787439 Fix stream handling when the media transport disconnects prematurely
We might not have a stream anymore when receiving the reply to a AVDTP
command that assumes that there is an existing stream. So ignore the
replies to these commands if we don't have a stream anymore.
2009-09-15 11:26:50 +03:00
Peter Hurley
854ac30779 Fixed duplicate attempt from device to connect 'signalling' channel
A device may attempt to initiate a duplicate avdtp channel while
a host-initiated channel connection is still pending. This
situation is referred to as 'XCASE connect:connect' in sink.c and
source.c. This fix rejects the device-initiated connection in this
circumstance.
2009-09-09 20:53:47 +03:00
Johan Hedberg
aa218c796c Fix AVDTP stream leak for invalid media transport config 2009-09-05 18:40:18 +03:00
Johan Hedberg
88d7897d4c Fix audio connection authorization handling with timeouts
When manager.c (HFP/HSP), avdtp.c (A2DP) or control.c wants to cancel an
authorization request it shouldnd't affect the requests of the other
modules. So btd_cancel_authorization cannot be used. This patch adds a new
cancellation function to device.c which will remove the specific callback
from the list and only if the list is empty call btd_cancel_authorization.
2009-09-04 18:50:56 +03:00
Johan Hedberg
9604e597d7 Fix authorization when the audio profiles are slow to connect
Incoming audio connections should be automatically authorized if either
HFP/HSP or A2DP is already connected for the same device.
2009-09-03 19:58:00 +03:00
Johan Hedberg
9428fbcf37 Fix AVDTP Abort when transport closes before response 2009-09-03 18:23:51 +03:00
Johan Hedberg
998b0976e2 Fix AVDTP General Reject to match ESR04
ESR04 (Errata Service Release to the Bluetooth spec) clarifies the content
of the general reject AVDTP message to contain the original signal
identifier. It also specifies a new message type 0x01 for the general
reject. The change is also present in the latest AVDTP test specification.
2009-09-02 18:11:43 +03:00
Johan Hedberg
e297183416 Reject AVDTP_DISCOVER when there are no SEPs available 2009-09-02 12:28:40 +03:00
Daniel Orstadius
23f3293d30 Reject AVDTP START/STOP when disconnecting 2009-09-02 12:28:27 +03:00
João Paulo Rechi Vita
f79bab5a11 Create A2DP Source interface. 2009-07-13 22:16:26 +03:00
Johan Hedberg
5ad144c524 Don't assert on AVDTP reference count bugs
In the case that the AVDTP session references weren't fully dropped when a
disconnection happens, in later reconnections the disconnect_timeout
function cound have a reference count higher than 1. These bugs naturally
need to fixed (and there's a proper error() call to log them) but we can
still handle the situation semi-cleanly instead of asserting and aborting
since the AVDTP session struct will just silently hang around and get
reused at the next connection attempt.
2009-06-17 02:37:06 +03:00
Johan Hedberg
b72c346901 Call shutdown() on A2DP audio stream channel before closing
This makes sure that no other process (e.g. pulseaudio) reads or writes
the stream channel after it is logically closed through the AVDTP
signalling channel.
2009-06-16 00:16:57 +03:00
Luiz Augusto von Dentz
e7e1be5d17 Fix bug which cause authorization to be denied in certain headsets.
Some headsets (Nokia HS-12W) connects first on avrcp and only then on hfp
so in case Trusted property is not set this will cause agent_authorize to
return -EBUSY and drop hfp connection.

The proper solution would be to group all connections requests only
sending one authorization so the agent either accept them all or not, but
that would require API changes which we are avoiding right now, so the
current fix only send one connection request which the reponse is used for
the rest of the connections.
2009-06-15 18:10:39 +03:00
Johan Hedberg
b472464eb8 Don't set the disconnect timer if both sides end up sending commands
Situations where both sides end up sending commands are rare but they can
happen. They are also not fatal since one side will usually just end up
getting a "SEP in bad state" error and give up its setup procedure while
the other sides setup succeeds.

If we have a command that's pending a reply for don't set the disconnect
timer after processing a command from the other device (this is especially
important since the timeout for our pending requests is longer than the
disconnect timeout (4 seconds vs. 1 second).
2009-06-13 18:56:03 +07:00
Johan Hedberg
0b66fb8794 Fix AVDTP Discover timeout handling
The AVDTP Discover command doesn't have a SEID in it (all other commands
do) so don't try to read it from the buffer (which would cause a
segfault).
2009-05-31 23:46:14 +03:00
Luiz Augusto von Dentz
24bd55a4a3 Make sure audio driver is probed when handling an incoming connections.
Driver should be probed when adding a reference so that can be released
when the device is temporary using .remove callback. In case of AVDTP as
it is not possible to verify if it is a source or sink it uses the same
uuid used for authorization request which is advance audio uuid.
2009-05-14 23:34:36 +03:00
Johan Hedberg
0a4ec18352 Fix try_send error handling 2009-05-07 21:09:21 +03:00
Luiz Augusto von Dentz
56b3f3c383 Make sessions list per server rather than global. 2009-05-04 10:16:46 -03:00
Johan Hedberg
18e22b01b6 Fix another format string issue 2009-05-04 11:00:23 +03:00
Johan Hedberg
924cbd7850 Fix more format string issues 2009-05-02 23:33:37 +03:00
Luiz Augusto von Dentz
f481e7faa9 Fix bug which prevent a2dp adapter driver probe to succeed a second time.
a2dp adapter driver was not calling avdtp_exit on adapter removal so the next
time it is probed it fail since the kernel reports that the address is already
in use.
2009-04-28 14:01:50 -03:00
Johan Hedberg
e5ae3e24c5 Fix manager_get_device to not always create a new device object
In the case that someone calls Adapter.RemoveDevice while we're connected to an
audio profile some function calls could be triggered to manager_get_device.
This patch makes sure these calls don't recreate the device object that was
just removed.
2009-04-11 20:01:00 +03:00
Johan Hedberg
a32df6e52f Fix incomming AVDTP connect while authorization in progress
avctp_get_internal will return NULL if we are waiting for authorizatoin to
succeed. This patch adds a check for it and rejects the connect attempt when
necessary.
2009-04-11 12:27:30 +03:00
Luiz Augusto von Dentz
7891d2c193 Prevent possible null pointer deference.
stream pointer should be valid no matter what state sep is assuming.
2009-04-01 13:55:49 -03:00
Luiz Augusto von Dentz
8c6f5ed4d5 Remove unused variable. 2009-04-01 11:59:51 -03:00