aboutsummaryrefslogtreecommitdiffstats
path: root/community/kodi
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2015-10-07 09:50:18 +0000
committerCarlo Landmeter <clandmeter@gmail.com>2015-10-07 15:43:45 +0200
commit386d01f1568ff757b6a8b31cf58d4eee7391c2c1 (patch)
treed6b8c7ff487a5436a1b0a88078534205faa45279 /community/kodi
parent80a17cd4c0be6796f45304322a74f6cf84fbde32 (diff)
downloadaports-386d01f1568ff757b6a8b31cf58d4eee7391c2c1.tar.bz2
aports-386d01f1568ff757b6a8b31cf58d4eee7391c2c1.tar.xz
community/kodi*: move from main
Diffstat (limited to 'community/kodi')
-rw-r--r--community/kodi/APKBUILD113
-rw-r--r--community/kodi/add-missing-includes.patch10
-rw-r--r--community/kodi/fix-fileemu.patch467
-rw-r--r--community/kodi/fix-musl.patch107
-rw-r--r--community/kodi/fix-rsxs.patch24
-rw-r--r--community/kodi/fortify-source-fix.patch11
-rw-r--r--community/kodi/kodi-14.0-gcc5.patch25
-rw-r--r--community/kodi/no-snesapu.patch46
-rw-r--r--community/kodi/remove-av_read_frame_flush.patch13
-rw-r--r--community/kodi/remove-filewrap.patch40
-rw-r--r--community/kodi/set-default-stacksize.patch10
11 files changed, 866 insertions, 0 deletions
diff --git a/community/kodi/APKBUILD b/community/kodi/APKBUILD
new file mode 100644
index 0000000000..3f482c084a
--- /dev/null
+++ b/community/kodi/APKBUILD
@@ -0,0 +1,113 @@
+# Contributor: Carlo Landmeter <clandmeter@gmail.com>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=kodi
+pkgver=14.2
+_realname=Helix
+pkgrel=6
+pkgdesc="A software media player and entertainment hub for digital media"
+url="http://kodi.tv"
+arch="x86 x86_64"
+license="GPL"
+depends="python hicolor-icon-theme xdpyinfo unrar mesa-demos curl py-pillow
+ py-bluez py-simplejson"
+depends_dev="gettext-dev boost-dev mesa-dev glew-dev glu-dev mariadb-dev
+ libass-dev libogg-dev libvorbis-dev libmodplug-dev curl-dev flac-dev
+ libgcrypt-dev bzip2-dev tiff-dev lzo-dev yajl-dev bluez-dev tinyxml-dev
+ fribidi-dev sqlite-dev libpng-dev libcdio-dev pcre-dev freetype-dev
+ taglib-dev jasper-dev alsa-lib-dev dbus-dev sdl-dev sdl_image-dev
+ lame-dev libmicrohttpd-dev libbluray-dev avahi-dev libxrandr-dev
+ libxt-dev libxmu-dev samba-dev gawk libssh-dev libva-dev libnfs-dev
+ yasm-dev libmpeg2-dev libmad-dev libsamplerate-dev rtmpdump-dev
+ libjpeg-turbo-dev eudev-dev libcap-dev udisks-dev faac-dev gnutls-dev
+ libxslt-dev libplist-dev libshairport-dev ffmpeg-dev afpfs-ng-dev
+ libcec-dev x264-dev bsd-compat-headers curl-dev python-dev"
+makedepends="$depends_dev automake autoconf m4 libtool swig findutils openjdk7-jre-base
+ boost-thread zip gperf cmake coreutils nasm tar pkgconfig"
+subpackages="$pkgname-dev $pkgname-doc $pkgname-dbg"
+install=""
+replaces="xbmc"
+options="ldpath-recursive"
+source="https://github.com/xbmc/xbmc/archive/$pkgver-$_realname.zip
+ no-snesapu.patch
+ fix-musl.patch
+ fix-fileemu.patch
+ fix-rsxs.patch
+ fortify-source-fix.patch
+ remove-av_read_frame_flush.patch
+ remove-filewrap.patch
+ add-missing-includes.patch
+ set-default-stacksize.patch
+ kodi-14.0-gcc5.patch
+ "
+
+_builddir="$srcdir/xbmc-$pkgver-$_realname"
+
+prepare() {
+ local i
+ cd "$_builddir"
+ for i in $source; do
+ case $i in
+ *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+ esac
+ done
+}
+
+build() {
+ cd "$_builddir"
+ export MAKEFLAGS=""
+ ./bootstrap || return 1
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --localstatedir=/var \
+ --disable-non-free \
+ --disable-debug \
+ --with-ffmpeg=shared \
+ --enable-static=no \
+ --enable-libbluray \
+ || return 1
+ make || return 1
+}
+
+package() {
+ cd "$_builddir"
+ make DESTDIR="$pkgdir" install || return 1
+}
+
+md5sums="f9e035a6ad5f426246f9d30b17a214d3 14.2-Helix.zip
+5ad388f29ab8f4ca6bc9e2b73bf946ef no-snesapu.patch
+9d61cf68c8d994d11d7c4c0ab9383098 fix-musl.patch
+69049c53ffc4a403ccff3bba77e47793 fix-fileemu.patch
+1c8cc1618f29613fe3521db3e4a99db5 fix-rsxs.patch
+a769a0018f58cb4f5ea865dcabbe2bed fortify-source-fix.patch
+e87c3d8170ad5448a6cf19d1509ab415 remove-av_read_frame_flush.patch
+cb116c5b55438222db308d4b6b7bc6ff remove-filewrap.patch
+ed12b2515c259c87ea622e04df78dfe5 add-missing-includes.patch
+deff09ba18d3bc4674d1c195a40ea399 set-default-stacksize.patch
+39807cbc0f17d8a25b89c455c420719d kodi-14.0-gcc5.patch"
+sha256sums="2fca08694314e8147a3a643fcd80953d5e818fcfb6af9612210f06a05f406ff3 14.2-Helix.zip
+3c04c2cd6909cfb587b194e6c5a3025f1a3f03a0c5178ad70541ff7e69915935 no-snesapu.patch
+c07906ae884919cce64abae77f9facbb1aa68ba214ae7ec3195c260ae1a15c27 fix-musl.patch
+cd566ae87c0ecc3e7cbeee9d80b042ae937d4f243413293616bd31f24efffec7 fix-fileemu.patch
+e5de7cf5e781de9288f362c9d1c88d226297ba4aae3f75e5980f0a7cfc2258f0 fix-rsxs.patch
+b5b6636e77dc11bd3a78d811e60cd98b6929e018b8f32ae2ee100a00e5535bea fortify-source-fix.patch
+29f5c17585a0fc05e8e4d548c4deddefc9fc6b742d873658ce299bab9244eeed remove-av_read_frame_flush.patch
+11f537c6d5a2089053c80600b4dc1d6530faaee2141eba1a7eb0b941385ba9f1 remove-filewrap.patch
+0ea70141b3b80ac586e941c97806f819b562f1d5166d0fe045e28dff0b62d739 add-missing-includes.patch
+212cb3d9861b2b57d9929c2046917c5789d4bacf7849ec3f7c5a4740693349b2 set-default-stacksize.patch
+598f36cea0f63440e5755d88752552240fc5cd2b98e4f80a9feeb9605c917777 kodi-14.0-gcc5.patch"
+sha512sums="a01cd5e4b59943e800c8998a4f401fe04947f4c4e39cf10d4f791602f98115c615ec3a226a399359a6f06c0555d831f509f8b12b558ab35f842bef2f5e1ea4e3 14.2-Helix.zip
+8b2b3159b536719bad7c00f2eb51c4778f8e6c049cfe07e2555a530ad8587ca7b83623e1b5f40220d2e490e38442f893f87496620aa94da27d37a8bddc72f434 no-snesapu.patch
+ddcd22512656607dd077135f95c7342081fbbeb9f78f8dc7e55e4a3a98b19d7c046faebb2925443c27dbd1cd7889e054a43a36e1efdbb8df2817997876c35513 fix-musl.patch
+d2c284a7156a842e23a1089053cb28af1a825fddbeb5b5e8d4a8f2d8b37a7861a7082529e603cfe56eb2c7fd35c4ce1aa7e9f224690ab42689c9886d60dafbc7 fix-fileemu.patch
+e1ed2e2e53c20b59f2ea926e9097e99438fdaed9b9d4c0133567bd1c8dc26b003961ad045ce4aaba62e9825e1a2d9651e72bd21bdb09dcc840c8e14d9602d109 fix-rsxs.patch
+5e972e6f6ad13f5dc8ac5e9d593171988e0cc93879178aa7621af44d41b89b5b86429af4d0c2e6516b626d042f247bcf0b1f957f647138a03ce73c5c7b3311b9 fortify-source-fix.patch
+5e54cf4e77b3d12923a88c18f268b069f28cbf26069217d76ab4685e1ec67bddc1f374b60eaffa653caa8b7fd6916037f47df8547f012b46d6653c4d1debf5b4 remove-av_read_frame_flush.patch
+cdac558134441633a83a346c2d5f5d69a1dea10276d5a46d18433d5c94937528610a662749db0909685e6bf42277e1318726409b572390f3b8ebea61209ee5c9 remove-filewrap.patch
+378a0e8fd9676dd76cfb30d62085b953625dd0185e2673de2331fc7ae0802dae4f56d0b74e878e4d313942fda8831e9669bff284dbe974db5ad16fe07af884d6 add-missing-includes.patch
+3fd97e9fa22e59b3cd30fdad19474e177a9d062598765fa8ba4955f1da4e10581ff1463dd0794d3ee3cefebf753007a4d445b2bc47a257574d3927c1408b8876 set-default-stacksize.patch
+bef0f96849ba5bc1e31d310fce7a7a65ab5ece9222799607687d26044085affbc358f94e5c21db566dedc1e3c27623a79104fed3feb76da03b63528a5da24dcb kodi-14.0-gcc5.patch"
diff --git a/community/kodi/add-missing-includes.patch b/community/kodi/add-missing-includes.patch
new file mode 100644
index 0000000000..236bfa6fd0
--- /dev/null
+++ b/community/kodi/add-missing-includes.patch
@@ -0,0 +1,10 @@
+--- a/xbmc/filesystem/ZipManager.h.orig
++++ b/xbmc/filesystem/ZipManager.h
+@@ -33,6 +33,7 @@
+ #include <string>
+ #include <vector>
+ #include <map>
++#include <stdint.h>
+
+ class CURL;
+
diff --git a/community/kodi/fix-fileemu.patch b/community/kodi/fix-fileemu.patch
new file mode 100644
index 0000000000..59d0045ac1
--- /dev/null
+++ b/community/kodi/fix-fileemu.patch
@@ -0,0 +1,467 @@
+diff --git a/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp b/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp
+index ae7ccb5..d8fd7fc 100644
+--- a/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp
++++ b/xbmc/cores/DllLoader/exports/emu_msvcrt.cpp
+@@ -49,6 +49,7 @@
+ #include <fcntl.h>
+ #include <time.h>
+ #include <signal.h>
++#include <paths.h>
+ #ifdef TARGET_POSIX
+ #include "PlatformDefs.h" // for __stat64
+ #endif
+@@ -466,13 +467,10 @@ extern "C"
+ EmuFileObject* o = g_emuFileWrapper.GetFileObjectByDescriptor(fd);
+ if (o)
+ {
+- if(!o->used)
+- return NULL;
+-
+ int nmode = convert_fmode(mode);
+ if( (o->mode & nmode) != nmode)
+ CLog::Log(LOGWARNING, "dll_fdopen - mode 0x%x differs from fd mode 0x%x", nmode, o->mode);
+- return &o->file_emu;
++ return g_emuFileWrapper.GetStreamByFileObject(o);
+ }
+ else if (!IS_STD_DESCRIPTOR(fd))
+ {
+@@ -535,7 +533,7 @@ extern "C"
+ return -1;
+ }
+ object->mode = iMode;
+- return g_emuFileWrapper.GetDescriptorByStream(&object->file_emu);
++ return g_emuFileWrapper.GetDescriptorByFileObject(object);
+ }
+ delete pFile;
+ return -1;
+@@ -1181,8 +1179,8 @@ extern "C"
+ {
+ FILE* file = NULL;
+ #if defined(TARGET_LINUX) && !defined(TARGET_ANDROID)
+- if (strcmp(filename, MOUNTED) == 0
+- || strcmp(filename, MNTTAB) == 0)
++ if (strcmp(filename, _PATH_MOUNTED) == 0
++ || strcmp(filename, _PATH_MNTTAB) == 0)
+ {
+ CLog::Log(LOGINFO, "%s - something opened the mount file, let's hope it knows what it's doing", __FUNCTION__);
+ return fopen(filename, mode);
+@@ -1572,7 +1570,7 @@ extern "C"
+ int ret;
+
+ ret = dll_fgetpos64(stream, &tmpPos);
+-#if !defined(TARGET_POSIX) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
++#if !defined(GLIBC) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
+ *pos = (fpos_t)tmpPos;
+ #else
+ pos->__pos = (off_t)tmpPos.__pos;
+@@ -1585,8 +1583,9 @@ extern "C"
+ CFile* pFile = g_emuFileWrapper.GetFileXbmcByStream(stream);
+ if (pFile != NULL)
+ {
+-#if !defined(TARGET_POSIX) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
+- *pos = pFile->GetPosition();
++#if !defined(GLIBC) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
++ uint64_t *ppos = (uint64_t *) pos;
++ *ppos = pFile->GetPosition();
+ #else
+ pos->__pos = pFile->GetPosition();
+ #endif
+@@ -1607,8 +1606,9 @@ extern "C"
+ int fd = g_emuFileWrapper.GetDescriptorByStream(stream);
+ if (fd >= 0)
+ {
+-#if !defined(TARGET_POSIX) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
+- if (dll_lseeki64(fd, *pos, SEEK_SET) >= 0)
++#if !defined(GLIBC) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
++ const uint64_t *ppos = (const uint64_t *) pos;
++ if (dll_lseeki64(fd, *ppos, SEEK_SET) >= 0)
+ #else
+ if (dll_lseeki64(fd, (__off64_t)pos->__pos, SEEK_SET) >= 0)
+ #endif
+@@ -1624,7 +1624,7 @@ extern "C"
+ {
+ // it might be something else than a file, or the file is not emulated
+ // let the operating system handle it
+-#if !defined(TARGET_POSIX) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
++#if !defined(GLIBC) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
+ return fsetpos(stream, pos);
+ #else
+ return fsetpos64(stream, pos);
+@@ -1640,7 +1640,7 @@ extern "C"
+ if (fd >= 0)
+ {
+ fpos64_t tmpPos;
+-#if !defined(TARGET_POSIX) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
++#if !defined(GLIBC) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
+ tmpPos= *pos;
+ #else
+ tmpPos.__pos = (off64_t)(pos->__pos);
+diff --git a/xbmc/cores/DllLoader/exports/emu_msvcrt.h b/xbmc/cores/DllLoader/exports/emu_msvcrt.h
+index ae9b1c4..3b19122 100644
+--- a/xbmc/cores/DllLoader/exports/emu_msvcrt.h
++++ b/xbmc/cores/DllLoader/exports/emu_msvcrt.h
+@@ -26,7 +26,7 @@
+ #define _onexit_t void*
+ #endif
+
+-#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
++#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID) || !defined(GLIBC)
+ typedef off_t __off_t;
+ typedef int64_t off64_t;
+ typedef off64_t __off64_t;
+diff --git a/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.cpp b/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.cpp
+index cf8a060..9110312 100644
+--- a/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.cpp
++++ b/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.cpp
+@@ -27,12 +27,7 @@ CEmuFileWrapper g_emuFileWrapper;
+ CEmuFileWrapper::CEmuFileWrapper()
+ {
+ // since we always use dlls we might just initialize it directly
+- for (int i = 0; i < MAX_EMULATED_FILES; i++)
+- {
+- memset(&m_files[i], 0, sizeof(EmuFileObject));
+- m_files[i].used = false;
+- m_files[i].file_emu._file = -1;
+- }
++ memset(m_files, 0, sizeof(m_files));
+ }
+
+ CEmuFileWrapper::~CEmuFileWrapper()
+@@ -43,22 +38,7 @@ void CEmuFileWrapper::CleanUp()
+ {
+ CSingleLock lock(m_criticalSection);
+ for (int i = 0; i < MAX_EMULATED_FILES; i++)
+- {
+- if (m_files[i].used)
+- {
+- m_files[i].file_xbmc->Close();
+- delete m_files[i].file_xbmc;
+-
+- if (m_files[i].file_lock)
+- {
+- delete m_files[i].file_lock;
+- m_files[i].file_lock = NULL;
+- }
+- memset(&m_files[i], 0, sizeof(EmuFileObject));
+- m_files[i].used = false;
+- m_files[i].file_emu._file = -1;
+- }
+- }
++ UnRegisterFileObject(&m_files[i], true);
+ }
+
+ EmuFileObject* CEmuFileWrapper::RegisterFileObject(XFILE::CFile* pFile)
+@@ -69,13 +49,11 @@ EmuFileObject* CEmuFileWrapper::RegisterFileObject(XFILE::CFile* pFile)
+
+ for (int i = 0; i < MAX_EMULATED_FILES; i++)
+ {
+- if (!m_files[i].used)
++ if (!m_files[i].file_xbmc)
+ {
+ // found a free location
+ object = &m_files[i];
+- object->used = true;
+ object->file_xbmc = pFile;
+- object->file_emu._file = (i + FILE_WRAPPER_OFFSET);
+ object->file_lock = new CCriticalSection();
+ break;
+ }
+@@ -84,82 +62,71 @@ EmuFileObject* CEmuFileWrapper::RegisterFileObject(XFILE::CFile* pFile)
+ return object;
+ }
+
+-void CEmuFileWrapper::UnRegisterFileObjectByDescriptor(int fd)
++void CEmuFileWrapper::UnRegisterFileObject(EmuFileObject *object, bool free_file)
+ {
+- int i = fd - FILE_WRAPPER_OFFSET;
+- if (i >= 0 && i < MAX_EMULATED_FILES)
++ if (object && object->file_xbmc)
+ {
+- if (m_files[i].used)
++ if (object->file_xbmc && free_file)
+ {
+- CSingleLock lock(m_criticalSection);
+-
+- // we assume the emulated function alreay deleted the CFile object
+- if (m_files[i].used)
+- {
+- if (m_files[i].file_lock)
+- {
+- delete m_files[i].file_lock;
+- m_files[i].file_lock = NULL;
+- }
+- memset(&m_files[i], 0, sizeof(EmuFileObject));
+- m_files[i].used = false;
+- m_files[i].file_emu._file = -1;
+- }
++ object->file_xbmc->Close();
++ delete object->file_xbmc;
+ }
++ if (object->file_lock)
++ {
++ delete object->file_lock;
++ }
++
++ memset(object, 0, sizeof(*object));
+ }
+ }
+
++void CEmuFileWrapper::UnRegisterFileObjectByDescriptor(int fd)
++{
++ CSingleLock lock(m_criticalSection);
++ UnRegisterFileObject(GetFileObjectByDescriptor(fd), false);
++}
++
+ void CEmuFileWrapper::UnRegisterFileObjectByStream(FILE* stream)
+ {
+- if (stream != NULL)
+- {
+- return UnRegisterFileObjectByDescriptor(stream->_file);
+- }
++ CSingleLock lock(m_criticalSection);
++ UnRegisterFileObject(GetFileObjectByStream(stream), false);
+ }
+
+ void CEmuFileWrapper::LockFileObjectByDescriptor(int fd)
+ {
+- int i = fd - FILE_WRAPPER_OFFSET;
+- if (i >= 0 && i < MAX_EMULATED_FILES)
++ EmuFileObject* object = GetFileObjectByDescriptor(fd);
++ if (object && object->file_xbmc)
+ {
+- if (m_files[i].used)
+- {
+- m_files[i].file_lock->lock();
+- }
++ object->file_lock->lock();
+ }
+ }
+
+ bool CEmuFileWrapper::TryLockFileObjectByDescriptor(int fd)
+-{
+- int i = fd - FILE_WRAPPER_OFFSET;
+- if (i >= 0 && i < MAX_EMULATED_FILES)
+- {
+- if (m_files[i].used)
+- {
+- return m_files[i].file_lock->try_lock();
+- }
++{
++ EmuFileObject* object = GetFileObjectByDescriptor(fd);
++ if (object && object->file_xbmc)
++ {
++ return object->file_lock->try_lock();
+ }
++
+ return false;
+ }
+
+ void CEmuFileWrapper::UnlockFileObjectByDescriptor(int fd)
+-{
+- int i = fd - FILE_WRAPPER_OFFSET;
+- if (i >= 0 && i < MAX_EMULATED_FILES)
+- {
+- if (m_files[i].used)
+- {
+- m_files[i].file_lock->unlock();
+- }
++{
++ EmuFileObject* object = GetFileObjectByDescriptor(fd);
++ if (object && object->file_xbmc)
++ {
++ object->file_lock->unlock();
+ }
+ }
+
+ EmuFileObject* CEmuFileWrapper::GetFileObjectByDescriptor(int fd)
+ {
+- int i = fd - FILE_WRAPPER_OFFSET;
++ int i = fd - 0x7000000;
+ if (i >= 0 && i < MAX_EMULATED_FILES)
+ {
+- if (m_files[i].used)
++ if (m_files[i].file_xbmc)
+ {
+ return &m_files[i];
+ }
+@@ -167,20 +134,38 @@ EmuFileObject* CEmuFileWrapper::GetFileObjectByDescriptor(int fd)
+ return NULL;
+ }
+
+-EmuFileObject* CEmuFileWrapper::GetFileObjectByStream(FILE* stream)
++int CEmuFileWrapper::GetDescriptorByFileObject(EmuFileObject *object)
+ {
+- if (stream != NULL)
++ int i = object - m_files;
++ if (i >= 0 && i < MAX_EMULATED_FILES)
+ {
+- return GetFileObjectByDescriptor(stream->_file);
++ return 0x7000000 + i;
+ }
++ return -1;
++}
+
++EmuFileObject* CEmuFileWrapper::GetFileObjectByStream(FILE* stream)
++{
++ EmuFileObject *object = (EmuFileObject*) stream;
++ if (object >= &m_files[0] || object < &m_files[MAX_EMULATED_FILES])
++ {
++ if (object->file_xbmc)
++ {
++ return object;
++ }
++ }
+ return NULL;
+ }
+
++FILE* CEmuFileWrapper::GetStreamByFileObject(EmuFileObject *object)
++{
++ return (FILE*) object;
++}
++
+ XFILE::CFile* CEmuFileWrapper::GetFileXbmcByDescriptor(int fd)
+ {
+ EmuFileObject* object = GetFileObjectByDescriptor(fd);
+- if (object != NULL && object->used)
++ if (object != NULL)
+ {
+ return object->file_xbmc;
+ }
+@@ -191,8 +176,8 @@ XFILE::CFile* CEmuFileWrapper::GetFileXbmcByStream(FILE* stream)
+ {
+ if (stream != NULL)
+ {
+- EmuFileObject* object = GetFileObjectByDescriptor(stream->_file);
+- if (object != NULL && object->used)
++ EmuFileObject* object = GetFileObjectByStream(stream);
++ if (object != NULL)
+ {
+ return object->file_xbmc;
+ }
+@@ -202,42 +187,20 @@ XFILE::CFile* CEmuFileWrapper::GetFileXbmcByStream(FILE* stream)
+
+ int CEmuFileWrapper::GetDescriptorByStream(FILE* stream)
+ {
+- if (stream != NULL)
+- {
+- int i = stream->_file - FILE_WRAPPER_OFFSET;
+- if (i >= 0 && i < MAX_EMULATED_FILES)
+- {
+- return stream->_file;
+- }
+- }
+- return -1;
++ return GetDescriptorByFileObject(GetFileObjectByStream(stream));
+ }
+
+ FILE* CEmuFileWrapper::GetStreamByDescriptor(int fd)
+ {
+- EmuFileObject* object = GetFileObjectByDescriptor(fd);
+- if (object != NULL && object->used)
+- {
+- return &object->file_emu;
+- }
+- return NULL;
++ return GetStreamByFileObject(GetFileObjectByDescriptor(fd));
+ }
+
+ bool CEmuFileWrapper::DescriptorIsEmulatedFile(int fd)
+ {
+- int i = fd - FILE_WRAPPER_OFFSET;
+- if (i >= 0 && i < MAX_EMULATED_FILES)
+- {
+- return true;
+- }
+- return false;
++ return GetFileObjectByDescriptor(fd) != NULL;
+ }
+
+ bool CEmuFileWrapper::StreamIsEmulatedFile(FILE* stream)
+ {
+- if (stream != NULL)
+- {
+- return DescriptorIsEmulatedFile(stream->_file);
+- }
+- return false;
++ return GetFileObjectByStream(stream) != NULL;
+ }
+diff --git a/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.h b/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.h
+index 3d79c7a..1b3e62f 100644
+--- a/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.h
++++ b/xbmc/cores/DllLoader/exports/util/EmuFileWrapper.h
+@@ -27,14 +27,14 @@
+ #include "system.h"
+ #include "threads/CriticalSection.h"
+
+-#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD) && !defined(TARGET_ANDROID) && !defined(__UCLIBC__)
+-#define _file _fileno
+-#elif defined(__UCLIBC__)
+-#define _file __filedes
+-#endif
++//#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD) && !defined(TARGET_ANDROID) && !defined(__UCLIBC__)
++//#define _file _fileno
++//#elif defined(__UCLIBC__)
++//#define _file __filedes
++//#endif
+
+ #define MAX_EMULATED_FILES 50
+-#define FILE_WRAPPER_OFFSET 0x00000100
++//#define FILE_WRAPPER_OFFSET 0x00000100
+
+ namespace XFILE
+ {
+@@ -43,11 +43,9 @@ namespace XFILE
+
+ typedef struct stEmuFileObject
+ {
+- bool used;
+- FILE file_emu;
+- XFILE::CFile* file_xbmc;
++ XFILE::CFile* file_xbmc;
+ CCriticalSection *file_lock;
+- int mode;
++ int mode;
+ } EmuFileObject;
+
+ class CEmuFileWrapper
+@@ -62,19 +60,22 @@ public:
+ void CleanUp();
+
+ EmuFileObject* RegisterFileObject(XFILE::CFile* pFile);
++ void UnRegisterFileObject(EmuFileObject*, bool free_file);
+ void UnRegisterFileObjectByDescriptor(int fd);
+ void UnRegisterFileObjectByStream(FILE* stream);
+ void LockFileObjectByDescriptor(int fd);
+ bool TryLockFileObjectByDescriptor(int fd);
+ void UnlockFileObjectByDescriptor(int fd);
+- EmuFileObject* GetFileObjectByDescriptor(int fd);
+- EmuFileObject* GetFileObjectByStream(FILE* stream);
++ EmuFileObject* GetFileObjectByDescriptor(int fd);
++ int GetDescriptorByFileObject(EmuFileObject*);
++ EmuFileObject* GetFileObjectByStream(FILE* stream);
++ FILE* GetStreamByFileObject(EmuFileObject*);
+ XFILE::CFile* GetFileXbmcByDescriptor(int fd);
+ XFILE::CFile* GetFileXbmcByStream(FILE* stream);
+- static int GetDescriptorByStream(FILE* stream);
++ int GetDescriptorByStream(FILE* stream);
+ FILE* GetStreamByDescriptor(int fd);
+- static bool DescriptorIsEmulatedFile(int fd);
+- static bool StreamIsEmulatedFile(FILE* stream);
++ bool DescriptorIsEmulatedFile(int fd);
++ bool StreamIsEmulatedFile(FILE* stream);
+ private:
+ EmuFileObject m_files[MAX_EMULATED_FILES];
+ CCriticalSection m_criticalSection;
+diff --git a/xbmc/cores/DllLoader/exports/wrapper.c b/xbmc/cores/DllLoader/exports/wrapper.c
+index a9225e5..355da1c 100644
+--- a/xbmc/cores/DllLoader/exports/wrapper.c
++++ b/xbmc/cores/DllLoader/exports/wrapper.c
+@@ -39,7 +39,7 @@
+ #endif
+ #include <dlfcn.h>
+
+-#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
++#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID) || !defined(GLIBC)
+ typedef off_t __off_t;
+ typedef int64_t off64_t;
+ typedef off64_t __off64_t;
diff --git a/community/kodi/fix-musl.patch b/community/kodi/fix-musl.patch
new file mode 100644
index 0000000000..61b3571b07
--- /dev/null
+++ b/community/kodi/fix-musl.patch
@@ -0,0 +1,107 @@
+diff -ru xbmc-12.3-Frodo.orig/configure.in xbmc-12.3-Frodo/configure.in
+diff -ru xbmc-12.3-Frodo.orig/lib/SlingboxLib/SlingboxLib.cpp xbmc-12.3-Frodo/lib/SlingboxLib/SlingboxLib.cpp
+--- xbmc-12.3-Frodo.orig/lib/SlingboxLib/SlingboxLib.cpp 2013-12-12 21:47:49.000000000 +0000
++++ xbmc-12.3-Frodo/lib/SlingboxLib/SlingboxLib.cpp 2014-04-15 06:07:15.746789122 +0000
+@@ -29,7 +29,9 @@
+ #include <time.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
++#include <sys/time.h>
+ #include <sys/socket.h>
++#include <sys/select.h>
+ #define INVALID_SOCKET (SOCKET)(~0)
+ #define SOCKET_ERROR (-1)
+ #endif
+diff -ru xbmc-12.3-Frodo.orig/lib/libXDAAP/thread.h xbmc-12.3-Frodo/lib/libXDAAP/thread.h
+--- xbmc-12.3-Frodo.orig/lib/libXDAAP/thread.h 2013-12-12 21:47:49.000000000 +0000
++++ xbmc-12.3-Frodo/lib/libXDAAP/thread.h 2014-04-15 06:11:09.940947997 +0000
+@@ -37,7 +37,7 @@
+ #define ts_mutex pthread_mutex_t
+ #define ts_condition pthread_cond_t
+
+-#if defined(__APPLE__) || defined(__FreeBSD__)
++#if !defined(PTHREAD_MUTEX_RECURSIVE_NP)
+ #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
+ #endif
+
+diff -ru xbmc-12.3-Frodo.orig/xbmc/visualizations/XBMCProjectM/libprojectM/BeatDetect.cpp xbmc-12.3-Frodo/xbmc/visualizations/XBMCProjectM/libprojectM/BeatDetect.cpp
+--- xbmc-12.3-Frodo.orig/xbmc/visualizations/XBMCProjectM/libprojectM/BeatDetect.cpp 2014-04-15 05:52:42.214313750 +0000
++++ xbmc-12.3-Frodo/xbmc/visualizations/XBMCProjectM/libprojectM/BeatDetect.cpp 2014-04-15 05:49:51.921324165 +0000
+@@ -33,7 +33,7 @@
+
+ #include "Common.hpp"
+ #include "PCM.hpp"
+-#include <cmath>
++#include "math.h"
+ #include "BeatDetect.hpp"
+
+ #ifdef _WIN32
+--- ./configure.in.orig
++++ ./configure.in
+@@ -628,7 +628,7 @@
+ use_x11=no
+ build_shared_lib=yes
+ ;;
+- i*86*-linux-gnu*|i*86*-*-linux-uclibc*)
++ i*86*-linux-gnu*|i*86*-*-linux-uclibc*|i*86*-linux-musl*)
+ ARCH="i486-linux"
+ if test "$use_cpu" = "no" -a "$cross_compiling" = "yes"; then
+ use_arch="x86"
+@@ -636,7 +636,7 @@
+ fi
+ use_static_ffmpeg=yes
+ ;;
+- x86_64-*-linux-gnu*|x86_64-*-linux-uclibc*)
++ x86_64-*-linux-gnu*|x86_64-*-linux-uclibc*|x86_64-*-linux-musl*)
+ ARCH="x86_64-linux"
+ if test "$use_cpu" = "no" -a "$cross_compiling" = "yes"; then
+ use_arch="x86_64"
+@@ -688,7 +688,7 @@
+ powerpc64-*-linux-gnu*|powerpc64-*-linux-uclibc*)
+ ARCH="powerpc64-linux"
+ ;;
+- arm*-*-linux-gnu*|arm*-*-linux-uclibc*)
++ arm*-*-linux-gnu*|arm*-*-linux-uclibc*|arm*-*-linux-muslgnu*)
+ ARCH="arm"
+ use_arch="arm"
+ ffmpeg_target_os=linux
+--- ./xbmc/cores/DllLoader/ldt_keeper.c.orig
++++ ./xbmc/cores/DllLoader/ldt_keeper.c
+@@ -48,7 +48,7 @@
+ #if defined(__GLIBC__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0))
+ _syscall3( int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount );
+ #else
+-#if defined(TARGET_ANDROID) && defined(__i386__) && !defined(modify_ldt)
++#if defined(__linux__) && !defined(__GLIBC__) && !defined(modify_ldt)
+ #define modify_ldt(a,b,c) syscall( __NR_modify_ldt, a, b, c);
+ #else
+ int modify_ldt(int func, void *ptr, unsigned long bytecount);
+--- ./tools/TexturePacker/XBTFWriter.cpp.orig
++++ ./tools/TexturePacker/XBTFWriter.cpp
+@@ -23,11 +23,7 @@
+ #include <inttypes.h>
+ #include "guilib/XBTF.h"
+ #include "utils/EndianSwap.h"
+-#if defined(TARGET_FREEBSD) || defined(TARGET_DARWIN)
+ #include <stdlib.h>
+-#elif !defined(TARGET_DARWIN)
+-#include <malloc.h>
+-#endif
+ #include <memory.h>
+
+ #define WRITE_STR(str, size, file) fwrite(str, size, 1, file)
+--- ./m4/xbmc_arch.m4.orig
++++ ./m4/xbmc_arch.m4
+@@ -2,10 +2,10 @@
+
+ # host detection and setup
+ case $host in
+- i*86*-linux-gnu*|i*86*-*-linux-uclibc*)
++ i*86*-linux-gnu*|i*86*-*-linux-uclibc|*i*86*-linux-musl*)
+ AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
+ ;;
+- x86_64-*-linux-gnu*|x86_64-*-linux-uclibc*)
++ x86_64-*-linux-gnu*|x86_64-*-linux-uclibc*|x86_64-*-linux-musl*)
+ AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
+ ;;
+ i386-*-freebsd*)
diff --git a/community/kodi/fix-rsxs.patch b/community/kodi/fix-rsxs.patch
new file mode 100644
index 0000000000..ccc7698c73
--- /dev/null
+++ b/community/kodi/fix-rsxs.patch
@@ -0,0 +1,24 @@
+--- xbmc-12.3-Frodo/xbmc/screensavers/rsxs-0.9/configure.ac 2014-04-15 10:22:51.025587069 +0000
++++ xbmc-12.3-Frodo/xbmc/screensavers/rsxs-0.9/configure.ac 2014-04-15 10:21:51.947852111 +0000
+@@ -14,18 +14,13 @@
+
+ # Checks for programs.
+ LT_AC_PROG_SED
+-AC_LANG(C++)
+-AC_PROG_CXX
+-#CXXFLAGS=`echo $CXXFLAGS | sed -e s,-O2,-O3,`
+-AC_PROG_CXXCPP
+-
+-#if test x"$GXX" = x"yes"; then
+-# CXXFLAGS=`echo $CXXFLAGS -Wall`
+-#fi
+
+ AC_PROG_CC
+ AM_PROG_CC_C_O
+ gl_EARLY
++AC_PROG_CXX
++AC_PROG_CXXCPP
++
+ AC_PROG_RANLIB
+
+ # Cut-down version of AC_LIB_LTDL. We don't want the option to install
diff --git a/community/kodi/fortify-source-fix.patch b/community/kodi/fortify-source-fix.patch
new file mode 100644
index 0000000000..5717746e09
--- /dev/null
+++ b/community/kodi/fortify-source-fix.patch
@@ -0,0 +1,11 @@
+--- a/xbmc/cores/DllLoader/exports/wrapper.c.orig
++++ b/xbmc/cores/DllLoader/exports/wrapper.c
+@@ -462,7 +462,7 @@
+ // are actually #defines which are inlined when compiled with -O. Those defines
+ // actally call __*chk (for example, __fread_chk). We need to bypass this whole
+ // thing to actually call our wrapped functions.
+-#if _FORTIFY_SOURCE > 1
++#if defined(__GLIBC__) && _FORTIFY_SOURCE > 1
+
+ size_t __wrap___fread_chk(void * ptr, size_t ptrlen, size_t size, size_t n, FILE * stream)
+ {
diff --git a/community/kodi/kodi-14.0-gcc5.patch b/community/kodi/kodi-14.0-gcc5.patch
new file mode 100644
index 0000000000..e4c1e52f7c
--- /dev/null
+++ b/community/kodi/kodi-14.0-gcc5.patch
@@ -0,0 +1,25 @@
+--- a/xbmc/screensavers/rsxs-0.9/lib/argp.h.orig 2015-03-26 13:25:20.000000000 -0500
++++ b/xbmc/screensavers/rsxs-0.9/lib/argp.h 2015-05-19 16:05:20.992493851 -0500
+@@ -559,7 +559,7 @@
+ # endif
+
+ # ifndef ARGP_EI
+-# define ARGP_EI extern __inline__
++# define ARGP_EI extern __inline__ __attribute__ ((gnu_inline))
+ # endif
+
+ ARGP_EI void
+--- a/xbmc/screensavers/rsxs-0.9/lib/argp-fmtstream.h.orig 2015-03-26 13:25:20.000000000 -0500
++++ b/xbmc/screensavers/rsxs-0.9/lib/argp-fmtstream.h 2015-05-19 16:02:25.775456866 -0500
+@@ -198,11 +198,7 @@
+ #endif
+
+ #ifndef ARGP_FS_EI
+-#ifdef __clang__
+ #define ARGP_FS_EI extern inline __attribute__ ((__gnu_inline__))
+-#else
+-#define ARGP_FS_EI extern inline
+-#endif
+ #endif
+
+ ARGP_FS_EI size_t
diff --git a/community/kodi/no-snesapu.patch b/community/kodi/no-snesapu.patch
new file mode 100644
index 0000000000..d49b273abd
--- /dev/null
+++ b/community/kodi/no-snesapu.patch
@@ -0,0 +1,46 @@
+diff --git a/Makefile.in b/Makefile.in
+index 31826b1..2f468e7 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -168,7 +168,6 @@ PAPCODECS_DIRS= \
+ lib/timidity \
+ lib/libsidplay2 \
+ lib/stsound/StSoundLibrary \
+- lib/snesapu/SNES/SNESAPU \
+ lib/vgmstream
+
+ ifeq (@USE_ASAP_CODEC@,1)
+@@ -373,9 +372,6 @@ ifeq (@USE_ASAP_CODEC@,1)
+ endif
+ endif
+ $(MAKE) -C lib/stsound/StSoundLibrary
+-ifeq ($(or $(findstring powerpc,@ARCH@),$(findstring x86_64-linux,@ARCH@),$(findstring arm, @ARCH@),$(findstring freebsd,@ARCH@)),)
+- $(MAKE) -C lib/snesapu/SNES/SNESAPU
+-endif
+ imagelib: dllloader
+ $(MAKE) -C lib/cximage-6.0
+
+diff --git a/configure.in b/configure.in
+index 538d9af..3f04545 100644
+--- a/configure.in
++++ b/configure.in
+@@ -2348,7 +2348,6 @@ OUTPUT_FILES="Makefile \
+ lib/nosefart/Makefile \
+ lib/libsidplay2/Makefile \
+ lib/vgmstream/Makefile \
+- lib/snesapu/SNES/SNESAPU/Makefile \
+ lib/stsound/StSoundLibrary/Makefile \
+ xbmc/cores/playercorefactory/Makefile \
+ xbmc/music/karaoke/Makefile \
+diff --git a/xbmc/cores/paplayer/Makefile.in b/xbmc/cores/paplayer/Makefile.in
+index 31cc8bd..a433e82 100644
+--- a/xbmc/cores/paplayer/Makefile.in
++++ b/xbmc/cores/paplayer/Makefile.in
+@@ -31,7 +31,6 @@ SRCS += ASAPCodec.cpp
+ endif
+
+ ifneq ($(ARCH), arm)
+-CXXFLAGS += -DHAS_SPC_CODEC
+ SRCS += SPCCodec.cpp
+ endif
+
diff --git a/community/kodi/remove-av_read_frame_flush.patch b/community/kodi/remove-av_read_frame_flush.patch
new file mode 100644
index 0000000000..f931aae580
--- /dev/null
+++ b/community/kodi/remove-av_read_frame_flush.patch
@@ -0,0 +1,13 @@
+--- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp.orig
++++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
+@@ -539,10 +539,6 @@
+
+ void CDVDDemuxFFmpeg::Flush()
+ {
+- // naughty usage of an internal ffmpeg function
+- if (m_pFormatContext)
+- av_read_frame_flush(m_pFormatContext);
+-
+ m_currentPts = DVD_NOPTS_VALUE;
+
+ m_pkt.result = -1;
diff --git a/community/kodi/remove-filewrap.patch b/community/kodi/remove-filewrap.patch
new file mode 100644
index 0000000000..70145b0ba8
--- /dev/null
+++ b/community/kodi/remove-filewrap.patch
@@ -0,0 +1,40 @@
+--- a/xbmc/utils/posix/PosixInterfaceForCLog.cpp.orig
++++ b/xbmc/utils/posix/PosixInterfaceForCLog.cpp
+@@ -28,10 +28,6 @@
+ #include "android/activity/XBMCApp.h"
+ #endif // TARGET_ANDROID
+
+-struct FILEWRAP : public FILE
+-{};
+-
+-
+ CPosixInterfaceForCLog::CPosixInterfaceForCLog() :
+ m_file(NULL)
+ { }
+@@ -50,7 +46,7 @@
+ (void)remove(backupOldLogToFilename.c_str()); // if it's failed, try to continue
+ (void)rename(logFilename.c_str(), backupOldLogToFilename.c_str()); // if it's failed, try to continue
+
+- m_file = (FILEWRAP*)fopen(logFilename.c_str(), "wb");
++ m_file = fopen(logFilename.c_str(), "wb");
+ if (!m_file)
+ return false; // error, can't open log file
+
+--- a/xbmc/utils/posix/PosixInterfaceForCLog.h.orig
++++ b/xbmc/utils/posix/PosixInterfaceForCLog.h
+@@ -21,8 +21,6 @@
+
+ #include <string>
+
+-struct FILEWRAP; // forward declaration, wrapper for FILE
+-
+ class CPosixInterfaceForCLog
+ {
+ public:
+@@ -34,5 +32,5 @@
+ void PrintDebugString(const std::string& debugString);
+ static void GetCurrentLocalTime(int& hour, int& minute, int& second);
+ private:
+- FILEWRAP* m_file;
++ FILE * m_file;
+ };
diff --git a/community/kodi/set-default-stacksize.patch b/community/kodi/set-default-stacksize.patch
new file mode 100644
index 0000000000..8a79215f8b
--- /dev/null
+++ b/community/kodi/set-default-stacksize.patch
@@ -0,0 +1,10 @@
+--- ./xbmc/threads/platform/pthreads/ThreadImpl.cpp.orig
++++ ./xbmc/threads/platform/pthreads/ThreadImpl.cpp
+@@ -42,6 +42,7 @@
+ {
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
++ if (!stacksize) stacksize = 1024*1024;
+ #if !defined(TARGET_ANDROID) // http://code.google.com/p/android/issues/detail?id=7808
+ if (stacksize > PTHREAD_STACK_MIN)
+ pthread_attr_setstacksize(&attr, stacksize);