Commit Graph

1532 Commits

Author SHA1 Message Date
Frédéric Dalleau
b15f606312 Add watch for RFCOMM disconnect to HFP HF role 2011-08-05 12:18:41 +03:00
Frédéric Danis
3163523575 audio: add profile version to HandsfreeAgent
Some phones with HFP Audio Gateway version previous to 1.5 (e.g.
Samsung SGH-D600 returning 0x0101 as profile version) do not accept an
AT+BRSF with latest features. The Handsfree agent should adapt its
AT+BRSF command depending on the remote version, so add version
information as parameter of NewConnection method.

Here is traces of buggy exchange:

< ACL data: handle 12 flags 0x02 dlen 20
    L2CAP(d): cid 0x0046 len 16 [psm 3]
      RFCOMM(d): UIH: cr 1 dlci 10 pf 0 ilen 12 fcs 0xb0
      0000: 41 54 2b 42 52 53 46 3d  31 31 38 0d              AT+BRSF=118.
> ACL data: handle 12 flags 0x02 dlen 18
    L2CAP(d): cid 0x0041 len 14 [psm 3]
      RFCOMM(d): UIH: cr 0 dlci 10 pf 1 ilen 9 fcs 0x76 credits 1
      0000: 0d 0a 45 52 52 4f 52 0d  0a                       ..ERROR..
< ACL data: handle 12 flags 0x02 dlen 8
    L2CAP(d): cid 0x0046 len 4 [psm 3]
      RFCOMM(s): DISC: cr 1 dlci 10 pf 1 ilen 0 fcs 0x6d

and after the fix (and corresponding fix in oFono):

< ACL data: handle 12 flags 0x02 dlen 19
    L2CAP(d): cid 0x0048 len 15 [psm 3]
      RFCOMM(d): UIH: cr 1 dlci 10 pf 0 ilen 11 fcs 0xb0
      0000: 41 54 2b 42 52 53 46 3d  32 32 0d                 AT+BRSF=22.
> ACL data: handle 12 flags 0x02 dlen 28
    L2CAP(d): cid 0x0041 len 24 [psm 3]
      RFCOMM(d): UIH: cr 0 dlci 10 pf 1 ilen 19 fcs 0x76 credits 1
      0000: 0d 0a 2b 42 52 53 46 3a  20 33 33 0d 0a 0d 0a 4f  ..+BRSF: 33....O
      0010: 4b 0d 0a                                          K..
< ACL data: handle 12 flags 0x02 dlen 18
    L2CAP(d): cid 0x0048 len 14 [psm 3]
      RFCOMM(d): UIH: cr 1 dlci 10 pf 0 ilen 10 fcs 0xb0
      0000: 41 54 2b 43 49 4e 44 3d  3f 0d                    AT+CIND=?.
2011-08-04 14:02:39 +03:00
Claudio Takahasi
9c0c6b6b33 Remove unneeded textfile header includes 2011-08-02 10:53:38 +03:00
Szymon Janc
53e6e763d2 Fix telephony driver compilation with GLib < 2.28 2011-07-19 00:05:40 +03:00
Lukasz Rymanowski
c34e795644 Fix headset state callback in Media API
Headset watch is not registered per device. Therefore, when headset
disconnects, there is need to check for which audio device it is called.
2011-07-10 10:57:17 +03:00
Peter Hurley
5d88d8d690 avdtp: fix race condition when starting a stream
The AVDTP spec allows for a race condition between remote and local
device when issuing an AVDTP_START cmd on a stream in the OPEN state.

However, the internal state must continue to be consistent. For example,
suppose that avdtp_start() has been called while in the OPEN state and
a AVDTP_START cmd is sent.  Now before we have received a response (and
thus entered the STREAMING state), we *receive* a START cmd. Prior to
this fix, since the sep is still in the OPEN state, we would accept
the new START cmd. This will leads us to send both a Start_Ind and
Start_Cfm - not good.

Now, we track this transitional state (starting == TRUE).

