Commit Graph

1750 Commits

Author SHA1 Message Date
Anderson Lizardo
5c6db9e861 audio/IPC: Fix errno handling convention
Variables which are assigned to the errno variable (usually called
"err") should be negative, and "-err" should be used where a positive
value is needed.

This commit also changes places where errno can be replaced with -err
(for consistency) and one perror() usage error.
2011-11-17 13:57:52 +02:00
Anderson Lizardo
f2c10b575c AVDTP: Fix errno handling convention
Variables which are assigned to the errno variable (usually called
"err") should be negative, and "-err" should be used where a positive
value is needed.
2011-11-17 13:57:52 +02:00
Anderson Lizardo
e4e02ce657 AVCTP: Fix errno handling convention
Variables which are assigned to the errno variable (usually called
"err") should be negative, and "-err" should be used where a positive
value is needed.

This patch also fixes a bug related to not using an "err" variable to
store the errno value before calling external library code.
2011-11-17 13:57:52 +02:00
Dmitriy Paliy
a267bc2dcd Fix enable fast connectable when connection allowed 2011-11-14 14:09:00 +02:00
Lucas De Marchi
3adcd9ed77 AVRCP: implement TRACK-REACHED-END event 2011-11-04 15:38:33 +02:00
Dmitriy Paliy
35c7dd410f Fix response on AT+CHLD=0 in maemo6
Currently, +CIEV indicator after AT+CHLD=0 command for one active call,
one held call, one incoming call scenario is incorrect. callheld=2
according to HFP 1.5 spec., p.70, means 'Call on hold, no active call'.
Hence, value 2 cannot be provided in +CIEV if there is an active call.
2011-11-02 12:00:09 +02:00
Luiz Augusto von Dentz
4ed6c1c2a4 Add MediaPlayer.Release method
This is similar to MediaEndpoint.Release which is useful to notify the
player that it is no longer registered/active.
2011-10-28 15:15:48 +03:00
Dmitriy Paliy
d8e4938352 Fix incorrect use of atoi in maemo6
Use of atoi is incorrect and unsafe in maemo6 telephony and replaced
by g_ascii_digit_value.
2011-10-28 14:46:41 +03:00
Lucas De Marchi
26204a61eb Fix check for PDU size
Company ID became part of the avrcp header so its size is already
accounted in the AVRCP_HEADER_LENGTH define.
2011-10-28 14:00:42 +03:00
Luiz Augusto von Dentz
6d130cd512 Fix calling g_io_channel_shutdown twice for a gateway connection
This happens in the following circumstance:

bluetoothd[30869]: audio/manager.c:hf_io_cb() Authorization denied!

(bluetoothd:30869): GLib-WARNING **: Invalid file descriptor.

Reported by Daniel Wagner <wagi@monom.org>
2011-10-25 10:40:01 +02:00
Lucas De Marchi
557a8ae858 Unregister players' events when disconnected 2011-10-22 12:18:28 +02:00
Lucas De Marchi
fd8dda80fc Fix leak of GTimer 2011-10-22 12:18:24 +02:00
Lucas De Marchi
ce8cd61098 Add missing TRACK-REACHED-START event
When track is changed, we automatically start to play it, therefore we
need to notify CT regarding this event.
2011-10-22 12:18:18 +02:00
Frédéric Danis
4a4b56556f Fix implicit declaration of 'g_slist_free_full'
audio/avrcp.c: In function 'avrcp_unregister':
audio/avrcp.c:1253: error: implicit declaration of function 'g_slist_free_full'

thermometer/thermometer.c: In function 'destroy_char':
thermometer/thermometer.c:79: error: implicit declaration of function 'g_slist_free_full'
2011-10-18 13:23:47 +03:00
Johan Hedberg
68838679e1 Move SDP client functions from glib-helper.c to sdp-client.c 2011-10-18 11:15:23 +03:00
Johan Hedberg
9b98a6c764 Add glib-compat.h to deal with issues in old GLib versions 2011-10-18 10:57:06 +03:00
Lucas De Marchi
b3ba324261 AVRCP: Implement RequestContinuingResponse PDU 2011-10-18 10:25:50 +03:00
Lucas De Marchi
d888f54946 AVRCP: Implement AbortContinuingResponse PDU 2011-10-18 10:25:48 +03:00
Lucas De Marchi
464c36f7d8 AVRCP: respond with UINT32_MAX if duration is not available
Section 5.4.1 of AVRCP 1.3 spec says:

	If TG does not support SongLength And SongPosition on TG, then TG shall
	return 0xFFFFFFFF.

