From c872f00508ce4afe3b8ec863b23595c31fd8b4be Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Mon, 31 Mar 2014 17:35:28 +0200 Subject: Use libav/ffmpeg for audio decoding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libav 9.12 and ffmpeg 2.2 have been tested. Here’s why: My mp4 “parser” *cough* never was a mp4 parser in the sense that it actually understood the file format. Instead it grepped the input stream for “magic” strings (section identifiers). That alone should be sufficient to throw away the code and rewrite it. Additionally libfaad2 has not been updated for ages. I guess it was abandoned in favor of libav/ffmpeg. With libav/ffmpeg, which we support both as long as the API’s don’t diverge too much, pianobar gains fast and reliable AAC and MP3 decoding without bothering too much about the details. Most users will have it installed already. On my own machine libav consumes about 2/3 CPU time compared to the previous solution when playing AAC. Unfortunately memory usage doubled and my attempts to disable unused protocols/formats/codec failed due to libav’s API limitations. While cleaning up a small detail regarding the eventcmd API has changed too: Song duration and position are measured in seconds instead of milliseconds now. Since libav/ffmpeg keeps track of accurate timing the precision pianobar keeps track of can be reduced, while still being sufficient for most users. --- Makefile | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 2867da1..2267419 100644 --- a/Makefile +++ b/Makefile @@ -73,22 +73,8 @@ LIBWAITRESS_INCLUDE:=${LIBWAITRESS_DIR} LIBWAITRESS_TEST_SRC=${LIBWAITRESS_DIR}/waitress-test.c LIBWAITRESS_TEST_OBJ:=${LIBWAITRESS_TEST_SRC:.c=.o} -ifeq (${DISABLE_FAAD}, 1) - LIBFAAD_CFLAGS:= - LIBFAAD_LDFLAGS:= -else - LIBFAAD_CFLAGS:=-DENABLE_FAAD - LIBFAAD_LDFLAGS:=-lfaad -endif - -ifeq (${DISABLE_MAD}, 1) - LIBMAD_CFLAGS:= - LIBMAD_LDFLAGS:= -else - LIBMAD_CFLAGS:=-DENABLE_MAD - LIBMAD_CFLAGS+=$(shell pkg-config --cflags mad) - LIBMAD_LDFLAGS:=$(shell pkg-config --libs mad) -endif +LIBAV_CFLAGS=$(shell pkg-config --cflags libavcodec libavformat libavutil libavfilter) +LIBAV_LDFLAGS=$(shell pkg-config --libs libavcodec libavformat libavutil libavfilter) LIBGNUTLS_CFLAGS:=$(shell pkg-config --cflags gnutls) LIBGNUTLS_LDFLAGS:=$(shell pkg-config --libs gnutls) @@ -104,15 +90,14 @@ ifeq (${DYNLINK},1) pianobar: ${PIANOBAR_OBJ} ${PIANOBAR_HDR} libpiano.so.0 @echo " LINK $@" @${CC} -o $@ ${PIANOBAR_OBJ} ${LDFLAGS} -lao -lpthread -lm -L. -lpiano \ - ${LIBFAAD_LDFLAGS} ${LIBMAD_LDFLAGS} ${LIBGNUTLS_LDFLAGS} \ - ${LIBGCRYPT_LDFLAGS} + ${LIBAV_LDFLAGS} ${LIBGNUTLS_LDFLAGS} ${LIBGCRYPT_LDFLAGS} else pianobar: ${PIANOBAR_OBJ} ${PIANOBAR_HDR} ${LIBPIANO_OBJ} ${LIBWAITRESS_OBJ} \ ${LIBWAITRESS_HDR} @echo " LINK $@" @${CC} ${CFLAGS} ${LDFLAGS} ${PIANOBAR_OBJ} ${LIBPIANO_OBJ} \ ${LIBWAITRESS_OBJ} -lao -lpthread -lm \ - ${LIBFAAD_LDFLAGS} ${LIBMAD_LDFLAGS} ${LIBGNUTLS_LDFLAGS} \ + ${LIBAV_LDFLAGS} ${LIBGNUTLS_LDFLAGS} \ ${LIBGCRYPT_LDFLAGS} ${LIBJSONC_LDFLAGS} -o $@ endif @@ -134,7 +119,7 @@ libpiano.so.0: ${LIBPIANO_RELOBJ} ${LIBPIANO_HDR} ${LIBWAITRESS_RELOBJ} \ %.d: %.c @set -e; rm -f $@; \ $(CC) -M ${CFLAGS} -I ${LIBPIANO_INCLUDE} -I ${LIBWAITRESS_INCLUDE} \ - ${LIBFAAD_CFLAGS} ${LIBMAD_CFLAGS} ${LIBGNUTLS_CFLAGS} \ + ${LIBAV_CFLAGS} ${LIBGNUTLS_CFLAGS} \ ${LIBGCRYPT_CFLAGS} ${LIBJSONC_CFLAGS} $< > $@.$$$$; \ sed '1 s,^.*\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \ rm -f $@.$$$$ @@ -147,7 +132,7 @@ libpiano.so.0: ${LIBPIANO_RELOBJ} ${LIBPIANO_HDR} ${LIBWAITRESS_RELOBJ} \ %.o: %.c @echo " CC $<" @${CC} ${CFLAGS} -I ${LIBPIANO_INCLUDE} -I ${LIBWAITRESS_INCLUDE} \ - ${LIBFAAD_CFLAGS} ${LIBMAD_CFLAGS} ${LIBGNUTLS_CFLAGS} \ + ${LIBAV_CFLAGS} ${LIBGNUTLS_CFLAGS} \ ${LIBGCRYPT_CFLAGS} ${LIBJSONC_CFLAGS} -c -o $@ $< # create position independent code (for shared libraries) @@ -168,10 +153,9 @@ all: pianobar debug: pianobar debug: CC=clang -debug: CFLAGS=-Wall -Wextra \ +debug: CFLAGS=-g -Wall -Wextra \ -pedantic \ -Wno-unused-parameter \ - -fsanitize=address \ -fsanitize=integer \ -fsanitize=undefined \ -fsanitize=alignment \ -- cgit v1.2.3