diff --git a/packages/mediacenter/xbmc-theme-Confluence/meta b/packages/mediacenter/xbmc-theme-Confluence/meta
index 6d9d734eeb..42d29517cb 100644
--- a/packages/mediacenter/xbmc-theme-Confluence/meta
+++ b/packages/mediacenter/xbmc-theme-Confluence/meta
@@ -19,7 +19,7 @@
################################################################################
PKG_NAME="xbmc-theme-Confluence"
-PKG_VERSION="f76c547"
+PKG_VERSION="1fef727"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="GPL"
diff --git a/packages/mediacenter/xbmc/meta b/packages/mediacenter/xbmc/meta
index de15e7a55d..d2891ea9f4 100644
--- a/packages/mediacenter/xbmc/meta
+++ b/packages/mediacenter/xbmc/meta
@@ -19,7 +19,7 @@
################################################################################
PKG_NAME="xbmc"
-PKG_VERSION="f76c547"
+PKG_VERSION="1fef727"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="GPL"
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-001-add_support_to_specify_GIT_REV-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-001-add_support_to_specify_GIT_REV-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-f76c547-001-add_support_to_specify_GIT_REV-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-1fef727-001-add_support_to_specify_GIT_REV-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-303-fix_libdvd_xFLAGS-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-303-fix_libdvd_xFLAGS-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-f76c547-303-fix_libdvd_xFLAGS-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-1fef727-303-fix_libdvd_xFLAGS-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-311-fix_rsxs_build-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-311-fix_rsxs_build-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-f76c547-311-fix_rsxs_build-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-1fef727-311-fix_rsxs_build-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-402-enable_yasm_in_ffmpeg-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-402-enable_yasm_in_ffmpeg-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-f76c547-402-enable_yasm_in_ffmpeg-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-1fef727-402-enable_yasm_in_ffmpeg-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-404-add_lame_check-0.6.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-404-add_lame_check-0.6.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-f76c547-404-add_lame_check-0.6.patch
rename to packages/mediacenter/xbmc/patches/xbmc-1fef727-404-add_lame_check-0.6.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-f76c547-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-1fef727-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-452-change_lcd_content-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-452-change_lcd_content-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-f76c547-452-change_lcd_content-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-1fef727-452-change_lcd_content-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-453-add_openelec.tv_RSS_news-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-453-add_openelec.tv_RSS_news-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-f76c547-453-add_openelec.tv_RSS_news-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-1fef727-453-add_openelec.tv_RSS_news-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-454-disable_backslash-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-454-disable_backslash-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-f76c547-454-disable_backslash-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-1fef727-454-disable_backslash-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-457-fix_connection_check-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-457-fix_connection_check-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-f76c547-457-fix_connection_check-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-1fef727-457-fix_connection_check-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-463-add_remote_devinput-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-463-add_remote_devinput-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-f76c547-463-add_remote_devinput-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-1fef727-463-add_remote_devinput-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-464-add_eject_keymapping_for_lirc-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-464-add_eject_keymapping_for_lirc-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-f76c547-464-add_eject_keymapping_for_lirc-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-1fef727-464-add_eject_keymapping_for_lirc-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-801-cec-PR570.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-801-cec-PR570.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-f76c547-801-cec-PR570.patch
rename to packages/mediacenter/xbmc/patches/xbmc-1fef727-801-cec-PR570.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-902.01-xvba_support-eb7c9d5b4988582b041b97c88903e1d771bdbc33.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-902.01-xvba_support-4bf8428afb48c6495f8bc1a1f55f82aa5f722021.patch
similarity index 83%
rename from packages/mediacenter/xbmc/patches/xbmc-f76c547-902.01-xvba_support-eb7c9d5b4988582b041b97c88903e1d771bdbc33.patch
rename to packages/mediacenter/xbmc/patches/xbmc-1fef727-902.01-xvba_support-4bf8428afb48c6495f8bc1a1f55f82aa5f722021.patch
index c16d5aee65..78d6f4042d 100644
--- a/packages/mediacenter/xbmc/patches/xbmc-f76c547-902.01-xvba_support-eb7c9d5b4988582b041b97c88903e1d771bdbc33.patch
+++ b/packages/mediacenter/xbmc/patches/xbmc-1fef727-902.01-xvba_support-4bf8428afb48c6495f8bc1a1f55f82aa5f722021.patch
@@ -1,8 +1,7 @@
-diff --git a/configure.in b/configure.in
-index e1cc9d2..d0d3beb 100755
---- a/configure.in
-+++ b/configure.in
-@@ -98,6 +98,8 @@ vaapi_not_found="== Could not find libva. VAAPI support disabled. =="
+diff -Naur xbmc-1fef727/configure.in xbmc-1fef727.patch/configure.in
+--- xbmc-1fef727/configure.in 2012-02-07 12:47:09.000000000 +0100
++++ xbmc-1fef727.patch/configure.in 2012-02-07 14:30:17.968097582 +0100
+@@ -98,6 +98,8 @@
vaapi_disabled="== VAAPI support manually disabled. =="
crystalhd_not_found="== Could not find libcrystalhd. CrystalHD support disabled. =="
crystalhd_disabled="== CrystalHD support manually disabled. =="
@@ -11,7 +10,7 @@ index e1cc9d2..d0d3beb 100755
vdadecoder_enabled="== VDADecoder support enabled. =="
vdadecoder_disabled="== VDADecoder support manually disabled. =="
vtbdecoder_enabled="== VTBDecoder support enabled. =="
-@@ -204,6 +206,12 @@ AC_ARG_ENABLE([crystalhd],
+@@ -204,6 +206,12 @@
[enable CrystalHD decoding (default is auto)])],
[use_crystalhd=$enableval],
[use_crystalhd=auto])
@@ -24,7 +23,7 @@ index e1cc9d2..d0d3beb 100755
AC_ARG_ENABLE([vdadecoder],
[AS_HELP_STRING([--enable-vdadecoder],
-@@ -1382,6 +1390,38 @@ else
+@@ -1382,6 +1390,38 @@
USE_CRYSTALHD=0
fi
@@ -63,7 +62,7 @@ index e1cc9d2..d0d3beb 100755
# VDADecoder
if test "x$use_vdadecoder" != "xno"; then
if test "$host_vendor" = "apple" ; then
-@@ -1578,6 +1618,12 @@ else
+@@ -1578,6 +1618,12 @@
final_message="$final_message\n CrystalHD:\tNo"
fi
@@ -76,7 +75,7 @@ index e1cc9d2..d0d3beb 100755
if test "x$use_vdadecoder" != "xno"; then
final_message="$final_message\n VDADecoder:\tYes"
else
-@@ -1952,6 +1998,7 @@ AC_SUBST(USE_OPENGLES)
+@@ -1943,6 +1989,7 @@
AC_SUBST(USE_VDPAU)
AC_SUBST(USE_VAAPI)
AC_SUBST(USE_CRYSTALHD)
@@ -84,7 +83,7 @@ index e1cc9d2..d0d3beb 100755
AC_SUBST(USE_LIBSMBCLIENT)
AC_SUBST(USE_LIBNFS)
AC_SUBST(USE_LIBAFPCLIENT)
-@@ -2094,6 +2141,7 @@ XB_CONFIG_MODULE([lib/ffmpeg], [
+@@ -2085,6 +2132,7 @@
--enable-gpl \
`if test "x$use_vdpau" != "xno"; then echo --enable-vdpau; else echo --disable-vdpau; fi` \
`if test "x$use_vaapi" != "xno"; then echo --enable-vaapi; else echo --disable-vaapi; fi` \
@@ -92,11 +91,10 @@ index e1cc9d2..d0d3beb 100755
--enable-protocol=http \
--enable-pthreads \
--enable-runtime-cpudetect \
-diff --git a/language/English/strings.xml b/language/English/strings.xml
-index 090a1b9..7a976cf 100644
---- a/language/English/strings.xml
-+++ b/language/English/strings.xml
-@@ -1232,6 +1232,8 @@
+diff -Naur xbmc-1fef727/language/English/strings.xml xbmc-1fef727.patch/language/English/strings.xml
+--- xbmc-1fef727/language/English/strings.xml 2012-02-07 12:47:05.000000000 +0100
++++ xbmc-1fef727.patch/language/English/strings.xml 2012-02-07 14:30:17.970097621 +0100
+@@ -1230,6 +1230,8 @@
Allow hardware acceleration (OpenMax)
Pixel Shaders
Allow hardware acceleration (VideoToolbox)
@@ -105,53 +103,10 @@ index 090a1b9..7a976cf 100644
A/V sync method
Audio clock
-diff --git a/lib/UnrarXLib/extract.cpp b/lib/UnrarXLib/extract.cpp
-index b4a8091..da60857 100644
---- a/lib/UnrarXLib/extract.cpp
-+++ b/lib/UnrarXLib/extract.cpp
-@@ -1,9 +1,5 @@
- #include "rar.hpp"
- #include "Util.h"
--#ifdef _LINUX
--#include "XSyncUtils.h"
--#include "XEventUtils.h"
--#endif
-
- // a cautious wrapper around strncpy
- char *strncpy_null_terminated(char *dest, const char *src, size_t n)
-diff --git a/lib/UnrarXLib/unpack.cpp b/lib/UnrarXLib/unpack.cpp
-index 265b54f..bc2f220 100644
---- a/lib/UnrarXLib/unpack.cpp
-+++ b/lib/UnrarXLib/unpack.cpp
-@@ -8,11 +8,6 @@
- #include "unpack20.cpp"
- #endif
-
--#ifdef _LINUX
--#include "XSyncUtils.h"
--#include "XEventUtils.h"
--#endif
--
- Unpack::Unpack(ComprDataIO *DataIO)
- {
- UnpIO=DataIO;
-diff --git a/lib/UnrarXLib/unpack15.cpp b/lib/UnrarXLib/unpack15.cpp
-index e1b5f10..725e2be 100644
---- a/lib/UnrarXLib/unpack15.cpp
-+++ b/lib/UnrarXLib/unpack15.cpp
-@@ -1,7 +1,3 @@
--#ifdef _LINUX
--#include "XSyncUtils.h"
--#endif
--
- #define STARTL1 2
- static unsigned int DecL1[]={0x8000,0xa000,0xc000,0xd000,0xe000,0xea00,
- 0xee00,0xf000,0xf200,0xf200,0xffff};
-diff --git a/lib/ffmpeg/configure b/lib/ffmpeg/configure
-index fec801c..fc73296 100755
---- a/lib/ffmpeg/configure
-+++ b/lib/ffmpeg/configure
-@@ -111,6 +111,7 @@ Configuration options:
+diff -Naur xbmc-1fef727/lib/ffmpeg/configure xbmc-1fef727.patch/lib/ffmpeg/configure
+--- xbmc-1fef727/lib/ffmpeg/configure 2012-02-07 12:46:58.000000000 +0100
++++ xbmc-1fef727.patch/lib/ffmpeg/configure 2012-02-07 14:30:17.994098094 +0100
+@@ -111,6 +111,7 @@
--disable-vaapi disable VAAPI code
--disable-vdpau disable VDPAU code
--disable-dxva2 disable DXVA2 code
@@ -159,7 +114,7 @@ index fec801c..fc73296 100755
--enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
--enable-hardcoded-tables use hardcoded tables instead of runtime generation
--enable-memalign-hack emulate memalign, interferes with memory debuggers
-@@ -932,6 +933,7 @@ CONFIG_LIST="
+@@ -932,6 +933,7 @@
swscale_alpha
vaapi
vdpau
@@ -167,7 +122,7 @@ index fec801c..fc73296 100755
version3
x11grab
zlib
-@@ -1240,6 +1242,7 @@ h264_decoder_select="golomb h264dsp h264pred"
+@@ -1240,6 +1242,7 @@
h264_dxva2_hwaccel_deps="dxva2api_h"
h264_dxva2_hwaccel_select="dxva2 h264_decoder"
h264_vaapi_hwaccel_select="vaapi"
@@ -175,7 +130,7 @@ index fec801c..fc73296 100755
h264_vdpau_decoder_select="vdpau h264_decoder"
imc_decoder_select="fft mdct"
jpegls_decoder_select="golomb"
-@@ -1263,6 +1266,7 @@ mpeg2_dxva2_hwaccel_deps="dxva2api_h"
+@@ -1263,6 +1266,7 @@
mpeg2_dxva2_hwaccel_select="dxva2 mpeg2video_decoder"
mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
@@ -183,7 +138,7 @@ index fec801c..fc73296 100755
mpeg4_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h vdpau_mpeg4_support"
mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
-@@ -1306,6 +1310,7 @@ vc1_decoder_select="h263_decoder"
+@@ -1306,6 +1310,7 @@
vc1_dxva2_hwaccel_deps="dxva2api_h DXVA_PictureParameters_wDecodedPictureIndex"
vc1_dxva2_hwaccel_select="dxva2 vc1_decoder"
vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
@@ -191,7 +146,7 @@ index fec801c..fc73296 100755
vc1_vdpau_decoder_select="vdpau vc1_decoder"
vorbis_decoder_select="mdct"
vorbis_encoder_select="mdct"
-@@ -1327,12 +1332,14 @@ wmv3_decoder_select="vc1_decoder"
+@@ -1327,12 +1332,14 @@
wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
@@ -206,7 +161,7 @@ index fec801c..fc73296 100755
vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
# parsers
-@@ -2762,6 +2769,7 @@ check_header sys/select.h
+@@ -2762,6 +2769,7 @@
check_header termios.h
check_header vdpau/vdpau.h
check_header vdpau/vdpau_x11.h
@@ -214,64 +169,10 @@ index fec801c..fc73296 100755
check_cpp_condition vdpau/vdpau.h "defined(VDP_DECODER_PROFILE_MPEG4_PART2_SP)" && enable vdpau_mpeg4_support
check_header X11/extensions/XvMClib.h
-diff --git a/lib/ffmpeg/libavcodec/Makefile b/lib/ffmpeg/libavcodec/Makefile
-index 6a0a05b..65cca69 100644
---- a/lib/ffmpeg/libavcodec/Makefile
-+++ b/lib/ffmpeg/libavcodec/Makefile
-@@ -3,7 +3,7 @@ include $(SUBDIR)../config.mak
- NAME = avcodec
- FFLIBS = avcore avutil
-
--HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h xvmc.h
-+HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h xvmc.h xvba.h
-
- OBJS = allcodecs.o \
- audioconvert.o \
-@@ -43,6 +43,7 @@ RDFT-OBJS-$(CONFIG_HARDCODED_TABLES) += sin_tables.o
- OBJS-$(CONFIG_RDFT) += rdft.o $(RDFT-OBJS-yes)
- OBJS-$(CONFIG_VAAPI) += vaapi.o
- OBJS-$(CONFIG_VDPAU) += vdpau.o
-+OBJS-$(CONFIG_XVBA) += xvba.o
-
- # decoders/encoders/hardware accelerators
- OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o
-@@ -169,6 +170,7 @@ OBJS-$(CONFIG_H264_DECODER) += h264.o \
- mpegvideo.o error_resilience.o
- OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o
- OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o
-+OBJS-$(CONFIG_H264_XVBA_HWACCEL) += xvba_h264.o
- OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o
- OBJS-$(CONFIG_HUFFYUV_ENCODER) += huffyuv.o
- OBJS-$(CONFIG_IDCIN_DECODER) += idcinvideo.o
-@@ -246,6 +248,7 @@ OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpegvideo_enc.o \
- mpegvideo.o error_resilience.o
- OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o
- OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o
-+OBJS-$(CONFIG_MPEG2_XVBA_HWACCEL) += xvba_mpeg2.o
- OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12.o mpeg12data.o \
- mpegvideo.o error_resilience.o
- OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpegvideo_enc.o \
-@@ -379,6 +382,7 @@ OBJS-$(CONFIG_VC1_DECODER) += vc1dec.o vc1.o vc1data.o vc1dsp.o \
- intrax8.o intrax8dsp.o
- OBJS-$(CONFIG_VC1_DXVA2_HWACCEL) += dxva2_vc1.o
- OBJS-$(CONFIG_VC1_VAAPI_HWACCEL) += vaapi_vc1.o
-+OBJS-$(CONFIG_VC1_XVBA_HWACCEL) += xvba_vc1.o
- OBJS-$(CONFIG_VCR1_DECODER) += vcr1.o
- OBJS-$(CONFIG_VCR1_ENCODER) += vcr1.o
- OBJS-$(CONFIG_VMDAUDIO_DECODER) += vmdav.o
-@@ -647,6 +651,7 @@ SKIPHEADERS-$(CONFIG_DXVA2) += dxva2.h dxva2_internal.h
- SKIPHEADERS-$(CONFIG_LIBDIRAC) += libdirac.h
- SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h
- SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h
-+SKIPHEADERS-$(CONFIG_XVBA) += xvba_internal.h
- SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h
- SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h
- SKIPHEADERS += mpegaudio3.h
-diff --git a/lib/ffmpeg/libavcodec/allcodecs.c b/lib/ffmpeg/libavcodec/allcodecs.c
-index 04c5c6a..38b8791 100644
---- a/lib/ffmpeg/libavcodec/allcodecs.c
-+++ b/lib/ffmpeg/libavcodec/allcodecs.c
-@@ -57,13 +57,17 @@ void avcodec_register_all(void)
+diff -Naur xbmc-1fef727/lib/ffmpeg/libavcodec/allcodecs.c xbmc-1fef727.patch/lib/ffmpeg/libavcodec/allcodecs.c
+--- xbmc-1fef727/lib/ffmpeg/libavcodec/allcodecs.c 2012-02-07 12:47:01.000000000 +0100
++++ xbmc-1fef727.patch/lib/ffmpeg/libavcodec/allcodecs.c 2012-02-07 14:30:17.996098134 +0100
+@@ -57,13 +57,17 @@
REGISTER_HWACCEL (H263_VAAPI, h263_vaapi);
REGISTER_HWACCEL (H264_DXVA2, h264_dxva2);
REGISTER_HWACCEL (H264_VAAPI, h264_vaapi);
@@ -289,11 +190,10 @@ index 04c5c6a..38b8791 100644
/* video codecs */
REGISTER_ENCODER (A64MULTI, a64multi);
-diff --git a/lib/ffmpeg/libavcodec/h264.c b/lib/ffmpeg/libavcodec/h264.c
-index 0e002ce..d054b20 100644
---- a/lib/ffmpeg/libavcodec/h264.c
-+++ b/lib/ffmpeg/libavcodec/h264.c
-@@ -55,6 +55,7 @@ static const uint8_t div6[52]={
+diff -Naur xbmc-1fef727/lib/ffmpeg/libavcodec/h264.c xbmc-1fef727.patch/lib/ffmpeg/libavcodec/h264.c
+--- xbmc-1fef727/lib/ffmpeg/libavcodec/h264.c 2012-02-07 12:47:00.000000000 +0100
++++ xbmc-1fef727.patch/lib/ffmpeg/libavcodec/h264.c 2012-02-07 14:30:17.998098174 +0100
+@@ -55,6 +55,7 @@
static const enum PixelFormat hwaccel_pixfmt_list_h264_jpeg_420[] = {
PIX_FMT_DXVA2_VLD,
PIX_FMT_VAAPI_VLD,
@@ -301,11 +201,62 @@ index 0e002ce..d054b20 100644
PIX_FMT_YUVJ420P,
PIX_FMT_NONE
};
-diff --git a/lib/ffmpeg/libavcodec/mpegvideo.c b/lib/ffmpeg/libavcodec/mpegvideo.c
-index 31642e6..56113c7 100644
---- a/lib/ffmpeg/libavcodec/mpegvideo.c
-+++ b/lib/ffmpeg/libavcodec/mpegvideo.c
-@@ -117,6 +117,7 @@ const enum PixelFormat ff_pixfmt_list_420[] = {
+diff -Naur xbmc-1fef727/lib/ffmpeg/libavcodec/Makefile xbmc-1fef727.patch/lib/ffmpeg/libavcodec/Makefile
+--- xbmc-1fef727/lib/ffmpeg/libavcodec/Makefile 2012-02-07 12:46:59.000000000 +0100
++++ xbmc-1fef727.patch/lib/ffmpeg/libavcodec/Makefile 2012-02-07 14:30:17.996098134 +0100
+@@ -3,7 +3,7 @@
+ NAME = avcodec
+ FFLIBS = avcore avutil
+
+-HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h xvmc.h
++HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h xvmc.h xvba.h
+
+ OBJS = allcodecs.o \
+ audioconvert.o \
+@@ -43,6 +43,7 @@
+ OBJS-$(CONFIG_RDFT) += rdft.o $(RDFT-OBJS-yes)
+ OBJS-$(CONFIG_VAAPI) += vaapi.o
+ OBJS-$(CONFIG_VDPAU) += vdpau.o
++OBJS-$(CONFIG_XVBA) += xvba.o
+
+ # decoders/encoders/hardware accelerators
+ OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o
+@@ -169,6 +170,7 @@
+ mpegvideo.o error_resilience.o
+ OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o
+ OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o
++OBJS-$(CONFIG_H264_XVBA_HWACCEL) += xvba_h264.o
+ OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o
+ OBJS-$(CONFIG_HUFFYUV_ENCODER) += huffyuv.o
+ OBJS-$(CONFIG_IDCIN_DECODER) += idcinvideo.o
+@@ -246,6 +248,7 @@
+ mpegvideo.o error_resilience.o
+ OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o
+ OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o
++OBJS-$(CONFIG_MPEG2_XVBA_HWACCEL) += xvba_mpeg2.o
+ OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12.o mpeg12data.o \
+ mpegvideo.o error_resilience.o
+ OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpegvideo_enc.o \
+@@ -379,6 +382,7 @@
+ intrax8.o intrax8dsp.o
+ OBJS-$(CONFIG_VC1_DXVA2_HWACCEL) += dxva2_vc1.o
+ OBJS-$(CONFIG_VC1_VAAPI_HWACCEL) += vaapi_vc1.o
++OBJS-$(CONFIG_VC1_XVBA_HWACCEL) += xvba_vc1.o
+ OBJS-$(CONFIG_VCR1_DECODER) += vcr1.o
+ OBJS-$(CONFIG_VCR1_ENCODER) += vcr1.o
+ OBJS-$(CONFIG_VMDAUDIO_DECODER) += vmdav.o
+@@ -647,6 +651,7 @@
+ SKIPHEADERS-$(CONFIG_LIBDIRAC) += libdirac.h
+ SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h
+ SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h
++SKIPHEADERS-$(CONFIG_XVBA) += xvba_internal.h
+ SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h
+ SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h
+ SKIPHEADERS += mpegaudio3.h
+diff -Naur xbmc-1fef727/lib/ffmpeg/libavcodec/mpegvideo.c xbmc-1fef727.patch/lib/ffmpeg/libavcodec/mpegvideo.c
+--- xbmc-1fef727/lib/ffmpeg/libavcodec/mpegvideo.c 2012-02-07 12:46:59.000000000 +0100
++++ xbmc-1fef727.patch/lib/ffmpeg/libavcodec/mpegvideo.c 2012-02-07 14:30:18.000098213 +0100
+@@ -117,6 +117,7 @@
const enum PixelFormat ff_hwaccel_pixfmt_list_420[] = {
PIX_FMT_DXVA2_VLD,
PIX_FMT_VAAPI_VLD,
@@ -313,11 +264,9 @@ index 31642e6..56113c7 100644
PIX_FMT_YUV420P,
PIX_FMT_NONE
};
-diff --git a/lib/ffmpeg/libavcodec/xvba.c b/lib/ffmpeg/libavcodec/xvba.c
-new file mode 100644
-index 0000000..48fd905
---- /dev/null
-+++ b/lib/ffmpeg/libavcodec/xvba.c
+diff -Naur xbmc-1fef727/lib/ffmpeg/libavcodec/xvba.c xbmc-1fef727.patch/lib/ffmpeg/libavcodec/xvba.c
+--- xbmc-1fef727/lib/ffmpeg/libavcodec/xvba.c 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/lib/ffmpeg/libavcodec/xvba.c 2012-02-07 14:30:18.001098232 +0100
@@ -0,0 +1,65 @@
+/*
+ * HW decode acceleration for MPEG-2, H.264 and VC-1
@@ -384,11 +333,9 @@ index 0000000..48fd905
+ render->num_slices++;
+}
+
-diff --git a/lib/ffmpeg/libavcodec/xvba.h b/lib/ffmpeg/libavcodec/xvba.h
-new file mode 100644
-index 0000000..a62d649
---- /dev/null
-+++ b/lib/ffmpeg/libavcodec/xvba.h
+diff -Naur xbmc-1fef727/lib/ffmpeg/libavcodec/xvba.h xbmc-1fef727.patch/lib/ffmpeg/libavcodec/xvba.h
+--- xbmc-1fef727/lib/ffmpeg/libavcodec/xvba.h 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/lib/ffmpeg/libavcodec/xvba.h 2012-02-07 14:30:18.001098232 +0100
@@ -0,0 +1,65 @@
+/*
+ * HW decode acceleration for MPEG-2, H.264 and VC-1
@@ -455,11 +402,9 @@ index 0000000..a62d649
+};
+
+#endif /* AVCODEC_XVBA_H */
-diff --git a/lib/ffmpeg/libavcodec/xvba_h264.c b/lib/ffmpeg/libavcodec/xvba_h264.c
-new file mode 100644
-index 0000000..0d98dea
---- /dev/null
-+++ b/lib/ffmpeg/libavcodec/xvba_h264.c
+diff -Naur xbmc-1fef727/lib/ffmpeg/libavcodec/xvba_h264.c xbmc-1fef727.patch/lib/ffmpeg/libavcodec/xvba_h264.c
+--- xbmc-1fef727/lib/ffmpeg/libavcodec/xvba_h264.c 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/lib/ffmpeg/libavcodec/xvba_h264.c 2012-02-07 14:30:18.002098252 +0100
@@ -0,0 +1,180 @@
+/*
+ * H.264 HW decode acceleration through XVBA
@@ -641,11 +586,9 @@ index 0000000..0d98dea
+ .decode_slice = decode_slice,
+ .priv_data_size = 0,
+};
-diff --git a/lib/ffmpeg/libavcodec/xvba_internal.h b/lib/ffmpeg/libavcodec/xvba_internal.h
-new file mode 100644
-index 0000000..9653f85
---- /dev/null
-+++ b/lib/ffmpeg/libavcodec/xvba_internal.h
+diff -Naur xbmc-1fef727/lib/ffmpeg/libavcodec/xvba_internal.h xbmc-1fef727.patch/lib/ffmpeg/libavcodec/xvba_internal.h
+--- xbmc-1fef727/lib/ffmpeg/libavcodec/xvba_internal.h 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/lib/ffmpeg/libavcodec/xvba_internal.h 2012-02-07 14:30:18.002098252 +0100
@@ -0,0 +1,24 @@
+/*
+ * HW decode acceleration for MPEG-2, H.264 and VC-1
@@ -671,11 +614,9 @@ index 0000000..9653f85
+
+int ff_xvba_translate_profile(int profile);
+void ff_xvba_add_slice_data(struct xvba_render_state *render, const uint8_t *buffer, uint32_t size);
-diff --git a/lib/ffmpeg/libavcodec/xvba_mpeg2.c b/lib/ffmpeg/libavcodec/xvba_mpeg2.c
-new file mode 100644
-index 0000000..552ef95
---- /dev/null
-+++ b/lib/ffmpeg/libavcodec/xvba_mpeg2.c
+diff -Naur xbmc-1fef727/lib/ffmpeg/libavcodec/xvba_mpeg2.c xbmc-1fef727.patch/lib/ffmpeg/libavcodec/xvba_mpeg2.c
+--- xbmc-1fef727/lib/ffmpeg/libavcodec/xvba_mpeg2.c 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/lib/ffmpeg/libavcodec/xvba_mpeg2.c 2012-02-07 14:30:18.003098272 +0100
@@ -0,0 +1,52 @@
+/*
+ * MPEG-2 HW decode acceleration through XVBA
@@ -729,11 +670,9 @@ index 0000000..552ef95
+ .decode_slice = decode_slice,
+ .priv_data_size = 0,
+};
-diff --git a/lib/ffmpeg/libavcodec/xvba_vc1.c b/lib/ffmpeg/libavcodec/xvba_vc1.c
-new file mode 100644
-index 0000000..e7b9211
---- /dev/null
-+++ b/lib/ffmpeg/libavcodec/xvba_vc1.c
+diff -Naur xbmc-1fef727/lib/ffmpeg/libavcodec/xvba_vc1.c xbmc-1fef727.patch/lib/ffmpeg/libavcodec/xvba_vc1.c
+--- xbmc-1fef727/lib/ffmpeg/libavcodec/xvba_vc1.c 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/lib/ffmpeg/libavcodec/xvba_vc1.c 2012-02-07 14:30:18.003098272 +0100
@@ -0,0 +1,194 @@
+/*
+ * VC-1 HW decode acceleration through XVBA
@@ -929,10 +868,9 @@ index 0000000..e7b9211
+ .decode_slice = decode_slice,
+ .priv_data_size = 0,
+};
-diff --git a/lib/ffmpeg/libavcodec/xvmc_internal.h b/lib/ffmpeg/libavcodec/xvmc_internal.h
-index 9bb8909..a64d6ee 100644
---- a/lib/ffmpeg/libavcodec/xvmc_internal.h
-+++ b/lib/ffmpeg/libavcodec/xvmc_internal.h
+diff -Naur xbmc-1fef727/lib/ffmpeg/libavcodec/xvmc_internal.h xbmc-1fef727.patch/lib/ffmpeg/libavcodec/xvmc_internal.h
+--- xbmc-1fef727/lib/ffmpeg/libavcodec/xvmc_internal.h 2012-02-07 12:47:01.000000000 +0100
++++ xbmc-1fef727.patch/lib/ffmpeg/libavcodec/xvmc_internal.h 2012-02-07 14:30:18.004098292 +0100
@@ -1,5 +1,7 @@
/*
- * XVideo Motion Compensation internal functions
@@ -942,11 +880,10 @@ index 9bb8909..a64d6ee 100644
*
* This file is part of FFmpeg.
*
-diff --git a/lib/ffmpeg/libavutil/pixdesc.c b/lib/ffmpeg/libavutil/pixdesc.c
-index 83aa8b0..fcc20d0 100644
---- a/lib/ffmpeg/libavutil/pixdesc.c
-+++ b/lib/ffmpeg/libavutil/pixdesc.c
-@@ -717,6 +717,12 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
+diff -Naur xbmc-1fef727/lib/ffmpeg/libavutil/pixdesc.c xbmc-1fef727.patch/lib/ffmpeg/libavutil/pixdesc.c
+--- xbmc-1fef727/lib/ffmpeg/libavutil/pixdesc.c 2012-02-07 12:46:58.000000000 +0100
++++ xbmc-1fef727.patch/lib/ffmpeg/libavutil/pixdesc.c 2012-02-07 14:30:18.005098312 +0100
+@@ -717,6 +717,12 @@
.log2_chroma_h = 1,
.flags = PIX_FMT_HWACCEL,
},
@@ -959,11 +896,10 @@ index 83aa8b0..fcc20d0 100644
[PIX_FMT_YUV420P16LE] = {
.name = "yuv420p16le",
.nb_components= 3,
-diff --git a/lib/ffmpeg/libavutil/pixfmt.h b/lib/ffmpeg/libavutil/pixfmt.h
-index 8ec91c8..4803dd7 100644
---- a/lib/ffmpeg/libavutil/pixfmt.h
-+++ b/lib/ffmpeg/libavutil/pixfmt.h
-@@ -127,6 +127,7 @@ enum PixelFormat {
+diff -Naur xbmc-1fef727/lib/ffmpeg/libavutil/pixfmt.h xbmc-1fef727.patch/lib/ffmpeg/libavutil/pixfmt.h
+--- xbmc-1fef727/lib/ffmpeg/libavutil/pixfmt.h 2012-02-07 12:46:58.000000000 +0100
++++ xbmc-1fef727.patch/lib/ffmpeg/libavutil/pixfmt.h 2012-02-07 14:30:18.005098312 +0100
+@@ -127,6 +127,7 @@
PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
PIX_FMT_VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer
@@ -971,11 +907,49 @@ index 8ec91c8..4803dd7 100644
PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0
PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0
-diff --git a/xbmc/ApplicationMessenger.cpp b/xbmc/ApplicationMessenger.cpp
-index e95ecdc..892948a 100644
---- a/xbmc/ApplicationMessenger.cpp
-+++ b/xbmc/ApplicationMessenger.cpp
-@@ -72,7 +72,7 @@
+diff -Naur xbmc-1fef727/lib/UnrarXLib/extract.cpp xbmc-1fef727.patch/lib/UnrarXLib/extract.cpp
+--- xbmc-1fef727/lib/UnrarXLib/extract.cpp 2012-02-07 12:46:53.000000000 +0100
++++ xbmc-1fef727.patch/lib/UnrarXLib/extract.cpp 2012-02-07 14:30:17.982097858 +0100
+@@ -1,9 +1,5 @@
+ #include "rar.hpp"
+ #include "Util.h"
+-#ifdef _LINUX
+-#include "XSyncUtils.h"
+-#include "XEventUtils.h"
+-#endif
+
+ // a cautious wrapper around strncpy
+ char *strncpy_null_terminated(char *dest, const char *src, size_t n)
+diff -Naur xbmc-1fef727/lib/UnrarXLib/unpack15.cpp xbmc-1fef727.patch/lib/UnrarXLib/unpack15.cpp
+--- xbmc-1fef727/lib/UnrarXLib/unpack15.cpp 2012-02-07 12:46:53.000000000 +0100
++++ xbmc-1fef727.patch/lib/UnrarXLib/unpack15.cpp 2012-02-07 14:30:17.992098054 +0100
+@@ -1,7 +1,3 @@
+-#ifdef _LINUX
+-#include "XSyncUtils.h"
+-#endif
+-
+ #define STARTL1 2
+ static unsigned int DecL1[]={0x8000,0xa000,0xc000,0xd000,0xe000,0xea00,
+ 0xee00,0xf000,0xf200,0xf200,0xffff};
+diff -Naur xbmc-1fef727/lib/UnrarXLib/unpack.cpp xbmc-1fef727.patch/lib/UnrarXLib/unpack.cpp
+--- xbmc-1fef727/lib/UnrarXLib/unpack.cpp 2012-02-07 12:46:53.000000000 +0100
++++ xbmc-1fef727.patch/lib/UnrarXLib/unpack.cpp 2012-02-07 14:30:17.991098035 +0100
+@@ -8,11 +8,6 @@
+ #include "unpack20.cpp"
+ #endif
+
+-#ifdef _LINUX
+-#include "XSyncUtils.h"
+-#include "XEventUtils.h"
+-#endif
+-
+ Unpack::Unpack(ComprDataIO *DataIO)
+ {
+ UnpIO=DataIO;
+diff -Naur xbmc-1fef727/xbmc/ApplicationMessenger.cpp xbmc-1fef727.patch/xbmc/ApplicationMessenger.cpp
+--- xbmc-1fef727/xbmc/ApplicationMessenger.cpp 2012-02-07 12:46:48.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/ApplicationMessenger.cpp 2012-02-07 14:30:18.007098350 +0100
+@@ -73,7 +73,7 @@
using namespace std;
@@ -984,10 +958,9 @@ index e95ecdc..892948a 100644
{
m_msg.dwMessage = msg.dwMessage;
m_msg.dwParam1 = msg.dwParam1;
-diff --git a/xbmc/cdrip/CDDAReader.cpp b/xbmc/cdrip/CDDAReader.cpp
-index 16fa7b6..6c242d8 100644
---- a/xbmc/cdrip/CDDAReader.cpp
-+++ b/xbmc/cdrip/CDDAReader.cpp
+diff -Naur xbmc-1fef727/xbmc/cdrip/CDDAReader.cpp xbmc-1fef727.patch/xbmc/cdrip/CDDAReader.cpp
+--- xbmc-1fef727/xbmc/cdrip/CDDAReader.cpp 2012-02-07 12:46:48.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cdrip/CDDAReader.cpp 2012-02-07 14:30:18.007098350 +0100
@@ -29,7 +29,7 @@
#define SECTOR_COUNT 52
@@ -997,11 +970,10 @@ index 16fa7b6..6c242d8 100644
{
m_sRipBuffer[0].pbtStream = NULL;
m_sRipBuffer[1].pbtStream = NULL;
-diff --git a/xbmc/cores/DllLoader/exports/emu_kernel32.cpp b/xbmc/cores/DllLoader/exports/emu_kernel32.cpp
-index 13a23e2..493d64d 100644
---- a/xbmc/cores/DllLoader/exports/emu_kernel32.cpp
-+++ b/xbmc/cores/DllLoader/exports/emu_kernel32.cpp
-@@ -240,15 +240,6 @@ extern "C" DWORD WINAPI dllGetCurrentProcessId(void)
+diff -Naur xbmc-1fef727/xbmc/cores/DllLoader/exports/emu_kernel32.cpp xbmc-1fef727.patch/xbmc/cores/DllLoader/exports/emu_kernel32.cpp
+--- xbmc-1fef727/xbmc/cores/DllLoader/exports/emu_kernel32.cpp 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/DllLoader/exports/emu_kernel32.cpp 2012-02-07 14:30:18.008098370 +0100
+@@ -240,15 +240,6 @@
#endif
}
@@ -1017,11 +989,10 @@ index 13a23e2..493d64d 100644
extern "C" int WINAPI dllDuplicateHandle(HANDLE hSourceProcessHandle, // handle to source process
HANDLE hSourceHandle, // handle to duplicate
HANDLE hTargetProcessHandle, // handle to target process
-diff --git a/xbmc/cores/DllLoader/exports/emu_kernel32.h b/xbmc/cores/DllLoader/exports/emu_kernel32.h
-index 2e637a7..9cc2f0b 100644
---- a/xbmc/cores/DllLoader/exports/emu_kernel32.h
-+++ b/xbmc/cores/DllLoader/exports/emu_kernel32.h
-@@ -686,7 +686,6 @@ extern "C" BOOL WINAPI dllGetProcessAffinityMask(HANDLE hProcess, LPDWORD lpProc
+diff -Naur xbmc-1fef727/xbmc/cores/DllLoader/exports/emu_kernel32.h xbmc-1fef727.patch/xbmc/cores/DllLoader/exports/emu_kernel32.h
+--- xbmc-1fef727/xbmc/cores/DllLoader/exports/emu_kernel32.h 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/DllLoader/exports/emu_kernel32.h 2012-02-07 14:30:18.009098390 +0100
+@@ -686,7 +686,6 @@
extern "C" HGLOBAL WINAPI dllLoadResource(HMODULE module, HRSRC res);
extern "C" HRSRC WINAPI dllFindResourceA(HMODULE module, LPCTSTR name, LPCTSTR type);
@@ -1029,10 +1000,9 @@ index 2e637a7..9cc2f0b 100644
extern "C" int WINAPI dllGetLocaleInfoA(LCID Locale, LCTYPE LCType, LPTSTR lpLCData, int cchData);
extern "C" UINT WINAPI dllGetConsoleCP();
extern "C" UINT WINAPI dllGetConsoleOutputCP();
-diff --git a/xbmc/cores/DummyVideoPlayer.cpp b/xbmc/cores/DummyVideoPlayer.cpp
-index f0b4aeb..47d25e4 100644
---- a/xbmc/cores/DummyVideoPlayer.cpp
-+++ b/xbmc/cores/DummyVideoPlayer.cpp
+diff -Naur xbmc-1fef727/xbmc/cores/DummyVideoPlayer.cpp xbmc-1fef727.patch/xbmc/cores/DummyVideoPlayer.cpp
+--- xbmc-1fef727/xbmc/cores/DummyVideoPlayer.cpp 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/DummyVideoPlayer.cpp 2012-02-07 14:30:18.009098390 +0100
@@ -33,7 +33,7 @@
CDummyVideoPlayer::CDummyVideoPlayer(IPlayerCallback& callback)
@@ -1042,868 +1012,10 @@ index f0b4aeb..47d25e4 100644
{
m_paused = false;
m_clock = 0;
-diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
-index 4961b7d..70f20d7 100644
---- a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
-+++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
-@@ -60,6 +60,9 @@
- VA_MICRO_VERSION == 0 && VA_SDS_VERSION < 5)))
-
- #endif
-+#ifdef HAVE_LIBXVBA
-+#include "cores/dvdplayer/DVDCodecs/Video/XVBA.h"
-+#endif
-
- #ifdef HAS_GLX
- #include
-@@ -120,6 +123,10 @@ CLinuxRendererGL::YUVBUFFER::YUVBUFFER()
- #ifdef HAVE_LIBVDPAU
- vdpau = NULL;
- #endif
-+#ifdef HAVE_LIBXVBA
-+ xvba = NULL;
-+ xvba_tmp = NULL;
-+#endif
- }
-
- CLinuxRendererGL::YUVBUFFER::~YUVBUFFER()
-@@ -159,6 +166,7 @@ CLinuxRendererGL::CLinuxRendererGL()
- m_rgbPbo = 0;
-
- m_dllSwScale = new DllSwScale;
-+ m_bValidated = false;
- }
-
- CLinuxRendererGL::~CLinuxRendererGL()
-@@ -223,7 +231,7 @@ bool CLinuxRendererGL::ValidateRenderer()
-
- void CLinuxRendererGL::ManageTextures()
- {
-- m_NumYV12Buffers = 2;
-+ m_NumYV12Buffers = 3;
- //m_iYV12RenderBuffer = 0;
- return;
- }
-@@ -568,6 +576,11 @@ void CLinuxRendererGL::Flush()
- m_bValidated = false;
- }
-
-+unsigned int CLinuxRendererGL::GetProcessorSize()
-+{
-+ return m_NumYV12Buffers;
-+}
-+
- void CLinuxRendererGL::Update(bool bPauseDrawing)
- {
- if (!m_bConfigured) return;
-@@ -729,14 +742,15 @@ unsigned int CLinuxRendererGL::PreInit()
- {
- CSingleLock lock(g_graphicsContext);
- m_bConfigured = false;
-- m_bValidated = false;
-- UnInit();
-+ if (m_bValidated)
-+ UnInit();
-+
- m_resolution = g_guiSettings.m_LookAndFeelResolution;
- if ( m_resolution == RES_WINDOW )
- m_resolution = RES_DESKTOP;
-
- m_iYV12RenderBuffer = 0;
-- m_NumYV12Buffers = 2;
-+ m_NumYV12Buffers = 3;
-
- // setup the background colour
- m_clearColour = (float)(g_advancedSettings.m_videoBlackBarColour & 0xff) / 0xff;
-@@ -816,7 +830,7 @@ void CLinuxRendererGL::UpdateVideoFilter()
- case VS_SCALINGMETHOD_LINEAR:
- SetTextureFilter(m_scalingMethod == VS_SCALINGMETHOD_NEAREST ? GL_NEAREST : GL_LINEAR);
- m_renderQuality = RQ_SINGLEPASS;
-- if (((m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI)) && m_nonLinStretch)
-+ if (((m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI) || (m_renderMethod & RENDER_XVBA)) && m_nonLinStretch)
- {
- m_pVideoFilterShader = new StretchFilterShader();
- if (!m_pVideoFilterShader->CompileAndLink())
-@@ -897,6 +911,11 @@ void CLinuxRendererGL::LoadShaders(int field)
- CLog::Log(LOGNOTICE, "GL: Using VAAPI render method");
- m_renderMethod = RENDER_VAAPI;
- }
-+ else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_XVBA)
-+ {
-+ CLog::Log(LOGNOTICE, "GL: Using XVBA render method");
-+ m_renderMethod = RENDER_XVBA;
-+ }
- else
- {
- int requestedMethod = g_guiSettings.GetInt("videoplayer.rendermethod");
-@@ -1031,6 +1050,18 @@ void CLinuxRendererGL::LoadShaders(int field)
- m_textureCreate = &CLinuxRendererGL::CreateVAAPITexture;
- m_textureDelete = &CLinuxRendererGL::DeleteVAAPITexture;
- }
-+ else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_XVBA)
-+ {
-+ m_textureUpload = &CLinuxRendererGL::UploadXVBATexture;
-+ m_textureCreate = &CLinuxRendererGL::CreateXVBATexture;
-+ m_textureDelete = &CLinuxRendererGL::DeleteXVBATexture;
-+ }
-+ else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_XVBA_YV12)
-+ {
-+ m_textureUpload = &CLinuxRendererGL::UploadXVBAyv12Texture;
-+ m_textureCreate = &CLinuxRendererGL::CreateXVBAyv12Texture;
-+ m_textureDelete = &CLinuxRendererGL::DeleteXVBAyv12Texture;
-+ }
- else
- {
- // setup default YV12 texture handlers
-@@ -1124,6 +1155,13 @@ void CLinuxRendererGL::Render(DWORD flags, int renderBuffer)
- RenderVDPAU(renderBuffer, m_currentField);
- }
- #endif
-+#ifdef HAVE_LIBXVBA
-+ else if (m_renderMethod & RENDER_XVBA)
-+ {
-+ UpdateVideoFilter();
-+ RenderXVBA(renderBuffer, m_currentField);
-+ }
-+#endif
- #ifdef HAVE_LIBVA
- else if (m_renderMethod & RENDER_VAAPI)
- {
-@@ -1597,6 +1635,77 @@ void CLinuxRendererGL::RenderVAAPI(int index, int field)
- #endif
- }
-
-+void CLinuxRendererGL::RenderXVBA(int index, int field)
-+{
-+#ifdef HAVE_LIBXVBA
-+ YUVPLANE &plane = m_buffers[index].fields[field][0];
-+
-+ glEnable(m_textureTarget);
-+ glActiveTextureARB(GL_TEXTURE0);
-+ glBindTexture(m_textureTarget, plane.id);
-+
-+ // Try some clamping or wrapping
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-+
-+ if (m_pVideoFilterShader)
-+ {
-+ GLint filter;
-+ if (!m_pVideoFilterShader->GetTextureFilter(filter))
-+ filter = m_scalingMethod == VS_SCALINGMETHOD_NEAREST ? GL_NEAREST : GL_LINEAR;
-+
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, filter);
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, filter);
-+ m_pVideoFilterShader->SetSourceTexture(0);
-+ m_pVideoFilterShader->SetWidth(m_sourceWidth);
-+ m_pVideoFilterShader->SetHeight(m_sourceHeight);
-+
-+ //disable non-linear stretch when a dvd menu is shown, parts of the menu are rendered through the overlay renderer
-+ //having non-linear stretch on breaks the alignment
-+ if (g_application.m_pPlayer && g_application.m_pPlayer->IsInMenu())
-+ m_pVideoFilterShader->SetNonLinStretch(1.0);
-+ else
-+ m_pVideoFilterShader->SetNonLinStretch(pow(g_settings.m_fPixelRatio, g_advancedSettings.m_videoNonLinStretchRatio));
-+
-+ m_pVideoFilterShader->Enable();
-+ }
-+ else
-+ {
-+ GLint filter = m_scalingMethod == VS_SCALINGMETHOD_NEAREST ? GL_NEAREST : GL_LINEAR;
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, filter);
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, filter);
-+ }
-+
-+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-+ VerifyGLState();
-+
-+ glBegin(GL_QUADS);
-+ if (m_textureTarget==GL_TEXTURE_2D)
-+ {
-+ glTexCoord2f(plane.rect.x1, plane.rect.y1); glVertex2f(m_destRect.x1, m_destRect.y1);
-+ glTexCoord2f(plane.rect.x2, plane.rect.y1); glVertex2f(m_destRect.x2, m_destRect.y1);
-+ glTexCoord2f(plane.rect.x2, plane.rect.y2); glVertex2f(m_destRect.x2, m_destRect.y2);
-+ glTexCoord2f(plane.rect.x1, plane.rect.y2); glVertex2f(m_destRect.x1, m_destRect.y2);
-+ }
-+ else
-+ {
-+ glTexCoord2f(m_destRect.x1, m_destRect.y1); glVertex4f(m_destRect.x1, m_destRect.y1, 0.0f, 0.0f);
-+ glTexCoord2f(m_destRect.x2, m_destRect.y1); glVertex4f(m_destRect.x2, m_destRect.y1, 1.0f, 0.0f);
-+ glTexCoord2f(m_destRect.x2, m_destRect.y2); glVertex4f(m_destRect.x2, m_destRect.y2, 1.0f, 1.0f);
-+ glTexCoord2f(m_destRect.x1, m_destRect.y2); glVertex4f(m_destRect.x1, m_destRect.y2, 0.0f, 1.0f);
-+ }
-+ glEnd();
-+ VerifyGLState();
-+
-+ if (m_pVideoFilterShader)
-+ m_pVideoFilterShader->Disable();
-+
-+ glBindTexture (m_textureTarget, 0);
-+ glDisable(m_textureTarget);
-+#endif
-+}
-+
-+
- void CLinuxRendererGL::RenderSoftware(int index, int field)
- {
- YUVPLANES &planes = m_buffers[index].fields[field];
-@@ -2351,6 +2460,424 @@ void CLinuxRendererGL::UploadVAAPITexture(int index)
- #endif
- }
-
-+void CLinuxRendererGL::DeleteXVBATexture(int index)
-+{
-+#ifdef HAVE_LIBXVBA
-+ YUVPLANE &plane = m_buffers[index].fields[0][1];
-+
-+ if (m_buffers[index].xvba)
-+ m_buffers[index].xvba->FinishGL();
-+
-+ SAFE_RELEASE(m_buffers[index].xvba);
-+ SAFE_RELEASE(m_buffers[index].xvba_tmp);
-+
-+ if(plane.id && glIsTexture(plane.id))
-+ glDeleteTextures(1, &plane.id);
-+ plane.id = 0;
-+ m_buffers[index].fields[0][0].id = 0;
-+
-+#endif
-+}
-+
-+
-+bool CLinuxRendererGL::CreateXVBATexture(int index)
-+{
-+#ifdef HAVE_LIBXVBA
-+ YV12Image &im = m_buffers[index].image;
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+ YUVPLANE &plane = fields[0][0];
-+ YUVPLANE &planeFallback = fields[0][1];
-+
-+ DeleteXVBATexture(index);
-+
-+ memset(&im , 0, sizeof(im));
-+ memset(&fields, 0, sizeof(fields));
-+ im.height = m_sourceHeight;
-+ im.width = m_sourceWidth;
-+
-+ for(int f = 0;fSet();
-+#endif
-+ return true;
-+}
-+
-+void CLinuxRendererGL::UploadXVBATexture(int index)
-+{
-+#ifdef HAVE_LIBXVBA
-+ XVBA::CDecoder *xvba = m_buffers[index].xvba;
-+
-+ if (m_buffers[index].xvba_tmp)
-+ {
-+ SAFE_RELEASE(m_buffers[index].xvba);
-+ xvba = m_buffers[index].xvba = m_buffers[index].xvba_tmp;
-+ m_buffers[index].xvba_tmp = NULL;
-+ }
-+
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+ YUVPLANE &planeFallback = fields[0][1];
-+ YUVPLANE &plane = fields[m_currentField][0];
-+
-+ if (!xvba)
-+ {
-+ fields[0][0].id = planeFallback.id;
-+ fields[1][0].id = planeFallback.id;
-+ fields[2][0].id = planeFallback.id;
-+ m_eventTexturesDone[index]->Set();
-+ return;
-+ }
-+
-+ XVBA_SURFACE_FLAG field;
-+ if (m_currentField == FIELD_TOP)
-+ field = XVBA_TOP_FIELD;
-+ else if (m_currentField == FIELD_BOT)
-+ field = XVBA_BOTTOM_FIELD;
-+ else
-+ field = XVBA_FRAME;
-+
-+ glEnable(m_textureTarget);
-+ if (xvba->UploadTexture(index, field, m_textureTarget) == 1)
-+ plane.id = xvba->GetTexture(index, field);
-+
-+ // crop texture
-+ CRect crop = xvba->GetCropRect();
-+ plane.rect = m_sourceRect;
-+ plane.rect.x1 += crop.x1;
-+ plane.rect.x2 -= m_sourceWidth - crop.x2;
-+ plane.rect.y1 += crop.y1;
-+ plane.rect.y2 -= m_sourceHeight - crop.y2;
-+ plane.rect.y1 /= plane.pixpertex_y;
-+ plane.rect.y2 /= plane.pixpertex_y;
-+ plane.rect.x1 /= plane.pixpertex_x;
-+ plane.rect.x2 /= plane.pixpertex_x;
-+ if (m_textureTarget == GL_TEXTURE_2D)
-+ {
-+ plane.rect.y1 /= plane.texheight;
-+ plane.rect.y2 /= plane.texheight;
-+ plane.rect.x1 /= plane.texwidth;
-+ plane.rect.x2 /= plane.texwidth;
-+ }
-+
-+ glDisable(m_textureTarget);
-+
-+ m_eventTexturesDone[index]->Set();
-+#endif
-+}
-+
-+//********************************************************************************************************
-+// XVBA YV12 Texture creation, deletion, copying + clearing
-+//********************************************************************************************************
-+void CLinuxRendererGL::DeleteXVBAyv12Texture(int index)
-+{
-+#ifdef HAVE_LIBXVBA
-+ YV12Image &im = m_buffers[index].image;
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+ GLuint *pbo = m_buffers[index].pbo;
-+
-+ if (m_buffers[index].xvba)
-+ m_buffers[index].xvba->FinishGL();
-+
-+ SAFE_RELEASE(m_buffers[index].xvba);
-+ SAFE_RELEASE(m_buffers[index].xvba_tmp);
-+
-+ if( fields[FIELD_FULL][0].id == 0 ) return;
-+
-+ /* finish up all textures, and delete them */
-+ g_graphicsContext.BeginPaint(); //FIXME
-+ for(int f = 0;f> im.cshift_x;
-+ im.stride[2] = im.width >> im.cshift_x;
-+
-+ im.planesize[0] = im.stride[0] * im.height;
-+ im.planesize[1] = im.stride[1] * ( im.height >> im.cshift_y );
-+ im.planesize[2] = im.stride[2] * ( im.height >> im.cshift_y );
-+
-+ im.plane[1] = im.plane[2] = 0;
-+ pbo[1] = pbo[2] = 0;
-+
-+ bool pboSetup = false;
-+ if (m_pboUsed)
-+ {
-+ pboSetup = true;
-+
-+ glGenBuffersARB(1, pbo);
-+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo[0]);
-+ glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, im.planesize[0] + im.planesize[0]/2 + PBO_OFFSET, 0, GL_STREAM_DRAW_ARB);
-+ void* pboPtr = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY_ARB);
-+ if (pboPtr)
-+ {
-+ im.plane[0] = (BYTE*) pboPtr + PBO_OFFSET;
-+ memset(im.plane[0], 0, im.planesize[0]);
-+ }
-+ else
-+ {
-+ CLog::Log(LOGWARNING,"GL: failed to set up pixel buffer object");
-+ pboSetup = false;
-+ }
-+
-+ if (!pboSetup)
-+ {
-+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo[0]);
-+ glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);
-+ glDeleteBuffersARB(1, pbo);
-+ memset(m_buffers[index].pbo, 0, sizeof(m_buffers[index].pbo));
-+ }
-+
-+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
-+ }
-+
-+ if (!pboSetup)
-+ {
-+ im.plane[0] = new BYTE[im.planesize[0]+im.planesize[0]/2];
-+ }
-+
-+ glEnable(m_textureTarget);
-+ for(int f = 0;f> fieldshift;
-+
-+ if (m_renderMethod & RENDER_SW)
-+ {
-+ planes[1].texwidth = 0;
-+ planes[1].texheight = 0;
-+ planes[2].texwidth = 0;
-+ planes[2].texheight = 0;
-+ }
-+ else
-+ {
-+ planes[1].texwidth = planes[0].texwidth >> im.cshift_x;
-+ planes[1].texheight = planes[0].texheight >> im.cshift_y;
-+ planes[2].texwidth = planes[0].texwidth >> im.cshift_x;
-+ planes[2].texheight = planes[0].texheight >> im.cshift_y;
-+ }
-+
-+ for (int p = 0; p < 3; p++)
-+ {
-+ planes[p].pixpertex_x = 1;
-+ planes[p].pixpertex_y = 1;
-+ }
-+
-+ if(m_renderMethod & RENDER_POT)
-+ {
-+ for(int p = 0; p < 3; p++)
-+ {
-+ planes[p].texwidth = NP2(planes[p].texwidth);
-+ planes[p].texheight = NP2(planes[p].texheight);
-+ }
-+ }
-+
-+ for(int p = 0; p < 3; p++)
-+ {
-+ YUVPLANE &plane = planes[p];
-+ if (plane.texwidth * plane.texheight == 0)
-+ continue;
-+
-+ glBindTexture(m_textureTarget, plane.id);
-+ if (m_renderMethod & RENDER_SW)
-+ {
-+ glTexImage2D(m_textureTarget, 0, GL_RGBA, plane.texwidth, plane.texheight, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
-+ }
-+ else
-+ {
-+ GLint format;
-+ if (p == 2) //V plane needs an alpha texture
-+ format = GL_ALPHA;
-+ else
-+ format = GL_LUMINANCE;
-+
-+ glTexImage2D(m_textureTarget, 0, format, plane.texwidth, plane.texheight, 0, format, GL_UNSIGNED_BYTE, NULL);
-+ }
-+
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-+ VerifyGLState();
-+ }
-+ }
-+ glDisable(m_textureTarget);
-+ m_eventTexturesDone[index]->Set();
-+#endif
-+ return true;
-+}
-+
-+void CLinuxRendererGL::UploadXVBAyv12Texture(int source)
-+{
-+#ifdef HAVE_LIBXVBA
-+ YUVBUFFER& buf = m_buffers[source];
-+ YV12Image* im = &buf.image;
-+ YUVFIELDS& fields = buf.fields;
-+ XVBA::CDecoder *xvba = m_buffers[source].xvba;
-+
-+ if (m_buffers[source].xvba_tmp)
-+ {
-+ SAFE_RELEASE(m_buffers[source].xvba);
-+ xvba = m_buffers[source].xvba = m_buffers[source].xvba_tmp;
-+ m_buffers[source].xvba_tmp = NULL;
-+ }
-+
-+ if (!(im->flags&IMAGE_FLAG_READY) || !xvba)
-+ {
-+ m_eventTexturesDone[source]->Set();
-+ return;
-+ }
-+
-+ bool deinterlacing;
-+ if (m_currentField == FIELD_FULL)
-+ deinterlacing = false;
-+ else
-+ deinterlacing = true;
-+
-+ glEnable(m_textureTarget);
-+ VerifyGLState();
-+
-+ glPixelStorei(GL_UNPACK_ALIGNMENT,1);
-+
-+ if (deinterlacing)
-+ {
-+ // Load Even Y Field
-+ LoadPlane( fields[FIELD_TOP][0] , GL_LUMINANCE, buf.flipindex
-+ , im->width, im->height >> 1
-+ , im->stride[0]*2, im->plane[0] );
-+
-+ //load Odd Y Field
-+ LoadPlane( fields[FIELD_BOT][0], GL_LUMINANCE, buf.flipindex
-+ , im->width, im->height >> 1
-+ , im->stride[0]*2, im->plane[0] + im->stride[0], &buf.pbo[0] ) ;
-+
-+ // Load Even U & V Fields
-+ LoadPlane( fields[FIELD_TOP][1], GL_LUMINANCE, buf.flipindex
-+ , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
-+ , im->stride[1]*2, im->plane[0] + im->planesize[0] + im->planesize[1], &buf.pbo[0] );
-+
-+ LoadPlane( fields[FIELD_TOP][2], GL_ALPHA, buf.flipindex
-+ , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
-+ , im->stride[2]*2, im->plane[0] + im->planesize[0], &buf.pbo[0] );
-+
-+ // Load Odd U & V Fields
-+ LoadPlane( fields[FIELD_BOT][1], GL_LUMINANCE, buf.flipindex
-+ , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
-+ , im->stride[1]*2, im->plane[0] + im->stride[1] + im->planesize[0] + im->planesize[1], &buf.pbo[0] );
-+
-+ LoadPlane( fields[FIELD_BOT][2], GL_ALPHA, buf.flipindex
-+ , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
-+ , im->stride[2]*2, im->plane[0] + im->stride[2] + im->planesize[0], &buf.pbo[0] );
-+ }
-+ else
-+ {
-+ //Load Y plane
-+ LoadPlane( fields[FIELD_FULL][0], GL_LUMINANCE, buf.flipindex
-+ , im->width, im->height
-+ , im->stride[0], im->plane[0], &buf.pbo[0] );
-+
-+ //load U plane
-+ LoadPlane( fields[FIELD_FULL][1], GL_LUMINANCE, buf.flipindex
-+ , im->width >> im->cshift_x, im->height >> im->cshift_y
-+ , im->stride[1], im->plane[0] + im->planesize[0] + im->planesize[1] , &buf.pbo[0] );
-+
-+ //load V plane
-+ LoadPlane( fields[FIELD_FULL][2], GL_ALPHA, buf.flipindex
-+ , im->width >> im->cshift_x, im->height >> im->cshift_y
-+ , im->stride[2], im->plane[0] + im->planesize[0], &buf.pbo[0] );
-+ }
-+
-+ m_eventTexturesDone[source]->Set();
-+
-+ VerifyGLState();
-+
-+ // crop texture
-+ CRect crop = xvba->GetCropRect();
-+ m_sourceRect.x1 += crop.x1;
-+ m_sourceRect.x2 -= m_sourceWidth - crop.x2;
-+ m_sourceRect.y1 += crop.y1;
-+ m_sourceRect.y2 -= m_sourceHeight - crop.y2;
-+ CalculateTextureSourceRects(source, 3);
-+
-+ glDisable(m_textureTarget);
-+#endif
-+}
-+
- void CLinuxRendererGL::UploadYUV422PackedTexture(int source)
- {
- YUVBUFFER& buf = m_buffers[source];
-@@ -2934,6 +3461,9 @@ bool CLinuxRendererGL::Supports(ERENDERFEATURE feature)
- if (m_renderMethod & RENDER_VAAPI)
- return false;
-
-+ if (m_renderMethod & RENDER_XVBA)
-+ return false;
-+
- return (m_renderMethod & RENDER_GLSL)
- || (m_renderMethod & RENDER_ARB)
- || ((m_renderMethod & RENDER_SW) && glewIsSupported("GL_ARB_imaging") == GL_TRUE);
-@@ -2947,6 +3477,9 @@ bool CLinuxRendererGL::Supports(ERENDERFEATURE feature)
- if (m_renderMethod & RENDER_VAAPI)
- return false;
-
-+ if (m_renderMethod & RENDER_XVBA)
-+ return false;
-+
- return (m_renderMethod & RENDER_GLSL)
- || (m_renderMethod & RENDER_ARB)
- || ((m_renderMethod & RENDER_SW) && glewIsSupported("GL_ARB_imaging") == GL_TRUE);
-@@ -2970,7 +3503,8 @@ bool CLinuxRendererGL::Supports(ERENDERFEATURE feature)
- if (feature == RENDERFEATURE_NONLINSTRETCH)
- {
- if (((m_renderMethod & RENDER_GLSL) && !(m_renderMethod & RENDER_POT)) ||
-- (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI))
-+ (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI) ||
-+ (m_renderMethod & RENDER_XVBA))
- return true;
- }
-
-@@ -3010,10 +3544,22 @@ bool CLinuxRendererGL::Supports(EINTERLACEMETHOD method)
- if(m_renderMethod & RENDER_VAAPI)
- return false;
-
-- if(method == VS_INTERLACEMETHOD_DEINTERLACE
-- || method == VS_INTERLACEMETHOD_DEINTERLACE_HALF
-- || method == VS_INTERLACEMETHOD_SW_BLEND)
-- return true;
-+ if(m_renderMethod & RENDER_XVBA)
-+ {
-+ if (method == VS_INTERLACEMETHOD_RENDER_BOB_INVERTED
-+ || method == VS_INTERLACEMETHOD_RENDER_BOB)
-+ return true;
-+ else
-+ return false;
-+ }
-+
-+ if (CONF_FLAGS_FORMAT_MASK(m_iFlags) != CONF_FLAGS_FORMAT_XVBA)
-+ {
-+ if(method == VS_INTERLACEMETHOD_DEINTERLACE
-+ || method == VS_INTERLACEMETHOD_DEINTERLACE_HALF
-+ || method == VS_INTERLACEMETHOD_SW_BLEND)
-+ return true;
-+ }
-
- if((method == VS_INTERLACEMETHOD_RENDER_BLEND
- || method == VS_INTERLACEMETHOD_RENDER_WEAVE_INVERTED
-@@ -3045,7 +3591,7 @@ bool CLinuxRendererGL::Supports(ESCALINGMETHOD method)
- || method == VS_SCALINGMETHOD_LANCZOS3)
- {
- if ((glewIsSupported("GL_EXT_framebuffer_object") && (m_renderMethod & RENDER_GLSL)) ||
-- (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI))
-+ (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI) || (m_renderMethod & RENDER_XVBA))
- {
- // spline36 and lanczos3 are only allowed through advancedsettings.xml
- if(method != VS_SCALINGMETHOD_SPLINE36
-@@ -3104,7 +3650,7 @@ void CLinuxRendererGL::UnBindPbo(YUVBUFFER& buff)
- pbo = true;
-
- glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, buff.pbo[plane]);
-- glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, buff.image.planesize[plane] + PBO_OFFSET, NULL, GL_STREAM_DRAW_ARB);
-+ glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, buff.image.planesize[plane] + buff.image.planesize[plane]/2 + PBO_OFFSET, NULL, GL_STREAM_DRAW_ARB);
- buff.image.plane[plane] = (BYTE*)glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY_ARB) + PBO_OFFSET;
- }
- if(pbo)
-@@ -3128,4 +3674,13 @@ void CLinuxRendererGL::AddProcessor(VAAPI::CHolder& holder)
- }
- #endif
-
-+#ifdef HAVE_LIBXVBA
-+void CLinuxRendererGL::AddProcessor(XVBA::CDecoder* xvba)
-+{
-+ YUVBUFFER &buf = m_buffers[NextYV12Texture()];
-+ SAFE_RELEASE(buf.xvba_tmp);
-+ buf.xvba_tmp = (XVBA::CDecoder*)xvba->Acquire();
-+}
-+#endif
-+
- #endif
-diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.h b/xbmc/cores/VideoRenderers/LinuxRendererGL.h
-index 38c84aa..ae0b81b 100644
---- a/xbmc/cores/VideoRenderers/LinuxRendererGL.h
-+++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.h
-@@ -40,6 +40,7 @@ class CBaseTexture;
- namespace Shaders { class BaseYUV2RGBShader; }
- namespace Shaders { class BaseVideoFilterShader; }
- namespace VAAPI { struct CHolder; }
-+namespace XVBA { class CDecoder; }
-
- #define NUM_BUFFERS 3
-
-@@ -94,6 +95,7 @@ enum RenderMethod
- RENDER_VDPAU=0x08,
- RENDER_POT=0x10,
- RENDER_VAAPI=0x20,
-+ RENDER_XVBA=0x40,
- };
-
- enum RenderQuality
-@@ -141,6 +143,7 @@ public:
- virtual void UnInit();
- virtual void Reset(); /* resets renderer after seek for example */
- virtual void Flush();
-+ virtual unsigned int GetProcessorSize();
-
- #ifdef HAVE_LIBVDPAU
- virtual void AddProcessor(CVDPAU* vdpau);
-@@ -148,6 +151,9 @@ public:
- #ifdef HAVE_LIBVA
- virtual void AddProcessor(VAAPI::CHolder& holder);
- #endif
-+#ifdef HAVE_LIBXVBA
-+ virtual void AddProcessor(XVBA::CDecoder* xvba);
-+#endif
-
- virtual void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255);
-
-@@ -194,6 +200,14 @@ protected:
- void DeleteVAAPITexture(int index);
- bool CreateVAAPITexture(int index);
-
-+ void UploadXVBATexture(int index);
-+ void DeleteXVBATexture(int index);
-+ bool CreateXVBATexture(int index);
-+
-+ void UploadXVBAyv12Texture(int index);
-+ void DeleteXVBAyv12Texture(int index);
-+ bool CreateXVBAyv12Texture(int index);
-+
- void UploadYUV422PackedTexture(int index);
- void DeleteYUV422PackedTexture(int index);
- bool CreateYUV422PackedTexture(int index);
-@@ -211,6 +225,7 @@ protected:
- void RenderSoftware(int renderBuffer, int field); // single pass s/w yuv2rgb renderer
- void RenderVDPAU(int renderBuffer, int field); // render using vdpau hardware
- void RenderVAAPI(int renderBuffer, int field); // render using vdpau hardware
-+ void RenderXVBA(int renderBuffer, int field); // render using xvba hardware
-
- CFrameBufferObject m_fbo;
-
-@@ -270,6 +285,10 @@ protected:
- #ifdef HAVE_LIBVA
- VAAPI::CHolder& vaapi;
- #endif
-+#ifdef HAVE_LIBXVBA
-+ XVBA::CDecoder* xvba;
-+ XVBA::CDecoder* xvba_tmp;
-+#endif
- };
-
- typedef YUVBUFFER YUVBUFFERS[NUM_BUFFERS];
-diff --git a/xbmc/cores/VideoRenderers/RenderFlags.h b/xbmc/cores/VideoRenderers/RenderFlags.h
-index f663380..cbe82c5 100644
---- a/xbmc/cores/VideoRenderers/RenderFlags.h
-+++ b/xbmc/cores/VideoRenderers/RenderFlags.h
-@@ -79,5 +79,7 @@
- #define CONF_FLAGS_FORMAT_VAAPI 0x030000
- #define CONF_FLAGS_FORMAT_OMXEGL 0x040000
- #define CONF_FLAGS_FORMAT_CVBREF 0x080000
-+#define CONF_FLAGS_FORMAT_XVBA 0x011000
-+#define CONF_FLAGS_FORMAT_XVBA_YV12 0x012000
- #define CONF_FLAGS_FORMAT_BYPASS 0x100000
- #endif
-diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp
-index 31bb49a..8f0506d 100644
---- a/xbmc/cores/VideoRenderers/RenderManager.cpp
-+++ b/xbmc/cores/VideoRenderers/RenderManager.cpp
-@@ -53,6 +53,10 @@
- #include "../dvdplayer/DVDCodecs/Video/DVDVideoCodec.h"
- #include "../dvdplayer/DVDCodecs/DVDCodecUtils.h"
-
-+#ifdef HAVE_LIBXVBA
-+ #include "../dvdplayer/DVDCodecs/Video/XVBA.h"
-+#endif
-+
- #define MAXPRESENTDELAY 0.500
-
- /* at any point we want an exclusive lock on rendermanager */
-@@ -779,6 +783,25 @@ int CXBMCRenderManager::AddVideoPicture(DVDVideoPicture& pic)
- else if(pic.format == DVDVideoPicture::FMT_VAAPI)
- m_pRenderer->AddProcessor(*pic.vaapi);
- #endif
-+#ifdef HAVE_LIBXVBA
-+ else if(pic.format == DVDVideoPicture::FMT_XVBA)
-+ {
-+ if (pic.xvba)
-+ {
-+ m_pRenderer->AddProcessor(pic.xvba);
-+ pic.xvba->Present(index);
-+ }
-+ }
-+ else if(pic.format == DVDVideoPicture::FMT_XVBA_YV12)
-+ {
-+ if (pic.xvba)
-+ {
-+ m_pRenderer->AddProcessor(pic.xvba);
-+ pic.xvba->Present(index);
-+ pic.xvba->CopyYV12(index, image.plane[0]);
-+ }
-+ }
-+#endif
- m_pRenderer->ReleaseImage(index, false);
-
- return index;
-diff --git a/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp b/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp
-index fa9f68a..68f4008 100644
---- a/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp
-+++ b/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp
-@@ -186,6 +186,8 @@ BaseYUV2RGBGLSLShader::BaseYUV2RGBGLSLShader(bool rect, unsigned flags, bool str
- m_defines += "#define XBMC_YUY2\n";
- else if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_UYVY)
- m_defines += "#define XBMC_UYVY\n";
-+ if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_XVBA_YV12)
-+ m_defines += "#define XBMC_YV12\n";
-
- VertexShader()->LoadSource("yuv2rgb_vertex.glsl", m_defines);
- #elif HAS_GLES == 2
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp
-index ae107a6..1b8cd96 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp
-@@ -323,7 +323,7 @@ CPictureBuffer::~CPictureBuffer()
+diff -Naur xbmc-1fef727/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp
+--- xbmc-1fef727/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp 2012-02-07 14:30:18.016098528 +0100
+@@ -323,7 +323,7 @@
#pragma mark -
#endif
CMPCOutputThread::CMPCOutputThread(void *device, DllLibCrystalHD *dll, bool has_bcm70015) :
@@ -1912,41 +1024,9 @@ index ae107a6..1b8cd96 100644
m_dll(dll),
m_device(device),
m_has_bcm70015(has_bcm70015),
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
-index e4bd9c9..edc2fe1 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
-@@ -34,6 +34,7 @@
-
- namespace DXVA { class CSurfaceContext; }
- namespace VAAPI { struct CHolder; }
-+namespace XVBA { class CDecoder; }
- class CVDPAU;
- class COpenMax;
- class COpenMaxVideo;
-@@ -64,6 +65,9 @@ struct DVDVideoPicture
- struct {
- VAAPI::CHolder* vaapi;
- };
-+ struct {
-+ XVBA::CDecoder* xvba;
-+ };
-
- struct {
- COpenMax *openMax;
-@@ -109,6 +113,8 @@ struct DVDVideoPicture
- FMT_VAAPI,
- FMT_OMXEGL,
- FMT_CVBREF,
-+ FMT_XVBA,
-+ FMT_XVBA_YV12,
- } format;
- };
-
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
-index 1728e82..7b528ab 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
+diff -Naur xbmc-1fef727/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
+--- xbmc-1fef727/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp 2012-02-07 14:30:18.018098568 +0100
@@ -56,6 +56,9 @@
#ifdef HAVE_LIBVA
#include "VAAPI.h"
@@ -1957,7 +1037,7 @@ index 1728e82..7b528ab 100644
using namespace boost;
-@@ -100,6 +103,22 @@ enum PixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx
+@@ -100,6 +103,22 @@
dec->Release();
}
#endif
@@ -1978,13 +1058,42 @@ index 1728e82..7b528ab 100644
+ }
+#endif
#ifdef HAVE_LIBVA
- if(*cur == PIX_FMT_VAAPI_VLD && g_guiSettings.GetBool("videoplayer.usevaapi"))
- {
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in b/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in
-index 1dce256..8b7d5fb 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in
-@@ -17,6 +17,10 @@ SRCS+= CrystalHD.cpp \
+ // mpeg4 vaapi decoding is disabled
+ if(*cur == PIX_FMT_VAAPI_VLD && g_guiSettings.GetBool("videoplayer.usevaapi")
+diff -Naur xbmc-1fef727/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
+--- xbmc-1fef727/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h 2012-02-07 14:30:18.017098548 +0100
+@@ -34,6 +34,7 @@
+
+ namespace DXVA { class CSurfaceContext; }
+ namespace VAAPI { struct CHolder; }
++namespace XVBA { class CDecoder; }
+ class CVDPAU;
+ class COpenMax;
+ class COpenMaxVideo;
+@@ -64,6 +65,9 @@
+ struct {
+ VAAPI::CHolder* vaapi;
+ };
++ struct {
++ XVBA::CDecoder* xvba;
++ };
+
+ struct {
+ COpenMax *openMax;
+@@ -109,6 +113,8 @@
+ FMT_VAAPI,
+ FMT_OMXEGL,
+ FMT_CVBREF,
++ FMT_XVBA,
++ FMT_XVBA_YV12,
+ } format;
+ };
+
+diff -Naur xbmc-1fef727/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in
+--- xbmc-1fef727/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in 2012-02-07 14:30:18.018098568 +0100
+@@ -17,6 +17,10 @@
DVDVideoCodecCrystalHD.cpp \
endif
@@ -1995,11 +1104,9 @@ index 1dce256..8b7d5fb 100644
ifeq (@USE_VDA@,1)
SRCS+= DVDVideoCodecVDA.cpp \
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp
-new file mode 100644
-index 0000000..d6317e0
---- /dev/null
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp
+diff -Naur xbmc-1fef727/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp
+--- xbmc-1fef727/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp 2012-02-07 14:30:18.021098627 +0100
@@ -0,0 +1,1401 @@
+/*
+ * Copyright (C) 2005-2011 Team XBMC
@@ -2219,7 +1326,7 @@ index 0000000..d6317e0
+ { CSingleLock lock(g_graphicsContext);
+ if (!m_display)
+ m_display = XOpenDisplay(NULL);
-+ window = g_Windowing.GetWindow();
++ window = 0;
+ }
+
+ int version;
@@ -3402,11 +2509,9 @@ index 0000000..d6317e0
+}
+
+#endif
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h
-new file mode 100644
-index 0000000..5ca39ab
---- /dev/null
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h
+diff -Naur xbmc-1fef727/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h
+--- xbmc-1fef727/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h 2012-02-07 14:30:18.021098627 +0100
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2005-2011 Team XBMC
@@ -3569,10 +2674,9 @@ index 0000000..5ca39ab
+};
+
+}
-diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
-index b0a3796..858a2ed 100644
---- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
-+++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
+diff -Naur xbmc-1fef727/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
+--- xbmc-1fef727/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp 2012-02-07 14:30:18.023098666 +0100
@@ -19,7 +19,6 @@
*
*/
@@ -3581,7 +2685,7 @@ index b0a3796..858a2ed 100644
#include "system.h"
#ifndef __STDC_CONSTANT_MACROS
#define __STDC_CONSTANT_MACROS
-@@ -44,6 +43,7 @@
+@@ -43,6 +42,7 @@
#include "filesystem/Directory.h"
#include "utils/log.h"
#include "threads/Thread.h"
@@ -3589,7 +2693,7 @@ index b0a3796..858a2ed 100644
#include "utils/TimeUtils.h"
void CDemuxStreamAudioFFmpeg::GetStreamInfo(std::string& strInfo)
-@@ -153,16 +153,12 @@ static void ff_flush_avutil_log_buffers(void)
+@@ -153,16 +153,12 @@
++it;
}
@@ -3609,7 +2713,7 @@ index b0a3796..858a2ed 100644
return 1;
return 0;
}
-@@ -234,7 +230,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput)
+@@ -234,7 +230,7 @@
std::string strFile;
m_iCurrentPts = DVD_NOPTS_VALUE;
m_speed = DVD_PLAYSPEED_NORMAL;
@@ -3618,7 +2722,7 @@ index b0a3796..858a2ed 100644
m_program = UINT_MAX;
if (!pInput) return false;
-@@ -506,7 +502,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput)
+@@ -506,7 +502,7 @@
void CDVDDemuxFFmpeg::Dispose()
{
@@ -3627,7 +2731,7 @@ index b0a3796..858a2ed 100644
if (m_pFormatContext)
{
-@@ -555,7 +551,7 @@ void CDVDDemuxFFmpeg::Reset()
+@@ -555,7 +551,7 @@
void CDVDDemuxFFmpeg::Flush()
{
@@ -3636,7 +2740,7 @@ index b0a3796..858a2ed 100644
// naughty usage of an internal ffmpeg function
if (m_pFormatContext)
-@@ -571,7 +567,7 @@ void CDVDDemuxFFmpeg::Abort()
+@@ -571,7 +567,7 @@
void CDVDDemuxFFmpeg::SetSpeed(int iSpeed)
{
@@ -3645,7 +2749,7 @@ index b0a3796..858a2ed 100644
if(!m_pFormatContext)
return;
-@@ -633,7 +629,7 @@ double CDVDDemuxFFmpeg::ConvertTimestamp(int64_t pts, int den, int num)
+@@ -633,7 +629,7 @@
DemuxPacket* CDVDDemuxFFmpeg::Read()
{
@@ -3654,7 +2758,7 @@ index b0a3796..858a2ed 100644
AVPacket pkt;
DemuxPacket* pPacket = NULL;
-@@ -832,7 +828,7 @@ DemuxPacket* CDVDDemuxFFmpeg::Read()
+@@ -832,7 +828,7 @@
bool CDVDDemuxFFmpeg::SeekTime(int time, bool backwords, double *startpts)
{
@@ -3663,7 +2767,7 @@ index b0a3796..858a2ed 100644
if(time < 0)
time = 0;
-@@ -892,7 +888,7 @@ bool CDVDDemuxFFmpeg::SeekTime(int time, bool backwords, double *startpts)
+@@ -892,7 +888,7 @@
bool CDVDDemuxFFmpeg::SeekByte(__int64 pos)
{
@@ -3672,10 +2776,9 @@ index b0a3796..858a2ed 100644
CSingleLock lock(m_critSection);
int ret = m_dllAvFormat.av_seek_frame(m_pFormatContext, -1, pos, AVSEEK_FLAG_BYTE);
-diff --git a/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp b/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp
-index 23c5e3e..129674a 100644
---- a/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp
-+++ b/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp
+diff -Naur xbmc-1fef727/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp
+--- xbmc-1fef727/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp 2012-02-07 14:30:18.024098686 +0100
@@ -21,6 +21,7 @@
#include "DVDPerformanceCounter.h"
@@ -3684,7 +2787,7 @@ index 23c5e3e..129674a 100644
#include "dvd_config.h"
-@@ -68,22 +69,16 @@ HRESULT __stdcall DVDPerformanceCounterVideoQueue(PLARGE_INTEGER numerator, PLAR
+@@ -68,22 +69,16 @@
inline __int64 get_thread_cpu_usage(ProcessPerformance* p)
{
@@ -3710,10 +2813,9 @@ index 23c5e3e..129674a 100644
__int64 threadTime = (p->timer_thread.QuadPart - old_time_thread.QuadPart);
__int64 systemTime = (p->timer_system.QuadPart - old_time_system.QuadPart);
-diff --git a/xbmc/cores/dvdplayer/DVDPerformanceCounter.h b/xbmc/cores/dvdplayer/DVDPerformanceCounter.h
-index 2f0b5ac..e97a14c 100644
---- a/xbmc/cores/dvdplayer/DVDPerformanceCounter.h
-+++ b/xbmc/cores/dvdplayer/DVDPerformanceCounter.h
+diff -Naur xbmc-1fef727/xbmc/cores/dvdplayer/DVDPerformanceCounter.h xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDPerformanceCounter.h
+--- xbmc-1fef727/xbmc/cores/dvdplayer/DVDPerformanceCounter.h 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDPerformanceCounter.h 2012-02-07 14:30:18.025098706 +0100
@@ -24,7 +24,7 @@
#define FILETIME_TO_ULARGE_INTEGER(ularge, filetime) { ularge.u.HighPart = filetime.dwHighDateTime; ularge.u.LowPart = filetime.dwLowDateTime; }
@@ -3723,7 +2825,7 @@ index 2f0b5ac..e97a14c 100644
#include "threads/SingleLock.h"
class CDVDMessageQueue;
-@@ -33,7 +33,7 @@ typedef struct stProcessPerformance
+@@ -33,7 +33,7 @@
{
ULARGE_INTEGER timer_thread;
ULARGE_INTEGER timer_system;
@@ -3732,7 +2834,7 @@ index 2f0b5ac..e97a14c 100644
} ProcessPerformance;
class CDVDPerformanceCounter
-@@ -45,20 +45,20 @@ public:
+@@ -45,20 +45,20 @@
bool Initialize();
void DeInitialize();
@@ -3763,11 +2865,22 @@ index 2f0b5ac..e97a14c 100644
CDVDMessageQueue* m_pAudioQueue;
CDVDMessageQueue* m_pVideoQueue;
-diff --git a/xbmc/cores/dvdplayer/DVDPlayer.cpp b/xbmc/cores/dvdplayer/DVDPlayer.cpp
-index 1d8cdf5..f7d31d4 100644
---- a/xbmc/cores/dvdplayer/DVDPlayer.cpp
-+++ b/xbmc/cores/dvdplayer/DVDPlayer.cpp
-@@ -348,7 +348,7 @@ bool CDVDPlayer::OpenFile(const CFileItem& file, const CPlayerOptions &options)
+diff -Naur xbmc-1fef727/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
+--- xbmc-1fef727/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp 2012-02-07 14:30:18.029098786 +0100
+@@ -518,7 +518,7 @@
+ m_decode.msg = NULL;
+ m_decode.Release();
+
+- g_dvdPerformanceCounter.EnableAudioDecodePerformance(ThreadHandle());
++ g_dvdPerformanceCounter.EnableAudioDecodePerformance(this);
+
+ #ifdef _WIN32
+ CoInitializeEx(NULL, COINIT_MULTITHREADED);
+diff -Naur xbmc-1fef727/xbmc/cores/dvdplayer/DVDPlayer.cpp xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDPlayer.cpp
+--- xbmc-1fef727/xbmc/cores/dvdplayer/DVDPlayer.cpp 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDPlayer.cpp 2012-02-07 14:30:18.028098766 +0100
+@@ -341,7 +341,7 @@
// if playing a file close it first
// this has to be changed so we won't have to close it.
@@ -3776,7 +2889,7 @@ index 1d8cdf5..f7d31d4 100644
CloseFile();
m_bAbortRequest = false;
-@@ -440,9 +440,8 @@ void CDVDPlayer::OnStartup()
+@@ -432,9 +432,8 @@
m_messenger.Init();
@@ -3787,7 +2900,7 @@ index 1d8cdf5..f7d31d4 100644
}
bool CDVDPlayer::OpenInputStream()
-@@ -2879,7 +2878,7 @@ bool CDVDPlayer::OpenAudioStream(int iStream, int source)
+@@ -2707,7 +2706,7 @@
m_dvdPlayerAudio.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
/* audio normally won't consume full cpu, so let it have prio */
@@ -3796,7 +2909,7 @@ index 1d8cdf5..f7d31d4 100644
return true;
}
-@@ -2941,11 +2940,11 @@ bool CDVDPlayer::OpenVideoStream(int iStream, int source)
+@@ -2769,11 +2768,11 @@
// the CoreAudio audio device handler thread. We do the same for
// the DVDPlayerVideo thread so it can run to sleep without getting
// swapped out by a busy OS.
@@ -3810,24 +2923,10 @@ index 1d8cdf5..f7d31d4 100644
#endif
return true;
-diff --git a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
-index 41fbaaf..9f2128c 100644
---- a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
-+++ b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
-@@ -518,7 +518,7 @@ void CDVDPlayerAudio::OnStartup()
- m_decode.msg = NULL;
- m_decode.Release();
-
-- g_dvdPerformanceCounter.EnableAudioDecodePerformance(ThreadHandle());
-+ g_dvdPerformanceCounter.EnableAudioDecodePerformance(this);
-
- #ifdef _WIN32
- CoInitializeEx(NULL, COINIT_MULTITHREADED);
-diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
-index 695cb7e..4c99c48 100644
---- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
-+++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
-@@ -189,7 +189,7 @@ bool CDVDPlayerVideo::OpenStream( CDVDStreamInfo &hint )
+diff -Naur xbmc-1fef727/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
+--- xbmc-1fef727/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2012-02-07 14:30:18.030098805 +0100
+@@ -189,7 +189,7 @@
return false;
}
@@ -3836,7 +2935,7 @@ index 695cb7e..4c99c48 100644
{
g_VideoReferenceClock.Create();
//we have to wait for the clock to start otherwise alsa can cause trouble
-@@ -288,7 +288,7 @@ void CDVDPlayerVideo::OnStartup()
+@@ -288,7 +288,7 @@
m_iCurrentPts = DVD_NOPTS_VALUE;
m_FlipTimeStamp = m_pClock->GetAbsoluteClock();
@@ -3845,7 +2944,7 @@ index 695cb7e..4c99c48 100644
}
void CDVDPlayerVideo::Process()
-@@ -1051,6 +1051,14 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts)
+@@ -1049,6 +1049,14 @@
flags |= CONF_FLAGS_FORMAT_CVBREF;
formatstr = "BGRA";
break;
@@ -3860,10 +2959,9 @@ index 695cb7e..4c99c48 100644
}
if(m_bAllowFullscreen)
-diff --git a/xbmc/cores/paplayer/PAPlayer.cpp b/xbmc/cores/paplayer/PAPlayer.cpp
-index 43b57d3..13f5238 100644
---- a/xbmc/cores/paplayer/PAPlayer.cpp
-+++ b/xbmc/cores/paplayer/PAPlayer.cpp
+diff -Naur xbmc-1fef727/xbmc/cores/paplayer/PAPlayer.cpp xbmc-1fef727.patch/xbmc/cores/paplayer/PAPlayer.cpp
+--- xbmc-1fef727/xbmc/cores/paplayer/PAPlayer.cpp 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/paplayer/PAPlayer.cpp 2012-02-07 14:30:18.031098824 +0100
@@ -52,7 +52,7 @@
// Supporting all open audio codec standards.
// First one being nullsoft's nsv audio decoder format
@@ -3873,7 +2971,7 @@ index 43b57d3..13f5238 100644
{
m_bIsPlaying = false;
m_bPaused = false;
-@@ -168,7 +168,7 @@ bool PAPlayer::OpenFile(const CFileItem& file, const CPlayerOptions &options)
+@@ -168,7 +168,7 @@
*m_currentFile = file;
@@ -3882,10 +2980,861 @@ index 43b57d3..13f5238 100644
Create();
m_startEvent.Set();
-diff --git a/xbmc/dialogs/GUIDialogCache.cpp b/xbmc/dialogs/GUIDialogCache.cpp
-index 1114cc6..85548e4 100644
---- a/xbmc/dialogs/GUIDialogCache.cpp
-+++ b/xbmc/dialogs/GUIDialogCache.cpp
+diff -Naur xbmc-1fef727/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp xbmc-1fef727.patch/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
+--- xbmc-1fef727/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp 2012-02-07 14:30:18.012098450 +0100
+@@ -61,6 +61,9 @@
+ VA_MICRO_VERSION == 0 && VA_SDS_VERSION < 5)))
+
+ #endif
++#ifdef HAVE_LIBXVBA
++#include "cores/dvdplayer/DVDCodecs/Video/XVBA.h"
++#endif
+
+ #ifdef HAS_GLX
+ #include
+@@ -121,6 +124,10 @@
+ #ifdef HAVE_LIBVDPAU
+ vdpau = NULL;
+ #endif
++#ifdef HAVE_LIBXVBA
++ xvba = NULL;
++ xvba_tmp = NULL;
++#endif
+ }
+
+ CLinuxRendererGL::YUVBUFFER::~YUVBUFFER()
+@@ -160,6 +167,7 @@
+ m_rgbPbo = 0;
+
+ m_dllSwScale = new DllSwScale;
++ m_bValidated = false;
+ }
+
+ CLinuxRendererGL::~CLinuxRendererGL()
+@@ -224,7 +232,7 @@
+
+ void CLinuxRendererGL::ManageTextures()
+ {
+- m_NumYV12Buffers = 2;
++ m_NumYV12Buffers = 3;
+ //m_iYV12RenderBuffer = 0;
+ return;
+ }
+@@ -569,6 +577,11 @@
+ m_bValidated = false;
+ }
+
++unsigned int CLinuxRendererGL::GetProcessorSize()
++{
++ return m_NumYV12Buffers;
++}
++
+ void CLinuxRendererGL::Update(bool bPauseDrawing)
+ {
+ if (!m_bConfigured) return;
+@@ -730,14 +743,15 @@
+ {
+ CSingleLock lock(g_graphicsContext);
+ m_bConfigured = false;
+- m_bValidated = false;
+- UnInit();
++ if (m_bValidated)
++ UnInit();
++
+ m_resolution = g_guiSettings.m_LookAndFeelResolution;
+ if ( m_resolution == RES_WINDOW )
+ m_resolution = RES_DESKTOP;
+
+ m_iYV12RenderBuffer = 0;
+- m_NumYV12Buffers = 2;
++ m_NumYV12Buffers = 3;
+
+ // setup the background colour
+ m_clearColour = (float)(g_advancedSettings.m_videoBlackBarColour & 0xff) / 0xff;
+@@ -817,7 +831,7 @@
+ case VS_SCALINGMETHOD_LINEAR:
+ SetTextureFilter(m_scalingMethod == VS_SCALINGMETHOD_NEAREST ? GL_NEAREST : GL_LINEAR);
+ m_renderQuality = RQ_SINGLEPASS;
+- if (((m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI)) && m_nonLinStretch)
++ if (((m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI) || (m_renderMethod & RENDER_XVBA)) && m_nonLinStretch)
+ {
+ m_pVideoFilterShader = new StretchFilterShader();
+ if (!m_pVideoFilterShader->CompileAndLink())
+@@ -898,6 +912,11 @@
+ CLog::Log(LOGNOTICE, "GL: Using VAAPI render method");
+ m_renderMethod = RENDER_VAAPI;
+ }
++ else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_XVBA)
++ {
++ CLog::Log(LOGNOTICE, "GL: Using XVBA render method");
++ m_renderMethod = RENDER_XVBA;
++ }
+ else
+ {
+ int requestedMethod = g_guiSettings.GetInt("videoplayer.rendermethod");
+@@ -1032,6 +1051,18 @@
+ m_textureCreate = &CLinuxRendererGL::CreateVAAPITexture;
+ m_textureDelete = &CLinuxRendererGL::DeleteVAAPITexture;
+ }
++ else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_XVBA)
++ {
++ m_textureUpload = &CLinuxRendererGL::UploadXVBATexture;
++ m_textureCreate = &CLinuxRendererGL::CreateXVBATexture;
++ m_textureDelete = &CLinuxRendererGL::DeleteXVBATexture;
++ }
++ else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_XVBA_YV12)
++ {
++ m_textureUpload = &CLinuxRendererGL::UploadXVBAyv12Texture;
++ m_textureCreate = &CLinuxRendererGL::CreateXVBAyv12Texture;
++ m_textureDelete = &CLinuxRendererGL::DeleteXVBAyv12Texture;
++ }
+ else
+ {
+ // setup default YV12 texture handlers
+@@ -1125,6 +1156,13 @@
+ RenderVDPAU(renderBuffer, m_currentField);
+ }
+ #endif
++#ifdef HAVE_LIBXVBA
++ else if (m_renderMethod & RENDER_XVBA)
++ {
++ UpdateVideoFilter();
++ RenderXVBA(renderBuffer, m_currentField);
++ }
++#endif
+ #ifdef HAVE_LIBVA
+ else if (m_renderMethod & RENDER_VAAPI)
+ {
+@@ -1598,6 +1636,77 @@
+ #endif
+ }
+
++void CLinuxRendererGL::RenderXVBA(int index, int field)
++{
++#ifdef HAVE_LIBXVBA
++ YUVPLANE &plane = m_buffers[index].fields[field][0];
++
++ glEnable(m_textureTarget);
++ glActiveTextureARB(GL_TEXTURE0);
++ glBindTexture(m_textureTarget, plane.id);
++
++ // Try some clamping or wrapping
++ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
++ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
++
++ if (m_pVideoFilterShader)
++ {
++ GLint filter;
++ if (!m_pVideoFilterShader->GetTextureFilter(filter))
++ filter = m_scalingMethod == VS_SCALINGMETHOD_NEAREST ? GL_NEAREST : GL_LINEAR;
++
++ glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, filter);
++ glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, filter);
++ m_pVideoFilterShader->SetSourceTexture(0);
++ m_pVideoFilterShader->SetWidth(m_sourceWidth);
++ m_pVideoFilterShader->SetHeight(m_sourceHeight);
++
++ //disable non-linear stretch when a dvd menu is shown, parts of the menu are rendered through the overlay renderer
++ //having non-linear stretch on breaks the alignment
++ if (g_application.m_pPlayer && g_application.m_pPlayer->IsInMenu())
++ m_pVideoFilterShader->SetNonLinStretch(1.0);
++ else
++ m_pVideoFilterShader->SetNonLinStretch(pow(g_settings.m_fPixelRatio, g_advancedSettings.m_videoNonLinStretchRatio));
++
++ m_pVideoFilterShader->Enable();
++ }
++ else
++ {
++ GLint filter = m_scalingMethod == VS_SCALINGMETHOD_NEAREST ? GL_NEAREST : GL_LINEAR;
++ glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, filter);
++ glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, filter);
++ }
++
++ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
++ VerifyGLState();
++
++ glBegin(GL_QUADS);
++ if (m_textureTarget==GL_TEXTURE_2D)
++ {
++ glTexCoord2f(plane.rect.x1, plane.rect.y1); glVertex2f(m_destRect.x1, m_destRect.y1);
++ glTexCoord2f(plane.rect.x2, plane.rect.y1); glVertex2f(m_destRect.x2, m_destRect.y1);
++ glTexCoord2f(plane.rect.x2, plane.rect.y2); glVertex2f(m_destRect.x2, m_destRect.y2);
++ glTexCoord2f(plane.rect.x1, plane.rect.y2); glVertex2f(m_destRect.x1, m_destRect.y2);
++ }
++ else
++ {
++ glTexCoord2f(m_destRect.x1, m_destRect.y1); glVertex4f(m_destRect.x1, m_destRect.y1, 0.0f, 0.0f);
++ glTexCoord2f(m_destRect.x2, m_destRect.y1); glVertex4f(m_destRect.x2, m_destRect.y1, 1.0f, 0.0f);
++ glTexCoord2f(m_destRect.x2, m_destRect.y2); glVertex4f(m_destRect.x2, m_destRect.y2, 1.0f, 1.0f);
++ glTexCoord2f(m_destRect.x1, m_destRect.y2); glVertex4f(m_destRect.x1, m_destRect.y2, 0.0f, 1.0f);
++ }
++ glEnd();
++ VerifyGLState();
++
++ if (m_pVideoFilterShader)
++ m_pVideoFilterShader->Disable();
++
++ glBindTexture (m_textureTarget, 0);
++ glDisable(m_textureTarget);
++#endif
++}
++
++
+ void CLinuxRendererGL::RenderSoftware(int index, int field)
+ {
+ YUVPLANES &planes = m_buffers[index].fields[field];
+@@ -2352,6 +2461,424 @@
+ #endif
+ }
+
++void CLinuxRendererGL::DeleteXVBATexture(int index)
++{
++#ifdef HAVE_LIBXVBA
++ YUVPLANE &plane = m_buffers[index].fields[0][1];
++
++ if (m_buffers[index].xvba)
++ m_buffers[index].xvba->FinishGL();
++
++ SAFE_RELEASE(m_buffers[index].xvba);
++ SAFE_RELEASE(m_buffers[index].xvba_tmp);
++
++ if(plane.id && glIsTexture(plane.id))
++ glDeleteTextures(1, &plane.id);
++ plane.id = 0;
++ m_buffers[index].fields[0][0].id = 0;
++
++#endif
++}
++
++
++bool CLinuxRendererGL::CreateXVBATexture(int index)
++{
++#ifdef HAVE_LIBXVBA
++ YV12Image &im = m_buffers[index].image;
++ YUVFIELDS &fields = m_buffers[index].fields;
++ YUVPLANE &plane = fields[0][0];
++ YUVPLANE &planeFallback = fields[0][1];
++
++ DeleteXVBATexture(index);
++
++ memset(&im , 0, sizeof(im));
++ memset(&fields, 0, sizeof(fields));
++ im.height = m_sourceHeight;
++ im.width = m_sourceWidth;
++
++ for(int f = 0;fSet();
++#endif
++ return true;
++}
++
++void CLinuxRendererGL::UploadXVBATexture(int index)
++{
++#ifdef HAVE_LIBXVBA
++ XVBA::CDecoder *xvba = m_buffers[index].xvba;
++
++ if (m_buffers[index].xvba_tmp)
++ {
++ SAFE_RELEASE(m_buffers[index].xvba);
++ xvba = m_buffers[index].xvba = m_buffers[index].xvba_tmp;
++ m_buffers[index].xvba_tmp = NULL;
++ }
++
++ YUVFIELDS &fields = m_buffers[index].fields;
++ YUVPLANE &planeFallback = fields[0][1];
++ YUVPLANE &plane = fields[m_currentField][0];
++
++ if (!xvba)
++ {
++ fields[0][0].id = planeFallback.id;
++ fields[1][0].id = planeFallback.id;
++ fields[2][0].id = planeFallback.id;
++ m_eventTexturesDone[index]->Set();
++ return;
++ }
++
++ XVBA_SURFACE_FLAG field;
++ if (m_currentField == FIELD_TOP)
++ field = XVBA_TOP_FIELD;
++ else if (m_currentField == FIELD_BOT)
++ field = XVBA_BOTTOM_FIELD;
++ else
++ field = XVBA_FRAME;
++
++ glEnable(m_textureTarget);
++ if (xvba->UploadTexture(index, field, m_textureTarget) == 1)
++ plane.id = xvba->GetTexture(index, field);
++
++ // crop texture
++ CRect crop = xvba->GetCropRect();
++ plane.rect = m_sourceRect;
++ plane.rect.x1 += crop.x1;
++ plane.rect.x2 -= m_sourceWidth - crop.x2;
++ plane.rect.y1 += crop.y1;
++ plane.rect.y2 -= m_sourceHeight - crop.y2;
++ plane.rect.y1 /= plane.pixpertex_y;
++ plane.rect.y2 /= plane.pixpertex_y;
++ plane.rect.x1 /= plane.pixpertex_x;
++ plane.rect.x2 /= plane.pixpertex_x;
++ if (m_textureTarget == GL_TEXTURE_2D)
++ {
++ plane.rect.y1 /= plane.texheight;
++ plane.rect.y2 /= plane.texheight;
++ plane.rect.x1 /= plane.texwidth;
++ plane.rect.x2 /= plane.texwidth;
++ }
++
++ glDisable(m_textureTarget);
++
++ m_eventTexturesDone[index]->Set();
++#endif
++}
++
++//********************************************************************************************************
++// XVBA YV12 Texture creation, deletion, copying + clearing
++//********************************************************************************************************
++void CLinuxRendererGL::DeleteXVBAyv12Texture(int index)
++{
++#ifdef HAVE_LIBXVBA
++ YV12Image &im = m_buffers[index].image;
++ YUVFIELDS &fields = m_buffers[index].fields;
++ GLuint *pbo = m_buffers[index].pbo;
++
++ if (m_buffers[index].xvba)
++ m_buffers[index].xvba->FinishGL();
++
++ SAFE_RELEASE(m_buffers[index].xvba);
++ SAFE_RELEASE(m_buffers[index].xvba_tmp);
++
++ if( fields[FIELD_FULL][0].id == 0 ) return;
++
++ /* finish up all textures, and delete them */
++ g_graphicsContext.BeginPaint(); //FIXME
++ for(int f = 0;f> im.cshift_x;
++ im.stride[2] = im.width >> im.cshift_x;
++
++ im.planesize[0] = im.stride[0] * im.height;
++ im.planesize[1] = im.stride[1] * ( im.height >> im.cshift_y );
++ im.planesize[2] = im.stride[2] * ( im.height >> im.cshift_y );
++
++ im.plane[1] = im.plane[2] = 0;
++ pbo[1] = pbo[2] = 0;
++
++ bool pboSetup = false;
++ if (m_pboUsed)
++ {
++ pboSetup = true;
++
++ glGenBuffersARB(1, pbo);
++ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo[0]);
++ glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, im.planesize[0] + im.planesize[0]/2 + PBO_OFFSET, 0, GL_STREAM_DRAW_ARB);
++ void* pboPtr = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY_ARB);
++ if (pboPtr)
++ {
++ im.plane[0] = (BYTE*) pboPtr + PBO_OFFSET;
++ memset(im.plane[0], 0, im.planesize[0]);
++ }
++ else
++ {
++ CLog::Log(LOGWARNING,"GL: failed to set up pixel buffer object");
++ pboSetup = false;
++ }
++
++ if (!pboSetup)
++ {
++ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo[0]);
++ glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);
++ glDeleteBuffersARB(1, pbo);
++ memset(m_buffers[index].pbo, 0, sizeof(m_buffers[index].pbo));
++ }
++
++ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
++ }
++
++ if (!pboSetup)
++ {
++ im.plane[0] = new BYTE[im.planesize[0]+im.planesize[0]/2];
++ }
++
++ glEnable(m_textureTarget);
++ for(int f = 0;f> fieldshift;
++
++ if (m_renderMethod & RENDER_SW)
++ {
++ planes[1].texwidth = 0;
++ planes[1].texheight = 0;
++ planes[2].texwidth = 0;
++ planes[2].texheight = 0;
++ }
++ else
++ {
++ planes[1].texwidth = planes[0].texwidth >> im.cshift_x;
++ planes[1].texheight = planes[0].texheight >> im.cshift_y;
++ planes[2].texwidth = planes[0].texwidth >> im.cshift_x;
++ planes[2].texheight = planes[0].texheight >> im.cshift_y;
++ }
++
++ for (int p = 0; p < 3; p++)
++ {
++ planes[p].pixpertex_x = 1;
++ planes[p].pixpertex_y = 1;
++ }
++
++ if(m_renderMethod & RENDER_POT)
++ {
++ for(int p = 0; p < 3; p++)
++ {
++ planes[p].texwidth = NP2(planes[p].texwidth);
++ planes[p].texheight = NP2(planes[p].texheight);
++ }
++ }
++
++ for(int p = 0; p < 3; p++)
++ {
++ YUVPLANE &plane = planes[p];
++ if (plane.texwidth * plane.texheight == 0)
++ continue;
++
++ glBindTexture(m_textureTarget, plane.id);
++ if (m_renderMethod & RENDER_SW)
++ {
++ glTexImage2D(m_textureTarget, 0, GL_RGBA, plane.texwidth, plane.texheight, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
++ }
++ else
++ {
++ GLint format;
++ if (p == 2) //V plane needs an alpha texture
++ format = GL_ALPHA;
++ else
++ format = GL_LUMINANCE;
++
++ glTexImage2D(m_textureTarget, 0, format, plane.texwidth, plane.texheight, 0, format, GL_UNSIGNED_BYTE, NULL);
++ }
++
++ glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
++ glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
++ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
++ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
++ VerifyGLState();
++ }
++ }
++ glDisable(m_textureTarget);
++ m_eventTexturesDone[index]->Set();
++#endif
++ return true;
++}
++
++void CLinuxRendererGL::UploadXVBAyv12Texture(int source)
++{
++#ifdef HAVE_LIBXVBA
++ YUVBUFFER& buf = m_buffers[source];
++ YV12Image* im = &buf.image;
++ YUVFIELDS& fields = buf.fields;
++ XVBA::CDecoder *xvba = m_buffers[source].xvba;
++
++ if (m_buffers[source].xvba_tmp)
++ {
++ SAFE_RELEASE(m_buffers[source].xvba);
++ xvba = m_buffers[source].xvba = m_buffers[source].xvba_tmp;
++ m_buffers[source].xvba_tmp = NULL;
++ }
++
++ if (!(im->flags&IMAGE_FLAG_READY) || !xvba)
++ {
++ m_eventTexturesDone[source]->Set();
++ return;
++ }
++
++ bool deinterlacing;
++ if (m_currentField == FIELD_FULL)
++ deinterlacing = false;
++ else
++ deinterlacing = true;
++
++ glEnable(m_textureTarget);
++ VerifyGLState();
++
++ glPixelStorei(GL_UNPACK_ALIGNMENT,1);
++
++ if (deinterlacing)
++ {
++ // Load Even Y Field
++ LoadPlane( fields[FIELD_TOP][0] , GL_LUMINANCE, buf.flipindex
++ , im->width, im->height >> 1
++ , im->stride[0]*2, im->plane[0] );
++
++ //load Odd Y Field
++ LoadPlane( fields[FIELD_BOT][0], GL_LUMINANCE, buf.flipindex
++ , im->width, im->height >> 1
++ , im->stride[0]*2, im->plane[0] + im->stride[0], &buf.pbo[0] ) ;
++
++ // Load Even U & V Fields
++ LoadPlane( fields[FIELD_TOP][1], GL_LUMINANCE, buf.flipindex
++ , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
++ , im->stride[1]*2, im->plane[0] + im->planesize[0] + im->planesize[1], &buf.pbo[0] );
++
++ LoadPlane( fields[FIELD_TOP][2], GL_ALPHA, buf.flipindex
++ , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
++ , im->stride[2]*2, im->plane[0] + im->planesize[0], &buf.pbo[0] );
++
++ // Load Odd U & V Fields
++ LoadPlane( fields[FIELD_BOT][1], GL_LUMINANCE, buf.flipindex
++ , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
++ , im->stride[1]*2, im->plane[0] + im->stride[1] + im->planesize[0] + im->planesize[1], &buf.pbo[0] );
++
++ LoadPlane( fields[FIELD_BOT][2], GL_ALPHA, buf.flipindex
++ , im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
++ , im->stride[2]*2, im->plane[0] + im->stride[2] + im->planesize[0], &buf.pbo[0] );
++ }
++ else
++ {
++ //Load Y plane
++ LoadPlane( fields[FIELD_FULL][0], GL_LUMINANCE, buf.flipindex
++ , im->width, im->height
++ , im->stride[0], im->plane[0], &buf.pbo[0] );
++
++ //load U plane
++ LoadPlane( fields[FIELD_FULL][1], GL_LUMINANCE, buf.flipindex
++ , im->width >> im->cshift_x, im->height >> im->cshift_y
++ , im->stride[1], im->plane[0] + im->planesize[0] + im->planesize[1] , &buf.pbo[0] );
++
++ //load V plane
++ LoadPlane( fields[FIELD_FULL][2], GL_ALPHA, buf.flipindex
++ , im->width >> im->cshift_x, im->height >> im->cshift_y
++ , im->stride[2], im->plane[0] + im->planesize[0], &buf.pbo[0] );
++ }
++
++ m_eventTexturesDone[source]->Set();
++
++ VerifyGLState();
++
++ // crop texture
++ CRect crop = xvba->GetCropRect();
++ m_sourceRect.x1 += crop.x1;
++ m_sourceRect.x2 -= m_sourceWidth - crop.x2;
++ m_sourceRect.y1 += crop.y1;
++ m_sourceRect.y2 -= m_sourceHeight - crop.y2;
++ CalculateTextureSourceRects(source, 3);
++
++ glDisable(m_textureTarget);
++#endif
++}
++
+ void CLinuxRendererGL::UploadYUV422PackedTexture(int source)
+ {
+ YUVBUFFER& buf = m_buffers[source];
+@@ -2935,6 +3462,9 @@
+ if (m_renderMethod & RENDER_VAAPI)
+ return false;
+
++ if (m_renderMethod & RENDER_XVBA)
++ return false;
++
+ return (m_renderMethod & RENDER_GLSL)
+ || (m_renderMethod & RENDER_ARB)
+ || ((m_renderMethod & RENDER_SW) && glewIsSupported("GL_ARB_imaging") == GL_TRUE);
+@@ -2948,6 +3478,9 @@
+ if (m_renderMethod & RENDER_VAAPI)
+ return false;
+
++ if (m_renderMethod & RENDER_XVBA)
++ return false;
++
+ return (m_renderMethod & RENDER_GLSL)
+ || (m_renderMethod & RENDER_ARB)
+ || ((m_renderMethod & RENDER_SW) && glewIsSupported("GL_ARB_imaging") == GL_TRUE);
+@@ -2971,7 +3504,8 @@
+ if (feature == RENDERFEATURE_NONLINSTRETCH)
+ {
+ if (((m_renderMethod & RENDER_GLSL) && !(m_renderMethod & RENDER_POT)) ||
+- (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI))
++ (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI) ||
++ (m_renderMethod & RENDER_XVBA))
+ return true;
+ }
+
+@@ -3034,10 +3568,22 @@
+ return false;
+ #endif
+
+- if(method == VS_INTERLACEMETHOD_DEINTERLACE
+- || method == VS_INTERLACEMETHOD_DEINTERLACE_HALF
+- || method == VS_INTERLACEMETHOD_SW_BLEND)
+- return true;
++ if (CONF_FLAGS_FORMAT_MASK(m_iFlags) != CONF_FLAGS_FORMAT_XVBA)
++ {
++ if(method == VS_INTERLACEMETHOD_DEINTERLACE
++ || method == VS_INTERLACEMETHOD_DEINTERLACE_HALF
++ || method == VS_INTERLACEMETHOD_SW_BLEND)
++ return true;
++ }
++
++ if(m_renderMethod & RENDER_XVBA)
++ {
++ if (method == VS_INTERLACEMETHOD_RENDER_BOB_INVERTED
++ || method == VS_INTERLACEMETHOD_RENDER_BOB)
++ return true;
++ else
++ return false;
++ }
+
+ if((method == VS_INTERLACEMETHOD_RENDER_BLEND
+ || method == VS_INTERLACEMETHOD_RENDER_WEAVE_INVERTED
+@@ -3069,7 +3615,7 @@
+ || method == VS_SCALINGMETHOD_LANCZOS3)
+ {
+ if ((glewIsSupported("GL_EXT_framebuffer_object") && (m_renderMethod & RENDER_GLSL)) ||
+- (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI))
++ (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI) || (m_renderMethod & RENDER_XVBA))
+ {
+ // spline36 and lanczos3 are only allowed through advancedsettings.xml
+ if(method != VS_SCALINGMETHOD_SPLINE36
+@@ -3128,7 +3674,7 @@
+ pbo = true;
+
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, buff.pbo[plane]);
+- glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, buff.image.planesize[plane] + PBO_OFFSET, NULL, GL_STREAM_DRAW_ARB);
++ glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, buff.image.planesize[plane] + buff.image.planesize[plane]/2 + PBO_OFFSET, NULL, GL_STREAM_DRAW_ARB);
+ buff.image.plane[plane] = (BYTE*)glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY_ARB) + PBO_OFFSET;
+ }
+ if(pbo)
+@@ -3152,4 +3698,13 @@
+ }
+ #endif
+
++#ifdef HAVE_LIBXVBA
++void CLinuxRendererGL::AddProcessor(XVBA::CDecoder* xvba)
++{
++ YUVBUFFER &buf = m_buffers[NextYV12Texture()];
++ SAFE_RELEASE(buf.xvba_tmp);
++ buf.xvba_tmp = (XVBA::CDecoder*)xvba->Acquire();
++}
++#endif
++
+ #endif
+diff -Naur xbmc-1fef727/xbmc/cores/VideoRenderers/LinuxRendererGL.h xbmc-1fef727.patch/xbmc/cores/VideoRenderers/LinuxRendererGL.h
+--- xbmc-1fef727/xbmc/cores/VideoRenderers/LinuxRendererGL.h 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/VideoRenderers/LinuxRendererGL.h 2012-02-07 14:30:18.013098470 +0100
+@@ -40,6 +40,7 @@
+ namespace Shaders { class BaseYUV2RGBShader; }
+ namespace Shaders { class BaseVideoFilterShader; }
+ namespace VAAPI { struct CHolder; }
++namespace XVBA { class CDecoder; }
+
+ #define NUM_BUFFERS 3
+
+@@ -94,6 +95,7 @@
+ RENDER_VDPAU=0x08,
+ RENDER_POT=0x10,
+ RENDER_VAAPI=0x20,
++ RENDER_XVBA=0x40,
+ };
+
+ enum RenderQuality
+@@ -141,6 +143,7 @@
+ virtual void UnInit();
+ virtual void Reset(); /* resets renderer after seek for example */
+ virtual void Flush();
++ virtual unsigned int GetProcessorSize();
+
+ #ifdef HAVE_LIBVDPAU
+ virtual void AddProcessor(CVDPAU* vdpau);
+@@ -148,6 +151,9 @@
+ #ifdef HAVE_LIBVA
+ virtual void AddProcessor(VAAPI::CHolder& holder);
+ #endif
++#ifdef HAVE_LIBXVBA
++ virtual void AddProcessor(XVBA::CDecoder* xvba);
++#endif
+
+ virtual void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255);
+
+@@ -194,6 +200,14 @@
+ void DeleteVAAPITexture(int index);
+ bool CreateVAAPITexture(int index);
+
++ void UploadXVBATexture(int index);
++ void DeleteXVBATexture(int index);
++ bool CreateXVBATexture(int index);
++
++ void UploadXVBAyv12Texture(int index);
++ void DeleteXVBAyv12Texture(int index);
++ bool CreateXVBAyv12Texture(int index);
++
+ void UploadYUV422PackedTexture(int index);
+ void DeleteYUV422PackedTexture(int index);
+ bool CreateYUV422PackedTexture(int index);
+@@ -211,6 +225,7 @@
+ void RenderSoftware(int renderBuffer, int field); // single pass s/w yuv2rgb renderer
+ void RenderVDPAU(int renderBuffer, int field); // render using vdpau hardware
+ void RenderVAAPI(int renderBuffer, int field); // render using vdpau hardware
++ void RenderXVBA(int renderBuffer, int field); // render using xvba hardware
+
+ CFrameBufferObject m_fbo;
+
+@@ -270,6 +285,10 @@
+ #ifdef HAVE_LIBVA
+ VAAPI::CHolder& vaapi;
+ #endif
++#ifdef HAVE_LIBXVBA
++ XVBA::CDecoder* xvba;
++ XVBA::CDecoder* xvba_tmp;
++#endif
+ };
+
+ typedef YUVBUFFER YUVBUFFERS[NUM_BUFFERS];
+diff -Naur xbmc-1fef727/xbmc/cores/VideoRenderers/RenderFlags.h xbmc-1fef727.patch/xbmc/cores/VideoRenderers/RenderFlags.h
+--- xbmc-1fef727/xbmc/cores/VideoRenderers/RenderFlags.h 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/VideoRenderers/RenderFlags.h 2012-02-07 14:30:18.013098470 +0100
+@@ -79,5 +79,7 @@
+ #define CONF_FLAGS_FORMAT_VAAPI 0x030000
+ #define CONF_FLAGS_FORMAT_OMXEGL 0x040000
+ #define CONF_FLAGS_FORMAT_CVBREF 0x080000
++#define CONF_FLAGS_FORMAT_XVBA 0x011000
++#define CONF_FLAGS_FORMAT_XVBA_YV12 0x012000
+ #define CONF_FLAGS_FORMAT_BYPASS 0x100000
+ #endif
+diff -Naur xbmc-1fef727/xbmc/cores/VideoRenderers/RenderManager.cpp xbmc-1fef727.patch/xbmc/cores/VideoRenderers/RenderManager.cpp
+--- xbmc-1fef727/xbmc/cores/VideoRenderers/RenderManager.cpp 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/VideoRenderers/RenderManager.cpp 2012-02-07 14:30:18.014098490 +0100
+@@ -53,6 +53,10 @@
+ #include "../dvdplayer/DVDCodecs/Video/DVDVideoCodec.h"
+ #include "../dvdplayer/DVDCodecs/DVDCodecUtils.h"
+
++#ifdef HAVE_LIBXVBA
++ #include "../dvdplayer/DVDCodecs/Video/XVBA.h"
++#endif
++
+ #define MAXPRESENTDELAY 0.500
+
+ /* at any point we want an exclusive lock on rendermanager */
+@@ -777,6 +781,25 @@
+ else if(pic.format == DVDVideoPicture::FMT_VAAPI)
+ m_pRenderer->AddProcessor(*pic.vaapi);
+ #endif
++#ifdef HAVE_LIBXVBA
++ else if(pic.format == DVDVideoPicture::FMT_XVBA)
++ {
++ if (pic.xvba)
++ {
++ m_pRenderer->AddProcessor(pic.xvba);
++ pic.xvba->Present(index);
++ }
++ }
++ else if(pic.format == DVDVideoPicture::FMT_XVBA_YV12)
++ {
++ if (pic.xvba)
++ {
++ m_pRenderer->AddProcessor(pic.xvba);
++ pic.xvba->Present(index);
++ pic.xvba->CopyYV12(index, image.plane[0]);
++ }
++ }
++#endif
+ m_pRenderer->ReleaseImage(index, false);
+
+ return index;
+diff -Naur xbmc-1fef727/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp xbmc-1fef727.patch/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp
+--- xbmc-1fef727/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp 2012-02-07 12:46:52.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp 2012-02-07 14:30:18.015098509 +0100
+@@ -186,6 +186,8 @@
+ m_defines += "#define XBMC_YUY2\n";
+ else if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_UYVY)
+ m_defines += "#define XBMC_UYVY\n";
++ if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_XVBA_YV12)
++ m_defines += "#define XBMC_YV12\n";
+
+ VertexShader()->LoadSource("yuv2rgb_vertex.glsl", m_defines);
+ #elif HAS_GLES == 2
+diff -Naur xbmc-1fef727/xbmc/dialogs/GUIDialogCache.cpp xbmc-1fef727.patch/xbmc/dialogs/GUIDialogCache.cpp
+--- xbmc-1fef727/xbmc/dialogs/GUIDialogCache.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/dialogs/GUIDialogCache.cpp 2012-02-07 14:30:18.032098844 +0100
@@ -29,7 +29,7 @@
#include "threads/SingleLock.h"
#include "utils/TimeUtils.h"
@@ -3895,11 +3844,10 @@ index 1114cc6..85548e4 100644
{
m_pDlg = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
-diff --git a/xbmc/filesystem/FileCache.cpp b/xbmc/filesystem/FileCache.cpp
-index c6af9d0..63937ef 100644
---- a/xbmc/filesystem/FileCache.cpp
-+++ b/xbmc/filesystem/FileCache.cpp
-@@ -79,7 +79,7 @@ private:
+diff -Naur xbmc-1fef727/xbmc/filesystem/FileCache.cpp xbmc-1fef727.patch/xbmc/filesystem/FileCache.cpp
+--- xbmc-1fef727/xbmc/filesystem/FileCache.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/filesystem/FileCache.cpp 2012-02-07 14:30:18.032098844 +0100
+@@ -79,7 +79,7 @@
};
@@ -3908,7 +3856,7 @@ index c6af9d0..63937ef 100644
{
m_bDeleteCache = true;
m_nSeekResult = 0;
-@@ -95,7 +95,7 @@ CFileCache::CFileCache()
+@@ -95,7 +95,7 @@
m_cacheFull = false;
}
@@ -3917,10 +3865,9 @@ index c6af9d0..63937ef 100644
{
m_pCache = pCache;
m_bDeleteCache = bDeleteCache;
-diff --git a/xbmc/filesystem/FilePipe.cpp b/xbmc/filesystem/FilePipe.cpp
-index 8426af0..c99aa6e 100644
---- a/xbmc/filesystem/FilePipe.cpp
-+++ b/xbmc/filesystem/FilePipe.cpp
+diff -Naur xbmc-1fef727/xbmc/filesystem/FilePipe.cpp xbmc-1fef727.patch/xbmc/filesystem/FilePipe.cpp
+--- xbmc-1fef727/xbmc/filesystem/FilePipe.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/filesystem/FilePipe.cpp 2012-02-07 14:30:18.033098864 +0100
@@ -24,6 +24,8 @@
#include "PipesManager.h"
#include "utils/StringUtils.h"
@@ -3930,11 +3877,10 @@ index 8426af0..c99aa6e 100644
using namespace XFILE;
CFilePipe::CFilePipe() : m_pos(0), m_length(-1), m_pipe(NULL)
-diff --git a/xbmc/filesystem/FileRar.cpp b/xbmc/filesystem/FileRar.cpp
-index 9c87a35..202b3ee 100644
---- a/xbmc/filesystem/FileRar.cpp
-+++ b/xbmc/filesystem/FileRar.cpp
-@@ -43,7 +43,7 @@ using namespace std;
+diff -Naur xbmc-1fef727/xbmc/filesystem/FileRar.cpp xbmc-1fef727.patch/xbmc/filesystem/FileRar.cpp
+--- xbmc-1fef727/xbmc/filesystem/FileRar.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/filesystem/FileRar.cpp 2012-02-07 14:30:18.033098864 +0100
+@@ -43,7 +43,7 @@
#define SEEKTIMOUT 30000
#ifdef HAS_FILESYSTEM_RAR
@@ -3943,11 +3889,10 @@ index 9c87a35..202b3ee 100644
{
m_pArc = NULL;
m_pCmd = NULL;
-diff --git a/xbmc/filesystem/HTSPDirectory.cpp b/xbmc/filesystem/HTSPDirectory.cpp
-index 83a1fca..152754d 100644
---- a/xbmc/filesystem/HTSPDirectory.cpp
-+++ b/xbmc/filesystem/HTSPDirectory.cpp
-@@ -76,7 +76,7 @@ static SSessions g_sessions;
+diff -Naur xbmc-1fef727/xbmc/filesystem/HTSPDirectory.cpp xbmc-1fef727.patch/xbmc/filesystem/HTSPDirectory.cpp
+--- xbmc-1fef727/xbmc/filesystem/HTSPDirectory.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/filesystem/HTSPDirectory.cpp 2012-02-07 14:30:18.034098884 +0100
+@@ -76,7 +76,7 @@
static CCriticalSection g_section;
@@ -3956,11 +3901,10 @@ index 83a1fca..152754d 100644
{
}
-diff --git a/xbmc/filesystem/LastFMDirectory.cpp b/xbmc/filesystem/LastFMDirectory.cpp
-index af5621c..a4b23fc 100644
---- a/xbmc/filesystem/LastFMDirectory.cpp
-+++ b/xbmc/filesystem/LastFMDirectory.cpp
-@@ -69,7 +69,7 @@ bool CLastFMDirectory::RetrieveList(CStdString url)
+diff -Naur xbmc-1fef727/xbmc/filesystem/LastFMDirectory.cpp xbmc-1fef727.patch/xbmc/filesystem/LastFMDirectory.cpp
+--- xbmc-1fef727/xbmc/filesystem/LastFMDirectory.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/filesystem/LastFMDirectory.cpp 2012-02-07 14:30:18.035098904 +0100
+@@ -69,7 +69,7 @@
m_dlgProgress->Progress();
}
@@ -3969,11 +3913,10 @@ index af5621c..a4b23fc 100644
m_strSource = url;
m_strDestination = "special://temp/lastfm.xml";
thread.Create();
-diff --git a/xbmc/filesystem/MythSession.cpp b/xbmc/filesystem/MythSession.cpp
-index 45de2cc..304ecdd 100644
---- a/xbmc/filesystem/MythSession.cpp
-+++ b/xbmc/filesystem/MythSession.cpp
-@@ -359,7 +359,7 @@ void CMythSession::SetSeasonAndEpisode(const cmyth_proginfo_t &program, int *sea
+diff -Naur xbmc-1fef727/xbmc/filesystem/MythSession.cpp xbmc-1fef727.patch/xbmc/filesystem/MythSession.cpp
+--- xbmc-1fef727/xbmc/filesystem/MythSession.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/filesystem/MythSession.cpp 2012-02-07 14:30:18.035098904 +0100
+@@ -359,7 +359,7 @@
return;
}
@@ -3982,10 +3925,9 @@ index 45de2cc..304ecdd 100644
{
m_control = NULL;
m_event = NULL;
-diff --git a/xbmc/filesystem/PipesManager.cpp b/xbmc/filesystem/PipesManager.cpp
-index 73f4aa2..80a1044 100644
---- a/xbmc/filesystem/PipesManager.cpp
-+++ b/xbmc/filesystem/PipesManager.cpp
+diff -Naur xbmc-1fef727/xbmc/filesystem/PipesManager.cpp xbmc-1fef727.patch/xbmc/filesystem/PipesManager.cpp
+--- xbmc-1fef727/xbmc/filesystem/PipesManager.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/filesystem/PipesManager.cpp 2012-02-07 14:30:18.036098923 +0100
@@ -23,6 +23,8 @@
#include "threads/SingleLock.h"
#include "Application.h"
@@ -3995,11 +3937,10 @@ index 73f4aa2..80a1044 100644
#ifndef min
#define min(a,b) ((a) < (b) ? (a) : (b))
#endif
-diff --git a/xbmc/filesystem/RarManager.h b/xbmc/filesystem/RarManager.h
-index dd4b2f0..6f93f79 100644
---- a/xbmc/filesystem/RarManager.h
-+++ b/xbmc/filesystem/RarManager.h
-@@ -71,7 +71,7 @@ public:
+diff -Naur xbmc-1fef727/xbmc/filesystem/RarManager.h xbmc-1fef727.patch/xbmc/filesystem/RarManager.h
+--- xbmc-1fef727/xbmc/filesystem/RarManager.h 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/filesystem/RarManager.h 2012-02-07 14:30:18.037098942 +0100
+@@ -71,7 +71,7 @@
CRarManager();
~CRarManager();
bool CacheRarredFile(CStdString& strPathInCache, const CStdString& strRarPath,
@@ -4008,11 +3949,10 @@ index dd4b2f0..6f93f79 100644
const CStdString& strDir =RAR_DEFAULT_CACHE, const int64_t iSize=-1);
bool GetPathInCache(CStdString& strPathInCache, const CStdString& strRarPath,
const CStdString& strPathInRar = "");
-diff --git a/xbmc/filesystem/SAPDirectory.cpp b/xbmc/filesystem/SAPDirectory.cpp
-index d8931b8..b997c12 100644
---- a/xbmc/filesystem/SAPDirectory.cpp
-+++ b/xbmc/filesystem/SAPDirectory.cpp
-@@ -272,7 +272,7 @@ namespace SDP
+diff -Naur xbmc-1fef727/xbmc/filesystem/SAPDirectory.cpp xbmc-1fef727.patch/xbmc/filesystem/SAPDirectory.cpp
+--- xbmc-1fef727/xbmc/filesystem/SAPDirectory.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/filesystem/SAPDirectory.cpp 2012-02-07 14:30:18.037098942 +0100
+@@ -272,7 +272,7 @@
using namespace SDP;
@@ -4021,7 +3961,7 @@ index d8931b8..b997c12 100644
{
m_socket = INVALID_SOCKET;
}
-@@ -486,7 +486,7 @@ namespace XFILE
+@@ -486,7 +486,7 @@
CSingleLock lock(g_sapsessions.m_section);
@@ -4030,42 +3970,10 @@ index d8931b8..b997c12 100644
g_sapsessions.Create();
// check if we can find this session in our cache
-diff --git a/xbmc/interfaces/python/XBPython.cpp b/xbmc/interfaces/python/XBPython.cpp
-index 9f43894..8cb3e61 100644
---- a/xbmc/interfaces/python/XBPython.cpp
-+++ b/xbmc/interfaces/python/XBPython.cpp
-@@ -676,11 +676,11 @@ void XBPython::PulseGlobalEvent()
- m_globalEvent.Set();
- }
-
--void XBPython::WaitForEvent(CEvent& hEvent, unsigned int timeout)
-+void XBPython::WaitForEvent(CEvent& hEvent)
- {
- // wait for either this event our our global event
- XbmcThreads::CEventGroup eventGroup(&hEvent, &m_globalEvent, NULL);
-- eventGroup.wait(timeout);
-+ eventGroup.wait();
- m_globalEvent.Reset();
- }
-
-diff --git a/xbmc/interfaces/python/XBPython.h b/xbmc/interfaces/python/XBPython.h
-index 7737744..8877b54 100644
---- a/xbmc/interfaces/python/XBPython.h
-+++ b/xbmc/interfaces/python/XBPython.h
-@@ -61,7 +61,7 @@ public:
- void Process();
-
- void PulseGlobalEvent();
-- void WaitForEvent(CEvent& hEvent, unsigned int timeout);
-+ void WaitForEvent(CEvent& hEvent);
-
- int ScriptsSize();
- int GetPythonScriptId(int scriptPosition);
-diff --git a/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp b/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp
-index 4ec7e23..d44fc23 100644
---- a/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp
-+++ b/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp
-@@ -181,9 +181,9 @@ void CGUIPythonWindow::SetCallbackWindow(void *state, void *object)
+diff -Naur xbmc-1fef727/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp xbmc-1fef727.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp
+--- xbmc-1fef727/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp 2012-02-07 14:30:18.039098982 +0100
+@@ -181,9 +181,9 @@
m_threadState = state;
}
@@ -4077,11 +3985,10 @@ index 4ec7e23..d44fc23 100644
m_actionEvent.Reset();
}
-diff --git a/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h b/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h
-index c776187..09c0d42 100644
---- a/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h
-+++ b/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h
-@@ -51,7 +51,7 @@ public:
+diff -Naur xbmc-1fef727/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h xbmc-1fef727.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h
+--- xbmc-1fef727/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h 2012-02-07 14:30:18.040099002 +0100
+@@ -51,7 +51,7 @@
virtual bool OnAction(const CAction &action);
virtual bool OnBack(int actionID);
void SetCallbackWindow(void* state, void *object);
@@ -4090,11 +3997,10 @@ index c776187..09c0d42 100644
void PulseActionEvent();
void SetDestroyAfterDeinit(bool destroy = true);
protected:
-diff --git a/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp b/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp
-index 2db79f1..9644351 100644
---- a/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp
-+++ b/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp
-@@ -279,9 +279,9 @@ void CGUIPythonWindowXML::ClearList()
+diff -Naur xbmc-1fef727/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp xbmc-1fef727.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp
+--- xbmc-1fef727/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp 2012-02-07 14:30:18.041099022 +0100
+@@ -279,9 +279,9 @@
UpdateButtons();
}
@@ -4106,11 +4012,10 @@ index 2db79f1..9644351 100644
m_actionEvent.Reset();
}
-diff --git a/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h b/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h
-index 27bc3a2..340be8b 100644
---- a/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h
-+++ b/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h
-@@ -40,7 +40,7 @@ public:
+diff -Naur xbmc-1fef727/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h xbmc-1fef727.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h
+--- xbmc-1fef727/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h 2012-02-07 14:30:18.041099022 +0100
+@@ -40,7 +40,7 @@
virtual void AllocResources(bool forceLoad = false);
virtual void FreeResources(bool forceUnLoad = false);
void Process(unsigned int currentTime, CDirtyRegionList ®ions);
@@ -4119,11 +4024,10 @@ index 27bc3a2..340be8b 100644
void PulseActionEvent();
void AddItem(CFileItemPtr fileItem,int itemPosition);
void RemoveItem(int itemPosition);
-diff --git a/xbmc/interfaces/python/xbmcmodule/window.cpp b/xbmc/interfaces/python/xbmcmodule/window.cpp
-index 9b9184a..1b72644 100644
---- a/xbmc/interfaces/python/xbmcmodule/window.cpp
-+++ b/xbmc/interfaces/python/xbmcmodule/window.cpp
-@@ -540,11 +540,11 @@ namespace PYXBMC
+diff -Naur xbmc-1fef727/xbmc/interfaces/python/xbmcmodule/window.cpp xbmc-1fef727.patch/xbmc/interfaces/python/xbmcmodule/window.cpp
+--- xbmc-1fef727/xbmc/interfaces/python/xbmcmodule/window.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/interfaces/python/xbmcmodule/window.cpp 2012-02-07 14:30:18.042099042 +0100
+@@ -540,11 +540,11 @@
CPyThreadState pyState;
if (WindowXML_Check(self))
@@ -4138,11 +4042,39 @@ index 9b9184a..1b72644 100644
}
}
Py_INCREF(Py_None);
-diff --git a/xbmc/linux/Makefile.in b/xbmc/linux/Makefile.in
-index c3a5877..43f552b 100644
---- a/xbmc/linux/Makefile.in
-+++ b/xbmc/linux/Makefile.in
-@@ -10,14 +10,11 @@ SRCS=ConvUtils.cpp \
+diff -Naur xbmc-1fef727/xbmc/interfaces/python/XBPython.cpp xbmc-1fef727.patch/xbmc/interfaces/python/XBPython.cpp
+--- xbmc-1fef727/xbmc/interfaces/python/XBPython.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/interfaces/python/XBPython.cpp 2012-02-07 14:30:18.038098962 +0100
+@@ -676,11 +676,11 @@
+ m_globalEvent.Set();
+ }
+
+-void XBPython::WaitForEvent(CEvent& hEvent, unsigned int timeout)
++void XBPython::WaitForEvent(CEvent& hEvent)
+ {
+ // wait for either this event our our global event
+ XbmcThreads::CEventGroup eventGroup(&hEvent, &m_globalEvent, NULL);
+- eventGroup.wait(timeout);
++ eventGroup.wait();
+ m_globalEvent.Reset();
+ }
+
+diff -Naur xbmc-1fef727/xbmc/interfaces/python/XBPython.h xbmc-1fef727.patch/xbmc/interfaces/python/XBPython.h
+--- xbmc-1fef727/xbmc/interfaces/python/XBPython.h 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/interfaces/python/XBPython.h 2012-02-07 14:30:18.039098982 +0100
+@@ -61,7 +61,7 @@
+ void Process();
+
+ void PulseGlobalEvent();
+- void WaitForEvent(CEvent& hEvent, unsigned int timeout);
++ void WaitForEvent(CEvent& hEvent);
+
+ int ScriptsSize();
+ int GetPythonScriptId(int scriptPosition);
+diff -Naur xbmc-1fef727/xbmc/linux/Makefile.in xbmc-1fef727.patch/xbmc/linux/Makefile.in
+--- xbmc-1fef727/xbmc/linux/Makefile.in 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/linux/Makefile.in 2012-02-07 14:30:18.043099062 +0100
+@@ -10,14 +10,11 @@
LinuxResourceCounter.cpp \
LinuxTimezone.cpp \
PosixMountProvider.cpp \
@@ -4157,10 +4089,9 @@ index c3a5877..43f552b 100644
LIB=linux.a
-diff --git a/xbmc/linux/PlatformDefs.h b/xbmc/linux/PlatformDefs.h
-index 33d1c96..55d20c5 100644
---- a/xbmc/linux/PlatformDefs.h
-+++ b/xbmc/linux/PlatformDefs.h
+diff -Naur xbmc-1fef727/xbmc/linux/PlatformDefs.h xbmc-1fef727.patch/xbmc/linux/PlatformDefs.h
+--- xbmc-1fef727/xbmc/linux/PlatformDefs.h 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/linux/PlatformDefs.h 2012-02-07 14:30:18.044099082 +0100
@@ -182,8 +182,6 @@
#define EXCEPTION_EXECUTE_HANDLER ...
//NOTE: dont try to define __except because it breaks g++ (already uses it).
@@ -4170,10 +4101,9 @@ index 33d1c96..55d20c5 100644
struct CXHandle; // forward declaration
typedef CXHandle* HANDLE;
-diff --git a/xbmc/linux/PlatformInclude.h b/xbmc/linux/PlatformInclude.h
-index 1f7e7e9..4e44ed8 100644
---- a/xbmc/linux/PlatformInclude.h
-+++ b/xbmc/linux/PlatformInclude.h
+diff -Naur xbmc-1fef727/xbmc/linux/PlatformInclude.h xbmc-1fef727.patch/xbmc/linux/PlatformInclude.h
+--- xbmc-1fef727/xbmc/linux/PlatformInclude.h 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/linux/PlatformInclude.h 2012-02-07 14:30:18.044099082 +0100
@@ -25,10 +25,7 @@
#include "PlatformDefs.h"
#include "XHandlePublic.h"
@@ -4185,11 +4115,9 @@ index 1f7e7e9..4e44ed8 100644
#include "XMemUtils.h"
#include "ConvUtils.h"
-diff --git a/xbmc/linux/XEventUtils.cpp b/xbmc/linux/XEventUtils.cpp
-deleted file mode 100644
-index 639b7b9..0000000
---- a/xbmc/linux/XEventUtils.cpp
-+++ /dev/null
+diff -Naur xbmc-1fef727/xbmc/linux/XEventUtils.cpp xbmc-1fef727.patch/xbmc/linux/XEventUtils.cpp
+--- xbmc-1fef727/xbmc/linux/XEventUtils.cpp 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/linux/XEventUtils.cpp 1970-01-01 01:00:00.000000000 +0100
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
@@ -4335,11 +4263,9 @@ index 639b7b9..0000000
- return true;
-}
-
-diff --git a/xbmc/linux/XEventUtils.h b/xbmc/linux/XEventUtils.h
-deleted file mode 100644
-index a77f843..0000000
---- a/xbmc/linux/XEventUtils.h
-+++ /dev/null
+diff -Naur xbmc-1fef727/xbmc/linux/XEventUtils.h xbmc-1fef727.patch/xbmc/linux/XEventUtils.h
+--- xbmc-1fef727/xbmc/linux/XEventUtils.h 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/linux/XEventUtils.h 1970-01-01 01:00:00.000000000 +0100
@@ -1,38 +0,0 @@
-#ifndef __X_EVENT_UTIL_H__
-#define __X_EVENT_UTIL_H__
@@ -4379,10 +4305,9 @@ index a77f843..0000000
-
-#endif
-
-diff --git a/xbmc/linux/XHandle.cpp b/xbmc/linux/XHandle.cpp
-index 61520b2..52f540a 100644
---- a/xbmc/linux/XHandle.cpp
-+++ b/xbmc/linux/XHandle.cpp
+diff -Naur xbmc-1fef727/xbmc/linux/XHandle.cpp xbmc-1fef727.patch/xbmc/linux/XHandle.cpp
+--- xbmc-1fef727/xbmc/linux/XHandle.cpp 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/linux/XHandle.cpp 2012-02-07 14:30:18.051099219 +0100
@@ -20,12 +20,15 @@
*/
@@ -4400,7 +4325,7 @@ index 61520b2..52f540a 100644
CXHandle::CXHandle()
{
Init();
-@@ -47,11 +50,6 @@ CXHandle::CXHandle(const CXHandle &src)
+@@ -47,11 +50,6 @@
Init();
@@ -4412,7 +4337,7 @@ index 61520b2..52f540a 100644
if (src.m_hMutex)
m_hMutex = new CCriticalSection();
-@@ -80,7 +78,7 @@ CXHandle::~CXHandle()
+@@ -80,7 +78,7 @@
CLog::Log(LOGERROR,"%s, destroying handle with ref count %d", __FUNCTION__, m_nRefCount);
assert(false);
}
@@ -4421,7 +4346,7 @@ index 61520b2..52f540a 100644
if (m_hMutex) {
delete m_hMutex;
}
-@@ -93,10 +91,6 @@ CXHandle::~CXHandle()
+@@ -93,10 +91,6 @@
delete m_hCond;
}
@@ -4432,7 +4357,7 @@ index 61520b2..52f540a 100644
if ( fd != 0 ) {
close(fd);
}
-@@ -107,11 +101,9 @@ void CXHandle::Init()
+@@ -107,11 +101,9 @@
{
fd=0;
m_hMutex=NULL;
@@ -4444,10 +4369,9 @@ index 61520b2..52f540a 100644
m_bManualEvent=FALSE;
m_bEventSet=FALSE;
m_nFindFileIterator=0 ;
-diff --git a/xbmc/linux/XHandle.h b/xbmc/linux/XHandle.h
-index 0e119bc..dd7f37d 100644
---- a/xbmc/linux/XHandle.h
-+++ b/xbmc/linux/XHandle.h
+diff -Naur xbmc-1fef727/xbmc/linux/XHandle.h xbmc-1fef727.patch/xbmc/linux/XHandle.h
+--- xbmc-1fef727/xbmc/linux/XHandle.h 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/linux/XHandle.h 2012-02-07 14:30:18.051099219 +0100
@@ -25,7 +25,6 @@
#ifndef _WIN32
@@ -4465,7 +4389,7 @@ index 0e119bc..dd7f37d 100644
CXHandle();
CXHandle(HandleType nType);
-@@ -47,8 +46,6 @@ public:
+@@ -47,8 +46,6 @@
inline HandleType GetType() { return m_type; }
void ChangeType(HandleType newType);
@@ -4474,7 +4398,7 @@ index 0e119bc..dd7f37d 100644
XbmcThreads::ConditionVariable *m_hCond;
std::list m_hParents;
-@@ -62,7 +59,6 @@ public:
+@@ -62,7 +59,6 @@
// simulate mutex and critical section
CCriticalSection *m_hMutex;
int RecursionCount; // for mutex - for compatibility with WIN32 critical section
@@ -4482,10 +4406,9 @@ index 0e119bc..dd7f37d 100644
int fd;
bool m_bManualEvent;
time_t m_tmCreation;
-diff --git a/xbmc/linux/XMemUtils.cpp b/xbmc/linux/XMemUtils.cpp
-index 906fe4e..c0006fe 100644
---- a/xbmc/linux/XMemUtils.cpp
-+++ b/xbmc/linux/XMemUtils.cpp
+diff -Naur xbmc-1fef727/xbmc/linux/XMemUtils.cpp xbmc-1fef727.patch/xbmc/linux/XMemUtils.cpp
+--- xbmc-1fef727/xbmc/linux/XMemUtils.cpp 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/linux/XMemUtils.cpp 2012-02-07 14:30:18.052099238 +0100
@@ -25,6 +25,10 @@
#include "XMemUtils.h"
@@ -4497,7 +4420,7 @@ index 906fe4e..c0006fe 100644
#undef ALIGN
#define ALIGN(value, alignment) (((value)+(alignment-1))&~(alignment-1))
-@@ -49,4 +53,130 @@ void _aligned_free(void *p) {
+@@ -49,4 +53,130 @@
free(pFull);
}
@@ -4628,10 +4551,9 @@ index 906fe4e..c0006fe 100644
+
+#endif
-diff --git a/xbmc/linux/XMemUtils.h b/xbmc/linux/XMemUtils.h
-index d6d314a..83fc95d 100644
---- a/xbmc/linux/XMemUtils.h
-+++ b/xbmc/linux/XMemUtils.h
+diff -Naur xbmc-1fef727/xbmc/linux/XMemUtils.h xbmc-1fef727.patch/xbmc/linux/XMemUtils.h
+--- xbmc-1fef727/xbmc/linux/XMemUtils.h 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/linux/XMemUtils.h 2012-02-07 14:30:18.053099258 +0100
@@ -22,10 +22,14 @@
*
*/
@@ -4647,11 +4569,9 @@ index d6d314a..83fc95d 100644
+
#endif
-diff --git a/xbmc/linux/XSyncUtils.cpp b/xbmc/linux/XSyncUtils.cpp
-deleted file mode 100644
-index 19c4b5a..0000000
---- a/xbmc/linux/XSyncUtils.cpp
-+++ /dev/null
+diff -Naur xbmc-1fef727/xbmc/linux/XSyncUtils.cpp xbmc-1fef727.patch/xbmc/linux/XSyncUtils.cpp
+--- xbmc-1fef727/xbmc/linux/XSyncUtils.cpp 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/linux/XSyncUtils.cpp 1970-01-01 01:00:00.000000000 +0100
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
@@ -4822,11 +4742,9 @@ index 19c4b5a..0000000
-}
-
-#endif
-diff --git a/xbmc/linux/XSyncUtils.h b/xbmc/linux/XSyncUtils.h
-deleted file mode 100644
-index f3ad36f..0000000
---- a/xbmc/linux/XSyncUtils.h
-+++ /dev/null
+diff -Naur xbmc-1fef727/xbmc/linux/XSyncUtils.h xbmc-1fef727.patch/xbmc/linux/XSyncUtils.h
+--- xbmc-1fef727/xbmc/linux/XSyncUtils.h 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/linux/XSyncUtils.h 1970-01-01 01:00:00.000000000 +0100
@@ -1,44 +0,0 @@
-#ifndef __X_SYNC_UTILS_
-#define __X_SYNC_UTILS_
@@ -4872,11 +4790,9 @@ index f3ad36f..0000000
-
-#endif
-
-diff --git a/xbmc/linux/XThreadUtils.cpp b/xbmc/linux/XThreadUtils.cpp
-deleted file mode 100644
-index 9d68481..0000000
---- a/xbmc/linux/XThreadUtils.cpp
-+++ /dev/null
+diff -Naur xbmc-1fef727/xbmc/linux/XThreadUtils.cpp xbmc-1fef727.patch/xbmc/linux/XThreadUtils.cpp
+--- xbmc-1fef727/xbmc/linux/XThreadUtils.cpp 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/linux/XThreadUtils.cpp 1970-01-01 01:00:00.000000000 +0100
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2005-2009 Team XBMC
@@ -5088,148 +5004,10 @@ index 9d68481..0000000
-
-#endif
-
-diff --git a/xbmc/linux/XThreadUtils.h b/xbmc/linux/XThreadUtils.h
-deleted file mode 100644
-index 41b659e..0000000
---- a/xbmc/linux/XThreadUtils.h
-+++ /dev/null
-@@ -1,100 +0,0 @@
--#ifndef __XTHREAD_UTILS__H__
--#define __XTHREAD_UTILS__H__
--
--/*
-- * Copyright (C) 2005-2009 Team XBMC
-- * http://www.xbmc.org
-- *
-- * This Program is free software; you can redistribute it and/or modify
-- * it under the terms of the GNU General Public License as published by
-- * the Free Software Foundation; either version 2, or (at your option)
-- * any later version.
-- *
-- * This Program is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- * GNU General Public License for more details.
-- *
-- * You should have received a copy of the GNU General Public License
-- * along with XBMC; see the file COPYING. If not, write to
-- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-- * http://www.gnu.org/copyleft/gpl.html
-- *
-- */
--
--#include
--
--HANDLE WINAPI CreateThread(
-- LPSECURITY_ATTRIBUTES lpThreadAttributes,
-- SIZE_T dwStackSize,
-- LPTHREAD_START_ROUTINE lpStartAddress,
-- LPVOID lpParameter,
-- DWORD dwCreationFlags,
-- LPDWORD lpThreadId
-- );
--
--HANDLE _beginthreadex(
-- void *security,
-- unsigned stack_size,
-- int ( *start_address )( void * ),
-- void *arglist,
-- unsigned initflag,
-- unsigned *thrdaddr
--);
--
--uintptr_t _beginthread(
-- void( *start_address )( void * ),
-- unsigned stack_size,
-- void *arglist
--);
--
--#if 0 // Deprecated, use CThread::GetCurrentThreadId() instead
--DWORD WINAPI GetCurrentThreadId(void);
--#endif
--
--HANDLE WINAPI GetCurrentThread(void);
--HANDLE WINAPI GetCurrentProcess(void);
--
--BOOL WINAPI GetThreadTimes (
-- HANDLE hThread,
-- LPFILETIME lpCreationTime,
-- LPFILETIME lpExitTime,
-- LPFILETIME lpKernelTime,
-- LPFILETIME lpUserTime
--);
--
--int GetThreadPriority(
-- HANDLE hThread
--);
--
--BOOL WINAPI SetThreadPriority(
-- HANDLE hThread,
-- int nPriority
--);
--
--// helper class for TLS handling
--class TLS
--{
--public:
-- TLS()
-- {
-- pthread_key_create(&m_key, free);
-- }
--
-- ~TLS()
-- {
-- pthread_key_delete(m_key);
-- }
--
-- void *Get()
-- {
-- if (pthread_getspecific(m_key) == NULL)
--pthread_setspecific(m_key, malloc(8));
--
-- return pthread_getspecific(m_key);
-- }
--
-- pthread_key_t m_key;
--};
--
--#endif
-diff --git a/xbmc/music/LastFmManager.cpp b/xbmc/music/LastFmManager.cpp
-index 700f28a..b97fdf2 100644
---- a/xbmc/music/LastFmManager.cpp
-+++ b/xbmc/music/LastFmManager.cpp
-@@ -70,7 +70,7 @@ using namespace XFILE;
-
- CLastFmManager* CLastFmManager::m_pInstance=NULL;
-
--CLastFmManager::CLastFmManager()
-+CLastFmManager::CLastFmManager() : CThread("CLastFmManager")
- {
- m_RadioTrackQueue = new CPlayList;
- }
-@@ -534,7 +534,7 @@ void CLastFmManager::Update()
- if (iNrCachedTracks == 0)
- {
- //get more tracks
-- if (ThreadHandle() != NULL)
-+ if (IsRunning())
- {
- m_hWorkerEvent.Set();
- }
-@@ -633,7 +633,7 @@ void CLastFmManager::StopRadio(bool bKillSession /*= true*/)
- {
- m_RadioSession = "";
- }
-- if (m_ThreadHandle)
-+ if (IsRunning())
- {
- m_bStop = true;
- m_hWorkerEvent.Set();
-diff --git a/xbmc/music/infoscanner/MusicInfoScanner.cpp b/xbmc/music/infoscanner/MusicInfoScanner.cpp
-index 3400f27..445edaf 100644
---- a/xbmc/music/infoscanner/MusicInfoScanner.cpp
-+++ b/xbmc/music/infoscanner/MusicInfoScanner.cpp
-@@ -57,7 +57,7 @@ using namespace MUSIC_INFO;
+diff -Naur xbmc-1fef727/xbmc/music/infoscanner/MusicInfoScanner.cpp xbmc-1fef727.patch/xbmc/music/infoscanner/MusicInfoScanner.cpp
+--- xbmc-1fef727/xbmc/music/infoscanner/MusicInfoScanner.cpp 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/music/infoscanner/MusicInfoScanner.cpp 2012-02-07 14:30:18.056099318 +0100
+@@ -57,7 +57,7 @@
using namespace XFILE;
using namespace MUSIC_GRABBER;
@@ -5238,7 +5016,7 @@ index 3400f27..445edaf 100644
{
m_bRunning = false;
m_pObserver = NULL;
-@@ -99,7 +99,7 @@ void CMusicInfoScanner::Process()
+@@ -99,7 +99,7 @@
// Create the thread to count all files to be scanned
SetPriority( GetMinPriority() );
@@ -5247,11 +5025,10 @@ index 3400f27..445edaf 100644
if (m_pObserver)
fileCountReader.Create();
-diff --git a/xbmc/music/infoscanner/MusicInfoScraper.cpp b/xbmc/music/infoscanner/MusicInfoScraper.cpp
-index 09aeb14..aad726c 100644
---- a/xbmc/music/infoscanner/MusicInfoScraper.cpp
-+++ b/xbmc/music/infoscanner/MusicInfoScraper.cpp
-@@ -28,7 +28,7 @@ using namespace MUSIC_GRABBER;
+diff -Naur xbmc-1fef727/xbmc/music/infoscanner/MusicInfoScraper.cpp xbmc-1fef727.patch/xbmc/music/infoscanner/MusicInfoScraper.cpp
+--- xbmc-1fef727/xbmc/music/infoscanner/MusicInfoScraper.cpp 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/music/infoscanner/MusicInfoScraper.cpp 2012-02-07 14:30:18.057099338 +0100
+@@ -28,7 +28,7 @@
using namespace ADDON;
using namespace std;
@@ -5260,11 +5037,40 @@ index 09aeb14..aad726c 100644
{
m_bSucceeded=false;
m_bCanceled=false;
-diff --git a/xbmc/network/AirPlayServer.cpp b/xbmc/network/AirPlayServer.cpp
-index 5a14773..dda7f0b 100644
---- a/xbmc/network/AirPlayServer.cpp
-+++ b/xbmc/network/AirPlayServer.cpp
-@@ -182,7 +182,7 @@ void CAirPlayServer::StopServer(bool bWait)
+diff -Naur xbmc-1fef727/xbmc/music/LastFmManager.cpp xbmc-1fef727.patch/xbmc/music/LastFmManager.cpp
+--- xbmc-1fef727/xbmc/music/LastFmManager.cpp 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/music/LastFmManager.cpp 2012-02-07 14:30:18.055099298 +0100
+@@ -70,7 +70,7 @@
+
+ CLastFmManager* CLastFmManager::m_pInstance=NULL;
+
+-CLastFmManager::CLastFmManager()
++CLastFmManager::CLastFmManager() : CThread("CLastFmManager")
+ {
+ m_RadioTrackQueue = new CPlayList;
+ }
+@@ -534,7 +534,7 @@
+ if (iNrCachedTracks == 0)
+ {
+ //get more tracks
+- if (ThreadHandle() != NULL)
++ if (IsRunning())
+ {
+ m_hWorkerEvent.Set();
+ }
+@@ -633,7 +633,7 @@
+ {
+ m_RadioSession = "";
+ }
+- if (m_ThreadHandle)
++ if (IsRunning())
+ {
+ m_bStop = true;
+ m_hWorkerEvent.Set();
+diff -Naur xbmc-1fef727/xbmc/network/AirPlayServer.cpp xbmc-1fef727.patch/xbmc/network/AirPlayServer.cpp
+--- xbmc-1fef727/xbmc/network/AirPlayServer.cpp 2012-02-07 12:46:47.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/network/AirPlayServer.cpp 2012-02-07 14:30:18.058099358 +0100
+@@ -183,7 +183,7 @@
}
}
@@ -5273,11 +5079,10 @@ index 5a14773..dda7f0b 100644
{
m_port = port;
m_nonlocal = nonlocal;
-diff --git a/xbmc/network/AirTunesServer.cpp b/xbmc/network/AirTunesServer.cpp
-index 8779c7c..24ffa6f 100644
---- a/xbmc/network/AirTunesServer.cpp
-+++ b/xbmc/network/AirTunesServer.cpp
-@@ -295,7 +295,7 @@ void CAirTunesServer::StopServer(bool bWait)
+diff -Naur xbmc-1fef727/xbmc/network/AirTunesServer.cpp xbmc-1fef727.patch/xbmc/network/AirTunesServer.cpp
+--- xbmc-1fef727/xbmc/network/AirTunesServer.cpp 2012-02-07 12:46:47.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/network/AirTunesServer.cpp 2012-02-07 14:30:18.058099358 +0100
+@@ -295,7 +295,7 @@
}
}
@@ -5286,60 +5091,9 @@ index 8779c7c..24ffa6f 100644
{
m_port = port;
m_pLibShairport = new DllLibShairport();
-diff --git a/xbmc/network/Network.h b/xbmc/network/Network.h
-index cb0ea52..e514e05 100644
---- a/xbmc/network/Network.h
-+++ b/xbmc/network/Network.h
-@@ -24,6 +24,7 @@
-
- #include
- #include "utils/StdString.h"
-+#include "system.h"
-
- enum EncMode { ENC_NONE = 0, ENC_WEP = 1, ENC_WPA = 2, ENC_WPA2 = 3 };
- enum NetworkAssignment { NETWORK_DASH = 0, NETWORK_DHCP = 1, NETWORK_STATIC = 2, NETWORK_DISABLED = 3 };
-diff --git a/xbmc/network/TCPServer.cpp b/xbmc/network/TCPServer.cpp
-index 4b0d9ad..fd46236 100644
---- a/xbmc/network/TCPServer.cpp
-+++ b/xbmc/network/TCPServer.cpp
-@@ -85,7 +85,7 @@ void CTCPServer::StopServer(bool bWait)
- }
- }
-
--CTCPServer::CTCPServer(int port, bool nonlocal)
-+CTCPServer::CTCPServer(int port, bool nonlocal) : CThread("CTCPServer")
- {
- m_port = port;
- m_nonlocal = nonlocal;
-diff --git a/xbmc/network/UdpClient.cpp b/xbmc/network/UdpClient.cpp
-index 8e1ef2e..8f49ce8 100644
---- a/xbmc/network/UdpClient.cpp
-+++ b/xbmc/network/UdpClient.cpp
-@@ -35,7 +35,7 @@
-
- #define UDPCLIENT_DEBUG_LEVEL LOGDEBUG
-
--CUdpClient::CUdpClient(void) : CThread()
-+CUdpClient::CUdpClient(void) : CThread("CUdpClient")
- {}
-
- CUdpClient::~CUdpClient(void)
-diff --git a/xbmc/network/UdpClient.h b/xbmc/network/UdpClient.h
-index 97acb28..a1aa597 100644
---- a/xbmc/network/UdpClient.h
-+++ b/xbmc/network/UdpClient.h
-@@ -25,6 +25,7 @@
- #include "threads/CriticalSection.h"
- #include
- #include
-+#include "system.h"
-
- class CUdpClient : CThread
- {
-diff --git a/xbmc/network/libscrobbler/scrobbler.cpp b/xbmc/network/libscrobbler/scrobbler.cpp
-index cb08d1b..cf5f927 100644
---- a/xbmc/network/libscrobbler/scrobbler.cpp
-+++ b/xbmc/network/libscrobbler/scrobbler.cpp
+diff -Naur xbmc-1fef727/xbmc/network/libscrobbler/scrobbler.cpp xbmc-1fef727.patch/xbmc/network/libscrobbler/scrobbler.cpp
+--- xbmc-1fef727/xbmc/network/libscrobbler/scrobbler.cpp 2012-02-07 12:46:47.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/network/libscrobbler/scrobbler.cpp 2012-02-07 14:30:18.061099416 +0100
@@ -46,7 +46,7 @@
#define SCROBBLER_ACTION_NOWPLAYING 2
@@ -5349,7 +5103,7 @@ index cb08d1b..cf5f927 100644
{
m_bBanned = false;
m_bBadAuth = false;
-@@ -67,7 +67,7 @@ void CScrobbler::Init()
+@@ -67,7 +67,7 @@
ResetState();
LoadCredentials();
LoadJournal();
@@ -5358,10 +5112,55 @@ index cb08d1b..cf5f927 100644
Create();
}
-diff --git a/xbmc/peripherals/Peripherals.cpp b/xbmc/peripherals/Peripherals.cpp
-index 3868cc7..ffd78d2 100644
---- a/xbmc/peripherals/Peripherals.cpp
-+++ b/xbmc/peripherals/Peripherals.cpp
+diff -Naur xbmc-1fef727/xbmc/network/Network.h xbmc-1fef727.patch/xbmc/network/Network.h
+--- xbmc-1fef727/xbmc/network/Network.h 2012-02-07 12:46:47.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/network/Network.h 2012-02-07 14:30:18.059099378 +0100
+@@ -24,6 +24,7 @@
+
+ #include
+ #include "utils/StdString.h"
++#include "system.h"
+
+ enum EncMode { ENC_NONE = 0, ENC_WEP = 1, ENC_WPA = 2, ENC_WPA2 = 3 };
+ enum NetworkAssignment { NETWORK_DASH = 0, NETWORK_DHCP = 1, NETWORK_STATIC = 2, NETWORK_DISABLED = 3 };
+diff -Naur xbmc-1fef727/xbmc/network/TCPServer.cpp xbmc-1fef727.patch/xbmc/network/TCPServer.cpp
+--- xbmc-1fef727/xbmc/network/TCPServer.cpp 2012-02-07 12:46:47.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/network/TCPServer.cpp 2012-02-07 14:30:18.059099378 +0100
+@@ -85,7 +85,7 @@
+ }
+ }
+
+-CTCPServer::CTCPServer(int port, bool nonlocal)
++CTCPServer::CTCPServer(int port, bool nonlocal) : CThread("CTCPServer")
+ {
+ m_port = port;
+ m_nonlocal = nonlocal;
+diff -Naur xbmc-1fef727/xbmc/network/UdpClient.cpp xbmc-1fef727.patch/xbmc/network/UdpClient.cpp
+--- xbmc-1fef727/xbmc/network/UdpClient.cpp 2012-02-07 12:46:47.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/network/UdpClient.cpp 2012-02-07 14:30:18.060099397 +0100
+@@ -35,7 +35,7 @@
+
+ #define UDPCLIENT_DEBUG_LEVEL LOGDEBUG
+
+-CUdpClient::CUdpClient(void) : CThread()
++CUdpClient::CUdpClient(void) : CThread("CUdpClient")
+ {}
+
+ CUdpClient::~CUdpClient(void)
+diff -Naur xbmc-1fef727/xbmc/network/UdpClient.h xbmc-1fef727.patch/xbmc/network/UdpClient.h
+--- xbmc-1fef727/xbmc/network/UdpClient.h 2012-02-07 12:46:47.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/network/UdpClient.h 2012-02-07 14:30:18.060099397 +0100
+@@ -25,6 +25,7 @@
+ #include "threads/CriticalSection.h"
+ #include
+ #include
++#include "system.h"
+
+ class CUdpClient : CThread
+ {
+diff -Naur xbmc-1fef727/xbmc/peripherals/Peripherals.cpp xbmc-1fef727.patch/xbmc/peripherals/Peripherals.cpp
+--- xbmc-1fef727/xbmc/peripherals/Peripherals.cpp 2012-02-07 12:46:48.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/peripherals/Peripherals.cpp 2012-02-07 14:30:18.062099436 +0100
@@ -19,6 +19,7 @@
*
*/
@@ -5370,11 +5169,10 @@ index 3868cc7..ffd78d2 100644
#include "Peripherals.h"
#include "bus/PeripheralBus.h"
#include "devices/PeripheralBluetooth.h"
-diff --git a/xbmc/pictures/GUIWindowSlideShow.cpp b/xbmc/pictures/GUIWindowSlideShow.cpp
-index ffe47a5..a7b54d2 100644
---- a/xbmc/pictures/GUIWindowSlideShow.cpp
-+++ b/xbmc/pictures/GUIWindowSlideShow.cpp
-@@ -67,7 +67,7 @@ using namespace XFILE;
+diff -Naur xbmc-1fef727/xbmc/pictures/GUIWindowSlideShow.cpp xbmc-1fef727.patch/xbmc/pictures/GUIWindowSlideShow.cpp
+--- xbmc-1fef727/xbmc/pictures/GUIWindowSlideShow.cpp 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/pictures/GUIWindowSlideShow.cpp 2012-02-07 14:30:18.063099456 +0100
+@@ -67,7 +67,7 @@
static float zoomamount[10] = { 1.0f, 1.2f, 1.5f, 2.0f, 2.8f, 4.0f, 6.0f, 9.0f, 13.5f, 20.0f };
@@ -5383,11 +5181,10 @@ index ffe47a5..a7b54d2 100644
{
m_pCallback = NULL;
m_isLoading = false;
-diff --git a/xbmc/rendering/dx/RenderSystemDX.cpp b/xbmc/rendering/dx/RenderSystemDX.cpp
-index 938cb36..ed92a41 100644
---- a/xbmc/rendering/dx/RenderSystemDX.cpp
-+++ b/xbmc/rendering/dx/RenderSystemDX.cpp
-@@ -569,7 +569,7 @@ bool CRenderSystemDX::PresentRenderImpl(const CDirtyRegionList &dirty)
+diff -Naur xbmc-1fef727/xbmc/rendering/dx/RenderSystemDX.cpp xbmc-1fef727.patch/xbmc/rendering/dx/RenderSystemDX.cpp
+--- xbmc-1fef727/xbmc/rendering/dx/RenderSystemDX.cpp 2012-02-07 12:46:48.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/rendering/dx/RenderSystemDX.cpp 2012-02-07 14:30:18.064099476 +0100
+@@ -569,7 +569,7 @@
//CVideoReferenceClock polls GetRasterStatus too,
//polling it from two threads at the same time is bad
@@ -5396,11 +5193,10 @@ index 938cb36..ed92a41 100644
{
//save current thread priority and set thread priority to THREAD_PRIORITY_TIME_CRITICAL
int priority = GetThreadPriority(GetCurrentThread());
-diff --git a/xbmc/settings/GUISettings.cpp b/xbmc/settings/GUISettings.cpp
-index e228621..b31dec0 100644
---- a/xbmc/settings/GUISettings.cpp
-+++ b/xbmc/settings/GUISettings.cpp
-@@ -592,6 +592,10 @@ void CGUISettings::Initialize()
+diff -Naur xbmc-1fef727/xbmc/settings/GUISettings.cpp xbmc-1fef727.patch/xbmc/settings/GUISettings.cpp
+--- xbmc-1fef727/xbmc/settings/GUISettings.cpp 2012-02-07 12:46:48.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/settings/GUISettings.cpp 2012-02-07 14:30:18.065099496 +0100
+@@ -587,6 +587,10 @@
#ifdef HAVE_LIBVA
AddBool(vp, "videoplayer.usevaapi", 13426, true);
#endif
@@ -5411,11 +5207,10 @@ index e228621..b31dec0 100644
#ifdef HAS_DX
AddBool(g_sysinfo.IsVistaOrHigher() ? vp: NULL, "videoplayer.usedxva2", 13427, g_sysinfo.IsVistaOrHigher() ? true : false);
#endif
-diff --git a/xbmc/settings/GUIWindowSettingsCategory.cpp b/xbmc/settings/GUIWindowSettingsCategory.cpp
-index eb04966..408152a 100644
---- a/xbmc/settings/GUIWindowSettingsCategory.cpp
-+++ b/xbmc/settings/GUIWindowSettingsCategory.cpp
-@@ -936,6 +936,15 @@ void CGUIWindowSettingsCategory::UpdateSettings()
+diff -Naur xbmc-1fef727/xbmc/settings/GUIWindowSettingsCategory.cpp xbmc-1fef727.patch/xbmc/settings/GUIWindowSettingsCategory.cpp
+--- xbmc-1fef727/xbmc/settings/GUIWindowSettingsCategory.cpp 2012-02-07 12:46:48.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/settings/GUIWindowSettingsCategory.cpp 2012-02-07 14:30:18.067099534 +0100
+@@ -921,6 +921,15 @@
pControl->SetEnabled(enabled);
}
}
@@ -5431,797 +5226,9 @@ index eb04966..408152a 100644
else if (strSetting.Equals("weather.addonsettings"))
{
AddonPtr addon;
-diff --git a/xbmc/threads/Thread.cpp b/xbmc/threads/Thread.cpp
-index bd213e2..becc594 100644
---- a/xbmc/threads/Thread.cpp
-+++ b/xbmc/threads/Thread.cpp
-@@ -20,41 +20,27 @@
-
- #include "threads/SystemClock.h"
- #include "Thread.h"
--#ifndef _LINUX
--#include
--#include "utils/win32exception.h"
--#ifndef _MT
--#pragma message( "Please compile using multithreaded run-time libraries" )
--#endif
--typedef unsigned (WINAPI *PBEGINTHREADEX_THREADFUNC)(LPVOID lpThreadParameter);
--#else
--#include "PlatformInclude.h"
--#include "XHandle.h"
--#include
--typedef int (*PBEGINTHREADEX_THREADFUNC)(LPVOID lpThreadParameter);
--#endif
--
--#if defined(__GNUC__) && !defined(__clang__)
--#include
--using namespace __cxxabiv1;
--#endif
--
- #include "utils/log.h"
- #include "utils/TimeUtils.h"
- #include "threads/ThreadLocal.h"
-
-+#define __STDC_FORMAT_MACROS
-+#include
-+
- static XbmcThreads::ThreadLocal currentThread;
-
-+#include "threads/platform/ThreadImpl.cpp"
-+
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
-
--CThread::CThread(const char* ThreadName) : m_StopEvent(true,true)
-+CThread::CThread(const char* ThreadName)
-+: m_StopEvent(true,true), m_TermEvent(true), m_StartEvent(true)
- {
- m_bStop = false;
-
- m_bAutoDelete = false;
-- m_ThreadHandle = NULL;
- m_ThreadId = 0;
- m_iLastTime = 0;
- m_iLastUsage = 0;
-@@ -66,12 +52,12 @@ CThread::CThread(const char* ThreadName) : m_StopEvent(true,true)
- m_ThreadName = ThreadName;
- }
-
--CThread::CThread(IRunnable* pRunnable, const char* ThreadName) : m_StopEvent(true,true)
-+CThread::CThread(IRunnable* pRunnable, const char* ThreadName)
-+: m_StopEvent(true,true), m_TermEvent(true), m_StartEvent(true)
- {
- m_bStop = false;
-
- m_bAutoDelete = false;
-- m_ThreadHandle = NULL;
- m_ThreadId = 0;
- m_iLastTime = 0;
- m_iLastUsage = 0;
-@@ -85,171 +71,62 @@ CThread::CThread(IRunnable* pRunnable, const char* ThreadName) : m_StopEvent(tru
-
- CThread::~CThread()
- {
-- if (m_ThreadHandle != NULL)
-- {
-- CloseHandle(m_ThreadHandle);
-- }
-- m_ThreadHandle = NULL;
--
-+ StopThread();
- }
-
--#ifndef _WIN32
--void CThread::term_handler (int signum)
-+bool CThread::IsRunning()
- {
-- CLog::Log(LOGERROR,"thread 0x%lx (%lu) got signal %d. calling OnException and terminating thread abnormally.", (long unsigned int)pthread_self(), (long unsigned int)pthread_self(), signum);
--
-- CThread* curThread = currentThread.get();
-- if (curThread)
-- {
-- curThread->m_bStop = TRUE;
-- curThread->m_StopEvent.Set();
--
-- curThread->OnException();
-- if( curThread->IsAutoDelete() )
-- delete curThread;
-- }
--
-- pthread_exit(NULL);
-+ return m_ThreadId ? true : false;
- }
-
--int CThread::staticThread(void* data)
--#else
--DWORD WINAPI CThread::staticThread(LPVOID* data)
--#endif
-+THREADFUNC CThread::staticThread(void* data)
- {
- CThread* pThread = (CThread*)(data);
-+ std::string name;
-+ ThreadIdentifier id;
-+ bool autodelete;
-+
- if (!pThread) {
- CLog::Log(LOGERROR,"%s, sanity failed. thread is NULL.",__FUNCTION__);
- return 1;
- }
-
-- if (pThread->m_ThreadName.empty())
-- pThread->m_ThreadName = pThread->GetTypeName();
-- pThread->SetDebugCallStackName(pThread->m_ThreadName.c_str());
-+ name = pThread->m_ThreadName;
-+ id = pThread->m_ThreadId;
-+ autodelete = pThread->m_bAutoDelete;
-
-- CLog::Log(LOGDEBUG,"Thread %s start, auto delete: %d", pThread->m_ThreadName.c_str(), pThread->IsAutoDelete());
-+ pThread->SetThreadInfo();
-+
-+ CLog::Log(LOGNOTICE,"Thread %s start, auto delete: %s", name.c_str(), (autodelete ? "true" : "false"));
-
- currentThread.set(pThread);
--#ifndef _LINUX
-- /* install win32 exception translator */
-- win32_exception::install_handler();
--#else
-- struct sigaction action;
-- action.sa_handler = term_handler;
-- sigemptyset (&action.sa_mask);
-- action.sa_flags = 0;
-- //sigaction (SIGABRT, &action, NULL);
-- //sigaction (SIGSEGV, &action, NULL);
--#endif
--
--
-- try
-- {
-- pThread->OnStartup();
-- }
--#ifndef _LINUX
-- catch (const win32_exception &e)
-- {
-- e.writelog(__FUNCTION__);
-- if( pThread->IsAutoDelete() )
-- {
-- delete pThread;
-- _endthreadex(123);
-- return 0;
-- }
-- }
--#endif
-- catch(...)
-- {
-- CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread startup, aborting. auto delete: %d", __FUNCTION__, pThread->m_ThreadName.c_str(), pThread->IsAutoDelete());
-- if( pThread->IsAutoDelete() )
-- {
-- delete pThread;
--#ifndef _LINUX
-- _endthreadex(123);
--#endif
-- return 0;
-- }
-- }
-+ pThread->m_StartEvent.Set();
-
-- try
-- {
-- pThread->Process();
-- }
--#ifndef _LINUX
-- catch (const access_violation &e)
-- {
-- e.writelog(__FUNCTION__);
-- }
-- catch (const win32_exception &e)
-- {
-- e.writelog(__FUNCTION__);
-- }
--#endif
-- catch(...)
-- {
-- CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread process, attemping cleanup in OnExit", __FUNCTION__, pThread->m_ThreadName.c_str());
-- }
-+ pThread->OnStartup();
-+ pThread->Process();
-+ pThread->OnExit();
-
-- try
-- {
-- pThread->OnExit();
-- }
--#ifndef _LINUX
-- catch (const access_violation &e)
-- {
-- e.writelog(__FUNCTION__);
-- }
-- catch (const win32_exception &e)
-- {
-- e.writelog(__FUNCTION__);
-- }
--#endif
-- catch(...)
-- {
-- CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread exit", __FUNCTION__, pThread->m_ThreadName.c_str());
-- }
-+ // lock during termination
-+ CSingleLock lock(pThread->m_CriticalSection);
-+
-+ pThread->m_ThreadId = 0;
-+ pThread->m_TermEvent.Set();
-+ pThread->TermHandler();
-
-- if ( pThread->IsAutoDelete() )
-+ lock.Leave();
-+
-+ if (autodelete)
- {
-- CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating (autodelete)", pThread->m_ThreadName.c_str(), (uint64_t)CThread::GetCurrentThreadId());
-+ CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating (autodelete)", name.c_str(), (uint64_t)id);
- delete pThread;
- pThread = NULL;
- }
- else
-- CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating", pThread->m_ThreadName.c_str(), (uint64_t)CThread::GetCurrentThreadId());
--
--// DXMERGE - this looks like it might have used to have been useful for something...
--// g_graphicsContext.DeleteThreadContext();
-+ CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating", name.c_str(), (uint64_t)id);
-
--#ifndef _LINUX
-- _endthreadex(123);
--#endif
- return 0;
- }
-
--void CThread::Create(bool bAutoDelete, unsigned stacksize)
--{
-- if (m_ThreadHandle != NULL)
-- {
-- throw 1; //ERROR should not b possible!!!
-- }
-- m_iLastTime = XbmcThreads::SystemClockMillis() * 10000;
-- m_iLastUsage = 0;
-- m_fLastUsage = 0.0f;
-- m_bAutoDelete = bAutoDelete;
-- m_bStop = false;
-- m_StopEvent.Reset();
--
-- m_ThreadHandle = (HANDLE)_beginthreadex(NULL, stacksize, (PBEGINTHREADEX_THREADFUNC)staticThread, (void*)this, 0, &m_ThreadId);
--
--#ifdef _LINUX
-- if (m_ThreadHandle && m_ThreadHandle->m_threadValid && m_bAutoDelete)
-- // FIXME: WinAPI can truncate 64bit pthread ids
-- pthread_detach(m_ThreadHandle->m_hThread);
--#endif
--}
--
- bool CThread::IsAutoDelete() const
- {
- return m_bAutoDelete;
-@@ -259,213 +136,15 @@ void CThread::StopThread(bool bWait /*= true*/)
- {
- m_bStop = true;
- m_StopEvent.Set();
-- if (m_ThreadHandle && bWait)
-+ if (m_ThreadId && bWait)
- {
-- WaitForThreadExit(INFINITE);
-- CloseHandle(m_ThreadHandle);
-- m_ThreadHandle = NULL;
-+ WaitForThreadExit(0xFFFFFFFF);
- }
- }
-
- ThreadIdentifier CThread::ThreadId() const
- {
--#ifdef _LINUX
-- if (m_ThreadHandle && m_ThreadHandle->m_threadValid)
-- return m_ThreadHandle->m_hThread;
-- else
-- return 0;
--#else
- return m_ThreadId;
--#endif
--}
--
--
--CThread::operator HANDLE()
--{
-- return m_ThreadHandle;
--}
--
--CThread::operator HANDLE() const
--{
-- return m_ThreadHandle;
--}
--
--bool CThread::SetPriority(const int iPriority)
--// Set thread priority
--// Return true for success
--{
-- bool rtn = false;
--
-- if (m_ThreadHandle)
-- {
-- rtn = SetThreadPriority( m_ThreadHandle, iPriority ) == TRUE;
-- }
--
-- return(rtn);
--}
--
--void CThread::SetPrioritySched_RR(void)
--{
--#ifdef __APPLE__
-- // Changing to SCHED_RR is safe under OSX, you don't need elevated privileges and the
-- // OSX scheduler will monitor SCHED_RR threads and drop to SCHED_OTHER if it detects
-- // the thread running away. OSX automatically does this with the CoreAudio audio
-- // device handler thread.
-- int32_t result;
-- thread_extended_policy_data_t theFixedPolicy;
--
-- // make thread fixed, set to 'true' for a non-fixed thread
-- theFixedPolicy.timeshare = false;
-- result = thread_policy_set(pthread_mach_thread_np(ThreadId()), THREAD_EXTENDED_POLICY,
-- (thread_policy_t)&theFixedPolicy, THREAD_EXTENDED_POLICY_COUNT);
--
-- int policy;
-- struct sched_param param;
-- result = pthread_getschedparam(ThreadId(), &policy, ¶m );
-- // change from default SCHED_OTHER to SCHED_RR
-- policy = SCHED_RR;
-- result = pthread_setschedparam(ThreadId(), policy, ¶m );
--#endif
--}
--
--int CThread::GetMinPriority(void)
--{
--#if 0
--//#if defined(__APPLE__)
-- struct sched_param sched;
-- int rtn, policy;
--
-- rtn = pthread_getschedparam(ThreadId(), &policy, &sched);
-- int min = sched_get_priority_min(policy);
--
-- return(min);
--#else
-- return(THREAD_PRIORITY_IDLE);
--#endif
--}
--
--int CThread::GetMaxPriority(void)
--{
--#if 0
--//#if defined(__APPLE__)
-- struct sched_param sched;
-- int rtn, policy;
--
-- rtn = pthread_getschedparam(ThreadId(), &policy, &sched);
-- int max = sched_get_priority_max(policy);
--
-- return(max);
--#else
-- return(THREAD_PRIORITY_HIGHEST);
--#endif
--}
--
--int CThread::GetNormalPriority(void)
--{
--#if 0
--//#if defined(__APPLE__)
-- struct sched_param sched;
-- int rtn, policy;
--
-- rtn = pthread_getschedparam(ThreadId(), &policy, &sched);
-- int min = sched_get_priority_min(policy);
-- int max = sched_get_priority_max(policy);
--
-- return( min + ((max-min) / 2) );
--#else
-- return(THREAD_PRIORITY_NORMAL);
--#endif
--}
--
--
--void CThread::SetDebugCallStackName( const char *name )
--{
--#ifdef _WIN32
-- const unsigned int MS_VC_EXCEPTION = 0x406d1388;
-- struct THREADNAME_INFO
-- {
-- DWORD dwType; // must be 0x1000
-- LPCSTR szName; // pointer to name (in same addr space)
-- DWORD dwThreadID; // thread ID (-1 caller thread)
-- DWORD dwFlags; // reserved for future use, most be zero
-- } info;
--
-- info.dwType = 0x1000;
-- info.szName = name;
-- info.dwThreadID = m_ThreadId;
-- info.dwFlags = 0;
--
-- try
-- {
-- RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info);
-- }
-- catch(...)
-- {
-- }
--#endif
--}
--
--// Get the thread name using the implementation dependant typeid() class
--// and attempt to clean it.
--std::string CThread::GetTypeName(void)
--{
-- std::string name = typeid(*this).name();
--
--#if defined(_MSC_VER)
-- // Visual Studio 2010 returns the name as "class CThread" etc
-- if (name.substr(0, 6) == "class ")
-- name = name.substr(6, name.length() - 6);
--#elif defined(__GNUC__) && !defined(__clang__)
-- // gcc provides __cxa_demangle to demangle the name
-- char* demangled = NULL;
-- int status;
--
-- demangled = __cxa_demangle(name.c_str(), NULL, 0, &status);
-- if (status == 0)
-- name = demangled;
-- else
-- CLog::Log(LOGDEBUG,"%s, __cxa_demangle(%s) failed with status %d", __FUNCTION__, name.c_str(), status);
--
-- if (demangled)
-- free(demangled);
--#endif
--
-- return name;
--}
--
--bool CThread::WaitForThreadExit(unsigned int milliseconds)
--// Waits for thread to exit, timeout in given number of msec.
--// Returns true when thread ended
--{
-- if (!m_ThreadHandle) return true;
--
--#ifndef _LINUX
-- // boost priority of thread we are waiting on to same as caller
-- int callee = GetThreadPriority(m_ThreadHandle);
-- int caller = GetThreadPriority(GetCurrentThread());
-- if(caller > callee)
-- SetThreadPriority(m_ThreadHandle, caller);
--
-- if (::WaitForSingleObject(m_ThreadHandle, milliseconds) != WAIT_TIMEOUT)
-- return true;
--
-- // restore thread priority if thread hasn't exited
-- if(caller > callee)
-- SetThreadPriority(m_ThreadHandle, callee);
--#else
-- if (!(m_ThreadHandle->m_threadValid) || pthread_join(m_ThreadHandle->m_hThread, NULL) == 0)
-- {
-- m_ThreadHandle->m_threadValid = false;
-- return true;
-- }
--#endif
--
-- return false;
--}
--
--HANDLE CThread::ThreadHandle()
--{
-- return m_ThreadHandle;
- }
-
- void CThread::Process()
-@@ -474,54 +153,14 @@ void CThread::Process()
- m_pRunnable->Run();
- }
-
--float CThread::GetRelativeUsage()
--{
-- unsigned __int64 iTime = XbmcThreads::SystemClockMillis();
-- iTime *= 10000; // convert into 100ns tics
--
-- // only update every 1 second
-- if( iTime < m_iLastTime + 1000*10000 ) return m_fLastUsage;
--
-- FILETIME CreationTime, ExitTime, UserTime, KernelTime;
-- if( GetThreadTimes( m_ThreadHandle, &CreationTime, &ExitTime, &KernelTime, &UserTime ) )
-- {
-- unsigned __int64 iUsage = 0;
-- iUsage += (((unsigned __int64)UserTime.dwHighDateTime) << 32) + ((unsigned __int64)UserTime.dwLowDateTime);
-- iUsage += (((unsigned __int64)KernelTime.dwHighDateTime) << 32) + ((unsigned __int64)KernelTime.dwLowDateTime);
--
-- if(m_iLastUsage > 0 && m_iLastTime > 0)
-- m_fLastUsage = (float)( iUsage - m_iLastUsage ) / (float)( iTime - m_iLastTime );
--
-- m_iLastUsage = iUsage;
-- m_iLastTime = iTime;
--
-- return m_fLastUsage;
-- }
-- return 0.0f;
--}
--
- bool CThread::IsCurrentThread() const
- {
- return IsCurrentThread(ThreadId());
- }
-
--
--ThreadIdentifier CThread::GetCurrentThreadId()
--{
--#ifdef _LINUX
-- return pthread_self();
--#else
-- return ::GetCurrentThreadId();
--#endif
--}
--
--bool CThread::IsCurrentThread(const ThreadIdentifier tid)
-+CThread* CThread::GetCurrentThread()
- {
--#ifdef _LINUX
-- return pthread_equal(pthread_self(), tid);
--#else
-- return (::GetCurrentThreadId() == tid);
--#endif
-+ return currentThread.get();
- }
-
- void CThread::Sleep(unsigned int milliseconds)
-@@ -529,7 +168,7 @@ void CThread::Sleep(unsigned int milliseconds)
- if(milliseconds > 10 && IsCurrentThread())
- m_StopEvent.WaitMSec(milliseconds);
- else
-- ::Sleep(milliseconds);
-+ XbmcThreads::ThreadSleep(milliseconds);
- }
-
-
-diff --git a/xbmc/threads/Thread.h b/xbmc/threads/Thread.h
-index 768d6f8..bebd9ee 100644
---- a/xbmc/threads/Thread.h
-+++ b/xbmc/threads/Thread.h
-@@ -23,19 +23,13 @@
- //
- //////////////////////////////////////////////////////////////////////
-
--#if !defined(AFX_THREAD_H__ACFB7357_B961_4AC1_9FB2_779526219817__INCLUDED_) && !defined(AFX_THREAD_H__67621B15_8724_4B5D_9343_7667075C89F2__INCLUDED_)
--#define AFX_THREAD_H__ACFB7357_B961_4AC1_9FB2_779526219817__INCLUDED_
--
--#if _MSC_VER > 1000
- #pragma once
--#endif // _MSC_VER > 1000
-
- #include
--#include "system.h" // for HANDLE
--#ifdef _LINUX
--#include "PlatformInclude.h"
--#endif
-+#include
- #include "Event.h"
-+#include "threads/ThreadImpl.h"
-+#include "threads/ThreadLocal.h"
-
- class IRunnable
- {
-@@ -44,37 +38,36 @@ public:
- virtual ~IRunnable() {}
- };
-
--#ifdef CTHREAD
--#undef CTHREAD
--#endif
--
- // minimum as mandated by XTL
- #define THREAD_MINSTACKSIZE 0x10000
-
- class CThread
- {
- public:
-- CThread(const char* ThreadName = NULL);
-- CThread(IRunnable* pRunnable, const char* ThreadName = NULL);
-+ CThread(const char* ThreadName);
-+ CThread(IRunnable* pRunnable, const char* ThreadName);
- virtual ~CThread();
- void Create(bool bAutoDelete = false, unsigned stacksize = 0);
- bool WaitForThreadExit(unsigned int milliseconds);
- void Sleep(unsigned int milliseconds);
- bool SetPriority(const int iPriority);
-- void SetPrioritySched_RR(void);
-+ int GetPriority(void);
- int GetMinPriority(void);
- int GetMaxPriority(void);
- int GetNormalPriority(void);
-- HANDLE ThreadHandle();
-- operator HANDLE();
-- operator HANDLE() const;
-+ int GetSchedRRPriority(void);
-+ bool SetPrioritySched_RR(int iPriority);
- bool IsAutoDelete() const;
- virtual void StopThread(bool bWait = true);
- float GetRelativeUsage(); // returns the relative cpu usage of this thread since last call
-+ int64_t GetAbsoluteUsage();
- bool IsCurrentThread() const;
-+ bool IsRunning();
-
- static bool IsCurrentThread(const ThreadIdentifier tid);
- static ThreadIdentifier GetCurrentThreadId();
-+ static CThread* GetCurrentThread();
-+ static int64_t GetCurrentThreadUsage();
- protected:
- virtual void OnStartup(){};
- virtual void OnExit(){};
-@@ -82,7 +75,6 @@ protected:
- virtual void Process();
-
- volatile bool m_bStop;
-- HANDLE m_ThreadHandle;
-
- enum WaitResponse { WAIT_INTERRUPTED = -1, WAIT_SIGNALED = 0, WAIT_TIMEDOUT = 1 };
-
-@@ -108,36 +100,22 @@ protected:
- }
-
- private:
-- /*! \brief set the threadname for the debugger/callstack, implementation dependent.
-- */
-- void SetDebugCallStackName( const char *threadName );
-- std::string GetTypeName(void);
--
--private:
-+ static THREADFUNC staticThread(void *data);
- ThreadIdentifier ThreadId() const;
-+ void SetThreadInfo();
-+ void TermHandler();
-+
-+ ThreadIdentifier m_ThreadId;
-+ ThreadOpaque m_ThreadOpaque;
- bool m_bAutoDelete;
- CEvent m_StopEvent;
-- unsigned m_ThreadId; // This value is unreliable on platforms using pthreads
-- // Use m_ThreadHandle->m_hThread instead
-+ CEvent m_TermEvent;
-+ CEvent m_StartEvent;
-+ CCriticalSection m_CriticalSection;
- IRunnable* m_pRunnable;
--
-- unsigned __int64 m_iLastUsage;
-- unsigned __int64 m_iLastTime;
-+ uint64_t m_iLastUsage;
-+ uint64_t m_iLastTime;
- float m_fLastUsage;
-
- std::string m_ThreadName;
--
--#ifdef _LINUX
-- static void term_handler (int signum);
--#endif
--
--#ifndef _WIN32
-- static int staticThread(void* data);
--#else
-- static DWORD WINAPI staticThread(LPVOID* data);
--#endif
--
--private:
- };
--
--#endif // !defined(AFX_THREAD_H__ACFB7357_B961_4AC1_9FB2_779526219817__INCLUDED_)
-diff --git a/xbmc/threads/ThreadImpl.h b/xbmc/threads/ThreadImpl.h
-new file mode 100644
-index 0000000..ad10e3b
---- /dev/null
-+++ b/xbmc/threads/ThreadImpl.h
-@@ -0,0 +1,25 @@
-+/*
-+ * Copyright (C) 2005-2011 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program is free software; you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License as published by
-+ * the Free Software Foundation; either version 2, or (at your option)
-+ * any later version.
-+ *
-+ * This Program is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+
-+#pragma once
-+
-+#include "threads/platform/ThreadImpl.h"
-+
-diff --git a/xbmc/threads/platform/ThreadImpl.cpp b/xbmc/threads/platform/ThreadImpl.cpp
-new file mode 100644
-index 0000000..7f0213b
---- /dev/null
-+++ b/xbmc/threads/platform/ThreadImpl.cpp
-@@ -0,0 +1,34 @@
-+/*
-+ * Copyright (C) 2005-2011 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program is free software; you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License as published by
-+ * the Free Software Foundation; either version 2, or (at your option)
-+ * any later version.
-+ *
-+ * This Program is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+
-+#pragma once
-+
-+#if (defined TARGET_POSIX)
-+#include "threads/platform/pthreads/ThreadImpl.cpp"
-+#if defined(TARGET_DARWIN_IOS)
-+#include "threads/platform/darwin/ThreadSchedImpl.cpp"
-+#else
-+#include "threads/platform/linux/ThreadSchedImpl.cpp"
-+#endif
-+#elif (defined TARGET_WINDOWS)
-+#include "threads/platform/win/ThreadImpl.cpp"
-+#endif
-+
-diff --git a/xbmc/threads/platform/ThreadImpl.h b/xbmc/threads/platform/ThreadImpl.h
-new file mode 100644
-index 0000000..f37709e
---- /dev/null
-+++ b/xbmc/threads/platform/ThreadImpl.h
-@@ -0,0 +1,28 @@
-+/*
-+ * Copyright (C) 2005-2011 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program is free software; you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License as published by
-+ * the Free Software Foundation; either version 2, or (at your option)
-+ * any later version.
-+ *
-+ * This Program is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+
-+#pragma once
-+
-+#if (defined TARGET_POSIX)
-+#include "threads/platform/pthreads/ThreadImpl.h"
-+#elif (defined TARGET_WINDOWS)
-+#include "threads/platform/win/ThreadImpl.h"
-+#endif
-diff --git a/xbmc/threads/platform/darwin/ThreadSchedImpl.cpp b/xbmc/threads/platform/darwin/ThreadSchedImpl.cpp
-new file mode 100644
-index 0000000..7612fe7
---- /dev/null
-+++ b/xbmc/threads/platform/darwin/ThreadSchedImpl.cpp
+diff -Naur xbmc-1fef727/xbmc/threads/platform/darwin/ThreadSchedImpl.cpp xbmc-1fef727.patch/xbmc/threads/platform/darwin/ThreadSchedImpl.cpp
+--- xbmc-1fef727/xbmc/threads/platform/darwin/ThreadSchedImpl.cpp 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/threads/platform/darwin/ThreadSchedImpl.cpp 2012-02-07 14:30:18.070099594 +0100
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2005-2011 Team XBMC
@@ -6270,11 +5277,9 @@ index 0000000..7612fe7
+ policy = SCHED_RR;
+ result = pthread_setschedparam(ThreadId(), policy, ¶m );
+}
-diff --git a/xbmc/threads/platform/linux/ThreadSchedImpl.cpp b/xbmc/threads/platform/linux/ThreadSchedImpl.cpp
-new file mode 100644
-index 0000000..034a100
---- /dev/null
-+++ b/xbmc/threads/platform/linux/ThreadSchedImpl.cpp
+diff -Naur xbmc-1fef727/xbmc/threads/platform/linux/ThreadSchedImpl.cpp xbmc-1fef727.patch/xbmc/threads/platform/linux/ThreadSchedImpl.cpp
+--- xbmc-1fef727/xbmc/threads/platform/linux/ThreadSchedImpl.cpp 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/threads/platform/linux/ThreadSchedImpl.cpp 2012-02-07 14:30:18.071099614 +0100
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2005-2011 Team XBMC
@@ -6306,11 +5311,9 @@ index 0000000..034a100
+{
+ return false;
+}
-diff --git a/xbmc/threads/platform/pthreads/ThreadImpl.cpp b/xbmc/threads/platform/pthreads/ThreadImpl.cpp
-new file mode 100644
-index 0000000..58b602c
---- /dev/null
-+++ b/xbmc/threads/platform/pthreads/ThreadImpl.cpp
+diff -Naur xbmc-1fef727/xbmc/threads/platform/pthreads/ThreadImpl.cpp xbmc-1fef727.patch/xbmc/threads/platform/pthreads/ThreadImpl.cpp
+--- xbmc-1fef727/xbmc/threads/platform/pthreads/ThreadImpl.cpp 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/threads/platform/pthreads/ThreadImpl.cpp 2012-02-07 14:30:18.072099634 +0100
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 2005-2011 Team XBMC
@@ -6532,11 +5535,9 @@ index 0000000..58b602c
+ return time;
+}
+
-diff --git a/xbmc/threads/platform/pthreads/ThreadImpl.h b/xbmc/threads/platform/pthreads/ThreadImpl.h
-new file mode 100644
-index 0000000..3f4dd39
---- /dev/null
-+++ b/xbmc/threads/platform/pthreads/ThreadImpl.h
+diff -Naur xbmc-1fef727/xbmc/threads/platform/pthreads/ThreadImpl.h xbmc-1fef727.patch/xbmc/threads/platform/pthreads/ThreadImpl.h
+--- xbmc-1fef727/xbmc/threads/platform/pthreads/ThreadImpl.h 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/threads/platform/pthreads/ThreadImpl.h 2012-02-07 14:30:18.072099634 +0100
@@ -0,0 +1,39 @@
+/*
+* Copyright (C) 2005-2011 Team XBMC
@@ -6577,11 +5578,79 @@ index 0000000..3f4dd39
+ inline static void ThreadSleep(unsigned int millis) { usleep(millis*1000); }
+}
+
-diff --git a/xbmc/threads/platform/win/ThreadImpl.cpp b/xbmc/threads/platform/win/ThreadImpl.cpp
-new file mode 100644
-index 0000000..6650ee6
---- /dev/null
-+++ b/xbmc/threads/platform/win/ThreadImpl.cpp
+diff -Naur xbmc-1fef727/xbmc/threads/platform/ThreadImpl.cpp xbmc-1fef727.patch/xbmc/threads/platform/ThreadImpl.cpp
+--- xbmc-1fef727/xbmc/threads/platform/ThreadImpl.cpp 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/threads/platform/ThreadImpl.cpp 2012-02-07 14:30:18.070099594 +0100
+@@ -0,0 +1,34 @@
++/*
++ * Copyright (C) 2005-2011 Team XBMC
++ * http://www.xbmc.org
++ *
++ * This Program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2, or (at your option)
++ * any later version.
++ *
++ * This Program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with XBMC; see the file COPYING. If not, write to
++ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
++ * http://www.gnu.org/copyleft/gpl.html
++ *
++ */
++
++#pragma once
++
++#if (defined TARGET_POSIX)
++#include "threads/platform/pthreads/ThreadImpl.cpp"
++#if defined(TARGET_DARWIN_IOS)
++#include "threads/platform/darwin/ThreadSchedImpl.cpp"
++#else
++#include "threads/platform/linux/ThreadSchedImpl.cpp"
++#endif
++#elif (defined TARGET_WINDOWS)
++#include "threads/platform/win/ThreadImpl.cpp"
++#endif
++
+diff -Naur xbmc-1fef727/xbmc/threads/platform/ThreadImpl.h xbmc-1fef727.patch/xbmc/threads/platform/ThreadImpl.h
+--- xbmc-1fef727/xbmc/threads/platform/ThreadImpl.h 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/threads/platform/ThreadImpl.h 2012-02-07 14:30:18.070099594 +0100
+@@ -0,0 +1,28 @@
++/*
++ * Copyright (C) 2005-2011 Team XBMC
++ * http://www.xbmc.org
++ *
++ * This Program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2, or (at your option)
++ * any later version.
++ *
++ * This Program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with XBMC; see the file COPYING. If not, write to
++ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
++ * http://www.gnu.org/copyleft/gpl.html
++ *
++ */
++
++#pragma once
++
++#if (defined TARGET_POSIX)
++#include "threads/platform/pthreads/ThreadImpl.h"
++#elif (defined TARGET_WINDOWS)
++#include "threads/platform/win/ThreadImpl.h"
++#endif
+diff -Naur xbmc-1fef727/xbmc/threads/platform/win/ThreadImpl.cpp xbmc-1fef727.patch/xbmc/threads/platform/win/ThreadImpl.cpp
+--- xbmc-1fef727/xbmc/threads/platform/win/ThreadImpl.cpp 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/threads/platform/win/ThreadImpl.cpp 2012-02-07 14:30:18.072099634 +0100
@@ -0,0 +1,207 @@
+/*
+ * Copyright (C) 2005-2011 Team XBMC
@@ -6790,11 +5859,9 @@ index 0000000..6650ee6
+ return time;
+}
+
-diff --git a/xbmc/threads/platform/win/ThreadImpl.h b/xbmc/threads/platform/win/ThreadImpl.h
-new file mode 100644
-index 0000000..ea9a0db
---- /dev/null
-+++ b/xbmc/threads/platform/win/ThreadImpl.h
+diff -Naur xbmc-1fef727/xbmc/threads/platform/win/ThreadImpl.h xbmc-1fef727.patch/xbmc/threads/platform/win/ThreadImpl.h
+--- xbmc-1fef727/xbmc/threads/platform/win/ThreadImpl.h 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/threads/platform/win/ThreadImpl.h 2012-02-07 14:30:18.073099654 +0100
@@ -0,0 +1,40 @@
+/*
+* Copyright (C) 2005-2011 Team XBMC
@@ -6836,10 +5903,717 @@ index 0000000..ea9a0db
+ inline static void ThreadSleep(unsigned int millis) { Sleep(millis); }
+}
+
-diff --git a/xbmc/utils/AlarmClock.cpp b/xbmc/utils/AlarmClock.cpp
-index 0f61171..75af866 100644
---- a/xbmc/utils/AlarmClock.cpp
-+++ b/xbmc/utils/AlarmClock.cpp
+diff -Naur xbmc-1fef727/xbmc/threads/Thread.cpp xbmc-1fef727.patch/xbmc/threads/Thread.cpp
+--- xbmc-1fef727/xbmc/threads/Thread.cpp 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/threads/Thread.cpp 2012-02-07 14:30:18.068099554 +0100
+@@ -20,41 +20,27 @@
+
+ #include "threads/SystemClock.h"
+ #include "Thread.h"
+-#ifndef _LINUX
+-#include
+-#include "utils/win32exception.h"
+-#ifndef _MT
+-#pragma message( "Please compile using multithreaded run-time libraries" )
+-#endif
+-typedef unsigned (WINAPI *PBEGINTHREADEX_THREADFUNC)(LPVOID lpThreadParameter);
+-#else
+-#include "PlatformInclude.h"
+-#include "XHandle.h"
+-#include
+-typedef int (*PBEGINTHREADEX_THREADFUNC)(LPVOID lpThreadParameter);
+-#endif
+-
+-#if defined(__GNUC__) && !defined(__clang__)
+-#include
+-using namespace __cxxabiv1;
+-#endif
+-
+ #include "utils/log.h"
+ #include "utils/TimeUtils.h"
+ #include "threads/ThreadLocal.h"
+
++#define __STDC_FORMAT_MACROS
++#include
++
+ static XbmcThreads::ThreadLocal currentThread;
+
++#include "threads/platform/ThreadImpl.cpp"
++
+ //////////////////////////////////////////////////////////////////////
+ // Construction/Destruction
+ //////////////////////////////////////////////////////////////////////
+
+-CThread::CThread(const char* ThreadName) : m_StopEvent(true,true)
++CThread::CThread(const char* ThreadName)
++: m_StopEvent(true,true), m_TermEvent(true), m_StartEvent(true)
+ {
+ m_bStop = false;
+
+ m_bAutoDelete = false;
+- m_ThreadHandle = NULL;
+ m_ThreadId = 0;
+ m_iLastTime = 0;
+ m_iLastUsage = 0;
+@@ -66,12 +52,12 @@
+ m_ThreadName = ThreadName;
+ }
+
+-CThread::CThread(IRunnable* pRunnable, const char* ThreadName) : m_StopEvent(true,true)
++CThread::CThread(IRunnable* pRunnable, const char* ThreadName)
++: m_StopEvent(true,true), m_TermEvent(true), m_StartEvent(true)
+ {
+ m_bStop = false;
+
+ m_bAutoDelete = false;
+- m_ThreadHandle = NULL;
+ m_ThreadId = 0;
+ m_iLastTime = 0;
+ m_iLastUsage = 0;
+@@ -85,171 +71,62 @@
+
+ CThread::~CThread()
+ {
+- if (m_ThreadHandle != NULL)
+- {
+- CloseHandle(m_ThreadHandle);
+- }
+- m_ThreadHandle = NULL;
+-
++ StopThread();
+ }
+
+-#ifndef _WIN32
+-void CThread::term_handler (int signum)
++bool CThread::IsRunning()
+ {
+- CLog::Log(LOGERROR,"thread 0x%lx (%lu) got signal %d. calling OnException and terminating thread abnormally.", (long unsigned int)pthread_self(), (long unsigned int)pthread_self(), signum);
+-
+- CThread* curThread = currentThread.get();
+- if (curThread)
+- {
+- curThread->m_bStop = TRUE;
+- curThread->m_StopEvent.Set();
+-
+- curThread->OnException();
+- if( curThread->IsAutoDelete() )
+- delete curThread;
+- }
+-
+- pthread_exit(NULL);
++ return m_ThreadId ? true : false;
+ }
+
+-int CThread::staticThread(void* data)
+-#else
+-DWORD WINAPI CThread::staticThread(LPVOID* data)
+-#endif
++THREADFUNC CThread::staticThread(void* data)
+ {
+ CThread* pThread = (CThread*)(data);
++ std::string name;
++ ThreadIdentifier id;
++ bool autodelete;
++
+ if (!pThread) {
+ CLog::Log(LOGERROR,"%s, sanity failed. thread is NULL.",__FUNCTION__);
+ return 1;
+ }
+
+- if (pThread->m_ThreadName.empty())
+- pThread->m_ThreadName = pThread->GetTypeName();
+- pThread->SetDebugCallStackName(pThread->m_ThreadName.c_str());
++ name = pThread->m_ThreadName;
++ id = pThread->m_ThreadId;
++ autodelete = pThread->m_bAutoDelete;
+
+- CLog::Log(LOGDEBUG,"Thread %s start, auto delete: %d", pThread->m_ThreadName.c_str(), pThread->IsAutoDelete());
++ pThread->SetThreadInfo();
++
++ CLog::Log(LOGNOTICE,"Thread %s start, auto delete: %s", name.c_str(), (autodelete ? "true" : "false"));
+
+ currentThread.set(pThread);
+-#ifndef _LINUX
+- /* install win32 exception translator */
+- win32_exception::install_handler();
+-#else
+- struct sigaction action;
+- action.sa_handler = term_handler;
+- sigemptyset (&action.sa_mask);
+- action.sa_flags = 0;
+- //sigaction (SIGABRT, &action, NULL);
+- //sigaction (SIGSEGV, &action, NULL);
+-#endif
++ pThread->m_StartEvent.Set();
+
++ pThread->OnStartup();
++ pThread->Process();
++ pThread->OnExit();
+
+- try
+- {
+- pThread->OnStartup();
+- }
+-#ifndef _LINUX
+- catch (const win32_exception &e)
+- {
+- e.writelog(__FUNCTION__);
+- if( pThread->IsAutoDelete() )
+- {
+- delete pThread;
+- _endthreadex(123);
+- return 0;
+- }
+- }
+-#endif
+- catch(...)
+- {
+- CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread startup, aborting. auto delete: %d", __FUNCTION__, pThread->m_ThreadName.c_str(), pThread->IsAutoDelete());
+- if( pThread->IsAutoDelete() )
+- {
+- delete pThread;
+-#ifndef _LINUX
+- _endthreadex(123);
+-#endif
+- return 0;
+- }
+- }
++ // lock during termination
++ CSingleLock lock(pThread->m_CriticalSection);
+
+- try
+- {
+- pThread->Process();
+- }
+-#ifndef _LINUX
+- catch (const access_violation &e)
+- {
+- e.writelog(__FUNCTION__);
+- }
+- catch (const win32_exception &e)
+- {
+- e.writelog(__FUNCTION__);
+- }
+-#endif
+- catch(...)
+- {
+- CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread process, attemping cleanup in OnExit", __FUNCTION__, pThread->m_ThreadName.c_str());
+- }
++ pThread->m_ThreadId = 0;
++ pThread->m_TermEvent.Set();
++ pThread->TermHandler();
+
+- try
+- {
+- pThread->OnExit();
+- }
+-#ifndef _LINUX
+- catch (const access_violation &e)
+- {
+- e.writelog(__FUNCTION__);
+- }
+- catch (const win32_exception &e)
+- {
+- e.writelog(__FUNCTION__);
+- }
+-#endif
+- catch(...)
+- {
+- CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread exit", __FUNCTION__, pThread->m_ThreadName.c_str());
+- }
++ lock.Leave();
+
+- if ( pThread->IsAutoDelete() )
++ if (autodelete)
+ {
+- CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating (autodelete)", pThread->m_ThreadName.c_str(), (uint64_t)CThread::GetCurrentThreadId());
++ CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating (autodelete)", name.c_str(), (uint64_t)id);
+ delete pThread;
+ pThread = NULL;
+ }
+ else
+- CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating", pThread->m_ThreadName.c_str(), (uint64_t)CThread::GetCurrentThreadId());
+-
+-// DXMERGE - this looks like it might have used to have been useful for something...
+-// g_graphicsContext.DeleteThreadContext();
++ CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating", name.c_str(), (uint64_t)id);
+
+-#ifndef _LINUX
+- _endthreadex(123);
+-#endif
+ return 0;
+ }
+
+-void CThread::Create(bool bAutoDelete, unsigned stacksize)
+-{
+- if (m_ThreadHandle != NULL)
+- {
+- throw 1; //ERROR should not b possible!!!
+- }
+- m_iLastTime = XbmcThreads::SystemClockMillis() * 10000;
+- m_iLastUsage = 0;
+- m_fLastUsage = 0.0f;
+- m_bAutoDelete = bAutoDelete;
+- m_bStop = false;
+- m_StopEvent.Reset();
+-
+- m_ThreadHandle = (HANDLE)_beginthreadex(NULL, stacksize, (PBEGINTHREADEX_THREADFUNC)staticThread, (void*)this, 0, &m_ThreadId);
+-
+-#ifdef _LINUX
+- if (m_ThreadHandle && m_ThreadHandle->m_threadValid && m_bAutoDelete)
+- // FIXME: WinAPI can truncate 64bit pthread ids
+- pthread_detach(m_ThreadHandle->m_hThread);
+-#endif
+-}
+-
+ bool CThread::IsAutoDelete() const
+ {
+ return m_bAutoDelete;
+@@ -259,213 +136,17 @@
+ {
+ m_bStop = true;
+ m_StopEvent.Set();
+- if (m_ThreadHandle && bWait)
++ CSingleLock lock(m_CriticalSection);
++ if (m_ThreadId && bWait)
+ {
+- WaitForThreadExit(INFINITE);
+- CloseHandle(m_ThreadHandle);
+- m_ThreadHandle = NULL;
++ lock.Leave();
++ WaitForThreadExit(0xFFFFFFFF);
+ }
+ }
+
+ ThreadIdentifier CThread::ThreadId() const
+ {
+-#ifdef _LINUX
+- if (m_ThreadHandle && m_ThreadHandle->m_threadValid)
+- return m_ThreadHandle->m_hThread;
+- else
+- return 0;
+-#else
+ return m_ThreadId;
+-#endif
+-}
+-
+-
+-CThread::operator HANDLE()
+-{
+- return m_ThreadHandle;
+-}
+-
+-CThread::operator HANDLE() const
+-{
+- return m_ThreadHandle;
+-}
+-
+-bool CThread::SetPriority(const int iPriority)
+-// Set thread priority
+-// Return true for success
+-{
+- bool rtn = false;
+-
+- if (m_ThreadHandle)
+- {
+- rtn = SetThreadPriority( m_ThreadHandle, iPriority ) == TRUE;
+- }
+-
+- return(rtn);
+-}
+-
+-void CThread::SetPrioritySched_RR(void)
+-{
+-#ifdef __APPLE__
+- // Changing to SCHED_RR is safe under OSX, you don't need elevated privileges and the
+- // OSX scheduler will monitor SCHED_RR threads and drop to SCHED_OTHER if it detects
+- // the thread running away. OSX automatically does this with the CoreAudio audio
+- // device handler thread.
+- int32_t result;
+- thread_extended_policy_data_t theFixedPolicy;
+-
+- // make thread fixed, set to 'true' for a non-fixed thread
+- theFixedPolicy.timeshare = false;
+- result = thread_policy_set(pthread_mach_thread_np(ThreadId()), THREAD_EXTENDED_POLICY,
+- (thread_policy_t)&theFixedPolicy, THREAD_EXTENDED_POLICY_COUNT);
+-
+- int policy;
+- struct sched_param param;
+- result = pthread_getschedparam(ThreadId(), &policy, ¶m );
+- // change from default SCHED_OTHER to SCHED_RR
+- policy = SCHED_RR;
+- result = pthread_setschedparam(ThreadId(), policy, ¶m );
+-#endif
+-}
+-
+-int CThread::GetMinPriority(void)
+-{
+-#if 0
+-//#if defined(__APPLE__)
+- struct sched_param sched;
+- int rtn, policy;
+-
+- rtn = pthread_getschedparam(ThreadId(), &policy, &sched);
+- int min = sched_get_priority_min(policy);
+-
+- return(min);
+-#else
+- return(THREAD_PRIORITY_IDLE);
+-#endif
+-}
+-
+-int CThread::GetMaxPriority(void)
+-{
+-#if 0
+-//#if defined(__APPLE__)
+- struct sched_param sched;
+- int rtn, policy;
+-
+- rtn = pthread_getschedparam(ThreadId(), &policy, &sched);
+- int max = sched_get_priority_max(policy);
+-
+- return(max);
+-#else
+- return(THREAD_PRIORITY_HIGHEST);
+-#endif
+-}
+-
+-int CThread::GetNormalPriority(void)
+-{
+-#if 0
+-//#if defined(__APPLE__)
+- struct sched_param sched;
+- int rtn, policy;
+-
+- rtn = pthread_getschedparam(ThreadId(), &policy, &sched);
+- int min = sched_get_priority_min(policy);
+- int max = sched_get_priority_max(policy);
+-
+- return( min + ((max-min) / 2) );
+-#else
+- return(THREAD_PRIORITY_NORMAL);
+-#endif
+-}
+-
+-
+-void CThread::SetDebugCallStackName( const char *name )
+-{
+-#ifdef _WIN32
+- const unsigned int MS_VC_EXCEPTION = 0x406d1388;
+- struct THREADNAME_INFO
+- {
+- DWORD dwType; // must be 0x1000
+- LPCSTR szName; // pointer to name (in same addr space)
+- DWORD dwThreadID; // thread ID (-1 caller thread)
+- DWORD dwFlags; // reserved for future use, most be zero
+- } info;
+-
+- info.dwType = 0x1000;
+- info.szName = name;
+- info.dwThreadID = m_ThreadId;
+- info.dwFlags = 0;
+-
+- try
+- {
+- RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info);
+- }
+- catch(...)
+- {
+- }
+-#endif
+-}
+-
+-// Get the thread name using the implementation dependant typeid() class
+-// and attempt to clean it.
+-std::string CThread::GetTypeName(void)
+-{
+- std::string name = typeid(*this).name();
+-
+-#if defined(_MSC_VER)
+- // Visual Studio 2010 returns the name as "class CThread" etc
+- if (name.substr(0, 6) == "class ")
+- name = name.substr(6, name.length() - 6);
+-#elif defined(__GNUC__) && !defined(__clang__)
+- // gcc provides __cxa_demangle to demangle the name
+- char* demangled = NULL;
+- int status;
+-
+- demangled = __cxa_demangle(name.c_str(), NULL, 0, &status);
+- if (status == 0)
+- name = demangled;
+- else
+- CLog::Log(LOGDEBUG,"%s, __cxa_demangle(%s) failed with status %d", __FUNCTION__, name.c_str(), status);
+-
+- if (demangled)
+- free(demangled);
+-#endif
+-
+- return name;
+-}
+-
+-bool CThread::WaitForThreadExit(unsigned int milliseconds)
+-// Waits for thread to exit, timeout in given number of msec.
+-// Returns true when thread ended
+-{
+- if (!m_ThreadHandle) return true;
+-
+-#ifndef _LINUX
+- // boost priority of thread we are waiting on to same as caller
+- int callee = GetThreadPriority(m_ThreadHandle);
+- int caller = GetThreadPriority(GetCurrentThread());
+- if(caller > callee)
+- SetThreadPriority(m_ThreadHandle, caller);
+-
+- if (::WaitForSingleObject(m_ThreadHandle, milliseconds) != WAIT_TIMEOUT)
+- return true;
+-
+- // restore thread priority if thread hasn't exited
+- if(caller > callee)
+- SetThreadPriority(m_ThreadHandle, callee);
+-#else
+- if (!(m_ThreadHandle->m_threadValid) || pthread_join(m_ThreadHandle->m_hThread, NULL) == 0)
+- {
+- m_ThreadHandle->m_threadValid = false;
+- return true;
+- }
+-#endif
+-
+- return false;
+-}
+-
+-HANDLE CThread::ThreadHandle()
+-{
+- return m_ThreadHandle;
+ }
+
+ void CThread::Process()
+@@ -474,54 +155,14 @@
+ m_pRunnable->Run();
+ }
+
+-float CThread::GetRelativeUsage()
+-{
+- unsigned __int64 iTime = XbmcThreads::SystemClockMillis();
+- iTime *= 10000; // convert into 100ns tics
+-
+- // only update every 1 second
+- if( iTime < m_iLastTime + 1000*10000 ) return m_fLastUsage;
+-
+- FILETIME CreationTime, ExitTime, UserTime, KernelTime;
+- if( GetThreadTimes( m_ThreadHandle, &CreationTime, &ExitTime, &KernelTime, &UserTime ) )
+- {
+- unsigned __int64 iUsage = 0;
+- iUsage += (((unsigned __int64)UserTime.dwHighDateTime) << 32) + ((unsigned __int64)UserTime.dwLowDateTime);
+- iUsage += (((unsigned __int64)KernelTime.dwHighDateTime) << 32) + ((unsigned __int64)KernelTime.dwLowDateTime);
+-
+- if(m_iLastUsage > 0 && m_iLastTime > 0)
+- m_fLastUsage = (float)( iUsage - m_iLastUsage ) / (float)( iTime - m_iLastTime );
+-
+- m_iLastUsage = iUsage;
+- m_iLastTime = iTime;
+-
+- return m_fLastUsage;
+- }
+- return 0.0f;
+-}
+-
+ bool CThread::IsCurrentThread() const
+ {
+ return IsCurrentThread(ThreadId());
+ }
+
+-
+-ThreadIdentifier CThread::GetCurrentThreadId()
++CThread* CThread::GetCurrentThread()
+ {
+-#ifdef _LINUX
+- return pthread_self();
+-#else
+- return ::GetCurrentThreadId();
+-#endif
+-}
+-
+-bool CThread::IsCurrentThread(const ThreadIdentifier tid)
+-{
+-#ifdef _LINUX
+- return pthread_equal(pthread_self(), tid);
+-#else
+- return (::GetCurrentThreadId() == tid);
+-#endif
++ return currentThread.get();
+ }
+
+ void CThread::Sleep(unsigned int milliseconds)
+@@ -529,7 +170,7 @@
+ if(milliseconds > 10 && IsCurrentThread())
+ m_StopEvent.WaitMSec(milliseconds);
+ else
+- ::Sleep(milliseconds);
++ XbmcThreads::ThreadSleep(milliseconds);
+ }
+
+
+diff -Naur xbmc-1fef727/xbmc/threads/Thread.h xbmc-1fef727.patch/xbmc/threads/Thread.h
+--- xbmc-1fef727/xbmc/threads/Thread.h 2012-02-07 12:46:50.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/threads/Thread.h 2012-02-07 14:30:18.069099574 +0100
+@@ -23,19 +23,13 @@
+ //
+ //////////////////////////////////////////////////////////////////////
+
+-#if !defined(AFX_THREAD_H__ACFB7357_B961_4AC1_9FB2_779526219817__INCLUDED_) && !defined(AFX_THREAD_H__67621B15_8724_4B5D_9343_7667075C89F2__INCLUDED_)
+-#define AFX_THREAD_H__ACFB7357_B961_4AC1_9FB2_779526219817__INCLUDED_
+-
+-#if _MSC_VER > 1000
+ #pragma once
+-#endif // _MSC_VER > 1000
+
+ #include
+-#include "system.h" // for HANDLE
+-#ifdef _LINUX
+-#include "PlatformInclude.h"
+-#endif
++#include
+ #include "Event.h"
++#include "threads/ThreadImpl.h"
++#include "threads/ThreadLocal.h"
+
+ class IRunnable
+ {
+@@ -44,37 +38,36 @@
+ virtual ~IRunnable() {}
+ };
+
+-#ifdef CTHREAD
+-#undef CTHREAD
+-#endif
+-
+ // minimum as mandated by XTL
+ #define THREAD_MINSTACKSIZE 0x10000
+
+ class CThread
+ {
+ public:
+- CThread(const char* ThreadName = NULL);
+- CThread(IRunnable* pRunnable, const char* ThreadName = NULL);
++ CThread(const char* ThreadName);
++ CThread(IRunnable* pRunnable, const char* ThreadName);
+ virtual ~CThread();
+ void Create(bool bAutoDelete = false, unsigned stacksize = 0);
+ bool WaitForThreadExit(unsigned int milliseconds);
+ void Sleep(unsigned int milliseconds);
+ bool SetPriority(const int iPriority);
+- void SetPrioritySched_RR(void);
++ int GetPriority(void);
+ int GetMinPriority(void);
+ int GetMaxPriority(void);
+ int GetNormalPriority(void);
+- HANDLE ThreadHandle();
+- operator HANDLE();
+- operator HANDLE() const;
++ int GetSchedRRPriority(void);
++ bool SetPrioritySched_RR(int iPriority);
+ bool IsAutoDelete() const;
+ virtual void StopThread(bool bWait = true);
+ float GetRelativeUsage(); // returns the relative cpu usage of this thread since last call
++ int64_t GetAbsoluteUsage();
+ bool IsCurrentThread() const;
++ bool IsRunning();
+
+ static bool IsCurrentThread(const ThreadIdentifier tid);
+ static ThreadIdentifier GetCurrentThreadId();
++ static CThread* GetCurrentThread();
++ static int64_t GetCurrentThreadUsage();
+ protected:
+ virtual void OnStartup(){};
+ virtual void OnExit(){};
+@@ -82,7 +75,6 @@
+ virtual void Process();
+
+ volatile bool m_bStop;
+- HANDLE m_ThreadHandle;
+
+ enum WaitResponse { WAIT_INTERRUPTED = -1, WAIT_SIGNALED = 0, WAIT_TIMEDOUT = 1 };
+
+@@ -108,36 +100,22 @@
+ }
+
+ private:
+- /*! \brief set the threadname for the debugger/callstack, implementation dependent.
+- */
+- void SetDebugCallStackName( const char *threadName );
+- std::string GetTypeName(void);
+-
+-private:
++ static THREADFUNC staticThread(void *data);
+ ThreadIdentifier ThreadId() const;
++ void SetThreadInfo();
++ void TermHandler();
++
++ ThreadIdentifier m_ThreadId;
++ ThreadOpaque m_ThreadOpaque;
+ bool m_bAutoDelete;
+ CEvent m_StopEvent;
+- unsigned m_ThreadId; // This value is unreliable on platforms using pthreads
+- // Use m_ThreadHandle->m_hThread instead
++ CEvent m_TermEvent;
++ CEvent m_StartEvent;
++ CCriticalSection m_CriticalSection;
+ IRunnable* m_pRunnable;
+-
+- unsigned __int64 m_iLastUsage;
+- unsigned __int64 m_iLastTime;
++ uint64_t m_iLastUsage;
++ uint64_t m_iLastTime;
+ float m_fLastUsage;
+
+ std::string m_ThreadName;
+-
+-#ifdef _LINUX
+- static void term_handler (int signum);
+-#endif
+-
+-#ifndef _WIN32
+- static int staticThread(void* data);
+-#else
+- static DWORD WINAPI staticThread(LPVOID* data);
+-#endif
+-
+-private:
+ };
+-
+-#endif // !defined(AFX_THREAD_H__ACFB7357_B961_4AC1_9FB2_779526219817__INCLUDED_)
+diff -Naur xbmc-1fef727/xbmc/threads/ThreadImpl.h xbmc-1fef727.patch/xbmc/threads/ThreadImpl.h
+--- xbmc-1fef727/xbmc/threads/ThreadImpl.h 1970-01-01 01:00:00.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/threads/ThreadImpl.h 2012-02-07 14:30:18.069099574 +0100
+@@ -0,0 +1,25 @@
++/*
++ * Copyright (C) 2005-2011 Team XBMC
++ * http://www.xbmc.org
++ *
++ * This Program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2, or (at your option)
++ * any later version.
++ *
++ * This Program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with XBMC; see the file COPYING. If not, write to
++ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
++ * http://www.gnu.org/copyleft/gpl.html
++ *
++ */
++
++#pragma once
++
++#include "threads/platform/ThreadImpl.h"
++
+diff -Naur xbmc-1fef727/xbmc/utils/AlarmClock.cpp xbmc-1fef727.patch/xbmc/utils/AlarmClock.cpp
+--- xbmc-1fef727/xbmc/utils/AlarmClock.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/utils/AlarmClock.cpp 2012-02-07 14:30:18.073099654 +0100
@@ -28,7 +28,7 @@
using namespace std;
@@ -6849,10 +6623,9 @@ index 0f61171..75af866 100644
{
}
-diff --git a/xbmc/utils/AsyncFileCopy.cpp b/xbmc/utils/AsyncFileCopy.cpp
-index e9b7bc0..44e7043 100644
---- a/xbmc/utils/AsyncFileCopy.cpp
-+++ b/xbmc/utils/AsyncFileCopy.cpp
+diff -Naur xbmc-1fef727/xbmc/utils/AsyncFileCopy.cpp xbmc-1fef727.patch/xbmc/utils/AsyncFileCopy.cpp
+--- xbmc-1fef727/xbmc/utils/AsyncFileCopy.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/utils/AsyncFileCopy.cpp 2012-02-07 14:30:18.074099674 +0100
@@ -26,7 +26,7 @@
#include "log.h"
#include "utils/TimeUtils.h"
@@ -6862,11 +6635,10 @@ index e9b7bc0..44e7043 100644
{
m_cancelled = false;
m_succeeded = false;
-diff --git a/xbmc/utils/DownloadQueue.cpp b/xbmc/utils/DownloadQueue.cpp
-index 4101090..0210241 100644
---- a/xbmc/utils/DownloadQueue.cpp
-+++ b/xbmc/utils/DownloadQueue.cpp
-@@ -32,7 +32,7 @@ using namespace XFILE;
+diff -Naur xbmc-1fef727/xbmc/utils/DownloadQueue.cpp xbmc-1fef727.patch/xbmc/utils/DownloadQueue.cpp
+--- xbmc-1fef727/xbmc/utils/DownloadQueue.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/utils/DownloadQueue.cpp 2012-02-07 14:30:18.074099674 +0100
+@@ -32,7 +32,7 @@
WORD CDownloadQueue::m_wNextQueueId = 0;
@@ -6875,10 +6647,9 @@ index 4101090..0210241 100644
{
m_bStop = false;
m_wQueueId = m_wNextQueueId++;
-diff --git a/xbmc/utils/DownloadQueue.h b/xbmc/utils/DownloadQueue.h
-index c314792..543a825 100644
---- a/xbmc/utils/DownloadQueue.h
-+++ b/xbmc/utils/DownloadQueue.h
+diff -Naur xbmc-1fef727/xbmc/utils/DownloadQueue.h xbmc-1fef727.patch/xbmc/utils/DownloadQueue.h
+--- xbmc-1fef727/xbmc/utils/DownloadQueue.h 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/utils/DownloadQueue.h 2012-02-07 14:30:18.075099693 +0100
@@ -26,6 +26,8 @@
#include "threads/CriticalSection.h"
#include "StdString.h"
@@ -6888,10 +6659,9 @@ index c314792..543a825 100644
struct TICKET
{
TICKET(WORD aQueueId, DWORD aItemId)
-diff --git a/xbmc/utils/DownloadQueueManager.h b/xbmc/utils/DownloadQueueManager.h
-index 3fb0d9f..9bda3ea 100644
---- a/xbmc/utils/DownloadQueueManager.h
-+++ b/xbmc/utils/DownloadQueueManager.h
+diff -Naur xbmc-1fef727/xbmc/utils/DownloadQueueManager.h xbmc-1fef727.patch/xbmc/utils/DownloadQueueManager.h
+--- xbmc-1fef727/xbmc/utils/DownloadQueueManager.h 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/utils/DownloadQueueManager.h 2012-02-07 14:30:18.075099693 +0100
@@ -22,6 +22,7 @@
*/
@@ -6900,10 +6670,9 @@ index 3fb0d9f..9bda3ea 100644
#define MAX_DOWNLOAD_QUEUES 3
-diff --git a/xbmc/utils/JobManager.cpp b/xbmc/utils/JobManager.cpp
-index dd7b28d..07c9502 100644
---- a/xbmc/utils/JobManager.cpp
-+++ b/xbmc/utils/JobManager.cpp
+diff -Naur xbmc-1fef727/xbmc/utils/JobManager.cpp xbmc-1fef727.patch/xbmc/utils/JobManager.cpp
+--- xbmc-1fef727/xbmc/utils/JobManager.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/utils/JobManager.cpp 2012-02-07 14:30:18.076099712 +0100
@@ -23,6 +23,9 @@
#include
#include "threads/SingleLock.h"
@@ -6914,11 +6683,10 @@ index dd7b28d..07c9502 100644
using namespace std;
bool CJob::ShouldCancel(unsigned int progress, unsigned int total) const
-diff --git a/xbmc/utils/LCD.h b/xbmc/utils/LCD.h
-index 7892d64..6b45008 100644
---- a/xbmc/utils/LCD.h
-+++ b/xbmc/utils/LCD.h
-@@ -66,8 +66,9 @@ public:
+diff -Naur xbmc-1fef727/xbmc/utils/LCD.h xbmc-1fef727.patch/xbmc/utils/LCD.h
+--- xbmc-1fef727/xbmc/utils/LCD.h 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/utils/LCD.h 2012-02-07 14:30:18.076099712 +0100
+@@ -68,8 +68,9 @@
void LoadSkin(const CStdString &xmlFile);
void Reset();
void Render(LCD_MODE mode);
@@ -6930,11 +6698,10 @@ index 7892d64..6b45008 100644
protected:
virtual void Process() = 0;
void StringToLCDCharSet(CStdString& strText);
-diff --git a/xbmc/utils/RssReader.cpp b/xbmc/utils/RssReader.cpp
-index 18fcdb4..fff6f5e 100644
---- a/xbmc/utils/RssReader.cpp
-+++ b/xbmc/utils/RssReader.cpp
-@@ -44,7 +44,7 @@ using namespace XFILE;
+diff -Naur xbmc-1fef727/xbmc/utils/RssReader.cpp xbmc-1fef727.patch/xbmc/utils/RssReader.cpp
+--- xbmc-1fef727/xbmc/utils/RssReader.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/utils/RssReader.cpp 2012-02-07 14:30:18.077099732 +0100
+@@ -44,7 +44,7 @@
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
@@ -6943,10 +6710,9 @@ index 18fcdb4..fff6f5e 100644
{
m_pObserver = NULL;
m_spacesBetweenFeeds = 0;
-diff --git a/xbmc/utils/RssReader.h b/xbmc/utils/RssReader.h
-index f94e2be..d202b37 100644
---- a/xbmc/utils/RssReader.h
-+++ b/xbmc/utils/RssReader.h
+diff -Naur xbmc-1fef727/xbmc/utils/RssReader.h xbmc-1fef727.patch/xbmc/utils/RssReader.h
+--- xbmc-1fef727/xbmc/utils/RssReader.h 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/utils/RssReader.h 2012-02-07 14:30:18.077099732 +0100
@@ -39,6 +39,9 @@
#include "tinyXML/tinyxml.h"
@@ -6957,10 +6723,9 @@ index f94e2be..d202b37 100644
#define RSS_COLOR_BODY 0
#define RSS_COLOR_HEADLINE 1
#define RSS_COLOR_CHANNEL 2
-diff --git a/xbmc/utils/Splash.cpp b/xbmc/utils/Splash.cpp
-index 58093b0..a53c90e 100644
---- a/xbmc/utils/Splash.cpp
-+++ b/xbmc/utils/Splash.cpp
+diff -Naur xbmc-1fef727/xbmc/utils/Splash.cpp xbmc-1fef727.patch/xbmc/utils/Splash.cpp
+--- xbmc-1fef727/xbmc/utils/Splash.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/utils/Splash.cpp 2012-02-07 14:30:18.078099752 +0100
@@ -31,7 +31,7 @@
using namespace XFILE;
@@ -6970,18 +6735,17 @@ index 58093b0..a53c90e 100644
{
m_ImageName = imageName;
fade = 0.5;
-@@ -139,5 +139,5 @@ void CSplash::Stop()
+@@ -139,5 +139,5 @@
bool CSplash::IsRunning()
{
- return (m_ThreadHandle != NULL);
+ return (IsRunning());
}
-diff --git a/xbmc/utils/TuxBoxUtil.cpp b/xbmc/utils/TuxBoxUtil.cpp
-index c15b634..ab5a5ce 100644
---- a/xbmc/utils/TuxBoxUtil.cpp
-+++ b/xbmc/utils/TuxBoxUtil.cpp
-@@ -48,7 +48,7 @@ using namespace std;
+diff -Naur xbmc-1fef727/xbmc/utils/TuxBoxUtil.cpp xbmc-1fef727.patch/xbmc/utils/TuxBoxUtil.cpp
+--- xbmc-1fef727/xbmc/utils/TuxBoxUtil.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/utils/TuxBoxUtil.cpp 2012-02-07 14:30:18.079099772 +0100
+@@ -48,7 +48,7 @@
CTuxBoxUtil g_tuxbox;
CTuxBoxService g_tuxboxService;
@@ -6990,11 +6754,10 @@ index c15b634..ab5a5ce 100644
{
}
CTuxBoxService::~CTuxBoxService()
-diff --git a/xbmc/video/VideoInfoDownloader.cpp b/xbmc/video/VideoInfoDownloader.cpp
-index 3185d2b..5a46034 100644
---- a/xbmc/video/VideoInfoDownloader.cpp
-+++ b/xbmc/video/VideoInfoDownloader.cpp
-@@ -116,7 +116,7 @@ int CVideoInfoDownloader::FindMovie(const CStdString &strMovie,
+diff -Naur xbmc-1fef727/xbmc/video/VideoInfoDownloader.cpp xbmc-1fef727.patch/xbmc/video/VideoInfoDownloader.cpp
+--- xbmc-1fef727/xbmc/video/VideoInfoDownloader.cpp 2012-02-07 12:46:48.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/video/VideoInfoDownloader.cpp 2012-02-07 14:30:18.079099772 +0100
+@@ -116,7 +116,7 @@
m_state = FIND_MOVIE;
m_strMovie = strMovie;
m_found = 0;
@@ -7003,7 +6766,7 @@ index 3185d2b..5a46034 100644
StopThread();
Create();
while (m_state != DO_NOTHING)
-@@ -160,7 +160,7 @@ bool CVideoInfoDownloader::GetDetails(const CScraperUrl &url,
+@@ -160,7 +160,7 @@
{ // threaded version
m_state = GET_DETAILS;
m_found = 0;
@@ -7012,7 +6775,7 @@ index 3185d2b..5a46034 100644
StopThread();
Create();
while (!m_found)
-@@ -195,7 +195,7 @@ bool CVideoInfoDownloader::GetEpisodeDetails(const CScraperUrl &url,
+@@ -195,7 +195,7 @@
{ // threaded version
m_state = GET_EPISODE_DETAILS;
m_found = 0;
@@ -7021,7 +6784,7 @@ index 3185d2b..5a46034 100644
StopThread();
Create();
while (!m_found)
-@@ -230,7 +230,7 @@ bool CVideoInfoDownloader::GetEpisodeList(const CScraperUrl& url,
+@@ -230,7 +230,7 @@
{ // threaded version
m_state = GET_EPISODE_LIST;
m_found = 0;
@@ -7030,11 +6793,10 @@ index 3185d2b..5a46034 100644
StopThread();
Create();
while (!m_found)
-diff --git a/xbmc/video/VideoInfoDownloader.h b/xbmc/video/VideoInfoDownloader.h
-index b91477d..8a05568 100644
---- a/xbmc/video/VideoInfoDownloader.h
-+++ b/xbmc/video/VideoInfoDownloader.h
-@@ -42,7 +42,7 @@ typedef std::vector MOVIELIST;
+diff -Naur xbmc-1fef727/xbmc/video/VideoInfoDownloader.h xbmc-1fef727.patch/xbmc/video/VideoInfoDownloader.h
+--- xbmc-1fef727/xbmc/video/VideoInfoDownloader.h 2012-02-07 12:46:48.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/video/VideoInfoDownloader.h 2012-02-07 14:30:18.080099792 +0100
+@@ -42,7 +42,7 @@
class CVideoInfoDownloader : public CThread
{
public:
@@ -7043,11 +6805,10 @@ index b91477d..8a05568 100644
virtual ~CVideoInfoDownloader() {}
// threaded lookup functions
-diff --git a/xbmc/video/VideoInfoScanner.cpp b/xbmc/video/VideoInfoScanner.cpp
-index 4534aa1..c245679 100644
---- a/xbmc/video/VideoInfoScanner.cpp
-+++ b/xbmc/video/VideoInfoScanner.cpp
-@@ -54,7 +54,7 @@ using namespace ADDON;
+diff -Naur xbmc-1fef727/xbmc/video/VideoInfoScanner.cpp xbmc-1fef727.patch/xbmc/video/VideoInfoScanner.cpp
+--- xbmc-1fef727/xbmc/video/VideoInfoScanner.cpp 2012-02-07 12:46:48.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/video/VideoInfoScanner.cpp 2012-02-07 14:30:18.081099811 +0100
+@@ -54,7 +54,7 @@
namespace VIDEO
{
@@ -7056,19 +6817,10 @@ index 4534aa1..c245679 100644
{
m_bRunning = false;
m_pObserver = NULL;
-diff --git a/xbmc/video/VideoReferenceClock.cpp b/xbmc/video/VideoReferenceClock.cpp
-index 83fabfe..b5c8154 100644
---- a/xbmc/video/VideoReferenceClock.cpp
-+++ b/xbmc/video/VideoReferenceClock.cpp
-@@ -30,6 +30,7 @@
- #if defined(HAS_GLX) && defined(HAS_XRANDR)
- #include
- #include
-+ #include "windowing/WindowingFactory.h"
- #define NVSETTINGSCMD "nvidia-settings -nt -q RefreshRate3"
- #elif defined(__APPLE__) && !defined(__arm__)
- #include
-@@ -106,7 +107,7 @@ using namespace std;
+diff -Naur xbmc-1fef727/xbmc/video/VideoReferenceClock.cpp xbmc-1fef727.patch/xbmc/video/VideoReferenceClock.cpp
+--- xbmc-1fef727/xbmc/video/VideoReferenceClock.cpp 2012-02-07 12:46:48.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/video/VideoReferenceClock.cpp 2012-02-07 14:30:18.082099830 +0100
+@@ -107,7 +107,7 @@
#endif
@@ -7077,7 +6829,7 @@ index 83fabfe..b5c8154 100644
{
m_SystemFrequency = CurrentHostFrequency();
m_ClockSpeed = 1.0;
-@@ -160,6 +161,8 @@ void CVideoReferenceClock::Process()
+@@ -161,6 +161,8 @@
m_RefreshChanged = 0;
m_Started.Set();
@@ -7086,242 +6838,10 @@ index 83fabfe..b5c8154 100644
if (SetupSuccess)
{
m_UseVblank = true; //tell other threads we're using vblank as clock
-@@ -228,6 +231,8 @@ bool CVideoReferenceClock::SetupGLX()
- m_vInfo = NULL;
- m_Context = NULL;
- m_Window = 0;
-+ m_pixmap = None;
-+ m_glPixmap = None;
-
- CLog::Log(LOGDEBUG, "CVideoReferenceClock: Setting up GLX");
-
-@@ -267,6 +272,14 @@ bool CVideoReferenceClock::SetupGLX()
- return false;
- }
-
-+ CStdString Vendor = g_Windowing.GetRenderVendor();
-+ Vendor.ToLower();
-+ if (Vendor.compare(0, 3, "ati") == 0)
-+ {
-+ CLog::Log(LOGDEBUG, "CVideoReferenceClock: GL_VENDOR: %s, using ati workaround", Vendor.c_str());
-+ m_bIsATI = true;
-+ }
-+
- m_vInfo = glXChooseVisual(m_Dpy, DefaultScreen(m_Dpy), singleBufferAttributes);
- if (!m_vInfo)
- {
-@@ -274,13 +287,26 @@ bool CVideoReferenceClock::SetupGLX()
- return false;
- }
-
-- Swa.border_pixel = 0;
-- Swa.event_mask = StructureNotifyMask;
-- Swa.colormap = XCreateColormap(m_Dpy, RootWindow(m_Dpy, m_vInfo->screen), m_vInfo->visual, AllocNone );
-- SwaMask = CWBorderPixel | CWColormap | CWEventMask;
-+ if (!m_bIsATI)
-+ {
-+ Swa.border_pixel = 0;
-+ Swa.event_mask = StructureNotifyMask;
-+ Swa.colormap = XCreateColormap(m_Dpy, RootWindow(m_Dpy, m_vInfo->screen), m_vInfo->visual, AllocNone );
-+ SwaMask = CWBorderPixel | CWColormap | CWEventMask;
-
-- m_Window = XCreateWindow(m_Dpy, RootWindow(m_Dpy, m_vInfo->screen), 0, 0, 256, 256, 0,
-+ m_Window = XCreateWindow(m_Dpy, RootWindow(m_Dpy, m_vInfo->screen), 0, 0, 256, 256, 0,
- m_vInfo->depth, InputOutput, m_vInfo->visual, SwaMask, &Swa);
-+ }
-+ else
-+ {
-+ m_pixmap = XCreatePixmap(m_Dpy, DefaultRootWindow(m_Dpy), 256, 256, m_vInfo->depth);
-+ if (!m_pixmap)
-+ {
-+ CLog::Log(LOGDEBUG, "CVideoReferenceClock: unable to create pixmap");
-+ return false;
-+ }
-+ m_glPixmap = glXCreateGLXPixmap(m_Dpy, m_vInfo, m_pixmap);
-+ }
-
- m_Context = glXCreateContext(m_Dpy, m_vInfo, NULL, True);
- if (!m_Context)
-@@ -289,25 +315,32 @@ bool CVideoReferenceClock::SetupGLX()
- return false;
- }
-
-- ReturnV = glXMakeCurrent(m_Dpy, m_Window, m_Context);
-+ if (!m_bIsATI)
-+ ReturnV = glXMakeCurrent(m_Dpy, m_Window, m_Context);
-+ else
-+ ReturnV = glXMakeCurrent(m_Dpy, m_glPixmap, m_Context);
-+
- if (ReturnV != True)
- {
- CLog::Log(LOGDEBUG, "CVideoReferenceClock: glXMakeCurrent returned %i", ReturnV);
- return false;
- }
-
-- m_glXWaitVideoSyncSGI = (int (*)(int, int, unsigned int*))glXGetProcAddress((const GLubyte*)"glXWaitVideoSyncSGI");
-- if (!m_glXWaitVideoSyncSGI)
-+ if (!m_bIsATI)
- {
-- CLog::Log(LOGDEBUG, "CVideoReferenceClock: glXWaitVideoSyncSGI not found");
-- return false;
-- }
-+ m_glXWaitVideoSyncSGI = (int (*)(int, int, unsigned int*))glXGetProcAddress((const GLubyte*)"glXWaitVideoSyncSGI");
-+ if (!m_glXWaitVideoSyncSGI)
-+ {
-+ CLog::Log(LOGDEBUG, "CVideoReferenceClock: glXWaitVideoSyncSGI not found");
-+ return false;
-+ }
-
-- ReturnV = m_glXWaitVideoSyncSGI(2, 0, &GlxTest);
-- if (ReturnV)
-- {
-- CLog::Log(LOGDEBUG, "CVideoReferenceClock: glXWaitVideoSyncSGI returned %i", ReturnV);
-- return false;
-+ ReturnV = m_glXWaitVideoSyncSGI(2, 0, &GlxTest);
-+ if (ReturnV)
-+ {
-+ CLog::Log(LOGDEBUG, "CVideoReferenceClock: glXWaitVideoSyncSGI returned %i", ReturnV);
-+ return false;
-+ }
- }
-
- m_glXGetVideoSyncSGI = (int (*)(unsigned int*))glXGetProcAddress((const GLubyte*)"glXGetVideoSyncSGI");
-@@ -479,19 +512,6 @@ void CVideoReferenceClock::CleanupGLX()
- {
- CLog::Log(LOGDEBUG, "CVideoReferenceClock: Cleaning up GLX");
-
-- bool AtiWorkaround = false;
-- const char* VendorPtr = (const char*)glGetString(GL_VENDOR);
-- if (VendorPtr)
-- {
-- CStdString Vendor = VendorPtr;
-- Vendor.ToLower();
-- if (Vendor.compare(0, 3, "ati") == 0)
-- {
-- CLog::Log(LOGDEBUG, "CVideoReferenceClock: GL_VENDOR: %s, using ati dpy workaround", VendorPtr);
-- AtiWorkaround = true;
-- }
-- }
--
- if (m_vInfo)
- {
- XFree(m_vInfo);
-@@ -508,9 +528,18 @@ void CVideoReferenceClock::CleanupGLX()
- XDestroyWindow(m_Dpy, m_Window);
- m_Window = 0;
- }
-+ if (m_glPixmap)
-+ {
-+ glXDestroyPixmap(m_Dpy, m_glPixmap);
-+ m_glPixmap = None;
-+ }
-+ if (m_pixmap)
-+ {
-+ XFreePixmap(m_Dpy, m_pixmap);
-+ m_pixmap = None;
-+ }
-
-- //ati saves the Display* in their libGL, if we close it here, we crash
-- if (m_Dpy && !AtiWorkaround)
-+ if (m_Dpy)
- {
- XCloseDisplay(m_Dpy);
- m_Dpy = NULL;
-@@ -532,10 +561,55 @@ void CVideoReferenceClock::RunGLX()
- m_glXGetVideoSyncSGI(&VblankCount);
- PrevVblankCount = VblankCount;
-
-+ int precision = 1;
-+ int proximity;
-+ uint64_t lastVblankTime = CurrentHostCounter();
-+ int sleepTime, correction;
-+
- while(!m_bStop)
- {
- //wait for the next vblank
-- ReturnV = m_glXWaitVideoSyncSGI(2, (VblankCount + 1) % 2, &VblankCount);
-+ if (!m_bIsATI)
-+ ReturnV = m_glXWaitVideoSyncSGI(2, (VblankCount + 1) % 2, &VblankCount);
-+ else
-+ {
-+ proximity = 0;
-+
-+ // calculate sleep time in micro secs
-+ // we start with 10% of interval multiplied with precision
-+ sleepTime = m_SystemFrequency / m_RefreshRate / 10000LL * precision;
-+
-+ // correct sleepTime
-+ correction = (CurrentHostCounter() - lastVblankTime) / m_SystemFrequency * 1000000LL;
-+ if (sleepTime > correction)
-+ sleepTime -= correction;
-+ usleep(sleepTime);
-+ m_glXGetVideoSyncSGI(&VblankCount);
-+ if (VblankCount == PrevVblankCount)
-+ {
-+ usleep(sleepTime/2);
-+ m_glXGetVideoSyncSGI(&VblankCount);
-+ while (VblankCount == PrevVblankCount)
-+ {
-+ usleep(sleepTime/20);
-+ m_glXGetVideoSyncSGI(&VblankCount);
-+ proximity++;
-+ }
-+ }
-+ // we might have waited too long, reduce sleep time
-+ else if (precision > 1)
-+ precision--;
-+
-+ // lets try to increase precision in order to reduce number
-+ // of required steps
-+ if (proximity > 4 && precision < 6)
-+ precision++;
-+
-+ lastVblankTime = CurrentHostCounter();
-+
-+ ReturnV = 0;
-+ }
-+
- m_glXGetVideoSyncSGI(&VblankCount); //the vblank count returned by glXWaitVideoSyncSGI is not always correct
- Now = CurrentHostCounter(); //get the timestamp of this vblank
-
-@@ -554,13 +628,14 @@ void CVideoReferenceClock::RunGLX()
- SingleLock.Leave();
- SendVblankSignal();
- UpdateRefreshrate();
--
- IsReset = false;
- }
- else
- {
- CLog::Log(LOGDEBUG, "CVideoReferenceClock: Vblank counter has reset");
-
-+ precision = 1;
-+
- //only try reattaching once
- if (IsReset)
- return;
-diff --git a/xbmc/video/VideoReferenceClock.h b/xbmc/video/VideoReferenceClock.h
-index 9699cd4..465d313 100644
---- a/xbmc/video/VideoReferenceClock.h
-+++ b/xbmc/video/VideoReferenceClock.h
-@@ -119,9 +119,12 @@ class CVideoReferenceClock : public CThread
- XVisualInfo *m_vInfo;
- Window m_Window;
- GLXContext m_Context;
-+ Pixmap m_pixmap;
-+ GLXPixmap m_glPixmap;
- int m_RREventBase;
-
- bool m_UseNvSettings;
-+ bool m_bIsATI;
-
- #elif defined(_WIN32) && defined(HAS_DX)
- bool SetupD3D();
-diff --git a/xbmc/win32/PlatformDefs.h b/xbmc/win32/PlatformDefs.h
-index 57cab8f..74e3d53 100644
---- a/xbmc/win32/PlatformDefs.h
-+++ b/xbmc/win32/PlatformDefs.h
-@@ -33,7 +33,6 @@ typedef __int64 off64_t;
+diff -Naur xbmc-1fef727/xbmc/win32/PlatformDefs.h xbmc-1fef727.patch/xbmc/win32/PlatformDefs.h
+--- xbmc-1fef727/xbmc/win32/PlatformDefs.h 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/win32/PlatformDefs.h 2012-02-07 14:30:18.082099830 +0100
+@@ -33,7 +33,6 @@
typedef __int64 fpos64_t;
typedef __int64 __off64_t;
typedef long __off_t;
@@ -7329,11 +6849,10 @@ index 57cab8f..74e3d53 100644
#define ssize_t int
-diff --git a/xbmc/win32/WindowHelper.cpp b/xbmc/win32/WindowHelper.cpp
-index 56856ac..8aa7da9 100644
---- a/xbmc/win32/WindowHelper.cpp
-+++ b/xbmc/win32/WindowHelper.cpp
-@@ -28,7 +28,7 @@ using namespace std;
+diff -Naur xbmc-1fef727/xbmc/win32/WindowHelper.cpp xbmc-1fef727.patch/xbmc/win32/WindowHelper.cpp
+--- xbmc-1fef727/xbmc/win32/WindowHelper.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/win32/WindowHelper.cpp 2012-02-07 14:30:18.083099850 +0100
+@@ -28,7 +28,7 @@
CWHelper g_windowHelper;
@@ -7342,10 +6861,9 @@ index 56856ac..8aa7da9 100644
{
m_hwnd = NULL;
m_hProcess = NULL;
-diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp
-index 62cf554..931700b 100644
---- a/xbmc/windowing/X11/WinSystemX11.cpp
-+++ b/xbmc/windowing/X11/WinSystemX11.cpp
+diff -Naur xbmc-1fef727/xbmc/windowing/X11/WinSystemX11.cpp xbmc-1fef727.patch/xbmc/windowing/X11/WinSystemX11.cpp
+--- xbmc-1fef727/xbmc/windowing/X11/WinSystemX11.cpp 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/windowing/X11/WinSystemX11.cpp 2012-02-07 14:30:43.758606503 +0100
@@ -35,6 +35,8 @@
#include
#include "cores/VideoRenderers/RenderManager.h"
@@ -7355,15 +6873,15 @@ index 62cf554..931700b 100644
#if defined(HAS_XRANDR)
#include
-@@ -52,6 +54,7 @@ CWinSystemX11::CWinSystemX11() : CWinSystemBase()
+@@ -52,6 +54,7 @@
m_wmWindow = 0;
m_bWasFullScreenBeforeMinimize = false;
m_dpyLostTime = 0;
+ m_internalModeSwitch = false;
- }
- CWinSystemX11::~CWinSystemX11()
-@@ -176,6 +179,45 @@ bool CWinSystemX11::ResizeWindow(int newWidth, int newHeight, int newLeft, int n
+ XSetErrorHandler(XErrorHandler);
+ }
+@@ -178,6 +181,45 @@
return false;
}
@@ -7409,7 +6927,7 @@ index 62cf554..931700b 100644
bool CWinSystemX11::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays)
{
m_nWidth = res.iWidth;
-@@ -191,13 +233,32 @@ bool CWinSystemX11::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool bl
+@@ -193,13 +235,32 @@
mode.hz = res.fRefreshRate;
mode.id = res.strId;
@@ -7445,7 +6963,7 @@ index 62cf554..931700b 100644
#endif
int options = SDL_OPENGL;
-@@ -491,6 +552,7 @@ void CWinSystemX11::CheckDisplayEvents()
+@@ -493,6 +554,7 @@
if (bGotEvent || bTimeout)
{
CLog::Log(LOGDEBUG, "%s - notify display reset event", __FUNCTION__);
@@ -7453,10 +6971,9 @@ index 62cf554..931700b 100644
CSingleLock lock(m_resourceSection);
-diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h
-index 5b941be..be59c5c 100644
---- a/xbmc/windowing/X11/WinSystemX11.h
-+++ b/xbmc/windowing/X11/WinSystemX11.h
+diff -Naur xbmc-1fef727/xbmc/windowing/X11/WinSystemX11.h xbmc-1fef727.patch/xbmc/windowing/X11/WinSystemX11.h
+--- xbmc-1fef727/xbmc/windowing/X11/WinSystemX11.h 2012-02-07 12:46:51.000000000 +0100
++++ xbmc-1fef727.patch/xbmc/windowing/X11/WinSystemX11.h 2012-02-07 14:30:18.085099890 +0100
@@ -27,6 +27,7 @@
#include "utils/Stopwatch.h"
#include
@@ -7465,7 +6982,7 @@ index 5b941be..be59c5c 100644
class IDispResource;
-@@ -60,6 +61,7 @@ public:
+@@ -60,6 +61,7 @@
// Local to WinSystemX11 only
Display* GetDisplay() { return m_dpy; }
GLXWindow GetWindow() { return m_glWindow; }
@@ -7473,7 +6990,7 @@ index 5b941be..be59c5c 100644
protected:
bool RefreshGlxContext();
-@@ -76,6 +78,9 @@ protected:
+@@ -76,6 +78,9 @@
CCriticalSection m_resourceSection;
std::vector m_resources;
uint64_t m_dpyLostTime;
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-981-toggleButtonState.patch b/packages/mediacenter/xbmc/patches/xbmc-1fef727-981-toggleButtonState.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-f76c547-981-toggleButtonState.patch
rename to packages/mediacenter/xbmc/patches/xbmc-1fef727-981-toggleButtonState.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-013-reenable_lcd_config_settings-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-f76c547-013-reenable_lcd_config_settings-0.1.patch
deleted file mode 100644
index 656dcac934..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-f76c547-013-reenable_lcd_config_settings-0.1.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff -Naur xbmc-9389dc8/xbmc/settings/GUISettings.cpp xbmc-9389dc8.patch/xbmc/settings/GUISettings.cpp
---- xbmc-9389dc8/xbmc/settings/GUISettings.cpp 2011-09-01 23:34:05.267139356 +0200
-+++ xbmc-9389dc8.patch/xbmc/settings/GUISettings.cpp 2011-09-01 23:34:52.098765331 +0200
-@@ -423,7 +423,8 @@
- AddString(vs, "videoscreen.testpattern",226,"", BUTTON_CONTROL_STANDARD);
- #endif
- #if defined(_LINUX) && !defined(__APPLE__)
-- AddBool(NULL, "videoscreen.haslcd", 4501, false);
-+ AddSeparator(vs, "videoscreen.sep2");
-+ AddBool(vs, "videoscreen.haslcd", 4501, false);
- #endif
-
- CSettingsCategory* ao = AddCategory(4, "audiooutput", 772);
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-462-add_remote_irtrans_mediacenter-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-f76c547-462-add_remote_irtrans_mediacenter-0.1.patch
deleted file mode 100644
index 0edef5a7a5..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-f76c547-462-add_remote_irtrans_mediacenter-0.1.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-diff -Naur xbmc-pvr-3513480/system/Lircmap.xml xbmc-pvr-3513480.patch/system/Lircmap.xml
---- xbmc-pvr-3513480/system/Lircmap.xml 2011-04-25 02:36:33.000000000 +0200
-+++ xbmc-pvr-3513480.patch/system/Lircmap.xml 2011-04-25 05:31:39.632429078 +0200
-@@ -409,4 +409,48 @@
- KEY_YELLOW
- KEY_BLUE
-
-+
-+ pause
-+ stop
-+ fwd
-+ rew
-+ left
-+ right
-+ up
-+ down
-+
-+ ch+
-+ ch-
-+ back
-+
-+ play
-+ info
-+ next
-+ prev
-+ teletext
-+ ehome
-+ rec
-+ vol+
-+ vol-
-+ mute
-+ power
-+ video
-+ music
-+ pictures
-+ tv
-+ 1
-+ 2
-+ 3
-+ 4
-+ 5
-+ 6
-+ 7
-+ 8
-+ 9
-+ 0
-+ red
-+ green
-+ yellow
-+ blue
-+
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-f76c547-991-use_XSetErrorHandler_so_libX11_doesnt_call_exit.patch b/packages/mediacenter/xbmc/patches/xbmc-f76c547-991-use_XSetErrorHandler_so_libX11_doesnt_call_exit.patch
deleted file mode 100644
index b7bbb2a019..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-f76c547-991-use_XSetErrorHandler_so_libX11_doesnt_call_exit.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff -Naur xbmc-f76c547/xbmc/windowing/X11/WinSystemX11.cpp xbmc-f76c547.patch/xbmc/windowing/X11/WinSystemX11.cpp
---- xbmc-f76c547/xbmc/windowing/X11/WinSystemX11.cpp 2012-02-06 15:19:03.037732518 +0100
-+++ xbmc-f76c547.patch/xbmc/windowing/X11/WinSystemX11.cpp 2012-02-06 15:18:37.545260709 +0100
-@@ -55,6 +55,8 @@
- m_bWasFullScreenBeforeMinimize = false;
- m_dpyLostTime = 0;
- m_internalModeSwitch = false;
-+
-+ XSetErrorHandler(XErrorHandler);
- }
-
- CWinSystemX11::~CWinSystemX11()
-@@ -596,4 +598,14 @@
- m_resources.erase(i);
- }
-
-+int CWinSystemX11::XErrorHandler(Display* dpy, XErrorEvent* error)
-+{
-+ char buf[1024];
-+ XGetErrorText(error->display, error->error_code, buf, sizeof(buf));
-+ CLog::Log(LOGERROR, "CWinSystemX11::XErrorHandler: %s, type:%i, serial:%lu, error_code:%i, request_code:%i minor_code:%i",
-+ buf, error->type, error->serial, (int)error->error_code, (int)error->request_code, (int)error->minor_code);
-+
-+ return 0;
-+}
-+
- #endif
-diff -Naur xbmc-f76c547/xbmc/windowing/X11/WinSystemX11.h xbmc-f76c547.patch/xbmc/windowing/X11/WinSystemX11.h
---- xbmc-f76c547/xbmc/windowing/X11/WinSystemX11.h 2012-02-06 15:19:03.038732537 +0100
-+++ xbmc-f76c547.patch/xbmc/windowing/X11/WinSystemX11.h 2012-02-06 15:17:16.253756180 +0100
-@@ -84,6 +84,7 @@
-
- private:
- bool IsSuitableVisual(XVisualInfo *vInfo);
-+ static int XErrorHandler(Display* dpy, XErrorEvent* error);
-
- CStopWatch m_screensaverReset;
- };