Commit Graph

82 Commits

Author SHA1 Message Date
Szymon Janc
14fc3c5403 android: Pass mode parameter to registered services 2014-03-04 10:18:27 +01:00
Szymon Janc
7d95d027b1 android: Create comon header for IPC
This header contains IPC specific structures and code not related to
BT and audio HAL protocols. This allows to fully decouple IPC from
HAL messages.

This is first step to make HAL part of IPC unit-testable and reusable
between BT HAL and audio HAL.
2014-02-28 15:22:45 +01:00
Szymon Janc
d61f3fc72e android/a2dp: Use common IPC for audio socket
This makes audio HAL to use same code for IPC as BT HAL.
2014-02-28 15:22:45 +01:00
Szymon Janc
dd1e44fce1 android: Refactor IPC init
This allows to pass socket path and max service ID while initializaing
IPC. This is first step to allow use it both for BT and Audio HALs.
2014-02-28 15:22:45 +01:00
Marcel Holtmann
cde69653e0 android: Update copyright and license details 2014-02-11 10:42:56 -08:00
Andrzej Kaczmarek
4190ac1223 android/a2dp: Fix audio deregistration
Unregistering a SEP can trigger abort_cfm callback if some device is
connected thus we should free setups list after all endpoints are
unregistered to avoid error in abort_cfm due to non-existing setup.
2014-02-10 13:22:57 +02:00
Andrzej Kaczmarek
496dd38b11 android/a2dp: Disconnect headset on IPC failure
In case audio IPC is suddenly disconnected (most likely due to crash of
mediaserver process) we should disconnect headset since it is no longer
associated with valid setup and cannot be used properly.
2014-02-10 13:22:57 +02:00
Andrzej Kaczmarek
217b2102f1 android/a2dp: Notify audio state on SEP close 2014-02-10 13:22:57 +02:00
Luiz Augusto von Dentz
8da3f38086 android/A2DP: Fix invalid read
Invalid read of size 8
   at 0x30EE465A78: g_slice_free_chain_with_offset (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x418209: bt_a2dp_unregister (a2dp.c:1576)
   by 0x4039E6: main (main.c:347)
 Address 0x4f2d248 is 8 bytes inside a block of size 16 free'd
   at 0x4A07577: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x30EE44EF7E: g_free (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x30EE4655CA: g_slice_free1 (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x30EE465F0C: g_slist_remove (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x41645F: a2dp_device_free (a2dp.c:174)
   by 0x30EE466477: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x30EE46649A: g_slist_free_full (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x418209: bt_a2dp_unregister (a2dp.c:1576)
   by 0x4039E6: main (main.c:347)
2014-02-06 14:00:56 +02:00
Luiz Augusto von Dentz
16c6bf15d5 android: Disconnect AVRCP once A2DP is disconnected
If A2DP is disconnected also disconnect AVRCP.
2014-02-05 14:44:20 +01:00
Luiz Augusto von Dentz
a8a4a233b9 android: Connect AVRCP once A2DP is connected
In case of being the initiator of the A2DP connection also attempt to
connect AVRCP.
2014-02-05 14:44:20 +01:00
Szymon Janc
6fd7e0f2e9 android/a2dp: Fix crash on remote disconnection
Remove setups when a2dp device is removed. This fix following:

Invalid read of size 4
   at 0x115E32: bt_stream_close (a2dp.c:1352)
   by 0x111DFB: ipc_handle_msg (ipc.c:95)
   by 0x11234B: audio_watch_cb (audio-ipc.c:67)
   by 0x48BD9C7: ??? (in /system/lib/libglib.so)
 Address 0x4a590f4 is 12 bytes inside a block of size 20 free'd
   at 0x4897E6C: free (in
       /system/lib/valgrind/vgpreload_memcheck-arm-linux.so)
   by 0x48C5E2B: g_free (in /system/lib/libglib.so)

Invalid read of size 4
   at 0x113638: avdtp_close (avdtp.c:3201)
   by 0x115E39: bt_stream_close (a2dp.c:1352)
   by 0x111DFB: ipc_handle_msg (ipc.c:95)
   by 0x11234B: audio_watch_cb (audio-ipc.c:67)
   by 0x48BD9C7: ??? (in /system/lib/libglib.so)
 Address 0x4a594a4 is 28 bytes inside a block of size 1,100 free'd
   at 0x4897E6C: free (in
       /system/lib/valgrind/vgpreload_memcheck-arm-linux.so)
   by 0x48C5E2B: g_free (in /system/lib/libglib.so)
2014-01-29 09:17:22 -08:00
Marcel Holtmann
c1add0ff9f android: Use src/log.h include instead of just log.h 2014-01-26 00:23:15 -08:00
Andrzej Kaczmarek
77ff405a45 android/a2dp: Fix audio resume on started stream
In case stream is started from remote we'll receive Resume Stream IPC
when audio is already considered as started (i.e. on first write from
AudioFlinger). In such case we should not try to send AVDTP_START since
this will fail but just reply success over IPC instead.
2014-01-24 22:59:45 +01:00
Luiz Augusto von Dentz
c19c7df0e7 android/A2DP: Fix invalid read after unregistering an endpoint
The endpoint is unregistered but it was still accessible via endpoints
list causing the following trace when audio HAL is closed:
Invalid read of size 8
   at 0x414A49: unregister_endpoint (a2dp.c:114)
   by 0x3862466477: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x386246649A: g_slist_free_full (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x414985: audio_disconnected (a2dp.c:1446)
   by 0x40FD5C: audio_watch_cb (audio-ipc.c:79)
   by 0x38624492A5: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x3862449627: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x3862449A39: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x4034D5: main (main.c:449)
 Address 0x4cd5e68 is 8 bytes inside a block of size 32 free'd
   at 0x4A07577: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x386244EF7E: g_free (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x4159FD: bt_audio_close (a2dp.c:1296)
   by 0x40F629: ipc_handle_msg (ipc.c:95)
   by 0x40FD9F: audio_watch_cb (audio-ipc.c:67)
   by 0x38624492A5: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x3862449627: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x3862449A39: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3800.2)
   by 0x4034D5: main (main.c:449)
2014-01-23 19:59:58 +02:00
Andrzej Kaczmarek
adaa54bdf7 android: Add MTU data to Open Stream Audio IPC
MTU value for transport channel is sent in Open Stream response, which
is required to calculate number of frames which can be packed into
single media packet.

This is to avoid including GPLv2 licensed headers in Audio HAL
implementation.
2014-01-23 11:34:19 +02:00
Luiz Augusto von Dentz
c26f5203fd android/A2DP: Add retry logic to Audio IPC
In case the audio HAL disconnects without cleaning up its endpoints treat
it as unclean disconnection and attempt to reconnect.
2014-01-21 16:20:54 +01:00
Luiz Augusto von Dentz
e2551c5f54 android/A2DP: Fix sending notification on bt_a2dp_unregister
At this point IPC might have been closed already.
2014-01-21 13:37:35 +02:00
Luiz Augusto von Dentz
73f26e34e8 android/A2DP: Notify when audio state change to suspend 2014-01-18 23:32:37 +02:00
Luiz Augusto von Dentz
5ab13f5539 android/A2DP: Notify when audio state change to stopped 2014-01-18 23:32:37 +02:00
Luiz Augusto von Dentz
786f12c057 android/A2DP: Notify when audio state change to started 2014-01-18 23:32:37 +02:00
Andrzej Kaczmarek
c2dfa92892 android/a2dp: Fix typo in condition 2014-01-16 17:50:32 +02:00
Luiz Augusto von Dentz
b270a8cbd2 android/A2DP: Add timeout to setup stream if remote becomes idle
If remote initiate the connection but do not setup any stream take over
the role and initiate the stream setup procedure.
2014-01-16 16:01:40 +02:00
Luiz Augusto von Dentz
b4d7dd4351 android/A2DP: Send stream fd in open stream response
This adds support of sending stream fd within open stream response.
2014-01-16 16:01:40 +02:00
Luiz Augusto von Dentz
484fba7019 android/A2DP: Fix selecting invalid bitpool range for SBC
For SBC bitpool range may not strictly match with presets so it needs to
be adjusted to fit within remote capabilities otherwise the remote device
may reject the configuration.
2014-01-16 16:01:40 +02:00
Luiz Augusto von Dentz
1a8dba380c android/A2DP: Change to connected state when a transport open
This changes the connected state to be only sent once a transport is
open, before this was done right after the signalling was connected but
this reflect in the audio HAL side attempting to open a stream while
with possible no transport available.
2014-01-16 16:01:40 +02:00
Andrzej Kaczmarek
c838bfcbb9 android/a2dp: Fix memory leak
audio_ipc_send_rsp_full() does not free buffer passed as parameter
thus it should be freed by caller.

This fixes following Valgrind report:

==1238== 5 bytes in 1 blocks are definitely lost in loss record 22 of 54
==1238==    at 0x4896DC8: calloc (in /system/lib/valgrind/vgpreload_memcheck-arm-linux.so)
==1238==    by 0x48C5DB7: g_malloc0 (gmem.c:189)
==1238==    by 0x1150EF: bt_stream_open (a2dp.c:1177)
==1238==    by 0x1116A7: ipc_handle_msg (ipc.c:95)
==1238==    by 0x111C11: audio_watch_cb (audio-ipc.c:66)
==1238==    by 0x48BD9C7: g_io_unix_dispatch (giounix.c:166)
==1238==    by 0x48C2CCB: g_main_context_dispatch (gmain.c:2539)
==1238==    by 0x48C2ED9: g_main_context_iterate.isra.19 (gmain.c:3146)
==1238==    by 0x48C3167: g_main_loop_run (gmain.c:3340)
==1238==    by 0x10B207: main (main.c:436)
2014-01-16 08:59:31 +01:00
Andrzej Kaczmarek
6bbd5c1736 android/a2dp: Fix memory leak
avdtp_service_cap_new() makes own copy of data stored in "codec" thus
it should be freed by caller.

This fixes following Valgrind report:

==1238== 6 bytes in 1 blocks are definitely lost in loss record 27 of 54
==1238==    at 0x4896DC8: calloc (in /system/lib/valgrind/vgpreload_memcheck-arm-linux.so)
==1238==    by 0x48C5DB7: g_malloc0 (gmem.c:189)
==1238==    by 0x115B4B: discover_cb (a2dp.c:303)
==1238==    by 0x111DE7: finalize_discovery (avdtp.c:933)
==1238==    by 0x114441: session_cb (avdtp.c:2556)
==1238==    by 0x48BD9C7: g_io_unix_dispatch (giounix.c:166)
==1238==    by 0x48C2CCB: g_main_context_dispatch (gmain.c:2539)
==1238==    by 0x48C2ED9: g_main_context_iterate.isra.19 (gmain.c:3146)
==1238==    by 0x48C3167: g_main_loop_run (gmain.c:3340)
==1238==    by 0x10B207: main (main.c:436)
2014-01-16 08:59:31 +01:00
Luiz Augusto von Dentz
0a6f949ff6 android/A2DP: Connect transport channel when initiator
This connects transport channel when initiator of open request.
2014-01-15 14:52:44 +02:00
Luiz Augusto von Dentz
c6fed41a02 android/A2DP: Add handling of incoming transport connection
This adds handling of incoming transport connection attempt.
2014-01-15 14:52:44 +02:00
Andrzej Kaczmarek
e21b24d825 android/a2dp: Fix freeing preset on SEP close
In case SEP was opened from local side, corresponding a2dp_setup
structure has just reference to a2dp_preset which is stored on presets
list. As a result, when closing SEP such preset will be freed leaving
dangling pointer on presets list.
2014-01-15 11:32:51 +02:00
Andrzej Kaczmarek
63ffbe33a5 android/a2dp: Fix IPC response length calculation
struct audio_rsp_open_stream has only zero-length array member thus its
size equals to 0. We need to explicitly specify size of array element
type here.
2014-01-15 11:10:13 +02:00
Luiz Augusto von Dentz
d2ba4c96ac audio/A2DP: Add implemention of SEP abort confirmation 2014-01-14 11:53:00 +01:00
Luiz Augusto von Dentz
b0b5ef76f8 audio/A2DP: Add implemention of SEP close confirmation 2014-01-14 11:53:00 +01:00
Luiz Augusto von Dentz
f0552102b4 audio/A2DP: Add implemention of SEP suspend confirmation 2014-01-14 11:52:59 +01:00
Luiz Augusto von Dentz
85dfe54a9e audio/A2DP: Add implemention of SEP start confirmation 2014-01-14 11:52:59 +01:00
Luiz Augusto von Dentz
a7e6f93477 audio/A2DP: Add implemention of SEP open confirmation 2014-01-14 11:52:59 +01:00
Luiz Augusto von Dentz
54ed16806e audio/A2DP: Add implemention of SEP set_configuration confirmation 2014-01-14 11:52:59 +01:00
Luiz Augusto von Dentz
cce40aefe2 android/A2DP: Discover endpoints when initiator 2014-01-14 11:52:59 +01:00
Luiz Augusto von Dentz
38305eb3a9 audio/A2DP: Add implemention of SEP suspend indication 2014-01-14 11:52:59 +01:00
Luiz Augusto von Dentz
18f5cab60b audio/A2DP: Add implemention of SEP start indication 2014-01-14 11:52:59 +01:00
Luiz Augusto von Dentz
4ae4b66c99 audio/A2DP: Add implemention of SEP close indication 2014-01-14 11:52:59 +01:00
Luiz Augusto von Dentz
7f2f807a69 audio/A2DP: Add implemention of SEP open indication 2014-01-14 11:52:59 +01:00
Andrzej Kaczmarek
2ea6eff01a android/a2dp: Fix buffer size calculation for codec caps 2014-01-13 15:10:28 +02:00
Luiz Augusto von Dentz
4830daffa2 audio/A2DP: Add implemention of audio Suspend Stream command 2014-01-13 14:33:16 +02:00
Luiz Augusto von Dentz
712aae3add audio/A2DP: Add implemention of audio Resume Stream command 2014-01-13 14:33:16 +02:00
Luiz Augusto von Dentz
31993b0a0e audio/A2DP: Add implemention of audio Close Stream command 2014-01-13 14:33:16 +02:00
Luiz Augusto von Dentz
a385cf8295 audio/A2DP: Add implemention of audio Open Stream command 2014-01-13 14:33:16 +02:00
Luiz Augusto von Dentz
48449b6632 audio/A2DP: Add implemention of audio Close command 2014-01-13 14:33:16 +02:00
Luiz Augusto von Dentz
bb36b8aa44 audio/A2DP: Add implemention of audio Open command 2014-01-13 14:33:16 +02:00