NB - 'starting' is only in a valid state while the sep is in the
OPEN state. 'starting' is reset when we return to the OPEN state.
2011-07-10 10:55:19 +03:00
Lucas De Marchi
13568564b1 avrcp: remove unused dbus reply message
Fix leak of dbus messages being created but not unreferenced after
method returns.
2011-07-10 10:40:47 +03:00
Luiz Augusto von Dentz
e202485107 Fix possible invalid read/free when using g_slist_free_full
This is probably a glib bug on g_slist_free_full which doesn't handle the
case where the list is modified inside the callback:

 Invalid read of size 8
    at 0x50AD5B2: g_slice_free_chain_with_offset (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x13057B: a2dp_unregister (a2dp.c:1550)
    by 0x12144C: a2dp_server_remove (manager.c:1032)
    by 0x50ADF16: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x178B55: adapter_remove (adapter.c:2326)
    by 0x175205: manager_remove_adapter (manager.c:290)
    by 0x50ADF16: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x50ADF3A: g_slist_free_full (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x175086: manager_cleanup (manager.c:298)
    by 0x11D7A8: main (main.c:305)
  Address 0x637a5e8 is 8 bytes inside a block of size 16 free'd
    at 0x4C27D6E: free (vg_replace_malloc.c:366)
    by 0x50AD9FC: g_slist_remove (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x12E5C6: a2dp_remove_sep (a2dp.c:1667)
    by 0x50ADF16: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x50ADF3A: g_slist_free_full (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x13057B: a2dp_unregister (a2dp.c:1550)
    by 0x12144C: a2dp_server_remove (manager.c:1032)
    by 0x50ADF16: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x178B55: adapter_remove (adapter.c:2326)
    by 0x175205: manager_remove_adapter (manager.c:290)
    by 0x50ADF16: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x50ADF3A: g_slist_free_full (in /usr/lib64/libglib-2.0.so.0.2800.8)

 Invalid free() / delete / delete[]
    at 0x4C27D6E: free (vg_replace_malloc.c:366)
    by 0x50AD5A3: g_slice_free_chain_with_offset (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x13057B: a2dp_unregister (a2dp.c:1550)
    by 0x12144C: a2dp_server_remove (manager.c:1032)
    by 0x50ADF16: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x178B55: adapter_remove (adapter.c:2326)
    by 0x175205: manager_remove_adapter (manager.c:290)
    by 0x50ADF16: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x50ADF3A: g_slist_free_full (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x175086: manager_cleanup (manager.c:298)
    by 0x11D7A8: main (main.c:305)
  Address 0x637a5e0 is 0 bytes inside a block of size 16 free'd
    at 0x4C27D6E: free (vg_replace_malloc.c:366)
    by 0x50AD9FC: g_slist_remove (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x12E5C6: a2dp_remove_sep (a2dp.c:1667)
    by 0x50ADF16: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x50ADF3A: g_slist_free_full (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x13057B: a2dp_unregister (a2dp.c:1550)
    by 0x12144C: a2dp_server_remove (manager.c:1032)
    by 0x50ADF16: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x178B55: adapter_remove (adapter.c:2326)
    by 0x175205: manager_remove_adapter (manager.c:290)
    by 0x50ADF16: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x50ADF3A: g_slist_free_full (in /usr/lib64/libglib-2.0.so.0.2800.8)

Invalid read of size 8
    at 0x50AD5B2: g_slice_free_chain_with_offset (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x175086: manager_cleanup (manager.c:298)
    by 0x11D7A8: main (main.c:305)
  Address 0x62b7ea8 is 8 bytes inside a block of size 16 free'd
    at 0x4C27D6E: free (vg_replace_malloc.c:366)
    by 0x50AD9FC: g_slist_remove (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x1751AE: manager_remove_adapter (manager.c:275)
    by 0x50ADF16: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x50ADF3A: g_slist_free_full (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x175086: manager_cleanup (manager.c:298)
    by 0x11D7A8: main (main.c:305)

 Invalid free() / delete / delete[]
    at 0x4C27D6E: free (vg_replace_malloc.c:366)
    by 0x50AD5A3: g_slice_free_chain_with_offset (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x175086: manager_cleanup (manager.c:298)
    by 0x11D7A8: main (main.c:305)
  Address 0x62b7ea0 is 0 bytes inside a block of size 16 free'd
    at 0x4C27D6E: free (vg_replace_malloc.c:366)
    by 0x50AD9FC: g_slist_remove (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x1751AE: manager_remove_adapter (manager.c:275)
    by 0x50ADF16: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x50ADF3A: g_slist_free_full (in /usr/lib64/libglib-2.0.so.0.2800.8)
    by 0x175086: manager_cleanup (manager.c:298)
    by 0x11D7A8: main (main.c:305)

To fix this now adapter_remove and a2dp_unregister_sep are passed
directly as a callbacks so g_slist_remove is not triggered.
2011-07-05 10:51:57 +03:00
Marcel Holtmann
3f553a30ad Allow building with GLib 2.16 for now 2011-07-04 11:09:55 +02:00
Lucas De Marchi
fcb426c76a Fix common misspelled words
Accounting of misspelled words, as detected by codespell:

acording      2
ancilliary    1
appropiate    1
atribute      1
cant          1
comming       2
gracefull     1
lenght        1
mispelled     1
occured       1
occurences    1
ocurred       3
prefered      1
presense      1
reponse       1
seperate      1
succesful     1
successully   1
sucessfull    1
sucessfully   1
2011-07-03 14:36:14 +03:00
Lucas De Marchi
b72a3526a8 avrcp: return NOT_IMPLEMENTED on request for vendor dep command
When a vendor dependent command is requested but target does not
implement it, the correct return value is CTYPE_NOT_IMPLEMENTED instead
of CTYPE_REJECTED.

AVRCP 1.3 spec clearly says so on section 4.5.1:
	[ It is assumed that devices that do not support this metadata
	transfer related features shall return a response of NOT
	IMPLEMENTED as per AV/C protocol specification ]

And AV/C General Specification, section 8.3.2 talks about legacy
behavior and mandates that NOT_IMPLEMENTED is returned.

Finally, in section 11.6.1 we see that VENDOR-DEPENDENT command frame
depends on the company_ID. Therefore we can't assume it has the same
format as the one specified for metadata transfer (in case the company
ID is 0x001958)
2011-06-30 22:52:28 +03:00
Lucas De Marchi
4560a956e9 avrcp: Factor out function to handle vendordep pdu
In order to support vendordep pdu as required by AVRCP 1.3 this part
will get very large. So, separate it to a new function like is done for
panel_passthrough.
2011-06-30 22:52:25 +03:00
Lucas De Marchi
027c6819f1 avrcp: Check that AVCTP packet is of type COMMAND 2011-06-30 22:52:23 +03:00
Luiz Augusto von Dentz
8306448148 Make use of g_slist_free_full on audio plugin 2011-06-30 14:38:59 +03:00
Luiz Augusto von Dentz
9c6e404f93 Mark Headset.Play method deprecated
SCO socket should be connected using either unix socket ipc or Media API
2011-06-30 11:11:02 +03:00
Peter Hurley
9a653953dc Fix finalize discovery if all stream end points are In Use
When handling the discover response, if all stream end points are
in use, then we must finalize discovery, as no GET_CAPABILITIES
command will be issued.
2011-06-28 11:05:04 +03:00
Rafal Michalski
b70fae3807 Fix invalid memory access issues in AVDTP module
Changing stream state from STREAMING to IDLE can be associated with side
effects under some circumstances (such as terminating bluetoothd during
music is streamed). In this case, after connection is lost, stream state
changes from STREAMING to IDLE - "avdtp_sep_set_state" is triggered which
invokes callback called "stream_state_changed" which internally invokes
"avdtp_sep_set_state" (state of stream doesn't change and stays as IDLE)
second time and then stream object is freed by "stream_free"
at the end of "avdtp_sep_set_state". After returning from callback,
first triggered "avdtp_sep_set_state" attempts to free stream object
again ("if (state == AVDTP_STATE_IDLE)" condition is still satisfied)
and it leads to invalid read/write/free issues (reported by valgrind)
in "stream free" body, since "stream" is "alias" pointer to stream object
which is already out of date (memory for stream object has been already
freed).

This patch prevents from this special case by freeing stream object only
when it is present on streams list and removing from this list when
stream object would be freed.
2011-06-14 12:07:56 +03:00
Rafal Michalski
d9b27da3cc Fix invalid read from memory issue in AVDTP module
Changing stream state from STREAMING to IDLE can be associated with side
effects under some circumstances (such as terminating bluetoothd during
music is streamed). In this case, after connection is lost, stream state
changes from STREAMING to IDLE - "avdtp_sep_set_state" is triggered which
invokes callback called "stream_state_changed" which internally invokes
"avdtp_sep_set_state" (state of stream doesn't change and stays as IDLE)
second time and then stream callbacks list is discarded by "stream_free"
("g_slist_free(stream->callbacks)"). After returning from callback,
"stream->callbacks" list (and "l" pointer as well) is already out of date,
so attempting to fetch "l->next" pointer (returned by "g_slist_next(l)"
to be prepared to next iteration of "for" loop) from node on discarded
list leads to invalid read issue (reported by valgrind).

This patch prevents from this issue by moving "l = g_slist_next(l)"
instruction just before invoking callback - loop has been modified and
"while" used instead of "for" loop variant.
2011-06-14 12:07:35 +03:00
Rafal Michalski
a2d3f2d5c5 Fix invalid write to memory issue in media module
Under some circumstances (such as terminating bluetoothd during music is
streamed) endpoint object may be destroyed (memory for endpoint object is
internally freed, directly by "media_endpoint_remove") after invoking
"media_transport_destroy" (in "media_endpoint_clear_configuration") to
destroy transport object (memory for transport object is directly freed by
"media_transport_free"). It leads to invalid write issue (reported by
valgrind) after assignment "endpoint->transport = NULL", since "endpoint"
is "alias" pointer to endpoint object which is already out of date
(memory for endpoint object has been already freed).

This patch prevents from this issue by ensuring that assignment
"endpoint->transport = NULL" would be executed when endpoint object
certainly exists.
2011-06-14 12:07:18 +03:00
Rafal Michalski
94a49c7082 Fix invalid write to memory issue in A2DP module
Under some circumstances (such as terminating bluetoothd during music is
streamed) sep object may be destroyed (memory for sep object is internally
freed, directly by "a2dp_unregister_sep") after invoking
"media_endpoint_clear_configuration" (in "stream_state_changed").
It leads to invalid write issue (reported by valgrind) after assignment
"sep->stream = NULL", since "sep" is "alias" pointer to sep object which
is already out of date (memory for sep object has been already freed)

This patch prevents from this issue by ensuring that assignment
"sep->stream = NULL" would be executed when sep object certainly exists.
2011-06-14 12:06:42 +03:00
Szymon Janc
3a916a0067 Fix AVCTP reply for message with invalid PID
Reply for control message with invalid (not registered for reception
of messages) PID should not have message information field present.

This was affecting AVCTP 1.3 qualification test case TP/NFR/BI-01-C.
2011-06-14 11:13:57 +03:00
Lukasz Pawlik
7fec07d69c Fix type in conditional expression
Function media_endpoint_create returns pointer to structure. In
conditional expression it is safer to compare returned value with NULL
and not with gboolean as it is done in register_endpoint function.
2011-06-06 18:40:04 +09:00
Luiz Augusto von Dentz
571d97d3fe telephony-ofono: fix features initialization
Features should be ready before telephony_init return, otherwise the
record might contain invalid features.
2011-06-01 15:08:38 +03:00
Slawomir Bochenski
f8e0916e2d Remove unnecessary jumps 2011-06-01 14:41:01 +03:00
Daniel Orstadius
3b7e90d9db Init telephony before adding the HFP SDP record
By patch b9d85c0010 the initialization
of the telephony subsystem is delayed in the bluetoothd startup
procedure. As a result the SupportedFeatures bitmap has not been set
when creating the HFP SDP record. This patch changes the order of
the telephony initialization (via the state_changed function) and
the registration of the record, so that it gets the right value.

Although the corresponding bit in +BRSF is correctly set, the
missing bit for the "Three-way calling" feature in the SDP record
causes some headsets not to send AT+CHLD=? in certain situations.
This results in failed connections since BlueZ does not enter the
"connected" state on the headset interface before that command is
received, if the feature is supported by both sides.
2011-06-01 11:15:33 +03:00
Ilia Kolomisnky
bb91e5ed10 Fix response for vendor dependent AVRCP commands
AVRCP TG now returns a REJECTED response with the "Invalid command"
error code for VENDOR DEPENDENT commands. This fixes test case
AVRCP/TG/INV/TC_TG_INV_BI_01_C with recent PTS version.
2011-05-31 10:48:30 +03:00
Dmitriy Paliy
a740e8599e Fix invalid read and possible memory leaks
Fixed incorrect update of transport->owners GSlist in
media_transport_free. Removal of list entries within 'for' loop leads to
invalid read of memory (l = l->next) and memory leaks.
2011-05-29 22:10:57 +03:00
Rafal Michalski
09b6fbef70 Fix invalid read of memory in avdtp module
Fixed incorrect update of server->sessions GSlist in avdtp_exit.
Previosly it was leading to invalid read of memory (l = l->next)
(and possible memory leaks) since after invoking avdtp_unref in
connection_lost, l pointer was not valid anymore (previously assignment
l = l->next was used after invoking connection_lost in for loop).
2011-05-29 22:08:30 +03:00
Luiz Augusto von Dentz
27a52a9ccb Fix possible buffer overflow when sending avdtp commands
Buffer size should be as big as the maximum of imtu and omtu, otherwise
it may overflow when sending messages which are bigger then imtu.
2011-05-29 22:05:08 +03:00
Szymon Janc
10a0350126 Report error if read failed in bluetooth_playback_poll_revents 2011-05-15 01:47:12 +03:00
Szymon Janc
51d73841d4 Remove unused variable svclass from hf_io_cb 2011-05-15 01:47:10 +03:00
Szymon Janc
6dc1643c76 Disconnect headset when not able to reply with ERROR command 2011-05-15 01:47:10 +03:00
Szymon Janc
50f0671290 Fix callbacks numbering in connect_cb_new from audio/headset.c 2011-05-15 01:47:10 +03:00
Szymon Janc
4ccf324d56 Validate if sending reply succeed in control_cb 2011-05-15 01:47:10 +03:00
Szymon Janc
984260d913 Remove unused remote_type variable from a2dp_config 2011-05-15 01:47:09 +03:00
Szymon Janc
906879b788 Fix garbage return value in send_req 2011-05-15 01:47:07 +03:00
Szymon Janc
d6ee6f16e6 Fix garbage return value in gst_avdtp_sink_audioservice_recv 2011-05-15 01:47:07 +03:00
Szymon Janc
24c6dee3b3 Remove redundant local copy of GSlist* from functions
Those functions already get copy of pointer to list so local copy is
not needed.
2011-05-15 01:47:05 +03:00
Szymon Janc
f8937ef155 Fix possible NULL pointer dereference in headset_server_init 2011-05-15 01:47:05 +03:00
Szymon Janc
3948fb1198 Fix empty parameter list in functions declarations
Use foo(void) instead of foo() for parameterless functions declaration.
This allows compiler to check if foo is called without parameters.
2011-05-15 01:47:05 +03:00
Szymon Janc
3d586da1dd Fix C++ style comments 2011-05-10 17:17:03 +02:00
Luiz Augusto von Dentz
01a3858e8c Fix crash when calling finalize_setup_errno
finalize_setup_errno last parameter must be NULL otherwise it may access
invalid memory.
2011-05-02 10:22:54 -07:00
Johan Hedberg
36cd74bfa7 Fix format string warnings 2011-04-27 18:00:08 -07:00
Johan Hedberg
407e977f8d Add format string warnings to printf-style functions 2011-04-27 18:00:02 -07:00
Marcel Holtmann
c6d0464321 Accept Apple specific headset commands 2011-04-27 17:24:11 -07:00
Johan Hedberg
44b7bcd6c1 Use flushable packets for A2DP media data 2011-04-21 10:33:31 +03:00
Johan Hedberg
fd0e49cb23 Clean up handle_transport_connect code flow 2011-04-21 10:31:45 +03:00
Luiz Augusto von Dentz
c28669fd69 Fix not waiting for POLLERR when disconnecting SCO
To make sure the SCO link is really disconnected we should wait for
POLLERR since POLLHUP does not necessarily means the link is
completely disconnected just that no further data can be sent/received.

Note that this depend on a fix of SCO socket shutdown in kernel to wait
for disconnect confimation to then kill/destroy the socket indicating
the err/reason using POLLERR.
2011-04-19 15:29:42 +03:00
Dmitriy Paliy
23de023582 Add NO CARRIER response to maemo6 telephony driver 2011-04-18 10:48:11 +03:00
Dmitriy Paliy
304b588b02 Add NO CARRIER response to HFP
HFP is updated by NO CARRIER response accordingly to HFP 1.5 p.68.
2011-04-18 10:48:11 +03:00