2014-02-18 14:40:32

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ v2 1/4] shared: Add initial AVRCP code

From: Andrei Emeltchenko <[email protected]>

The patch makes AVRCP to be transport agnostic so that it can be used in
with socket pair to build unit tests.

The idea is that all AVRCP specific logic will stay on src/shared/avrcp
and connecting handling elsewhere.
---
v2: Fix not updating Android.mk with new location of the files

android/Android.mk | 1 +
android/Makefile.am | 1 +
android/avrcp.c | 42 ++++++++++++-----------
src/shared/avrcp.c | 75 +++++++++++++++++++++++++++++++++++++++++
{android => src/shared}/avrcp.h | 13 ++++---
5 files changed, 108 insertions(+), 24 deletions(-)
create mode 100644 src/shared/avrcp.c
copy {android => src/shared}/avrcp.h (65%)

diff --git a/android/Android.mk b/android/Android.mk
index 2481a2c..4f8a17a 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -49,6 +49,7 @@ LOCAL_SRC_FILES := \
bluez/src/shared/ringbuf.c \
bluez/src/shared/hfp.c \
bluez/src/shared/io-glib.c \
+ bluez/src/shared/avrcp.c \
bluez/src/sdpd-database.c \
bluez/src/sdpd-service.c \
bluez/src/sdpd-request.c \
diff --git a/android/Makefile.am b/android/Makefile.am
index 1913b42..3cc0687 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -29,6 +29,7 @@ android_bluetoothd_SOURCES = android/main.c \
src/shared/mgmt.h src/shared/mgmt.c \
src/shared/ringbuf.h src/shared/ringbuf.c \
src/shared/hfp.h src/shared/hfp.c \
+ src/shared/avrcp.h src/shared/avrcp.c \
android/bluetooth.h android/bluetooth.c \
android/hidhost.h android/hidhost.c \
android/ipc.h android/ipc.c \
diff --git a/android/avrcp.c b/android/avrcp.c
index b8304f5..65b3417 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -32,12 +32,12 @@
#include "lib/bluetooth.h"
#include "lib/sdp.h"
#include "lib/sdp_lib.h"
+#include "src/shared/avrcp.h"
#include "src/log.h"
#include "bluetooth.h"
#include "avrcp.h"
#include "hal-msg.h"
#include "ipc.h"
-#include "avctp.h"

#define L2CAP_PSM_AVCTP 0x17

@@ -53,7 +53,7 @@ static GIOChannel *server = NULL;

struct avrcp_device {
bdaddr_t dst;
- struct avctp *session;
+ struct avrcp *session;
GIOChannel *io;
};

@@ -133,7 +133,7 @@ static void avrcp_device_free(void *data)
struct avrcp_device *dev = data;

if (dev->session)
- avctp_shutdown(dev->session);
+ avrcp_shutdown(dev->session);

if (dev->io) {
g_io_channel_shutdown(dev->io, FALSE, NULL);
@@ -168,6 +168,17 @@ static int device_cmp(gconstpointer s, gconstpointer user_data)
return bacmp(&dev->dst, dst);
}

