2014-07-23 11:34:58

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 1/4] android/client: Fix double close issue

From: Andrei Emeltchenko <[email protected]>

File is closed inside reading thread. Fixes:
...
Error in
`.../bluez/android/haltest':
double free or corruption (!prev): 0x000000000065a5e0 ***

Program received signal SIGABRT, Aborted.
...
---
android/client/if-sco.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/android/client/if-sco.c b/android/client/if-sco.c
index 4919fd9..70e2737 100644
--- a/android/client/if-sco.c
+++ b/android/client/if-sco.c
@@ -451,6 +451,8 @@ static void read_p(int argc, const char **argv)
haltest_error("Cannot create playback thread!\n");
goto failed;
}
+
+ return;
failed:
if (out)
fclose(out);
--
1.9.1



2014-07-24 08:04:30

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH 1/4] android/client: Fix double close issue

Hi Andrei,

On Wed, Jul 23, 2014, Andrei Emeltchenko wrote:
> File is closed inside reading thread. Fixes:
> ...
> Error in
> `.../bluez/android/haltest':
> double free or corruption (!prev): 0x000000000065a5e0 ***
>
> Program received signal SIGABRT, Aborted.
> ...
> ---
> android/client/if-sco.c | 2 ++
> 1 file changed, 2 insertions(+)

All four patches have been applied. Thanks.

Johan

2014-07-23 11:34:59

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 2/4] android/client: Fix crash reading not connected SCO

From: Andrei Emeltchenko <[email protected]>

When SCO is not connected we get -1 from in_read() HAL function.
---
android/client/if-sco.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/android/client/if-sco.c b/android/client/if-sco.c
index 70e2737..c33b012 100644
--- a/android/client/if-sco.c
+++ b/android/client/if-sco.c
@@ -287,7 +287,7 @@ static void *read_thread(void *data)
{
int (*filbuff_cb) (short*, void*) = feed_from_in;
short buffer[buffer_size_in / sizeof(short)];
- size_t len = 0;
+ ssize_t len = 0;
void *cb_data = NULL;
FILE *out = data;

@@ -311,6 +311,10 @@ static void *read_thread(void *data)
pthread_mutex_unlock(&state_mutex);

len = filbuff_cb(buffer, cb_data);
+ if (len < 0) {
+ haltest_error("Error receiving SCO data");
+ break;
+ }

haltest_info("Read %zd bytes\n", len);

--
1.9.1


2014-07-23 11:35:01

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 4/4] android/doc: Add Audio SCO HAL documentation

From: Andrei Emeltchenko <[email protected]>

---
android/README | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)

diff --git a/android/README b/android/README
index 72b157a..279530c 100644
--- a/android/README
+++ b/android/README
@@ -300,6 +300,34 @@ methods:
client->set_adv_data missing kernel support for vendor data
client->connect is_direct parameter is ignored

+Audio SCO HAL
+=============
+
+When Bluetooth chip's audio is not wired directly to device audio, Audio SCO
+HAL is used to enable SCO support. It needs to be loaded by AudioFlinger
+following audio_policy.cong configuration. Example of configuration is shown
+below:
+
+...
+ sco {
+ outputs {
+ sco {
+ sampling_rates 8000|44100
+ channel_masks AUDIO_CHANNEL_OUT_STEREO
+ formats AUDIO_FORMAT_PCM_16_BIT
+ devices AUDIO_DEVICE_OUT_ALL_SCO
+ }
+ }
+ inputs {
+ sco {
+ sampling_rates 8000|44100
+ channel_masks AUDIO_CHANNEL_IN_MONO
+ formats AUDIO_FORMAT_PCM_16_BIT
+ devices AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET
+ }
+ }
+ }
+...

Known Android issues
====================
--
1.9.1


2014-07-23 11:35:00

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 3/4] android/client: Check stream before standby() call

From: Andrei Emeltchenko <[email protected]>

Rearrange stop sequence. Fixes following issue:
...
Program received signal SIGSEGV, Segmentation fault.
0x00000000004105b8 in stop_p (argc=<optimized out>, argv=<optimized
out>) at android/client/if-sco.c:483
483 stream_out->common.standby(&stream_out->common);
(gdb) bt
out>) at android/client/if-sco.c:483
...

f stop
---
android/client/if-sco.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/android/client/if-sco.c b/android/client/if-sco.c
index c33b012..7a89692 100644
--- a/android/client/if-sco.c
+++ b/android/client/if-sco.c
@@ -473,16 +473,18 @@ static void stop_p(int argc, const char **argv)
return;
}

+ if (stream_out) {
+ pthread_mutex_lock(&outstream_mutex);
+ stream_out->common.standby(&stream_out->common);
+ pthread_mutex_unlock(&outstream_mutex);
+ }
+
current_state = STATE_STOPPING;
pthread_mutex_unlock(&state_mutex);

pthread_join(play_thread, NULL);
play_thread = 0;

- pthread_mutex_lock(&outstream_mutex);
- stream_out->common.standby(&stream_out->common);
- pthread_mutex_unlock(&outstream_mutex);
-
haltest_info("Ended %s\n", __func__);
}

--
1.9.1