Skip to content

Commit

Permalink
Add support for LC3plus A2DP source and sink
Browse files Browse the repository at this point in the history
Closes #479
  • Loading branch information
arkq committed Jan 29, 2022
1 parent 0c9d8c1 commit 8e2f953
Show file tree
Hide file tree
Showing 26 changed files with 975 additions and 10 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ unreleased
==========

- optional support for A2DP FastStream codec (music & voice)
- optional support for A2DP LC3plus codec (music & voice)
- enable/disable BT profiles/codecs via command line options
- allow to select BT transport codec with ALSA configuration
- allow to set PCM volume properties with ALSA configuration
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Dependencies:
- [fdk-aac](https://github.com/mstorsjo/fdk-aac) (when AAC support is enabled with `--enable-aac`)
- [openaptx](https://github.com/Arkq/openaptx) (when apt-X support is enabled with
`--enable-aptx` and/or `--enable-aptx-hd`)
- [lc3plus](https://www.iis.fraunhofer.de/en/ff/amm/communication/lc3.html) (when LC3plus support is
enabled with `--enable-lc3plus`)
- [libopenaptx](https://github.com/pali/libopenaptx) (when apt-X support is enabled and
`--with-libopenaptx` is used)
- [libldac](https://github.com/EHfive/ldacBT) (when LDAC support is enabled with `--enable-ldac`)
Expand Down
11 changes: 11 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ AM_COND_IF([ENABLE_FASTSTREAM], [
AC_DEFINE([ENABLE_FASTSTREAM], [1], [Define to 1 if FastStream is enabled.])
])

AC_ARG_ENABLE([lc3plus],
[AS_HELP_STRING([--enable-lc3plus], [enable LC3plus support])])
AM_CONDITIONAL([ENABLE_LC3PLUS], [test "x$enable_lc3plus" = "xyes"])
AM_COND_IF([ENABLE_LC3PLUS], [
AC_CHECK_HEADERS([lc3.h],
[], [AC_MSG_ERROR([LC3plus header file not found])])
AC_CHECK_LIB([LC3plus], [lc3plus_version],
[AC_SUBST([LC3PLUS_LIBS], [-lLC3plus])], [AC_MSG_ERROR([LC3plus library not found])])
AC_DEFINE([ENABLE_LC3PLUS], [1], [Define to 1 if LC3plus is enabled.])
])

AC_ARG_ENABLE([ldac],
[AS_HELP_STRING([--enable-ldac], [enable LDAC support])])
AM_CONDITIONAL([ENABLE_LDAC], [test "x$enable_ldac" = "xyes"])
Expand Down
4 changes: 4 additions & 0 deletions doc/bluealsa.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ OPTIONS
will be used.
Used AAC configuration depends on a remote Bluetooth device capabilities.

--lc3plus-bitrate=BPS
Set LC3plus encoder bit rate for constant bit rate mode (CBR) as *BPS*.
Default value is **264000** bits per second.

--ldac-abr
Enables LDAC adaptive bit rate, which will dynamically adjust encoder quality
based on the connection stability.
Expand Down
6 changes: 6 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ bluealsa_SOURCES += \
a2dp-faststream.c
endif

if ENABLE_LC3PLUS
bluealsa_SOURCES += \
a2dp-lc3plus.c
endif

if ENABLE_LDAC
bluealsa_SOURCES += \
a2dp-ldac.c
Expand Down Expand Up @@ -111,6 +116,7 @@ LDADD = \
@BLUEZ_LIBS@ \
@GIO2_LIBS@ \
@GLIB2_LIBS@ \
@LC3PLUS_LIBS@ \
@LDAC_ABR_LIBS@ \
@LDAC_DEC_LIBS@ \
@LDAC_ENC_LIBS@ \
Expand Down
8 changes: 4 additions & 4 deletions src/a2dp-aac.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,15 +367,15 @@ static void *a2dp_aac_enc_thread(struct ba_transport_thread *th) {
goto fail;
}

/* account written payload only */
/* resend RTP header */
len -= RTP_HEADER_LEN;

/* break if the last part of the payload has been written */
/* break if there is no more payload data */
if ((payload_len -= len) == 0)
break;

/* move rest of data to the beginning of the payload */
debug("Payload fragmentation: extra %zd bytes", payload_len);
/* move the rest of data to the beginning of payload */
debug("AAC payload fragmentation: extra %zu bytes", payload_len);
memmove(rtp_payload, rtp_payload + len, payload_len);

}
Expand Down
Loading

0 comments on commit 8e2f953

Please sign in to comment.