summaryrefslogtreecommitdiffstats
path: root/ATTIC/meta-audio-4a-framework/recipes-connectivity
diff options
context:
space:
mode:
Diffstat (limited to 'ATTIC/meta-audio-4a-framework/recipes-connectivity')
-rw-r--r--ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0001-build-and-link-with-a-shared-library.patch853
-rw-r--r--ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0002-log-add-calling-function-name.patch26
-rw-r--r--ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0003-dbus-request-a-name-on-startup.patch153
-rw-r--r--ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0004-bluealsa-pcm-bump-the-trigger-after-pcm-prepare.patch35
-rw-r--r--ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa_git.bbappend19
5 files changed, 1086 insertions, 0 deletions
diff --git a/ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0001-build-and-link-with-a-shared-library.patch b/ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0001-build-and-link-with-a-shared-library.patch
new file mode 100644
index 00000000..53ee3ad0
--- /dev/null
+++ b/ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0001-build-and-link-with-a-shared-library.patch
@@ -0,0 +1,853 @@
+From 7625b67a687b7a365d9d758a86ed05e84b2b3a61 Mon Sep 17 00:00:00 2001
+From: Thierry Bultel <thierry.bultel@iot.bzh>
+Date: Mon, 3 Dec 2018 14:29:07 +0100
+Subject: [PATCH 1/3] build and link with a shared library
+
+Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
+---
+ configure.ac | 4 +-
+ includes/bluealsa/bluealsa.h | 21 ++++++
+ {src/shared => includes/bluealsa}/ctl-client.h | 2 +-
+ {src/shared => includes/bluealsa}/ctl-proto.h | 0
+ {src/shared => includes/bluealsa}/defs.h | 0
+ {src/shared => includes/bluealsa}/ffb.h | 0
+ {src/shared => includes/bluealsa}/log.h | 0
+ {src/shared => includes/bluealsa}/rt.h | 0
+ src/Makefile.am | 11 ++-
+ src/asound/Makefile.am | 15 ++--
+ src/asound/bluealsa-ctl.c | 6 +-
+ src/asound/bluealsa-pcm.c | 10 +--
+ src/at.c | 4 +-
+ src/bluealsa.h | 2 +-
+ src/bluealsalib/Makefile.am | 50 ++++++++++++++
+ src/bluealsalib/bluealsa.pc.in | 12 ++++
+ src/bluez-a2dp.c | 2 +-
+ src/bluez.c | 2 +-
+ src/ctl.c | 4 +-
+ src/ctl.h | 2 +-
+ src/io.c | 8 +--
+ src/main.c | 4 +-
+ src/ofono.c | 2 +-
+ src/rfcomm.c | 4 +-
+ src/shared/ctl-client.c | 4 +-
+ src/shared/ffb.c | 2 +-
+ src/shared/log.c | 4 +-
+ src/shared/rt.c | 2 +-
+ src/transport.c | 2 +-
+ src/utils.c | 2 +-
+ test/Makefile.am | 10 ++-
+ test/server-mock.c | 3 -
+ test/test-at.c | 1 -
+ test/test-bluealsalib.c | 96 ++++++++++++++++++++++++++
+ test/test-io.c | 3 -
+ test/test-utils.c | 8 +--
+ utils/Makefile.am | 11 ++-
+ utils/aplay.c | 8 +--
+ utils/rfcomm.c | 4 +-
+ 39 files changed, 252 insertions(+), 73 deletions(-)
+ create mode 100644 includes/bluealsa/bluealsa.h
+ rename {src/shared => includes/bluealsa}/ctl-client.h (98%)
+ rename {src/shared => includes/bluealsa}/ctl-proto.h (100%)
+ rename {src/shared => includes/bluealsa}/defs.h (100%)
+ rename {src/shared => includes/bluealsa}/ffb.h (100%)
+ rename {src/shared => includes/bluealsa}/log.h (100%)
+ rename {src/shared => includes/bluealsa}/rt.h (100%)
+ create mode 100644 src/bluealsalib/Makefile.am
+ create mode 100644 src/bluealsalib/bluealsa.pc.in
+ create mode 100644 test/test-bluealsalib.c
+
+diff --git a/configure.ac b/configure.ac
+index 0bb9452..6323d60 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -152,8 +152,10 @@ AC_CONFIG_FILES([
+ Makefile
+ src/Makefile
+ src/asound/Makefile
++ src/bluealsalib/Makefile
+ utils/Makefile
+- test/Makefile])
++ test/Makefile
++ src/bluealsalib/bluealsa.pc])
+ AC_OUTPUT
+
+ # warn user that alsa-lib thread-safety makes troubles
+diff --git a/includes/bluealsa/bluealsa.h b/includes/bluealsa/bluealsa.h
+new file mode 100644
+index 0000000..062856a
+--- /dev/null
++++ b/includes/bluealsa/bluealsa.h
+@@ -0,0 +1,21 @@
++/*
++ * BlueALSA - bluealsa.h
++ * Copyright (c) 2018 Thierry Bultel
++ *
++ * This file is a part of bluez-alsa.
++ *
++ * This project is licensed under the terms of the MIT license.
++ *
++ */
++
++#ifndef BLUEALSA_H
++#define BLUEALSA_H
++
++#include <bluealsa/ctl-client.h>
++#include <bluealsa/defs.h>
++
++typedef int (*transport_update_cb) (struct ba_msg_transport *transports);
++
++extern int bluelsa_register_transport_update_cb(const char * interfance, transport_update_cb cb);
++
++#endif
+diff --git a/src/shared/ctl-client.h b/includes/bluealsa/ctl-client.h
+similarity index 98%
+rename from src/shared/ctl-client.h
+rename to includes/bluealsa/ctl-client.h
+index 3dc93a6..b8af154 100644
+--- a/src/shared/ctl-client.h
++++ b/includes/bluealsa/ctl-client.h
+@@ -12,7 +12,7 @@
+ #define BLUEALSA_SHARED_CTLCLIENT_H_
+
+ #include <stdbool.h>
+-#include "shared/ctl-proto.h"
++#include <bluealsa/ctl-proto.h>
+
+ int bluealsa_open(const char *interface);
+
+diff --git a/src/shared/ctl-proto.h b/includes/bluealsa/ctl-proto.h
+similarity index 100%
+rename from src/shared/ctl-proto.h
+rename to includes/bluealsa/ctl-proto.h
+diff --git a/src/shared/defs.h b/includes/bluealsa/defs.h
+similarity index 100%
+rename from src/shared/defs.h
+rename to includes/bluealsa/defs.h
+diff --git a/src/shared/ffb.h b/includes/bluealsa/ffb.h
+similarity index 100%
+rename from src/shared/ffb.h
+rename to includes/bluealsa/ffb.h
+diff --git a/src/shared/log.h b/includes/bluealsa/log.h
+similarity index 100%
+rename from src/shared/log.h
+rename to includes/bluealsa/log.h
+diff --git a/src/shared/rt.h b/includes/bluealsa/rt.h
+similarity index 100%
+rename from src/shared/rt.h
+rename to includes/bluealsa/rt.h
+diff --git a/src/Makefile.am b/src/Makefile.am
+index fb1241d..5626ae5 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -2,12 +2,9 @@
+ # Copyright (c) 2016-2018 Arkadiusz Bokowy
+
+ bin_PROGRAMS = bluealsa
+-SUBDIRS = asound
++SUBDIRS = bluealsalib asound
+
+ bluealsa_SOURCES = \
+- shared/ffb.c \
+- shared/log.c \
+- shared/rt.c \
+ at.c \
+ bluealsa.c \
+ bluez.c \
+@@ -34,7 +31,8 @@ AM_CFLAGS = \
+ @APTX_CFLAGS@ \
+ @LDAC_CFLAGS@ \
+ @LDAC_ABR_CFLAGS@ \
+- @SBC_CFLAGS@
++ @SBC_CFLAGS@ \
++ -I$(top_srcdir)/includes
+
+ LDADD = \
+ @BLUEZ_LIBS@ \
+@@ -44,4 +42,5 @@ LDADD = \
+ @APTX_LIBS@ \
+ @LDAC_LIBS@ \
+ @LDAC_ABR_LIBS@ \
+- @SBC_LIBS@
++ @SBC_LIBS@ \
++ bluealsalib/libbluealsa.la
+diff --git a/src/asound/Makefile.am b/src/asound/Makefile.am
+index 923d884..24618f1 100644
+--- a/src/asound/Makefile.am
++++ b/src/asound/Makefile.am
+@@ -5,32 +5,35 @@ EXTRA_DIST = 20-bluealsa.conf
+
+ asound_module_ctl_LTLIBRARIES = libasound_module_ctl_bluealsa.la
+ asound_module_pcm_LTLIBRARIES = libasound_module_pcm_bluealsa.la
++
+ asound_module_conf_DATA = 20-bluealsa.conf
+
+ libasound_module_ctl_bluealsa_la_SOURCES = \
+- ../shared/ctl-client.c \
+- ../shared/log.c \
+ bluealsa-ctl.c
++
+ libasound_module_pcm_bluealsa_la_SOURCES = \
+- ../shared/ctl-client.c \
+- ../shared/log.c \
+- ../shared/rt.c \
+ bluealsa-pcm.c
+
+ asound_module_ctldir = @ALSA_PLUGIN_DIR@
+ asound_module_pcmdir = @ALSA_PLUGIN_DIR@
++
+ asound_module_confdir = @ALSA_CONF_DIR@
+
+ AM_CFLAGS = \
+ -I$(top_srcdir)/src \
++ -I$(top_srcdir)/includes \
+ @ALSA_CFLAGS@ \
+ @BLUEZ_CFLAGS@ \
+ @GLIB2_CFLAGS@
+
+-AM_LDFLAGS = -module -avoid-version
++AM_LDFLAGS = \
++ -module \
++ -avoid-version \
++ ../bluealsalib/libbluealsa.la
+
+ libasound_module_ctl_bluealsa_la_LIBADD = \
+ @ALSA_LIBS@
++
+ libasound_module_pcm_bluealsa_la_LIBADD = \
+ @ALSA_LIBS@ \
+ @BLUEZ_LIBS@
+diff --git a/src/asound/bluealsa-ctl.c b/src/asound/bluealsa-ctl.c
+index f4a0181..1b9d124 100644
+--- a/src/asound/bluealsa-ctl.c
++++ b/src/asound/bluealsa-ctl.c
+@@ -19,9 +19,9 @@
+ #include <alsa/asoundlib.h>
+ #include <alsa/control_external.h>
+
+-#include "shared/ctl-client.h"
+-#include "shared/ctl-proto.h"
+-#include "shared/log.h"
++#include <bluealsa/ctl-client.h>
++#include <bluealsa/ctl-proto.h>
++#include <bluealsa/log.h>
+
+
+ enum ctl_elem_type {
+diff --git a/src/asound/bluealsa-pcm.c b/src/asound/bluealsa-pcm.c
+index 258aebd..42cb61d 100644
+--- a/src/asound/bluealsa-pcm.c
++++ b/src/asound/bluealsa-pcm.c
+@@ -23,11 +23,11 @@
+ #include <alsa/asoundlib.h>
+ #include <alsa/pcm_external.h>
+
+-#include "shared/ctl-client.h"
+-#include "shared/ctl-proto.h"
+-#include "shared/defs.h"
+-#include "shared/log.h"
+-#include "shared/rt.h"
++#include <bluealsa/ctl-client.h>
++#include <bluealsa/ctl-proto.h>
++#include <bluealsa/defs.h>
++#include <bluealsa/log.h>
++#include <bluealsa/rt.h>
+
+
+ struct bluealsa_pcm {
+diff --git a/src/at.c b/src/at.c
+index e3d1703..bda2255 100644
+--- a/src/at.c
++++ b/src/at.c
+@@ -16,8 +16,8 @@
+ #include <stdio.h>
+ #include <string.h>
+
+-#include "shared/defs.h"
+-#include "shared/log.h"
++#include <bluealsa/defs.h>
++#include <bluealsa/log.h>
+
+
+ /**
+diff --git a/src/bluealsa.h b/src/bluealsa.h
+index 7968ba9..7eee34f 100644
+--- a/src/bluealsa.h
++++ b/src/bluealsa.h
+@@ -27,7 +27,7 @@
+ #include "bluez.h"
+ #include "bluez-a2dp.h"
+ #include "transport.h"
+-#include "shared/ctl-proto.h"
++#include <bluealsa/ctl-proto.h>
+
+ struct ba_config {
+
+diff --git a/src/bluealsalib/Makefile.am b/src/bluealsalib/Makefile.am
+new file mode 100644
+index 0000000..11d9e00
+--- /dev/null
++++ b/src/bluealsalib/Makefile.am
+@@ -0,0 +1,50 @@
++# BlueALSA - Makefile.am
++# Copyright (c) 2018 Thiery Bultel (thierry.bultel@iot.bzh)
++
++bluealsalib_LTLIBRARIES = libbluealsa.la
++
++libbluealsa_la_SOURCES = \
++ ../shared/ctl-client.c \
++ ../shared/ffb.c \
++ ../shared/log.c \
++ ../shared/rt.c
++
++EXTRA_DIST=bluealsa.pc.in
++
++pkgconfigdir = $(libdir)/pkgconfig
++pkgconfig_DATA = bluealsa.pc
++
++AM_CFLAGS = \
++ -I$(top_srcdir)/src \
++ -I$(top_srcdir)/includes \
++ @ALSA_CFLAGS@ \
++ @BLUEZ_CFLAGS@ \
++ @GLIB2_CFLAGS@
++
++libbluealsa_la_LIBADD = \
++ @ALSA_LIBS@ \
++ @BLUEZ_LIBS@
++
++libbluealsa_la_LDFLAGS = \
++ $(AM_LDFLAGS) \
++ -version-info 1:0:0
++
++bluealsalibdir = $(libdir)
++
++# install path for published headers
++bluealsalibincludedir=$(includedir)/bluealsa
++
++bluealsalib_headers_dir=../../includes/bluealsa
++
++bluealsalib_headers = \
++ $(bluealsalib_headers_dir)/bluealsa.h \
++ $(bluealsalib_headers_dir)/ctl-client.h \
++ $(bluealsalib_headers_dir)/ctl-proto.h \
++ $(bluealsalib_headers_dir)/defs.h \
++ $(bluealsalib_headers_dir)/ffb.h \
++ $(bluealsalib_headers_dir)/log.h \
++ $(bluealsalib_headers_dir)/rt.h
++
++libbluealsa_la_SOURCES += $(bluealsalib_headers)
++
++bluealsalibinclude_HEADERS = $(bluealsalib_headers)
+diff --git a/src/bluealsalib/bluealsa.pc.in b/src/bluealsalib/bluealsa.pc.in
+new file mode 100644
+index 0000000..93c3c4a
+--- /dev/null
++++ b/src/bluealsalib/bluealsa.pc.in
+@@ -0,0 +1,12 @@
++prefix=@prefix@
++exec_prefix=@exec_prefix@
++libdir=@libdir@
++includedir=@includedir@
++
++Name: alsa
++Description: Bluez-Alsa - Library
++Version: @VERSION@
++Requires:
++Libs: -L${libdir} -lbluealsa
++#Libs.private: @ALSA_DEPLIBS@
++Cflags: -I${includedir}/bluealsa
+diff --git a/src/bluez-a2dp.c b/src/bluez-a2dp.c
+index 5f81e6e..4c7b07b 100644
+--- a/src/bluez-a2dp.c
++++ b/src/bluez-a2dp.c
+@@ -13,7 +13,7 @@
+ #endif
+
+ #include "bluez-a2dp.h"
+-#include "shared/defs.h"
++#include <bluealsa/defs.h>
+
+ static const a2dp_sbc_t a2dp_sbc = {
+ .frequency =
+diff --git a/src/bluez.c b/src/bluez.c
+index 537f0fe..591fdce 100644
+--- a/src/bluez.c
++++ b/src/bluez.c
+@@ -24,7 +24,7 @@
+ #include "ctl.h"
+ #include "transport.h"
+ #include "utils.h"
+-#include "shared/log.h"
++#include <bluealsa/log.h>
+
+
+ /**
+diff --git a/src/ctl.c b/src/ctl.c
+index ae2b812..dd3ab45 100644
+--- a/src/ctl.c
++++ b/src/ctl.c
+@@ -32,8 +32,8 @@
+ #include "hfp.h"
+ #include "transport.h"
+ #include "utils.h"
+-#include "shared/defs.h"
+-#include "shared/log.h"
++#include <bluealsa/defs.h>
++#include <bluealsa/log.h>
+
+ /* Special PCM type for internal usage only. */
+ #define BA_PCM_TYPE_RFCOMM 0x1F
+diff --git a/src/ctl.h b/src/ctl.h
+index 0e3c46b..593a9fd 100644
+--- a/src/ctl.h
++++ b/src/ctl.h
+@@ -11,7 +11,7 @@
+ #ifndef BLUEALSA_CTL_H_
+ #define BLUEALSA_CTL_H_
+
+-#include "shared/ctl-proto.h"
++#include <bluealsa/ctl-proto.h>
+
+ /* Indexes of special file descriptors in the poll array. */
+ #define CTL_IDX_SRV 0
+diff --git a/src/io.c b/src/io.c
+index b3d7ac9..f81eeb0 100644
+--- a/src/io.c
++++ b/src/io.c
+@@ -44,10 +44,10 @@
+ #include "bluealsa.h"
+ #include "transport.h"
+ #include "utils.h"
+-#include "shared/defs.h"
+-#include "shared/ffb.h"
+-#include "shared/log.h"
+-#include "shared/rt.h"
++#include <bluealsa/defs.h>
++#include <bluealsa/ffb.h>
++#include <bluealsa/log.h>
++#include <bluealsa/rt.h>
+
+
+ /**
+diff --git a/src/main.c b/src/main.c
+index 35e6702..9cef402 100644
+--- a/src/main.c
++++ b/src/main.c
+@@ -37,8 +37,8 @@
+ #endif
+ #include "transport.h"
+ #include "utils.h"
+-#include "shared/defs.h"
+-#include "shared/log.h"
++#include <bluealsa/defs.h>
++#include <bluealsa/log.h>
+
+
+ static char *get_a2dp_codecs(
+diff --git a/src/ofono.c b/src/ofono.c
+index 902d099..bfd4e39 100644
+--- a/src/ofono.c
++++ b/src/ofono.c
+@@ -27,7 +27,7 @@
+ #include "ctl.h"
+ #include "ofono-iface.h"
+ #include "transport.h"
+-#include "shared/log.h"
++#include <bluealsa/log.h>
+
+ #define OFONO_FAKE_DEV_ID 0xffff
+
+diff --git a/src/rfcomm.c b/src/rfcomm.c
+index a86ae61..2d76725 100644
+--- a/src/rfcomm.c
++++ b/src/rfcomm.c
+@@ -17,11 +17,11 @@
+ #include <string.h>
+ #include <unistd.h>
+
++#include <bluealsa/defs.h>
+ #include "bluealsa.h"
+ #include "ctl.h"
+ #include "utils.h"
+-#include "shared/defs.h"
+-#include "shared/log.h"
++#include <bluealsa/log.h>
+
+
+ /**
+diff --git a/src/shared/ctl-client.c b/src/shared/ctl-client.c
+index 6cf9402..2da9a54 100644
+--- a/src/shared/ctl-client.c
++++ b/src/shared/ctl-client.c
+@@ -8,7 +8,7 @@
+ *
+ */
+
+-#include "shared/ctl-client.h"
++#include <bluealsa/ctl-client.h>
+
+ #include <errno.h>
+ #include <fcntl.h>
+@@ -19,7 +19,7 @@
+ #include <sys/types.h>
+ #include <sys/un.h>
+
+-#include "shared/log.h"
++#include <bluealsa/log.h>
+
+
+ /**
+diff --git a/src/shared/ffb.c b/src/shared/ffb.c
+index b31d7d1..ab50f4a 100644
+--- a/src/shared/ffb.c
++++ b/src/shared/ffb.c
+@@ -8,7 +8,7 @@
+ *
+ */
+
+-#include "shared/ffb.h"
++#include "../../includes/bluealsa/ffb.h"
+
+
+ /**
+diff --git a/src/shared/log.c b/src/shared/log.c
+index 65f0fea..884540c 100644
+--- a/src/shared/log.c
++++ b/src/shared/log.c
+@@ -8,7 +8,7 @@
+ *
+ */
+
+-#include "shared/log.h"
++#include <bluealsa/log.h>
+
+ #include <pthread.h>
+ #include <stdarg.h>
+@@ -17,7 +17,7 @@
+ #include <string.h>
+ #include <syslog.h>
+
+-#include "shared/rt.h"
++#include <bluealsa/rt.h>
+
+
+ /* internal logging identifier */
+diff --git a/src/shared/rt.c b/src/shared/rt.c
+index edcbebc..40bd721 100644
+--- a/src/shared/rt.c
++++ b/src/shared/rt.c
+@@ -8,7 +8,7 @@
+ *
+ */
+
+-#include "shared/rt.h"
++#include <bluealsa/rt.h>
+
+ #include <stdlib.h>
+
+diff --git a/src/transport.c b/src/transport.c
+index 7253925..1617dd1 100644
+--- a/src/transport.c
++++ b/src/transport.c
+@@ -34,7 +34,7 @@
+ #include "io.h"
+ #include "rfcomm.h"
+ #include "utils.h"
+-#include "shared/log.h"
++#include <bluealsa/log.h>
+
+
+ static const char *transport_type_to_string(enum ba_transport_type type) {
+diff --git a/src/utils.c b/src/utils.c
+index 70d069e..27459d2 100644
+--- a/src/utils.c
++++ b/src/utils.c
+@@ -24,7 +24,7 @@
+
+ #include "a2dp-codecs.h"
+ #include "bluez.h"
+-#include "shared/log.h"
++#include <bluealsa/log.h>
+
+
+ /**
+diff --git a/test/Makefile.am b/test/Makefile.am
+index 104dc63..8f7b2eb 100644
+--- a/test/Makefile.am
++++ b/test/Makefile.am
+@@ -6,7 +6,8 @@ TESTS = \
+ test-ctl \
+ test-io \
+ test-pcm \
+- test-utils
++ test-utils \
++ test-bluealsalib
+
+ check_PROGRAMS = \
+ server-mock \
+@@ -14,7 +15,8 @@ check_PROGRAMS = \
+ test-ctl \
+ test-io \
+ test-pcm \
+- test-utils
++ test-utils \
++ test-bluealsalib
+
+ check_LTLIBRARIES = \
+ aloader.la
+@@ -25,6 +27,7 @@ aloader_la_LDFLAGS = \
+
+ AM_CFLAGS = \
+ -I$(top_srcdir)/src \
++ -I$(top_srcdir)/includes \
+ @AAC_CFLAGS@ \
+ @ALSA_CFLAGS@ \
+ @APTX_CFLAGS@ \
+@@ -46,4 +49,5 @@ LDADD = \
+ @GLIB2_LIBS@ \
+ @LDAC_ABR_LIBS@ \
+ @LDAC_LIBS@ \
+- @SBC_LIBS@
++ @SBC_LIBS@ \
++ ../src/bluealsalib/libbluealsa.la
+diff --git a/test/server-mock.c b/test/server-mock.c
+index 8c3a90e..c88fa35 100644
+--- a/test/server-mock.c
++++ b/test/server-mock.c
+@@ -31,9 +31,6 @@
+ #include "../src/rfcomm.c"
+ #include "../src/transport.c"
+ #include "../src/utils.c"
+-#include "../src/shared/ffb.c"
+-#include "../src/shared/log.c"
+-#include "../src/shared/rt.c"
+
+ static const a2dp_sbc_t cconfig = {
+ .frequency = SBC_SAMPLING_FREQ_44100,
+diff --git a/test/test-at.c b/test/test-at.c
+index 8cff264..a847c22 100644
+--- a/test/test-at.c
++++ b/test/test-at.c
+@@ -11,7 +11,6 @@
+ #include <check.h>
+
+ #include "../src/at.c"
+-#include "../src/shared/log.c"
+
+ START_TEST(test_at_build) {
+
+diff --git a/test/test-bluealsalib.c b/test/test-bluealsalib.c
+new file mode 100644
+index 0000000..d5fa3ff
+--- /dev/null
++++ b/test/test-bluealsalib.c
+@@ -0,0 +1,96 @@
++/*
++ * test-bluealsalib.c
++ * Copyright (c) 2018 Thierry Bultel
++ *
++ * This file is a part of bluez-alsa.
++ *
++ * This project is licensed under the terms of the MIT license.
++ *
++ */
++
++// TODO monitor all available interfaces
++const char * ba_interface = "hci0";
++
++#include <bluealsa/bluealsa.h>
++#include <bluealsa/log.h>
++#include <pthread.h>
++#include <errno.h>
++#include <poll.h>
++
++
++static void * monitor_thread_entry(void* arg) {
++ debug("...");
++
++ int ba_fd, ba_event_fd;
++ enum ba_event transport_mask = BA_EVENT_TRANSPORT_ADDED | BA_EVENT_TRANSPORT_CHANGED|BA_EVENT_TRANSPORT_REMOVED;
++
++ if ((ba_fd = bluealsa_open(ba_interface)) == -1) {
++ error("BlueALSA connection failed: %s", strerror(errno));
++ goto fail;
++ }
++
++ if ((ba_event_fd = bluealsa_open(ba_interface)) == -1) {
++ error("BlueALSA connection failed: %s", strerror(errno));
++ goto fail;
++ }
++
++ if (bluealsa_subscribe(ba_event_fd, transport_mask) == -1) {
++ error("BlueALSA subscription failed: %s", strerror(errno));
++ goto fail;
++ }
++
++goto init;
++
++ while (true) {
++
++ struct ba_msg_event event;
++ struct ba_msg_transport *transports;
++ ssize_t ret;
++ size_t i;
++
++ struct pollfd pfds[] = {{ ba_event_fd, POLLIN, 0 }};
++ if (poll(pfds, ARRAYSIZE(pfds), -1) == -1 && errno == EINTR)
++ continue;
++
++ while ((ret = recv(ba_event_fd, &event, sizeof(event), MSG_DONTWAIT)) == -1 && errno == EINTR)
++ continue;
++ if (ret != sizeof(event)) {
++ error("Couldn't read event: %s", strerror(ret == -1 ? errno : EBADMSG));
++ goto fail;
++ }
++
++init:
++ debug("Fetching available transports");
++ if ((ret = bluealsa_get_transports(ba_fd, &transports)) == -1) {
++ error("Couldn't get transports: %s", strerror(errno));
++ goto fail;
++ }
++
++ debug("Got %d transports", ret);
++
++ for (int ix=0; ix<ret; ix++) {
++ char addr[18];
++ struct ba_msg_transport * transport = &transports[ix];
++ ba2str(&transport->addr, addr);
++ info("Transport %d: type %d, dev %s", ix, transport->type, addr);
++ }
++
++ }
++
++fail:
++ info("exit");
++ return NULL;
++}
++
++int main(int argc, char * argv[]) {
++ printf("%s... !\n", argv[0]);
++
++ pthread_t monitor;
++ if (pthread_create(&monitor, NULL, monitor_thread_entry, NULL) == -1) {
++ debug("failed to create the monitor thread");
++ goto fail;
++ }
++ pthread_join(monitor, NULL);
++fail:
++ return 0;
++}
+diff --git a/test/test-io.c b/test/test-io.c
+index d913d2f..8ebb1d8 100644
+--- a/test/test-io.c
++++ b/test/test-io.c
+@@ -21,9 +21,6 @@
+ #include "../src/rfcomm.c"
+ #include "../src/transport.c"
+ #include "../src/utils.c"
+-#include "../src/shared/ffb.c"
+-#include "../src/shared/log.c"
+-#include "../src/shared/rt.c"
+
+ static const a2dp_sbc_t config_sbc_44100_stereo = {
+ .frequency = SBC_SAMPLING_FREQ_44100,
+diff --git a/test/test-utils.c b/test/test-utils.c
+index b704b42..46475f1 100644
+--- a/test/test-utils.c
++++ b/test/test-utils.c
+@@ -10,11 +10,11 @@
+
+ #include <check.h>
+
++#include <bluealsa/defs.h>
++#include <bluealsa/ffb.h>
++#include <bluealsa/rt.h>
++
+ #include "../src/utils.c"
+-#include "../src/shared/defs.h"
+-#include "../src/shared/ffb.c"
+-#include "../src/shared/log.c"
+-#include "../src/shared/rt.c"
+
+ START_TEST(test_dbus_profile_object_path) {
+
+diff --git a/utils/Makefile.am b/utils/Makefile.am
+index 256689a..a6d132c 100644
+--- a/utils/Makefile.am
++++ b/utils/Makefile.am
+@@ -6,32 +6,31 @@ bin_PROGRAMS =
+ if ENABLE_APLAY
+ bin_PROGRAMS += bluealsa-aplay
+ bluealsa_aplay_SOURCES = \
+- ../src/shared/ctl-client.c \
+- ../src/shared/ffb.c \
+- ../src/shared/log.c \
+ aplay.c
+ bluealsa_aplay_CFLAGS = \
+ -I$(top_srcdir)/src \
++ -I$(top_srcdir)/includes \
+ @ALSA_CFLAGS@ \
+ @BLUEZ_CFLAGS@ \
+ @GIO2_CFLAGS@
+ bluealsa_aplay_LDADD = \
+ @ALSA_LIBS@ \
+ @BLUEZ_LIBS@ \
+- @GIO2_LIBS@
++ @GIO2_LIBS@ \
++ ../src/bluealsalib/libbluealsa.la
+ endif
+
+ if ENABLE_RFCOMM
+ bin_PROGRAMS += bluealsa-rfcomm
+ bluealsa_rfcomm_SOURCES = \
+- ../src/shared/ctl-client.c \
+- ../src/shared/log.c \
+ rfcomm.c
+ bluealsa_rfcomm_CFLAGS = \
+ -I$(top_srcdir)/src \
++ -I$(top_srcdir)/includes \
+ @BLUEZ_CFLAGS@
+ bluealsa_rfcomm_LDADD = \
+ @BLUEZ_LIBS@ \
++ ../src/bluealsalib/libbluealsa.la \
+ -lreadline
+ endif
+
+diff --git a/utils/aplay.c b/utils/aplay.c
+index f792ce6..4b1372e 100644
+--- a/utils/aplay.c
++++ b/utils/aplay.c
+@@ -25,10 +25,10 @@
+ #include <alsa/asoundlib.h>
+ #include <gio/gio.h>
+
+-#include "shared/ctl-client.h"
+-#include "shared/defs.h"
+-#include "shared/ffb.h"
+-#include "shared/log.h"
++#include <bluealsa/ctl-client.h>
++#include <bluealsa/defs.h>
++#include <bluealsa/ffb.h>
++#include <bluealsa/log.h>
+
+ struct pcm_worker {
+ struct ba_msg_transport transport;
+diff --git a/utils/rfcomm.c b/utils/rfcomm.c
+index cc31f46..38e3b30 100644
+--- a/utils/rfcomm.c
++++ b/utils/rfcomm.c
+@@ -24,8 +24,8 @@
+ #include <readline/readline.h>
+ #include <readline/history.h>
+
+-#include "shared/ctl-client.h"
+-#include "shared/log.h"
++#include <bluealsa/ctl-client.h>
++#include <bluealsa/log.h>
+
+ static char *strtrim(char *str) {
+ while (isspace(*str))
+--
+2.16.4
+
diff --git a/ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0002-log-add-calling-function-name.patch b/ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0002-log-add-calling-function-name.patch
new file mode 100644
index 00000000..8ed7e0b6
--- /dev/null
+++ b/ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0002-log-add-calling-function-name.patch
@@ -0,0 +1,26 @@
+From 3a7400da79678e749381306e33163ca2c005cb3b Mon Sep 17 00:00:00 2001
+From: Thierry Bultel <thierry.bultel@iot.bzh>
+Date: Mon, 3 Dec 2018 14:31:31 +0100
+Subject: [PATCH 2/3] log: add calling function name
+
+Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
+---
+ includes/bluealsa/log.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/includes/bluealsa/log.h b/includes/bluealsa/log.h
+index 39663fb..6d4cec3 100644
+--- a/includes/bluealsa/log.h
++++ b/includes/bluealsa/log.h
+@@ -31,7 +31,7 @@ void info(const char *format, ...) __attribute__ ((format(printf, 1, 2)));
+
+ #if DEBUG
+ void _debug(const char *format, ...) __attribute__ ((format(printf, 1, 2)));
+-# define debug(M, ARGS ...) _debug("%s:%d: " M, __FILE__, __LINE__, ## ARGS)
++# define debug(M, ARGS ...) _debug("%s:%d:%s: " M, __FILE__, __LINE__,__func__, ## ARGS)
+ #else
+ # define debug(M, ARGS ...) do {} while (0)
+ #endif
+--
+2.16.4
+
diff --git a/ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0003-dbus-request-a-name-on-startup.patch b/ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0003-dbus-request-a-name-on-startup.patch
new file mode 100644
index 00000000..1ef59296
--- /dev/null
+++ b/ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0003-dbus-request-a-name-on-startup.patch
@@ -0,0 +1,153 @@
+From 4c14fffbd20a6dd9e6ceca1eb1726ceaafab7410 Mon Sep 17 00:00:00 2001
+From: Thierry Bultel <thierry.bultel@iot.bzh>
+Date: Fri, 18 Jan 2019 11:45:29 +0100
+Subject: [PATCH 3/3] dbus: request a name on startup
+
+When the service thread is ready, ask a name to dbus
+The advantage of doing that is that client applications
+can check dbus for bluez-alsa presence, without having
+to implement any kinf of polling logic. Also, this
+way, they can be notified on the service exit, to
+perform any needed cleanup.
+Since there must be an instance of bluealsa daemon
+per hci device, the dbus name will be
+'org.bluez-alsa.hci0', 'org.bluez-alsa.hci1' ...
+and so on.
+
+Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
+---
+ configure.ac | 10 ++++++++++
+ src/Makefile.am | 3 +++
+ src/bluez-alsa.conf | 14 ++++++++++++++
+ src/main.c | 32 ++++++++++++++++++++++++++++++++
+ 4 files changed, 59 insertions(+)
+ create mode 100644 src/bluez-alsa.conf
+
+diff --git a/configure.ac b/configure.ac
+index 6323d60..d4ec7d4 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -130,6 +130,16 @@ AC_ARG_WITH([alsaconfdir],
+ [alsaconfdir="$sysconfdir/alsa/conf.d"],
+ [alsaconfdir="$datadir/alsa/alsa.conf.d"])])
+
++AC_ARG_WITH(dbusconfdir, AC_HELP_STRING([--with-dbusconfdir=PATH],
++ [path to D-Bus config directory]), [path_dbusconf=${withval}],
++ [path_dbusconf="`$PKG_CONFIG --variable=sysconfdir dbus-1`"])
++if (test -z "${path_dbusconf}"); then
++ DBUS_CONFDIR="${sysconfdir}/dbus-1/system.d"
++else
++ DBUS_CONFDIR="${path_dbusconf}/dbus-1/system.d"
++fi
++AC_SUBST(DBUS_CONFDIR)
++
+ test "x$prefix" = xNONE && prefix=$ac_default_prefix
+ test "x$exec_prefix" = xNONE && exec_prefix=$prefix
+
+diff --git a/src/Makefile.am b/src/Makefile.am
+index 5626ae5..c501f2e 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -23,6 +23,9 @@ bluealsa_SOURCES += \
+ ofono-iface.c
+ endif
+
++dbusconfdir = @DBUS_CONFDIR@
++dist_dbusconf_DATA = bluez-alsa.conf
++
+ AM_CFLAGS = \
+ @BLUEZ_CFLAGS@ \
+ @GLIB2_CFLAGS@ \
+diff --git a/src/bluez-alsa.conf b/src/bluez-alsa.conf
+new file mode 100644
+index 0000000..6b999d6
+--- /dev/null
++++ b/src/bluez-alsa.conf
+@@ -0,0 +1,14 @@
++<!-- This configuration file specifies the required security policies
++ for bluez-alsa core daemon to work. -->
++
++<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
++ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
++<busconfig>
++
++ <!-- ../system.conf have denied everything, so we just punch some holes -->
++
++ <policy user="root">
++ <allow own_prefix="org.bluez-alsa"/>
++ </policy>
++
++</busconfig>
+diff --git a/src/main.c b/src/main.c
+index 9cef402..9183978 100644
+--- a/src/main.c
++++ b/src/main.c
+@@ -12,6 +12,7 @@
+ # include "config.h"
+ #endif
+
++#define _GNU_SOURCE
+ #include <errno.h>
+ #include <getopt.h>
+ #include <signal.h>
+@@ -58,6 +59,20 @@ static char *get_a2dp_codecs(
+ return g_strjoinv(", ", (char **)tmp);
+ }
+
++static void name_acquired_handler(
++ GDBusConnection *connection,
++ const gchar *name,
++ gpointer user_data) {
++ debug("Acquired name: %s", name);
++}
++
++static void name_lost_handler(
++ GDBusConnection *connection,
++ const gchar *name,
++ gpointer user_data) {
++ debug("Lost name: %s", name);
++}
++
+ static GMainLoop *loop = NULL;
+ static void main_loop_stop(int sig) {
+ /* Call to this handler restores the default action, so on the
+@@ -318,6 +333,7 @@ int main(int argc, char **argv) {
+ GError *err;
+
+ err = NULL;
++
+ address = g_dbus_address_get_for_bus_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
+ if ((config.dbus = g_dbus_connection_new_for_address_sync(address,
+ G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
+@@ -336,6 +352,19 @@ int main(int argc, char **argv) {
+ ofono_register();
+ #endif
+
++ char * name_on_bus = NULL;
++ asprintf(&name_on_bus, "org.bluez-alsa.%s", config.hci_dev.name);
++
++ guint g_dbusid;
++ g_dbusid = g_bus_own_name_on_connection(config.dbus,
++ name_on_bus,
++ G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
++ G_BUS_NAME_OWNER_FLAGS_REPLACE,
++ name_acquired_handler,
++ name_lost_handler,
++ NULL,
++ NULL);
++
+ /* In order to receive EPIPE while writing to the pipe whose reading end
+ * is closed, the SIGPIPE signal has to be handled. For more information
+ * see the io_thread_write_pcm() function. */
+@@ -359,5 +388,8 @@ int main(int argc, char **argv) {
+ bluealsa_ctl_free();
+ bluealsa_config_free();
+
++ g_bus_unown_name (g_dbusid);
++ free(name_on_bus);
++
+ return EXIT_SUCCESS;
+ }
+--
+2.16.4
+
diff --git a/ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0004-bluealsa-pcm-bump-the-trigger-after-pcm-prepare.patch b/ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0004-bluealsa-pcm-bump-the-trigger-after-pcm-prepare.patch
new file mode 100644
index 00000000..7befe733
--- /dev/null
+++ b/ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa/0004-bluealsa-pcm-bump-the-trigger-after-pcm-prepare.patch
@@ -0,0 +1,35 @@
+From ba292e82928a6a0ea663039ba2d5c030c4cfa80d Mon Sep 17 00:00:00 2001
+From: Thierry Bultel <thierry.bultel@iot.bzh>
+Date: Fri, 8 Feb 2019 10:21:55 +0100
+Subject: [PATCH] bluealsa-pcm: bump the trigger after pcm prepare
+
+When a sound application recovers from a EPIPE by calling
+snd_pcm_prepare, and goes immediately after to a call to poll,
+it would be stuck forever unless the internal event trigger
+is bumped.
+
+Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
+---
+ src/asound/bluealsa-pcm.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/src/asound/bluealsa-pcm.c b/src/asound/bluealsa-pcm.c
+index 42cb61d..4ccbf0d 100644
+--- a/src/asound/bluealsa-pcm.c
++++ b/src/asound/bluealsa-pcm.c
+@@ -351,6 +351,12 @@ static int bluealsa_prepare(snd_pcm_ioplug_t *io) {
+ pcm->io_ptr = 0;
+
+ debug("Prepared: %d", pcm->fd);
++
++ /* When the sound application calls poll just after snd_pcm_prepare,
++ * it would block forever unless the internal trigger is bumped
++ * */
++ eventfd_write(pcm->event_fd, 1);
++
+ return 0;
+ }
+
+--
+2.16.4
+
diff --git a/ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa_git.bbappend b/ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa_git.bbappend
new file mode 100644
index 00000000..ece43824
--- /dev/null
+++ b/ATTIC/meta-audio-4a-framework/recipes-connectivity/bluez-alsa/bluez-alsa_git.bbappend
@@ -0,0 +1,19 @@
+# This brings some mandatory patches for the softmixer and hal-manager.
+#
+# - patch 1 makes a communication library for hal-manager to get
+# the list of audio transports from bluez-alsa
+# - patch 2 makes the "debug" macro always display the caller name
+# - patch 3 asks dbus for a name like 'org.bluez-alsa.hciX' where hciX
+# - patch 4 is a bug fix
+# name of the HCI interface that the bluealsa daemon instance is handling
+#
+# Notice that patch 2 will very likely be replaced by a full dbus interface
+# in the future.
+#
+
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI += "file://0001-build-and-link-with-a-shared-library.patch"
+SRC_URI += "file://0002-log-add-calling-function-name.patch"
+SRC_URI += "file://0003-dbus-request-a-name-on-startup.patch"
+SRC_URI += "file://0004-bluealsa-pcm-bump-the-trigger-after-pcm-prepare.patch"