From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Sun, 22 May 2022 15:22:23 +0000 (+0100) Subject: Check for the appropriate AAC decoder at startup and in the help section. X-Git-Tag: 4.1-rc1~24^2~202 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed629037d478d0e4cd3eb316758e7adf6b0bb943;p=thirdparty%2Fshairport-sync.git Check for the appropriate AAC decoder at startup and in the help section. --- diff --git a/shairport.c b/shairport.c index 60b9c4bf..60b4b8e3 100644 --- a/shairport.c +++ b/shairport.c @@ -48,6 +48,7 @@ #include #include #include +#include #endif #ifdef CONFIG_MBEDTLS @@ -144,6 +145,25 @@ void print_version(void) { debug(1, "Can't print version string!"); } } + +#ifdef CONFIG_AIRPLAY_2 +int has_fplt_capable_aac_decoder(void) { + // return 1 if the AAC decoder advertises ftlp decoding capability, which + // is needed for decoding Buffered Audio streams + int has_capability = 0; + const AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_AAC); + if (codec != NULL) { + AVCodecContext *codec_context = avcodec_alloc_context3(codec); + if (codec_context != NULL) { + if (codec_context->sample_fmt == AV_SAMPLE_FMT_FLTP) + has_capability = 1; + av_free(codec_context); + } + } + return has_capability; +} +#endif + #ifdef CONFIG_SOXR pthread_t soxr_time_check_thread; void *soxr_time_check(__attribute__((unused)) void *arg) { @@ -229,6 +249,13 @@ void *soxr_time_check(__attribute__((unused)) void *arg) { #endif void usage(char *progname) { +#ifdef CONFIG_AIRPLAY_2 + if (has_fplt_capable_aac_decoder() == 0) { + printf("IMPORTANT NOTE: Shairport Sync will not run on this system.\n"); + printf("A Floating Point Planar (\"fplt\") AAC decoder is required,\n"); + printf("but the system's ffmpeg library does not contain one.\n\n"); + } +#endif printf("Usage: %s [options...]\n", progname); printf(" or: %s [options...] -- [audio output-specific options]\n", progname); printf("\n"); @@ -1657,7 +1684,7 @@ int main(int argc, char **argv) { #endif emergency_exit = 0; // what to do or skip in the exit_function atexit(exit_function); - + // set defaults // get a device id -- the first non-local MAC address @@ -1914,6 +1941,10 @@ int main(int argc, char **argv) { #endif #ifdef CONFIG_AIRPLAY_2 + if (has_fplt_capable_aac_decoder() == 0) { + die("Shairport Sync will not run on this system. A Floating Point Planar (\"fplt\") AAC decoder is required, but the system's ffmpeg library does not contain one."); + } + uint64_t apf = config.airplay_features; uint64_t apfh = config.airplay_features; apfh = apfh >> 32;