SongPosition is always available, but song length depends on user to
provied it.
2011-10-18 10:25:46 +03:00
Lucas De Marchi
2c920f6d68 AVRCP: implement TRACK-REACHED-START event 2011-10-18 10:25:43 +03:00
Lucas De Marchi
9ab125a8ec AVRCP: Use track's UID in event notification
When registering for TRACK_CHANGED event, CT expects the track's UID in
the INTERIM and CHANGED responses. According to AVRCP 1.3 spec, there
are only 2 possible values:
	1) 0: there's a track selected
	2) UINT32_MAX: there's no track selected

AVRCP 1.4 reserves the value UINT64_MAX for the second case. Since this
later value is the one used in certification process for best IOP
we return UINT64_MAX instead of the former.

This implementation allows to pass PTS test TP/NFY/BV-05-C.
2011-10-18 10:25:40 +03:00
Lucas De Marchi
239a0f68bb Make title always available in metadata 2011-10-13 16:09:52 +03:00
Lucas De Marchi
cd25bc2b76 Don't overwrite metadata when changing track
If we use the same hash table to set the new metadata, we have 2
undesired behaviors:

1) New track may contain fields from previous track if it didn't set all
the fields
2) If we fail on parsing the signal, we will still change some of the
fields
2011-10-13 16:08:29 +03:00
Dmitriy Paliy
9a4a6fad12 Fix +CLCC in maemo6 during CSD_CALL_STATUS_COMING
This fixes the same issue as in 8a6119ea1c685fc61419ee444a5967596f524c1c
but for CSD_CALL_STATUS_COMING. Call status change sequence in csd is
IDLE to COMING, COMING to PROCEEDING, and PROCEEDING to WAITING.

Returned 'state of the call' value after CSD_CALL_STATUS_COMING, as well
as after CSD_CALL_STATUS_PROCEEDING, in +CLCC shall be 5 (waiting, MT
call) instead of 4 (incoming, MT call) in maemo6 telephony driver for the
second incoming call.
2011-10-13 13:45:39 +03:00
Dmitriy Paliy
d0ed45425d Fix crash on power off in maemo6 after sending DTMF
This fixes regression introduced in
b48e610314. Crash happens when powering
off adapter after sending DTMF tone.
2011-10-13 13:33:46 +03:00
Lucas De Marchi
a2a2db8167 Refactor to share code
Refactor code when we are 'listing selected attributes' to share code
with 'listing all attributes'. This way we always keep the list of
attributes in a GList, and call player_get_media_attribute() in only one
place.
2011-10-13 13:10:45 +03:00
Lucas De Marchi
c8265ec286 AVRCP: Only return available metadata attributes
When remote side requests all available metadata (i.e. it gives number
attributes equals to 0) do not return zero-length strings for
unavailable items. The only exception is title, that must be always present.
2011-10-13 13:10:13 +03:00
Lucas De Marchi
7cddeb379d AVRCP: Check if len matches number of IDs
If number of attributes remote side provided is larger than the length
we read, we would read garbage from stack memory.
2011-10-13 13:09:25 +03:00
Lucas De Marchi
28b3057757 AVRCP: Return error for invalid metadata IDs 2011-10-13 13:08:58 +03:00
Lucas De Marchi
c684389188 Add callback to list available metadata IDs 2011-10-13 13:08:46 +03:00
Lucas De Marchi
c0cc10498d AVRCP: Do not list values for unsupported attributes 2011-10-13 13:06:39 +03:00
Lucas De Marchi
2932dbeeb3 Move debug messages to their correspondent getters 2011-10-13 13:05:54 +03:00
Dmitriy Paliy
c2a74289ef Fix call status in +CLCC for maemo6 telephony
If list current calls is requested when there is second incoming call
and csd call status is CSD_CALL_STATUS_PROCEEDING, then returned 'state
of the call' value in +CLCC is 4 (incoming, MT call), which is incorrect.
Indication than proceeds from incoming to waiting state.

This patch sets the corresponding value to 5 (waiting, MT call) in
maemo6 telephony driver for the second call.
2011-10-12 10:53:08 +03:00
Johan Hedberg
e34836262b Fix compilation error on 32-bit systems
This fixes the following compilation error with GLib on 32-bit sytems:

audio/media.c: In function 'get_setting':
audio/media.c:1109:44: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
audio/media.c: In function 'set_setting':
audio/media.c:1132:41: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
2011-10-12 00:28:51 +03:00
Luiz Augusto von Dentz
911f1b1be0 Fix crash while registering player
Crash is caused by not removed freed player from the list:

Invalid read of size 8
   at 0x13E7B5: media_adapter_find_player (media.c:861)
   by 0x13FEBC: register_player (media.c:1561)
   by 0x120DFE: process_message (object.c:224)
   by 0x4F6E9A0: ??? (in /lib64/libdbus-1.so.3.5.6)
   by 0x4F6092F: dbus_connection_dispatch (in /lib64/libdbus-1.so.3.5.6)
   by 0x11F787: message_dispatch (mainloop.c:80)
   by 0x4C762CA: ??? (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x4C74ADC: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x4C752D7: ??? (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x4C75824: g_main_loop_run (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x11EE4B: main (main.c:485)
 Address 0x642ef30 is 16 bytes inside a block of size 80 free'd
   at 0x4A0662E: free (vg_replace_malloc.c:366)
   by 0x4C7B7F2: g_free (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x12D292: player_destroy (avrcp.c:1099)
   by 0x120C38: service_filter (watch.c:477)
   by 0x120950: message_filter (watch.c:527)
   by 0x4F608E5: dbus_connection_dispatch (in /lib64/libdbus-1.so.3.5.6)
   by 0x11F787: message_dispatch (mainloop.c:80)
   by 0x4C762CA: ??? (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x4C74ADC: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x4C752D7: ??? (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x4C75824: g_main_loop_run (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x11EE4B: main (main.c:485)
2011-10-06 18:46:54 +03:00
Luiz Augusto von Dentz
9cf1a84ef7 Fix not being able to unregister player via UnregisterPlayer 2011-10-06 18:46:49 +03:00
Lucas De Marchi
c7f32491a8 AVRCP: do not allow CT to set a property not supported
If player never set a property, it means it doesn't support it. Doesn't
allow the remote side to set it and send a REJECTED response.
2011-10-06 15:36:36 +03:00
Lucas De Marchi
b6379821a6 AVRCP: fix loop over number of application settings 2011-10-06 15:35:35 +03:00
Luiz Augusto von Dentz
14ae307458 AVRCP: move MediaPlayer to adapter object
This move the MediaPlayer registration to adapter object on Media
interface so we can track players properly.
2011-10-06 11:13:28 +03:00
Luiz Augusto von Dentz
90c9c7bb13 Fix crash when remote connects to AVRCP without having a record
Device object may exist but control wont be initialized causing the
following crash:

Invalid read of size 8
   at 0x12B510: state_changed (control.c:90)
   by 0x12BA20: avctp_set_state (avctp.c:367)
   by 0x12C0DC: avctp_confirm_cb (avctp.c:733)
   by 0x166481: server_cb (btio.c:200)
   by 0x4E75ADC: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x4E762D7: ??? (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x4E76824: g_main_loop_run (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x11ED19: main (main.c:473)
 Address 0x8 is not stack'd, malloc'd or (recently) free'd
2011-10-05 17:08:57 +03:00
Luiz Augusto von Dentz
2d4c58a760 Fix not being able to register pdu handlers
This happens when removing and adding again an adapter
2011-10-05 17:08:53 +03:00
Johan Hedberg
4cadf1d198 Fix missing initialization of A2DP error 2011-10-05 15:28:08 +03:00
Luiz Augusto von Dentz
e5753d8778 Fix regression when disconnecting AVRCP
This prevent to disconnect AVRCP when doing e.g. Audio.Disconnect
2011-10-03 18:00:20 +03:00
Lucas De Marchi
4d3bb39485 AVRCP: fix missing bytes on notification 2011-10-03 16:14:12 +03:00
Frédéric Danis
355637a057 Fix Unref message after it was sent 2011-10-02 18:53:45 +03:00
Lucas De Marchi
4364aa411d AVRCP: fix changed notification
We sure want to send notifications only when section is not NULL.
Otherwise we either crash or do not send the expected notification.
2011-10-02 18:52:05 +03:00
Lucas De Marchi
8ebb3c79e1 AVRCP: fix case when only one setting is provided
If CT tries to change an Application Setting providing only one
setting, the size of the PDU will be 3 bytes. Therefore we should check
if the PDU is shorter than or equal 3, not only shorter.
2011-10-02 18:48:06 +03:00
Lucas De Marchi
138f831787 AVRCP: return empty string instead of rejecting
If media attribute is not available for a certain media file, return an
empty string instead of rejecting the request. The spec is not so clear
if only the title should be handled as an empty string when not present,
but this is the only alternative to rejecting the request.

IOP tests showed that some CT devices don't like reject messages: they
never ask for an attribute again if they previously received a REJECTED
message for that attribute. They consider REJECTED as "TG doesn't
implement it these optional attributes" as opposed to what we had
before, "this attribute is currently not available".
2011-10-02 18:47:58 +03:00
Dmitriy Paliy
b5dae52d36 Fix remove feedback DTMF tones timer on call release
User feedback DTMF tones queue is freed and timer removed when call
is released.
2011-09-27 16:41:11 +03:00
Dmitriy Paliy
4861017b1b Fix play DTMF feeback tones only for active call
Check on active call is added for playing of DTMF feedback tones to
notify user. Network DTMF tones are handled by modem, and therefore
there is no need in special check for those.
2011-09-27 16:41:09 +03:00
Dmitriy Paliy
5d9207acc1 Add playback of tones to handsfree
StartEventTone and StopTone method calls to tone generator are added
to maemo6 telephony driver. Such implements playback of DTMF tones
in handsfree to notify user.
2011-09-27 16:41:07 +03:00
Dmitriy Paliy
b48e610314 Fix error handling in start_dtmf_reply
If csd replyed with error to StartDTMF, then StopDTMF method call
is not sent.
2011-09-27 16:41:05 +03:00
Dmitriy Paliy
16af0ec65e Replace SendDTMF by StartDTMF/StopDTMF in maemo6
SendDTMF method call is replaced by StartDTMF/StopDTMF in maemo6 telephony
driver. StartDTMF/StopDTMF places DTMF tone in queue on modem side playing
it minimum required time. When using SendDTMF, modem ignores new tone
until currently playing one is not finished.

Downside of StartDTMF/StopDTMF combination is absence of audio feedback to
hands-free.
2011-09-27 16:41:01 +03:00
Lucas De Marchi
6d0ec74904 AVRCP: limit AVRCP packet size to the MTU of AV/C
AVRCP is an extension of AV/C spec which has a limit of 512 bytes. The
only place where it can exceed this value is in the response to
GetElementAttributes command.

Now we simply don't add the attributes that would overflow the available
buffer space.
2011-09-27 13:11:35 +03:00
Frédéric Dalleau
3c78fa2f91 Minor style fix 2011-09-24 13:12:05 +03:00
Frédéric Dalleau
f245d02b7a Remove unneeded checks in gateway_is_connected 2011-09-24 13:12:03 +03:00
Frédéric Dalleau
9344ad5be8 Check all states before allowing gw connection 2011-09-24 13:12:00 +03:00
Frédéric Dalleau
85d21c3ea5 Fix reference count issue in incoming connections
In case of incoming RFCOMM connection, manager calls
gateway_connect_rfcomm which already take reference to GIOChannel, hence
no need to take another one.
2011-09-22 20:10:28 +09:00
Frédéric Dalleau
dfea776a9c Set state to "connecting" on connection requested
Make sure that state changes to disconnected on errors (authorization
refused, disconnect, sdp) This change will become necessary when
integrating the Audio interface which rely on state change to confirm
that connection has started successfully.
2011-09-22 20:10:17 +09:00
Frédéric Dalleau
f00fc7ae6d Fix state to "playing" on SCO establishment 2011-09-22 20:10:12 +09:00
Frédéric Dalleau
68119298ac Fix asynchronously run request stream cb
Cancel pending callback if stream is canceled Asynchronously run
gateway_config_stream cb Remove occurences of sco_start_cb
2011-09-22 20:10:05 +09:00
Frédéric Dalleau
1fcbc48066 Fix disconnect SCO at same time than RFCOMM
If RFCOMM disconnects, SCO should be disconnected too.
2011-09-22 20:08:23 +09:00
Dmitriy Paliy
98ee8c58f9 Fix freeing watches list in maemo6 telephony
This fixes regression introduced in 8306448148.
List watches has to be freed instead of list pending.
2011-09-22 20:05:15 +09:00
Johan Hedberg
3169c1bef4 headset: Fix missing check for non-existent pending message 2011-09-21 17:29:42 +09:00
Johan Hedberg
26bc2d99dd Remove redundant empty line 2011-09-21 17:04:02 +09:00
Johan Hedberg
9390bf465f AVDTP: Fix state if authorization fails 2011-09-21 11:03:11 +09:00
Johan Hedberg
bd48d4b7dd AVDTP: Refactor audio_device_cancel_authorization usage 2011-09-20 17:21:05 +09:00
David Stockwell
4dc449c1e3 avrcp: get/set three-byte company-id 2011-09-16 11:32:12 +03:00
David Stockwell
232ba15531 avrcp: fix handling of metadata item 0x7
Metadata field number 0x7 should be the total playing time of the track
(TrackDuration) in msec, not current position within track.
2011-09-16 11:32:10 +03:00
David Stockwell
b0de2a7bc2 avrcp: use LAST element on media_info_id enum 2011-09-16 11:32:08 +03:00
Lucas De Marchi
f2ac0034a0 avrcp: fix overwrite of number of attributes
The response of GetCurrentPlayerApplicationSettingValue expects the
first operand to be the number of attributes in response. Since we start
with len=0, we were overwriting this number with the value of the first
attribute.

Also use g_memdup instead of g_malloc + memcpy.
2011-09-16 11:32:06 +03:00
Lucas De Marchi
66b9d4c7a0 avrcp: fix missing error code 2011-09-16 11:32:04 +03:00
Luiz Augusto von Dentz
71a84481dc AVRCP: change debug to better reflect packets protocol/profile 2011-09-14 12:24:31 +03:00
Luiz Augusto von Dentz
99f32ae9ac AVRCP: move handling of vendor dependent PDU from control.c to avrcp.c
This helps to isolate AVRCP PDU handling and MediaPlayer interface.
2011-09-13 10:44:56 +03:00
Luiz Augusto von Dentz
8d18c289c7 AVRCP: split AVCTP specific code from control.c
The code is moved to avctp.c to simplify control.c
2011-09-13 10:44:54 +03:00
Luiz Augusto von Dentz
c612aee09d AVRCP: rename avrcp_spec_avc_pdu to avrcp_header
Since old avrcp_header got renamed to avc_header now we can use
avrcp_header for AVRCP PDUs.
2011-09-13 10:44:53 +03:00
Luiz Augusto von Dentz
222b464a6d AVRCP: rename avrcp_header to avc_header
AVCTP carries AV/C packets/PDUs not AVRCP as avrcp_header suggests.
2011-09-13 10:44:51 +03:00
Luiz Augusto von Dentz
09984fd9c6 AVRCP: use a vtable to simplify PDU parsing/handling
This simplify a bit the handling by introducing common checks before
calling the handler callback, it is also much easier to add/remove
new PDUs in this way.
2011-09-13 10:44:48 +03:00
Lucas De Marchi
dec26ee50d Fix fd usage when not connected
When the avctp channel is not connected, we call
g_io_channel_unix_get_fd() with a NULL pointer. Glib does not check the
pointer before dereferencing it, causing bluetoothd to segv.

Move the function call to the place it's actually needed, after the
safety checks.
2011-08-30 15:53:57 +03:00
Marcel Holtmann
35906565c9 audio: Update license for shared header files
The header files with constants and structures for audio specific
interaction with Pulseaudio are suppose to be under LGPL license.

For some odd reason a2dp-codecs.h ended up being under GPL license
which is against the intention of this being shared and re-used by
non-GPL programs. Fix this now to avoid any future confusion.
2011-08-26 11:18:54 -07:00
Frédéric Dalleau
021813afd9 Implement media_transport for HFP_HS_UUID
The transport is used by pulseaudio to suspend and resume streams.
2011-08-24 14:22:38 +03:00
Frédéric Dalleau
06eb47dec5 Introduce gateway locking mechanism 2011-08-24 14:22:31 +03:00
Frédéric Dalleau
9ce8d3f01e Set state to "connecting" when AG connects.
This state is used by media.c to trigger pulseaudio configuration.
2011-08-24 14:21:12 +03:00
Frédéric Dalleau
270f3bb47c Fix RFCOMM disconnect on suspend request
When pulseaudio release an audio stream, gateway.c disconnects
RFCOMM instead of disconnecting only SCO.
2011-08-24 14:21:09 +03:00
Frédéric Dalleau
d3f534025c Update g_strcmp0 to strcasecmp 2011-08-24 14:21:07 +03:00
Frédéric Dalleau
9a0bab4796 Use state change callback from media interface
When a HFPHS endpoint is created, media will start to watch for
HandsfreeGateway state changes. media call SetConfiguration upon
connection and ClearConfiguration upon disconnection.
2011-08-24 14:21:03 +03:00
Frédéric Dalleau
083177c86c Add state change callback to HandsfreeGateway
Media interface needs to monitor state changes of HandsfreeGateway.
2011-08-24 14:20:59 +03:00
Frédéric Dalleau
a471827d1f Fix double free in error case in endpoint_reply
If SetConfiguration call fails, the headset or gateway for which
SetConfiguration is called is disconnected. This will free any
pending request, but this does not prevent the request to
terminate (endpoint_reply) and try to free itself once again.
Note that a copy of the freed pointer is tested which has not
been updated.
2011-08-24 14:20:55 +03:00
Peter Hurley
84f4d71d7d Fix get/set_hfp_active to match name conventions
These two functions are defined exclusively for headsets, so
follow established name conventions.
2011-08-22 11:04:24 +03:00
Peter Hurley
f9dddf3f41 Increase timeout before initiating AVDTP connection
AVDTP_CONNECT_TIMEOUT controls the delay between HSP/HFP
connection establishment and AVDTP signal channel establishment.
The original value of 1 sec. is too short to avoid racing for AVDTP
connection establishment (eg., if the device continues to configure
the HFP service level connection with additional AT cmds).

Some devices have broken AVDTP implementations that just cannot
handle the race conditions that arise if both devices are attempting
stream establishment at the same time. However, these conditions arise
only when the remote device is the ACL initiator (and in practice, the
RFCOMM initiator as well).  This fix bumps out the timeout value only
when the headset has initiated the link.
2011-08-22 10:49:02 +03:00
Johan Hedberg
8ec11b427e Clean up code in control.c 2011-08-12 11:26:11 +03:00
Lucas De Marchi
a21e648cf0 avrcp: update copyright 2011-08-12 11:05:13 +03:00
Lucas De Marchi
ab7e71ed87 avrcp: change TG record to use version 1.3 2011-08-12 11:05:11 +03:00
Lucas De Marchi
1a3de7bae4 avrcp: send response for registered events
When a certain event occur, check if CT registered to receive that
notification and send a response.

Example event for PTS test TC_TG_NFY_BV_02_C:

> ACL data: handle 11 flags 0x02 dlen 22
    L2CAP(d): cid 0x0043 len 18 [psm 23]
      AVCTP: Command : pt 0x00 transaction 2 pid 0x110e
        AV/C: Notify: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: RegisterNotification: pt 0x00 len 0x0005
            EventID: 0x02 (EVENT_TRACK_CHANGED)
            Interval: 0x00000000 (0 seconds)
< ACL data: handle 11 flags 0x02 dlen 26
    L2CAP(d): cid 0x0043 len 22 [psm 23]
      AVCTP: Response : pt 0x00 transaction 2 pid 0x110e
        AV/C: Interim: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: RegisterNotification: pt 0x00 len 0x0009
            EventID: 0x02 (EVENT_TRACK_CHANGED)
            Identifier: 0x0 (PLAYING)

[...]

< ACL data: handle 11 flags 0x02 dlen 26
    L2CAP(d): cid 0x0043 len 22 [psm 23]
      AVCTP: Response : pt 0x00 transaction 2 pid 0x110e
        AV/C: Changed: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: RegisterNotification: pt 0x00 len 0x0009
            EventID: 0x02 (EVENT_TRACK_CHANGED)
            Identifier: 0x0 (PLAYING)
2011-08-12 11:05:10 +03:00
Lucas De Marchi
a5924f6600 avrcp: handle GetElementAttributes pdu
Example responses for PTS test TC_TG_MDI_BV_04_C:

> ACL data: handle 11 flags 0x02 dlen 26
    L2CAP(d): cid 0x0042 len 22 [psm 23]
      AVCTP: Command : pt 0x00 transaction 2 pid 0x110e
        AV/C: Status: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: GetElementAttributes: pt 0x00 len 0x0009
            Identifier: 0x0 (PLAYING)
            AttributeCount: 0x00
< ACL data: handle 11 flags 0x02 dlen 70
    L2CAP(d): cid 0x0042 len 66 [psm 23]
      AVCTP: Response : pt 0x00 transaction 2 pid 0x110e
        AV/C: Stable: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: GetElementAttributes: pt 0x00 len 0x0035
            AttributeCount: 0x03
            Attribute: 0x00000001 (Title)
            CharsetID: 0x006a (UTF-8)
            AttributeValueLength: 0x0012
            AttributeValue: Walking on the Sun
            Attribute: 0x00000002 (Artist)
            CharsetID: 0x006a (UTF-8)
            AttributeValueLength: 0x0005
            AttributeValue: Lucas
            Attribute: 0x00000007 (Progress)
            CharsetID: 0x006a (UTF-8)
            AttributeValueLength: 0x0005
            AttributeValue: 32029

And TC_TG_MDI_BV_05_C:

> ACL data: handle 11 flags 0x02 dlen 30
    L2CAP(d): cid 0x0043 len 26 [psm 23]
      AVCTP: Command : pt 0x00 transaction 2 pid 0x110e
        AV/C: Status: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: GetElementAttributes: pt 0x00 len 0x000d
            Identifier: 0x0 (PLAYING)
            AttributeCount: 0x01
            Attribute: 0x00000001 (Title)
< ACL data: handle 11 flags 0x02 dlen 44
    L2CAP(d): cid 0x0043 len 40 [psm 23]
      AVCTP: Response : pt 0x00 transaction 2 pid 0x110e
        AV/C: Stable: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: GetElementAttributes: pt 0x00 len 0x001b
            AttributeCount: 0x01
            Attribute: 0x00000001 (Title)
            CharsetID: 0x006a (UTF-8)
            AttributeValueLength: 0x0012
            AttributeValue: Walking on the Sun
2011-08-12 11:05:08 +03:00
Lucas De Marchi
e468f8f1e9 avrcp: handle query for supported events 2011-08-12 11:04:52 +03:00
Lucas De Marchi
6ae019ed13 avrcp: handle RegisterNotification pdu
Handle mandatory events according to AVRCP 1.3 spec.
2011-08-12 11:04:50 +03:00
Lucas De Marchi
177d7aea76 avrcp: handle GetPlayStatus pdu
Example response for PTS test TC_TG_MDI_BV_02_C:

> ACL data: handle 11 flags 0x02 dlen 17
    L2CAP(d): cid 0x0043 len 13 [psm 23]
      AVCTP: Command : pt 0x00 transaction 2 pid 0x110e
        AV/C: Status: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: GetPlayStatus: pt 0x00 len 0x0000
< ACL data: handle 11 flags 0x02 dlen 26
    L2CAP(d): cid 0x0043 len 22 [psm 23]
      AVCTP: Response : pt 0x00 transaction 2 pid 0x110e
        AV/C: Stable: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: GetPlayStatus: pt 0x00 len 0x0009
            SongLength: 0x0000a7f8 (43000 miliseconds)
            SongPosition: 0x00012fad (77741 miliconds)
            PlayStatus: 0x01 (PLAYING)
2011-08-12 11:04:49 +03:00
Lucas De Marchi
ea42bc7391 avrcp: handle InformBatteryStatusOfCT pdu 2011-08-12 11:04:47 +03:00
Lucas De Marchi
bb8e4d6a12 avrcp: handle InformDisplayableCharacterSet pdu 2011-08-12 11:04:45 +03:00
Lucas De Marchi
3e5bde2244 avrcp: handle commands for future extension
AVRCP_GET_PLAYER_ATTRIBUTE_TEXT and AVRCP_GET_PLAYER_VALUE_TEXT shall
only be used if TG has extended attributes.

For the ones defined in AVRCP spec these commands should not be called.
Since we do not have extended attributes yet we can ignore those
commands.
2011-08-12 11:04:43 +03:00
Lucas De Marchi
81b99b59ad avrcp: handle SetPlayerApplicationSettingValue pdu 2011-08-12 11:04:42 +03:00
Lucas De Marchi
908d91867b avrcp: handle GetCurrentPlayerAplicationSettingValue pdu
Example response for PTS test TC_TG_PAS_BV_10_C:

> ACL data: handle 11 flags 0x02 dlen 19
    L2CAP(d): cid 0x0043 len 15 [psm 23]
      AVCTP: Command : pt 0x00 transaction 3 pid 0x110e
        AV/C: Status: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: GetCurrentPlayerApplicationSettingValue: pt 0x00 len 0x0002
            AttributeCount: 0x01
            AttributeID: 0x01 (Equalizer ON/OFF Status)
< ACL data: handle 11 flags 0x02 dlen 20
    L2CAP(d): cid 0x0043 len 16 [psm 23]
      AVCTP: Response : pt 0x00 transaction 3 pid 0x110e
        AV/C: Stable: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: GetCurrentPlayerApplicationSettingValue: pt 0x00 len 0x0003
            ValueCount: 0x01
            AttributeID: 0x01 (Equalizer ON/OFF Status)
            ValueID: 0x02 (ON)
2011-08-12 11:04:40 +03:00
Lucas De Marchi
0834a161e6 avrcp: handle ListPlayerApplicationSettingValues pdu
Example of response obtained with PTS test TC_TG_PAS_BV_06_C:

> ACL data: handle 11 flags 0x02 dlen 18
    L2CAP(d): cid 0x0043 len 14 [psm 23]
      AVCTP: Command : pt 0x00 transaction 3 pid 0x110e
        AV/C: Status: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: ListPlayerApplicationSettingValues: pt 0x00 len 0x0001
            AttributeID: 0x01 (Equalizer ON/OFF Status)
< ACL data: handle 11 flags 0x02 dlen 20
    L2CAP(d): cid 0x0043 len 16 [psm 23]
      AVCTP: Response : pt 0x00 transaction 3 pid 0x110e
        AV/C: Stable: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: ListPlayerApplicationSettingValues: pt 0x00 len 0x0003
            ValueCount: 0x02
            ValueID: 0x01 (OFF)
            ValueID: 0x02 (ON)
2011-08-12 11:04:38 +03:00
Lucas De Marchi
0c6cadf915 avrcp: handle ListPlayerApplicationSettingAttributes pdu
Example of response obtained with PTS test TC_TG_PAS_BV_06_C:

> ACL data: handle 11 flags 0x02 dlen 17
    L2CAP(d): cid 0x0043 len 13 [psm 23]
      AVCTP: Command : pt 0x00 transaction 2 pid 0x110e
        AV/C: Status: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: ListPlayerApplicationSettingAttributes: pt 0x00 len 0x0000
< ACL data: handle 11 flags 0x02 dlen 20
    L2CAP(d): cid 0x0043 len 16 [psm 23]
      AVCTP: Response : pt 0x00 transaction 2 pid 0x110e
        AV/C: Stable: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: ListPlayerApplicationSettingAttributes: pt 0x00 len 0x0003
            AttributeCount: 0x02
            AttributeID: 0x01 (Equalizer ON/OFF Status)
            AttributeID: 0x04 (Scan ON/OFF Status)
2011-08-12 11:04:37 +03:00
Lucas De Marchi
f25568f3b6 avrcp: handle query for company ids
Example of response for PTS test TC_TG_CFG_BV_02_C:

> ACL data: handle 11 flags 0x02 dlen 18
    L2CAP(d): cid 0x0043 len 14 [psm 23]
      AVCTP: Command : pt 0x00 transaction 2 pid 0x110e
        AV/C: Status: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: GetCapabilities: pt 0x00 len 0x0001
            CapabilityID: 0x02 (CompanyID)
< ACL data: handle 11 flags 0x02 dlen 22
    L2CAP(d): cid 0x0043 len 18 [psm 23]
      AVCTP: Response : pt 0x00 transaction 2 pid 0x110e
        AV/C: Stable: address 0x48 opcode 0x00
          Subunit: Panel
          Opcode: Vendor Dependent
          Company ID: 0x001958
          AVRCP: GetCapabilities: pt 0x00 len 0x0005
            CapabilityID: 0x02 (CompanyID)
            CapabilityCount: 0x01
            CompanyID: 0x001958
2011-08-12 11:04:35 +03:00
Lucas De Marchi
65e27905fe avrcp: implement ChangeTrack() method
ChangeTrack() is used by applications to inform bluetoothd that current
track changed, passing also the metadata.
2011-08-12 11:04:33 +03:00
Lucas De Marchi
85206cbbde avrcp: implement ChangePlayback() method
ChangePlayback() is used by applications to inform bluetoothd of the
current status of playback.
2011-08-12 11:04:32 +03:00
Lucas De Marchi
b7dd3c8a8a avrcp: implement SetProperty() method of MediaPlayer
SetProperty() is used by an application to set player specific
settings.
2011-08-12 11:04:30 +03:00
Lucas De Marchi
8c8eaec49b avrcp: add skeleton of MediaPlayer interface 2011-08-12 11:04:29 +03:00
Lucas De Marchi
be70215da3 audio: move interface declarations to their headers 2011-08-12 11:04:27 +03:00
Syam Sidhardhan
6e863c7e83 Fix crash when disconnecting A2DP
When we disconnect an A2DP device by immediate power off and quickly
also initiate a disconnection from our side, a crash is occurring. This
is happening because of the disconnect_timeout coming after freeing the
session.
2011-08-12 10:57:36 +03:00
Luiz Augusto von Dentz
bd3ca4fdf4 Fix possible invalid read/free on media.c
This also fix the circular dependency of media.c and a2dp.c

 Invalid read of size 8
    at 0x4EA8CC2: g_slice_free_chain_with_offset (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x13AF33: path_free (media.c:417)
    by 0x11EB39: remove_interface (object.c:563)
    by 0x11F360: g_dbus_unregister_interface (object.c:715)
    by 0x120C49: media_server_remove (manager.c:1098)
    by 0x4EA9826: g_slist_foreach (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x178915: adapter_remove (adapter.c:2326)
    by 0x17535F: btd_manager_unregister_adapter (manager.c:293)
    by 0x154081: device_event (hciops.c:2643)
    by 0x1543C1: io_stack_event (hciops.c:2763)
    by 0x4E8C88C: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x4E8D087: ??? (in /lib64/libglib-2.0.so.0.2908.0)
  Address 0x63f6638 is 8 bytes inside a block of size 16 free'd
    at 0x4A055FE: free (vg_replace_malloc.c:366)
    by 0x4E938F2: g_free (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x4EA854E: g_slice_free1 (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x4EA930C: g_slist_remove (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x13AE53: media_endpoint_remove (media.c:118)
    by 0x4EA9826: g_slist_foreach (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x4EA984A: g_slist_free_full (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x13AF33: path_free (media.c:417)
    by 0x11EB39: remove_interface (object.c:563)
    by 0x11F360: g_dbus_unregister_interface (object.c:715)
    by 0x120C49: media_server_remove (manager.c:1098)
    by 0x4EA9826: g_slist_foreach (in /lib64/libglib-2.0.so.0.2908.0)
2011-08-08 16:47:02 +03:00
Anderson Lizardo
3c19214717 Remove bogus extra semicolons 2011-08-08 13:04:34 +03:00
Dmitriy Paliy
fad552de92 Fix cancel pending D-Bus call to ohmd
Pending D-Bus call to ohmd daemon is canceled if telephony driver is
unloaded before reply comes.
2011-08-05 12:40:29 +03:00
Johan Hedberg
fb25161654 Move around static functions to avoid forward-declarations 2011-08-05 12:40:06 +03:00
Dmitriy Paliy
ccd40753e9 Add stop playing ringtone to maemo6 telephony driver
If ringtone is loud enough, it may leak to microphone when call is
answered via Bluetooth headset. As result, it can be heard on remote
end. Therefore, playing ringtone shall be stopped as fast as possible
before answering a call.
2011-08-05 12:39:42 +03:00
Frédéric Dalleau
bc66f33f63 Minor style fix in audio/gateway.c 2011-08-05 12:19:35 +03:00
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