+static struct avrcp_device *avrcp_device_find(const bdaddr_t *dst)
+{
+ GSList *l;
+
+ l = g_slist_find_custom(devices, dst, device_cmp);
+ if (!l)
+ return NULL;
+
+ return l->data;
+}
+
static void disconnect_cb(void *data)
{
struct avrcp_device *dev = data;
@@ -186,7 +197,6 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
char address[18];
uint16_t imtu, omtu;
GError *gerr = NULL;
- GSList *l;
int fd;

if (err) {
@@ -209,9 +219,8 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)

ba2str(&dst, address);

- l = g_slist_find_custom(devices, &dst, device_cmp);
- if (l) {
- dev = l->data;
+ dev = avrcp_device_find(&dst);
+ if (dev) {
if (dev->session) {
error("Unexpected connection");
return;
@@ -222,17 +231,17 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
}

fd = g_io_channel_unix_get_fd(chan);
- dev->session = avctp_new(fd, imtu, omtu, 0x0100);

+ dev->session = avrcp_new(fd, imtu, omtu, 0x0100);
if (!dev->session) {
avrcp_device_free(dev);
return;
}

- avctp_set_destroy_cb(dev->session, disconnect_cb, dev);
+ avrcp_set_destroy_cb(dev->session, disconnect_cb, dev);

/* FIXME: get the real name of the device */
- avctp_init_uinput(dev->session, "bluetooth", address);
+ avrcp_init_uinput(dev->session, "bluetooth", address);

g_io_channel_set_close_on_unref(chan, FALSE);

@@ -331,12 +340,10 @@ void bt_avrcp_connect(const bdaddr_t *dst)
{
struct avrcp_device *dev;
char addr[18];
- GSList *l;

DBG("");

- l = g_slist_find_custom(devices, dst, device_cmp);
- if (l)
+ if (avrcp_device_find(dst))
return;

dev = avrcp_device_new(dst);
@@ -352,18 +359,15 @@ void bt_avrcp_connect(const bdaddr_t *dst)
void bt_avrcp_disconnect(const bdaddr_t *dst)
{
struct avrcp_device *dev;
- GSList *l;

DBG("");

- l = g_slist_find_custom(devices, dst, device_cmp);
- if (!l)
+ dev = avrcp_device_find(dst);
+ if (!dev)
return;

- dev = l->data;
-
if (dev->session) {
- avctp_shutdown(dev->session);
+ avrcp_shutdown(dev->session);
return;
}

diff --git a/src/shared/avrcp.c b/src/shared/avrcp.c
new file mode 100644
index 0000000..32bd703
--- /dev/null
+++ b/src/shared/avrcp.c
@@ -0,0 +1,75 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdbool.h>
+#include <glib.h>
+
+#include "lib/bluetooth.h"
+
+#include "src/log.h"
+
+#include "android/avctp.h"
+#include "avrcp.h"
+
+struct avrcp {
+ struct avctp *session;
+};
+
+void avrcp_shutdown(struct avrcp *session)
+{
+ if (session->session)
+ avctp_shutdown(session->session);
+
+ g_free(session);
+}
+
+struct avrcp *avrcp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
+{
+ struct avrcp *session;
+
+ session = g_new0(struct avrcp, 1);
+
+ session->session = avctp_new(fd, imtu, omtu, version);
+ if (!session->session) {
+ g_free(session);
+ return NULL;
+ }
+
+ return session;
+}
+
+void avrcp_set_destroy_cb(struct avrcp *session, avrcp_destroy_cb_t cb,
+ void *user_data)
+{
+ avctp_set_destroy_cb(session->session, cb, user_data);
+}
+
+int avrcp_init_uinput(struct avrcp *session, const char *name,
+ const char *address)
+{
+ return avctp_init_uinput(session->session, name, address);
+}
diff --git a/android/avrcp.h b/src/shared/avrcp.h
similarity index 65%
copy from android/avrcp.h
copy to src/shared/avrcp.h
index 1fcd953..7955d56 100644
--- a/android/avrcp.h
+++ b/src/shared/avrcp.h
@@ -2,7 +2,7 @@
*
* BlueZ - Bluetooth protocol stack for Linux
*
- * Copyright (C) 2013-2014 Intel Corporation. All rights reserved.
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
@@ -21,8 +21,11 @@
*
*/

-bool bt_avrcp_register(const bdaddr_t *addr);
-void bt_avrcp_unregister(void);
+typedef void (*avrcp_destroy_cb_t) (void *user_data);

-void bt_avrcp_connect(const bdaddr_t *dst);
-void bt_avrcp_disconnect(const bdaddr_t *dst);
+struct avrcp *avrcp_new(int fd, size_t imtu, size_t omtu, uint16_t version);
+void avrcp_shutdown(struct avrcp *session);
+void avrcp_set_destroy_cb(struct avrcp *session, avrcp_destroy_cb_t cb,
+ void *user_data);
+int avrcp_init_uinput(struct avrcp *session, const char *name,
+ const char *address);
--
1.8.5.3



2014-02-20 09:03:26

by Andrei Emeltchenko

[permalink] [raw]
Subject: Re: [PATCH BlueZ v2 1/4] shared: Add initial AVRCP code

Hi

On Tue, Feb 18, 2014 at 04:40:32PM +0200, Luiz Augusto von Dentz wrote:
> From: Andrei Emeltchenko <[email protected]>
>
> The patch makes AVRCP to be transport agnostic so that it can be used in
> with socket pair to build unit tests.
>
> The idea is that all AVRCP specific logic will stay on src/shared/avrcp
> and connecting handling elsewhere.

Any comments about the patch? We need this one to start doing AVRCP unit tests.

Best regards
Andrei Emeltchenko


> ---
> v2: Fix not updating Android.mk with new location of the files
>
> android/Android.mk | 1 +
> android/Makefile.am | 1 +
> android/avrcp.c | 42 ++++++++++++-----------
> src/shared/avrcp.c | 75 +++++++++++++++++++++++++++++++++++++++++
> {android => src/shared}/avrcp.h | 13 ++++---
> 5 files changed, 108 insertions(+), 24 deletions(-)
> create mode 100644 src/shared/avrcp.c
> copy {android => src/shared}/avrcp.h (65%)
>
> diff --git a/android/Android.mk b/android/Android.mk
> index 2481a2c..4f8a17a 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -49,6 +49,7 @@ LOCAL_SRC_FILES := \
> bluez/src/shared/ringbuf.c \
> bluez/src/shared/hfp.c \
> bluez/src/shared/io-glib.c \
> + bluez/src/shared/avrcp.c \
> bluez/src/sdpd-database.c \
> bluez/src/sdpd-service.c \
> bluez/src/sdpd-request.c \
> diff --git a/android/Makefile.am b/android/Makefile.am
> index 1913b42..3cc0687 100644
> --- a/android/Makefile.am
> +++ b/android/Makefile.am
> @@ -29,6 +29,7 @@ android_bluetoothd_SOURCES = android/main.c \
> src/shared/mgmt.h src/shared/mgmt.c \
> src/shared/ringbuf.h src/shared/ringbuf.c \
> src/shared/hfp.h src/shared/hfp.c \
> + src/shared/avrcp.h src/shared/avrcp.c \
> android/bluetooth.h android/bluetooth.c \
> android/hidhost.h android/hidhost.c \
> android/ipc.h android/ipc.c \
> diff --git a/android/avrcp.c b/android/avrcp.c
> index b8304f5..65b3417 100644
> --- a/android/avrcp.c
> +++ b/android/avrcp.c
> @@ -32,12 +32,12 @@
> #include "lib/bluetooth.h"
> #include "lib/sdp.h"
> #include "lib/sdp_lib.h"
> +#include "src/shared/avrcp.h"
> #include "src/log.h"
> #include "bluetooth.h"
> #include "avrcp.h"
> #include "hal-msg.h"
> #include "ipc.h"
> -#include "avctp.h"
>
> #define L2CAP_PSM_AVCTP 0x17
>
> @@ -53,7 +53,7 @@ static GIOChannel *server = NULL;
>
> struct avrcp_device {
> bdaddr_t dst;
> - struct avctp *session;
> + struct avrcp *session;
> GIOChannel *io;
> };
>
> @@ -133,7 +133,7 @@ static void avrcp_device_free(void *data)
> struct avrcp_device *dev = data;
>
> if (dev->session)
> - avctp_shutdown(dev->session);
> + avrcp_shutdown(dev->session);
>
> if (dev->io) {
> g_io_channel_shutdown(dev->io, FALSE, NULL);
> @@ -168,6 +168,17 @@ static int device_cmp(gconstpointer s, gconstpointer user_data)
> return bacmp(&dev->dst, dst);
> }
>
> +static struct avrcp_device *avrcp_device_find(const bdaddr_t *dst)
> +{
> + GSList *l;
> +
> + l = g_slist_find_custom(devices, dst, device_cmp);
> + if (!l)
> + return NULL;
> +
> + return l->data;
> +}
> +
> static void disconnect_cb(void *data)
> {
> struct avrcp_device *dev = data;
> @@ -186,7 +197,6 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
> char address[18];
> uint16_t imtu, omtu;
> GError *gerr = NULL;
> - GSList *l;
> int fd;
>
> if (err) {
> @@ -209,9 +219,8 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
>
> ba2str(&dst, address);
>
> - l = g_slist_find_custom(devices, &dst, device_cmp);
> - if (l) {
> - dev = l->data;
> + dev = avrcp_device_find(&dst);
> + if (dev) {
> if (dev->session) {
> error("Unexpected connection");
> return;
> @@ -222,17 +231,17 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
> }
>
> fd = g_io_channel_unix_get_fd(chan);
> - dev->session = avctp_new(fd, imtu, omtu, 0x0100);
>
> + dev->session = avrcp_new(fd, imtu, omtu, 0x0100);
> if (!dev->session) {
> avrcp_device_free(dev);
> return;
> }
>
> - avctp_set_destroy_cb(dev->session, disconnect_cb, dev);
> + avrcp_set_destroy_cb(dev->session, disconnect_cb, dev);
>
> /* FIXME: get the real name of the device */
> - avctp_init_uinput(dev->session, "bluetooth", address);
> + avrcp_init_uinput(dev->session, "bluetooth", address);
>
> g_io_channel_set_close_on_unref(chan, FALSE);
>
> @@ -331,12 +340,10 @@ void bt_avrcp_connect(const bdaddr_t *dst)
> {
> struct avrcp_device *dev;
> char addr[18];
> - GSList *l;
>
> DBG("");
>
> - l = g_slist_find_custom(devices, dst, device_cmp);
> - if (l)
> + if (avrcp_device_find(dst))
> return;
>
> dev = avrcp_device_new(dst);
> @@ -352,18 +359,15 @@ void bt_avrcp_connect(const bdaddr_t *dst)
> void bt_avrcp_disconnect(const bdaddr_t *dst)
> {
> struct avrcp_device *dev;
> - GSList *l;
>
> DBG("");
>
> - l = g_slist_find_custom(devices, dst, device_cmp);
> - if (!l)
> + dev = avrcp_device_find(dst);
> + if (!dev)
> return;
>
> - dev = l->data;
> -
> if (dev->session) {
> - avctp_shutdown(dev->session);
> + avrcp_shutdown(dev->session);
> return;
> }
>
> diff --git a/src/shared/avrcp.c b/src/shared/avrcp.c
> new file mode 100644
> index 0000000..32bd703
> --- /dev/null
> +++ b/src/shared/avrcp.c
> @@ -0,0 +1,75 @@
> +/*
> + *
> + * BlueZ - Bluetooth protocol stack for Linux
> + *
> + * Copyright (C) 2014 Intel Corporation. All rights reserved.
> + *
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> + *
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include <config.h>
> +#endif
> +
> +#include <stdbool.h>
> +#include <glib.h>
> +
> +#include "lib/bluetooth.h"
> +
> +#include "src/log.h"
> +
> +#include "android/avctp.h"
> +#include "avrcp.h"
> +
> +struct avrcp {
> + struct avctp *session;
> +};
> +
> +void avrcp_shutdown(struct avrcp *session)
> +{
> + if (session->session)
> + avctp_shutdown(session->session);
> +
> + g_free(session);
> +}
> +
> +struct avrcp *avrcp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
> +{
> + struct avrcp *session;
> +
> + session = g_new0(struct avrcp, 1);
> +
> + session->session = avctp_new(fd, imtu, omtu, version);
> + if (!session->session) {
> + g_free(session);
> + return NULL;
> + }
> +
> + return session;
> +}
> +
> +void avrcp_set_destroy_cb(struct avrcp *session, avrcp_destroy_cb_t cb,
> + void *user_data)
> +{
> + avctp_set_destroy_cb(session->session, cb, user_data);
> +}
> +
> +int avrcp_init_uinput(struct avrcp *session, const char *name,
> + const char *address)
> +{
> + return avctp_init_uinput(session->session, name, address);
> +}
> diff --git a/android/avrcp.h b/src/shared/avrcp.h
> similarity index 65%
> copy from android/avrcp.h
> copy to src/shared/avrcp.h
> index 1fcd953..7955d56 100644
> --- a/android/avrcp.h
> +++ b/src/shared/avrcp.h
> @@ -2,7 +2,7 @@
> *
> * BlueZ - Bluetooth protocol stack for Linux
> *
> - * Copyright (C) 2013-2014 Intel Corporation. All rights reserved.
> + * Copyright (C) 2014 Intel Corporation. All rights reserved.
> *
> *
> * This library is free software; you can redistribute it and/or
> @@ -21,8 +21,11 @@
> *
> */
>
> -bool bt_avrcp_register(const bdaddr_t *addr);
> -void bt_avrcp_unregister(void);
> +typedef void (*avrcp_destroy_cb_t) (void *user_data);
>
> -void bt_avrcp_connect(const bdaddr_t *dst);
> -void bt_avrcp_disconnect(const bdaddr_t *dst);
> +struct avrcp *avrcp_new(int fd, size_t imtu, size_t omtu, uint16_t version);
> +void avrcp_shutdown(struct avrcp *session);
> +void avrcp_set_destroy_cb(struct avrcp *session, avrcp_destroy_cb_t cb,
> + void *user_data);
> +int avrcp_init_uinput(struct avrcp *session, const char *name,
> + const char *address);
> --
> 1.8.5.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2014-02-18 14:40:34

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ v2 3/4] shared: Move AVDTP implementation

From: Luiz Augusto von Dentz <[email protected]>

This moves AVDTP implementation to shared since it does already contain
some unit tests it can be reused by e.g. audio plugin.
---
Makefile.am | 2 +-
android/Android.mk | 2 +-
android/Makefile.am | 2 +-
android/a2dp.c | 2 +-
{android => src/shared}/avdtp.c | 0
{android => src/shared}/avdtp.h | 0
unit/test-avdtp.c | 2 +-
7 files changed, 5 insertions(+), 5 deletions(-)
rename {android => src/shared}/avdtp.c (100%)
rename {android => src/shared}/avdtp.h (100%)

diff --git a/Makefile.am b/Makefile.am
index ba9e5b3..0697c14 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -272,7 +272,7 @@ unit_tests += unit/test-avdtp
unit_test_avdtp_SOURCES = unit/test-avdtp.c \
src/shared/util.h src/shared/util.c \
src/log.h src/log.c \
- android/avdtp.c android/avdtp.h
+ src/shared/avdtp.c src/shared/avdtp.h
unit_test_avdtp_LDADD = @GLIB_LIBS@

unit_tests += unit/test-avctp
diff --git a/android/Android.mk b/android/Android.mk
index 763056c..5134d81 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -36,7 +36,6 @@ LOCAL_SRC_FILES := \
bluez/android/socket.c \
bluez/android/ipc.c \
bluez/android/audio-ipc.c \
- bluez/android/avdtp.c \
bluez/android/a2dp.c \
bluez/android/avrcp.c \
bluez/android/pan.c \
@@ -48,6 +47,7 @@ LOCAL_SRC_FILES := \
bluez/src/shared/ringbuf.c \
bluez/src/shared/hfp.c \
bluez/src/shared/io-glib.c \
+ bluez/src/shared/avdtp.c \
bluez/src/shared/avctp.c \
bluez/src/shared/avrcp.c \
bluez/src/sdpd-database.c \
diff --git a/android/Makefile.am b/android/Makefile.am
index d1b3119..50b5a3b 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -31,11 +31,11 @@ android_bluetoothd_SOURCES = android/main.c \
src/shared/hfp.h src/shared/hfp.c \
src/shared/avctp.h src/shared/avctp.c \
src/shared/avrcp.h src/shared/avrcp.c \
+ src/shared/avdtp.h src/shared/avdtp.c \
android/bluetooth.h android/bluetooth.c \
android/hidhost.h android/hidhost.c \
android/ipc.h android/ipc.c \
android/audio-ipc.h android/audio-ipc.c \
- android/avdtp.h android/avdtp.c \
android/a2dp.h android/a2dp.c \
android/avrcp.h android/avrcp.c \
android/socket.h android/socket.c \
diff --git a/android/a2dp.c b/android/a2dp.c
index 5d7dc78..f0a28ed 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -39,12 +39,12 @@
#include "lib/sdp_lib.h"
#include "profiles/audio/a2dp-codecs.h"
#include "src/log.h"
+#include "src/shared/avdtp.h"
#include "a2dp.h"
#include "hal-msg.h"
#include "ipc.h"
#include "utils.h"
#include "bluetooth.h"
-#include "avdtp.h"
#include "avrcp.h"
#include "audio-msg.h"
#include "audio-ipc.h"
diff --git a/android/avdtp.c b/src/shared/avdtp.c
similarity index 100%
rename from android/avdtp.c
rename to src/shared/avdtp.c
diff --git a/android/avdtp.h b/src/shared/avdtp.h
similarity index 100%
rename from android/avdtp.h
rename to src/shared/avdtp.h
diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index 8fe5ce3..d8137f2 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -37,7 +37,7 @@

#include "src/shared/util.h"
#include "src/log.h"
-#include "android/avdtp.h"
+#include "src/shared/avdtp.h"

struct test_pdu {
bool valid;
--
1.8.5.3


2014-02-18 14:40:35

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ v2 4/4] build: Move unit tests build rules to Makefile.unit

From: Luiz Augusto von Dentz <[email protected]>

---
Makefile.am | 99 +----------------------------------------------------------
Makefile.unit | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 99 insertions(+), 98 deletions(-)
create mode 100644 Makefile.unit

diff --git a/Makefile.am b/Makefile.am
index 0697c14..9bffa0f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -179,10 +179,10 @@ EXTRA_DIST += src/genbuiltin src/bluetooth.conf \
profiles/input/input.conf profiles/proximity/proximity.conf

test_scripts =
-unit_tests =

include Makefile.tools
include Makefile.obexd
+include Makefile.unit
include android/Makefile.am

if HID2HCI
@@ -224,103 +224,6 @@ AM_CFLAGS += @DBUS_CFLAGS@ @GLIB_CFLAGS@
AM_CPPFLAGS = -I$(builddir)/lib -I$(srcdir)/gdbus


-unit_tests += unit/test-eir unit/test-uuid unit/test-textfile unit/test-crc
-
-unit_test_eir_SOURCES = unit/test-eir.c src/eir.c src/uuid-helper.c
-unit_test_eir_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
-
-unit_test_uuid_SOURCES = unit/test-uuid.c
-unit_test_uuid_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
-
-unit_test_textfile_SOURCES = unit/test-textfile.c src/textfile.h src/textfile.c
-unit_test_textfile_LDADD = @GLIB_LIBS@
-
-unit_test_crc_SOURCES = unit/test-crc.c monitor/crc.h monitor/crc.c
-unit_test_crc_LDADD = @GLIB_LIBS@
-
-unit_tests += unit/test-ringbuf unit/test-queue
-
-unit_test_ringbuf_SOURCES = unit/test-ringbuf.c \
- src/shared/util.h src/shared/util.c \
- src/shared/ringbuf.h src/shared/ringbuf.c
-unit_test_ringbuf_LDADD = @GLIB_LIBS@
-
-unit_test_queue_SOURCES = unit/test-queue.c \
- src/shared/util.h src/shared/util.c \
- src/shared/queue.h src/shared/queue.c
-unit_test_queue_LDADD = @GLIB_LIBS@
-
-unit_tests += unit/test-mgmt
-
-unit_test_mgmt_SOURCES = unit/test-mgmt.c \
- src/shared/io.h src/shared/io-glib.c \
- src/shared/queue.h src/shared/queue.c \
- src/shared/util.h src/shared/util.c \
- src/shared/mgmt.h src/shared/mgmt.c
-unit_test_mgmt_LDADD = @GLIB_LIBS@
-
-unit_tests += unit/test-sdp
-
-unit_test_sdp_SOURCES = unit/test-sdp.c \
- src/shared/util.h src/shared/util.c \
- src/sdpd.h src/sdpd-database.c \
- src/sdpd-service.c src/sdpd-request.c
-unit_test_sdp_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
-
-unit_tests += unit/test-avdtp
-
-unit_test_avdtp_SOURCES = unit/test-avdtp.c \
- src/shared/util.h src/shared/util.c \
- src/log.h src/log.c \
- src/shared/avdtp.c src/shared/avdtp.h
-unit_test_avdtp_LDADD = @GLIB_LIBS@
-
-unit_tests += unit/test-avctp
-
-unit_test_avctp_SOURCES = unit/test-avctp.c \
- src/shared/util.h src/shared/util.c \
- src/log.h src/log.c \
- src/shared/avctp.c src/shared/avctp.h
-unit_test_avctp_LDADD = @GLIB_LIBS@
-
-unit_tests += unit/test-gdbus-client
-
-unit_test_gdbus_client_SOURCES = unit/test-gdbus-client.c
-unit_test_gdbus_client_LDADD = gdbus/libgdbus-internal.la \
- @GLIB_LIBS@ @DBUS_LIBS@
-
-unit_tests += unit/test-gobex-header unit/test-gobex-packet unit/test-gobex \
- unit/test-gobex-transfer unit/test-gobex-apparam
-
-unit_test_gobex_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
- unit/test-gobex.c
-unit_test_gobex_LDADD = @GLIB_LIBS@
-
-unit_test_gobex_packet_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
- unit/test-gobex-packet.c
-unit_test_gobex_packet_LDADD = @GLIB_LIBS@
-
-unit_test_gobex_header_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
- unit/test-gobex-header.c
-unit_test_gobex_header_LDADD = @GLIB_LIBS@
-
-unit_test_gobex_transfer_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
- unit/test-gobex-transfer.c
-unit_test_gobex_transfer_LDADD = @GLIB_LIBS@
-
-unit_test_gobex_apparam_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
- unit/test-gobex-apparam.c
-unit_test_gobex_apparam_LDADD = @GLIB_LIBS@
-
-unit_tests += unit/test-lib
-
-unit_test_lib_SOURCES = unit/test-lib.c
-unit_test_lib_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
-
-noinst_PROGRAMS += $(unit_tests)
-
-TESTS = $(unit_tests)
-
pkgconfigdir = $(libdir)/pkgconfig

if LIBRARY
diff --git a/Makefile.unit b/Makefile.unit
new file mode 100644
index 0000000..1d1893e
--- /dev/null
+++ b/Makefile.unit
@@ -0,0 +1,98 @@
+unit_tests =
+
+unit_tests += unit/test-eir unit/test-uuid unit/test-textfile unit/test-crc
+
+unit_test_eir_SOURCES = unit/test-eir.c src/eir.c src/uuid-helper.c
+unit_test_eir_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
+
+unit_test_uuid_SOURCES = unit/test-uuid.c
+unit_test_uuid_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
+
+unit_test_textfile_SOURCES = unit/test-textfile.c src/textfile.h src/textfile.c
+unit_test_textfile_LDADD = @GLIB_LIBS@
+
+unit_test_crc_SOURCES = unit/test-crc.c monitor/crc.h monitor/crc.c
+unit_test_crc_LDADD = @GLIB_LIBS@
+
+unit_tests += unit/test-ringbuf unit/test-queue
+
+unit_test_ringbuf_SOURCES = unit/test-ringbuf.c \
+ src/shared/util.h src/shared/util.c \
+ src/shared/ringbuf.h src/shared/ringbuf.c
+unit_test_ringbuf_LDADD = @GLIB_LIBS@
+
+unit_test_queue_SOURCES = unit/test-queue.c \
+ src/shared/util.h src/shared/util.c \
+ src/shared/queue.h src/shared/queue.c
+unit_test_queue_LDADD = @GLIB_LIBS@
+
+unit_tests += unit/test-mgmt
+
+unit_test_mgmt_SOURCES = unit/test-mgmt.c \
+ src/shared/io.h src/shared/io-glib.c \
+ src/shared/queue.h src/shared/queue.c \
+ src/shared/util.h src/shared/util.c \
+ src/shared/mgmt.h src/shared/mgmt.c
+unit_test_mgmt_LDADD = @GLIB_LIBS@
+
+unit_tests += unit/test-sdp
+
+unit_test_sdp_SOURCES = unit/test-sdp.c \
+ src/shared/util.h src/shared/util.c \
+ src/sdpd.h src/sdpd-database.c \
+ src/sdpd-service.c src/sdpd-request.c
+unit_test_sdp_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
+
+unit_tests += unit/test-avdtp
+
+unit_test_avdtp_SOURCES = unit/test-avdtp.c \
+ src/shared/util.h src/shared/util.c \
+ src/log.h src/log.c \
+ src/shared/avdtp.c src/shared/avdtp.h
+unit_test_avdtp_LDADD = @GLIB_LIBS@
+
+unit_tests += unit/test-avctp
+
+unit_test_avctp_SOURCES = unit/test-avctp.c \
+ src/shared/util.h src/shared/util.c \
+ src/log.h src/log.c \
+ src/shared/avctp.c src/shared/avctp.h
+unit_test_avctp_LDADD = @GLIB_LIBS@
+
+unit_tests += unit/test-gdbus-client
+
+unit_test_gdbus_client_SOURCES = unit/test-gdbus-client.c
+unit_test_gdbus_client_LDADD = gdbus/libgdbus-internal.la \
+ @GLIB_LIBS@ @DBUS_LIBS@
+
+unit_tests += unit/test-gobex-header unit/test-gobex-packet unit/test-gobex \
+ unit/test-gobex-transfer unit/test-gobex-apparam
+
+unit_test_gobex_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
+ unit/test-gobex.c
+unit_test_gobex_LDADD = @GLIB_LIBS@
+
+unit_test_gobex_packet_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
+ unit/test-gobex-packet.c
+unit_test_gobex_packet_LDADD = @GLIB_LIBS@
+
+unit_test_gobex_header_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
+ unit/test-gobex-header.c
+unit_test_gobex_header_LDADD = @GLIB_LIBS@
+
+unit_test_gobex_transfer_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
+ unit/test-gobex-transfer.c
+unit_test_gobex_transfer_LDADD = @GLIB_LIBS@
+
+unit_test_gobex_apparam_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
+ unit/test-gobex-apparam.c
+unit_test_gobex_apparam_LDADD = @GLIB_LIBS@
+
+unit_tests += unit/test-lib
+
+unit_test_lib_SOURCES = unit/test-lib.c
+unit_test_lib_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
+
+noinst_PROGRAMS += $(unit_tests)
+
+TESTS = $(unit_tests)
--
1.8.5.3


2014-02-18 14:40:33

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ v2 2/4] shared: Move AVCTP implementation

From: Luiz Augusto von Dentz <[email protected]>

This moves AVCTP implementation to shared since it does already contain
some unit tests it can be reused by e.g. audio plugin.
---
Makefile.am | 2 +-
android/Android.mk | 2 +-
android/Makefile.am | 2 +-
{android => src/shared}/avctp.c | 0
{android => src/shared}/avctp.h | 0
src/shared/avrcp.c | 2 +-
unit/test-avctp.c | 2 +-
7 files changed, 5 insertions(+), 5 deletions(-)
rename {android => src/shared}/avctp.c (100%)
rename {android => src/shared}/avctp.h (100%)

diff --git a/Makefile.am b/Makefile.am
index 84dd33b..ba9e5b3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -280,7 +280,7 @@ unit_tests += unit/test-avctp
unit_test_avctp_SOURCES = unit/test-avctp.c \
src/shared/util.h src/shared/util.c \
src/log.h src/log.c \
- android/avctp.c android/avctp.h
+ src/shared/avctp.c src/shared/avctp.h
unit_test_avctp_LDADD = @GLIB_LIBS@

unit_tests += unit/test-gdbus-client
diff --git a/android/Android.mk b/android/Android.mk
index 4f8a17a..763056c 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -38,7 +38,6 @@ LOCAL_SRC_FILES := \
bluez/android/audio-ipc.c \
bluez/android/avdtp.c \
bluez/android/a2dp.c \
- bluez/android/avctp.c \
bluez/android/avrcp.c \
bluez/android/pan.c \
bluez/android/handsfree.c \
@@ -49,6 +48,7 @@ LOCAL_SRC_FILES := \
bluez/src/shared/ringbuf.c \
bluez/src/shared/hfp.c \
bluez/src/shared/io-glib.c \
+ bluez/src/shared/avctp.c \
bluez/src/shared/avrcp.c \
bluez/src/sdpd-database.c \
bluez/src/sdpd-service.c \
diff --git a/android/Makefile.am b/android/Makefile.am
index 3cc0687..d1b3119 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -29,6 +29,7 @@ android_bluetoothd_SOURCES = android/main.c \
src/shared/mgmt.h src/shared/mgmt.c \
src/shared/ringbuf.h src/shared/ringbuf.c \
src/shared/hfp.h src/shared/hfp.c \
+ src/shared/avctp.h src/shared/avctp.c \
src/shared/avrcp.h src/shared/avrcp.c \
android/bluetooth.h android/bluetooth.c \
android/hidhost.h android/hidhost.c \
@@ -36,7 +37,6 @@ android_bluetoothd_SOURCES = android/main.c \
android/audio-ipc.h android/audio-ipc.c \
android/avdtp.h android/avdtp.c \
android/a2dp.h android/a2dp.c \
- android/avctp.h android/avctp.c \
android/avrcp.h android/avrcp.c \
android/socket.h android/socket.c \
android/pan.h android/pan.c \
diff --git a/android/avctp.c b/src/shared/avctp.c
similarity index 100%
rename from android/avctp.c
rename to src/shared/avctp.c
diff --git a/android/avctp.h b/src/shared/avctp.h
similarity index 100%
rename from android/avctp.h
rename to src/shared/avctp.h
diff --git a/src/shared/avrcp.c b/src/shared/avrcp.c
index 32bd703..1325284 100644
--- a/src/shared/avrcp.c
+++ b/src/shared/avrcp.c
@@ -32,7 +32,7 @@

#include "src/log.h"

-#include "android/avctp.h"
+#include "avctp.h"
#include "avrcp.h"

struct avrcp {
diff --git a/unit/test-avctp.c b/unit/test-avctp.c
index be1dfd7..83bf2c5 100644
--- a/unit/test-avctp.c
+++ b/unit/test-avctp.c
@@ -38,7 +38,7 @@
#include "src/shared/util.h"
#include "src/log.h"

-#include "android/avctp.h"
+#include "src/shared/avctp.h"

struct test_pdu {
bool valid;
--
1.8.5.3