squeezelite: Import new package

Signed-off-by: Ted Hess <thess@kitschensync.net>
This commit is contained in:
Ted Hess
2015-07-17 12:12:18 -04:00
parent 957d75cd2f
commit 12fbef0412
8 changed files with 580 additions and 0 deletions
@@ -0,0 +1,56 @@
From 1c53ed7db5b49ebf347efe65dbf9b740f9d54557 Mon Sep 17 00:00:00 2001
From: Carlo Landmeter <clandmeter@gmail.com>
Date: Tue, 31 Mar 2015 09:52:53 +0000
Subject: [PATCH] respect LDFLAGS
---
Makefile | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
# Cross compile support - create a Makefile which defines these three variables and then includes this Makefile...
-CFLAGS ?= -Wall -fPIC -O2 $(OPTS)
-LDFLAGS ?= -lasound -lpthread -lm -lrt
+CFLAGS ?= -Wall -O2
+CFLAGS += -fPIC $(OPTS)
+LIBS ?= -lasound -lpthread -lm -lrt
EXECUTABLE ?= squeezelite
# passing one or more of these in $(OPTS) enables optional feature inclusion
@@ -52,20 +53,20 @@ endif
# add optional link options
ifneq (,$(findstring $(OPT_LINKALL), $(CFLAGS)))
- LDFLAGS += $(LINKALL)
+ LIBS += $(LINKALL)
ifneq (,$(findstring $(OPT_FF), $(CFLAGS)))
- LDFLAGS += $(LINKALL_FF)
+ LIBS += $(LINKALL_FF)
endif
ifneq (,$(findstring $(OPT_RESAMPLE), $(CFLAGS)))
- LDFLAGS += $(LINKALL_RESAMPLE)
+ LIBS += $(LINKALL_RESAMPLE)
endif
ifneq (,$(findstring $(OPT_IR), $(CFLAGS)))
- LDFLAGS += $(LINKALL_IR)
+ LIBS += $(LINKALL_IR)
endif
else
# if not LINKALL and linux add LINK_LINUX
ifeq ($(UNAME), Linux)
- LDFLAGS += $(LINK_LINUX)
+ LIBS += $(LINK_LINUX)
endif
endif
@@ -74,7 +75,7 @@ OBJECTS = $(SOURCES:.c=.o)
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
- $(CC) $(OBJECTS) $(LDFLAGS) -o $@
+ $(CC) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@
$(OBJECTS): $(DEPS)
@@ -0,0 +1,30 @@
--- a/main.c
+++ b/main.c
@@ -187,6 +187,17 @@ static void sighandler(int signum) {
signal(signum, SIG_DFL);
}
+// Waits for nonzero MAC
+static void get_nonzero_mac(u8_t mac[], u32_t timeout_ms) {
+ u32_t wait_timeout = gettime_ms() + timeout_ms;
+ do{
+ get_mac(mac);
+ if ((mac[0]+mac[1]+mac[2]+mac[3]+mac[4]+mac[5]) != 0) {
+ break;
+ }
+ }while(wait_timeout > gettime_ms());
+}
+
int main(int argc, char **argv) {
char *server = NULL;
char *output_device = "default";
@@ -240,7 +251,8 @@ int main(int argc, char **argv) {
#define MAXCMDLINE 512
char cmdline[MAXCMDLINE] = "";
- get_mac(mac);
+ // Waits for nonzero MAC
+ get_nonzero_mac(mac,10000);
for (i = 0; i < argc && (strlen(argv[i]) + strlen(cmdline) + 2 < MAXCMDLINE); i++) {
strcat(cmdline, argv[i]);
@@ -0,0 +1,83 @@
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@ OPT_IR = -DIR
SOURCES = \
main.c slimproto.c buffer.c stream.c utils.c \
output.c output_alsa.c output_pa.c output_stdout.c output_pack.c decode.c \
- flac.c pcm.c mad.c vorbis.c faad.c mpg.c
+ flac.c pcm.c mad.c vorbis.c faad.c
SOURCES_DSD = dsd.c dop.c dsd2pcm/dsd2pcm.c
SOURCES_FF = ffmpeg.c
@@ -25,7 +25,7 @@ SOURCES_IR = ir.c
LINK_LINUX = -ldl
-LINKALL = -lFLAC -lmad -lvorbisfile -lfaad -lmpg123
+LINKALL = -lFLAC -lmad -lvorbisfile -lfaad
LINKALL_FF = -lavcodec -lavformat -lavutil
LINKALL_RESAMPLE = -lsoxr
LINKALL_IR = -llirc_client
--- a/decode.c
+++ b/decode.c
@@ -146,8 +146,8 @@ void decode_init(log_level level, const
// try mad then mpg for mp3 unless command line option passed
if (!(strstr(exclude_codecs, "mp3") || strstr(exclude_codecs, "mad")) &&
(!include_codecs || strstr(include_codecs, "mp3") || strstr(include_codecs, "mad"))) codecs[i] = register_mad();
- if (!(strstr(exclude_codecs, "mp3") || strstr(exclude_codecs, "mpg")) && !codecs[i] &&
- (!include_codecs || strstr(include_codecs, "mp3") || strstr(include_codecs, "mpg"))) codecs[i] = register_mpg();
+// if (!(strstr(exclude_codecs, "mp3") || strstr(exclude_codecs, "mpg")) && !codecs[i] &&
+// (!include_codecs || strstr(include_codecs, "mp3") || strstr(include_codecs, "mpg"))) codecs[i] = register_mpg();
mutex_create(decode.mutex);
--- a/main.c
+++ b/main.c
@@ -35,7 +35,8 @@
#else
#define CODECS_DSD ""
#endif
-#define CODECS_MP3 " (mad,mpg for specific mp3 codec)"
+//#define CODECS_MP3 " (mad,mpg for specific mp3 codec)"
+#define CODECS_MP3 " (mad for specific mp3 codec)"
#define CODECS CODECS_BASE CODECS_FF CODECS_DSD CODECS_MP3
--- a/squeezelite.h
+++ b/squeezelite.h
@@ -140,7 +140,7 @@
#if LINUX
#define LIBFLAC "libFLAC.so.8"
#define LIBMAD "libmad.so.0"
-#define LIBMPG "libmpg123.so.0"
+//#define LIBMPG "libmpg123.so.0"
#define LIBVORBIS "libvorbisfile.so.3"
#define LIBTREMOR "libvorbisidec.so.1"
#define LIBFAAD "libfaad.so.2"
@@ -154,7 +154,7 @@
#if OSX
#define LIBFLAC "libFLAC.8.dylib"
#define LIBMAD "libmad.0.dylib"
-#define LIBMPG "libmpg123.0.dylib"
+//#define LIBMPG "libmpg123.0.dylib"
#define LIBVORBIS "libvorbisfile.3.dylib"
#define LIBTREMOR "libvorbisidec.1.dylib"
#define LIBFAAD "libfaad.2.dylib"
@@ -167,7 +167,7 @@
#if WIN
#define LIBFLAC "libFLAC.dll"
#define LIBMAD "libmad-0.dll"
-#define LIBMPG "libmpg123-0.dll"
+//#define LIBMPG "libmpg123-0.dll"
#define LIBVORBIS "libvorbisfile.dll"
#define LIBTREMOR "libvorbisidec.dll"
#define LIBFAAD "libfaad2.dll"
@@ -180,7 +180,7 @@
#if FREEBSD
#define LIBFLAC "libFLAC.so.11"
#define LIBMAD "libmad.so.2"
-#define LIBMPG "libmpg123.so.0"
+//#define LIBMPG "libmpg123.so.0"
#define LIBVORBIS "libvorbisfile.so.6"
#define LIBTREMOR "libvorbisidec.so.1"
#define LIBFAAD "libfaad.so.2"
@@ -0,0 +1,14 @@
--- a/output_alsa.c
+++ b/output_alsa.c
@@ -862,8 +862,11 @@ void output_init_alsa(log_level level, c
LOG_INFO("memory locked");
}
+#ifdef M_TRIM_THRESHOLD
+ // mallopt is not defined in musl libc
mallopt(M_TRIM_THRESHOLD, -1);
mallopt(M_MMAP_MAX, 0);
+#endif
touch_memory(silencebuf, MAX_SILENCE_FRAMES * BYTES_PER_FRAME);
touch_memory(outputbuf->buf, outputbuf->size);
@@ -0,0 +1,105 @@
--- a/faad.c
+++ b/faad.c
@@ -593,6 +593,8 @@ static bool load_faad() {
return false;
}
+ err = dlerror(); // Reset previous dynamic linking error string (if there was)
+
a->NeAACDecGetCurrentConfiguration = dlsym(handle, "NeAACDecGetCurrentConfiguration");
a->NeAACDecSetConfiguration = dlsym(handle, "NeAACDecSetConfiguration");
a->NeAACDecOpen = dlsym(handle, "NeAACDecOpen");
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -590,6 +590,8 @@ static bool load_ff() {
return false;
}
+ err = dlerror(); // Reset previous dynamic linking error string (if there was)
+
sprintf(name, LIBAVFORMAT, LIBAVFORMAT_VERSION_MAJOR);
handle_format = dlopen(name, RTLD_NOW);
if (!handle_format) {
--- a/flac.c
+++ b/flac.c
@@ -241,6 +241,8 @@ static bool load_flac() {
return false;
}
+ err = dlerror(); // Reset previous dynamic linking error string (if there was)
+
f->FLAC__StreamDecoderErrorStatusString = dlsym(handle, "FLAC__StreamDecoderErrorStatusString");
f->FLAC__StreamDecoderStateString = dlsym(handle, "FLAC__StreamDecoderStateString");
f->FLAC__stream_decoder_new = dlsym(handle, "FLAC__stream_decoder_new");
--- a/ir.c
+++ b/ir.c
@@ -167,10 +167,10 @@ static void *ir_thread() {
UNLOCK_I;
wake_controller();
}
-
+
free(code);
}
-
+
return 0;
}
@@ -184,6 +184,8 @@ static bool load_lirc() {
return false;
}
+ err = dlerror(); // Reset previous dynamic linking error string (if there was)
+
i->lirc_init = dlsym(handle, "lirc_init");
i->lirc_deinit = dlsym(handle, "lirc_deinit");
i->lirc_readconfig = dlsym(handle, "lirc_readconfig");
--- a/mad.c
+++ b/mad.c
@@ -364,7 +364,9 @@ static bool load_mad() {
LOG_INFO("dlerror: %s", dlerror());
return false;
}
-
+
+ err = dlerror(); // Reset previous dynamic linking error string (if there was)
+
m->mad_stream_init = dlsym(handle, "mad_stream_init");
m->mad_frame_init = dlsym(handle, "mad_frame_init");
m->mad_synth_init = dlsym(handle, "mad_synth_init");
--- a/mpg.c
+++ b/mpg.c
@@ -221,7 +221,9 @@ static bool load_mpg() {
LOG_INFO("dlerror: %s", dlerror());
return false;
}
-
+
+ err = dlerror(); // Reset previous dynamic linking error string (if there was)
+
m->mpg123_init = dlsym(handle, "mpg123_init");
m->mpg123_feature = dlsym(handle, "mpg123_feature");
m->mpg123_rates = dlsym(handle, "mpg123_rates");
--- a/resample.c
+++ b/resample.c
@@ -250,6 +250,8 @@ static bool load_soxr(void) {
return false;
}
+ err = dlerror(); // Reset previous dynamic linking error string (if there was)
+
r->soxr_io_spec = dlsym(handle, "soxr_io_spec");
r->soxr_quality_spec = dlsym(handle, "soxr_quality_spec");
r->soxr_create = dlsym(handle, "soxr_create");
--- a/vorbis.c
+++ b/vorbis.c
@@ -286,6 +286,8 @@ static bool load_vorbis() {
}
}
+ err = dlerror(); // Reset previous dynamic linking error string (if there was)
+
v->ov_read = tremor ? NULL : dlsym(handle, "ov_read");
v->ov_read_tremor = tremor ? dlsym(handle, "ov_read") : NULL;
v->ov_info = dlsym(handle, "ov_info");