diff --git a/configure.ac b/configure.ac index 0ebd9b050..2400a619f 100644 --- a/configure.ac +++ b/configure.ac @@ -422,9 +422,9 @@ AC_SUBST([SYSTEMD_SYSTEM_UNIT_DIR], [$systemdsystemunitdir]) AC_ARG_WITH([systemdbluealsadargs], AS_HELP_STRING([--with-systemdbluealsadargs=ARGS], [bluealsad arguments to be used in - bluealsa.service, defaults to '-S -p a2dp-source -p a2dp-sink' if not specified]), + bluealsa.service, defaults to '-S -p a2dp-source -p a2dp-sink --all-codecs' if not specified]), [systemdbluealsadargs="${withval}"], - [systemdbluealsadargs="-S -p a2dp-source -p a2dp-sink"]) + [systemdbluealsadargs="-S -p a2dp-source -p a2dp-sink --all-codecs"]) AC_SUBST([SYSTEMD_BLUEALSAD_ARGS], [$systemdbluealsadargs]) AC_ARG_WITH([systemdbluealsaaplayargs], diff --git a/doc/bluealsad.8.rst b/doc/bluealsad.8.rst index 47089fdfe..7532d0db9 100644 --- a/doc/bluealsad.8.rst +++ b/doc/bluealsad.8.rst @@ -6,7 +6,7 @@ bluealsad Bluetooth Audio ALSA Backend ---------------------------- -:Date: August 2024 +:Date: December 2024 :Manual section: 8 :Manual group: System Manager's Manual :Version: $VERSION$ @@ -90,6 +90,15 @@ OPTIONS For the list of supported audio codecs see the "Available BT audio codecs" section of the **bluealsad** command-line help message. +--all-codecs + Enable all available Bluetooth audio codecs. + This option is equivalent to enabling all available audio codecs by + specifying them with the ``--codec`` option. + + After enabling all available codecs, it is still possible to disable some + of them by using the ``--codec`` option with the **-** prefix. However, the + ``--codec`` option(s) must be specified after the ``--all-codecs`` option. + --initial-volume=NUM Set the initial volume to *NUM* % when a device is first connected. *NUM* must be an integer in the range from **0** to **100**. diff --git a/src/main.c b/src/main.c index add20e79c..408b4ebf0 100644 --- a/src/main.c +++ b/src/main.c @@ -154,8 +154,8 @@ static void g_bus_name_lost(GDBusConnection *conn, const char *name, void *userd int main(int argc, char **argv) { int opt; - const char *opts = "hVSB:i:p:c:"; - const struct option longopts[] = { + static const char *opts = "hVSB:i:p:c:"; + static const struct option longopts[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, { "syslog", no_argument, NULL, 'S' }, @@ -164,6 +164,7 @@ int main(int argc, char **argv) { { "device", required_argument, NULL, 'i' }, { "profile", required_argument, NULL, 'p' }, { "codec", required_argument, NULL, 'c' }, + { "all-codecs", no_argument, NULL, 25 }, { "initial-volume", required_argument, NULL, 17 }, { "keep-alive", required_argument, NULL, 8 }, { "io-rt-priority", required_argument, NULL, 3 }, @@ -200,6 +201,19 @@ int main(int argc, char **argv) { { 0, 0, 0, 0 }, }; + static const struct { + uint32_t codec_id; + bool *ptr; + } hfp_codecs[] = { + { HFP_CODEC_CVSD, &config.hfp.codecs.cvsd }, +#if ENABLE_MSBC + { HFP_CODEC_MSBC, &config.hfp.codecs.msbc }, +#endif +#if ENABLE_LC3_SWB + { HFP_CODEC_LC3_SWB, &config.hfp.codecs.lc3_swb }, +#endif + }; + bool syslog = false; char dbus_service[32] = BLUEALSA_SERVICE; @@ -221,6 +235,7 @@ int main(int argc, char **argv) { " -i, --device=hciX\t\tHCI device(s) to use\n" " -p, --profile=NAME\t\tset enabled BT profiles\n" " -c, --codec=NAME\t\tset enabled BT audio codecs\n" + " --all-codecs\t\t\tenable all available BT audio codecs\n" " --initial-volume=NUM\t\tinitial volume level [0-100]\n" " --keep-alive=SEC\t\tkeep Bluetooth transport alive\n" " --io-rt-priority=NUM\t\treal-time priority for IO threads\n" @@ -375,19 +390,6 @@ int main(int argc, char **argv) { case 'c' /* --codec=NAME */ : { - static const struct { - uint32_t codec_id; - bool *ptr; - } hfp_codecs[] = { - { HFP_CODEC_CVSD, &config.hfp.codecs.cvsd }, -#if ENABLE_MSBC - { HFP_CODEC_MSBC, &config.hfp.codecs.msbc }, -#endif -#if ENABLE_LC3_SWB - { HFP_CODEC_LC3_SWB, &config.hfp.codecs.lc3_swb }, -#endif - }; - bool enable = true; bool matched = false; if (optarg[0] == '+' || optarg[0] == '-') { @@ -418,6 +420,15 @@ int main(int argc, char **argv) { break; } + case 25 /* --all-codecs */ : { + struct a2dp_sep * const * seps = a2dp_seps; + for (struct a2dp_sep *sep = *seps; sep != NULL; sep = *++seps) + sep->enabled = true; + for (size_t i = 0; i < ARRAYSIZE(hfp_codecs); i++) + *hfp_codecs[i].ptr = true; + break; + } + case 17 /* --initial-volume=NUM */ : { unsigned int vol = atoi(optarg); if (vol > 100) {