From 237e296493d295647a6fbdb02e84f8f4c2a1c810 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Sun, 18 Feb 2018 20:11:37 +0100 Subject: kodi: add aac workaround from Debian --- package/kodi/Makefile | 6 ++++++ package/kodi/files/kodi-shim.c | 29 +++++++++++++++++++++++++++++ package/kodi/files/kodi.init | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 package/kodi/files/kodi-shim.c diff --git a/package/kodi/Makefile b/package/kodi/Makefile index 7b60a3f5d..e18933812 100644 --- a/package/kodi/Makefile +++ b/package/kodi/Makefile @@ -161,6 +161,10 @@ pre-configure: cp $(WRKBUILD)/../../tools/depends/native/TexturePacker/TexturePacker \ $(STAGING_HOST_DIR)/usr/bin +pre-build: + $(TARGET_CC) -shared -fPIC -o $(WRKBUILD)/kodi-shim.so \ + ./files/kodi-shim.c + kodi-install: $(INSTALL_DIR) $(STAGING_TARGET_DIR)/usr/share/kodi $(CP) $(WRKINST)/usr/share/kodi/* \ @@ -178,5 +182,7 @@ kodi-install: $(IDIR_KODI)/usr/bin $(INSTALL_BIN) $(WRKINST)/usr/bin/kodi \ $(IDIR_KODI)/usr/bin + $(CP) $(WRKBUILD)/kodi-shim.so \ + $(IDIR_KODI)/usr/lib/kodi include ${ADK_TOPDIR}/mk/pkg-bottom.mk diff --git a/package/kodi/files/kodi-shim.c b/package/kodi/files/kodi-shim.c new file mode 100644 index 000000000..952cb5660 --- /dev/null +++ b/package/kodi/files/kodi-shim.c @@ -0,0 +1,29 @@ +// from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=881536 + +#define _GNU_SOURCE +#include +#include + +// Mini version of AVPacket +typedef struct AVPacket { + void *buf; + int64_t pts; + int64_t dts; + uint8_t *data; + int size; +} AVPacket; + +int avcodec_decode_audio4(void* a, void* b, int* got_frame_ptr, const AVPacket* pkt) +{ + // Ignore null packets + if (pkt->size == 0) + { + *got_frame_ptr = 0; + return 0; + } + + // Forward to real function + int (*orig_decode)(void*, void*, int*, const AVPacket*) = + dlsym(RTLD_NEXT, "avcodec_decode_audio4"); + return orig_decode(a, b, got_frame_ptr, pkt); +} diff --git a/package/kodi/files/kodi.init b/package/kodi/files/kodi.init index 6e92cc234..34bf185f4 100644 --- a/package/kodi/files/kodi.init +++ b/package/kodi/files/kodi.init @@ -15,7 +15,7 @@ start) if [ ! -d /data/kodi ]; then mkdir /data/kodi fi - /usr/lib/kodi/kodi.bin & + LD_PRELOAD=/usr/lib/kodi/kodi-shim.so /usr/lib/kodi/kodi.bin & ;; stop) kill $(pgrep -f /usr/lib/kodi/kodi.bin) -- cgit v1.2.3