All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] android/client: Fix double initialize of bluetooth
@ 2014-11-26 11:43 Grzegorz Kolodziejczyk
  2014-11-26 11:43 ` [PATCH 2/2] android/client: Fix no closing bt, audio dev on exit Grzegorz Kolodziejczyk
  2014-12-03  8:14 ` [PATCH 1/2] android/client: Fix double initialize of bluetooth Szymon Janc
  0 siblings, 2 replies; 3+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-11-26 11:43 UTC (permalink / raw)
  To: linux-bluetooth

Profile initialization loop should omit already initialized profiles
by process line command.
---
 android/client/haltest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/client/haltest.c b/android/client/haltest.c
index add1978..f19e671 100644
--- a/android/client/haltest.c
+++ b/android/client/haltest.c
@@ -422,7 +422,7 @@ static void init(void)
 	}
 
 	/* Init what is available to init */
-	for (i = 2; i < NELEM(interfaces) - 1; ++i) {
+	for (i = 3; i < NELEM(interfaces) - 1; ++i) {
 		m = get_interface_method(interfaces[i]->name, "init");
 		if (m != NULL)
 			m->func(2, argv);
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] android/client: Fix no closing bt, audio dev on exit
  2014-11-26 11:43 [PATCH 1/2] android/client: Fix double initialize of bluetooth Grzegorz Kolodziejczyk
@ 2014-11-26 11:43 ` Grzegorz Kolodziejczyk
  2014-12-03  8:14 ` [PATCH 1/2] android/client: Fix double initialize of bluetooth Szymon Janc
  1 sibling, 0 replies; 3+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-11-26 11:43 UTC (permalink / raw)
  To: linux-bluetooth

Audio, bt hw devices should be closed on exit.

On exit we get:
==696== 80 bytes in 1 blocks are definitely lost in loss record 6 of 13
==696==    at 0x4C2745D: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==696==    by 0x6B3E683: open_bluetooth (hal-bluetooth.c:1079)
==696==    by 0x4051C3: init_p (if-bt.c:374)
==696==    by 0x4020F8: process_line (haltest.c:310)
==696==    by 0x401919: main (haltest.c:423)
==696==
==696== 272 bytes in 1 blocks are possibly lost in loss record 10 of 13
==696==    at 0x4C291D4: calloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==696==    by 0x4011C24: _dl_allocate_tls (in /usr/lib64/ld-2.18.so)
==696==    by 0x534480A: pthread_create@@GLIBC_2.2.5 (in
/usr/lib64/libpthread-2.18.so)
==696==    by 0x5D192AE: audio_open (hal-audio.c:1541)
==696==    by 0x411683: init_p (audio.h:655)
==696==    by 0x4020F8: process_line (haltest.c:310)
==696==    by 0x401907: main (haltest.c:421)
==696==
==696== LEAK SUMMARY:
==696==    definitely lost: 80 bytes in 1 blocks
==696==    indirectly lost: 0 bytes in 0 blocks
==696==      possibly lost: 272 bytes in 1 blocks
==696==    still reachable: 6,236 bytes in 18 blocks
==696==         suppressed: 0 bytes in 0 blocks
---
 android/client/haltest.c |  7 +++++++
 android/client/if-bt.c   | 15 ++++++++++++---
 android/client/if-main.h |  1 +
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/android/client/haltest.c b/android/client/haltest.c
index f19e671..c62be75 100644
--- a/android/client/haltest.c
+++ b/android/client/haltest.c
@@ -34,6 +34,8 @@
 #include "pollhandler.h"
 #include "history.h"
 
+static void process_line(char *line_buffer);
+
 const struct interface *interfaces[] = {
 	&audio_if,
 	&sco_if,
@@ -172,6 +174,11 @@ static void help_p(int argc, const char **argv)
 /* quit/exit execution */
 static void quit_p(int argc, const char **argv)
 {
+	char cleanup_audio[] = "audio cleanup";
+
+	close_hw_bt_dev();
+	process_line(cleanup_audio);
+
 	exit(0);
 }
 
diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index 22f3f4c..250f826 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -22,6 +22,7 @@
 #include "../hal-msg.h"
 #include "../hal-utils.h"
 
+static hw_device_t *bt_device;
 const bt_interface_t *if_bluetooth;
 
 #define VERIFY_PROP_TYPE_ARG(n, typ) \
@@ -162,6 +163,15 @@ static void add_remote_device_from_props(int num_properties,
 	}
 }
 
+bool close_hw_bt_dev(void)
+{
+	if (!bt_device)
+		return false;
+
+	bt_device->close(bt_device);
+	return true;
+}
+
 static void adapter_state_changed_cb(bt_state_t state)
 {
 	haltest_info("%s: state=%s\n", __func__, bt_state_t2str(state));
@@ -363,7 +373,6 @@ static void init_p(int argc, const char **argv)
 {
 	int err;
 	const hw_module_t *module;
-	hw_device_t *device;
 
 	err = hw_get_module(BT_HARDWARE_MODULE_ID, &module);
 	if (err) {
@@ -371,14 +380,14 @@ static void init_p(int argc, const char **argv)
 		return;
 	}
 
-	err = module->methods->open(module, BT_HARDWARE_MODULE_ID, &device);
+	err = module->methods->open(module, BT_HARDWARE_MODULE_ID, &bt_device);
 	if (err) {
 		haltest_error("module->methods->open returned %d\n", err);
 		return;
 	}
 
 	if_bluetooth =
-		    ((bluetooth_device_t *) device)->get_bluetooth_interface();
+		((bluetooth_device_t *) bt_device)->get_bluetooth_interface();
 	if (!if_bluetooth) {
 		haltest_error("get_bluetooth_interface returned NULL\n");
 		return;
diff --git a/android/client/if-main.h b/android/client/if-main.h
index 96409aa..6a620e4 100644
--- a/android/client/if-main.h
+++ b/android/client/if-main.h
@@ -154,6 +154,7 @@ const char *enum_devices(void *v, int i);
 const char *interface_name(void *v, int i);
 const char *command_name(void *v, int i);
 void add_remote_device(const bt_bdaddr_t *addr);
+bool close_hw_bt_dev(void);
 
 const struct interface *get_interface(const char *name);
 struct method *get_method(struct method *methods, const char *name);
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] android/client: Fix double initialize of bluetooth
  2014-11-26 11:43 [PATCH 1/2] android/client: Fix double initialize of bluetooth Grzegorz Kolodziejczyk
  2014-11-26 11:43 ` [PATCH 2/2] android/client: Fix no closing bt, audio dev on exit Grzegorz Kolodziejczyk
@ 2014-12-03  8:14 ` Szymon Janc
  1 sibling, 0 replies; 3+ messages in thread
From: Szymon Janc @ 2014-12-03  8:14 UTC (permalink / raw)
  To: Grzegorz Kolodziejczyk; +Cc: linux-bluetooth

Hi Grzegorz,

On Wednesday 26 of November 2014 12:43:48 Grzegorz Kolodziejczyk wrote:
> Profile initialization loop should omit already initialized profiles
> by process line command.
> ---
>  android/client/haltest.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/android/client/haltest.c b/android/client/haltest.c
> index add1978..f19e671 100644
> --- a/android/client/haltest.c
> +++ b/android/client/haltest.c
> @@ -422,7 +422,7 @@ static void init(void)
>  	}
>  
>  	/* Init what is available to init */
> -	for (i = 2; i < NELEM(interfaces) - 1; ++i) {
> +	for (i = 3; i < NELEM(interfaces) - 1; ++i) {
>  		m = get_interface_method(interfaces[i]->name, "init");
>  		if (m != NULL)
>  			m->func(2, argv);

Both patches applied, thanks.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-12-03  8:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-26 11:43 [PATCH 1/2] android/client: Fix double initialize of bluetooth Grzegorz Kolodziejczyk
2014-11-26 11:43 ` [PATCH 2/2] android/client: Fix no closing bt, audio dev on exit Grzegorz Kolodziejczyk
2014-12-03  8:14 ` [PATCH 1/2] android/client: Fix double initialize of bluetooth Szymon Janc

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.