diff --git a/packages/mediacenter/xbmc-theme-Confluence/meta b/packages/mediacenter/xbmc-theme-Confluence/meta
index f7ebd60761..10debe2adc 100644
--- a/packages/mediacenter/xbmc-theme-Confluence/meta
+++ b/packages/mediacenter/xbmc-theme-Confluence/meta
@@ -19,11 +19,7 @@
################################################################################
PKG_NAME="xbmc-theme-Confluence"
-if [ "$PVR" = yes ]; then
- PKG_VERSION="pvr-11.0.2"
-else
- PKG_VERSION="11.0.1"
-fi
+PKG_VERSION="11.0.2"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="GPL"
diff --git a/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-11.0.1-001-add_oe_settings_to_homescreen.patch b/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-11.0.2-001-add_oe_settings_to_homescreen.patch
similarity index 100%
rename from packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-11.0.1-001-add_oe_settings_to_homescreen.patch
rename to packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-11.0.2-001-add_oe_settings_to_homescreen.patch
diff --git a/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-11.0.1-801.04-cec-PR887.patch b/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-11.0.2-801.04-cec-PR887.patch
similarity index 100%
rename from packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-11.0.1-801.04-cec-PR887.patch
rename to packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-11.0.2-801.04-cec-PR887.patch
diff --git a/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-pvr-11.0.1-001-add_oe_settings_to_homescreen.patch b/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-pvr-11.0.1-001-add_oe_settings_to_homescreen.patch
deleted file mode 100644
index d12175ed71..0000000000
--- a/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-pvr-11.0.1-001-add_oe_settings_to_homescreen.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- xbmc-theme-Confluence-11.0.1/720p/IncludesHomeMenuItems.xml 2012-03-31 08:37:23.304505434 +0400
-+++ xbmc-theme-Confluence-11.0.1/720p/IncludesHomeMenuItems.patch.xml 2012-03-31 08:39:57.894660377 +0400
-@@ -183,6 +183,11 @@
-
- ActivateWindow(Settings)
-
-+
-+ ButtonHomeSubCommonValues
-+
-+ RunAddon(os.openelec.settings)
-+
-
- ButtonHomeSubCommonValues
-
diff --git a/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-pvr-11.0.1-801.04-cec-PR887.patch b/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-pvr-11.0.1-801.04-cec-PR887.patch
deleted file mode 100644
index ee93a64678..0000000000
--- a/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-pvr-11.0.1-801.04-cec-PR887.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-From 3e1367b680b26123e9e1aa09f8caf2a932d47572 Mon Sep 17 00:00:00 2001
-From: Lars Op den Kamp
-Date: Tue, 17 Apr 2012 01:57:43 +0200
-Subject: [PATCH 2/2] cec: libCEC 1.6 support and fixes. libCEC 1.6+ is needed
- when using firmware v2 on the CEC adapter, which adds
- wake over CEC * added a new setting to control
- whether to put the TV in standby when the player is put
- in standby. * added some button mappings: all menu
- related buttons -> menu, previous channel -> teletext,
- added support for the channels list on samsung, mapped
- next fav -> menu (when available) * display the
- firmware version in the peripheral manager (if
- available) * handle the new CEC alert callback
- (libCEC 1.6+) * replaced 'Put this PC in standby mode
- when the TV is switched off' with an enum that allows
- the user to chose between 'Ignore', 'Suspend' and
- 'Shutdown' * fixed - crash when changing settings
- without libCEC started. * fixed - range of wake and
- power-off devices * fixed - update the correct
- standby device setting ('standby_devices' not
- 'wake_devices') * fixed - don't get the settings from
- the eeprom, but always use the settings provided in
- xbmc
-
----
- .../720p/DialogPeripheralManager.xml | 4 +-
- configure.in | 2 +-
- language/English/strings.xml | 5 +-
- project/BuildDependencies/scripts/libcec_d.txt | 2 +-
- system/peripherals.xml | 15 +-
- tools/darwin/depends/libcec/Makefile | 2 +-
- xbmc/peripherals/bus/PeripheralBus.cpp | 1 +
- xbmc/peripherals/devices/Peripheral.h | 2 +
- xbmc/peripherals/devices/PeripheralCecAdapter.cpp | 160 ++++++++++++++++----
- xbmc/peripherals/devices/PeripheralCecAdapter.h | 4 +
- 10 files changed, 152 insertions(+), 45 deletions(-)
-
-diff --git a/720p/DialogPeripheralManager.xml b/720p/DialogPeripheralManager.xml
-index 07954d0..5717017 100644
---- a/720p/DialogPeripheralManager.xml
-+++ b/720p/DialogPeripheralManager.xml
-@@ -117,7 +117,7 @@
- 50
- 520
- 20
--
-+
- left
- center
- font12
-@@ -173,7 +173,7 @@
- 50
- 520
- 20
--
-+
- left
- center
- font12
---
-1.7.5.4
-
diff --git a/packages/mediacenter/xbmc/install b/packages/mediacenter/xbmc/install
index 0cc27e104e..9f7e80a580 100755
--- a/packages/mediacenter/xbmc/install
+++ b/packages/mediacenter/xbmc/install
@@ -29,9 +29,7 @@ mkdir -p $INSTALL/usr/bin
cp $PKG_DIR/scripts/gputemp $INSTALL/usr/bin
cp $PKG_DIR/scripts/wait_on_xbmc_exit $INSTALL/usr/bin
cp $PKG_BUILD/tools/EventClients/Clients/XBMC\ Send/xbmc-send.py $INSTALL/usr/bin/xbmc-send
- if [ "$PVR" = yes ]; then
- cp $PKG_DIR/scripts/setwakeup.sh $INSTALL/usr/bin
- fi
+ cp $PKG_DIR/scripts/setwakeup.sh $INSTALL/usr/bin
mkdir -p $INSTALL/usr/lib/xbmc
cp $PKG_BUILD/xbmc.bin $INSTALL/usr/lib/xbmc
diff --git a/packages/mediacenter/xbmc/meta b/packages/mediacenter/xbmc/meta
index 0113858204..9691da35bc 100644
--- a/packages/mediacenter/xbmc/meta
+++ b/packages/mediacenter/xbmc/meta
@@ -19,11 +19,7 @@
################################################################################
PKG_NAME="xbmc"
-if [ "$PVR" = yes ]; then
- PKG_VERSION="pvr-11.0.2"
-else
- PKG_VERSION="11.0.1"
-fi
+PKG_VERSION="11.0.2"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="GPL"
@@ -46,6 +42,10 @@ PKG_AUTORECONF="no"
PKG_DEPENDS="$PKG_DEPENDS Imaging"
PKG_DEPENDS="$PKG_DEPENDS simplejson"
+# various PVR clients
+ PKG_DEPENDS="$PKG_DEPENDS xbmc-addon-xvdr xbmc-addon-njoy"
+ PKG_DEPENDS="$PKG_DEPENDS xbmc-addon-xvdr xbmc-addon-vuplus"
+
if [ "$DISPLAYSERVER" = "xorg-server" ]; then
# for libX11 support
PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libX11 libXext"
@@ -149,8 +149,3 @@ fi
if [ "$XVBA" = yes ]; then
PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS xf86-video-fglrx"
fi
-
-if [ "$PVR" = yes ]; then
- PKG_DEPENDS="$PKG_DEPENDS xbmc-addon-xvdr xbmc-addon-njoy"
- PKG_DEPENDS="$PKG_DEPENDS xbmc-addon-xvdr xbmc-addon-vuplus"
-fi
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-801.01-cec-PR570.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.1-801.01-cec-PR570.patch
deleted file mode 100644
index ec91a7327d..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-801.01-cec-PR570.patch
+++ /dev/null
@@ -1,1976 +0,0 @@
-diff -Naur xbmc-11.0.1/configure.in xbmc-11.0.1.patch/configure.in
---- xbmc-11.0.1/configure.in 2012-03-21 23:57:58.000000000 +0100
-+++ xbmc-11.0.1.patch/configure.in 2012-04-17 14:47:57.830482197 +0200
-@@ -1173,7 +1173,7 @@
-
- # libcec is dyloaded, so we need to check for its headers and link any depends.
- if test "x$use_libcec" != "xno"; then
-- PKG_CHECK_MODULES([CEC],[libcec >= 1.1.0],,[use_libcec="no";AC_MSG_RESULT($libcec_disabled)])
-+ PKG_CHECK_MODULES([CEC],[libcec >= 1.5.0],,[use_libcec="no";AC_MSG_RESULT($libcec_disabled)])
-
- if test "x$use_libcec" != "xno"; then
- INCLUDES="$INCLUDES $CEC_CFLAGS"
-diff -Naur xbmc-11.0.1/language/English/strings.xml xbmc-11.0.1.patch/language/English/strings.xml
---- xbmc-11.0.1/language/English/strings.xml 2012-03-21 23:57:54.000000000 +0100
-+++ xbmc-11.0.1.patch/language/English/strings.xml 2012-04-17 14:47:57.881483158 +0200
-@@ -2378,6 +2378,7 @@
- Device removed
- Keymap to use for this device
- Keymap enabled
-+ Do not use the custom keymap for this device
-
- Location
- Class
-@@ -2392,16 +2393,23 @@
- Press "user" button command
- Enable switch side commands
- Could not open the adapter
-- Power on the TV when starting XBMC
-- Power off devices when stopping XBMC
-+ Devices to power on the TV when starting XBMC
-+ Devices to power off devices when stopping XBMC
- Put devices in standby mode when activating screensaver
-
- Could not detect the CEC port. Set it up manually.
-- Could not detect the CEC adapter.
-- Unsupported libcec interface version. %d is greater than the version XBMC supports (%d)
-+ Could not initialise the CEC adapter. Check your settings.
-+ Unsupported libCEC interface version. %d is greater than the version XBMC supports (%d)
- Put this PC in standby mode when the TV is switched off
- HDMI port number
- Connected
-- Adapter found, but libcec is not available
-+ Adapter found, but libCEC is not available
- Use the TV's language setting
-+ Connected to HDMI device
-+ Make XBMC the active source when starting
-+ Physical address (overrules HDMI port)
-+ COM port (leave empty unless needed)
-+ Configuration updated
-+ Failed to set the new configuration. Please check your settings.
-+ Send 'inactive source' command when stopping XBMC
-
-diff -Naur xbmc-11.0.1/lib/libcec/Makefile xbmc-11.0.1.patch/lib/libcec/Makefile
---- xbmc-11.0.1/lib/libcec/Makefile 2012-03-21 23:57:36.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/libcec/Makefile 2012-04-17 14:47:58.899502388 +0200
-@@ -7,17 +7,17 @@
-
- # lib name, version
- LIBNAME=libcec
--VERSION=1.2.0
-+VERSION=latest
- SOURCE=$(LIBNAME)-$(VERSION)
-
- # download location and format
--BASE_URL=http://mirrors.xbmc.org/build-deps/darwin-libs
--ARCHIVE=$(SOURCE).tar.gz
-+BASE_URL=http://packages.pulse-eight.net/pulse/sources/libcec
-+ARCHIVE=$(SOURCE).tar.bz2
- TARBALLS_LOCATION=.
- RETRIEVE_TOOL=/usr/bin/curl
- RETRIEVE_TOOL_FLAGS=-Ls --create-dirs --output $(TARBALLS_LOCATION)/$(ARCHIVE)
- ARCHIVE_TOOL=tar
--ARCHIVE_TOOL_FLAGS=xf
-+ARCHIVE_TOOL_FLAGS=jxf
-
- PREFIX ?= /usr/local
- LIBCEC_CONFIGOPTS ?= --prefix=$(PREFIX)
-@@ -25,30 +25,30 @@
- # configuration settings
- CONFIGURE=./configure CFLAGS=-D_FILE_OFFSET_BITS=64 $(LIBCEC_CONFIGOPTS)
-
--SO_NAME=$(SOURCE)/.libs/$(LIBNAME).so
-+SO_NAME=$(LIBNAME)/.libs/$(LIBNAME).so
-
- all: $(SO_NAME)
-
- $(TARBALLS_LOCATION)/$(ARCHIVE):
- $(RETRIEVE_TOOL) $(RETRIEVE_TOOL_FLAGS) $(BASE_URL)/$(ARCHIVE)
-
--$(SOURCE): $(TARBALLS_LOCATION)/$(ARCHIVE)
-- rm -rf $(SOURCE)
-+$(LIBNAME): $(TARBALLS_LOCATION)/$(ARCHIVE)
-+ rm -rf $(LIBNAME)
- $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE)
-- echo $(SOURCE) > .gitignore
-- cd $(SOURCE); autoreconf -vif
-- cd $(SOURCE); $(CONFIGURE)
-+ echo $(LIBNAME) > .gitignore
-+ cd $(LIBNAME); autoreconf -vif
-+ cd $(LIBNAME); $(CONFIGURE)
-
--$(SO_NAME): $(SOURCE)
-- make -j 1 -C $(SOURCE)
-+$(SO_NAME): $(LIBNAME)
-+ make -j 1 -C $(LIBNAME)
-
- install:
-- make -C $(SOURCE) install
-+ make -C $(LIBNAME) install
- ldconfig
-
- clean:
-- rm -rf $(SOURCE)
-+ rm -rf $(LIBNAME)
-
- distclean::
-- rm -rf $(SOURCE)
-+ rm -rf $(LIBNAME)
-
-diff -Naur xbmc-11.0.1/system/peripherals.xml xbmc-11.0.1.patch/system/peripherals.xml
---- xbmc-11.0.1/system/peripherals.xml 2012-03-21 23:57:58.000000000 +0100
-+++ xbmc-11.0.1.patch/system/peripherals.xml 2012-04-17 14:47:58.899502388 +0200
-@@ -1,22 +1,29 @@
-
-
--
-+
-
--
--
--
--
-+
-+
-+
-+
-
-
--
--
--
--
--
--
--
--
--
--
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-+
-
-
-diff -Naur xbmc-11.0.1/xbmc/Application.cpp xbmc-11.0.1.patch/xbmc/Application.cpp
---- xbmc-11.0.1/xbmc/Application.cpp 2012-03-21 23:57:32.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/Application.cpp 2012-04-17 14:48:56.437589161 +0200
-@@ -160,9 +160,6 @@
- #endif
- #include "interfaces/AnnouncementManager.h"
- #include "peripherals/Peripherals.h"
--#ifdef HAVE_LIBCEC
--#include "peripherals/devices/PeripheralCecAdapter.h"
--#endif
- #include "peripherals/dialogs/GUIDialogPeripheralManager.h"
- #include "peripherals/dialogs/GUIDialogPeripheralSettings.h"
-
-@@ -2556,6 +2553,10 @@
- }
- }
- }
-+
-+ if (g_peripherals.OnAction(action))
-+ return true;
-+
- if (action.GetID() == ACTION_MUTE)
- {
- ToggleMute();
-@@ -2831,23 +2832,9 @@
-
- bool CApplication::ProcessPeripherals(float frameTime)
- {
--#ifdef HAVE_LIBCEC
-- vector peripherals;
-- if (g_peripherals.GetPeripheralsWithFeature(peripherals, FEATURE_CEC))
-- {
-- for (unsigned int iPeripheralPtr = 0; iPeripheralPtr < peripherals.size(); iPeripheralPtr++)
-- {
-- CPeripheralCecAdapter *cecDevice = (CPeripheralCecAdapter *) peripherals.at(iPeripheralPtr);
-- if (cecDevice && cecDevice->GetButton())
-- {
-- CKey key(cecDevice->GetButton(), cecDevice->GetHoldTime());
-- cecDevice->ResetButton();
-- return OnKey(key);
-- }
-- }
-- }
--#endif
--
-+ CKey key;
-+ if (g_peripherals.GetNextKeypress(frameTime, key))
-+ return OnKey(key);
- return false;
- }
-
-@@ -3288,7 +3275,8 @@
- {
- try
- {
-- CAnnouncementManager::Announce(System, "xbmc", "OnQuit");
-+ CVariant vExitCode(exitCode);
-+ CAnnouncementManager::Announce(System, "xbmc", "OnQuit", vExitCode);
-
- // cancel any jobs from the jobmanager
- CJobManager::GetInstance().CancelJobs();
-@@ -5027,6 +5015,8 @@
-
- bool CApplication::IsMuted() const
- {
-+ if (g_peripherals.IsMuted())
-+ return true;
- return g_settings.m_bMute;
- }
-
-@@ -5040,6 +5030,9 @@
-
- void CApplication::Mute()
- {
-+ if (g_peripherals.Mute())
-+ return;
-+
- g_settings.m_iPreMuteVolumeLevel = GetVolume();
- SetVolume(0);
- g_settings.m_bMute = true;
-@@ -5047,6 +5040,9 @@
-
- void CApplication::UnMute()
- {
-+ if (g_peripherals.UnMute())
-+ return;
-+
- SetVolume(g_settings.m_iPreMuteVolumeLevel);
- g_settings.m_iPreMuteVolumeLevel = 0;
- g_settings.m_bMute = false;
-diff -Naur xbmc-11.0.1/xbmc/peripherals/devices/PeripheralCecAdapter.cpp xbmc-11.0.1.patch/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
---- xbmc-11.0.1/xbmc/peripherals/devices/PeripheralCecAdapter.cpp 2012-03-21 23:57:32.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/peripherals/devices/PeripheralCecAdapter.cpp 2012-04-17 14:47:59.547514629 +0200
-@@ -18,8 +18,8 @@
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
--#include "system.h"
-
-+#include "system.h"
- #if defined(HAVE_LIBCEC)
- #include "PeripheralCecAdapter.h"
- #include "input/XBIRRemote.h"
-@@ -31,36 +31,40 @@
- #include "peripherals/Peripherals.h"
- #include "peripherals/bus/PeripheralBus.h"
- #include "settings/GUISettings.h"
-+#include "settings/Settings.h"
- #include "utils/log.h"
-+#include "utils/Variant.h"
-
--#include
-+#include
-
- using namespace PERIPHERALS;
- using namespace ANNOUNCEMENT;
- using namespace CEC;
-
--#define CEC_LIB_SUPPORTED_VERSION 1
-+#define CEC_LIB_SUPPORTED_VERSION 0x1500
-
- /* time in seconds to ignore standby commands from devices after the screensaver has been activated */
- #define SCREENSAVER_TIMEOUT 10
-+#define VOLUME_CHANGE_TIMEOUT 250
-+#define VOLUME_REFRESH_TIMEOUT 100
-
- class DllLibCECInterface
- {
- public:
- virtual ~DllLibCECInterface() {}
-- virtual ICECAdapter* CECInit(const char *interfaceName, cec_device_type_list types)=0;
-- virtual void* CECDestroy(ICECAdapter *adapter)=0;
-+ virtual ICECAdapter* CECInitialise(libcec_configuration *configuration)=0;
-+ virtual void* CECDestroy(ICECAdapter *adapter)=0;
- };
-
- class DllLibCEC : public DllDynamic, DllLibCECInterface
- {
- DECLARE_DLL_WRAPPER(DllLibCEC, DLL_PATH_LIBCEC)
-
-- DEFINE_METHOD2(ICECAdapter*, CECInit, (const char *p1, cec_device_type_list p2))
-- DEFINE_METHOD1(void* , CECDestroy, (ICECAdapter *p1))
-+ DEFINE_METHOD1(ICECAdapter*, CECInitialise, (libcec_configuration *p1))
-+ DEFINE_METHOD1(void* , CECDestroy, (ICECAdapter *p1))
-
- BEGIN_METHOD_RESOLVE()
-- RESOLVE_METHOD_RENAME(CECInit, CECInit)
-+ RESOLVE_METHOD_RENAME(CECInitialise, CECInitialise)
- RESOLVE_METHOD_RENAME(CECDestroy, CECDestroy)
- END_METHOD_RESOLVE()
- };
-@@ -71,41 +75,19 @@
- m_bStarted(false),
- m_bHasButton(false),
- m_bIsReady(false),
-+ m_bHasConnectedAudioSystem(false),
- m_strMenuLanguage("???"),
-- m_lastKeypress(0)
-+ m_lastKeypress(0),
-+ m_lastChange(VOLUME_CHANGE_NONE),
-+ m_iExitCode(0),
-+ m_bIsMuted(false) // TODO fetch the correct initial value when system audiostatus is implemented in libCEC
- {
- m_button.iButton = 0;
- m_button.iDuration = 0;
- m_screensaverLastActivated.SetValid(false);
-- m_dll = new DllLibCEC;
-- if (m_dll->Load() && m_dll->IsLoaded())
-- {
-- cec_device_type_list typeList;
-- typeList.clear();
-- typeList.add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
-- m_cecAdapter = m_dll->CECInit("XBMC", typeList);
-- }
-- else
-- m_cecAdapter = NULL;
--
-- if (!m_cecAdapter || m_cecAdapter->GetMinLibVersion() > CEC_LIB_SUPPORTED_VERSION)
-- {
-- /* unsupported libcec version */
-- CLog::Log(LOGERROR, g_localizeStrings.Get(36013).c_str(), CEC_LIB_SUPPORTED_VERSION, m_cecAdapter ? m_cecAdapter->GetMinLibVersion() : -1);
-
-- CStdString strMessage;
-- strMessage.Format(g_localizeStrings.Get(36013).c_str(), CEC_LIB_SUPPORTED_VERSION, m_cecAdapter ? m_cecAdapter->GetMinLibVersion() : -1);
-- CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(36000), strMessage);
-- m_bError = true;
-- if (m_cecAdapter)
-- m_dll->CECDestroy(m_cecAdapter);
-- m_cecAdapter = NULL;
-- }
-- else
-- {
-- CLog::Log(LOGDEBUG, "%s - using libCEC v%d.%d", __FUNCTION__, m_cecAdapter->GetLibVersionMajor(), m_cecAdapter->GetLibVersionMinor());
-- m_features.push_back(FEATURE_CEC);
-- }
-+ m_configuration.Clear();
-+ m_features.push_back(FEATURE_CEC);
- }
-
- CPeripheralCecAdapter::~CPeripheralCecAdapter(void)
-@@ -117,7 +99,6 @@
-
- if (m_dll && m_cecAdapter)
- {
-- FlushLog();
- m_dll->CECDestroy(m_cecAdapter);
- m_cecAdapter = NULL;
- delete m_dll;
-@@ -129,60 +110,94 @@
- {
- if (flag == System && !strcmp(sender, "xbmc") && !strcmp(message, "OnQuit") && m_bIsReady)
- {
-- m_cecAdapter->SetInactiveView();
-- if (GetSettingBool("cec_power_off_shutdown"))
-- m_cecAdapter->StandbyDevices();
-+ m_iExitCode = data.asInteger(0);
-+ StopThread(false);
- }
-- else if (flag == GUI && !strcmp(sender, "xbmc") && !strcmp(message, "OnScreensaverDeactivated") && GetSettingBool("cec_standby_screensaver") && m_bIsReady)
-+ else if (flag == GUI && !strcmp(sender, "xbmc") && !strcmp(message, "OnScreensaverDeactivated") && m_bIsReady)
- {
-- m_cecAdapter->PowerOnDevices();
-+ if (m_configuration.bPowerOffScreensaver == 1)
-+ {
-+ // power off/on on screensaver is set, and devices to wake are set
-+ if (!m_configuration.wakeDevices.IsEmpty())
-+ m_cecAdapter->PowerOnDevices(CECDEVICE_BROADCAST);
-+
-+ // the option to make XBMC the active source is set
-+ if (m_configuration.bActivateSource == 1)
-+ m_cecAdapter->SetActiveSource();
-+ }
- }
-- else if (flag == GUI && !strcmp(sender, "xbmc") && !strcmp(message, "OnScreensaverActivated") && GetSettingBool("cec_standby_screensaver"))
-+ else if (flag == GUI && !strcmp(sender, "xbmc") && !strcmp(message, "OnScreensaverActivated") && m_bIsReady)
- {
- // Don't put devices to standby if application is currently playing
-- if (!g_application.IsPlaying() || g_application.IsPaused())
-+ if ((!g_application.IsPlaying() || g_application.IsPaused()) && m_configuration.bPowerOffScreensaver == 1)
- {
- m_screensaverLastActivated = CDateTime::GetCurrentDateTime();
-- m_cecAdapter->StandbyDevices();
-+ // only power off when we're the active source
-+ if (m_cecAdapter->IsLibCECActiveSource())
-+ m_cecAdapter->StandbyDevices(CECDEVICE_BROADCAST);
- }
- }
- else if (flag == System && !strcmp(sender, "xbmc") && !strcmp(message, "OnSleep"))
- {
-- if (GetSettingBool("cec_power_off_shutdown") && m_bIsReady)
-- m_cecAdapter->StandbyDevices();
-+ // this will also power off devices when we're the active source
- CSingleLock lock(m_critSection);
- m_bStop = true;
- WaitForThreadExit(0);
- }
- else if (flag == System && !strcmp(sender, "xbmc") && !strcmp(message, "OnWake"))
- {
-+ // reconnect to the device
- CSingleLock lock(m_critSection);
- CLog::Log(LOGDEBUG, "%s - reconnecting to the CEC adapter after standby mode", __FUNCTION__);
-+
-+ // close the previous connection
- m_cecAdapter->Close();
-
-- CStdString strPort = GetComPort();
-- if (!strPort.empty())
-- {
-- if (!m_cecAdapter->Open(strPort.c_str(), 10000))
-- {
-- CLog::Log(LOGERROR, "%s - failed to reconnect to the CEC adapter", __FUNCTION__);
-- FlushLog();
-- m_bStop = true;
-- }
-- else
-- {
-- if (GetSettingBool("cec_power_on_startup"))
-- PowerOnCecDevices(CECDEVICE_TV);
-- m_cecAdapter->SetActiveView();
-- }
-- }
-+ // and open a new one
-+ m_bStop = false;
-+ Create();
- }
- }
-
- bool CPeripheralCecAdapter::InitialiseFeature(const PeripheralFeature feature)
- {
-- if (feature == FEATURE_CEC && !m_bStarted)
-+ if (feature == FEATURE_CEC && !m_bStarted && GetSettingBool("enabled"))
- {
-+ SetConfigurationFromSettings();
-+ m_callbacks.CBCecLogMessage = &CecLogMessage;
-+ m_callbacks.CBCecKeyPress = &CecKeyPress;
-+ m_callbacks.CBCecCommand = &CecCommand;
-+ m_callbacks.CBCecConfigurationChanged = &CecConfiguration;
-+ m_configuration.callbackParam = this;
-+ m_configuration.callbacks = &m_callbacks;
-+
-+ m_dll = new DllLibCEC;
-+ if (m_dll->Load() && m_dll->IsLoaded())
-+ m_cecAdapter = m_dll->CECInitialise(&m_configuration);
-+ else
-+ return false;
-+
-+ if (m_configuration.serverVersion < CEC_LIB_SUPPORTED_VERSION)
-+ {
-+ /* unsupported libcec version */
-+ CLog::Log(LOGERROR, g_localizeStrings.Get(36013).c_str(), CEC_LIB_SUPPORTED_VERSION, m_cecAdapter ? m_configuration.serverVersion : -1);
-+
-+ CStdString strMessage;
-+ strMessage.Format(g_localizeStrings.Get(36013).c_str(), CEC_LIB_SUPPORTED_VERSION, m_cecAdapter ? m_configuration.serverVersion : -1);
-+ CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(36000), strMessage);
-+ m_bError = true;
-+ if (m_cecAdapter)
-+ m_dll->CECDestroy(m_cecAdapter);
-+ m_cecAdapter = NULL;
-+
-+ m_features.clear();
-+ return false;
-+ }
-+ else
-+ {
-+ CLog::Log(LOGDEBUG, "%s - using libCEC v%s", __FUNCTION__, m_cecAdapter->ToString((cec_server_version)m_configuration.serverVersion));
-+ }
-+
- m_bStarted = true;
- Create();
- }
-@@ -221,23 +236,20 @@
- return strPort;
- }
-
--void CPeripheralCecAdapter::Process(void)
-+bool CPeripheralCecAdapter::OpenConnection(void)
- {
-+ bool bIsOpen(false);
-+
- if (!GetSettingBool("enabled"))
- {
- CLog::Log(LOGDEBUG, "%s - CEC adapter is disabled in peripheral settings", __FUNCTION__);
- m_bStarted = false;
-- return;
-+ return bIsOpen;
- }
-
- CStdString strPort = GetComPort();
- if (strPort.empty())
-- return;
--
-- // set correct physical address from peripheral settings
-- int iHdmiPort = GetSettingInt("cec_hdmi_port");
-- SetHdmiPort(iHdmiPort);
-- FlushLog();
-+ return bIsOpen;
-
- // open the CEC adapter
- CLog::Log(LOGDEBUG, "%s - opening a connection to the CEC adapter: %s", __FUNCTION__, strPort.c_str());
-@@ -247,100 +259,221 @@
- strMessage.Format(g_localizeStrings.Get(21336), g_localizeStrings.Get(36000));
- CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(36000), strMessage);
-
-- if (!m_cecAdapter->Open(strPort.c_str(), 10000))
-- {
-- FlushLog();
-- CLog::Log(LOGERROR, "%s - could not opening a connection to the CEC adapter", __FUNCTION__);
-- CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(36000), g_localizeStrings.Get(36012));
-- m_bStarted = false;
-- return;
-- }
-+ bool bConnectionFailedDisplayed(false);
-
-- CLog::Log(LOGDEBUG, "%s - connection to the CEC adapter opened", __FUNCTION__);
-- m_bIsReady = true;
-- CAnnouncementManager::AddAnnouncer(this);
--
-- if (GetSettingBool("cec_power_on_startup"))
-+ while (!m_bStop && !bIsOpen)
- {
-- PowerOnCecDevices(CECDEVICE_TV);
-- FlushLog();
-+ if ((bIsOpen = m_cecAdapter->Open(strPort.c_str(), 10000)) == false)
-+ {
-+ CLog::Log(LOGERROR, "%s - could not opening a connection to the CEC adapter", __FUNCTION__);
-+ if (!bConnectionFailedDisplayed)
-+ CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(36000), g_localizeStrings.Get(36012));
-+ bConnectionFailedDisplayed = true;
-+
-+ Sleep(10000);
-+ }
- }
-
-- if (GetSettingBool("use_tv_menu_language"))
-+ if (bIsOpen)
- {
-- cec_menu_language language;
-- if (m_cecAdapter->GetDeviceMenuLanguage(CECDEVICE_TV, &language))
-- SetMenuLanguage(language.language);
-+ CLog::Log(LOGDEBUG, "%s - connection to the CEC adapter opened", __FUNCTION__);
-+
-+ if (!m_configuration.wakeDevices.IsEmpty())
-+ m_cecAdapter->PowerOnDevices(CECDEVICE_BROADCAST);
-+
-+ if (m_configuration.bActivateSource == 1)
-+ m_cecAdapter->SetActiveSource();
- }
-
-- m_cecAdapter->SetOSDString(CECDEVICE_TV, CEC_DISPLAY_CONTROL_DISPLAY_FOR_DEFAULT_TIME, g_localizeStrings.Get(36016).c_str());
-- CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(36000), g_localizeStrings.Get(36016));
-+ return bIsOpen;
-+}
-+
-+void CPeripheralCecAdapter::Process(void)
-+{
-+ if (!OpenConnection())
-+ return;
-+
-+ CAnnouncementManager::AddAnnouncer(this);
-+
-+ m_queryThread = new CPeripheralCecAdapterUpdateThread(this, &m_configuration);
-+ m_queryThread->Create(false);
-
- while (!m_bStop)
- {
-- FlushLog();
- if (!m_bStop)
-- ProcessNextCommand();
-+ ProcessVolumeChange();
-+
- if (!m_bStop)
- Sleep(5);
- }
-
-+ delete m_queryThread;
-+
-+ if (m_iExitCode != EXITCODE_REBOOT)
-+ {
-+ if (m_cecAdapter->IsLibCECActiveSource())
-+ {
-+ if (!m_configuration.powerOffDevices.IsEmpty())
-+ {
-+ CLog::Log(LOGDEBUG, "%s - sending standby commands", __FUNCTION__);
-+ m_cecAdapter->StandbyDevices();
-+ }
-+ else if (m_configuration.bSendInactiveSource == 1)
-+ {
-+ CLog::Log(LOGDEBUG, "%s - sending inactive source commands", __FUNCTION__);
-+ m_cecAdapter->SetInactiveView();
-+ }
-+ }
-+ else
-+ {
-+ CLog::Log(LOGDEBUG, "%s - XBMC is not the active source, not sending any standby commands", __FUNCTION__);
-+ }
-+ }
-+
- m_cecAdapter->Close();
-
- CLog::Log(LOGDEBUG, "%s - CEC adapter processor thread ended", __FUNCTION__);
- m_bStarted = false;
- }
-
--bool CPeripheralCecAdapter::PowerOnCecDevices(cec_logical_address iLogicalAddress)
-+bool CPeripheralCecAdapter::HasConnectedAudioSystem(void)
- {
-- bool bReturn(false);
-+ CSingleLock lock(m_critSection);
-+ return m_bHasConnectedAudioSystem;
-+}
-
-- if (m_cecAdapter && m_bIsReady)
-+void CPeripheralCecAdapter::SetAudioSystemConnected(bool bSetTo)
-+{
-+ CSingleLock lock(m_critSection);
-+ m_bHasConnectedAudioSystem = bSetTo;
-+}
-+
-+void CPeripheralCecAdapter::ScheduleVolumeUp(void)
-+{
- {
-- CLog::Log(LOGDEBUG, "%s - powering on CEC capable device with address %1x", __FUNCTION__, iLogicalAddress);
-- bReturn = m_cecAdapter->PowerOnDevices(iLogicalAddress);
-+ CSingleLock lock(m_critSection);
-+ m_volumeChangeQueue.push(VOLUME_CHANGE_UP);
- }
-+ Sleep(5);
-+}
-
-- return bReturn;
-+void CPeripheralCecAdapter::ScheduleVolumeDown(void)
-+{
-+ {
-+ CSingleLock lock(m_critSection);
-+ m_volumeChangeQueue.push(VOLUME_CHANGE_DOWN);
-+ }
-+ Sleep(5);
- }
-
--bool CPeripheralCecAdapter::StandbyCecDevices(cec_logical_address iLogicalAddress)
-+void CPeripheralCecAdapter::ScheduleMute(void)
- {
-- bool bReturn(false);
-+ {
-+ CSingleLock lock(m_critSection);
-+ m_volumeChangeQueue.push(VOLUME_CHANGE_MUTE);
-+ }
-+ Sleep(5);
-+}
-
-- if (m_cecAdapter && m_bIsReady)
-+void CPeripheralCecAdapter::ProcessVolumeChange(void)
-+{
-+ bool bSendRelease(false);
-+ CecVolumeChange pendingVolumeChange = VOLUME_CHANGE_NONE;
- {
-- CLog::Log(LOGDEBUG, "%s - putting CEC capable devices with address %1x in standby mode", __FUNCTION__, iLogicalAddress);
-- bReturn = m_cecAdapter->StandbyDevices(iLogicalAddress);
-+ CSingleLock lock(m_critSection);
-+ if (m_volumeChangeQueue.size() > 0)
-+ {
-+ /* get the first change from the queue */
-+ pendingVolumeChange = m_volumeChangeQueue.front();
-+ m_volumeChangeQueue.pop();
-+
-+ /* remove all dupe entries */
-+ while (m_volumeChangeQueue.size() > 0 && m_volumeChangeQueue.front() == pendingVolumeChange)
-+ m_volumeChangeQueue.pop();
-+
-+ /* send another keypress after VOLUME_REFRESH_TIMEOUT ms */
-+ bool bRefresh(m_lastKeypress + VOLUME_REFRESH_TIMEOUT < XbmcThreads::SystemClockMillis());
-+
-+ /* only send the keypress when it hasn't been sent yet */
-+ if (pendingVolumeChange != m_lastChange)
-+ {
-+ m_lastKeypress = XbmcThreads::SystemClockMillis();
-+ m_lastChange = pendingVolumeChange;
-+ }
-+ else if (bRefresh)
-+ {
-+ m_lastKeypress = XbmcThreads::SystemClockMillis();
-+ pendingVolumeChange = m_lastChange;
-+ }
-+ else
-+ pendingVolumeChange = VOLUME_CHANGE_NONE;
-+ }
-+ else if (m_lastKeypress > 0 && m_lastKeypress + VOLUME_CHANGE_TIMEOUT < XbmcThreads::SystemClockMillis())
-+ {
-+ /* send a key release */
-+ m_lastKeypress = 0;
-+ bSendRelease = true;
-+ m_lastChange = VOLUME_CHANGE_NONE;
-+ }
- }
-
-- return bReturn;
-+ switch (pendingVolumeChange)
-+ {
-+ case VOLUME_CHANGE_UP:
-+ m_cecAdapter->SendKeypress(CECDEVICE_AUDIOSYSTEM, CEC_USER_CONTROL_CODE_VOLUME_UP, false);
-+ break;
-+ case VOLUME_CHANGE_DOWN:
-+ m_cecAdapter->SendKeypress(CECDEVICE_AUDIOSYSTEM, CEC_USER_CONTROL_CODE_VOLUME_DOWN, false);
-+ break;
-+ case VOLUME_CHANGE_MUTE:
-+ m_cecAdapter->SendKeypress(CECDEVICE_AUDIOSYSTEM, CEC_USER_CONTROL_CODE_MUTE, false);
-+ {
-+ CSingleLock lock(m_critSection);
-+ m_bIsMuted = !m_bIsMuted;
-+ }
-+ break;
-+ case VOLUME_CHANGE_NONE:
-+ if (bSendRelease)
-+ m_cecAdapter->SendKeyRelease(CECDEVICE_AUDIOSYSTEM, false);
-+ break;
-+ }
- }
-
--bool CPeripheralCecAdapter::SendPing(void)
-+void CPeripheralCecAdapter::VolumeUp(void)
- {
-- bool bReturn(false);
-- if (m_cecAdapter && m_bIsReady)
-+ if (HasConnectedAudioSystem())
- {
-- CLog::Log(LOGDEBUG, "%s - sending ping to the CEC adapter", __FUNCTION__);
-- bReturn = m_cecAdapter->PingAdapter();
-+ CSingleLock lock(m_critSection);
-+ m_volumeChangeQueue.push(VOLUME_CHANGE_UP);
- }
-+}
-
-- return bReturn;
-+void CPeripheralCecAdapter::VolumeDown(void)
-+{
-+ if (HasConnectedAudioSystem())
-+ {
-+ CSingleLock lock(m_critSection);
-+ m_volumeChangeQueue.push(VOLUME_CHANGE_DOWN);
-+ }
- }
-
--bool CPeripheralCecAdapter::SetHdmiPort(int iHdmiPort)
-+void CPeripheralCecAdapter::Mute(void)
- {
-- bool bReturn(false);
-- if (m_cecAdapter && m_bIsReady)
-+ if (HasConnectedAudioSystem())
- {
-- if (iHdmiPort <= 0 || iHdmiPort > 16)
-- iHdmiPort = 1;
-- CLog::Log(LOGDEBUG, "%s - changing active HDMI port to %d", __FUNCTION__, iHdmiPort);
-- bReturn = m_cecAdapter->SetPhysicalAddress(iHdmiPort << 12);
-+ CSingleLock lock(m_critSection);
-+ m_volumeChangeQueue.push(VOLUME_CHANGE_MUTE);
- }
-+}
-
-- return bReturn;
-+bool CPeripheralCecAdapter::IsMuted(void)
-+{
-+ if (HasConnectedAudioSystem())
-+ {
-+ CSingleLock lock(m_critSection);
-+ return m_bIsMuted;
-+ }
-+ return false;
- }
-
- void CPeripheralCecAdapter::SetMenuLanguage(const char *strLanguage)
-@@ -404,10 +537,13 @@
- CLog::Log(LOGWARNING, "%s - TV menu language set to unknown value '%s'", __FUNCTION__, strLanguage);
- }
-
--void CPeripheralCecAdapter::ProcessNextCommand(void)
-+int CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command &command)
- {
-- cec_command command;
-- if (m_cecAdapter && m_bIsReady && m_cecAdapter->GetNextCommand(&command))
-+ CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
-+ if (!adapter)
-+ return 0;
-+
-+ if (adapter->m_bIsReady)
- {
- CLog::Log(LOGDEBUG, "%s - processing command: initiator=%1x destination=%1x opcode=%02x", __FUNCTION__, command.initiator, command.destination, command.opcode);
-
-@@ -416,21 +552,21 @@
- case CEC_OPCODE_STANDBY:
- /* a device was put in standby mode */
- CLog::Log(LOGDEBUG, "%s - device %1x was put in standby mode", __FUNCTION__, command.initiator);
-- if (command.initiator == CECDEVICE_TV && GetSettingBool("standby_pc_on_tv_standby") &&
-- (!m_screensaverLastActivated.IsValid() || CDateTime::GetCurrentDateTime() - m_screensaverLastActivated > CDateTimeSpan(0, 0, 0, SCREENSAVER_TIMEOUT)))
-+ if (command.initiator == CECDEVICE_TV && adapter->m_configuration.bPowerOffOnStandby == 1 &&
-+ (!adapter->m_screensaverLastActivated.IsValid() || CDateTime::GetCurrentDateTime() - adapter->m_screensaverLastActivated > CDateTimeSpan(0, 0, 0, SCREENSAVER_TIMEOUT)))
- {
-- m_bStarted = false;
-+ adapter->m_bStarted = false;
- g_application.getApplicationMessenger().Suspend();
- }
- break;
- case CEC_OPCODE_SET_MENU_LANGUAGE:
-- if (GetSettingBool("use_tv_menu_language") && command.initiator == CECDEVICE_TV && command.parameters.size == 3)
-+ if (adapter->m_configuration.bUseTVMenuLanguage == 1 && command.initiator == CECDEVICE_TV && command.parameters.size == 3)
- {
- char strNewLanguage[4];
- for (int iPtr = 0; iPtr < 3; iPtr++)
- strNewLanguage[iPtr] = command.parameters[iPtr];
- strNewLanguage[3] = 0;
-- SetMenuLanguage(strNewLanguage);
-+ adapter->SetMenuLanguage(strNewLanguage);
- }
- break;
- case CEC_OPCODE_DECK_CONTROL:
-@@ -438,11 +574,11 @@
- command.parameters.size == 1 &&
- command.parameters[0] == CEC_DECK_CONTROL_MODE_STOP)
- {
-- CSingleLock lock(m_critSection);
-+ CSingleLock lock(adapter->m_critSection);
- cec_keypress key;
- key.duration = 500;
- key.keycode = CEC_USER_CONTROL_CODE_STOP;
-- m_buttonQueue.push(key);
-+ adapter->m_buttonQueue.push(key);
- }
- break;
- case CEC_OPCODE_PLAY:
-@@ -451,26 +587,58 @@
- {
- if (command.parameters[0] == CEC_PLAY_MODE_PLAY_FORWARD)
- {
-- CSingleLock lock(m_critSection);
-+ CSingleLock lock(adapter->m_critSection);
- cec_keypress key;
- key.duration = 500;
- key.keycode = CEC_USER_CONTROL_CODE_PLAY;
-- m_buttonQueue.push(key);
-+ adapter->m_buttonQueue.push(key);
- }
- else if (command.parameters[0] == CEC_PLAY_MODE_PLAY_STILL)
- {
-- CSingleLock lock(m_critSection);
-+ CSingleLock lock(adapter->m_critSection);
- cec_keypress key;
- key.duration = 500;
- key.keycode = CEC_USER_CONTROL_CODE_PAUSE;
-- m_buttonQueue.push(key);
-+ adapter->m_buttonQueue.push(key);
- }
- }
- break;
-+ case CEC_OPCODE_REPORT_POWER_STATUS:
-+ if (command.initiator == CECDEVICE_TV &&
-+ command.parameters.size == 1 &&
-+ command.parameters[0] == CEC_POWER_STATUS_ON &&
-+ adapter->m_queryThread)
-+ {
-+ adapter->m_queryThread->Signal();
-+ }
-+ break;
- default:
- break;
- }
- }
-+ return 1;
-+}
-+
-+int CPeripheralCecAdapter::CecConfiguration(void *cbParam, const libcec_configuration &config)
-+{
-+ CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
-+ if (!adapter)
-+ return 0;
-+
-+ CSingleLock lock(adapter->m_critSection);
-+ adapter->SetConfigurationFromLibCEC(config);
-+ return 1;
-+}
-+
-+int CPeripheralCecAdapter::CecKeyPress(void *cbParam, const cec_keypress &key)
-+{
-+ CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
-+ if (!adapter)
-+ return 0;
-+
-+ CSingleLock lock(adapter->m_critSection);
-+ adapter->m_buttonQueue.push(key);
-+ return 1;
- }
-
- bool CPeripheralCecAdapter::GetNextCecKey(cec_keypress &key)
-@@ -483,10 +651,6 @@
- m_buttonQueue.pop();
- bReturn = true;
- }
-- else if (m_cecAdapter->GetNextKeypress(&key))
-- {
-- bReturn = true;
-- }
-
- return bReturn;
- }
-@@ -726,41 +890,43 @@
- else if (bEnabled && !m_cecAdapter && m_bStarted)
- InitialiseFeature(FEATURE_CEC);
- }
-- else if (strChangedSetting.Equals("cec_hdmi_port"))
-+ else
- {
-- SetHdmiPort(GetSettingInt("cec_hdmi_port"));
-+ SetConfigurationFromSettings();
-+ m_queryThread->UpdateConfiguration(&m_configuration);
- }
- }
-
--void CPeripheralCecAdapter::FlushLog(void)
-+int CPeripheralCecAdapter::CecLogMessage(void *cbParam, const cec_log_message &message)
- {
-- cec_log_message message;
-- while (m_cecAdapter && m_cecAdapter->GetNextLogMessage(&message))
-- {
-- int iLevel = -1;
-- switch (message.level)
-- {
-- case CEC_LOG_ERROR:
-- iLevel = LOGERROR;
-- break;
-- case CEC_LOG_WARNING:
-- iLevel = LOGWARNING;
-- break;
-- case CEC_LOG_NOTICE:
-- iLevel = LOGDEBUG;
-- break;
-- case CEC_LOG_TRAFFIC:
-- case CEC_LOG_DEBUG:
-- if (GetSettingBool("cec_debug_logging"))
-- iLevel = LOGDEBUG;
-- break;
-- default:
-- break;
-- }
-+ CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
-+ if (!adapter)
-+ return 0;
-
-- if (iLevel >= 0)
-- CLog::Log(iLevel, "%s - %s", __FUNCTION__, message.message);
-+ int iLevel = -1;
-+ switch (message.level)
-+ {
-+ case CEC_LOG_ERROR:
-+ iLevel = LOGERROR;
-+ break;
-+ case CEC_LOG_WARNING:
-+ iLevel = LOGWARNING;
-+ break;
-+ case CEC_LOG_NOTICE:
-+ iLevel = LOGDEBUG;
-+ break;
-+ case CEC_LOG_TRAFFIC:
-+ case CEC_LOG_DEBUG:
-+ iLevel = LOGDEBUG;
-+ break;
-+ default:
-+ break;
- }
-+
-+ if (iLevel >= 0)
-+ CLog::Log(iLevel, "%s - %s", __FUNCTION__, message.message);
-+
-+ return 1;
- }
-
- bool CPeripheralCecAdapter::TranslateComPort(CStdString &strLocation)
-@@ -774,4 +940,301 @@
-
- return false;
- }
-+
-+void CPeripheralCecAdapter::SetConfigurationFromLibCEC(const CEC::libcec_configuration &config)
-+{
-+ // set the primary device type
-+ m_configuration.deviceTypes.Clear();
-+ m_configuration.deviceTypes.Add(config.deviceTypes[0]);
-+ SetSetting("device_type", (int)config.deviceTypes[0]);
-+
-+ // set the connected device
-+ m_configuration.baseDevice = config.baseDevice;
-+ SetSetting("connected_device", (int)config.baseDevice);
-+
-+ // set the HDMI port number
-+ m_configuration.iHDMIPort = config.iHDMIPort;
-+ SetSetting("cec_hdmi_port", config.iHDMIPort);
-+
-+ // set the physical address, when baseDevice or iHDMIPort are not set
-+ if (m_configuration.baseDevice == CECDEVICE_UNKNOWN ||
-+ m_configuration.iHDMIPort == 0 || m_configuration.iHDMIPort > 4)
-+ {
-+ m_configuration.iPhysicalAddress = config.iPhysicalAddress;
-+ CStdString strPhysicalAddress;
-+ strPhysicalAddress.Format("%x", config.iPhysicalAddress);
-+ SetSetting("physical_address", strPhysicalAddress);
-+ }
-+
-+ // set the tv vendor override
-+ m_configuration.tvVendor = config.tvVendor;
-+ SetSetting("tv_vendor", (int)config.tvVendor);
-+
-+ // set the devices to wake when starting
-+ m_configuration.wakeDevices = config.wakeDevices;
-+ CStdString strWakeDevices;
-+ for (unsigned int iPtr = 0; iPtr <= 16; iPtr++)
-+ if (config.wakeDevices[iPtr])
-+ strWakeDevices.AppendFormat(" %X", iPtr);
-+ SetSetting("wake_devices", strWakeDevices.Trim());
-+
-+ // set the devices to power off when stopping
-+ m_configuration.powerOffDevices = config.powerOffDevices;
-+ CStdString strPowerOffDevices;
-+ for (unsigned int iPtr = 0; iPtr <= 16; iPtr++)
-+ if (config.powerOffDevices[iPtr])
-+ strPowerOffDevices.AppendFormat(" %X", iPtr);
-+ SetSetting("wake_devices", strPowerOffDevices.Trim());
-+
-+ // set the boolean settings
-+ m_configuration.bUseTVMenuLanguage = config.bUseTVMenuLanguage;
-+ SetSetting("use_tv_menu_language", m_configuration.bUseTVMenuLanguage == 1);
-+
-+ m_configuration.bActivateSource = config.bActivateSource;
-+ SetSetting("activate_source", m_configuration.bActivateSource == 1);
-+
-+ m_configuration.bPowerOffScreensaver = config.bPowerOffScreensaver;
-+ SetSetting("cec_standby_screensaver", m_configuration.bPowerOffScreensaver == 1);
-+
-+ m_configuration.bPowerOffOnStandby = config.bPowerOffOnStandby;
-+ SetSetting("standby_pc_on_tv_standby", m_configuration.bPowerOffOnStandby == 1);
-+
-+ if (config.serverVersion >= CEC_SERVER_VERSION_1_5_1)
-+ m_configuration.bSendInactiveSource = config.bSendInactiveSource;
-+ SetSetting("send_inactive_source", m_configuration.bSendInactiveSource == 1);
-+}
-+
-+void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
-+{
-+ // client version 1.5.0
-+ m_configuration.clientVersion = CEC_CLIENT_VERSION_1_5_1;
-+
-+ // device name 'XBMC'
-+ snprintf(m_configuration.strDeviceName, 13, "%s", GetSettingString("device_name").c_str());
-+
-+ // set the primary device type
-+ m_configuration.deviceTypes.Clear();
-+ int iDeviceType = GetSettingInt("device_type");
-+ if (iDeviceType != (int)CEC_DEVICE_TYPE_RECORDING_DEVICE &&
-+ iDeviceType != (int)CEC_DEVICE_TYPE_PLAYBACK_DEVICE &&
-+ iDeviceType != (int)CEC_DEVICE_TYPE_TUNER)
-+ iDeviceType = (int)CEC_DEVICE_TYPE_RECORDING_DEVICE;
-+ m_configuration.deviceTypes.Add((cec_device_type)iDeviceType);
-+
-+ // always try to autodetect the address.
-+ // when the firmware supports this, it will override the physical address, connected device and hdmi port settings
-+ m_configuration.bAutodetectAddress = 1;
-+
-+ // set the physical address
-+ // when set, it will override the connected device and hdmi port settings
-+ CStdString strPhysicalAddress = GetSettingString("physical_address");
-+ int iPhysicalAddress;
-+ if (sscanf(strPhysicalAddress.c_str(), "%x", &iPhysicalAddress) == 1 && iPhysicalAddress > 0 && iPhysicalAddress < 0xFFFF)
-+ m_configuration.iPhysicalAddress = iPhysicalAddress;
-+
-+ // set the connected device
-+ int iConnectedDevice = GetSettingInt("connected_device");
-+ if (iConnectedDevice == 0 || iConnectedDevice == 5)
-+ m_configuration.baseDevice = (cec_logical_address)iConnectedDevice;
-+
-+ // set the HDMI port number
-+ int iHDMIPort = GetSettingInt("cec_hdmi_port");
-+ if (iHDMIPort >= 0 && iHDMIPort <= 4)
-+ m_configuration.iHDMIPort = iHDMIPort;
-+
-+ // set the tv vendor override
-+ int iVendor = GetSettingInt("tv_vendor");
-+ if (iVendor > 0 && iVendor < 0xFFFFFF)
-+ m_configuration.tvVendor = iVendor;
-+
-+ // read the devices to wake when starting
-+ CStdString strWakeDevices = CStdString(GetSettingString("wake_devices")).Trim();
-+ m_configuration.wakeDevices.Clear();
-+ ReadLogicalAddresses(strWakeDevices, m_configuration.wakeDevices);
-+
-+ // read the devices to power off when stopping
-+ CStdString strStandbyDevices = CStdString(GetSettingString("standby_devices")).Trim();
-+ m_configuration.powerOffDevices.Clear();
-+ ReadLogicalAddresses(strStandbyDevices, m_configuration.powerOffDevices);
-+
-+ // always get the settings from the rom, when supported by the firmware
-+ m_configuration.bGetSettingsFromROM = 1;
-+
-+ // read the boolean settings
-+ m_configuration.bUseTVMenuLanguage = GetSettingBool("use_tv_menu_language") ? 1 : 0;
-+ m_configuration.bActivateSource = GetSettingBool("activate_source") ? 1 : 0;
-+ m_configuration.bPowerOffScreensaver = GetSettingBool("cec_standby_screensaver") ? 1 : 0;
-+ m_configuration.bPowerOffOnStandby = GetSettingBool("standby_pc_on_tv_standby") ? 1 : 0;
-+ m_configuration.bSendInactiveSource = GetSettingBool("send_inactive_source") ? 1 : 0;
-+}
-+
-+void CPeripheralCecAdapter::ReadLogicalAddresses(const CStdString &strString, cec_logical_addresses &addresses)
-+{
-+ for (size_t iPtr = 0; iPtr < strString.size(); iPtr++)
-+ {
-+ CStdString strDevice = CStdString(strString.substr(iPtr, 1)).Trim();
-+ if (!strDevice.IsEmpty())
-+ {
-+ int iDevice(0);
-+ if (sscanf(strDevice.c_str(), "%x", &iDevice) == 1 && iDevice >= 0 && iDevice <= 0xF)
-+ addresses.Set((cec_logical_address)iDevice);
-+ }
-+ }
-+}
-+
-+CPeripheralCecAdapterUpdateThread::CPeripheralCecAdapterUpdateThread(CPeripheralCecAdapter *adapter, libcec_configuration *configuration) :
-+ CThread("CEC Adapter Update Thread"),
-+ m_adapter(adapter),
-+ m_configuration(*configuration),
-+ m_bNextConfigurationScheduled(false),
-+ m_bIsUpdating(true)
-+{
-+ m_nextConfiguration.Clear();
-+ m_event.Reset();
-+}
-+
-+CPeripheralCecAdapterUpdateThread::~CPeripheralCecAdapterUpdateThread(void)
-+{
-+ StopThread(false);
-+ m_event.Set();
-+ StopThread(true);
-+}
-+
-+void CPeripheralCecAdapterUpdateThread::Signal(void)
-+{
-+ m_event.Set();
-+}
-+
-+bool CPeripheralCecAdapterUpdateThread::UpdateConfiguration(libcec_configuration *configuration)
-+{
-+ CSingleLock lock(m_critSection);
-+ if (m_bIsUpdating)
-+ {
-+ m_bNextConfigurationScheduled = true;
-+ m_nextConfiguration = *configuration;
-+ }
-+ else
-+ {
-+ m_configuration = *configuration;
-+ m_event.Set();
-+ }
-+ return true;
-+}
-+
-+bool CPeripheralCecAdapterUpdateThread::WaitReady(void)
-+{
-+ // don't wait if we're not powering up anything
-+ if (m_configuration.wakeDevices.IsEmpty() && m_configuration.bActivateSource == 0)
-+ return true;
-+
-+ // wait for the TV if we're configured to become the active source.
-+ // wait for the first device in the wake list otherwise.
-+ cec_logical_address waitFor = (m_configuration.bActivateSource == 1) ?
-+ CECDEVICE_TV :
-+ m_configuration.wakeDevices.primary;
-+
-+ cec_power_status powerStatus(CEC_POWER_STATUS_UNKNOWN);
-+ bool bContinue(true);
-+ while (bContinue && !m_adapter->m_bStop && !m_bStop && powerStatus != CEC_POWER_STATUS_ON)
-+ {
-+ powerStatus = m_adapter->m_cecAdapter->GetDevicePowerStatus(waitFor);
-+ if (powerStatus != CEC_POWER_STATUS_ON)
-+ bContinue = !m_event.WaitMSec(1000);
-+ }
-+
-+ return powerStatus == CEC_POWER_STATUS_ON;
-+}
-+
-+bool CPeripheralCecAdapterUpdateThread::SetInitialConfiguration(void)
-+{
-+ // devices to wake are set
-+ if (!m_configuration.wakeDevices.IsEmpty())
-+ m_adapter->m_cecAdapter->PowerOnDevices(CECDEVICE_BROADCAST);
-+
-+ // the option to make XBMC the active source is set
-+ if (m_configuration.bActivateSource == 1)
-+ m_adapter->m_cecAdapter->SetActiveSource();
-+
-+ // wait until devices are powered up
-+ if (!WaitReady())
-+ return false;
-+
-+ // request the menu language of the TV
-+ if (m_configuration.bUseTVMenuLanguage == 1)
-+ {
-+ cec_menu_language language;
-+ if (m_adapter->m_cecAdapter->GetDeviceMenuLanguage(CECDEVICE_TV, &language))
-+ m_adapter->SetMenuLanguage(language.language);
-+ }
-+
-+ // request the OSD name of the TV
-+ CStdString strNotification;
-+ cec_osd_name tvName = m_adapter->m_cecAdapter->GetDeviceOSDName(CECDEVICE_TV);
-+ strNotification.Format("%s: %s", g_localizeStrings.Get(36016), tvName.name);
-+
-+ /* disable the mute setting when an amp is found, because the amp handles the mute setting and
-+ set PCM output to 100% */
-+ if (m_adapter->m_cecAdapter->IsActiveDeviceType(CEC_DEVICE_TYPE_AUDIO_SYSTEM))
-+ {
-+ // request the OSD name of the amp
-+ cec_osd_name ampName = m_adapter->m_cecAdapter->GetDeviceOSDName(CECDEVICE_AUDIOSYSTEM);
-+ CLog::Log(LOGDEBUG, "%s - CEC capable amplifier found (%s). volume will be controlled on the amp", __FUNCTION__, ampName.name);
-+ strNotification.AppendFormat(" - %s", ampName.name);
-+
-+ // set amp present
-+ m_adapter->SetAudioSystemConnected(true);
-+ g_settings.m_bMute = false;
-+ g_settings.m_nVolumeLevel = VOLUME_MAXIMUM;
-+ }
-+
-+ m_adapter->m_bIsReady = true;
-+
-+ // try to send an OSD string to the TV
-+ m_adapter->m_cecAdapter->SetOSDString(CECDEVICE_TV, CEC_DISPLAY_CONTROL_DISPLAY_FOR_DEFAULT_TIME, g_localizeStrings.Get(36016).c_str());
-+ // and let the gui know that we're done
-+ CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(36000), strNotification);
-+
-+ CSingleLock lock(m_critSection);
-+ m_bIsUpdating = false;
-+ return true;
-+}
-+
-+void CPeripheralCecAdapterUpdateThread::Process(void)
-+{
-+ // set the initial configuration
-+ if (!SetInitialConfiguration())
-+ return;
-+
-+ // and wait for updates
-+ bool bUpdate(false);
-+ while (!m_bStop)
-+ {
-+ // update received
-+ if (m_event.WaitMSec(500) || bUpdate)
-+ {
-+ if (m_bStop)
-+ return;
-+ // set the new configuration
-+ bool bConfigSet(m_adapter->m_cecAdapter->SetConfiguration(&m_configuration));
-+ CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(36000), g_localizeStrings.Get(bConfigSet ? 36023 : 36024));
-+ {
-+ CSingleLock lock(m_critSection);
-+ bUpdate = m_bNextConfigurationScheduled;
-+ if (bUpdate)
-+ {
-+ // another update is scheduled
-+ m_bNextConfigurationScheduled = false;
-+ m_configuration = m_nextConfiguration;
-+ }
-+ else
-+ {
-+ // nothing left to do, wait for updates
-+ m_bIsUpdating = false;
-+ m_event.Reset();
-+ }
-+ }
-+ }
-+ }
-+}
-+
- #endif
-diff -Naur xbmc-11.0.1/xbmc/peripherals/devices/PeripheralCecAdapter.h xbmc-11.0.1.patch/xbmc/peripherals/devices/PeripheralCecAdapter.h
---- xbmc-11.0.1/xbmc/peripherals/devices/PeripheralCecAdapter.h 2012-03-21 23:57:32.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/peripherals/devices/PeripheralCecAdapter.h 2012-04-17 14:47:59.563514930 +0200
-@@ -20,7 +20,28 @@
- *
- */
-
--#if defined(HAVE_LIBCEC)
-+#if !defined(HAVE_LIBCEC)
-+#include "Peripheral.h"
-+
-+// an empty implementation, so CPeripherals can be compiled without a bunch of #ifdef's when libCEC is not available
-+namespace PERIPHERALS
-+{
-+ class CPeripheralCecAdapter : public CPeripheral
-+ {
-+ public:
-+ bool HasConnectedAudioSystem(void) { return false; }
-+ void ScheduleVolumeUp(void) {}
-+ void ScheduleVolumeDown(void) {}
-+ bool IsMuted(void) { return false; }
-+ void ScheduleMute(void) {}
-+
-+ WORD GetButton(void) { return 0; }
-+ unsigned int GetHoldTime(void) { return 0; }
-+ void ResetButton(void) {}
-+ };
-+}
-+
-+#else
-
- #include "PeripheralHID.h"
- #include "interfaces/AnnouncementManager.h"
-@@ -32,7 +53,7 @@
- #ifdef isset
- #undef isset
- #endif
--#include
-+#include
-
- class DllLibCEC;
-
-@@ -43,25 +64,40 @@
-
- namespace PERIPHERALS
- {
-+ class CPeripheralCecAdapterUpdateThread;
-+
- typedef struct
- {
- WORD iButton;
- unsigned int iDuration;
- } CecButtonPress;
-
-+ typedef enum
-+ {
-+ VOLUME_CHANGE_NONE,
-+ VOLUME_CHANGE_UP,
-+ VOLUME_CHANGE_DOWN,
-+ VOLUME_CHANGE_MUTE
-+ } CecVolumeChange;
-
- class CPeripheralCecAdapter : public CPeripheralHID, public ANNOUNCEMENT::IAnnouncer, private CThread
- {
-+ friend class CPeripheralCecAdapterUpdateThread;
-+
- public:
- CPeripheralCecAdapter(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId);
- virtual ~CPeripheralCecAdapter(void);
-
- virtual void Announce(ANNOUNCEMENT::EAnnouncementFlag flag, const char *sender, const char *message, const CVariant &data);
-- virtual bool PowerOnCecDevices(CEC::cec_logical_address iLogicalAddress);
-- virtual bool StandbyCecDevices(CEC::cec_logical_address iLogicalAddress);
--
-- virtual bool SendPing(void);
-- virtual bool SetHdmiPort(int iHdmiPort);
-+ virtual bool HasConnectedAudioSystem(void);
-+ virtual void SetAudioSystemConnected(bool bSetTo);
-+ virtual void ScheduleVolumeUp(void);
-+ virtual void VolumeUp(void);
-+ virtual void ScheduleVolumeDown(void);
-+ virtual void VolumeDown(void);
-+ virtual void ScheduleMute(void);
-+ virtual void Mute(void);
-+ virtual bool IsMuted(void);
-
- virtual void OnSettingChanged(const CStdString &strChangedSetting);
-
-@@ -71,27 +107,66 @@
- virtual CStdString GetComPort(void);
-
- protected:
-- virtual void FlushLog(void);
-- virtual bool GetNextCecKey(CEC::cec_keypress &key);
-+ virtual bool OpenConnection(void);
-+ virtual void SetConfigurationFromSettings(void);
-+ virtual void SetConfigurationFromLibCEC(const CEC::libcec_configuration &config);
-+ static void ReadLogicalAddresses(const CStdString &strString, CEC::cec_logical_addresses &addresses);
-+ static int CecKeyPress(void *cbParam, const CEC::cec_keypress &key);
-+ static int CecLogMessage(void *cbParam, const CEC::cec_log_message &message);
-+ static int CecCommand(void *cbParam, const CEC::cec_command &command);
-+ static int CecConfiguration(void *cbParam, const CEC::libcec_configuration &config);
-+
- virtual bool GetNextKey(void);
-+ virtual bool GetNextCecKey(CEC::cec_keypress &key);
- virtual bool InitialiseFeature(const PeripheralFeature feature);
- virtual void Process(void);
-- virtual void ProcessNextCommand(void);
-+ virtual void ProcessVolumeChange(void);
- virtual void SetMenuLanguage(const char *strLanguage);
- static bool FindConfigLocation(CStdString &strString);
- static bool TranslateComPort(CStdString &strPort);
-
-- DllLibCEC* m_dll;
-- CEC::ICECAdapter* m_cecAdapter;
-- bool m_bStarted;
-- bool m_bHasButton;
-- bool m_bIsReady;
-- CStdString m_strMenuLanguage;
-- CDateTime m_screensaverLastActivated;
-- CecButtonPress m_button;
-- std::queue m_buttonQueue;
-- unsigned int m_lastKeypress;
-- CCriticalSection m_critSection;
-+ DllLibCEC* m_dll;
-+ CEC::ICECAdapter* m_cecAdapter;
-+ bool m_bStarted;
-+ bool m_bHasButton;
-+ bool m_bIsReady;
-+ bool m_bHasConnectedAudioSystem;
-+ CStdString m_strMenuLanguage;
-+ CDateTime m_screensaverLastActivated;
-+ CecButtonPress m_button;
-+ std::queue m_buttonQueue;
-+ std::queue m_volumeChangeQueue;
-+ unsigned int m_lastKeypress;
-+ CecVolumeChange m_lastChange;
-+ int m_iExitCode;
-+ bool m_bIsMuted;
-+ CPeripheralCecAdapterUpdateThread*m_queryThread;
-+ CEC::ICECCallbacks m_callbacks;
-+ CCriticalSection m_critSection;
-+ CEC::libcec_configuration m_configuration;
-+ };
-+
-+ class CPeripheralCecAdapterUpdateThread : public CThread
-+ {
-+ public:
-+ CPeripheralCecAdapterUpdateThread(CPeripheralCecAdapter *adapter, CEC::libcec_configuration *configuration);
-+ virtual ~CPeripheralCecAdapterUpdateThread(void);
-+
-+ virtual void Signal(void);
-+ virtual bool UpdateConfiguration(CEC::libcec_configuration *configuration);
-+
-+ protected:
-+ virtual bool WaitReady(void);
-+ virtual bool SetInitialConfiguration(void);
-+ virtual void Process(void);
-+
-+ CPeripheralCecAdapter * m_adapter;
-+ CEvent m_event;
-+ CCriticalSection m_critSection;
-+ CEC::libcec_configuration m_configuration;
-+ CEC::libcec_configuration m_nextConfiguration;
-+ bool m_bNextConfigurationScheduled;
-+ bool m_bIsUpdating;
- };
- }
-
-diff -Naur xbmc-11.0.1/xbmc/peripherals/devices/Peripheral.cpp xbmc-11.0.1.patch/xbmc/peripherals/devices/Peripheral.cpp
---- xbmc-11.0.1/xbmc/peripherals/devices/Peripheral.cpp 2012-03-21 23:57:32.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/peripherals/devices/Peripheral.cpp 2012-04-17 14:47:59.570515061 +0200
-@@ -30,6 +30,14 @@
- using namespace PERIPHERALS;
- using namespace std;
-
-+struct SortBySettingsOrder
-+{
-+ bool operator()(const CSetting *left, const CSetting *right)
-+ {
-+ return left->GetOrder() < right->GetOrder();
-+ }
-+};
-+
- CPeripheral::CPeripheral(const PeripheralType type, const PeripheralBusType busType, const CStdString &strLocation, const CStdString &strDeviceName, int iVendorId, int iProductId) :
- m_type(type),
- m_busType(busType),
-@@ -168,6 +176,15 @@
- return m_subDevices.size() > 0;
- }
-
-+vector CPeripheral::GetSettings(void) const
-+{
-+ vector settings;
-+ for (map::const_iterator it = m_settings.begin(); it != m_settings.end(); it++)
-+ settings.push_back(it->second);
-+ sort(settings.begin(), settings.end(), SortBySettingsOrder());
-+ return settings;
-+}
-+
- void CPeripheral::AddSetting(const CStdString &strKey, const CSetting *setting)
- {
- if (!setting)
-@@ -183,7 +200,7 @@
- case SETTINGS_TYPE_BOOL:
- {
- const CSettingBool *mappedSetting = (const CSettingBool *) setting;
-- CSettingBool *boolSetting = new CSettingBool(0, strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->GetControlType());
-+ CSettingBool *boolSetting = new CSettingBool(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->GetControlType());
- if (boolSetting)
- {
- boolSetting->SetVisible(mappedSetting->IsVisible());
-@@ -194,7 +211,7 @@
- case SETTINGS_TYPE_INT:
- {
- const CSettingInt *mappedSetting = (const CSettingInt *) setting;
-- CSettingInt *intSetting = new CSettingInt(0, strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->m_iMin, mappedSetting->m_iStep, mappedSetting->m_iMax, mappedSetting->GetControlType(), mappedSetting->m_strFormat);
-+ CSettingInt *intSetting = new CSettingInt(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->m_iMin, mappedSetting->m_iStep, mappedSetting->m_iMax, mappedSetting->GetControlType(), mappedSetting->m_strFormat);
- if (intSetting)
- {
- intSetting->SetVisible(mappedSetting->IsVisible());
-@@ -205,7 +222,7 @@
- case SETTINGS_TYPE_FLOAT:
- {
- const CSettingFloat *mappedSetting = (const CSettingFloat *) setting;
-- CSettingFloat *floatSetting = new CSettingFloat(0, strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->m_fMin, mappedSetting->m_fStep, mappedSetting->m_fMax, mappedSetting->GetControlType());
-+ CSettingFloat *floatSetting = new CSettingFloat(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->m_fMin, mappedSetting->m_fStep, mappedSetting->m_fMax, mappedSetting->GetControlType());
- if (floatSetting)
- {
- floatSetting->SetVisible(mappedSetting->IsVisible());
-@@ -216,7 +233,7 @@
- case SETTINGS_TYPE_STRING:
- {
- const CSettingString *mappedSetting = (const CSettingString *) setting;
-- CSettingString *stringSetting = new CSettingString(0, strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData().c_str(), mappedSetting->GetControlType(), mappedSetting->m_bAllowEmpty, mappedSetting->m_iHeadingString);
-+ CSettingString *stringSetting = new CSettingString(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData().c_str(), mappedSetting->GetControlType(), mappedSetting->m_bAllowEmpty, mappedSetting->m_iHeadingString);
- if (stringSetting)
- {
- stringSetting->SetVisible(mappedSetting->IsVisible());
-@@ -323,7 +340,7 @@
- bool bChanged(boolSetting->GetData() != bValue);
- boolSetting->SetData(bValue);
- if (bChanged && m_bInitialised)
-- m_changedSettings.push_back(strKey);
-+ m_changedSettings.insert(strKey);
- }
- }
- }
-@@ -339,7 +356,7 @@
- bool bChanged(intSetting->GetData() != iValue);
- intSetting->SetData(iValue);
- if (bChanged && m_bInitialised)
-- m_changedSettings.push_back(strKey);
-+ m_changedSettings.insert(strKey);
- }
- }
- }
-@@ -355,11 +372,26 @@
- bool bChanged(floatSetting->GetData() != fValue);
- floatSetting->SetData(fValue);
- if (bChanged && m_bInitialised)
-- m_changedSettings.push_back(strKey);
-+ m_changedSettings.insert(strKey);
- }
- }
- }
-
-+void CPeripheral::SetSettingVisible(const CStdString &strKey, bool bSetTo)
-+{
-+ map::iterator it = m_settings.find(strKey);
-+ if (it != m_settings.end())
-+ (*it).second->SetVisible(bSetTo);
-+}
-+
-+bool CPeripheral::IsSettingVisible(const CStdString &strKey) const
-+{
-+ map::const_iterator it = m_settings.find(strKey);
-+ if (it != m_settings.end())
-+ return (*it).second->IsVisible();
-+ return false;
-+}
-+
- void CPeripheral::SetSetting(const CStdString &strKey, const CStdString &strValue)
- {
- map::iterator it = m_settings.find(strKey);
-@@ -373,7 +405,7 @@
- bool bChanged(!stringSetting->GetData().Equals(strValue));
- stringSetting->SetData(strValue);
- if (bChanged && m_bInitialised)
-- m_changedSettings.push_back(strKey);
-+ m_changedSettings.insert(strKey);
- }
- }
- else if ((*it).second->GetType() == SETTINGS_TYPE_INT)
-@@ -436,7 +468,7 @@
-
- if (!bExiting)
- {
-- for (vector::iterator it = m_changedSettings.begin(); it != m_changedSettings.end(); it++)
-+ for (set::const_iterator it = m_changedSettings.begin(); it != m_changedSettings.end(); it++)
- OnSettingChanged(*it);
- }
- m_changedSettings.clear();
-@@ -467,7 +499,7 @@
- map::iterator it = m_settings.begin();
- while (it != m_settings.end())
- {
-- m_changedSettings.push_back((*it).first);
-+ m_changedSettings.insert((*it).first);
- ++it;
- }
-
-diff -Naur xbmc-11.0.1/xbmc/peripherals/devices/Peripheral.h xbmc-11.0.1.patch/xbmc/peripherals/devices/Peripheral.h
---- xbmc-11.0.1/xbmc/peripherals/devices/Peripheral.h 2012-03-21 23:57:32.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/peripherals/devices/Peripheral.h 2012-04-17 14:47:59.589515425 +0200
-@@ -20,7 +20,7 @@
- *
- */
-
--#include
-+#include
- #include "utils/StdString.h"
- #include "peripherals/PeripheralTypes.h"
-
-@@ -128,6 +128,8 @@
- */
- virtual const CStdString GetSettingString(const CStdString &strKey) const;
- virtual void SetSetting(const CStdString &strKey, const CStdString &strValue);
-+ virtual void SetSettingVisible(const CStdString &strKey, bool bSetTo);
-+ virtual bool IsSettingVisible(const CStdString &strKey) const;
-
- virtual int GetSettingInt(const CStdString &strKey) const;
- virtual void SetSetting(const CStdString &strKey, int iValue);
-@@ -142,6 +144,8 @@
- virtual void LoadPersistedSettings(void);
- virtual void ResetDefaultSettings(void);
-
-+ virtual std::vector GetSettings(void) const;
-+
- virtual bool ErrorOccured(void) const { return m_bError; }
-
- protected:
-@@ -163,6 +167,6 @@
- std::vector m_features;
- std::vector m_subDevices;
- std::map m_settings;
-- std::vector m_changedSettings;
-+ std::set m_changedSettings;
- };
- }
-diff -Naur xbmc-11.0.1/xbmc/peripherals/devices/PeripheralHID.cpp xbmc-11.0.1.patch/xbmc/peripherals/devices/PeripheralHID.cpp
---- xbmc-11.0.1/xbmc/peripherals/devices/PeripheralHID.cpp 2012-03-21 23:57:32.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/peripherals/devices/PeripheralHID.cpp 2012-04-17 14:47:59.589515425 +0200
-@@ -37,7 +37,7 @@
-
- CPeripheralHID::~CPeripheralHID(void)
- {
-- if (!m_strKeymap.IsEmpty() && GetSettingBool("keymap_enabled"))
-+ if (!m_strKeymap.IsEmpty() && !GetSettingBool("do_not_use_custom_keymap"))
- {
- CLog::Log(LOGDEBUG, "%s - switching active keymapping to: default", __FUNCTION__);
- CButtonTranslator::GetInstance().RemoveDevice(m_strKeymap);
-@@ -59,9 +59,12 @@
- SetSetting("keymap", m_strKeymap);
- }
-
-+ if (!IsSettingVisible("keymap"))
-+ SetSettingVisible("do_not_use_custom_keymap", false);
-+
- if (!m_strKeymap.IsEmpty())
- {
-- bool bKeymapEnabled(GetSettingBool("keymap_enabled"));
-+ bool bKeymapEnabled(!GetSettingBool("do_not_use_custom_keymap"));
- if (bKeymapEnabled)
- {
- CLog::Log(LOGDEBUG, "%s - adding keymapping for: %s", __FUNCTION__, m_strKeymap.c_str());
-@@ -82,7 +85,7 @@
-
- void CPeripheralHID::OnSettingChanged(const CStdString &strChangedSetting)
- {
-- if (m_bInitialised && ((strChangedSetting.Equals("keymap") && GetSettingBool("keymap_enabled")) || strChangedSetting.Equals("keymap_enabled")))
-+ if (m_bInitialised && ((strChangedSetting.Equals("keymap") && !GetSettingBool("do_not_use_custom_keymap")) || strChangedSetting.Equals("keymap_enabled")))
- {
- m_bInitialised = false;
- InitialiseFeature(FEATURE_HID);
-diff -Naur xbmc-11.0.1/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp xbmc-11.0.1.patch/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp
---- xbmc-11.0.1/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp 2012-03-21 23:57:32.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp 2012-04-17 14:47:59.590515442 +0200
-@@ -66,17 +66,15 @@
-
- if (m_item)
- {
-- int iIndex = 1;
- CPeripheral *peripheral = g_peripherals.GetByPath(m_item->GetPath());
- if (peripheral)
- {
-- map::iterator it = peripheral->m_settings.begin();
-- while (it != peripheral->m_settings.end())
-+ vector settings = peripheral->GetSettings();
-+ for (size_t iPtr = 0; iPtr < settings.size(); iPtr++)
- {
-- CSetting *setting = (*it).second;
-+ CSetting *setting = settings[iPtr];
- if (!setting->IsVisible())
- {
-- ++it;
- CLog::Log(LOGDEBUG, "%s - invisible", __FUNCTION__);
- continue;
- }
-@@ -89,7 +87,7 @@
- if (boolSetting)
- {
- m_boolSettings.insert(make_pair(CStdString(boolSetting->GetSetting()), boolSetting->GetData()));
-- AddBool(iIndex++, boolSetting->GetLabel(), &m_boolSettings[boolSetting->GetSetting()], true);
-+ AddBool(boolSetting->GetOrder(), boolSetting->GetLabel(), &m_boolSettings[boolSetting->GetSetting()], true);
- }
- }
- break;
-@@ -99,7 +97,7 @@
- if (intSetting)
- {
- m_intSettings.insert(make_pair(CStdString(intSetting->GetSetting()), (float) intSetting->GetData()));
-- AddSlider(iIndex++, intSetting->GetLabel(), &m_intSettings[intSetting->GetSetting()], (float)intSetting->m_iMin, (float)intSetting->m_iStep, (float)intSetting->m_iMax, CGUIDialogVideoSettings::FormatInteger, false);
-+ AddSlider(intSetting->GetOrder(), intSetting->GetLabel(), &m_intSettings[intSetting->GetSetting()], (float)intSetting->m_iMin, (float)intSetting->m_iStep, (float)intSetting->m_iMax, CGUIDialogVideoSettings::FormatInteger, false);
- }
- }
- break;
-@@ -109,7 +107,7 @@
- if (floatSetting)
- {
- m_floatSettings.insert(make_pair(CStdString(floatSetting->GetSetting()), floatSetting->GetData()));
-- AddSlider(iIndex++, floatSetting->GetLabel(), &m_floatSettings[floatSetting->GetSetting()], floatSetting->m_fMin, floatSetting->m_fStep, floatSetting->m_fMax, CGUIDialogVideoSettings::FormatFloat, false);
-+ AddSlider(floatSetting->GetOrder(), floatSetting->GetLabel(), &m_floatSettings[floatSetting->GetSetting()], floatSetting->m_fMin, floatSetting->m_fStep, floatSetting->m_fMax, CGUIDialogVideoSettings::FormatFloat, false);
- }
- }
- break;
-@@ -119,7 +117,7 @@
- if (stringSetting)
- {
- m_stringSettings.insert(make_pair(CStdString(stringSetting->GetSetting()), stringSetting->GetData()));
-- AddString(iIndex, stringSetting->GetLabel(), &m_stringSettings[stringSetting->GetSetting()]);
-+ AddString(stringSetting->GetOrder(), stringSetting->GetLabel(), &m_stringSettings[stringSetting->GetSetting()]);
- }
- }
- break;
-@@ -128,7 +126,6 @@
- CLog::Log(LOGDEBUG, "%s - unknown type", __FUNCTION__);
- break;
- }
-- ++it;
- }
- }
- else
-diff -Naur xbmc-11.0.1/xbmc/peripherals/Peripherals.cpp xbmc-11.0.1.patch/xbmc/peripherals/Peripherals.cpp
---- xbmc-11.0.1/xbmc/peripherals/Peripherals.cpp 2012-03-21 23:57:32.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/peripherals/Peripherals.cpp 2012-04-17 14:47:59.647516518 +0200
-@@ -27,9 +27,7 @@
- #include "devices/PeripheralNIC.h"
- #include "devices/PeripheralNyxboard.h"
- #include "devices/PeripheralTuner.h"
--#if defined(HAVE_LIBCEC)
- #include "devices/PeripheralCecAdapter.h"
--#endif
- #include "bus/PeripheralBusUSB.h"
- #include "dialogs/GUIDialogPeripheralManager.h"
-
-@@ -43,6 +41,7 @@
- #include "guilib/LocalizeStrings.h"
- #include "dialogs/GUIDialogKaiToast.h"
- #include "utils/StringUtils.h"
-+#include "guilib/Key.h"
-
- using namespace PERIPHERALS;
- using namespace XFILE;
-@@ -447,6 +446,8 @@
- void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, map &m_settings)
- {
- TiXmlElement *currentNode = xmlNode->FirstChildElement("setting");
-+ int iMaxOrder(0);
-+
- while (currentNode)
- {
- CSetting *setting = NULL;
-@@ -492,10 +493,32 @@
- }
-
- //TODO add more types if needed
-+
-+ /* set the visibility */
- setting->SetVisible(bConfigurable);
-+
-+ /* set the order */
-+ int iOrder(0);
-+ currentNode->Attribute("order", &iOrder);
-+ /* if the order attribute is invalid or 0, then the setting will be added at the end */
-+ if (iOrder < 0)
-+ iOrder = 0;
-+ setting->SetOrder(iOrder);
-+ if (iOrder > iMaxOrder)
-+ iMaxOrder = iOrder;
-+
-+ /* and add this new setting */
- m_settings[strKey] = setting;
-+
- currentNode = currentNode->NextSiblingElement("setting");
- }
-+
-+ /* add the settings without an order attribute or an invalid order attribute set at the end */
-+ for (map::iterator it = m_settings.begin(); it != m_settings.end(); it++)
-+ {
-+ if (it->second->GetOrder() == 0)
-+ it->second->SetOrder(++iMaxOrder);
-+ }
- }
-
- void CPeripherals::GetDirectory(const CStdString &strPath, CFileItemList &items) const
-@@ -531,3 +554,89 @@
-
- return NULL;
- }
-+
-+bool CPeripherals::OnAction(const CAction &action)
-+{
-+ if (action.GetID() == ACTION_MUTE)
-+ {
-+ return ToggleMute();
-+ }
-+
-+ if (SupportsCEC() && action.GetAmount() && (action.GetID() == ACTION_VOLUME_UP || action.GetID() == ACTION_VOLUME_DOWN))
-+ {
-+ vector peripherals;
-+ if (GetPeripheralsWithFeature(peripherals, FEATURE_CEC))
-+ {
-+ for (unsigned int iPeripheralPtr = 0; iPeripheralPtr < peripherals.size(); iPeripheralPtr++)
-+ {
-+ CPeripheralCecAdapter *cecDevice = (CPeripheralCecAdapter *) peripherals.at(iPeripheralPtr);
-+ if (cecDevice && cecDevice->HasConnectedAudioSystem())
-+ {
-+ if (action.GetID() == ACTION_VOLUME_UP)
-+ cecDevice->ScheduleVolumeUp();
-+ else
-+ cecDevice->ScheduleVolumeDown();
-+ return true;
-+ }
-+ }
-+ }
-+ }
-+
-+ return false;
-+}
-+
-+bool CPeripherals::IsMuted(void)
-+{
-+ vector peripherals;
-+ if (SupportsCEC() && GetPeripheralsWithFeature(peripherals, FEATURE_CEC))
-+ {
-+ for (unsigned int iPeripheralPtr = 0; iPeripheralPtr < peripherals.size(); iPeripheralPtr++)
-+ {
-+ CPeripheralCecAdapter *cecDevice = (CPeripheralCecAdapter *) peripherals.at(iPeripheralPtr);
-+ if (cecDevice && cecDevice->IsMuted())
-+ return true;
-+ }
-+ }
-+
-+ return false;
-+}
-+
-+bool CPeripherals::ToggleMute(void)
-+{
-+ vector peripherals;
-+ if (SupportsCEC() && GetPeripheralsWithFeature(peripherals, FEATURE_CEC))
-+ {
-+ for (unsigned int iPeripheralPtr = 0; iPeripheralPtr < peripherals.size(); iPeripheralPtr++)
-+ {
-+ CPeripheralCecAdapter *cecDevice = (CPeripheralCecAdapter *) peripherals.at(iPeripheralPtr);
-+ if (cecDevice && cecDevice->HasConnectedAudioSystem())
-+ {
-+ cecDevice->ScheduleMute();
-+ return true;
-+ }
-+ }
-+ }
-+
-+ return false;
-+}
-+
-+bool CPeripherals::GetNextKeypress(float frameTime, CKey &key)
-+{
-+ vector peripherals;
-+ if (SupportsCEC() && GetPeripheralsWithFeature(peripherals, FEATURE_CEC))
-+ {
-+ for (unsigned int iPeripheralPtr = 0; iPeripheralPtr < peripherals.size(); iPeripheralPtr++)
-+ {
-+ CPeripheralCecAdapter *cecDevice = (CPeripheralCecAdapter *) peripherals.at(iPeripheralPtr);
-+ if (cecDevice && cecDevice->GetButton())
-+ {
-+ CKey newKey(cecDevice->GetButton(), cecDevice->GetHoldTime());
-+ cecDevice->ResetButton();
-+ key = newKey;
-+ return true;
-+ }
-+ }
-+ }
-+
-+ return false;
-+}
-diff -Naur xbmc-11.0.1/xbmc/peripherals/Peripherals.h xbmc-11.0.1.patch/xbmc/peripherals/Peripherals.h
---- xbmc-11.0.1/xbmc/peripherals/Peripherals.h 2012-03-21 23:57:32.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/peripherals/Peripherals.h 2012-04-17 14:47:59.648516536 +0200
-@@ -29,6 +29,8 @@
- class CSetting;
- class CSettingsCategory;
- class TiXmlElement;
-+class CAction;
-+class CKey;
-
- namespace PERIPHERALS
- {
-@@ -147,6 +149,54 @@
- */
- virtual CPeripheral *GetByPath(const CStdString &strPath) const;
-
-+ /*!
-+ * @brief Try to let one of the peripherals handle an action.
-+ * @param action The change to handle.
-+ * @return True when this change was handled by a peripheral (and should not be handled by anything else), false otherwise.
-+ */
-+ virtual bool OnAction(const CAction &action);
-+
-+ /*!
-+ * @brief Check whether there's a peripheral that reports to be muted.
-+ * @return True when at least one peripheral reports to be muted, false otherwise.
-+ */
-+ virtual bool IsMuted(void);
-+
-+ /*!
-+ * @brief Try to toggle the mute status via a peripheral.
-+ * @return True when this change was handled by a peripheral (and should not be handled by anything else), false otherwise.
-+ */
-+ virtual bool ToggleMute(void);
-+
-+ /*!
-+ * @brief Try to mute the audio via a peripheral.
-+ * @return True when this change was handled by a peripheral (and should not be handled by anything else), false otherwise.
-+ */
-+ virtual bool Mute(void) { return ToggleMute(); } // TODO CEC only supports toggling the mute status at this time
-+
-+ /*!
-+ * @brief Try to unmute the audio via a peripheral.
-+ * @return True when this change was handled by a peripheral (and should not be handled by anything else), false otherwise.
-+ */
-+ virtual bool UnMute(void) { return ToggleMute(); } // TODO CEC only supports toggling the mute status at this time
-+
-+ /*!
-+ * @brief Try to get a keypress from a peripheral.
-+ * @param frameTime The current frametime.
-+ * @param key The fetched key.
-+ * @return True when a keypress was fetched, false otherwise.
-+ */
-+ virtual bool GetNextKeypress(float frameTime, CKey &key);
-+
-+ bool SupportsCEC(void) const
-+ {
-+#if defined(HAVE_LIBCEC)
-+ return true;
-+#else
-+ return false;
-+#endif
-+ }
-+
- private:
- CPeripherals(void);
- bool LoadMappings(void);
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-801.02-cec-fixed_possible_deadlock.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.1-801.02-cec-fixed_possible_deadlock.patch
deleted file mode 100644
index d08d45ece7..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-801.02-cec-fixed_possible_deadlock.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From 35e4a2eb5515fe72d87b6d78b0567609df79df2b Mon Sep 17 00:00:00 2001
-From: bobo1on1
-Date: Wed, 28 Mar 2012 21:30:25 +0200
-Subject: [PATCH] fixed: possible deadlock
-
----
- xbmc/peripherals/devices/PeripheralCecAdapter.cpp | 6 ++++--
- 1 files changed, 4 insertions(+), 2 deletions(-)
-
-diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
-index 0cb6602..1c91341 100644
---- a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
-+++ b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
-@@ -140,8 +140,10 @@ void CPeripheralCecAdapter::Announce(AnnouncementFlag flag, const char *sender,
- else if (flag == System && !strcmp(sender, "xbmc") && !strcmp(message, "OnSleep"))
- {
- // this will also power off devices when we're the active source
-- CSingleLock lock(m_critSection);
-- m_bStop = true;
-+ {
-+ CSingleLock lock(m_critSection);
-+ m_bStop = true;
-+ }
- WaitForThreadExit(0);
- }
- else if (flag == System && !strcmp(sender, "xbmc") && !strcmp(message, "OnWake"))
---
-1.7.5.4
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-801.03-cec-fixed_make_sure_the_old_thread_is_stopped_before_starting_a_new_one.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.1-801.03-cec-fixed_make_sure_the_old_thread_is_stopped_before_starting_a_new_one.patch
deleted file mode 100644
index c186e4d62a..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-801.03-cec-fixed_make_sure_the_old_thread_is_stopped_before_starting_a_new_one.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From de4cd8d63257af1cb9060c4b2b304a82655adb99 Mon Sep 17 00:00:00 2001
-From: bobo1on1
-Date: Wed, 28 Mar 2012 21:31:46 +0200
-Subject: [PATCH] fixed: make sure the old thread is stopped before starting a
- new one, fixes throwing an exception in the main thread
-
----
- xbmc/peripherals/devices/PeripheralCecAdapter.cpp | 14 ++++++++------
- 1 files changed, 8 insertions(+), 6 deletions(-)
-
-diff --git a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
-index 1c91341..a898a16 100644
---- a/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
-+++ b/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
-@@ -148,15 +148,17 @@ void CPeripheralCecAdapter::Announce(AnnouncementFlag flag, const char *sender,
- }
- else if (flag == System && !strcmp(sender, "xbmc") && !strcmp(message, "OnWake"))
- {
-- // reconnect to the device
-- CSingleLock lock(m_critSection);
-- CLog::Log(LOGDEBUG, "%s - reconnecting to the CEC adapter after standby mode", __FUNCTION__);
-+ {
-+ // reconnect to the device
-+ CSingleLock lock(m_critSection);
-+ CLog::Log(LOGDEBUG, "%s - reconnecting to the CEC adapter after standby mode", __FUNCTION__);
-
-- // close the previous connection
-- m_cecAdapter->Close();
-+ // close the previous connection
-+ m_cecAdapter->Close();
-+ }
-
- // and open a new one
-- m_bStop = false;
-+ StopThread();
- Create();
- }
- }
---
-1.7.5.4
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-801.04-cec-PR887.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.1-801.04-cec-PR887.patch
deleted file mode 100644
index f870fbb3b6..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-801.04-cec-PR887.patch
+++ /dev/null
@@ -1,630 +0,0 @@
-diff -Naur xbmc-pvr-11.0.1/configure.in xbmc-pvr-11.0.1.patch/configure.in
---- xbmc-pvr-11.0.1/configure.in 2012-04-17 14:08:05.972587511 +0200
-+++ xbmc-pvr-11.0.1.patch/configure.in 2012-04-17 14:18:39.755586920 +0200
-@@ -1173,7 +1173,7 @@
-
- # libcec is dyloaded, so we need to check for its headers and link any depends.
- if test "x$use_libcec" != "xno"; then
-- PKG_CHECK_MODULES([CEC],[libcec >= 1.5.0],,[use_libcec="no";AC_MSG_RESULT($libcec_disabled)])
-+ PKG_CHECK_MODULES([CEC],[libcec >= 1.6.0],,[use_libcec="no";AC_MSG_RESULT($libcec_disabled)])
-
- if test "x$use_libcec" != "xno"; then
- INCLUDES="$INCLUDES $CEC_CFLAGS"
-diff -Naur xbmc-pvr-11.0.1/language/English/strings.xml xbmc-pvr-11.0.1.patch/language/English/strings.xml
---- xbmc-pvr-11.0.1/language/English/strings.xml 2012-04-17 14:08:05.974587546 +0200
-+++ xbmc-pvr-11.0.1.patch/language/English/strings.xml 2012-04-17 14:18:39.757586958 +0200
-@@ -2853,7 +2853,7 @@
- Could not detect the CEC port. Set it up manually.
- Could not initialise the CEC adapter. Check your settings.
- Unsupported libCEC interface version. %d is greater than the version XBMC supports (%d)
-- Put this PC in standby mode when the TV is switched off
-+ When the TV is switched off
- HDMI port number
- Connected
- Adapter found, but libCEC is not available
-@@ -2865,4 +2865,7 @@
- Configuration updated
- Failed to set the new configuration. Please check your settings.
- Send 'inactive source' command when stopping XBMC
-+ Put devices in standby mode when putting the PC in standby
-+ This device needs servicing
-+ Ignore
-
-diff -Naur xbmc-pvr-11.0.1/system/peripherals.xml xbmc-pvr-11.0.1.patch/system/peripherals.xml
---- xbmc-pvr-11.0.1/system/peripherals.xml 2012-04-17 14:08:05.975587564 +0200
-+++ xbmc-pvr-11.0.1.patch/system/peripherals.xml 2012-04-17 14:18:39.757586958 +0200
-@@ -14,13 +14,14 @@
-
-
-
--
--
--
--
--
--
--
-+
-+
-+
-+
-+
-+
-+
-+
-
-
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/peripherals/bus/PeripheralBus.cpp xbmc-pvr-11.0.1.patch/xbmc/peripherals/bus/PeripheralBus.cpp
---- xbmc-pvr-11.0.1/xbmc/peripherals/bus/PeripheralBus.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/peripherals/bus/PeripheralBus.cpp 2012-04-17 14:18:39.758586977 +0200
-@@ -323,6 +323,7 @@
- peripheralFile->SetProperty("bus", PeripheralTypeTranslator::BusTypeToString(peripheral->GetBusType()));
- peripheralFile->SetProperty("location", peripheral->Location());
- peripheralFile->SetProperty("class", PeripheralTypeTranslator::TypeToString(peripheral->Type()));
-+ peripheralFile->SetProperty("version", peripheral->GetVersionInfo());
- items.Add(peripheralFile);
- }
- }
-diff -Naur xbmc-pvr-11.0.1/xbmc/peripherals/devices/PeripheralCecAdapter.cpp xbmc-pvr-11.0.1.patch/xbmc/peripherals/devices/PeripheralCecAdapter.cpp
---- xbmc-pvr-11.0.1/xbmc/peripherals/devices/PeripheralCecAdapter.cpp 2012-04-17 14:17:35.207364830 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/peripherals/devices/PeripheralCecAdapter.cpp 2012-04-17 14:18:39.760587015 +0200
-@@ -41,7 +41,7 @@
- using namespace ANNOUNCEMENT;
- using namespace CEC;
-
--#define CEC_LIB_SUPPORTED_VERSION 0x1500
-+#define CEC_LIB_SUPPORTED_VERSION 0x1600
-
- /* time in seconds to ignore standby commands from devices after the screensaver has been activated */
- #define SCREENSAVER_TIMEOUT 10
-@@ -80,7 +80,9 @@
- m_lastKeypress(0),
- m_lastChange(VOLUME_CHANGE_NONE),
- m_iExitCode(0),
-- m_bIsMuted(false) // TODO fetch the correct initial value when system audiostatus is implemented in libCEC
-+ m_bIsMuted(false), // TODO fetch the correct initial value when system audiostatus is implemented in libCEC
-+ m_bGoingToStandby(false),
-+ m_bIsRunning(false)
- {
- m_button.iButton = 0;
- m_button.iDuration = 0;
-@@ -96,6 +98,7 @@
-
- m_bStop = true;
- StopThread(true);
-+ CAnnouncementManager::RemoveAnnouncer(this);
-
- if (m_dll && m_cecAdapter)
- {
-@@ -110,7 +113,11 @@
- {
- if (flag == System && !strcmp(sender, "xbmc") && !strcmp(message, "OnQuit") && m_bIsReady)
- {
-- m_iExitCode = data.asInteger(0);
-+ {
-+ CSingleLock lock(m_critSection);
-+ m_iExitCode = data.asInteger(0);
-+ }
-+ CAnnouncementManager::RemoveAnnouncer(this);
- StopThread(false);
- }
- else if (flag == GUI && !strcmp(sender, "xbmc") && !strcmp(message, "OnScreensaverDeactivated") && m_bIsReady)
-@@ -142,23 +149,22 @@
- // this will also power off devices when we're the active source
- {
- CSingleLock lock(m_critSection);
-- m_bStop = true;
-+ m_bGoingToStandby = false;
- }
-- WaitForThreadExit(0);
-+ StopThread();
- }
- else if (flag == System && !strcmp(sender, "xbmc") && !strcmp(message, "OnWake"))
- {
- {
-- // reconnect to the device
- CSingleLock lock(m_critSection);
-- CLog::Log(LOGDEBUG, "%s - reconnecting to the CEC adapter after standby mode", __FUNCTION__);
--
-- // close the previous connection
-- m_cecAdapter->Close();
-+ m_iExitCode = EXITCODE_RESTARTAPP;
- }
-
-- // and open a new one
-+ CLog::Log(LOGDEBUG, "%s - reconnecting to the CEC adapter after standby mode", __FUNCTION__);
-+ CAnnouncementManager::RemoveAnnouncer(this);
- StopThread();
-+
-+ // and open a new one
- Create();
- }
- }
-@@ -172,6 +178,7 @@
- m_callbacks.CBCecKeyPress = &CecKeyPress;
- m_callbacks.CBCecCommand = &CecCommand;
- m_callbacks.CBCecConfigurationChanged = &CecConfiguration;
-+ m_callbacks.CBCecAlert = &CecAlert;
- m_configuration.callbackParam = this;
- m_configuration.callbacks = &m_callbacks;
-
-@@ -200,6 +207,8 @@
- else
- {
- CLog::Log(LOGDEBUG, "%s - using libCEC v%s", __FUNCTION__, m_cecAdapter->ToString((cec_server_version)m_configuration.serverVersion));
-+ if (m_configuration.serverVersion >= CEC_SERVER_VERSION_1_6_0)
-+ m_strVersionInfo.Format("%d", m_configuration.iFirmwareVersion);
- }
-
- m_bStarted = true;
-@@ -297,6 +306,13 @@
- if (!OpenConnection())
- return;
-
-+ {
-+ CSingleLock lock(m_critSection);
-+ m_iExitCode = EXITCODE_QUIT;
-+ m_bGoingToStandby = false;
-+ m_bIsRunning = true;
-+ }
-+
- CAnnouncementManager::AddAnnouncer(this);
-
- m_queryThread = new CPeripheralCecAdapterUpdateThread(this, &m_configuration);
-@@ -312,8 +328,17 @@
- }
-
- delete m_queryThread;
-+ m_queryThread = NULL;
-+
-+ bool bSendStandbyCommands(false);
-+ {
-+ CSingleLock lock(m_critSection);
-+ bSendStandbyCommands = m_iExitCode != EXITCODE_REBOOT &&
-+ m_iExitCode != EXITCODE_RESTARTAPP &&
-+ (!m_bGoingToStandby || GetSettingBool("standby_tv_on_pc_standby"));
-+ }
-
-- if (m_iExitCode != EXITCODE_REBOOT)
-+ if (bSendStandbyCommands)
- {
- if (m_cecAdapter->IsLibCECActiveSource())
- {
-@@ -337,7 +362,12 @@
- m_cecAdapter->Close();
-
- CLog::Log(LOGDEBUG, "%s - CEC adapter processor thread ended", __FUNCTION__);
-- m_bStarted = false;
-+
-+ {
-+ CSingleLock lock(m_critSection);
-+ m_bStarted = false;
-+ m_bIsRunning = false;
-+ }
- }
-
- bool CPeripheralCecAdapter::HasConnectedAudioSystem(void)
-@@ -556,11 +586,15 @@
- case CEC_OPCODE_STANDBY:
- /* a device was put in standby mode */
- CLog::Log(LOGDEBUG, "%s - device %1x was put in standby mode", __FUNCTION__, command.initiator);
-- if (command.initiator == CECDEVICE_TV && adapter->m_configuration.bPowerOffOnStandby == 1 &&
-+ if (command.initiator == CECDEVICE_TV &&
-+ (adapter->m_configuration.bPowerOffOnStandby == 1 || adapter->m_configuration.bShutdownOnStandby == 1) &&
- (!adapter->m_screensaverLastActivated.IsValid() || CDateTime::GetCurrentDateTime() - adapter->m_screensaverLastActivated > CDateTimeSpan(0, 0, 0, SCREENSAVER_TIMEOUT)))
- {
- adapter->m_bStarted = false;
-- g_application.getApplicationMessenger().Suspend();
-+ if (adapter->m_configuration.bPowerOffOnStandby == 1)
-+ g_application.getApplicationMessenger().Suspend();
-+ else if (adapter->m_configuration.bShutdownOnStandby == 1)
-+ g_application.getApplicationMessenger().Shutdown();
- }
- break;
- case CEC_OPCODE_SET_MENU_LANGUAGE:
-@@ -634,6 +668,30 @@
- return 1;
- }
-
-+int CPeripheralCecAdapter::CecAlert(void *cbParam, const libcec_alert alert, const libcec_parameter &data)
-+{
-+ (void)data;
-+
-+ CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
-+ if (!adapter)
-+ return 0;
-+
-+ int iAlertString(0);
-+ switch (alert)
-+ {
-+ case CEC_ALERT_SERVICE_DEVICE:
-+ iAlertString = 36027;
-+ break;
-+ default:
-+ break;
-+ }
-+
-+ if (iAlertString)
-+ CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(36000), g_localizeStrings.Get(iAlertString));
-+
-+ return 1;
-+}
-+
- int CPeripheralCecAdapter::CecKeyPress(void *cbParam, const cec_keypress &key)
- {
- CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
-@@ -695,6 +753,10 @@
- case CEC_USER_CONTROL_CODE_RIGHT_DOWN:
- iButton = XINPUT_IR_REMOTE_RIGHT;
- break;
-+ case CEC_USER_CONTROL_CODE_NEXT_FAVORITE:
-+ case CEC_USER_CONTROL_CODE_SETUP_MENU:
-+ case CEC_USER_CONTROL_CODE_CONTENTS_MENU:
-+ case CEC_USER_CONTROL_CODE_FAVORITE_MENU:
- case CEC_USER_CONTROL_CODE_ROOT_MENU:
- iButton = XINPUT_IR_REMOTE_MENU;
- break;
-@@ -711,7 +773,11 @@
- iButton = XINPUT_IR_REMOTE_CHANNEL_PLUS;
- break;
- case CEC_USER_CONTROL_CODE_PREVIOUS_CHANNEL:
-+#if defined(XINPUT_IR_REMOTE_TELETEXT)
-+ iButton = XINPUT_IR_REMOTE_TELETEXT; // only supported by the pvr branch
-+#else
- iButton = XINPUT_IR_REMOTE_BACK;
-+#endif
- break;
- case CEC_USER_CONTROL_CODE_SOUND_SELECT:
- iButton = XINPUT_IR_REMOTE_LANGUAGE;
-@@ -806,13 +872,23 @@
- case CEC_USER_CONTROL_CODE_F4_YELLOW:
- iButton = XINPUT_IR_REMOTE_YELLOW;
- break;
-+ case CEC_USER_CONTROL_CODE_ELECTRONIC_PROGRAM_GUIDE:
-+#if defined(XINPUT_IR_REMOTE_GUIDE)
-+ iButton = XINPUT_IR_REMOTE_GUIDE;
-+#else
-+ bHasButton = false;
-+#endif
-+ break;
-+ case CEC_USER_CONTROL_CODE_AN_CHANNELS_LIST:
-+#if defined(XINPUT_IR_REMOTE_LIVE_TV)
-+ iButton = XINPUT_IR_REMOTE_LIVE_TV;
-+#else
-+ bHasButton = false;
-+#endif
-+ break;
- case CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION:
- case CEC_USER_CONTROL_CODE_EJECT:
-- case CEC_USER_CONTROL_CODE_SETUP_MENU:
-- case CEC_USER_CONTROL_CODE_CONTENTS_MENU:
-- case CEC_USER_CONTROL_CODE_FAVORITE_MENU:
- case CEC_USER_CONTROL_CODE_DOT:
-- case CEC_USER_CONTROL_CODE_NEXT_FAVORITE:
- case CEC_USER_CONTROL_CODE_INPUT_SELECT:
- case CEC_USER_CONTROL_CODE_INITIAL_CONFIGURATION:
- case CEC_USER_CONTROL_CODE_HELP:
-@@ -821,7 +897,6 @@
- case CEC_USER_CONTROL_CODE_ANGLE:
- case CEC_USER_CONTROL_CODE_SUB_PICTURE:
- case CEC_USER_CONTROL_CODE_VIDEO_ON_DEMAND:
-- case CEC_USER_CONTROL_CODE_ELECTRONIC_PROGRAM_GUIDE:
- case CEC_USER_CONTROL_CODE_TIMER_PROGRAMMING:
- case CEC_USER_CONTROL_CODE_PLAY_FUNCTION:
- case CEC_USER_CONTROL_CODE_PAUSE_PLAY_FUNCTION:
-@@ -894,11 +969,15 @@
- else if (bEnabled && !m_cecAdapter && m_bStarted)
- InitialiseFeature(FEATURE_CEC);
- }
-- else
-+ else if (IsRunning())
- {
- SetConfigurationFromSettings();
- m_queryThread->UpdateConfiguration(&m_configuration);
- }
-+ else
-+ {
-+ InitialiseFeature(FEATURE_CEC);
-+ }
- }
-
- int CPeripheralCecAdapter::CecLogMessage(void *cbParam, const cec_log_message &message)
-@@ -962,7 +1041,7 @@
-
- // set the physical address, when baseDevice or iHDMIPort are not set
- if (m_configuration.baseDevice == CECDEVICE_UNKNOWN ||
-- m_configuration.iHDMIPort == 0 || m_configuration.iHDMIPort > 4)
-+ m_configuration.iHDMIPort == 0 || m_configuration.iHDMIPort > 15)
- {
- m_configuration.iPhysicalAddress = config.iPhysicalAddress;
- CStdString strPhysicalAddress;
-@@ -977,7 +1056,7 @@
- // set the devices to wake when starting
- m_configuration.wakeDevices = config.wakeDevices;
- CStdString strWakeDevices;
-- for (unsigned int iPtr = 0; iPtr <= 16; iPtr++)
-+ for (unsigned int iPtr = CECDEVICE_TV; iPtr <= CECDEVICE_BROADCAST; iPtr++)
- if (config.wakeDevices[iPtr])
- strWakeDevices.AppendFormat(" %X", iPtr);
- SetSetting("wake_devices", strWakeDevices.Trim());
-@@ -985,10 +1064,10 @@
- // set the devices to power off when stopping
- m_configuration.powerOffDevices = config.powerOffDevices;
- CStdString strPowerOffDevices;
-- for (unsigned int iPtr = 0; iPtr <= 16; iPtr++)
-+ for (unsigned int iPtr = CECDEVICE_TV; iPtr <= CECDEVICE_BROADCAST; iPtr++)
- if (config.powerOffDevices[iPtr])
- strPowerOffDevices.AppendFormat(" %X", iPtr);
-- SetSetting("wake_devices", strPowerOffDevices.Trim());
-+ SetSetting("standby_devices", strPowerOffDevices.Trim());
-
- // set the boolean settings
- m_configuration.bUseTVMenuLanguage = config.bUseTVMenuLanguage;
-@@ -1001,17 +1080,27 @@
- SetSetting("cec_standby_screensaver", m_configuration.bPowerOffScreensaver == 1);
-
- m_configuration.bPowerOffOnStandby = config.bPowerOffOnStandby;
-- SetSetting("standby_pc_on_tv_standby", m_configuration.bPowerOffOnStandby == 1);
-
- if (config.serverVersion >= CEC_SERVER_VERSION_1_5_1)
- m_configuration.bSendInactiveSource = config.bSendInactiveSource;
- SetSetting("send_inactive_source", m_configuration.bSendInactiveSource == 1);
-+
-+ if (config.serverVersion >= CEC_SERVER_VERSION_1_6_0)
-+ {
-+ m_configuration.iFirmwareVersion = config.iFirmwareVersion;
-+ m_strVersionInfo.Format("%d", m_configuration.iFirmwareVersion);
-+ m_configuration.bShutdownOnStandby = config.bShutdownOnStandby;
-+ }
-+
-+ SetSetting("standby_pc_on_tv_standby",
-+ m_configuration.bPowerOffOnStandby == 1 ? 13011 :
-+ m_configuration.bShutdownOnStandby == 1 ? 13005 : 36028);
- }
-
- void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
- {
-- // client version 1.5.0
-- m_configuration.clientVersion = CEC_CLIENT_VERSION_1_5_1;
-+ // client version 1.6.0
-+ m_configuration.clientVersion = CEC_CLIENT_VERSION_1_6_0;
-
- // device name 'XBMC'
- snprintf(m_configuration.strDeviceName, 13, "%s", GetSettingString("device_name").c_str());
-@@ -1061,15 +1150,16 @@
- m_configuration.powerOffDevices.Clear();
- ReadLogicalAddresses(strStandbyDevices, m_configuration.powerOffDevices);
-
-- // always get the settings from the rom, when supported by the firmware
-- m_configuration.bGetSettingsFromROM = 1;
--
- // read the boolean settings
- m_configuration.bUseTVMenuLanguage = GetSettingBool("use_tv_menu_language") ? 1 : 0;
- m_configuration.bActivateSource = GetSettingBool("activate_source") ? 1 : 0;
- m_configuration.bPowerOffScreensaver = GetSettingBool("cec_standby_screensaver") ? 1 : 0;
-- m_configuration.bPowerOffOnStandby = GetSettingBool("standby_pc_on_tv_standby") ? 1 : 0;
- m_configuration.bSendInactiveSource = GetSettingBool("send_inactive_source") ? 1 : 0;
-+
-+ // read the mutually exclusive boolean settings
-+ int iStandbyAction(GetSettingInt("standby_pc_on_tv_standby"));
-+ m_configuration.bPowerOffOnStandby = iStandbyAction == 13011 ? 1 : 0;
-+ m_configuration.bShutdownOnStandby = iStandbyAction == 13005 ? 1 : 0;
- }
-
- void CPeripheralCecAdapter::ReadLogicalAddresses(const CStdString &strString, cec_logical_addresses &addresses)
-@@ -1203,6 +1293,12 @@
- return true;
- }
-
-+bool CPeripheralCecAdapter::IsRunning(void) const
-+{
-+ CSingleLock lock(m_critSection);
-+ return m_bIsRunning;
-+}
-+
- void CPeripheralCecAdapterUpdateThread::Process(void)
- {
- // set the initial configuration
-diff -Naur xbmc-pvr-11.0.1/xbmc/peripherals/devices/PeripheralCecAdapter.h xbmc-pvr-11.0.1.patch/xbmc/peripherals/devices/PeripheralCecAdapter.h
---- xbmc-pvr-11.0.1/xbmc/peripherals/devices/PeripheralCecAdapter.h 2012-04-17 14:08:06.071589381 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/peripherals/devices/PeripheralCecAdapter.h 2012-04-17 14:18:39.761587034 +0200
-@@ -115,6 +115,8 @@
- static int CecLogMessage(void *cbParam, const CEC::cec_log_message &message);
- static int CecCommand(void *cbParam, const CEC::cec_command &command);
- static int CecConfiguration(void *cbParam, const CEC::libcec_configuration &config);
-+ static int CecAlert(void *cbParam, const CEC::libcec_alert alert, const CEC::libcec_parameter &data);
-+ bool IsRunning(void) const;
-
- virtual bool GetNextKey(void);
- virtual bool GetNextCecKey(CEC::cec_keypress &key);
-@@ -140,6 +142,8 @@
- CecVolumeChange m_lastChange;
- int m_iExitCode;
- bool m_bIsMuted;
-+ bool m_bGoingToStandby;
-+ bool m_bIsRunning;
- CPeripheralCecAdapterUpdateThread*m_queryThread;
- CEC::ICECCallbacks m_callbacks;
- CCriticalSection m_critSection;
-diff -Naur xbmc-pvr-11.0.1/xbmc/peripherals/devices/Peripheral.cpp xbmc-pvr-11.0.1.patch/xbmc/peripherals/devices/Peripheral.cpp
---- xbmc-pvr-11.0.1/xbmc/peripherals/devices/Peripheral.cpp 2012-04-17 14:08:06.104590004 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/peripherals/devices/Peripheral.cpp 2012-04-17 14:18:39.752586865 +0200
-@@ -211,7 +211,15 @@
- case SETTINGS_TYPE_INT:
- {
- const CSettingInt *mappedSetting = (const CSettingInt *) setting;
-- CSettingInt *intSetting = new CSettingInt(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->m_iMin, mappedSetting->m_iStep, mappedSetting->m_iMax, mappedSetting->GetControlType(), mappedSetting->m_strFormat);
-+ CSettingInt *intSetting(NULL);
-+ if (mappedSetting->GetControlType() == SPIN_CONTROL_INT)
-+ {
-+ intSetting = new CSettingInt(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->m_iMin, mappedSetting->m_iStep, mappedSetting->m_iMax, mappedSetting->GetControlType(), mappedSetting->m_strFormat);
-+ }
-+ else if (mappedSetting->GetControlType() == SPIN_CONTROL_TEXT)
-+ {
-+ intSetting = new CSettingInt(mappedSetting->GetOrder(), strKey.c_str(), mappedSetting->GetLabel(), mappedSetting->GetData(), mappedSetting->m_entries, mappedSetting->GetControlType());
-+ }
- if (intSetting)
- {
- intSetting->SetVisible(mappedSetting->IsVisible());
-diff -Naur xbmc-pvr-11.0.1/xbmc/peripherals/devices/Peripheral.h xbmc-pvr-11.0.1.patch/xbmc/peripherals/devices/Peripheral.h
---- xbmc-pvr-11.0.1/xbmc/peripherals/devices/Peripheral.h 2012-04-17 14:08:06.104590004 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/peripherals/devices/Peripheral.h 2012-04-17 14:18:39.758586977 +0200
-@@ -53,6 +53,7 @@
- const CStdString &DeviceName(void) const { return m_strDeviceName; }
- bool IsHidden(void) const { return m_bHidden; }
- void SetHidden(bool bSetTo = true) { m_bHidden = bSetTo; }
-+ const CStdString &GetVersionInfo(void) const { return m_strVersionInfo; }
-
- /*!
- * @brief Check whether this device has the given feature.
-@@ -161,6 +162,7 @@
- CStdString m_strVendorId;
- int m_iProductId;
- CStdString m_strProductId;
-+ CStdString m_strVersionInfo;
- bool m_bInitialised;
- bool m_bHidden;
- bool m_bError;
-diff -Naur xbmc-pvr-11.0.1/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp xbmc-pvr-11.0.1.patch/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp
---- xbmc-pvr-11.0.1/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp 2012-04-17 14:08:06.105590023 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp 2012-04-17 14:18:39.753586884 +0200
-@@ -51,6 +51,7 @@
- delete m_item;
- m_boolSettings.clear();
- m_intSettings.clear();
-+ m_intTextSettings.clear();
- m_floatSettings.clear();
- m_stringSettings.clear();
- m_settings.clear();
-@@ -96,8 +97,23 @@
- CSettingInt *intSetting = (CSettingInt *) setting;
- if (intSetting)
- {
-- m_intSettings.insert(make_pair(CStdString(intSetting->GetSetting()), (float) intSetting->GetData()));
-- AddSlider(intSetting->GetOrder(), intSetting->GetLabel(), &m_intSettings[intSetting->GetSetting()], (float)intSetting->m_iMin, (float)intSetting->m_iStep, (float)intSetting->m_iMax, CGUIDialogVideoSettings::FormatInteger, false);
-+ if (intSetting->GetControlType() == SPIN_CONTROL_INT)
-+ {
-+ m_intSettings.insert(make_pair(CStdString(intSetting->GetSetting()), (float) intSetting->GetData()));
-+ AddSlider(intSetting->GetOrder(), intSetting->GetLabel(), &m_intSettings[intSetting->GetSetting()], (float)intSetting->m_iMin, (float)intSetting->m_iStep, (float)intSetting->m_iMax, CGUIDialogVideoSettings::FormatInteger, false);
-+ }
-+ else if (intSetting->GetControlType() == SPIN_CONTROL_TEXT)
-+ {
-+ m_intTextSettings.insert(make_pair(CStdString(intSetting->GetSetting()), intSetting->GetData()));
-+ vector > entries;
-+ map::iterator entriesItr = intSetting->m_entries.begin();
-+ while (entriesItr != intSetting->m_entries.end())
-+ {
-+ entries.push_back(make_pair(entriesItr->first, entriesItr->second));
-+ ++entriesItr;
-+ }
-+ AddSpin(intSetting->GetOrder(), intSetting->GetLabel(), &m_intTextSettings[intSetting->GetSetting()], entries);
-+ }
- }
- }
- break;
-@@ -160,6 +176,13 @@
- ++intItr;
- }
-
-+ map::iterator intTextItr = m_intTextSettings.begin();
-+ while (intTextItr != m_intTextSettings.end())
-+ {
-+ peripheral->SetSetting((*intTextItr).first, (*intTextItr).second);
-+ ++intTextItr;
-+ }
-+
- map::iterator floatItr = m_floatSettings.begin();
- while (floatItr != m_floatSettings.end())
- {
-@@ -210,6 +233,7 @@
- /* clear the settings */
- m_boolSettings.clear();
- m_intSettings.clear();
-+ m_intTextSettings.clear();
- m_floatSettings.clear();
- m_stringSettings.clear();
- m_settings.clear();
-diff -Naur xbmc-pvr-11.0.1/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.h xbmc-pvr-11.0.1.patch/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.h
---- xbmc-pvr-11.0.1/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.h 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.h 2012-04-17 14:18:39.753586884 +0200
-@@ -44,6 +44,7 @@
- bool m_bIsInitialising;
- std::map m_boolSettings;
- std::map m_intSettings;
-+ std::map m_intTextSettings;
- std::map m_floatSettings;
- std::map m_stringSettings;
- };
-diff -Naur xbmc-pvr-11.0.1/xbmc/peripherals/Peripherals.cpp xbmc-pvr-11.0.1.patch/xbmc/peripherals/Peripherals.cpp
---- xbmc-pvr-11.0.1/xbmc/peripherals/Peripherals.cpp 2012-04-17 14:08:06.106590043 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/peripherals/Peripherals.cpp 2012-04-17 14:18:39.752586865 +0200
-@@ -41,6 +41,7 @@
- #include "guilib/LocalizeStrings.h"
- #include "dialogs/GUIDialogKaiToast.h"
- #include "utils/StringUtils.h"
-+#include "Util.h"
- #include "guilib/Key.h"
-
- using namespace PERIPHERALS;
-@@ -486,29 +487,46 @@
- float fMax = currentNode->Attribute("max") ? (float) atof(currentNode->Attribute("max")) : 0;
- setting = new CSettingFloat(0, strKey, iLabelId, fValue, fMin, fStep, fMax, SPIN_CONTROL_FLOAT);
- }
-+ else if (strSettingsType.Equals("enum"))
-+ {
-+ CStdString strEnums(currentNode->Attribute("lvalues"));
-+ if (!strEnums.IsEmpty())
-+ {
-+ map enums;
-+ vector valuesVec;
-+ CUtil::Tokenize(strEnums, valuesVec, "|");
-+ for (unsigned int i = 0; i < valuesVec.size(); i++)
-+ enums.insert(make_pair(atoi(valuesVec[i]), atoi(valuesVec[i])));
-+ int iValue = currentNode->Attribute("value") ? atoi(currentNode->Attribute("value")) : 0;
-+ setting = new CSettingInt(0, strKey, iLabelId, iValue, enums, SPIN_CONTROL_TEXT);
-+ }
-+ }
- else
- {
- CStdString strValue(currentNode->Attribute("value"));
- setting = new CSettingString(0, strKey, iLabelId, strValue, EDIT_CONTROL_INPUT, !bConfigurable, -1);
- }
-
-- //TODO add more types if needed
-+ if (setting)
-+ {
-+ //TODO add more types if needed
-
-- /* set the visibility */
-- setting->SetVisible(bConfigurable);
-+ /* set the visibility */
-+ setting->SetVisible(bConfigurable);
-
-- /* set the order */
-- int iOrder(0);
-- currentNode->Attribute("order", &iOrder);
-- /* if the order attribute is invalid or 0, then the setting will be added at the end */
-- if (iOrder < 0)
-- iOrder = 0;
-- setting->SetOrder(iOrder);
-- if (iOrder > iMaxOrder)
-- iMaxOrder = iOrder;
-+ /* set the order */
-+ int iOrder(0);
-+ currentNode->Attribute("order", &iOrder);
-+ /* if the order attribute is invalid or 0, then the setting will be added at the end */
-+ if (iOrder < 0)
-+ iOrder = 0;
-+ setting->SetOrder(iOrder);
-+ if (iOrder > iMaxOrder)
-+ iMaxOrder = iOrder;
-
-- /* and add this new setting */
-- m_settings[strKey] = setting;
-+ /* and add this new setting */
-+ m_settings[strKey] = setting;
-+ }
-
- currentNode = currentNode->NextSiblingElement("setting");
- }
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-901.01-ffmpeg-10.2-28b186f.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.1-901.01-ffmpeg-10.2-28b186f.patch
deleted file mode 100644
index 73e25bd3af..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-901.01-ffmpeg-10.2-28b186f.patch
+++ /dev/null
@@ -1,3198 +0,0 @@
-diff -Naur xbmc-11.0.1/configure.in xbmc-11.0.1.patch/configure.in
---- xbmc-11.0.1/configure.in 2012-03-21 23:57:58.000000000 +0100
-+++ xbmc-11.0.1.patch/configure.in 2012-06-05 15:19:23.820493772 +0200
-@@ -2024,7 +2024,7 @@
- --disable-amd3dnow \
- --disable-armv5te \
- --disable-armv6t2 \
-- --disable-static \
-+ --enable-static \
- `if test "$use_debug" = "no"; then echo --disable-debug; fi` \
- --disable-muxers \
- --enable-muxer=spdif \
-@@ -2038,7 +2038,6 @@
- --disable-ffplay \
- --disable-ffserver \
- --disable-ffmpeg \
-- --enable-shared \
- --disable-doc \
- --disable-decoder=mpeg_xvmc \
- --enable-postproc \
-@@ -2046,6 +2045,7 @@
- --enable-protocol=http \
- --enable-pthreads \
- --enable-runtime-cpudetect \
-+ --disable-openmp \
- --cc="$CC" &&
- sed -ie "s#YASM=yasm#YASM=${prefix}/bin/yasm#" config.mak &&
- sed -ie "s#YASMDEP=yasm#YASMDEP=${prefix}/bin/yasm#" config.mak &&
-diff -Naur xbmc-11.0.1/lib/DllAvCodec.h xbmc-11.0.1.patch/lib/DllAvCodec.h
---- xbmc-11.0.1/lib/DllAvCodec.h 2012-03-21 23:57:36.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllAvCodec.h 2012-06-05 15:19:23.822493812 +0200
-@@ -24,7 +24,7 @@
- #include "config.h"
- #endif
- #include "DynamicDll.h"
--#include "DllAvCore.h"
-+#include "DllAvUtil.h"
- #include "utils/log.h"
-
- extern "C" {
-@@ -76,28 +76,6 @@
- #endif
- }
-
--/* Some convenience macros introduced at this particular revision of libavcodec.
-- */
--#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52,25,0)
--#define CH_LAYOUT_5POINT0_BACK (CH_LAYOUT_SURROUND|CH_BACK_LEFT|CH_BACK_RIGHT)
--#define CH_LAYOUT_5POINT1_BACK (CH_LAYOUT_5POINT0_BACK|CH_LOW_FREQUENCY)
--#undef CH_LAYOUT_7POINT1_WIDE
--#define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_5POINT1_BACK|\
-- CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER)
--#endif
--
--#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52,64,0)
--// API added on: 2010-03-31
--#define AVMediaType CodecType
--#define AVMEDIA_TYPE_UNKNOWN CODEC_TYPE_UNKNOWN
--#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
--#define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO
--#define AVMEDIA_TYPE_DATA CODEC_TYPE_DATA
--#define AVMEDIA_TYPE_SUBTITLE CODEC_TYPE_SUBTITLE
--#define AVMEDIA_TYPE_ATTACHMENT CODEC_TYPE_ATTACHMENT
--#define AVMEDIA_TYPE_NB CODEC_TYPE_NB
--#endif
--
- #include "threads/SingleLock.h"
-
- class DllAvCodecInterface
-@@ -106,20 +84,20 @@
- virtual ~DllAvCodecInterface() {}
- virtual void avcodec_register_all(void)=0;
- virtual void avcodec_flush_buffers(AVCodecContext *avctx)=0;
-- virtual int avcodec_open_dont_call(AVCodecContext *avctx, AVCodec *codec)=0;
-+ virtual int avcodec_open2_dont_call(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)=0;
- virtual AVCodec *avcodec_find_decoder(enum CodecID id)=0;
- virtual AVCodec *avcodec_find_encoder(enum CodecID id)=0;
- virtual int avcodec_close_dont_call(AVCodecContext *avctx)=0;
- virtual AVFrame *avcodec_alloc_frame(void)=0;
- virtual int avpicture_fill(AVPicture *picture, uint8_t *ptr, PixelFormat pix_fmt, int width, int height)=0;
- virtual int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt)=0;
-- virtual int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt)=0;
-+ virtual int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)=0;
- virtual int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)=0;
- virtual int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples)=0;
- virtual int avpicture_get_size(PixelFormat pix_fmt, int width, int height)=0;
-- virtual AVCodecContext *avcodec_alloc_context(void)=0;
-+ virtual AVCodecContext *avcodec_alloc_context3(AVCodec *codec)=0;
- virtual void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)=0;
-- virtual void avcodec_get_context_defaults(AVCodecContext *s)=0;
-+ virtual void avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec)=0;
- virtual AVCodecParserContext *av_parser_init(int codec_id)=0;
- virtual int av_parser_parse2(AVCodecParserContext *s,AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size,
-@@ -137,7 +115,6 @@
- virtual enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat *fmt)=0;
- virtual int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic)=0;
- virtual void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic)=0;
-- virtual int avcodec_thread_init(AVCodecContext *s, int thread_count)=0;
- virtual AVCodec *av_codec_next(AVCodec *c)=0;
- virtual AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int out_channels,
- enum AVSampleFormat in_fmt , int in_channels,
-@@ -151,7 +128,7 @@
- virtual int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name)=0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
-
- // Use direct layer
- class DllAvCodec : public DllDynamic, DllAvCodecInterface
-@@ -166,12 +143,12 @@
- ::avcodec_register_all();
- }
- virtual void avcodec_flush_buffers(AVCodecContext *avctx) { ::avcodec_flush_buffers(avctx); }
-- virtual int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
-+ virtual int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
-- return ::avcodec_open(avctx, codec);
-+ return ::avcodec_open2(avctx, codec, options);
- }
-- virtual int avcodec_open_dont_call(AVCodecContext *avctx, AVCodec *codec) { *(int *)0x0 = 0; return 0; }
-+ virtual int avcodec_open2_dont_call(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) { *(int *)0x0 = 0; return 0; }
- virtual int avcodec_close_dont_call(AVCodecContext *avctx) { *(int *)0x0 = 0; return 0; }
- virtual AVCodec *avcodec_find_decoder(enum CodecID id) { return ::avcodec_find_decoder(id); }
- virtual AVCodec *avcodec_find_encoder(enum CodecID id) { return ::avcodec_find_encoder(id); }
-@@ -182,33 +159,21 @@
- }
- virtual AVFrame *avcodec_alloc_frame() { return ::avcodec_alloc_frame(); }
- virtual int avpicture_fill(AVPicture *picture, uint8_t *ptr, PixelFormat pix_fmt, int width, int height) { return ::avpicture_fill(picture, ptr, pix_fmt, width, height); }
--#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,23,0)
-- // API added on: 2009-04-07
- virtual int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt) { return ::avcodec_decode_video2(avctx, picture, got_picture_ptr, avpkt); }
-- virtual int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt) { return ::avcodec_decode_audio3(avctx, samples, frame_size_ptr, avpkt); }
-+ virtual int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt) { return ::avcodec_decode_audio4(avctx, frame, got_frame_ptr, avpkt); }
- virtual int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) { return ::avcodec_decode_subtitle2(avctx, sub, got_sub_ptr, avpkt); }
--#else
-- virtual int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt) { return ::avcodec_decode_video(avctx, picture, got_picture_ptr, avpkt->data, avpkt->size); }
-- virtual int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt) { return ::avcodec_decode_audio2(avctx, samples, frame_size_ptr, avpkt->data, avpkt->size); }
-- virtual int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) { return ::avcodec_decode_subtitle(avctx, sub, got_sub_ptr, avpkt->data, avpkt->size); }
--#endif
- virtual int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples) { return ::avcodec_encode_audio(avctx, buf, buf_size, samples); }
- virtual int avpicture_get_size(PixelFormat pix_fmt, int width, int height) { return ::avpicture_get_size(pix_fmt, width, height); }
-- virtual AVCodecContext *avcodec_alloc_context() { return ::avcodec_alloc_context(); }
-+ virtual AVCodecContext *avcodec_alloc_context3(AVCodec *codec) { return ::avcodec_alloc_context3(codec); }
- virtual void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) { ::avcodec_string(buf, buf_size, enc, encode); }
-- virtual void avcodec_get_context_defaults(AVCodecContext *s) { ::avcodec_get_context_defaults(s); }
-+ virtual void avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec) { ::avcodec_get_context_defaults3(s, codec); }
-
- virtual AVCodecParserContext *av_parser_init(int codec_id) { return ::av_parser_init(codec_id); }
- virtual int av_parser_parse2(AVCodecParserContext *s,AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size,
- int64_t pts, int64_t dts, int64_t pos)
- {
--#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,21,0)
-- // API added on : 2009-03-05
- return ::av_parser_parse2(s, avctx, poutbuf, poutbuf_size, buf, buf_size, pts, dts, pos);
--#else
-- return ::av_parser_parse(s, avctx, poutbuf, poutbuf_size, buf, buf_size, pts, dts);
--#endif
- }
- virtual void av_parser_close(AVCodecParserContext *s) { ::av_parser_close(s); }
-
-@@ -225,7 +190,6 @@
- virtual int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic) { return ::avcodec_default_get_buffer(s, pic); }
- virtual void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic) { ::avcodec_default_release_buffer(s, pic); }
- virtual enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat *fmt) { return ::avcodec_default_get_format(s, fmt); }
-- virtual int avcodec_thread_init(AVCodecContext *s, int thread_count) { return ::avcodec_thread_init(s, thread_count); }
- virtual AVCodec *av_codec_next(AVCodec *c) { return ::av_codec_next(c); }
- virtual AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int out_channels,
- enum AVSampleFormat in_fmt , int in_channels,
-@@ -256,12 +220,12 @@
- {
- DECLARE_DLL_WRAPPER(DllAvCodec, DLL_PATH_LIBAVCODEC)
- DEFINE_FUNC_ALIGNED1(void, __cdecl, avcodec_flush_buffers, AVCodecContext*)
-- DEFINE_FUNC_ALIGNED2(int, __cdecl, avcodec_open_dont_call, AVCodecContext*, AVCodec *)
-+ DEFINE_FUNC_ALIGNED3(int, __cdecl, avcodec_open2_dont_call, AVCodecContext*, AVCodec *, AVDictionary **)
- DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_video2, AVCodecContext*, AVFrame*, int*, AVPacket*)
-- DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_audio3, AVCodecContext*, int16_t*, int*, AVPacket*)
-+ DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_audio4, AVCodecContext*, AVFrame*, int*, AVPacket*)
- DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_subtitle2, AVCodecContext*, AVSubtitle*, int*, AVPacket*)
- DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_encode_audio, AVCodecContext*, uint8_t*, int, const short*)
-- DEFINE_FUNC_ALIGNED0(AVCodecContext*, __cdecl, avcodec_alloc_context)
-+ DEFINE_FUNC_ALIGNED1(AVCodecContext*, __cdecl, avcodec_alloc_context3, AVCodec *)
- DEFINE_FUNC_ALIGNED1(AVCodecParserContext*, __cdecl, av_parser_init, int)
- DEFINE_FUNC_ALIGNED9(int, __cdecl, av_parser_parse2, AVCodecParserContext*,AVCodecContext*, uint8_t**, int*, const uint8_t*, int, int64_t, int64_t, int64_t)
- DEFINE_METHOD1(int, av_dup_packet, (AVPacket *p1))
-@@ -278,7 +242,7 @@
- DEFINE_METHOD5(int, avpicture_fill, (AVPicture *p1, uint8_t *p2, PixelFormat p3, int p4, int p5))
- DEFINE_METHOD3(int, avpicture_get_size, (PixelFormat p1, int p2, int p3))
- DEFINE_METHOD4(void, avcodec_string, (char *p1, int p2, AVCodecContext *p3, int p4))
-- DEFINE_METHOD1(void, avcodec_get_context_defaults, (AVCodecContext *p1))
-+ DEFINE_METHOD2(void, avcodec_get_context_defaults3, (AVCodecContext *p1, AVCodec *p2))
- DEFINE_METHOD1(void, av_parser_close, (AVCodecParserContext *p1))
- DEFINE_METHOD1(void, avpicture_free, (AVPicture *p1))
- DEFINE_METHOD1(AVBitStreamFilterContext*, av_bitstream_filter_init, (const char *p1))
-@@ -290,7 +254,6 @@
- DEFINE_METHOD2(void, avcodec_default_release_buffer, (AVCodecContext *p1, AVFrame *p2))
- DEFINE_METHOD2(enum PixelFormat, avcodec_default_get_format, (struct AVCodecContext *p1, const enum PixelFormat *p2))
-
-- DEFINE_METHOD2(int, avcodec_thread_init, (AVCodecContext *p1, int p2))
- DEFINE_METHOD1(AVCodec*, av_codec_next, (AVCodec *p1))
- DEFINE_METHOD6(AVAudioConvert*, av_audio_convert_alloc, (enum AVSampleFormat p1, int p2,
- enum AVSampleFormat p3, int p4,
-@@ -301,7 +264,7 @@
- const void * const p4[6], const int p5[6], int p6))
- BEGIN_METHOD_RESOLVE()
- RESOLVE_METHOD(avcodec_flush_buffers)
-- RESOLVE_METHOD_RENAME(avcodec_open,avcodec_open_dont_call)
-+ RESOLVE_METHOD_RENAME(avcodec_open2,avcodec_open2_dont_call)
- RESOLVE_METHOD_RENAME(avcodec_close,avcodec_close_dont_call)
- RESOLVE_METHOD(avcodec_find_decoder)
- RESOLVE_METHOD(avcodec_find_encoder)
-@@ -309,13 +272,13 @@
- RESOLVE_METHOD_RENAME(avcodec_register_all, avcodec_register_all_dont_call)
- RESOLVE_METHOD(avpicture_fill)
- RESOLVE_METHOD(avcodec_decode_video2)
-- RESOLVE_METHOD(avcodec_decode_audio3)
-+ RESOLVE_METHOD(avcodec_decode_audio4)
- RESOLVE_METHOD(avcodec_decode_subtitle2)
- RESOLVE_METHOD(avcodec_encode_audio)
- RESOLVE_METHOD(avpicture_get_size)
-- RESOLVE_METHOD(avcodec_alloc_context)
-+ RESOLVE_METHOD(avcodec_alloc_context3)
- RESOLVE_METHOD(avcodec_string)
-- RESOLVE_METHOD(avcodec_get_context_defaults)
-+ RESOLVE_METHOD(avcodec_get_context_defaults3)
- RESOLVE_METHOD(av_parser_init)
- RESOLVE_METHOD(av_parser_parse2)
- RESOLVE_METHOD(av_parser_close)
-@@ -328,7 +291,6 @@
- RESOLVE_METHOD(avcodec_default_get_buffer)
- RESOLVE_METHOD(avcodec_default_release_buffer)
- RESOLVE_METHOD(avcodec_default_get_format)
-- RESOLVE_METHOD(avcodec_thread_init)
- RESOLVE_METHOD(av_codec_next)
- RESOLVE_METHOD(av_audio_convert_alloc)
- RESOLVE_METHOD(av_audio_convert_free)
-@@ -339,15 +301,15 @@
- END_METHOD_RESOLVE()
-
- /* dependencies of libavcodec */
-- DllAvCore m_dllAvCore;
-+ DllAvUtil m_dllAvUtil;
- // DllAvUtil loaded implicitely by m_dllAvCore
-
- public:
- static CCriticalSection m_critSection;
-- int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
-+ int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
-- return avcodec_open_dont_call(avctx,codec);
-+ return avcodec_open2_dont_call(avctx,codec, options);
- }
- int avcodec_close(AVCodecContext *avctx)
- {
-@@ -361,7 +323,7 @@
- }
- virtual bool Load()
- {
-- if (!m_dllAvCore.Load())
-+ if (!m_dllAvUtil.Load())
- return false;
- return DllDynamic::Load();
- }
-diff -Naur xbmc-11.0.1/lib/DllAvCore.h xbmc-11.0.1.patch/lib/DllAvCore.h
---- xbmc-11.0.1/lib/DllAvCore.h 2012-03-21 23:57:39.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllAvCore.h 1970-01-01 01:00:00.000000000 +0100
-@@ -1,182 +0,0 @@
--#pragma once
--/*
-- * Copyright (C) 2005-2010 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, Inc., 51 Franklin Street, Fifth Floor,
-- * Boston, MA 02110-1301, USA.
-- * http://www.gnu.org/copyleft/gpl.html
-- *
-- */
--
--#if (defined HAVE_CONFIG_H) && (!defined WIN32)
-- #include "config.h"
--#endif
--#include "DynamicDll.h"
--#include "DllAvUtil.h"
--#include "utils/log.h"
--
--extern "C" {
--#ifdef USE_EXTERNAL_FFMPEG
-- #ifdef HAVE_LIBAVUTIL_SAMPLEFMT_H
-- // libavcore was merged to libavutil on 2010-02-15
-- #include
-- #include
-- #endif
--
-- #ifdef HAVE_LIBAVCORE_AVCORE_H
-- #include
-- #endif
-- #ifdef HAVE_LIBAVCORE_SAMPLEFMT_H
-- #include
-- #endif
--
-- /* Needed for old FFmpeg versions as used below */
-- #ifdef HAVE_LIBAVCODEC_AVCODEC_H
-- #include
-- #else
-- #include
-- #endif
--#else
-- #include "libavcore/avcore.h"
-- #include "libavcore/samplefmt.h"
--#endif
--}
--
--/* Compatibility for old external FFmpeg versions. */
--
--#ifdef USE_EXTERNAL_FFMPEG
--
--#ifndef LIBAVCORE_VERSION_INT
--// API added on: 2010-07-21, removed on 2010-02-15
--#define LIBAVCORE_VERSION_INT 0
--#endif
--
--#ifndef AV_SAMPLE_FMT_NONE
--// API added on: 2010-11-02
--#define AVSampleFormat SampleFormat
--#define AV_SAMPLE_FMT_NONE SAMPLE_FMT_NONE
--#define AV_SAMPLE_FMT_U8 SAMPLE_FMT_U8
--#define AV_SAMPLE_FMT_S16 SAMPLE_FMT_S16
--#define AV_SAMPLE_FMT_S32 SAMPLE_FMT_S32
--#define AV_SAMPLE_FMT_FLT SAMPLE_FMT_FLT
--#define AV_SAMPLE_FMT_DBL SAMPLE_FMT_DBL
--#endif
--
--#ifndef AV_CH_FRONT_LEFT
--// API added on: 2010-11-21
--#define AV_CH_FRONT_LEFT CH_FRONT_LEFT
--#define AV_CH_FRONT_RIGHT CH_FRONT_RIGHT
--#define AV_CH_FRONT_CENTER CH_FRONT_CENTER
--#define AV_CH_LOW_FREQUENCY CH_LOW_FREQUENCY
--#define AV_CH_BACK_LEFT CH_BACK_LEFT
--#define AV_CH_BACK_RIGHT CH_BACK_RIGHT
--#define AV_CH_FRONT_LEFT_OF_CENTER CH_FRONT_LEFT_OF_CENTER
--#define AV_CH_FRONT_RIGHT_OF_CENTER CH_FRONT_RIGHT_OF_CENTER
--#define AV_CH_BACK_CENTER CH_BACK_CENTER
--#define AV_CH_SIDE_LEFT CH_SIDE_LEFT
--#define AV_CH_SIDE_RIGHT CH_SIDE_RIGHT
--#define AV_CH_TOP_CENTER CH_TOP_CENTER
--#define AV_CH_TOP_FRONT_LEFT CH_TOP_FRONT_LEFT
--#define AV_CH_TOP_FRONT_CENTER CH_TOP_FRONT_CENTER
--#define AV_CH_TOP_FRONT_RIGHT CH_TOP_FRONT_RIGHT
--#define AV_CH_TOP_BACK_LEFT CH_TOP_BACK_LEFT
--#define AV_CH_TOP_BACK_CENTER CH_TOP_BACK_CENTER
--#define AV_CH_TOP_BACK_RIGHT CH_TOP_BACK_RIGHT
--#define AV_CH_STEREO_LEFT CH_STEREO_LEFT
--#define AV_CH_STEREO_RIGHT CH_STEREO_RIGHT
--
--#define AV_CH_LAYOUT_NATIVE CH_LAYOUT_NATIVE
--
--#define AV_CH_LAYOUT_MONO CH_LAYOUT_MONO
--#define AV_CH_LAYOUT_STEREO CH_LAYOUT_STEREO
--#define AV_CH_LAYOUT_2_1 CH_LAYOUT_2_1
--#define AV_CH_LAYOUT_SURROUND CH_LAYOUT_SURROUND
--#define AV_CH_LAYOUT_4POINT0 CH_LAYOUT_4POINT0
--#define AV_CH_LAYOUT_2_2 CH_LAYOUT_2_2
--#define AV_CH_LAYOUT_QUAD CH_LAYOUT_QUAD
--#define AV_CH_LAYOUT_5POINT0 CH_LAYOUT_5POINT0
--#define AV_CH_LAYOUT_5POINT1 CH_LAYOUT_5POINT1
--#define AV_CH_LAYOUT_5POINT0_BACK CH_LAYOUT_5POINT0_BACK
--#define AV_CH_LAYOUT_5POINT1_BACK CH_LAYOUT_5POINT1_BACK
--#define AV_CH_LAYOUT_7POINT0 CH_LAYOUT_7POINT0
--#define AV_CH_LAYOUT_7POINT1 CH_LAYOUT_7POINT1
--#define AV_CH_LAYOUT_7POINT1_WIDE CH_LAYOUT_7POINT1_WIDE
--#define AV_CH_LAYOUT_STEREO_DOWNMIX CH_LAYOUT_STEREO_DOWNMIX
--#endif
--
--#endif // USE_EXTERNAL_FFMPEG
--
--class DllAvCoreInterface
--{
--public:
-- virtual ~DllAvCoreInterface() {}
-- virtual int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) = 0;
--};
--
--#if (defined USE_EXTERNAL_FFMPEG)
--
--// Use direct layer
--class DllAvCore : public DllDynamic, DllAvCoreInterface
--{
--public:
-- virtual ~DllAvCore() {}
--#if LIBAVCORE_VERSION_INT >= AV_VERSION_INT(0,12,0) || LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(50,38,0)
-- // API added on: 2010-11-02, moved to libavutil on 2010-02-15
-- virtual int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) { return ::av_get_bits_per_sample_fmt(sample_fmt); }
--#else
-- // from avcodec.h
-- virtual int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) { return ::av_get_bits_per_sample_format(sample_fmt); }
--#endif
--
-- // DLL faking.
-- virtual bool ResolveExports() { return true; }
-- virtual bool Load() {
--#if LIBAVCORE_VERSION_INT > 0
-- CLog::Log(LOGDEBUG, "DllAvCore: Using libavcore system library");
--#endif
-- return true;
-- }
-- virtual void Unload() {}
--};
--
--#else
--
--class DllAvCore : public DllDynamic, DllAvCoreInterface
--{
-- DECLARE_DLL_WRAPPER(DllAvCore, DLL_PATH_LIBAVCORE)
--
-- LOAD_SYMBOLS()
--
-- DEFINE_METHOD1(int, av_get_bits_per_sample_fmt, (enum AVSampleFormat p1))
--
-- BEGIN_METHOD_RESOLVE()
-- RESOLVE_METHOD(av_get_bits_per_sample_fmt)
-- END_METHOD_RESOLVE()
--
-- /* dependency of libavcore */
-- DllAvUtil m_dllAvUtil;
--
--public:
-- virtual bool Load()
-- {
-- if (!m_dllAvUtil.Load())
-- return false;
-- return DllDynamic::Load();
-- }
--};
--
--#endif
--
-diff -Naur xbmc-11.0.1/lib/DllAvFilter.h xbmc-11.0.1.patch/lib/DllAvFilter.h
---- xbmc-11.0.1/lib/DllAvFilter.h 2012-03-21 23:57:39.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllAvFilter.h 2012-06-05 15:19:23.835494072 +0200
-@@ -24,8 +24,8 @@
- #include "config.h"
- #endif
- #include "DynamicDll.h"
--#include "DllAvCore.h"
- #include "DllAvCodec.h"
-+#include "DllSwResample.h"
- #include "utils/log.h"
-
- extern "C" {
-@@ -43,24 +43,17 @@
- #if (defined USE_EXTERNAL_FFMPEG)
- #if (defined HAVE_LIBAVFILTER_AVFILTER_H)
- #include
-+ #include
-+ #include
- #elif (defined HAVE_FFMPEG_AVFILTER_H)
- #include
-- #endif
-- /* for av_vsrc_buffer_add_frame */
-- #if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,8,0)
-- #include
-- #elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,7,0)
-- int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter,
-- AVFrame *frame);
-- #elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,3,0)
-- int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter,
-- AVFrame *frame, int64_t pts);
-- #else
-- int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter,
-- AVFrame *frame, int64_t pts, AVRational pixel_aspect);
-+ #include
-+ #include
- #endif
- #else
- #include "libavfilter/avfiltergraph.h"
-+ #include "libavfilter/buffersink.h"
-+ #include "libavfilter/avcodec.h"
- #endif
- }
-
-@@ -82,21 +75,16 @@
- virtual int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)=0;
- virtual int avfilter_poll_frame(AVFilterLink *link)=0;
- virtual int avfilter_request_frame(AVFilterLink *link)=0;
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,13,0)
- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int flags)=0;
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,7,0)
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame)=0;
--#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,3,0)
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts)=0;
--#else
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts, AVRational pixel_aspect)=0;
--#endif
- virtual AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)=0;
- virtual void avfilter_unref_buffer(AVFilterBufferRef *ref)=0;
- virtual int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)=0;
-+ virtual int av_buffersink_get_buffer_ref(AVFilterContext *buffer_sink, AVFilterBufferRef **bufref, int flags)=0;
-+ virtual AVBufferSinkParams *av_buffersink_params_alloc()=0;
-+ virtual int av_buffersink_poll_frame(AVFilterContext *ctx)=0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
- // Use direct mapping
- class DllAvFilter : public DllDynamic, DllAvFilterInterface
- {
-@@ -115,12 +103,7 @@
- virtual void avfilter_graph_free(AVFilterGraph **graph)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(1,76,0)
- ::avfilter_graph_free(graph);
--#else
-- ::avfilter_graph_free(*graph);
-- *graph = NULL;
--#endif
- }
- void avfilter_register_all()
- {
-@@ -133,56 +116,31 @@
- virtual AVFilterInOut *avfilter_inout_alloc()
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- return ::avfilter_inout_alloc();
--#else
-- return (AVFilterInOut*)::av_mallocz(sizeof(AVFilterInOut));
--#endif
- }
- virtual void avfilter_inout_free(AVFilterInOut **inout)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- ::avfilter_inout_free(inout);
--#else
-- *inout = NULL;
--#endif
- }
- virtual int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs, void *log_ctx)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if ( LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(1,79,0) \
-- && LIBAVFILTER_VERSION_INT < AV_VERSION_INT(2,0,0) ) \
-- ||( LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,16,0))
- return ::avfilter_graph_parse(graph, filters, inputs, outputs, log_ctx);
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
-- return ::avfilter_graph_parse(graph, filters, *inputs, *outputs, log_ctx);
--#else
-- return ::avfilter_graph_parse(graph, filters, *inputs, *outputs, (AVClass*)log_ctx);
--#endif
- }
- virtual int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
- {
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
- return ::avfilter_graph_config(graphctx, log_ctx);
--#else
-- return ::avfilter_graph_config(graphctx, (AVClass*)log_ctx);
--#endif
- }
- virtual int avfilter_poll_frame(AVFilterLink *link) { return ::avfilter_poll_frame(link); }
- virtual int avfilter_request_frame(AVFilterLink *link) { return ::avfilter_request_frame(link); }
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,13,0)
- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int flags) { return ::av_vsrc_buffer_add_frame(buffer_filter, frame, flags); }
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,7,0)
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame) { return ::av_vsrc_buffer_add_frame(buffer_filter, frame); }
--#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,3,0)
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts) { return ::av_vsrc_buffer_add_frame(buffer_filter, frame, pts); }
--#else
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts, AVRational pixel_aspect) { return ::av_vsrc_buffer_add_frame(buffer_filter, frame, pts, pixel_aspect); }
--#endif
- virtual AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h) { return ::avfilter_get_video_buffer(link, perms, w, h); }
- virtual void avfilter_unref_buffer(AVFilterBufferRef *ref) { ::avfilter_unref_buffer(ref); }
- virtual int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad) { return ::avfilter_link(src, srcpad, dst, dstpad); }
-+ virtual int av_buffersink_get_buffer_ref(AVFilterContext *buffer_sink, AVFilterBufferRef **bufref, int flags) { return ::av_buffersink_get_buffer_ref(buffer_sink, bufref, flags); }
-+ virtual AVBufferSinkParams *av_buffersink_params_alloc() { return ::av_buffersink_params_alloc(); }
-+ virtual int av_buffersink_poll_frame(AVFilterContext *ctx) { return av_buffersink_poll_frame(ctx); }
- // DLL faking.
- virtual bool ResolveExports() { return true; }
- virtual bool Load() {
-@@ -200,45 +158,24 @@
-
- DEFINE_METHOD3(int, avfilter_open_dont_call, (AVFilterContext **p1, AVFilter *p2, const char *p3))
- DEFINE_METHOD1(void, avfilter_free_dont_call, (AVFilterContext *p1))
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(1,76,0)
- DEFINE_METHOD1(void, avfilter_graph_free_dont_call, (AVFilterGraph **p1))
--#else
-- DEFINE_METHOD1(void, avfilter_graph_free_dont_call, (AVFilterGraph *p1))
--#endif
- DEFINE_METHOD0(void, avfilter_register_all_dont_call)
- DEFINE_METHOD6(int, avfilter_graph_create_filter, (AVFilterContext **p1, AVFilter *p2, const char *p3, const char *p4, void *p5, AVFilterGraph *p6))
- DEFINE_METHOD1(AVFilter*, avfilter_get_by_name, (const char *p1))
- DEFINE_METHOD0(AVFilterGraph*, avfilter_graph_alloc)
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- DEFINE_METHOD0(AVFilterInOut*, avfilter_inout_alloc_dont_call)
- DEFINE_METHOD1(void, avfilter_inout_free_dont_call, (AVFilterInOut **p1))
--#endif
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,16,0)
-- DEFINE_METHOD5(int, avfilter_graph_parse_dont_call, (AVFilterGraph *p1, const char *p2, AVFilterInOut **p3, AVFilterInOut **p4, void *p5))
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
-- DEFINE_METHOD5(int, avfilter_graph_parse_dont_call, (AVFilterGraph *p1, const char *p2, AVFilterInOut *p3, AVFilterInOut *p4, void *p5))
--#else
-- DEFINE_METHOD5(int, avfilter_graph_parse_dont_call, (AVFilterGraph *p1, const char *p2, AVFilterInOut *p3, AVFilterInOut *p4, AVClass *p5))
--#endif
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
-- DEFINE_METHOD2(int, avfilter_graph_config_dont_call, (AVFilterGraph *p1, void *p2))
--#else
-- DEFINE_METHOD2(int, avfilter_graph_config_dont_call, (AVFilterGraph *p1, AVClass *p2))
--#endif
-+ DEFINE_FUNC_ALIGNED5(int, __cdecl, avfilter_graph_parse_dont_call, AVFilterGraph *, const char *, AVFilterInOut **, AVFilterInOut **, void *)
-+ DEFINE_FUNC_ALIGNED2(int, __cdecl, avfilter_graph_config_dont_call, AVFilterGraph *, void *)
- DEFINE_FUNC_ALIGNED1(int, __cdecl, avfilter_poll_frame, AVFilterLink *)
- DEFINE_FUNC_ALIGNED1(int, __cdecl, avfilter_request_frame, AVFilterLink*)
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,13,0)
- DEFINE_METHOD3(int, av_vsrc_buffer_add_frame, (AVFilterContext *p1, AVFrame *p2, int p3))
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,7,0)
-- DEFINE_METHOD2(int, av_vsrc_buffer_add_frame, (AVFilterContext *p1, AVFrame *p2))
--#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,3,0)
-- DEFINE_METHOD3(int, av_vsrc_buffer_add_frame, (AVFilterContext *p1, AVFrame *p2, int64_t p3))
--#else
-- DEFINE_METHOD4(int, av_vsrc_buffer_add_frame, (AVFilterContext *p1, AVFrame *p2, int64_t p3, AVRational p4))
--#endif
- DEFINE_METHOD4(AVFilterBufferRef*, avfilter_get_video_buffer, (AVFilterLink *p1, int p2, int p3, int p4))
- DEFINE_METHOD1(void, avfilter_unref_buffer, (AVFilterBufferRef *p1))
- DEFINE_METHOD4(int, avfilter_link, (AVFilterContext *p1, unsigned p2, AVFilterContext *p3, unsigned p4))
-+ DEFINE_FUNC_ALIGNED3(int , __cdecl, av_buffersink_get_buffer_ref, AVFilterContext *, AVFilterBufferRef **, int);
-+ DEFINE_FUNC_ALIGNED0(AVBufferSinkParams*, __cdecl, av_buffersink_params_alloc);
-+ DEFINE_FUNC_ALIGNED1(int , __cdecl, av_buffersink_poll_frame, AVFilterContext *);
-
- BEGIN_METHOD_RESOLVE()
- RESOLVE_METHOD_RENAME(avfilter_open, avfilter_open_dont_call)
-@@ -248,10 +185,8 @@
- RESOLVE_METHOD(avfilter_graph_create_filter)
- RESOLVE_METHOD(avfilter_get_by_name)
- RESOLVE_METHOD(avfilter_graph_alloc)
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- RESOLVE_METHOD_RENAME(avfilter_inout_alloc, avfilter_inout_alloc_dont_call)
- RESOLVE_METHOD_RENAME(avfilter_inout_free, avfilter_inout_free_dont_call)
--#endif
- RESOLVE_METHOD_RENAME(avfilter_graph_parse, avfilter_graph_parse_dont_call)
- RESOLVE_METHOD_RENAME(avfilter_graph_config, avfilter_graph_config_dont_call)
- RESOLVE_METHOD(avfilter_poll_frame)
-@@ -260,10 +195,14 @@
- RESOLVE_METHOD(avfilter_get_video_buffer)
- RESOLVE_METHOD(avfilter_unref_buffer)
- RESOLVE_METHOD(avfilter_link)
-+ RESOLVE_METHOD(av_buffersink_get_buffer_ref)
-+ RESOLVE_METHOD(av_buffersink_params_alloc)
-+ RESOLVE_METHOD(av_buffersink_poll_frame)
- END_METHOD_RESOLVE()
-
- /* dependencies of libavfilter */
- DllAvUtil m_dllAvUtil;
-+ DllSwResample m_dllSwResample;
-
- public:
- int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
-@@ -279,12 +218,7 @@
- void avfilter_graph_free(AVFilterGraph **graph)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(1,76,0)
- avfilter_graph_free_dont_call(graph);
--#else
-- avfilter_graph_free_dont_call(*graph);
-- m_dllAvUtil.av_freep(graph);
--#endif
- }
- void avfilter_register_all()
- {
-@@ -294,45 +228,29 @@
- AVFilterInOut* avfilter_inout_alloc()
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- return avfilter_inout_alloc_dont_call();
--#else
-- return (AVFilterInOut*)m_dllAvUtil.av_mallocz(sizeof(AVFilterInOut));
--#endif
- }
- int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs, void *log_ctx)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,16,0)
- return avfilter_graph_parse_dont_call(graph, filters, inputs, outputs, log_ctx);
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
-- return avfilter_graph_parse_dont_call(graph, filters, *inputs, *outputs, log_ctx);
--#else
-- return avfilter_graph_parse_dont_call(graph, filters, *inputs, *outputs, (AVClass*)log_ctx);
--#endif
- }
- void avfilter_inout_free(AVFilterInOut **inout)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- avfilter_inout_free_dont_call(inout);
--#else
-- *inout = NULL;
--#endif
- }
- int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
- return avfilter_graph_config_dont_call(graphctx, log_ctx);
--#else
-- return avfilter_graph_config_dont_call(graphctx, (AVClass*)log_ctx);
--#endif
- }
- virtual bool Load()
- {
- if (!m_dllAvUtil.Load())
- return false;
-+ if (!m_dllSwResample.Load())
-+ return false;
- return DllDynamic::Load();
- }
- };
-diff -Naur xbmc-11.0.1/lib/DllAvFormat.h xbmc-11.0.1.patch/lib/DllAvFormat.h
---- xbmc-11.0.1/lib/DllAvFormat.h 2012-03-21 23:57:42.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllAvFormat.h 2012-06-05 15:19:23.837494112 +0200
-@@ -62,57 +62,45 @@
- virtual ~DllAvFormatInterface() {}
- virtual void av_register_all_dont_call(void)=0;
- virtual AVInputFormat *av_find_input_format(const char *short_name)=0;
-- virtual int url_feof(ByteIOContext *s)=0;
-- virtual AVMetadataTag *av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags)=0;
-- virtual void av_close_input_file(AVFormatContext *s)=0;
-- virtual void av_close_input_stream(AVFormatContext *s)=0;
-+ virtual int url_feof(AVIOContext *s)=0;
-+ virtual void avformat_close_input(AVFormatContext **s)=0;
- virtual int av_read_frame(AVFormatContext *s, AVPacket *pkt)=0;
- virtual void av_read_frame_flush(AVFormatContext *s)=0;
- virtual int av_read_play(AVFormatContext *s)=0;
- virtual int av_read_pause(AVFormatContext *s)=0;
- virtual int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)=0;
--#if (!defined USE_EXTERNAL_FFMPEG)
-- virtual int av_find_stream_info_dont_call(AVFormatContext *ic)=0;
-+#if (!defined USE_EXTERNAL_FFMPEG) && (!defined TARGET_DARWIN)
-+ virtual int avformat_find_stream_info_dont_call(AVFormatContext *ic, AVDictionary **options)=0;
- #endif
-- virtual int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, AVInputFormat *fmt, int buf_size, AVFormatParameters *ap)=0;
-- virtual void url_set_interrupt_cb(URLInterruptCB *interrupt_cb)=0;
-- virtual int av_open_input_stream(AVFormatContext **ic_ptr, ByteIOContext *pb, const char *filename, AVInputFormat *fmt, AVFormatParameters *ap)=0;
-- virtual int init_put_byte(ByteIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
-+ virtual int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)=0;
-+ virtual AVIOContext *avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
- int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
- int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
- offset_t (*seek)(void *opaque, offset_t offset, int whence))=0;
- virtual AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened)=0;
- virtual AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)=0;
-- virtual int av_probe_input_buffer(ByteIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)=0;
-- virtual void dump_format(AVFormatContext *ic, int index, const char *url, int is_output)=0;
-- virtual int url_fdopen(ByteIOContext **s, URLContext *h)=0;
-- virtual int url_fopen(ByteIOContext **s, const char *filename, int flags)=0;
-- virtual int url_fclose(ByteIOContext *s)=0;
-- virtual int url_open_dyn_buf(ByteIOContext **s)=0;
-- virtual int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer)=0;
-- virtual offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence)=0;
-- virtual int get_buffer(ByteIOContext *s, unsigned char *buf, int size)=0;
-- virtual int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size)=0;
-- virtual void put_byte(ByteIOContext *s, int b)=0;
-- virtual void put_buffer(ByteIOContext *s, const unsigned char *buf, int size)=0;
-- virtual void put_be24(ByteIOContext *s, unsigned int val)=0;
-- virtual void put_be32(ByteIOContext *s, unsigned int val)=0;
-- virtual void put_be16(ByteIOContext *s, unsigned int val)=0;
-+ virtual int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)=0;
-+ virtual void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)=0;
-+ virtual int avio_open(AVIOContext **s, const char *filename, int flags)=0;
-+ virtual int avio_close(AVIOContext *s)=0;
-+ virtual int avio_open_dyn_buf(AVIOContext **s)=0;
-+ virtual int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)=0;
-+ virtual offset_t avio_seek(AVIOContext *s, offset_t offset, int whence)=0;
-+ virtual int avio_read(AVIOContext *s, unsigned char *buf, int size)=0;
-+ virtual void avio_w8(AVIOContext *s, int b)=0;
-+ virtual void avio_write(AVIOContext *s, const unsigned char *buf, int size)=0;
-+ virtual void avio_wb24(AVIOContext *s, unsigned int val)=0;
-+ virtual void avio_wb32(AVIOContext *s, unsigned int val)=0;
-+ virtual void avio_wb16(AVIOContext *s, unsigned int val)=0;
- virtual AVFormatContext *avformat_alloc_context(void)=0;
-- virtual AVStream *av_new_stream(AVFormatContext *s, int id)=0;
-+ virtual AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)=0;
- virtual AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type)=0;
-- virtual int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap)=0;
-- virtual ByteIOContext *av_alloc_put_byte(unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
-- int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
-- int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
-- offset_t (*seek)(void *opaque, offset_t offset, int whence))=0;
-- virtual int av_write_header (AVFormatContext *s)=0;
-+ virtual int avformat_write_header (AVFormatContext *s, AVDictionary **options)=0;
- virtual int av_write_trailer(AVFormatContext *s)=0;
- virtual int av_write_frame (AVFormatContext *s, AVPacket *pkt)=0;
-- virtual int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags)=0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
-
- // Use direct mapping
- class DllAvFormat : public DllDynamic, DllAvFormatInterface
-@@ -126,78 +114,45 @@
- }
- virtual void av_register_all_dont_call() { *(int* )0x0 = 0; }
- virtual AVInputFormat *av_find_input_format(const char *short_name) { return ::av_find_input_format(short_name); }
-- virtual int url_feof(ByteIOContext *s) { return ::url_feof(s); }
--#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,31,0)
-- // API added on: 2009-03-01
-- virtual AVMetadataTag *av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags){ return ::av_metadata_get(m, key, prev, flags); }
--#else
-- virtual AVMetadataTag *av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags){ return NULL; }
--#endif
-- virtual void av_close_input_file(AVFormatContext *s) { ::av_close_input_file(s); }
-- virtual void av_close_input_stream(AVFormatContext *s) { ::av_close_input_stream(s); }
-+ virtual int url_feof(AVIOContext *s) { return ::url_feof(s); }
-+ virtual void avformat_close_input(AVFormatContext **s) { ::avformat_close_input(s); }
- virtual int av_read_frame(AVFormatContext *s, AVPacket *pkt) { return ::av_read_frame(s, pkt); }
- virtual void av_read_frame_flush(AVFormatContext *s) { ::av_read_frame_flush(s); }
- virtual int av_read_play(AVFormatContext *s) { return ::av_read_play(s); }
- virtual int av_read_pause(AVFormatContext *s) { return ::av_read_pause(s); }
- virtual int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { return ::av_seek_frame(s, stream_index, timestamp, flags); }
-- virtual int av_find_stream_info(AVFormatContext *ic)
-+ virtual int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
-- return ::av_find_stream_info(ic);
-+ return ::avformat_find_stream_info(ic, options);
- }
-- virtual int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, AVInputFormat *fmt, int buf_size, AVFormatParameters *ap) { return ::av_open_input_file(ic_ptr, filename, fmt, buf_size, ap); }
-- virtual void url_set_interrupt_cb(URLInterruptCB *interrupt_cb) { ::url_set_interrupt_cb(interrupt_cb); }
-- virtual int av_open_input_stream(AVFormatContext **ic_ptr, ByteIOContext *pb, const char *filename, AVInputFormat *fmt, AVFormatParameters *ap) { return ::av_open_input_stream(ic_ptr, pb, filename, fmt, ap); }
-- virtual int init_put_byte(ByteIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
-+ virtual int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
-+ { return ::avformat_open_input(ps, filename, fmt, options); }
-+ virtual AVIOContext *avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
- int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
- int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
-- offset_t (*seek)(void *opaque, offset_t offset, int whence)) { return ::init_put_byte(s, buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); }
-+ offset_t (*seek)(void *opaque, offset_t offset, int whence)) { return ::avio_alloc_context(buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); }
- virtual AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened) {return ::av_probe_input_format(pd, is_opened); }
- virtual AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max) {*score_max = 100; return ::av_probe_input_format(pd, is_opened); } // Use av_probe_input_format, this is not exported by ffmpeg's headers
--#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,98,0)
-- // API added on: 2010-02-08
-- virtual int av_probe_input_buffer(ByteIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size) { return ::av_probe_input_buffer(pb, fmt, filename, logctx, offset, max_probe_size); }
--#else
-- virtual int av_probe_input_buffer(ByteIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size) { return -1; }
--#endif
-- virtual void dump_format(AVFormatContext *ic, int index, const char *url, int is_output) { ::dump_format(ic, index, url, is_output); }
-- virtual int url_fdopen(ByteIOContext **s, URLContext *h) { return ::url_fdopen(s, h); }
-- virtual int url_fopen(ByteIOContext **s, const char *filename, int flags) { return ::url_fopen(s, filename, flags); }
-- virtual int url_fclose(ByteIOContext *s) { return ::url_fclose(s); }
-- virtual int url_open_dyn_buf(ByteIOContext **s) { return ::url_open_dyn_buf(s); }
-- virtual int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer) { return ::url_close_dyn_buf(s, pbuffer); }
-- virtual offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence) { return ::url_fseek(s, offset, whence); }
-- virtual int get_buffer(ByteIOContext *s, unsigned char *buf, int size) { return ::get_buffer(s, buf, size); }
-- virtual int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size) { return ::get_partial_buffer(s, buf, size); }
-- virtual void put_byte(ByteIOContext *s, int b) { ::put_byte(s, b); }
-- virtual void put_buffer(ByteIOContext *s, const unsigned char *buf, int size) { ::put_buffer(s, buf, size); }
-- virtual void put_be24(ByteIOContext *s, unsigned int val) { ::put_be24(s, val); }
-- virtual void put_be32(ByteIOContext *s, unsigned int val) { ::put_be32(s, val); }
-- virtual void put_be16(ByteIOContext *s, unsigned int val) { ::put_be16(s, val); }
-+ virtual int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size) { return ::av_probe_input_buffer(pb, fmt, filename, logctx, offset, max_probe_size); }
-+ virtual void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output) { ::av_dump_format(ic, index, url, is_output); }
-+ virtual int avio_open(AVIOContext **s, const char *filename, int flags) { return ::avio_open(s, filename, flags); }
-+ virtual int avio_close(AVIOContext *s) { return ::avio_close(s); }
-+ virtual int avio_open_dyn_buf(AVIOContext **s) { return ::avio_open_dyn_buf(s); }
-+ virtual int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) { return ::avio_close_dyn_buf(s, pbuffer); }
-+ virtual offset_t avio_seek(AVIOContext *s, offset_t offset, int whence) { return ::avio_seek(s, offset, whence); }
-+ virtual int avio_read(AVIOContext *s, unsigned char *buf, int size) { return ::avio_read(s, buf, size); }
-+ virtual void avio_w8(AVIOContext *s, int b) { ::avio_w8(s, b); }
-+ virtual void avio_write(AVIOContext *s, const unsigned char *buf, int size) { ::avio_write(s, buf, size); }
-+ virtual void avio_wb24(AVIOContext *s, unsigned int val) { ::avio_wb24(s, val); }
-+ virtual void avio_wb32(AVIOContext *s, unsigned int val) { ::avio_wb32(s, val); }
-+ virtual void avio_wb16(AVIOContext *s, unsigned int val) { ::avio_wb16(s, val); }
- virtual AVFormatContext *avformat_alloc_context() { return ::avformat_alloc_context(); }
-- virtual AVStream *av_new_stream(AVFormatContext *s, int id) { return ::av_new_stream(s, id); }
--#if LIBAVFORMAT_VERSION_INT < (52<<16 | 45<<8)
-- virtual AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type) { return ::guess_format(short_name, filename, mime_type); }
--#else
-+ virtual AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c) { return ::avformat_new_stream(s, c); }
- virtual AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type) { return ::av_guess_format(short_name, filename, mime_type); }
--#endif
-- virtual int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap) { return ::av_set_parameters(s, ap); }
-- virtual ByteIOContext *av_alloc_put_byte(unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
-- int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
-- int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
-- offset_t (*seek)(void *opaque, offset_t offset, int whence)) { return ::av_alloc_put_byte(buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); }
-- virtual int av_write_header (AVFormatContext *s) { return ::av_write_header (s); }
-+ virtual int avformat_write_header (AVFormatContext *s, AVDictionary **options) { return ::avformat_write_header (s, options); }
- virtual int av_write_trailer(AVFormatContext *s) { return ::av_write_trailer(s); }
- virtual int av_write_frame (AVFormatContext *s, AVPacket *pkt) { return ::av_write_frame(s, pkt); }
--#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,43,0)
-- // API added on: 2009-12-13
-- virtual int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags) { return ::av_metadata_set2(pm, key, value, flags); }
--#elif LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,31,0)
-- // API added on: 2009-03-01
-- virtual int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags) { return ::av_metadata_set(pm, key, value); }
--#else
-- virtual int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags) { return -1; }
--#endif
-
- // DLL faking.
- virtual bool ResolveExports() { return true; }
-@@ -218,108 +173,78 @@
-
- DEFINE_METHOD0(void, av_register_all_dont_call)
- DEFINE_METHOD1(AVInputFormat*, av_find_input_format, (const char *p1))
-- DEFINE_METHOD1(int, url_feof, (ByteIOContext *p1))
-- DEFINE_METHOD4(AVMetadataTag*, av_metadata_get, (AVMetadata *p1, const char *p2, const AVMetadataTag *p3, int p4))
-- DEFINE_METHOD1(void, av_close_input_file, (AVFormatContext *p1))
-- DEFINE_METHOD1(void, av_close_input_stream, (AVFormatContext *p1))
-+ DEFINE_METHOD1(int, url_feof, (AVIOContext *p1))
-+ DEFINE_METHOD1(void, avformat_close_input, (AVFormatContext **p1))
- DEFINE_METHOD1(int, av_read_play, (AVFormatContext *p1))
- DEFINE_METHOD1(int, av_read_pause, (AVFormatContext *p1))
- DEFINE_METHOD1(void, av_read_frame_flush, (AVFormatContext *p1))
- DEFINE_FUNC_ALIGNED2(int, __cdecl, av_read_frame, AVFormatContext *, AVPacket *)
- DEFINE_FUNC_ALIGNED4(int, __cdecl, av_seek_frame, AVFormatContext*, int, int64_t, int)
-- DEFINE_FUNC_ALIGNED1(int, __cdecl, av_find_stream_info_dont_call, AVFormatContext*)
-- DEFINE_FUNC_ALIGNED5(int, __cdecl, av_open_input_file, AVFormatContext**, const char *, AVInputFormat *, int, AVFormatParameters *)
-- DEFINE_FUNC_ALIGNED5(int,__cdecl, av_open_input_stream, AVFormatContext **, ByteIOContext *, const char *, AVInputFormat *, AVFormatParameters *)
-+ DEFINE_FUNC_ALIGNED2(int, __cdecl, avformat_find_stream_info_dont_call, AVFormatContext*, AVDictionary **)
-+ DEFINE_FUNC_ALIGNED4(int, __cdecl, avformat_open_input, AVFormatContext **, const char *, AVInputFormat *, AVDictionary **)
- DEFINE_FUNC_ALIGNED2(AVInputFormat*, __cdecl, av_probe_input_format, AVProbeData*, int)
- DEFINE_FUNC_ALIGNED3(AVInputFormat*, __cdecl, av_probe_input_format2, AVProbeData*, int, int*)
-- DEFINE_FUNC_ALIGNED6(int, __cdecl, av_probe_input_buffer, ByteIOContext *, AVInputFormat **, const char *, void *, unsigned int, unsigned int)
-- DEFINE_FUNC_ALIGNED3(int, __cdecl, get_buffer, ByteIOContext*, unsigned char *, int)
-- DEFINE_FUNC_ALIGNED3(int, __cdecl, get_partial_buffer, ByteIOContext*, unsigned char *, int)
-- DEFINE_FUNC_ALIGNED2(void, __cdecl, put_byte, ByteIOContext*, int)
-- DEFINE_FUNC_ALIGNED3(void, __cdecl, put_buffer, ByteIOContext*, const unsigned char *, int)
-- DEFINE_FUNC_ALIGNED2(void, __cdecl, put_be24, ByteIOContext*, unsigned int)
-- DEFINE_FUNC_ALIGNED2(void, __cdecl, put_be32, ByteIOContext*, unsigned int)
-- DEFINE_FUNC_ALIGNED2(void, __cdecl, put_be16, ByteIOContext*, unsigned int)
-- DEFINE_METHOD1(void, url_set_interrupt_cb, (URLInterruptCB *p1))
-- DEFINE_METHOD8(int, init_put_byte, (ByteIOContext *p1, unsigned char *p2, int p3, int p4, void *p5,
-+ DEFINE_FUNC_ALIGNED6(int, __cdecl, av_probe_input_buffer, AVIOContext *, AVInputFormat **, const char *, void *, unsigned int, unsigned int)
-+ DEFINE_FUNC_ALIGNED3(int, __cdecl, avio_read, AVIOContext*, unsigned char *, int)
-+ DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_w8, AVIOContext*, int)
-+ DEFINE_FUNC_ALIGNED3(void, __cdecl, avio_write, AVIOContext*, const unsigned char *, int)
-+ DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_wb24, AVIOContext*, unsigned int)
-+ DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_wb32, AVIOContext*, unsigned int)
-+ DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_wb16, AVIOContext*, unsigned int)
-+ DEFINE_METHOD7(AVIOContext *, avio_alloc_context, (unsigned char *p1, int p2, int p3, void *p4,
-+ int (*p5)(void *opaque, uint8_t *buf, int buf_size),
- int (*p6)(void *opaque, uint8_t *buf, int buf_size),
-- int (*p7)(void *opaque, uint8_t *buf, int buf_size),
-- offset_t (*p8)(void *opaque, offset_t offset, int whence)))
-- DEFINE_METHOD4(void, dump_format, (AVFormatContext *p1, int p2, const char *p3, int p4))
-- DEFINE_METHOD2(int, url_fdopen, (ByteIOContext **p1, URLContext *p2))
-- DEFINE_METHOD3(int, url_fopen, (ByteIOContext **p1, const char *p2, int p3))
-- DEFINE_METHOD1(int, url_fclose, (ByteIOContext *p1))
-- DEFINE_METHOD1(int, url_open_dyn_buf, (ByteIOContext **p1))
-- DEFINE_METHOD2(int, url_close_dyn_buf, (ByteIOContext *p1, uint8_t **p2))
-- DEFINE_METHOD3(offset_t, url_fseek, (ByteIOContext *p1, offset_t p2, int p3))
-+ offset_t (*p7)(void *opaque, offset_t offset, int whence)))
-+ DEFINE_METHOD4(void, av_dump_format, (AVFormatContext *p1, int p2, const char *p3, int p4))
-+ DEFINE_METHOD3(int, avio_open, (AVIOContext **p1, const char *p2, int p3))
-+ DEFINE_METHOD1(int, avio_close, (AVIOContext *p1))
-+ DEFINE_METHOD1(int, avio_open_dyn_buf, (AVIOContext **p1))
-+ DEFINE_METHOD2(int, avio_close_dyn_buf, (AVIOContext *p1, uint8_t **p2))
-+ DEFINE_METHOD3(offset_t, avio_seek, (AVIOContext *p1, offset_t p2, int p3))
- DEFINE_METHOD0(AVFormatContext *, avformat_alloc_context)
-- DEFINE_METHOD2(AVStream *, av_new_stream, (AVFormatContext *p1, int p2))
--#if LIBAVFORMAT_VERSION_INT < (52<<16 | 45<<8)
-- DEFINE_METHOD3(AVOutputFormat *, guess_format, (const char *p1, const char *p2, const char *p3))
--#else
-+ DEFINE_METHOD2(AVStream *, avformat_new_stream, (AVFormatContext *p1, AVCodec *p2))
- DEFINE_METHOD3(AVOutputFormat *, av_guess_format, (const char *p1, const char *p2, const char *p3))
--#endif
-- DEFINE_METHOD2(int, av_set_parameters, (AVFormatContext *p1, AVFormatParameters *p2));
-- DEFINE_METHOD7(ByteIOContext *, av_alloc_put_byte, (unsigned char *p1, int p2, int p3, void *p4,
-- int(*p5)(void *opaque, uint8_t *buf, int buf_size),
-- int(*p6)(void *opaque, uint8_t *buf, int buf_size),
-- offset_t(*p7)(void *opaque, offset_t offset, int whence)))
-- DEFINE_METHOD1(int, av_write_header , (AVFormatContext *p1))
-+ DEFINE_METHOD2(int, avformat_write_header , (AVFormatContext *p1, AVDictionary **p2))
- DEFINE_METHOD1(int, av_write_trailer, (AVFormatContext *p1))
- DEFINE_METHOD2(int, av_write_frame , (AVFormatContext *p1, AVPacket *p2))
-- DEFINE_METHOD4(int, av_metadata_set2, (AVMetadata **p1, const char *p2, const char *p3, int p4));
- BEGIN_METHOD_RESOLVE()
- RESOLVE_METHOD_RENAME(av_register_all, av_register_all_dont_call)
- RESOLVE_METHOD(av_find_input_format)
- RESOLVE_METHOD(url_feof)
-- RESOLVE_METHOD(av_metadata_get)
-- RESOLVE_METHOD(av_close_input_file)
-- RESOLVE_METHOD(av_close_input_stream)
-+ RESOLVE_METHOD(avformat_close_input)
- RESOLVE_METHOD(av_read_frame)
- RESOLVE_METHOD(av_read_play)
- RESOLVE_METHOD(av_read_pause)
-- RESOLVE_METHOD_RENAME(ff_read_frame_flush, av_read_frame_flush)
-+ RESOLVE_METHOD(av_read_frame_flush)
- RESOLVE_METHOD(av_seek_frame)
-- RESOLVE_METHOD_RENAME(av_find_stream_info, av_find_stream_info_dont_call)
-- RESOLVE_METHOD(av_open_input_file)
-- RESOLVE_METHOD(url_set_interrupt_cb)
-- RESOLVE_METHOD(av_open_input_stream)
-- RESOLVE_METHOD(init_put_byte)
-+ RESOLVE_METHOD_RENAME(avformat_find_stream_info, avformat_find_stream_info_dont_call)
-+ RESOLVE_METHOD(avformat_open_input)
-+ RESOLVE_METHOD(avio_alloc_context)
- RESOLVE_METHOD(av_probe_input_format)
- RESOLVE_METHOD(av_probe_input_format2)
- RESOLVE_METHOD(av_probe_input_buffer)
-- RESOLVE_METHOD(dump_format)
-- RESOLVE_METHOD(url_fdopen)
-- RESOLVE_METHOD(url_fopen)
-- RESOLVE_METHOD(url_fclose)
-- RESOLVE_METHOD(url_open_dyn_buf)
-- RESOLVE_METHOD(url_close_dyn_buf)
-- RESOLVE_METHOD(url_fseek)
-- RESOLVE_METHOD(get_buffer)
-- RESOLVE_METHOD(get_partial_buffer)
-- RESOLVE_METHOD(put_byte)
-- RESOLVE_METHOD(put_buffer)
-- RESOLVE_METHOD(put_be24)
-- RESOLVE_METHOD(put_be32)
-- RESOLVE_METHOD(put_be16)
-+ RESOLVE_METHOD(av_dump_format)
-+ RESOLVE_METHOD(avio_open)
-+ RESOLVE_METHOD(avio_close)
-+ RESOLVE_METHOD(avio_open_dyn_buf)
-+ RESOLVE_METHOD(avio_close_dyn_buf)
-+ RESOLVE_METHOD(avio_seek)
-+ RESOLVE_METHOD(avio_read)
-+ RESOLVE_METHOD(avio_w8)
-+ RESOLVE_METHOD(avio_write)
-+ RESOLVE_METHOD(avio_wb24)
-+ RESOLVE_METHOD(avio_wb32)
-+ RESOLVE_METHOD(avio_wb16)
- RESOLVE_METHOD(avformat_alloc_context)
-- RESOLVE_METHOD(av_new_stream)
--#if LIBAVFORMAT_VERSION_INT < (52<<16 | 45<<8)
-- RESOLVE_METHOD(guess_format)
--#else
-+ RESOLVE_METHOD(avformat_new_stream)
- RESOLVE_METHOD(av_guess_format)
--#endif
-- RESOLVE_METHOD(av_set_parameters)
-- RESOLVE_METHOD(av_alloc_put_byte)
-- RESOLVE_METHOD(av_write_header)
-+ RESOLVE_METHOD(avformat_write_header)
- RESOLVE_METHOD(av_write_trailer)
- RESOLVE_METHOD(av_write_frame)
-- RESOLVE_METHOD(av_metadata_set2)
- END_METHOD_RESOLVE()
-
- /* dependencies of libavformat */
- DllAvCodec m_dllAvCodec;
-- // DllAvCore loaded implicitely by m_dllAvCodec
- // DllAvUtil loaded implicitely by m_dllAvCodec
-
- public:
-@@ -328,10 +253,10 @@
- CSingleLock lock(DllAvCodec::m_critSection);
- av_register_all_dont_call();
- }
-- int av_find_stream_info(AVFormatContext *ic)
-+ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
-- return(av_find_stream_info_dont_call(ic));
-+ return avformat_find_stream_info_dont_call(ic, options);
- }
-
- virtual bool Load()
-diff -Naur xbmc-11.0.1/lib/DllAvUtil.h xbmc-11.0.1.patch/lib/DllAvUtil.h
---- xbmc-11.0.1/lib/DllAvUtil.h 2012-03-21 23:57:41.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllAvUtil.h 2012-06-05 15:19:23.837494112 +0200
-@@ -65,6 +65,7 @@
- #include "libavutil/opt.h"
- #include "libavutil/mem.h"
- #include "libavutil/fifo.h"
-+ #include "libavutil/samplefmt.h"
- #endif
- }
-
-@@ -89,7 +90,7 @@
- virtual int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)=0;
- virtual const AVCRC* av_crc_get_table(AVCRCId crc_id)=0;
- virtual uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)=0;
-- virtual int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out)=0;
-+ virtual int av_opt_set(void *obj, const char *name, const char *val, int search_flags)=0;
- virtual AVFifoBuffer *av_fifo_alloc(unsigned int size) = 0;
- virtual void av_fifo_free(AVFifoBuffer *f) = 0;
- virtual void av_fifo_reset(AVFifoBuffer *f) = 0;
-@@ -97,10 +98,13 @@
- virtual int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int)) = 0;
- virtual int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int)) = 0;
- virtual char *av_strdup(const char *s)=0;
-+ virtual int av_get_bytes_per_sample(enum AVSampleFormat p1) = 0;
-+ virtual AVDictionaryEntry *av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags) = 0;
-+ virtual int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)=0;
-+ virtual int av_samples_get_buffer_size (int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align) = 0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
--
-+#if defined (USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
- // Use direct layer
- class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
- {
-@@ -117,12 +121,7 @@
- virtual int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) { return ::av_rescale_q(a, bq, cq); }
- virtual const AVCRC* av_crc_get_table(AVCRCId crc_id) { return ::av_crc_get_table(crc_id); }
- virtual uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length) { return ::av_crc(ctx, crc, buffer, length); }
--#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,7,0)
-- // API added on: 2008-12-16
-- virtual int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out) { return ::av_set_string3(obj, name, val, alloc, o_out); }
--#else
-- virtual int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out) { return AVERROR(ENOENT); }
--#endif
-+ virtual int av_opt_set(void *obj, const char *name, const char *val, int search_flags) { return ::av_opt_set(obj, name, val, search_flags); }
- virtual AVFifoBuffer *av_fifo_alloc(unsigned int size) {return ::av_fifo_alloc(size); }
- virtual void av_fifo_free(AVFifoBuffer *f) { ::av_fifo_free(f); }
- virtual void av_fifo_reset(AVFifoBuffer *f) { ::av_fifo_reset(f); }
-@@ -132,6 +131,12 @@
- virtual int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int))
- { return ::av_fifo_generic_write(f, src, size, func); }
- virtual char *av_strdup(const char *s) { return ::av_strdup(s); }
-+ virtual int av_get_bytes_per_sample(enum AVSampleFormat p1)
-+ { return ::av_get_bytes_per_sample(p1); }
-+ virtual AVDictionaryEntry *av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags){ return ::av_dict_get(m, key, prev, flags); }
-+ virtual int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags) { return ::av_dict_set(pm, key, value, flags); }
-+ virtual int av_samples_get_buffer_size (int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
-+ { return ::av_samples_get_buffer_size(linesize, nb_channels, nb_samples, sample_fmt, align); }
-
- // DLL faking.
- virtual bool ResolveExports() { return true; }
-@@ -160,7 +165,7 @@
- DEFINE_METHOD3(int64_t, av_rescale_q, (int64_t p1, AVRational p2, AVRational p3));
- DEFINE_METHOD1(const AVCRC*, av_crc_get_table, (AVCRCId p1))
- DEFINE_METHOD4(uint32_t, av_crc, (const AVCRC *p1, uint32_t p2, const uint8_t *p3, size_t p4));
-- DEFINE_METHOD5(int, av_set_string3, (void *p1, const char *p2, const char *p3, int p4, const AVOption **p5));
-+ DEFINE_METHOD4(int, av_opt_set, (void *p1, const char *p2, const char *p3, int p4));
- DEFINE_METHOD1(AVFifoBuffer*, av_fifo_alloc, (unsigned int p1))
- DEFINE_METHOD1(void, av_fifo_free, (AVFifoBuffer *p1))
- DEFINE_METHOD1(void, av_fifo_reset, (AVFifoBuffer *p1))
-@@ -168,6 +173,10 @@
- DEFINE_METHOD4(int, av_fifo_generic_read, (AVFifoBuffer *p1, void *p2, int p3, void (*p4)(void*, void*, int)))
- DEFINE_METHOD4(int, av_fifo_generic_write, (AVFifoBuffer *p1, void *p2, int p3, int (*p4)(void*, void*, int)))
- DEFINE_METHOD1(char*, av_strdup, (const char *p1))
-+ DEFINE_METHOD1(int, av_get_bytes_per_sample, (enum AVSampleFormat p1))
-+ DEFINE_METHOD4(AVDictionaryEntry *, av_dict_get, (AVDictionary *p1, const char *p2, const AVDictionaryEntry *p3, int p4))
-+ DEFINE_METHOD4(int, av_dict_set, (AVDictionary **p1, const char *p2, const char *p3, int p4));
-+ DEFINE_METHOD5(int, av_samples_get_buffer_size, (int *p1, int p2, int p3, enum AVSampleFormat p4, int p5))
-
- public:
- BEGIN_METHOD_RESOLVE()
-@@ -181,7 +190,7 @@
- RESOLVE_METHOD(av_rescale_q)
- RESOLVE_METHOD(av_crc_get_table)
- RESOLVE_METHOD(av_crc)
-- RESOLVE_METHOD(av_set_string3)
-+ RESOLVE_METHOD(av_opt_set)
- RESOLVE_METHOD(av_fifo_alloc)
- RESOLVE_METHOD(av_fifo_free)
- RESOLVE_METHOD(av_fifo_reset)
-@@ -189,6 +198,10 @@
- RESOLVE_METHOD(av_fifo_generic_read)
- RESOLVE_METHOD(av_fifo_generic_write)
- RESOLVE_METHOD(av_strdup)
-+ RESOLVE_METHOD(av_get_bytes_per_sample)
-+ RESOLVE_METHOD(av_dict_get)
-+ RESOLVE_METHOD(av_dict_set)
-+ RESOLVE_METHOD(av_samples_get_buffer_size)
- END_METHOD_RESOLVE()
- };
-
-diff -Naur xbmc-11.0.1/lib/DllPostProc.h xbmc-11.0.1.patch/lib/DllPostProc.h
---- xbmc-11.0.1/lib/DllPostProc.h 2012-03-21 23:57:44.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllPostProc.h 2012-06-05 15:19:23.870494772 +0200
-@@ -87,7 +87,7 @@
- virtual void pp_free_context(pp_context *ppContext)=0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
-
- // We call directly.
- class DllPostProc : public DllDynamic, DllPostProcInterface
-diff -Naur xbmc-11.0.1/lib/DllSwResample.h xbmc-11.0.1.patch/lib/DllSwResample.h
---- xbmc-11.0.1/lib/DllSwResample.h 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllSwResample.h 2012-06-05 15:19:23.870494772 +0200
-@@ -0,0 +1,87 @@
-+#pragma once
-+/*
-+ * Copyright (C) 2005-2010 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
-+ *
-+ */
-+
-+#if (defined HAVE_CONFIG_H) && (!defined WIN32)
-+ #include "config.h"
-+#endif
-+#include "DynamicDll.h"
-+
-+extern "C" {
-+#ifndef HAVE_MMX
-+#define HAVE_MMX
-+#endif
-+#ifndef __STDC_CONSTANT_MACROS
-+#define __STDC_CONSTANT_MACROS
-+#endif
-+#ifndef __GNUC__
-+#pragma warning(disable:4244)
-+#endif
-+#if (defined USE_EXTERNAL_FFMPEG)
-+ #include
-+#else
-+ #include "libswresample/swresample.h"
-+#endif
-+}
-+
-+
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
-+
-+// Use direct mapping
-+class DllSwResample : public DllDynamic
-+{
-+public:
-+ virtual ~DllSwResample() {}
-+
-+ // DLL faking.
-+ virtual bool ResolveExports() { return true; }
-+ virtual bool Load() {
-+ CLog::Log(LOGDEBUG, "DllAvFormat: Using libswresample system library");
-+ return true;
-+ }
-+ virtual void Unload() {}
-+};
-+
-+#else
-+
-+class DllSwResample : public DllDynamic
-+{
-+ DECLARE_DLL_WRAPPER(DllSwResample, DLL_PATH_LIBSWRESAMPLE)
-+
-+ LOAD_SYMBOLS()
-+
-+ BEGIN_METHOD_RESOLVE()
-+ END_METHOD_RESOLVE()
-+
-+ /* dependencies of libavformat */
-+ DllAvUtil m_dllAvUtil;
-+
-+public:
-+
-+ virtual bool Load()
-+ {
-+ if (!m_dllAvUtil.Load())
-+ return false;
-+ return DllDynamic::Load();
-+ }
-+};
-+
-+#endif
-diff -Naur xbmc-11.0.1/lib/DllSwScale.h xbmc-11.0.1.patch/lib/DllSwScale.h
---- xbmc-11.0.1/lib/DllSwScale.h 2012-03-21 23:57:39.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllSwScale.h 2012-06-05 15:19:23.871494792 +0200
-@@ -92,7 +92,7 @@
- virtual void sws_freeContext(struct SwsContext *context)=0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
-
- // We call into this library directly.
- class DllSwScale : public DllDynamic, public DllSwScaleInterface
-diff -Naur xbmc-11.0.1/lib/Makefile.in xbmc-11.0.1.patch/lib/Makefile.in
---- xbmc-11.0.1/lib/Makefile.in 2012-03-21 23:57:41.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/Makefile.in 2012-06-05 15:19:23.880494972 +0200
-@@ -1,21 +1,18 @@
- ARCH=@ARCH@
-
-+AR=@AR@
- LD=@LD@
- CC=@CC@
- CXX=@CXX@
--SHELL=@SHELL@
--ifeq ($(findstring osx,$(ARCH)),osx)
--ifeq ($(findstring arm,$(ARCH)),arm)
--LDFLAGS=-arch armv7 -iphoneos_version_min 4.1 -bundle -undefined dynamic_lookup -read_only_relocs suppress
--else
--LDFLAGS=-bundle -undefined dynamic_lookup -read_only_relocs suppress
--endif
--else
--LDFLAGS=-shared -fPIC -rdynamic
--endif
- SYSDIR=@abs_top_srcdir@/system/players/dvdplayer
--WRAPPER=@abs_top_srcdir@/xbmc/cores/DllLoader/exports/wrapper.o
--WRAPPER_MACH_ALIAS=@abs_top_srcdir@/xbmc/cores/DllLoader/exports/wrapper_mach_alias
-+
-+AVFORMAT_SO=avformat-53-$(ARCH).so
-+AVCODEC_SO=avcodec-53-$(ARCH).so
-+AVUTIL_SO=avutil-51-$(ARCH).so
-+AVFILTER_SO=avfilter-2-$(ARCH).so
-+SWSCALE_SO=swscale-2-$(ARCH).so
-+POSTPROC_SO=postproc-52-$(ARCH).so
-+SWRESAMPLE_SO=swresample-0-$(ARCH).so
-
- DIRS=
- ifneq (@USE_EXTERNAL_FFMPEG@,1)
-@@ -24,123 +21,55 @@
-
- LIBS=
- ifneq (@USE_EXTERNAL_FFMPEG@,1)
-- LIBS+=avutil-50-$(ARCH).so \
-- avcodec-52-$(ARCH).so \
-- avcore-0-$(ARCH).so \
-- avformat-52-$(ARCH).so \
-- postproc-51-$(ARCH).so \
-- avfilter-1-$(ARCH).so \
-- swscale-0-$(ARCH).so
--endif
--
--ifneq (,$(findstring powerpc,$(ARCH)))
-- ARCH_DIR=ppc
--else
--ifeq ($(findstring arm,$(ARCH)),arm)
-- ARCH_DIR=arm
--else
-- ARCH_DIR=x86
--endif
-+ LIBS+=$(AVUTIL_SO) \
-+ $(AVCODEC_SO) \
-+ $(AVFORMAT_SO) \
-+ $(POSTPROC_SO) \
-+ $(AVFILTER_SO) \
-+ $(SWSCALE_SO) \
-+ $(SWRESAMPLE_SO)
- endif
-
- .PHONY: $(DIRS) codecs
-
--codecs: $(addprefix $(SYSDIR)/, $(LIBS));
--
--
--ifeq ($(findstring osx,$(ARCH)), osx)
--# Add -lbundle1.o for powerpc-osx
--ifeq ($(ARCH), powerpc-osx)
--BUNDLE1_O = -lbundle1.o
--endif
--
--$(SYSDIR)/avutil-50-$(ARCH).so: $(WRAPPER) ffmpeg/libavutil/libavutil.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavutil/*.o \
-- ffmpeg/libavutil/$(ARCH_DIR)/*.o $(BUNDLE1_O)
--
--$(SYSDIR)/avcodec-52-$(ARCH).so: $(WRAPPER) ffmpeg/libavcodec/libavcodec.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavcodec/*.o \
-- ffmpeg/libavcodec/$(ARCH_DIR)/*.o $(BUNDLE1_O)
--
--$(SYSDIR)/avcore-0-$(ARCH).so: $(WRAPPER) ffmpeg/libavcore/libavcore.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavcore/*.o $(BUNDLE1_O)
--
--$(SYSDIR)/avformat-52-$(ARCH).so: $(WRAPPER) ffmpeg/libavformat/libavformat.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavformat/*.o $(BUNDLE1_O)
--
--ifeq ($(findstring x86,$(ARCH_DIR)), x86)
--$(SYSDIR)/avfilter-1-$(ARCH).so: $(WRAPPER) ffmpeg/libavfilter/libavfilter.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavfilter/$(ARCH_DIR)/*.o \
-- ffmpeg/libavfilter/*.o $(BUNDLE1_O)
--else # No libavfilter/ppc or libavfilter/arm
--$(SYSDIR)/avfilter-1-$(ARCH).so: $(WRAPPER) ffmpeg/libavfilter/libavfilter.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavfilter/*.o $(BUNDLE1_O)
--endif
-+ifneq ($(findstring osx,$(ARCH)), osx)
-
--ifneq ($(findstring arm,$(ARCH)), arm)
--$(SYSDIR)/swscale-0-$(ARCH).so: $(WRAPPER) ffmpeg/libswscale/libswscale.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libswscale/*.o \
-- ffmpeg/libswscale/$(ARCH_DIR)/*.o $(BUNDLE1_O)
--else # No ARM version of swscale available yet.
--$(SYSDIR)/swscale-0-$(ARCH).so: $(WRAPPER) ffmpeg/libswscale/libswscale.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libswscale/*.o
--endif
--
--$(SYSDIR)/postproc-51-$(ARCH).so: $(WRAPPER) ffmpeg/libpostproc/libpostproc.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libpostproc/*.o $(BUNDLE1_O)
--
--ffmpeg/libavutil/libavutil.dylib : ffmpeg;
--ffmpeg/libavcodec/libavcodec.dylib : ffmpeg;
--ffmpeg/libavcore/libavcore.dylib : ffmpeg;
--ffmpeg/libavformat/libavformat.dylib : ffmpeg;
--ffmpeg/libavformat/libavfilter.dylib : ffmpeg;
--ffmpeg/libswscale/libswscale.dylib : ffmpeg;
--ffmpeg/libpostproc/libpostproc.dylib : ffmpeg;
--ffmpeg:
-- $(MAKE) -C $@
--
--else
-+codecs: $(addprefix $(SYSDIR)/, $(LIBS));
-
--$(SYSDIR)/avutil-50-$(ARCH).so: ffmpeg/libavutil/libavutil.so
-+$(SYSDIR)/$(AVUTIL_SO): ffmpeg/libavutil/libavutil.so
- cp ffmpeg/libavutil/libavutil.so $@
-
--$(SYSDIR)/avcodec-52-$(ARCH).so: $(WRAPPER) ffmpeg/libavcodec/libavcodec.so
-+$(SYSDIR)/$(AVCODEC_SO): ffmpeg/libavcodec/libavcodec.so
- cp ffmpeg/libavcodec/libavcodec.so $@
-
--$(SYSDIR)/avcore-0-$(ARCH).so: $(WRAPPER) ffmpeg/libavcore/libavcore.so
-- cp ffmpeg/libavcore/libavcore.so $@
--
--$(SYSDIR)/avformat-52-$(ARCH).so: $(WRAPPER) ffmpeg/libavformat/libavformat.so
-+$(SYSDIR)/$(AVFORMAT_SO): ffmpeg/libavformat/libavformat.so
- cp ffmpeg/libavformat/libavformat.so $@
-
--$(SYSDIR)/avfilter-1-$(ARCH).so: $(WRAPPER) ffmpeg/libavfilter/libavfilter.so
-+$(SYSDIR)/$(AVFILTER_SO): ffmpeg/libavfilter/libavfilter.so
- cp ffmpeg/libavfilter/libavfilter.so $@
-
--$(SYSDIR)/swscale-0-$(ARCH).so: $(WRAPPER) ffmpeg/libswscale/libswscale.so
-+$(SYSDIR)/$(SWSCALE_SO): ffmpeg/libswscale/libswscale.so
- cp ffmpeg/libswscale/libswscale.so $@
-
--$(SYSDIR)/postproc-51-$(ARCH).so: $(WRAPPER) ffmpeg/libpostproc/libpostproc.so
-+$(SYSDIR)/$(POSTPROC_SO): ffmpeg/libpostproc/libpostproc.so
- cp ffmpeg/libpostproc/libpostproc.so $@
-
-+$(SYSDIR)/$(SWRESAMPLE_SO): ffmpeg/libswresample/libswresample.so
-+ cp ffmpeg/libswresample/libswresample.so $@
-+
- ffmpeg/libavutil/libavutil.so : ffmpeg;
- ffmpeg/libavcodec/libavcodec.so : ffmpeg;
--ffmpeg/libavcore/libavcore.so : ffmpeg;
- ffmpeg/libavformat/libavformat.so : ffmpeg;
- ffmpeg/libavfilter/libavfilter.so : ffmpeg;
- ffmpeg/libswscale/libswscale.so : ffmpeg;
- ffmpeg/libpostproc/libpostproc.so : ffmpeg;
-+ffmpeg/libswresample/libswresample.so : ffmpeg;
-+endif
-+
- ffmpeg:
- $(MAKE) -C $@
--
-+ifeq ($(findstring osx,$(ARCH)), osx)
-+ $(AR) d ffmpeg/libavcodec/libavcodec.a inverse.o
- endif
-
- clean:
-diff -Naur xbmc-11.0.1/xbmc/cdrip/EncoderFFmpeg.cpp xbmc-11.0.1.patch/xbmc/cdrip/EncoderFFmpeg.cpp
---- xbmc-11.0.1/xbmc/cdrip/EncoderFFmpeg.cpp 2012-03-21 23:57:32.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cdrip/EncoderFFmpeg.cpp 2012-06-05 15:19:23.881494992 +0200
-@@ -59,11 +59,7 @@
-
- CStdString filename = URIUtils::GetFileName(strFile);
- AVOutputFormat *fmt = NULL;
--#if LIBAVFORMAT_VERSION_MAJOR < 52
-- fmt = m_dllAvFormat.guess_format(NULL, filename.c_str(), NULL);
--#else
- fmt = m_dllAvFormat.av_guess_format(NULL, filename.c_str(), NULL);
--#endif
- if (!fmt)
- {
- CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Unable to guess the output format for the file %s", filename.c_str());
-@@ -82,7 +78,7 @@
- }
-
- m_Format = m_dllAvFormat.avformat_alloc_context();
-- m_Format->pb = m_dllAvFormat.av_alloc_put_byte(m_BCBuffer, sizeof(m_BCBuffer), URL_RDONLY, this, NULL, MuxerReadPacket, NULL);
-+ m_Format->pb = m_dllAvFormat.avio_alloc_context(m_BCBuffer, sizeof(m_BCBuffer), AVIO_FLAG_READ, this, NULL, MuxerReadPacket, NULL);
- if (!m_Format->pb)
- {
- m_dllAvUtil.av_freep(&m_Format);
-@@ -93,17 +89,8 @@
- m_Format->oformat = fmt;
- m_Format->bit_rate = g_guiSettings.GetInt("audiocds.bitrate") * 1000;
-
-- /* setup the muxer */
-- if (m_dllAvFormat.av_set_parameters(m_Format, NULL) != 0)
-- {
-- m_dllAvUtil.av_freep(&m_Format->pb);
-- m_dllAvUtil.av_freep(&m_Format);
-- CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to set the muxer parameters");
-- return false;
-- }
--
- /* add a stream to it */
-- m_Stream = m_dllAvFormat.av_new_stream(m_Format, 1);
-+ m_Stream = m_dllAvFormat.avformat_new_stream(m_Format, codec);
- if (!m_Stream)
- {
- m_dllAvUtil.av_freep(&m_Format->pb);
-@@ -144,7 +131,7 @@
- return false;
- }
-
-- if (m_dllAvCodec.avcodec_open(m_CodecCtx, codec))
-+ if (m_dllAvCodec.avcodec_open2(m_CodecCtx, codec, NULL))
- {
- CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to open the codec");
- m_dllAvUtil.av_freep(&m_Stream);
-@@ -179,7 +166,7 @@
- SetTag("encoder" , "XBMC FFmpeg Encoder");
-
- /* write the header */
-- if (m_dllAvFormat.av_write_header(m_Format) != 0)
-+ if (m_dllAvFormat.avformat_write_header(m_Format, NULL) != 0)
- {
- CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to write the header");
- delete[] m_Buffer;
-@@ -194,7 +181,7 @@
-
- void CEncoderFFmpeg::SetTag(const CStdString tag, const CStdString value)
- {
-- m_dllAvFormat.av_metadata_set2(&m_Format->metadata, tag.c_str(), value.c_str(), 0);
-+ m_dllAvUtil.av_dict_set(&m_Format->metadata, tag.c_str(), value.c_str(), 0);
- }
-
- int CEncoderFFmpeg::MuxerReadPacket(void *opaque, uint8_t *buf, int buf_size)
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp 2012-06-05 15:19:23.882495012 +0200
-@@ -29,10 +29,6 @@
-
- CDVDAudioCodecFFmpeg::CDVDAudioCodecFFmpeg() : CDVDAudioCodec()
- {
-- m_iBufferSize1 = 0;
-- m_pBuffer1 = (BYTE*)_aligned_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE, 16);
-- memset(m_pBuffer1, 0, AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
--
- m_iBufferSize2 = 0;
- m_pBuffer2 = (BYTE*)_aligned_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE, 16);
- memset(m_pBuffer2, 0, AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
-@@ -45,11 +41,11 @@
- m_channelMap[0] = PCM_INVALID;
- m_channels = 0;
- m_layout = 0;
-+ m_pFrame1 = NULL;
- }
-
- CDVDAudioCodecFFmpeg::~CDVDAudioCodecFFmpeg()
- {
-- _aligned_free(m_pBuffer1);
- _aligned_free(m_pBuffer2);
- Dispose();
- }
-@@ -59,12 +55,10 @@
- AVCodec* pCodec;
- m_bOpenedCodec = false;
-
-- if (!m_dllAvCore.Load() || !m_dllAvUtil.Load() || !m_dllAvCodec.Load())
-+ if (!m_dllAvUtil.Load() || !m_dllAvCodec.Load())
- return false;
-
- m_dllAvCodec.avcodec_register_all();
-- m_pCodecContext = m_dllAvCodec.avcodec_alloc_context();
-- m_dllAvCodec.avcodec_get_context_defaults(m_pCodecContext);
-
- pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec);
- if (!pCodec)
-@@ -73,6 +67,7 @@
- return false;
- }
-
-+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
- m_pCodecContext->debug_mv = 0;
- m_pCodecContext->debug = 0;
- m_pCodecContext->workaround_bugs = 1;
-@@ -97,13 +92,14 @@
- memcpy(m_pCodecContext->extradata, hints.extradata, hints.extrasize);
- }
-
-- if (m_dllAvCodec.avcodec_open(m_pCodecContext, pCodec) < 0)
-+ if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0)
- {
- CLog::Log(LOGDEBUG,"CDVDAudioCodecFFmpeg::Open() Unable to open codec");
- Dispose();
- return false;
- }
-
-+ m_pFrame1 = m_dllAvCodec.avcodec_alloc_frame();
- m_bOpenedCodec = true;
- m_iSampleFormat = AV_SAMPLE_FMT_NONE;
- return true;
-@@ -111,6 +107,9 @@
-
- void CDVDAudioCodecFFmpeg::Dispose()
- {
-+ if (m_pFrame1) m_dllAvUtil.av_free(m_pFrame1);
-+ m_pFrame1 = NULL;
-+
- if (m_pConvert)
- {
- m_dllAvCodec.av_audio_convert_free(m_pConvert);
-@@ -135,7 +134,7 @@
-
- int CDVDAudioCodecFFmpeg::Decode(BYTE* pData, int iSize)
- {
-- int iBytesUsed;
-+ int iBytesUsed, got_frame;
- if (!m_pCodecContext) return -1;
-
- m_iBufferSize1 = AVCODEC_MAX_AUDIO_FRAME_SIZE ;
-@@ -145,10 +144,17 @@
- m_dllAvCodec.av_init_packet(&avpkt);
- avpkt.data = pData;
- avpkt.size = iSize;
-- iBytesUsed = m_dllAvCodec.avcodec_decode_audio3( m_pCodecContext
-- , (int16_t*)m_pBuffer1
-- , &m_iBufferSize1
-+ iBytesUsed = m_dllAvCodec.avcodec_decode_audio4( m_pCodecContext
-+ , m_pFrame1
-+ , &got_frame
- , &avpkt);
-+ if (iBytesUsed < 0 || !got_frame)
-+ {
-+ m_iBufferSize1 = 0;
-+ m_iBufferSize2 = 0;
-+ return iBytesUsed;
-+ }
-+ m_iBufferSize1 = m_dllAvUtil.av_samples_get_buffer_size(NULL, m_pCodecContext->channels, m_pFrame1->nb_samples, m_pCodecContext->sample_fmt, 1);
-
- /* some codecs will attempt to consume more data than what we gave */
- if (iBytesUsed > iSize)
-@@ -184,9 +190,9 @@
- return iBytesUsed;
- }
-
-- const void *ibuf[6] = { m_pBuffer1 };
-+ const void *ibuf[6] = { m_pFrame1->data[0] };
- void *obuf[6] = { m_pBuffer2 };
-- int istr[6] = { m_dllAvCore.av_get_bits_per_sample_fmt(m_pCodecContext->sample_fmt)/8 };
-+ int istr[6] = { m_dllAvUtil.av_get_bytes_per_sample(m_pCodecContext->sample_fmt) };
- int ostr[6] = { 2 };
- int len = m_iBufferSize1 / istr[0];
- if(m_dllAvCodec.av_audio_convert(m_pConvert, obuf, ostr, ibuf, istr, len) < 0)
-@@ -208,7 +214,7 @@
- {
- if(m_iBufferSize1)
- {
-- *dst = m_pBuffer1;
-+ *dst = m_pFrame1->data[0];
- return m_iBufferSize1;
- }
- if(m_iBufferSize2)
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h 2012-06-05 15:19:23.882495012 +0200
-@@ -23,7 +23,6 @@
-
- #include "DVDAudioCodec.h"
- #include "DllAvCodec.h"
--#include "DllAvCore.h"
- #include "DllAvFormat.h"
- #include "DllAvUtil.h"
-
-@@ -51,7 +50,7 @@
- enum AVSampleFormat m_iSampleFormat;
- enum PCMChannels m_channelMap[PCM_MAX_CH + 1];
-
-- BYTE *m_pBuffer1;
-+ AVFrame* m_pFrame1;
- int m_iBufferSize1;
-
- BYTE *m_pBuffer2;
-@@ -64,7 +63,6 @@
- int64_t m_layout;
-
- DllAvCodec m_dllAvCodec;
-- DllAvCore m_dllAvCore;
- DllAvUtil m_dllAvUtil;
-
- void BuildChannelMap();
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp 2012-06-05 15:19:23.883495032 +0200
-@@ -79,11 +79,7 @@
- /* get the muxer */
- AVOutputFormat *fOut = NULL;
-
--#if LIBAVFORMAT_VERSION_MAJOR < 52
-- fOut = m_dllAvFormat.guess_format(muxerName.c_str(), NULL, NULL);
--#else
- fOut = m_dllAvFormat.av_guess_format(muxerName.c_str(), NULL, NULL);
--#endif
- if (!fOut)
- {
- CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Failed to get the FFmpeg %s muxer", muxerName.c_str());
-@@ -103,7 +99,7 @@
- muxer.m_pFormat->oformat = fOut;
-
- /* allocate a put_byte struct so we can grab the output */
-- muxer.m_pFormat->pb = m_dllAvFormat.av_alloc_put_byte(muxer.m_BCBuffer, sizeof(muxer.m_BCBuffer), URL_RDONLY, &muxer, NULL, MuxerReadPacket, NULL);
-+ muxer.m_pFormat->pb = m_dllAvFormat.avio_alloc_context(muxer.m_BCBuffer, sizeof(muxer.m_BCBuffer), AVIO_FLAG_READ, &muxer, NULL, MuxerReadPacket, NULL);
- if (!muxer.m_pFormat->pb)
- {
- CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Failed to allocate ByteIOContext");
-@@ -112,21 +108,10 @@
- }
-
- /* this is streamed, no file, and ignore the index */
-- muxer.m_pFormat->pb->is_streamed = 1;
-+ muxer.m_pFormat->pb->seekable = 0;
- muxer.m_pFormat->flags |= AVFMT_NOFILE | AVFMT_FLAG_IGNIDX;
- muxer.m_pFormat->bit_rate = hints.bitrate;
-
-- /* setup the muxer */
-- if (m_dllAvFormat.av_set_parameters(muxer.m_pFormat, NULL) != 0)
-- {
-- CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Failed to set the %s muxer parameters", muxerName.c_str());
-- Dispose();
-- return false;
-- }
--
--#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,92,0)
-- // API added on: 2011-01-02
--
- /* While this is strictly only needed on big-endian systems, we do it on
- * both to avoid as much dead code as possible.
- * CoreAudio (at least on the cases we've seen) wants IEC 61937 in
-@@ -138,8 +123,7 @@
- #endif
-
- /* request output of wanted endianness */
-- if (!fOut->priv_class || m_dllAvUtil.av_set_string3(muxer.m_pFormat->priv_data, "spdif_flags", spdifFlags, 0, NULL) != 0)
--#endif
-+ if (!fOut->priv_class || m_dllAvUtil.av_opt_set(muxer.m_pFormat->priv_data, "spdif_flags", spdifFlags, 0) != 0)
- {
- #if defined(WORDS_BIGENDIAN) && !defined(__APPLE__)
- CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Unable to set big-endian stream mode (FFmpeg too old?), disabling passthrough");
-@@ -149,7 +133,7 @@
- }
-
- /* add a stream to it */
-- muxer.m_pStream = m_dllAvFormat.av_new_stream(muxer.m_pFormat, 1);
-+ muxer.m_pStream = m_dllAvFormat.avformat_new_stream(muxer.m_pFormat, NULL);
- if (!muxer.m_pStream)
- {
- CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Failed to allocate AVStream context");
-@@ -159,8 +143,6 @@
-
-
- /* set the stream's parameters */
-- muxer.m_pStream->stream_copy = 1;
--
- m_SampleRate = hints.samplerate;
- if(!m_SampleRate && hints.codec == CODEC_ID_AC3)
- m_SampleRate = 48000;
-@@ -176,7 +158,7 @@
- codec->extradata_size = hints.extrasize;
- memcpy(codec->extradata, hints.extradata, hints.extrasize);
-
-- muxer.m_WroteHeader = m_dllAvFormat.av_write_header(muxer.m_pFormat) == 0;
-+ muxer.m_WroteHeader = m_dllAvFormat.avformat_write_header(muxer.m_pFormat, NULL) == 0;
- if (!muxer.m_WroteHeader)
- {
- CLog::Log(LOGERROR, "CDVDAudioCodecPassthrough::SetupMuxer - Failed to write the frame header");
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp 2012-06-05 15:19:23.943496230 +0200
-@@ -55,7 +55,7 @@
- bool CDVDAudioEncoderFFmpeg::Initialize(unsigned int channels, enum PCMChannels *channelMap, unsigned int bitsPerSample, unsigned int sampleRate)
- {
- Reset();
-- if (!channelMap || !m_dllAvUtil.Load() || !m_dllAvCore.Load() || !m_dllAvCodec.Load())
-+ if (!channelMap || !m_dllAvUtil.Load() || !m_dllAvCodec.Load())
- return false;
-
- m_dllAvCodec.avcodec_register_all();
-@@ -65,7 +65,7 @@
- return false;
-
- /* always assume 6 channels, 5.1... m_remap will give us what we want */
-- m_CodecCtx = m_dllAvCodec.avcodec_alloc_context();
-+ m_CodecCtx = m_dllAvCodec.avcodec_alloc_context3(codec);
- m_CodecCtx->bit_rate = AC3_ENCODE_BITRATE;
- m_CodecCtx->sample_rate = sampleRate;
- m_CodecCtx->channels = 6;
-@@ -104,7 +104,7 @@
- }
- }
-
-- if (m_dllAvCodec.avcodec_open(m_CodecCtx, codec))
-+ if (m_dllAvCodec.avcodec_open2(m_CodecCtx, codec, NULL))
- {
- m_dllAvUtil.av_freep(&m_CodecCtx);
- return false;
-@@ -149,7 +149,7 @@
-
- if (m_AudioConvert)
- m_TmpBuffer2 = new uint8_t[m_NeededFrames * m_CodecCtx->channels *
-- m_dllAvCore.av_get_bits_per_sample_fmt(m_CodecCtx->sample_fmt) / 8];
-+ m_dllAvUtil.av_get_bytes_per_sample(m_CodecCtx->sample_fmt)];
-
- return true;
- }
-@@ -186,7 +186,7 @@
- void *convInBuf[] = { m_TmpBuffer };
- int convInStr[] = { m_BitsPerSample / 8 };
- void *convOutBuf[] = { m_TmpBuffer2 };
-- int convOutStr[] = { m_dllAvCore.av_get_bits_per_sample_fmt(m_CodecCtx->sample_fmt) / 8 };
-+ int convOutStr[] = { m_dllAvUtil.av_get_bytes_per_sample(m_CodecCtx->sample_fmt) };
- if (m_dllAvCodec.av_audio_convert(m_AudioConvert, convOutBuf, convOutStr,
- convInBuf, convInStr, m_NeededFrames * m_CodecCtx->channels) < 0) {
- CLog::Log(LOGERROR, "CDVDAudioEncoderFFmpeg: Audio conversion failed");
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.h xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.h
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.h 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.h 2012-06-05 15:19:23.944496250 +0200
-@@ -43,7 +43,6 @@
- virtual int GetData(uint8_t **data);
- private:
- DllAvCodec m_dllAvCodec;
-- DllAvCore m_dllAvCore;
- DllAvUtil m_dllAvUtil;
-
- AVCodecContext *m_CodecCtx;
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp 2012-06-05 15:19:23.944496250 +0200
-@@ -49,7 +49,14 @@
-
- m_dllAvCodec.avcodec_register_all();
-
-- m_pCodecContext = m_dllAvCodec.avcodec_alloc_context();
-+ AVCodec* pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec);
-+ if (!pCodec)
-+ {
-+ CLog::Log(LOGDEBUG,"%s - Unable to find codec %d", __FUNCTION__, hints.codec);
-+ return false;
-+ }
-+
-+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
- m_pCodecContext->debug_mv = 0;
- m_pCodecContext->debug = 0;
- m_pCodecContext->workaround_bugs = FF_BUG_AUTODETECT;
-@@ -100,14 +107,7 @@
- delete[] parse_extra;
- }
-
-- AVCodec* pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec);
-- if (!pCodec)
-- {
-- CLog::Log(LOGDEBUG,"%s - Unable to find codec %d", __FUNCTION__, hints.codec);
-- return false;
-- }
--
-- if (m_dllAvCodec.avcodec_open(m_pCodecContext, pCodec) < 0)
-+ if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0)
- {
- CLog::Log(LOGDEBUG,"CDVDVideoCodecFFmpeg::Open() Unable to open codec");
- return false;
-@@ -134,19 +134,12 @@
- {
- for(unsigned i=0;i= (52<<10)
- if(sub.rects[i])
- {
- m_dllAvUtil.av_free(sub.rects[i]->pict.data[0]);
- m_dllAvUtil.av_free(sub.rects[i]->pict.data[1]);
- m_dllAvUtil.av_freep(&sub.rects[i]);
- }
--#else
-- if(sub.rects[i].bitmap)
-- m_dllAvUtil.av_freep(&sub.rects[i].bitmap);
-- if(m_Subtitle.rects[i].rgba_palette)
-- m_dllAvUtil.av_freep(&sub.rects[i].rgba_palette);
--#endif
- }
- if(sub.rects)
- m_dllAvUtil.av_freep(&sub.rects);
-@@ -294,7 +287,6 @@
- overlay->source_width = m_width;
- overlay->source_height = m_height;
-
--#if LIBAVCODEC_VERSION_INT >= (52<<10)
- BYTE* s = rect.pict.data[0];
- BYTE* t = overlay->data;
- for(int i=0;idata;
-- for(int i=0;ilinesize;
-- }
--
-- memcpy(overlay->palette, rect.rgba_palette, rect.nb_colors*4);
--
-- m_dllAvUtil.av_freep(&rect.bitmap);
-- m_dllAvUtil.av_freep(&rect.rgba_palette);
--#endif
- m_SubtitleIndex++;
-
- return overlay;
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp 2012-06-05 15:19:23.946496292 +0200
-@@ -123,12 +123,11 @@
- CDVDVideoCodecFFmpeg::CDVDVideoCodecFFmpeg() : CDVDVideoCodec()
- {
- m_pCodecContext = NULL;
-- m_pConvertFrame = NULL;
- m_pFrame = NULL;
- m_pFilterGraph = NULL;
- m_pFilterIn = NULL;
- m_pFilterOut = NULL;
-- m_pFilterLink = NULL;
-+ m_pBufferRef = NULL;
-
- m_iPictureWidth = 0;
- m_iPictureHeight = 0;
-@@ -163,9 +162,13 @@
- m_dllAvFilter.avfilter_register_all();
-
- m_bSoftware = hints.software;
-- m_pCodecContext = m_dllAvCodec.avcodec_alloc_context();
-+
-+ m_formats.push_back(PIX_FMT_YUV420P);
-+ m_formats.push_back(PIX_FMT_YUVJ420P);
-+ m_formats.push_back(PIX_FMT_NONE); /* always add none to get a terminated list in ffmpeg world */
-
- pCodec = NULL;
-+ m_pCodecContext = NULL;
-
- if (hints.codec == CODEC_ID_H264)
- {
-@@ -196,6 +199,7 @@
-
- CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Creating VDPAU(%ix%i, %d)",hints.width, hints.height, hints.codec);
- CVDPAU* vdp = new CVDPAU();
-+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
- m_pCodecContext->codec_id = hints.codec;
- m_pCodecContext->width = hints.width;
- m_pCodecContext->height = hints.height;
-@@ -207,7 +211,7 @@
- m_pCodecContext->codec_id = CODEC_ID_NONE; // ffmpeg will complain if this has been set
- break;
- }
-- m_pCodecContext->codec_id = CODEC_ID_NONE; // ffmpeg will complain if this has been set
-+ m_dllAvUtil.av_freep(&m_pCodecContext);
- CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Failed to get VDPAU device");
- vdp->Release();
- }
-@@ -226,21 +230,26 @@
-
- CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Using codec: %s",pCodec->long_name ? pCodec->long_name : pCodec->name);
-
-+ if(m_pCodecContext == NULL)
-+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
-+
- m_pCodecContext->opaque = (void*)this;
- m_pCodecContext->debug_mv = 0;
- m_pCodecContext->debug = 0;
- m_pCodecContext->workaround_bugs = FF_BUG_AUTODETECT;
- m_pCodecContext->get_format = GetFormat;
- m_pCodecContext->codec_tag = hints.codec_tag;
-+ /* Only allow slice threading, since frame threading is more
-+ * sensitive to changes in frame sizes, and it causes crashes
-+ * during HW accell */
-+ m_pCodecContext->thread_type = FF_THREAD_SLICE;
-
- #if defined(__APPLE__) && defined(__arm__)
- // ffmpeg with enabled neon will crash and burn if this is enabled
- m_pCodecContext->flags &= CODEC_FLAG_EMU_EDGE;
- #else
- if (pCodec->id != CODEC_ID_H264 && pCodec->capabilities & CODEC_CAP_DR1
--#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,69,0)
- && pCodec->id != CODEC_ID_VP8
--#endif
- )
- m_pCodecContext->flags |= CODEC_FLAG_EMU_EDGE;
- #endif
-@@ -272,16 +281,16 @@
- if (it->m_name == "surfaces")
- m_uSurfacesCount = std::atoi(it->m_value.c_str());
- else
-- m_dllAvUtil.av_set_string3(m_pCodecContext, it->m_name.c_str(), it->m_value.c_str(), 0, NULL);
-+ m_dllAvUtil.av_opt_set(m_pCodecContext, it->m_name.c_str(), it->m_value.c_str(), 0);
- }
-
- int num_threads = std::min(8 /*MAX_THREADS*/, g_cpuInfo.getCPUCount());
- if( num_threads > 1 && !hints.software && m_pHardware == NULL // thumbnail extraction fails when run threaded
- && ( pCodec->id == CODEC_ID_H264
- || pCodec->id == CODEC_ID_MPEG4 ))
-- m_dllAvCodec.avcodec_thread_init(m_pCodecContext, num_threads);
-+ m_pCodecContext->thread_count = num_threads;
-
-- if (m_dllAvCodec.avcodec_open(m_pCodecContext, pCodec) < 0)
-+ if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0)
- {
- CLog::Log(LOGDEBUG,"CDVDVideoCodecFFmpeg::Open() Unable to open codec");
- return false;
-@@ -290,14 +299,7 @@
- m_pFrame = m_dllAvCodec.avcodec_alloc_frame();
- if (!m_pFrame) return false;
-
-- if(pCodec->name)
-- m_name = CStdString("ff-") + pCodec->name;
-- else
-- m_name = "ffmpeg";
--
-- if(m_pHardware)
-- m_name += "-" + m_pHardware->Name();
--
-+ UpdateName();
- return true;
- }
-
-@@ -306,13 +308,6 @@
- if (m_pFrame) m_dllAvUtil.av_free(m_pFrame);
- m_pFrame = NULL;
-
-- if (m_pConvertFrame)
-- {
-- m_dllAvCodec.avpicture_free(m_pConvertFrame);
-- m_dllAvUtil.av_free(m_pConvertFrame);
-- }
-- m_pConvertFrame = NULL;
--
- if (m_pCodecContext)
- {
- if (m_pCodecContext->codec) m_dllAvCodec.avcodec_close(m_pCodecContext);
-@@ -458,9 +453,6 @@
- return VC_ERROR;
- }
-
-- if (len != iSize && m_pCodecContext->skip_frame != AVDISCARD_NONREF)
-- CLog::Log(LOGWARNING, "%s - avcodec_decode_video didn't consume the full packet. size: %d, consumed: %d", __FUNCTION__, iSize, len);
--
- if (!iGotPicture)
- return VC_BUFFER;
-
-@@ -478,67 +470,32 @@
- if(m_pCodecContext->codec_id == CODEC_ID_H264)
- m_started = true;
-
-- if(m_pCodecContext->pix_fmt != PIX_FMT_YUV420P
-- && m_pCodecContext->pix_fmt != PIX_FMT_YUVJ420P
-- && m_pHardware == NULL)
-- {
-- if (!m_dllSwScale.IsLoaded() && !m_dllSwScale.Load())
-- return VC_ERROR;
--
-- if (!m_pConvertFrame)
-- {
-- // Allocate an AVFrame structure
-- m_pConvertFrame = (AVPicture*)m_dllAvUtil.av_mallocz(sizeof(AVPicture));
-- // Due to a bug in swsscale we need to allocate one extra line of data
-- if(m_dllAvCodec.avpicture_alloc( m_pConvertFrame
-- , PIX_FMT_YUV420P
-- , m_pCodecContext->width
-- , m_pCodecContext->height+1) < 0)
-- {
-- m_dllAvUtil.av_free(m_pConvertFrame);
-- m_pConvertFrame = NULL;
-- return VC_ERROR;
-- }
-- }
-+ if(m_pHardware == NULL)
-+ {
-+ bool need_scale = std::find( m_formats.begin()
-+ , m_formats.end()
-+ , m_pCodecContext->pix_fmt) == m_formats.end();
-
-- // convert the picture
-- struct SwsContext *context = m_dllSwScale.sws_getContext(m_pCodecContext->width, m_pCodecContext->height,
-- m_pCodecContext->pix_fmt, m_pCodecContext->width, m_pCodecContext->height,
-- PIX_FMT_YUV420P, SWS_FAST_BILINEAR | SwScaleCPUFlags(), NULL, NULL, NULL);
-+ bool need_reopen = false;
-+ if(!m_filters.Equals(m_filters_next))
-+ need_reopen = true;
-
-- if(context == NULL)
-+ if(m_pFilterIn)
- {
-- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::Decode - unable to obtain sws context for w:%i, h:%i, pixfmt: %i", m_pCodecContext->width, m_pCodecContext->height, m_pCodecContext->pix_fmt);
-- return VC_ERROR;
-+ if(m_pFilterIn->outputs[0]->format != m_pCodecContext->pix_fmt
-+ || m_pFilterIn->outputs[0]->w != m_pCodecContext->width
-+ || m_pFilterIn->outputs[0]->h != m_pCodecContext->height)
-+ need_reopen = true;
- }
-
-- m_dllSwScale.sws_scale(context
-- , m_pFrame->data
-- , m_pFrame->linesize
-- , 0
-- , m_pCodecContext->height
-- , m_pConvertFrame->data
-- , m_pConvertFrame->linesize);
--
-- m_dllSwScale.sws_freeContext(context);
-- }
-- else
-- {
-- // no need to convert, just free any existing convert buffers
-- if (m_pConvertFrame)
-+ // try to setup new filters
-+ if (need_reopen || (need_scale && m_pFilterGraph == NULL))
- {
-- m_dllAvCodec.avpicture_free(m_pConvertFrame);
-- m_dllAvUtil.av_free(m_pConvertFrame);
-- m_pConvertFrame = NULL;
-- }
-- }
-+ m_filters = m_filters_next;
-
-- // try to setup new filters
-- if (!m_filters.Equals(m_filters_next))
-- {
-- m_filters = m_filters_next;
-- if(FilterOpen(m_filters) < 0)
-- FilterClose();
-+ if(FilterOpen(m_filters, need_scale) < 0)
-+ FilterClose();
-+ }
- }
-
- int result;
-@@ -564,12 +521,6 @@
- if (m_pHardware)
- m_pHardware->Reset();
-
-- if (m_pConvertFrame)
-- {
-- m_dllAvCodec.avpicture_free(m_pConvertFrame);
-- m_dllAvUtil.av_free(m_pConvertFrame);
-- m_pConvertFrame = NULL;
-- }
- m_filters = "";
- FilterClose();
- }
-@@ -579,10 +530,10 @@
- pDvdVideoPicture->iWidth = m_pCodecContext->width;
- pDvdVideoPicture->iHeight = m_pCodecContext->height;
-
-- if(m_pFilterLink)
-+ if(m_pBufferRef)
- {
-- pDvdVideoPicture->iWidth = m_pFilterLink->cur_buf->video->w;
-- pDvdVideoPicture->iHeight = m_pFilterLink->cur_buf->video->h;
-+ pDvdVideoPicture->iWidth = m_pBufferRef->video->w;
-+ pDvdVideoPicture->iHeight = m_pBufferRef->video->h;
- }
-
- /* crop of 10 pixels if demuxer asked it */
-@@ -598,12 +549,8 @@
-
- /* use variable in the frame */
- AVRational pixel_aspect = m_pCodecContext->sample_aspect_ratio;
-- if (m_pFilterLink)
--#ifdef HAVE_AVFILTERBUFFERREFVIDEOPROPS_SAMPLE_ASPECT_RATIO
-- pixel_aspect = m_pFilterLink->cur_buf->video->sample_aspect_ratio;
--#else
-- pixel_aspect = m_pFilterLink->cur_buf->video->pixel_aspect;
--#endif
-+ if (m_pBufferRef)
-+ pixel_aspect = m_pBufferRef->video->sample_aspect_ratio;
-
- if (pixel_aspect.num == 0)
- aspect_ratio = 0;
-@@ -632,8 +579,6 @@
- pDvdVideoPicture->iFlags = DVP_FLAG_ALLOCATED;
- pDvdVideoPicture->iFlags |= m_pFrame->interlaced_frame ? DVP_FLAG_INTERLACED : 0;
- pDvdVideoPicture->iFlags |= m_pFrame->top_field_first ? DVP_FLAG_TOP_FIELD_FIRST: 0;
-- if(m_pCodecContext->pix_fmt == PIX_FMT_YUVJ420P)
-- pDvdVideoPicture->color_range = 1;
-
- pDvdVideoPicture->chroma_position = m_pCodecContext->chroma_sample_location;
- pDvdVideoPicture->color_primaries = m_pCodecContext->color_primaries;
-@@ -677,14 +622,6 @@
- if(!GetPictureCommon(pDvdVideoPicture))
- return false;
-
-- if(m_pConvertFrame)
-- {
-- for (int i = 0; i < 4; i++)
-- pDvdVideoPicture->data[i] = m_pConvertFrame->data[i];
-- for (int i = 0; i < 4; i++)
-- pDvdVideoPicture->iLineSize[i] = m_pConvertFrame->linesize[i];
-- }
-- else
- {
- for (int i = 0; i < 4; i++)
- pDvdVideoPicture->data[i] = m_pFrame->data[i];
-@@ -693,20 +630,38 @@
- }
-
- pDvdVideoPicture->iFlags |= pDvdVideoPicture->data[0] ? 0 : DVP_FLAG_DROPPED;
-- pDvdVideoPicture->format = DVDVideoPicture::FMT_YUV420P;
- pDvdVideoPicture->extended_format = 0;
-+ pDvdVideoPicture->color_range = 0;
-+
-+ PixelFormat pix_fmt;
-+ if(m_pBufferRef)
-+ pix_fmt = (PixelFormat)m_pBufferRef->format;
-+ else
-+ pix_fmt = m_pCodecContext->pix_fmt;
-+
-+ switch(pix_fmt)
-+ {
-+ case PIX_FMT_YUVJ420P:
-+ pDvdVideoPicture->format = DVDVideoPicture::FMT_YUV420P;
-+ pDvdVideoPicture->color_range = 1;
-+ break;
-+ default:
-+ pDvdVideoPicture->format = DVDVideoPicture::FMT_YUV420P;
-+ break;
-+ }
-
- return true;
- }
-
--int CDVDVideoCodecFFmpeg::FilterOpen(const CStdString& filters)
-+int CDVDVideoCodecFFmpeg::FilterOpen(const CStdString& filters, bool scale)
- {
- int result;
-+ AVBufferSinkParams *buffersink_params;
-
- if (m_pFilterGraph)
- FilterClose();
-
-- if (filters.IsEmpty())
-+ if (filters.IsEmpty() && !scale)
- return 0;
-
- if (!(m_pFilterGraph = m_dllAvFilter.avfilter_graph_alloc()))
-@@ -715,17 +670,8 @@
- return -1;
- }
-
-- // CrHasher HACK (if an alternative becomes available use it!): In order to display the output
-- // produced by a combination of filters we insert "nullsink" as the last filter and we use
-- // its input pin as our output pin.
-- //
-- // input --> .. --> last_filter --> [in] nullsink [null] [in] --> output
-- // | |
-- // | |
-- // +------------------------+
-- //
- AVFilter* srcFilter = m_dllAvFilter.avfilter_get_by_name("buffer");
-- AVFilter* outFilter = m_dllAvFilter.avfilter_get_by_name("nullsink"); // should be last filter in the graph for now
-+ AVFilter* outFilter = m_dllAvFilter.avfilter_get_by_name("buffersink"); // should be last filter in the graph for now
-
- CStdString args;
-
-@@ -744,11 +690,19 @@
- return result;
- }
-
-- if ((result = m_dllAvFilter.avfilter_graph_create_filter(&m_pFilterOut, outFilter, "out", NULL, NULL/*nullsink=>NULL*/, m_pFilterGraph)) < 0)
-+ buffersink_params = m_dllAvFilter.av_buffersink_params_alloc();
-+ buffersink_params->pixel_fmts = &m_formats[0];
-+#ifdef FF_API_OLD_VSINK_API
-+ if ((result = m_dllAvFilter.avfilter_graph_create_filter(&m_pFilterOut, outFilter, "out", NULL, (void*)buffersink_params->pixel_fmts, m_pFilterGraph)) < 0)
-+#else
-+ if ((result = m_dllAvFilter.avfilter_graph_create_filter(&m_pFilterOut, outFilter, "out", NULL, buffersink_params, m_pFilterGraph)) < 0)
-+#endif
- {
-+ m_dllAvUtil.av_freep(&buffersink_params);
- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterOpen - avfilter_graph_create_filter: out");
- return result;
- }
-+ m_dllAvUtil.av_freep(&buffersink_params);
-
- if (!filters.empty())
- {
-@@ -794,6 +748,12 @@
-
- void CDVDVideoCodecFFmpeg::FilterClose()
- {
-+ if(m_pBufferRef)
-+ {
-+ m_dllAvFilter.avfilter_unref_buffer(m_pBufferRef);
-+ m_pBufferRef = NULL;
-+ }
-+
- if (m_pFilterGraph)
- {
- m_dllAvFilter.avfilter_graph_free(&m_pFilterGraph);
-@@ -801,7 +761,6 @@
- // Disposed by above code
- m_pFilterIn = NULL;
- m_pFilterOut = NULL;
-- m_pFilterLink = NULL;
- }
- }
-
-@@ -809,24 +768,9 @@
- {
- int result, frames;
-
-- m_pFilterLink = m_pFilterOut->inputs[0];
--
- if (frame)
- {
--#if (defined USE_OLD_AV_VSRC_BUFFER_ADD_FRAME)
-- result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame, frame->pts, m_pCodecContext->sample_aspect_ratio);
--#else
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,13,0)
- result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame, 0);
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,7,0)
-- result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame);
--#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,3,0)
-- result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame, frame->pts);
--#else
-- result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame, frame->pts, m_pCodecContext->sample_aspect_ratio);
--#endif
--#endif
--
- if (result < 0)
- {
- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - av_vsrc_buffer_add_frame");
-@@ -834,7 +778,13 @@
- }
- }
-
-- if ((frames = m_dllAvFilter.avfilter_poll_frame(m_pFilterLink)) < 0)
-+ if(m_pBufferRef)
-+ {
-+ m_dllAvFilter.avfilter_unref_buffer(m_pBufferRef);
-+ m_pBufferRef = NULL;
-+ }
-+
-+ if ((frames = m_dllAvFilter.av_buffersink_poll_frame(m_pFilterOut)) < 0)
- {
- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - avfilter_poll_frame");
- return VC_ERROR;
-@@ -842,19 +792,9 @@
-
- if (frames > 0)
- {
-- if (m_pFilterLink->cur_buf)
-- {
-- m_dllAvFilter.avfilter_unref_buffer(m_pFilterLink->cur_buf);
-- m_pFilterLink->cur_buf = NULL;
-- }
--
-- if ((result = m_dllAvFilter.avfilter_request_frame(m_pFilterLink)) < 0)
-- {
-- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - avfilter_request_frame");
-- return VC_ERROR;
-- }
-
-- if (!m_pFilterLink->cur_buf)
-+ result = m_dllAvFilter.av_buffersink_get_buffer_ref(m_pFilterOut, &m_pBufferRef, 0);
-+ if(!m_pBufferRef)
- {
- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - cur_buf");
- return VC_ERROR;
-@@ -865,11 +805,11 @@
- else
- m_pFrame->repeat_pict = -(frames - 1);
-
-- m_pFrame->interlaced_frame = m_pFilterLink->cur_buf->video->interlaced;
-- m_pFrame->top_field_first = m_pFilterLink->cur_buf->video->top_field_first;
-+ m_pFrame->interlaced_frame = m_pBufferRef->video->interlaced;
-+ m_pFrame->top_field_first = m_pBufferRef->video->top_field_first;
-
-- memcpy(m_pFrame->linesize, m_pFilterLink->cur_buf->linesize, 4*sizeof(int));
-- memcpy(m_pFrame->data , m_pFilterLink->cur_buf->data , 4*sizeof(uint8_t*));
-+ memcpy(m_pFrame->linesize, m_pBufferRef->linesize, 4*sizeof(int));
-+ memcpy(m_pFrame->data , m_pBufferRef->data , 4*sizeof(uint8_t*));
-
- if(frames > 1)
- return VC_PICTURE;
-
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h 2012-06-05 15:19:23.946496292 +0200
-@@ -68,27 +68,36 @@
- {
- SAFE_RELEASE(m_pHardware);
- m_pHardware = hardware;
-- m_name += "-";
-- m_name += m_pHardware->Name();
-+ UpdateName();
- }
-
- protected:
- static enum PixelFormat GetFormat(struct AVCodecContext * avctx, const PixelFormat * fmt);
-
-- int FilterOpen(const CStdString& filters);
-+ int FilterOpen(const CStdString& filters, bool scale);
- void FilterClose();
- int FilterProcess(AVFrame* frame);
-
-+ void UpdateName()
-+ {
-+ if(m_pCodecContext->codec->name)
-+ m_name = CStdString("ff-") + m_pCodecContext->codec->name;
-+ else
-+ m_name = "ffmpeg";
-+
-+ if(m_pHardware)
-+ m_name += "-" + m_pHardware->Name();
-+ }
-+
- AVFrame* m_pFrame;
- AVCodecContext* m_pCodecContext;
-
-- AVPicture* m_pConvertFrame;
- CStdString m_filters;
- CStdString m_filters_next;
- AVFilterGraph* m_pFilterGraph;
- AVFilterContext* m_pFilterIn;
- AVFilterContext* m_pFilterOut;
-- AVFilterLink* m_pFilterLink;
-+ AVFilterBufferRef* m_pBufferRef;
-
- int m_iPictureWidth;
- int m_iPictureHeight;
-@@ -109,4 +118,5 @@
- int m_iLastKeyframe;
- double m_dts;
- bool m_started;
-+ std::vector m_formats;
- };
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp 2012-06-05 15:19:23.947496313 +0200
-@@ -525,8 +525,8 @@
- {
- while (!*(nal_start++));
- nal_end = avc_find_startcode(nal_start, end);
-- av_format_ctx->put_be32(pb, nal_end - nal_start);
-- av_format_ctx->put_buffer(pb, nal_start, nal_end - nal_start);
-+ av_format_ctx->avio_wb32(pb, nal_end - nal_start);
-+ av_format_ctx->avio_write(pb, nal_start, nal_end - nal_start);
- size += 4 + nal_end - nal_start;
- nal_start = nal_end;
- }
-@@ -537,14 +537,14 @@
- const uint8_t *buf_in, uint8_t **buf, int *size)
- {
- ByteIOContext *pb;
-- int ret = av_format_ctx->url_open_dyn_buf(&pb);
-+ int ret = av_format_ctx->avio_open_dyn_buf(&pb);
- if (ret < 0)
- return ret;
-
- avc_parse_nal_units(av_format_ctx, pb, buf_in, *size);
-
- av_util_ctx->av_freep(buf);
-- *size = av_format_ctx->url_close_dyn_buf(pb, buf);
-+ *size = av_format_ctx->avio_close_dyn_buf(pb, buf);
- return 0;
- }
-
-@@ -590,26 +590,26 @@
- }
- assert(sps);
-
-- av_format_ctx->put_byte(pb, 1); /* version */
-- av_format_ctx->put_byte(pb, sps[1]); /* profile */
-- av_format_ctx->put_byte(pb, sps[2]); /* profile compat */
-- av_format_ctx->put_byte(pb, sps[3]); /* level */
-- av_format_ctx->put_byte(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
-- av_format_ctx->put_byte(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
-+ av_format_ctx->avio_w8(pb, 1); /* version */
-+ av_format_ctx->avio_w8(pb, sps[1]); /* profile */
-+ av_format_ctx->avio_w8(pb, sps[2]); /* profile compat */
-+ av_format_ctx->avio_w8(pb, sps[3]); /* level */
-+ av_format_ctx->avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
-+ av_format_ctx->avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
-
-- av_format_ctx->put_be16(pb, sps_size);
-- av_format_ctx->put_buffer(pb, sps, sps_size);
-+ av_format_ctx->avio_wb16(pb, sps_size);
-+ av_format_ctx->avio_write(pb, sps, sps_size);
- if (pps)
- {
-- av_format_ctx->put_byte(pb, 1); /* number of pps */
-- av_format_ctx->put_be16(pb, pps_size);
-- av_format_ctx->put_buffer(pb, pps, pps_size);
-+ av_format_ctx->avio_w8(pb, 1); /* number of pps */
-+ av_format_ctx->avio_wb16(pb, pps_size);
-+ av_format_ctx->avio_write(pb, pps, pps_size);
- }
- av_util_ctx->av_free(start);
- }
- else
- {
-- av_format_ctx->put_buffer(pb, data, len);
-+ av_format_ctx->avio_write(pb, data, len);
- }
- }
- return 0;
-@@ -706,7 +706,7 @@
- }
-
- ByteIOContext *pb;
-- if (m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- {
- return false;
- }
-@@ -717,7 +717,7 @@
- // unhook from ffmpeg's extradata
- extradata = NULL;
- // extract the avcC atom data into extradata then write it into avcCData for VDADecoder
-- extrasize = m_dllAvFormat->url_close_dyn_buf(pb, &extradata);
-+ extrasize = m_dllAvFormat->avio_close_dyn_buf(pb, &extradata);
- // CFDataCreate makes a copy of extradata contents
- avcCData = CFDataCreate(kCFAllocatorDefault, (const uint8_t*)extradata, extrasize);
- // done with the converted extradata, we MUST free using av_free
-@@ -948,12 +948,12 @@
- int demuxer_bytes;
- uint8_t *demuxer_content;
-
-- if(m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if(m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- {
- return VC_ERROR;
- }
- demuxer_bytes = avc_parse_nal_units(m_dllAvFormat, pb, pData, iSize);
-- demuxer_bytes = m_dllAvFormat->url_close_dyn_buf(pb, &demuxer_content);
-+ demuxer_bytes = m_dllAvFormat->avio_close_dyn_buf(pb, &demuxer_content);
- avc_demux = CFDataCreate(kCFAllocatorDefault, demuxer_content, demuxer_bytes);
- m_dllAvUtil->av_free(demuxer_content);
- }
-@@ -961,7 +961,7 @@
- {
- // convert demuxer packet from 3 byte NAL sizes to 4 byte
- ByteIOContext *pb;
-- if (m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- return VC_ERROR;
-
- uint32_t nal_size;
-@@ -970,14 +970,14 @@
- while (nal_start < end)
- {
- nal_size = VDA_RB24(nal_start);
-- m_dllAvFormat->put_be32(pb, nal_size);
-+ m_dllAvFormat->avio_wb32(pb, nal_size);
- nal_start += 3;
-- m_dllAvFormat->put_buffer(pb, nal_start, nal_size);
-+ m_dllAvFormat->avio_write(pb, nal_start, nal_size);
- nal_start += nal_size;
- }
-
- uint8_t *demuxer_content;
-- int demuxer_bytes = m_dllAvFormat->url_close_dyn_buf(pb, &demuxer_content);
-+ int demuxer_bytes = m_dllAvFormat->avio_close_dyn_buf(pb, &demuxer_content);
- avc_demux = CFDataCreate(kCFAllocatorDefault, demuxer_content, demuxer_bytes);
- m_dllAvUtil->av_free(demuxer_content);
- }
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp 2012-06-05 15:19:23.949496352 +0200
-@@ -474,7 +474,7 @@
- {
- b |= 0x80;
- }
-- av_format_ctx->put_byte(pb, b);
-+ av_format_ctx->avio_w8(pb, b);
- }
-
- return numBytes;
-@@ -482,37 +482,37 @@
-
- void quicktime_write_esds(DllAvFormat *av_format_ctx, ByteIOContext *pb, quicktime_esds_t *esds)
- {
-- av_format_ctx->put_byte(pb, 0); // Version
-- av_format_ctx->put_be24(pb, 0); // Flags
-+ av_format_ctx->avio_w8(pb, 0); // Version
-+ av_format_ctx->avio_wb24(pb, 0); // Flags
-
- // elementary stream descriptor tag
-- av_format_ctx->put_byte(pb, 0x03);
-+ av_format_ctx->avio_w8(pb, 0x03);
- quicktime_write_mp4_descr_length(av_format_ctx, pb,
- 3 + 5 + (13 + 5 + esds->decoderConfigLen) + 3, false);
- // 3 bytes + 5 bytes for tag
-- av_format_ctx->put_be16(pb, esds->esid);
-- av_format_ctx->put_byte(pb, esds->stream_priority);
-+ av_format_ctx->avio_wb16(pb, esds->esid);
-+ av_format_ctx->avio_w8(pb, esds->stream_priority);
-
- // decoder configuration description tag
-- av_format_ctx->put_byte(pb, 0x04);
-+ av_format_ctx->avio_w8(pb, 0x04);
- quicktime_write_mp4_descr_length(av_format_ctx, pb,
- 13 + 5 + esds->decoderConfigLen, false);
- // 13 bytes + 5 bytes for tag
-- av_format_ctx->put_byte(pb, esds->objectTypeId); // objectTypeIndication
-- av_format_ctx->put_byte(pb, esds->streamType); // streamType
-- av_format_ctx->put_be24(pb, esds->bufferSizeDB); // buffer size
-- av_format_ctx->put_be32(pb, esds->maxBitrate); // max bitrate
-- av_format_ctx->put_be32(pb, esds->avgBitrate); // average bitrate
-+ av_format_ctx->avio_w8(pb, esds->objectTypeId); // objectTypeIndication
-+ av_format_ctx->avio_w8(pb, esds->streamType); // streamType
-+ av_format_ctx->avio_wb24(pb, esds->bufferSizeDB); // buffer size
-+ av_format_ctx->avio_wb32(pb, esds->maxBitrate); // max bitrate
-+ av_format_ctx->avio_wb32(pb, esds->avgBitrate); // average bitrate
-
- // decoder specific description tag
-- av_format_ctx->put_byte(pb, 0x05);
-+ av_format_ctx->avio_w8(pb, 0x05);
- quicktime_write_mp4_descr_length(av_format_ctx, pb, esds->decoderConfigLen, false);
-- av_format_ctx->put_buffer(pb, esds->decoderConfig, esds->decoderConfigLen);
-+ av_format_ctx->avio_write(pb, esds->decoderConfig, esds->decoderConfigLen);
-
- // sync layer configuration descriptor tag
-- av_format_ctx->put_byte(pb, 0x06); // tag
-- av_format_ctx->put_byte(pb, 0x01); // length
-- av_format_ctx->put_byte(pb, 0x7F); // no SL
-+ av_format_ctx->avio_w8(pb, 0x06); // tag
-+ av_format_ctx->avio_w8(pb, 0x01); // length
-+ av_format_ctx->avio_w8(pb, 0x7F); // no SL
-
- /* no IPI_DescrPointer */
- /* no IP_IdentificationDataSet */
-@@ -666,8 +666,8 @@
- {
- while (!*(nal_start++));
- nal_end = avc_find_startcode(nal_start, end);
-- av_format_ctx->put_be32(pb, nal_end - nal_start);
-- av_format_ctx->put_buffer(pb, nal_start, nal_end - nal_start);
-+ av_format_ctx->avio_wb32(pb, nal_end - nal_start);
-+ av_format_ctx->avio_write(pb, nal_start, nal_end - nal_start);
- size += 4 + nal_end - nal_start;
- nal_start = nal_end;
- }
-@@ -678,14 +678,14 @@
- const uint8_t *buf_in, uint8_t **buf, int *size)
- {
- ByteIOContext *pb;
-- int ret = av_format_ctx->url_open_dyn_buf(&pb);
-+ int ret = av_format_ctx->avio_open_dyn_buf(&pb);
- if (ret < 0)
- return ret;
-
- avc_parse_nal_units(av_format_ctx, pb, buf_in, *size);
-
- av_util_ctx->av_freep(buf);
-- *size = av_format_ctx->url_close_dyn_buf(pb, buf);
-+ *size = av_format_ctx->avio_close_dyn_buf(pb, buf);
- return 0;
- }
-
-@@ -770,26 +770,26 @@
- }
- assert(sps);
-
-- av_format_ctx->put_byte(pb, 1); /* version */
-- av_format_ctx->put_byte(pb, sps[1]); /* profile */
-- av_format_ctx->put_byte(pb, sps[2]); /* profile compat */
-- av_format_ctx->put_byte(pb, sps[3]); /* level */
-- av_format_ctx->put_byte(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
-- av_format_ctx->put_byte(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
-+ av_format_ctx->avio_w8(pb, 1); /* version */
-+ av_format_ctx->avio_w8(pb, sps[1]); /* profile */
-+ av_format_ctx->avio_w8(pb, sps[2]); /* profile compat */
-+ av_format_ctx->avio_w8(pb, sps[3]); /* level */
-+ av_format_ctx->avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
-+ av_format_ctx->avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
-
-- av_format_ctx->put_be16(pb, sps_size);
-- av_format_ctx->put_buffer(pb, sps, sps_size);
-+ av_format_ctx->avio_wb16(pb, sps_size);
-+ av_format_ctx->avio_write(pb, sps, sps_size);
- if (pps)
- {
-- av_format_ctx->put_byte(pb, 1); /* number of pps */
-- av_format_ctx->put_be16(pb, pps_size);
-- av_format_ctx->put_buffer(pb, pps, pps_size);
-+ av_format_ctx->avio_w8(pb, 1); /* number of pps */
-+ av_format_ctx->avio_wb16(pb, pps_size);
-+ av_format_ctx->avio_write(pb, pps, pps_size);
- }
- av_util_ctx->av_free(start);
- }
- else
- {
-- av_format_ctx->put_buffer(pb, data, len);
-+ av_format_ctx->avio_write(pb, data, len);
- }
- }
- return 0;
-@@ -1086,7 +1086,7 @@
- ByteIOContext *pb;
- quicktime_esds_t *esds;
-
-- if (m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- return false;
-
- esds = quicktime_set_esds(m_dllAvFormat, extradata, extrasize);
-@@ -1095,7 +1095,7 @@
- // unhook from ffmpeg's extradata
- extradata = NULL;
- // extract the esds atom decoderConfig from extradata
-- extrasize = m_dllAvFormat->url_close_dyn_buf(pb, &extradata);
-+ extrasize = m_dllAvFormat->avio_close_dyn_buf(pb, &extradata);
- free(esds->decoderConfig);
- free(esds);
-
-@@ -1152,7 +1152,7 @@
- // NAL reformating to bitstream format required
-
- ByteIOContext *pb;
-- if (m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- return false;
-
- m_convert_bytestream = true;
-@@ -1161,7 +1161,7 @@
- // unhook from ffmpeg's extradata
- extradata = NULL;
- // extract the avcC atom data into extradata getting size into extrasize
-- extrasize = m_dllAvFormat->url_close_dyn_buf(pb, &extradata);
-+ extrasize = m_dllAvFormat->avio_close_dyn_buf(pb, &extradata);
-
- // check for interlaced and get number of ref frames
- if (!validate_avcC_spc(extradata, extrasize, &m_max_ref_frames))
-@@ -1301,17 +1301,17 @@
- if (m_convert_bytestream)
- {
- // convert demuxer packet from bytestream (AnnexB) to bitstream
-- if(m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if(m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- return VC_ERROR;
-
- demux_size = avc_parse_nal_units(m_dllAvFormat, pb, pData, iSize);
-- demux_size = m_dllAvFormat->url_close_dyn_buf(pb, &demux_buff);
-+ demux_size = m_dllAvFormat->avio_close_dyn_buf(pb, &demux_buff);
- sampleBuff = CreateSampleBufferFrom(m_fmt_desc, demux_buff, demux_size);
- }
- else if (m_convert_3byteTo4byteNALSize)
- {
- // convert demuxer packet from 3 byte NAL sizes to 4 byte
-- if (m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- return VC_ERROR;
-
- uint32_t nal_size;
-@@ -1320,13 +1320,13 @@
- while (nal_start < end)
- {
- nal_size = VDA_RB24(nal_start);
-- m_dllAvFormat->put_be32(pb, nal_size);
-+ m_dllAvFormat->avio_wb32(pb, nal_size);
- nal_start += 3;
-- m_dllAvFormat->put_buffer(pb, nal_start, nal_size);
-+ m_dllAvFormat->avio_write(pb, nal_start, nal_size);
- nal_start += nal_size;
- }
-
-- demux_size = m_dllAvFormat->url_close_dyn_buf(pb, &demux_buff);
-+ demux_size = m_dllAvFormat->avio_close_dyn_buf(pb, &demux_buff);
- sampleBuff = CreateSampleBufferFrom(m_fmt_desc, demux_buff, demux_size);
- }
- else
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp 2012-06-05 15:19:23.950496372 +0200
-@@ -223,7 +223,6 @@
- }
-
- pic->type = FF_BUFFER_TYPE_USER;
-- pic->age = 1;
- pic->data[0] = (uint8_t*)wrapper;
- pic->data[1] = NULL;
- pic->data[2] = NULL;
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp 2012-06-05 15:19:23.951496392 +0200
-@@ -1197,14 +1197,12 @@
-
- if(pic->reference)
- {
-- pic->age = pA->ip_age[0];
- pA->ip_age[0]= pA->ip_age[1]+1;
- pA->ip_age[1]= 1;
- pA->b_age++;
- }
- else
- {
-- pic->age = pA->b_age;
- pA->ip_age[0]++;
- pA->ip_age[1]++;
- pA->b_age = 1;
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp 2012-06-05 15:19:23.955496472 +0200
-@@ -160,7 +160,7 @@
- #define g_demuxer (*((CDVDDemuxFFmpeg**)g_tls.Get()))
- #endif
-
--static int interrupt_cb(void)
-+static int interrupt_cb(void* unused)
- {
- if(g_demuxer && g_demuxer->Aborted())
- return 1;
-@@ -178,7 +178,7 @@
-
- static int dvd_file_read(void *h, uint8_t* buf, int size)
- {
-- if(interrupt_cb())
-+ if(interrupt_cb(NULL))
- return -1;
-
- CDVDInputStream* pInputStream = (CDVDInputStream*)h;
-@@ -192,7 +192,7 @@
- */
- static offset_t dvd_file_seek(void *h, offset_t pos, int whence)
- {
-- if(interrupt_cb())
-+ if(interrupt_cb(NULL))
- return -1;
-
- CDVDInputStream* pInputStream = (CDVDInputStream*)h;
-@@ -236,6 +236,7 @@
- m_speed = DVD_PLAYSPEED_NORMAL;
- g_demuxer = this;
- m_program = UINT_MAX;
-+ const AVIOInterruptCB int_cb = { interrupt_cb, NULL };
-
- if (!pInput) return false;
-
-@@ -246,10 +247,6 @@
-
- // register codecs
- m_dllAvFormat.av_register_all();
-- m_dllAvFormat.url_set_interrupt_cb(interrupt_cb);
--
-- // could be used for interupting ffmpeg while opening a file (eg internet streams)
-- // url_set_interrupt_cb(NULL);
-
- m_pInput = pInput;
- strFile = m_pInput->GetFileName();
-@@ -284,14 +281,14 @@
- // try mmsh, then mmst
- CStdString strFile2;
- strFile2.Format("mmsh://%s",strFile.substr(6,strFile.size()-6).c_str());
-- result = m_dllAvFormat.av_open_input_file(&m_pFormatContext, strFile2.c_str(), iformat, FFMPEG_FILE_BUFFER_SIZE, NULL);
-+ result = m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile2.c_str(), iformat, NULL);
- if (result < 0)
- {
- strFile = "mmst://";
- strFile += strFile2.Mid(7).c_str();
- }
- }
-- if (result < 0 && m_dllAvFormat.av_open_input_file(&m_pFormatContext, strFile.c_str(), iformat, FFMPEG_FILE_BUFFER_SIZE, NULL) < 0 )
-+ if (result < 0 && m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, NULL) < 0 )
- {
- CLog::Log(LOGDEBUG, "Error, could not open file %s", strFile.c_str());
- Dispose();
-@@ -301,24 +298,16 @@
- else
- {
- unsigned char* buffer = (unsigned char*)m_dllAvUtil.av_malloc(FFMPEG_FILE_BUFFER_SIZE);
-- m_ioContext = m_dllAvFormat.av_alloc_put_byte(buffer, FFMPEG_FILE_BUFFER_SIZE, 0, m_pInput, dvd_file_read, NULL, dvd_file_seek);
-+ m_ioContext = m_dllAvFormat.avio_alloc_context(buffer, FFMPEG_FILE_BUFFER_SIZE, 0, m_pInput, dvd_file_read, NULL, dvd_file_seek);
- m_ioContext->max_packet_size = m_pInput->GetBlockSize();
- if(m_ioContext->max_packet_size)
- m_ioContext->max_packet_size *= FFMPEG_FILE_BUFFER_SIZE / m_ioContext->max_packet_size;
-
- if(m_pInput->Seek(0, SEEK_POSSIBLE) == 0)
-- m_ioContext->is_streamed = 1;
-+ m_ioContext->seekable = 0;
-
- if( iformat == NULL )
- {
--#if defined(USE_EXTERNAL_FFMPEG) && LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52,98,0)
-- // API added on: 2011-02-09
-- // Old versions of ffmpeg do not have av_probe_input_format, so we need
-- // to always probe using the lower-level functions as well.
-- const bool legacyProbing = true;
--#else
-- const bool legacyProbing = false;
--#endif
- // let ffmpeg decide which demuxer we have to open
-
- bool trySPDIFonly = (m_pInput->GetContent() == "audio/x-spdif-compressed");
-@@ -331,7 +320,7 @@
- // want to probe for spdif (DTS or IEC 61937) compressed audio
- // specifically, or in case the file is a wav which may contain DTS or
- // IEC 61937 (e.g. ac3-in-wav) and we want to check for those formats.
-- if (legacyProbing || trySPDIFonly || (iformat && strcmp(iformat->name, "wav") == 0))
-+ if (trySPDIFonly || (iformat && strcmp(iformat->name, "wav") == 0))
- {
- AVProbeData pd;
- BYTE probe_buffer[FFMPEG_FILE_BUFFER_SIZE + AVPROBE_PADDING_SIZE];
-@@ -341,7 +330,7 @@
- pd.filename = strFile.c_str();
-
- // read data using avformat's buffers
-- pd.buf_size = m_dllAvFormat.get_buffer(m_ioContext, pd.buf, m_ioContext->max_packet_size ? m_ioContext->max_packet_size : m_ioContext->buffer_size);
-+ pd.buf_size = m_dllAvFormat.avio_read(m_ioContext, pd.buf, m_ioContext->max_packet_size ? m_ioContext->max_packet_size : m_ioContext->buffer_size);
- if (pd.buf_size <= 0)
- {
- CLog::Log(LOGERROR, "%s - error reading from input stream, %s", __FUNCTION__, strFile.c_str());
-@@ -350,10 +339,7 @@
- memset(pd.buf+pd.buf_size, 0, AVPROBE_PADDING_SIZE);
-
- // restore position again
-- m_dllAvFormat.url_fseek(m_ioContext , 0, SEEK_SET);
--
-- if (legacyProbing && !trySPDIFonly)
-- iformat = m_dllAvFormat.av_probe_input_format(&pd, 1);
-+ m_dllAvFormat.avio_seek(m_ioContext , 0, SEEK_SET);
-
- // the advancedsetting is for allowing the user to force outputting the
- // 44.1 kHz DTS wav file as PCM, so that an A/V receiver can decode
-@@ -424,7 +410,10 @@
-
-
- // open the demuxer
-- if (m_dllAvFormat.av_open_input_stream(&m_pFormatContext, m_ioContext, strFile.c_str(), iformat, NULL) < 0)
-+ m_pFormatContext = m_dllAvFormat.avformat_alloc_context();
-+ m_pFormatContext->pb = m_ioContext;
-+
-+ if (m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, NULL) < 0)
- {
- CLog::Log(LOGERROR, "%s - Error, could not open file %s", __FUNCTION__, strFile.c_str());
- Dispose();
-@@ -432,8 +421,11 @@
- }
- }
-
-+ // set the interrupt callback, appeared in libavformat 53.15.0
-+ m_pFormatContext->interrupt_callback = int_cb;
-+
- // analyse very short to speed up mjpeg playback start
-- if (iformat && (strcmp(iformat->name, "mjpeg") == 0) && m_ioContext->is_streamed)
-+ if (iformat && (strcmp(iformat->name, "mjpeg") == 0) && m_ioContext->seekable == 0)
- m_pFormatContext->max_analyze_duration = 500000;
-
- // we need to know if this is matroska or avi later
-@@ -447,8 +439,8 @@
- m_pFormatContext->max_analyze_duration = 500000;
-
-
-- CLog::Log(LOGDEBUG, "%s - av_find_stream_info starting", __FUNCTION__);
-- int iErr = m_dllAvFormat.av_find_stream_info(m_pFormatContext);
-+ CLog::Log(LOGDEBUG, "%s - avformat_find_stream_info starting", __FUNCTION__);
-+ int iErr = m_dllAvFormat.avformat_find_stream_info(m_pFormatContext, NULL);
- if (iErr < 0)
- {
- CLog::Log(LOGWARNING,"could not find codec parameters for %s", strFile.c_str());
-@@ -471,7 +463,7 @@
- m_pFormatContext->flags |= AVFMT_FLAG_NONBLOCK;
-
- // print some extra information
-- m_dllAvFormat.dump_format(m_pFormatContext, 0, strFile.c_str(), 0);
-+ m_dllAvFormat.av_dump_format(m_pFormatContext, 0, strFile.c_str(), 0);
-
- UpdateCurrentPTS();
-
-@@ -510,20 +502,12 @@
-
- if (m_pFormatContext)
- {
-- if (m_ioContext)
-+ if (m_ioContext && m_pFormatContext->pb && m_pFormatContext->pb != m_ioContext)
- {
-- if(m_pFormatContext->pb && m_pFormatContext->pb != m_ioContext)
-- {
-- CLog::Log(LOGWARNING, "CDVDDemuxFFmpeg::Dispose - demuxer changed our byte context behind our back, possible memleak");
-- m_ioContext = m_pFormatContext->pb;
-- }
-- m_dllAvFormat.av_close_input_stream(m_pFormatContext);
-- if (m_ioContext->buffer)
-- m_dllAvUtil.av_free(m_ioContext->buffer);
-- m_dllAvUtil.av_free(m_ioContext);
-+ CLog::Log(LOGWARNING, "CDVDDemuxFFmpeg::Dispose - demuxer changed our byte context behind our back, possible memleak");
-+ m_ioContext = m_pFormatContext->pb;
- }
-- else
-- m_dllAvFormat.av_close_input_file(m_pFormatContext);
-+ m_dllAvFormat.avformat_close_input(&m_pFormatContext);
- }
- m_ioContext = NULL;
- m_pFormatContext = NULL;
-@@ -773,19 +757,12 @@
- {
- stream->duration = duration;
- duration = m_dllAvUtil.av_rescale_rnd(stream->duration, (int64_t)stream->time_base.num * AV_TIME_BASE, stream->time_base.den, AV_ROUND_NEAR_INF);
-- if ((m_pFormatContext->duration == (int64_t)AV_NOPTS_VALUE && m_pFormatContext->file_size > 0)
-+ if ((m_pFormatContext->duration == (int64_t)AV_NOPTS_VALUE)
- || (m_pFormatContext->duration != (int64_t)AV_NOPTS_VALUE && duration > m_pFormatContext->duration))
- m_pFormatContext->duration = duration;
- }
- }
-
-- // check if stream seem to have grown since start
-- if(m_pFormatContext->file_size > 0 && m_pFormatContext->pb)
-- {
-- if(m_pFormatContext->pb->pos > m_pFormatContext->file_size)
-- m_pFormatContext->file_size = m_pFormatContext->pb->pos;
-- }
--
- pPacket->iStreamId = pkt.stream_index; // XXX just for now
- }
- m_dllAvCodec.av_free_packet(&pkt);
-@@ -923,19 +900,6 @@
- if (!m_pFormatContext)
- return 0;
-
-- /* apperently ffmpeg messes up sometimes, so check for negative value too */
-- if (m_pFormatContext->duration == (int64_t)AV_NOPTS_VALUE || m_pFormatContext->duration < 0LL)
-- {
-- // no duration is available for us
-- // try to calculate it
-- int iLength = 0;
-- if (m_iCurrentPts != DVD_NOPTS_VALUE && m_pFormatContext->file_size > 0 && m_pFormatContext->pb && m_pFormatContext->pb->pos > 0)
-- {
-- iLength = (int)(((m_iCurrentPts * m_pFormatContext->file_size) / m_pFormatContext->pb->pos) / 1000) & 0xFFFFFFFF;
-- }
-- return iLength;
-- }
--
- return (int)(m_pFormatContext->duration / (AV_TIME_BASE / 1000));
- }
-
-@@ -970,6 +934,12 @@
-
- void CDVDDemuxFFmpeg::AddStream(int iId)
- {
-+ if(iId >= MAX_STREAMS)
-+ {
-+ CLog::Log(LOGWARNING, "%s - streams id %d exeeds maximum supported", __FUNCTION__, iId);
-+ return;
-+ }
-+
- AVStream* pStream = m_pFormatContext->streams[iId];
- if (pStream)
- {
-@@ -987,8 +957,8 @@
- st->iBitRate = pStream->codec->bit_rate;
- st->iBitsPerSample = pStream->codec->bits_per_coded_sample;
-
-- if(m_dllAvFormat.av_metadata_get(pStream->metadata, "title", NULL, 0))
-- st->m_description = m_dllAvFormat.av_metadata_get(pStream->metadata, "title", NULL, 0)->value;
-+ if(m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0))
-+ st->m_description = m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0)->value;
-
- break;
- }
-@@ -1077,8 +1047,8 @@
- if(pStream->codec)
- st->identifier = pStream->codec->sub_id;
-
-- if(m_dllAvFormat.av_metadata_get(pStream->metadata, "title", NULL, 0))
-- st->m_description = m_dllAvFormat.av_metadata_get(pStream->metadata, "title", NULL, 0)->value;
-+ if(m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0))
-+ st->m_description = m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0)->value;
-
- break;
- }
-@@ -1089,7 +1059,7 @@
- {
- std::string fileName = "special://temp/fonts/";
- XFILE::CDirectory::Create(fileName);
-- AVMetadataTag *nameTag = m_dllAvFormat.av_metadata_get(pStream->metadata, "filename", NULL, 0);
-+ AVDictionaryEntry *nameTag = m_dllAvUtil.av_dict_get(pStream->metadata, "filename", NULL, 0);
- if (!nameTag) {
- CLog::Log(LOGERROR, "%s: TTF attachment has no name", __FUNCTION__);
- break;
-@@ -1138,7 +1108,7 @@
- // API added on: 2010-10-15
- // (Note that while the function was available earlier, the generic
- // metadata tags were not populated by default)
-- AVMetadataTag *langTag = m_dllAvFormat.av_metadata_get(pStream->metadata, "language", NULL, 0);
-+ AVDictionaryEntry *langTag = m_dllAvUtil.av_dict_get(pStream->metadata, "language", NULL, 0);
- if (langTag)
- strncpy(m_streams[iId]->language, langTag->value, 3);
- #else
-@@ -1248,7 +1218,7 @@
- // API added on: 2010-10-15
- // (Note that while the function was available earlier, the generic
- // metadata tags were not populated by default)
-- AVMetadataTag *titleTag = m_dllAvFormat.av_metadata_get(m_pFormatContext->chapters[chapterIdx-1]->metadata,
-+ AVDictionaryEntry *titleTag = m_dllAvUtil.av_dict_get(m_pFormatContext->chapters[chapterIdx-1]->metadata,
- "title", NULL, 0);
- if (titleTag)
- strChapterName = titleTag->value;
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h 2012-06-05 15:19:23.956496492 +0200
-@@ -128,7 +128,7 @@
- #define MAX_STREAMS 100
- CDemuxStream* m_streams[MAX_STREAMS]; // maximum number of streams that ffmpeg can handle
-
-- ByteIOContext* m_ioContext;
-+ AVIOContext* m_ioContext;
-
- DllAvFormat m_dllAvFormat;
- DllAvCodec m_dllAvCodec;
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2012-06-05 15:19:23.957496512 +0200
-@@ -413,6 +413,7 @@
- {
- if(m_pVideoCodec)
- m_pVideoCodec->Reset();
-+ picture.iFlags &= ~DVP_FLAG_ALLOCATED;
- m_packets.clear();
- m_started = false;
- }
-@@ -420,6 +421,7 @@
- {
- if(m_pVideoCodec)
- m_pVideoCodec->Reset();
-+ picture.iFlags &= ~DVP_FLAG_ALLOCATED;
- m_packets.clear();
-
- m_pullupCorrection.Flush();
-diff -Naur xbmc-11.0.1/xbmc/DllPaths_generated.h.in xbmc-11.0.1.patch/xbmc/DllPaths_generated.h.in
---- xbmc-11.0.1/xbmc/DllPaths_generated.h.in 2012-03-21 23:57:32.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/DllPaths_generated.h.in 2012-06-05 15:19:23.957496512 +0200
-@@ -74,13 +74,13 @@
- #define DLL_PATH_LIBMAD "@MAD_SONAME@"
-
- /* ffmpeg */
--#define DLL_PATH_LIBAVCODEC "special://xbmcbin/system/players/dvdplayer/avcodec-52-@ARCH@.so"
--#define DLL_PATH_LIBAVCORE "special://xbmcbin/system/players/dvdplayer/avcore-0-@ARCH@.so"
--#define DLL_PATH_LIBAVFORMAT "special://xbmcbin/system/players/dvdplayer/avformat-52-@ARCH@.so"
--#define DLL_PATH_LIBAVUTIL "special://xbmcbin/system/players/dvdplayer/avutil-50-@ARCH@.so"
--#define DLL_PATH_LIBPOSTPROC "special://xbmcbin/system/players/dvdplayer/postproc-51-@ARCH@.so"
--#define DLL_PATH_LIBSWSCALE "special://xbmcbin/system/players/dvdplayer/swscale-0-@ARCH@.so"
--#define DLL_PATH_LIBAVFILTER "special://xbmcbin/system/players/dvdplayer/avfilter-1-@ARCH@.so"
-+#define DLL_PATH_LIBAVCODEC "special://xbmcbin/system/players/dvdplayer/avcodec-53-@ARCH@.so"
-+#define DLL_PATH_LIBAVFORMAT "special://xbmcbin/system/players/dvdplayer/avformat-53-@ARCH@.so"
-+#define DLL_PATH_LIBAVUTIL "special://xbmcbin/system/players/dvdplayer/avutil-51-@ARCH@.so"
-+#define DLL_PATH_LIBPOSTPROC "special://xbmcbin/system/players/dvdplayer/postproc-52-@ARCH@.so"
-+#define DLL_PATH_LIBSWSCALE "special://xbmcbin/system/players/dvdplayer/swscale-2-@ARCH@.so"
-+#define DLL_PATH_LIBAVFILTER "special://xbmcbin/system/players/dvdplayer/avfilter-2-@ARCH@.so"
-+#define DLL_PATH_LIBSWRESAMPLE "special://xbmcbin/system/players/dvdplayer/swresample-0-@ARCH@.so"
-
- /* cdrip */
- #if defined(_LINUX) && !defined(__APPLE__)
-diff -Naur xbmc-11.0.1/xbmc/DllPaths_win32.h xbmc-11.0.1.patch/xbmc/DllPaths_win32.h
---- xbmc-11.0.1/xbmc/DllPaths_win32.h 2012-03-21 23:57:32.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/DllPaths_win32.h 2012-06-05 15:19:23.958496532 +0200
-@@ -58,13 +58,13 @@
- #define DLL_PATH_LIBRTMP "special://xbmcbin/system/players/dvdplayer/librtmp.dll"
-
- /* ffmpeg */
--#define DLL_PATH_LIBAVCODEC "special://xbmcbin/system/players/dvdplayer/avcodec-52.dll"
--#define DLL_PATH_LIBAVCORE "special://xbmcbin/system/players/dvdplayer/avcore-0.dll"
--#define DLL_PATH_LIBAVFORMAT "special://xbmcbin/system/players/dvdplayer/avformat-52.dll"
--#define DLL_PATH_LIBAVUTIL "special://xbmcbin/system/players/dvdplayer/avutil-50.dll"
--#define DLL_PATH_LIBAVFILTER "special://xbmcbin/system/players/dvdplayer/avfilter-1.dll"
--#define DLL_PATH_LIBPOSTPROC "special://xbmcbin/system/players/dvdplayer/postproc-51.dll"
--#define DLL_PATH_LIBSWSCALE "special://xbmcbin/system/players/dvdplayer/swscale-0.dll"
-+#define DLL_PATH_LIBAVCODEC "special://xbmcbin/system/players/dvdplayer/avcodec-53.dll"
-+#define DLL_PATH_LIBAVFORMAT "special://xbmcbin/system/players/dvdplayer/avformat-53.dll"
-+#define DLL_PATH_LIBAVUTIL "special://xbmcbin/system/players/dvdplayer/avutil-51.dll"
-+#define DLL_PATH_LIBAVFILTER "special://xbmcbin/system/players/dvdplayer/avfilter-2.dll"
-+#define DLL_PATH_LIBPOSTPROC "special://xbmcbin/system/players/dvdplayer/postproc-52.dll"
-+#define DLL_PATH_LIBSWSCALE "special://xbmcbin/system/players/dvdplayer/swscale-2.dll"
-+#define DLL_PATH_LIBSWRESAMPLE "special://xbmcbin/system/players/dvdplayer/swresample-0.dll"
-
- /* cdrip */
- #define DLL_PATH_LAME_ENC "special://xbmcbin/system/cdrip/lame_enc.dll"
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-001-add_support_to_specify_GIT_REV-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-001-add_support_to_specify_GIT_REV-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-001-add_support_to_specify_GIT_REV-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-001-add_support_to_specify_GIT_REV-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-303-fix_libdvd_xFLAGS-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-303-fix_libdvd_xFLAGS-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-303-fix_libdvd_xFLAGS-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-303-fix_libdvd_xFLAGS-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-311-fix_rsxs_build-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-311-fix_rsxs_build-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-311-fix_rsxs_build-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-311-fix_rsxs_build-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-321-texturepacker-hostflags-and-rework.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-321-texturepacker-hostflags-and-rework.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-321-texturepacker-hostflags-and-rework.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-321-texturepacker-hostflags-and-rework.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-331-fix_playpause_problem_ticket_7338-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-331-fix_playpause_problem_ticket_7338-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-331-fix_playpause_problem_ticket_7338-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-331-fix_playpause_problem_ticket_7338-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-402-enable_yasm_in_ffmpeg-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-402-enable_yasm_in_ffmpeg-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-402-enable_yasm_in_ffmpeg-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-402-enable_yasm_in_ffmpeg-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-404-add_lame_check-0.6.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-404-add_lame_check-0.6.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-404-add_lame_check-0.6.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-404-add_lame_check-0.6.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-452-change_lcd_content-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-452-change_lcd_content-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-452-change_lcd_content-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-452-change_lcd_content-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-453-add_openelec.tv_RSS_news-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-453-add_openelec.tv_RSS_news-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-453-add_openelec.tv_RSS_news-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-453-add_openelec.tv_RSS_news-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-454-disable_backslash-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-454-disable_backslash-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-454-disable_backslash-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-454-disable_backslash-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-457-fix_connection_check-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-457-fix_connection_check-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-457-fix_connection_check-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-457-fix_connection_check-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-463-add_remote_devinput-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-463-add_remote_devinput-0.1.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-463-add_remote_devinput-0.1.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-463-add_remote_devinput-0.1.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-806.01-cdrip-PR616.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-806.01-cdrip-PR616.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-806.01-cdrip-PR616.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-806.01-cdrip-PR616.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-806.02-cdrip-PR718.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-806.02-cdrip-PR718.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-806.02-cdrip-PR718.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-806.02-cdrip-PR718.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-901.01-ffmpeg-10.2-28b186f.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-901.01-ffmpeg-10.2-28b186f.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-901.01-ffmpeg-10.2-28b186f.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-901.01-ffmpeg-10.2-28b186f.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-901.03-ffmpeg_crystalhd_implementation.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-901.03-ffmpeg_crystalhd_implementation.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-901.03-ffmpeg_crystalhd_implementation.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-901.03-ffmpeg_crystalhd_implementation.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-901.41-avfilter-depends-on-avformat.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-901.41-avfilter-depends-on-avformat.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-901.41-avfilter-depends-on-avformat.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-901.41-avfilter-depends-on-avformat.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.00-vdpau_reset_pvr_changes.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.00-vdpau_reset_pvr_changes.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.00-vdpau_reset_pvr_changes.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.00-vdpau_reset_pvr_changes.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-902.01-xvba_support_vdpau_rework-c633159.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.01-xvba_support_vdpau_rework-c633159.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-902.01-xvba_support_vdpau_rework-c633159.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.01-xvba_support_vdpau_rework-c633159.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-902.02-xvba_support-gcc-4.7.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.02-xvba_support-gcc-4.7.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-902.02-xvba_support-gcc-4.7.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.02-xvba_support-gcc-4.7.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.03-fix_configure_in_VDPAU_detect.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.03-fix_configure_in_VDPAU_detect.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.03-fix_configure_in_VDPAU_detect.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.03-fix_configure_in_VDPAU_detect.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-902.11-disable_interop.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.11-disable_interop.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-902.11-disable_interop.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.11-disable_interop.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-902.12-linuxrenderer_delete_texture_targets_on_reconfigure.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.12-linuxrenderer_delete_texture_targets_on_reconfigure.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-902.12-linuxrenderer_delete_texture_targets_on_reconfigure.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.12-linuxrenderer_delete_texture_targets_on_reconfigure.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-903.01-fixed_still_frames_at_the_start_of_a_VTS_in_dvd_could_end_up_not_showing.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-903.01-fixed_still_frames_at_the_start_of_a_VTS_in_dvd_could_end_up_not_showing.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-903.01-fixed_still_frames_at_the_start_of_a_VTS_in_dvd_could_end_up_not_showing.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-903.01-fixed_still_frames_at_the_start_of_a_VTS_in_dvd_could_end_up_not_showing.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-981-toggleButtonState.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-981-toggleButtonState.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-981-toggleButtonState.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-981-toggleButtonState.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-982-UDisk-device-must-be-remount-in-DeviceChanged-event.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-982-UDisk-device-must-be-remount-in-DeviceChanged-event.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-982-UDisk-device-must-be-remount-in-DeviceChanged-event.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-982-UDisk-device-must-be-remount-in-DeviceChanged-event.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-983-fixed-failure-to-broswe-for-smb-shares.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-983-fixed-failure-to-broswe-for-smb-shares.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-983-fixed-failure-to-broswe-for-smb-shares.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-983-fixed-failure-to-broswe-for-smb-shares.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-984-do-not-remount-non-optical-devices-in-DeviceChanged-event.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-984-do-not-remount-non-optical-devices-in-DeviceChanged-event.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-984-do-not-remount-non-optical-devices-in-DeviceChanged-event.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-984-do-not-remount-non-optical-devices-in-DeviceChanged-event.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-990-wiimote.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-990-wiimote.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-990-wiimote.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-990-wiimote.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-999-crosscompile.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999-crosscompile.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-999-crosscompile.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-999-crosscompile.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.002-268d6a0-fix_ASIC_hang.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.002-268d6a0-fix_ASIC_hang.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.002-268d6a0-fix_ASIC_hang.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.002-268d6a0-fix_ASIC_hang.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.003-rar-PR1147.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.003-rar-PR1147.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.003-rar-PR1147.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.003-rar-PR1147.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.011-airtunes_reapply_lost_fix.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.011-airtunes_reapply_lost_fix.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.011-airtunes_reapply_lost_fix.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.011-airtunes_reapply_lost_fix.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.012-airtunes_implementation_for_windows_using_libshairplay.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.012-airtunes_implementation_for_windows_using_libshairplay.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.012-airtunes_implementation_for_windows_using_libshairplay.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.012-airtunes_implementation_for_windows_using_libshairplay.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.013-airtunes-add_dmap_metadata_parsing.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.013-airtunes-add_dmap_metadata_parsing.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.013-airtunes-add_dmap_metadata_parsing.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.013-airtunes-add_dmap_metadata_parsing.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.021-libnfs-1.3_support.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.021-libnfs-1.3_support.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.021-libnfs-1.3_support.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.021-libnfs-1.3_support.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.055-search-dialogs-workaround.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.055-search-dialogs-workaround.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.055-search-dialogs-workaround.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.055-search-dialogs-workaround.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.056-remove-broken-scrapers.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.056-remove-broken-scrapers.patch
similarity index 100%
rename from packages/mediacenter/xbmc/patches/xbmc-11.0.1-999.056-remove-broken-scrapers.patch
rename to packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.056-remove-broken-scrapers.patch
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-001-add_support_to_specify_GIT_REV-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-001-add_support_to_specify_GIT_REV-0.1.patch
deleted file mode 100644
index c013e0ae3a..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-001-add_support_to_specify_GIT_REV-0.1.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff -Naur xbmc-9389dc8/configure.in xbmc-9389dc8.patch/configure.in
---- xbmc-9389dc8/configure.in 2011-09-01 17:21:47.000000000 +0200
-+++ xbmc-9389dc8.patch/configure.in 2011-09-01 23:30:40.419399392 +0200
-@@ -428,6 +428,14 @@
- esac
- AC_SUBST([ARCH])
-
-+AC_CHECK_PROG(HAVE_GIT,git,"yes","no",)
-+if test "$HAVE_GIT" = "yes" -a "$GIT_REV" = ""; then
-+ GIT_REV=$(git --no-pager log --abbrev=7 -n 1 --pretty=format:"%h %ci" HEAD | awk '{gsub("-", "");print $2"-"$1}')
-+elif test "$GIT_REV" = ""; then
-+ GIT_REV="Unknown"
-+fi
-+final_message="$final_message\n git Rev.:\t${GIT_REV}"
-+
- # platform debug flags
- if test "$use_debug" = "yes"; then
- final_message="$final_message\n Debugging:\tYes"
-@@ -1177,7 +1185,6 @@
- fi
- fi
-
--AC_CHECK_PROG(HAVE_GIT,git,"yes","no",)
-
- # Checks for header files.
- AC_HEADER_DIRENT
-@@ -1408,12 +1415,6 @@
- final_message="$final_message\n Avahi:\tNo"
- fi
-
--if test "$HAVE_GIT" = "yes"; then
-- GIT_REV=$(git --no-pager log --abbrev=7 -n 1 --pretty=format:"%h %ci" HEAD | awk '{gsub("-", "");print $2"-"$1}')
--fi
--if test "$GIT_REV" = ""; then
-- GIT_REV="Unknown"
--fi
- if test "$host_vendor" = "apple"; then
- echo "#define GIT_REV \"$GIT_REV\"" > git_revision.h
- else
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-303-fix_libdvd_xFLAGS-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-303-fix_libdvd_xFLAGS-0.1.patch
deleted file mode 100644
index 5e76acefe4..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-303-fix_libdvd_xFLAGS-0.1.patch
+++ /dev/null
@@ -1,119 +0,0 @@
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdcss/src/libdvdcss.pc.in xbmc-pvr-3513480.patch/lib/libdvd/libdvdcss/src/libdvdcss.pc.in
---- xbmc-pvr-3513480/lib/libdvd/libdvdcss/src/libdvdcss.pc.in 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdcss/src/libdvdcss.pc.in 2011-04-25 05:01:20.091837122 +0200
-@@ -6,5 +6,5 @@
- Name: libdvdcss
- Description: DVD access and decryption library.
- Version: @VERSION@
--Libs: -L${libdir} -ldvdcss
--Cflags: -I{includedir} -I${includedir}/@PACKAGE@
-+Libs: -ldvdcss
-+Cflags: -I.
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnav-config2.sh xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnav-config2.sh
---- xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnav-config2.sh 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnav-config2.sh 2011-04-25 05:01:20.549828701 +0200
-@@ -56,17 +56,17 @@
- fi
-
- if test "$echo_cflags" = "yes"; then
-- echo -I$prefix/include $dvdread_cflags $extracflags $threadcflags
-+ echo $dvdread_cflags $extracflags $threadcflags
- fi
-
- if test "$echo_minicflags" = "yes"; then
-- echo -I$prefix/include -I$prefix/include/dvdnav $extracflags $threadcflags
-+ echo $extracflags $threadcflags
- fi
-
- if test "$echo_libs" = "yes"; then
-- echo -L$libdir -ldvdnav $dvdread_libs $threadlib
-+ echo -ldvdnav $dvdread_libs $threadlib
- fi
-
- if test "$echo_minilibs" = "yes"; then
-- echo -L$libdir -ldvdnavmini $threadlib
-+ echo -ldvdnavmini $threadlib
- fi
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnav-config.in xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnav-config.in
---- xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnav-config.in 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnav-config.in 2011-04-25 05:01:20.624827321 +0200
-@@ -76,13 +76,13 @@
- fi
-
- if test "$echo_cflags" = "yes"; then
-- echo -I@includedir@ -I@includedir@/libdvdread @THREAD_CFLAGS@
-+ echo @THREAD_CFLAGS@
- fi
-
- if test "$echo_libs" = "yes"; then
-- echo -L@libdir@ -ldvdnav -ldvdread @THREAD_LIBS@
-+ echo -ldvdnav -ldvdread @THREAD_LIBS@
- fi
-
- if test "$echo_minilibs" = "yes"; then
-- echo -L@libdir@ -ldvdnavmini @THREAD_LIBS@
-+ echo -ldvdnavmini @THREAD_LIBS@
- fi
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnavmini.pc.in xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnavmini.pc.in
---- xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnavmini.pc.in 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnavmini.pc.in 2011-04-25 05:01:21.042819641 +0200
-@@ -7,5 +7,5 @@
- Description: DVD Navigation mini library
- Version: @VERSION@
-
--Cflags: -I${includedir} @DVDREAD_CFLAGS@ @THREAD_CFLAGS@
--Libs: -L${libdir} -ldvdnav @THREAD_LIBS@
-+Cflags: @DVDREAD_CFLAGS@ @THREAD_CFLAGS@
-+Libs: -ldvdnav @THREAD_LIBS@
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnav.pc.in xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnav.pc.in
---- xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnav.pc.in 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnav.pc.in 2011-04-25 05:01:21.262815601 +0200
-@@ -8,5 +8,5 @@
- Version: @VERSION@
-
- Requires.private: dvdread >= 4.1.2
--Cflags: -I${includedir} @THREAD_CFLAGS@
--Libs: -L${libdir} -ldvdnav @THREAD_LIBS@
-+Cflags: @THREAD_CFLAGS@
-+Libs: -ldvdnav @THREAD_LIBS@
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdread/misc/dvdread-config.in xbmc-pvr-3513480.patch/lib/libdvd/libdvdread/misc/dvdread-config.in
---- xbmc-pvr-3513480/lib/libdvd/libdvdread/misc/dvdread-config.in 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdread/misc/dvdread-config.in 2011-04-25 05:01:21.278815307 +0200
-@@ -72,9 +72,9 @@
- fi
-
- if test "$echo_cflags" = "yes"; then
-- echo -I@includedir@
-+ echo ""
- fi
-
- if test "$echo_libs" = "yes"; then
-- echo -L@libdir@ -ldvdread
-+ echo -ldvdread
- fi
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdread/misc/dvdread-config.sh xbmc-pvr-3513480.patch/lib/libdvd/libdvdread/misc/dvdread-config.sh
---- xbmc-pvr-3513480/lib/libdvd/libdvdread/misc/dvdread-config.sh 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdread/misc/dvdread-config.sh 2011-04-25 05:01:21.278815307 +0200
-@@ -48,9 +48,9 @@
- fi
-
- if test "$echo_cflags" = "yes"; then
-- echo -I$prefix/include $extracflags
-+ echo $extracflags
- fi
-
- if test "$echo_libs" = "yes"; then
-- echo -L$libdir $dvdreadlib
-+ echo $dvdreadlib
- fi
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdread/misc/dvdread.pc.in xbmc-pvr-3513480.patch/lib/libdvd/libdvdread/misc/dvdread.pc.in
---- xbmc-pvr-3513480/lib/libdvd/libdvdread/misc/dvdread.pc.in 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdread/misc/dvdread.pc.in 2011-04-25 05:01:21.279815289 +0200
-@@ -7,5 +7,5 @@
- Description: Low level DVD access library
- Version: @VERSION@
-
--Cflags: -I${includedir}
--Libs: -L${libdir} -ldvdread
-+Cflags: -I.
-+Libs: -ldvdread
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-311-fix_rsxs_build-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-311-fix_rsxs_build-0.1.patch
deleted file mode 100644
index fe0ee49cab..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-311-fix_rsxs_build-0.1.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Naur xbmc-dab646e/xbmc/screensavers/rsxs-0.9/lib/argp-namefrob.h xbmc-dab646e.patch/xbmc/screensavers/rsxs-0.9/lib/argp-namefrob.h
---- xbmc-dab646e/xbmc/screensavers/rsxs-0.9/lib/argp-namefrob.h 2011-09-27 15:56:19.000000000 +0200
-+++ xbmc-dab646e.patch/xbmc/screensavers/rsxs-0.9/lib/argp-namefrob.h 2011-10-16 02:13:13.805433847 +0200
-@@ -17,7 +17,7 @@
- with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-
--#if !_LIBC
-+#if 0
- /* This code is written for inclusion in gnu-libc, and uses names in the
- namespace reserved for libc. If we're not compiling in libc, define those
- names to be the normal ones instead. */
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-321-texturepacker-hostflags-and-rework.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-321-texturepacker-hostflags-and-rework.patch
deleted file mode 100644
index 507334d2e2..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-321-texturepacker-hostflags-and-rework.patch
+++ /dev/null
@@ -1,199 +0,0 @@
-diff -Naur xbmc-pvr-11.0.1/configure.in xbmc-pvr-11.0.1.patch/configure.in
---- xbmc-pvr-11.0.1/configure.in 2012-03-27 17:55:54.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/configure.in 2012-06-19 04:44:55.985036378 +0200
-@@ -385,6 +385,12 @@
- [use_texturepacker=$enableval],
- [use_texturepacker=auto])
-
-+AC_ARG_WITH([texturepacker-root],
-+ [AS_HELP_STRING([--with-texturepacker-root],
-+ [root dir to search for librarys and includes if building native TexturePacker (default is \$prefix)])],
-+ [use_texturepacker_root=$withval],
-+ [use_texturepacker_root=$prefix])
-+
- AC_ARG_WITH([lirc-device],
- [AS_HELP_STRING([--with-lirc-device=file],
- [specify the default LIRC device (default is /dev/lircd)])],
-@@ -466,8 +472,7 @@
- use_cpu=cortex-a8
- check_sdl_arch=[`file /opt/local/lib/libSDL_image.dylib | awk '{V=7; print $V}'`]
- if test "x$check_sdl_arch" = "xi386"; then
-- use_texturepacker_native=yes
-- USE_TEXTUREPACKER_NATIVE_ROOT="/opt/local"
-+ use_texturepacker_root="/opt/local"
- else
- use_texturepacker=no
- fi
-@@ -484,8 +489,6 @@
- *86-apple-darwin*)
- use_joystick=no
- use_vtbdecoder=no
-- use_texturepacker_native=yes
-- USE_TEXTUREPACKER_NATIVE_ROOT="$prefix"
- ARCH="x86-osx"
- AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_OSX -D_LINUX")
- ;;
-@@ -1649,17 +1652,17 @@
-
- USE_TEXTUREPACKER_NATIVE=0
- if test "x$use_texturepacker" != "xno"; then
-- final_message="$final_message\n TexturePacker:Yes"
-- USE_TEXTUREPACKER=1
-- if test "x$use_texturepacker_native" = "xyes"; then
-+ if test "x$cross_compiling" = "xyes"; then
- USE_TEXTUREPACKER_NATIVE=1
-- if [[ ! -d "$USE_TEXTUREPACKER_NATIVE_ROOT" ]]; then
-- USE_TEXTUREPACKER_NATIVE_ROOT=
-- fi
-+ USE_TEXTUREPACKER_NATIVE_ROOT="$use_texturepacker_root"
-+ final_message="$final_message\n TexturePacker:Native ($USE_TEXTUREPACKER_NATIVE_ROOT)"
-+ else
-+ USE_TEXTUREPACKER=1
-+ final_message="$final_message\n TexturePacker:Yes"
- fi
- else
-- final_message="$final_message\n TexturePacker:No"
- USE_TEXTUREPACKER=0
-+ final_message="$final_message\n TexturePacker:No"
- fi
-
- if test "$use_mid" = "yes"; then
-diff -Naur xbmc-pvr-11.0.1/lib/libsquish/Makefile.in xbmc-pvr-11.0.1.patch/lib/libsquish/Makefile.in
---- xbmc-pvr-11.0.1/lib/libsquish/Makefile.in 2012-03-27 17:55:41.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/lib/libsquish/Makefile.in 2012-06-19 02:45:32.926185206 +0200
-@@ -1,6 +1,6 @@
- ARCH=@ARCH@
-
--SRCS= \
-+SRCS = \
- alpha.cpp \
- clusterfit.cpp \
- colourblock.cpp \
-@@ -11,27 +11,30 @@
- singlecolourfit.cpp \
- squish.cpp
-
--CXXFLAGS+=-I.
-+LIB = libsquish.a
-+NATIVE_LIB = libsquish-native.so
-+CLEAN_FILES += $(NATIVE_LIB)
-+
-+HOST_CXX ?= g++
-+CXXFLAGS += -I.
-+HOST_CXXFLAGS += -I.
-+
- ifeq ($(findstring powerpc,$(ARCH)),powerpc)
-- CXXFLAGS+=-DSQUISH_USE_ALTIVEC=1 -maltivec
-+ CXXFLAGS += -DSQUISH_USE_ALTIVEC=1 -maltivec
-+ HOST_CXXFLAGS += -DSQUISH_USE_ALTIVEC=1 -maltivec
- else ifeq ($(findstring x86,$(ARCH)), x86)
-- CXXFLAGS+=-DSQUISH_USE_SSE=2 -msse2
-+ CXXFLAGS += -DSQUISH_USE_SSE=2 -msse2
-+ HOST_CXXFLAGS += -DSQUISH_USE_SSE=2 -msse2
- endif
-
--LIB=libsquish.a
--
--ifeq (@USE_TEXTUREPACKER_NATIVE@,1)
--NATIVE_LIB=libsquish-native.so
--CLEAN_FILES+=$(NATIVE_LIB)
-+$(LIB): $(SRCS)
-
--all: $(LIB) $(NATIVE_LIB)
- # TexturePacker links to libsquish and needs to run on build system, so make a native flavor.
- $(NATIVE_LIB): $(SRCS)
- ifeq ($(findstring osx,$(ARCH)),osx)
-- g++ -m32 -DSQUISH_USE_SSE=2 -msse2 -I. $(SRCS) -dynamiclib -install_name `pwd`/libsquish-native.so -o $@
-+ $(HOST_CXX) -m32 $(HOST_CXXFLAGS) $(SRCS) -dynamiclib -install_name `pwd`/libsquish-native.so -o $@
- else
-- g++ -DSQUISH_USE_SSE=2 -msse2 -I. $(SRCS) -shared -fPIC -Wl,-soname,`pwd`/libsquish-native.so -o $@
--endif
-+ $(HOST_CXX) $(HOST_CXXFLAGS) $(SRCS) -shared -fPIC -Wl,-soname,`pwd`/libsquish-native.so -o $@
- endif
-
- include ../../Makefile.include
-diff -Naur xbmc-pvr-11.0.1/tools/TexturePacker/Makefile.in xbmc-pvr-11.0.1.patch/tools/TexturePacker/Makefile.in
---- xbmc-pvr-11.0.1/tools/TexturePacker/Makefile.in 2012-03-27 17:55:51.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/tools/TexturePacker/Makefile.in 2012-06-19 04:47:54.700638167 +0200
-@@ -1,47 +1,52 @@
--DEFINES += -D_LINUX -DUSE_LZO_PACKING
-+DEFINES += -D_LINUX -DUSE_LZO_PACKING
- ifneq ($(or $(findstring powerpc,@ARCH@),$(findstring ppc, @ARCH@)),)
--DEFINES += -DHOST_BIGENDIAN
-+DEFINES += -DHOST_BIGENDIAN
- endif
-
--CXXFLAGS+= \
-- -I. \
-- -I@abs_top_srcdir@/lib \
-- -I@abs_top_srcdir@/xbmc \
-- -I@abs_top_srcdir@/xbmc/linux
--
--ifeq (@USE_TEXTUREPACKER_NATIVE@,1)
--NATIVE_ROOT_PATH=@USE_TEXTUREPACKER_NATIVE_ROOT@
--ifdef NATIVE_ROOT_PATH
--ifeq ($(findstring osx,@ARCH@),osx)
--CXXFLAGS+= -m32
--endif
--CXXFLAGS+= -I$(NATIVE_ROOT_PATH)/include
--LIBS += -L$(NATIVE_ROOT_PATH)/lib
--endif
--LIBS += -L@abs_top_srcdir@/lib/libsquish -lsquish-native
--else
--LIBS += -L@abs_top_srcdir@/lib/libsquish -lsquish
--endif
--
--LIBS += -lSDL_image -lSDL -llzo2
--
--SRCS = \
-+SRCS = \
- md5.cpp \
- SDL_anigif.cpp \
- XBTFWriter.cpp \
- XBMCTex.cpp \
- @abs_top_srcdir@/xbmc/guilib/XBTF.cpp
-
--
--TARGET = TexturePacker
--CLEAN_FILES=$(TARGET)
-+TARGET = TexturePacker
-+CLEAN_FILES = $(TARGET)
-
- all: $(TARGET)
-
-+HOST_CXX ?= g++
-+HOST_ROOT_PATH = @USE_TEXTUREPACKER_NATIVE_ROOT@
-+
-+LIBS += -lSDL_image -lSDL -llzo2
-+LIBS += -L@abs_top_srcdir@/lib/libsquish -lsquish
-+HOST_LIBS += -L$(HOST_ROOT_PATH)/lib -lSDL_image -lSDL -llzo2
-+HOST_LIBS += -L@abs_top_srcdir@/lib/libsquish -lsquish-native
-+
-+CXXFLAGS += \
-+ -I. \
-+ -I@abs_top_srcdir@/lib \
-+ -I@abs_top_srcdir@/xbmc \
-+ -I@abs_top_srcdir@/xbmc/linux
-+
-+HOST_CXXFLAGS += \
-+ -I. \
-+ -I@abs_top_srcdir@/lib \
-+ -I@abs_top_srcdir@/xbmc \
-+ -I@abs_top_srcdir@/xbmc/linux \
-+ -I$(HOST_ROOT_PATH)/include
-+
-+ifeq ($(findstring osx,@ARCH@),osx)
-+CXXFLAGS += -m32
-+HOST_CXXFLAGS += -m32
-+endif
-+
- ifeq (@USE_TEXTUREPACKER_NATIVE@,1)
- # TexturePacker run native on build system, build it with native tools
- $(TARGET): $(SRCS)
-- g++ $(DEFINES) $(CXXFLAGS) $(SRCS) $(LIBS) -o $(TARGET)
-+ make -C @abs_top_srcdir@/lib/libsquish libsquish-native.so
-+ $(HOST_CXX) $(DEFINES) $(HOST_CXXFLAGS) $(SRCS) $(HOST_LIBS) -o $(TARGET)
-+
- clean:
- rm -f $(TARGET)
- else
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-331-fix_playpause_problem_ticket_7338-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-331-fix_playpause_problem_ticket_7338-0.1.patch
deleted file mode 100644
index 63b04cb3e0..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-331-fix_playpause_problem_ticket_7338-0.1.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff -Naur xbmc-10.1-Dharma/xbmc/Application.cpp xbmc-10.1-Dharma.patch/xbmc/Application.cpp
---- xbmc-10.1-Dharma/xbmc/Application.cpp 2011-03-08 02:49:14.000000000 +0100
-+++ xbmc-10.1-Dharma.patch/xbmc/Application.cpp 2011-05-06 01:41:52.853741840 +0200
-@@ -2515,8 +2515,8 @@
- if (!m_pPlayer->IsPaused())
- { // unpaused - set the playspeed back to normal
- SetPlaySpeed(1);
-+ g_audioManager.Enable(m_pPlayer->IsPaused() && !g_audioContext.IsPassthroughActive());
- }
-- g_audioManager.Enable(m_pPlayer->IsPaused() && !g_audioContext.IsPassthroughActive());
- return true;
- }
- if (!m_pPlayer->IsPaused())
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-402-enable_yasm_in_ffmpeg-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-402-enable_yasm_in_ffmpeg-0.1.patch
deleted file mode 100644
index b8f5b8afcf..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-402-enable_yasm_in_ffmpeg-0.1.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-diff -Naur xbmc-pvr-3513480/configure.in xbmc-pvr-3513480.patch/configure.in
---- xbmc-pvr-3513480/configure.in 2011-04-25 02:36:33.000000000 +0200
-+++ xbmc-pvr-3513480.patch/configure.in 2011-04-25 05:14:49.220848143 +0200
-@@ -885,6 +885,9 @@
- AC_MSG_NOTICE($external_ffmpeg_disabled)
- USE_EXTERNAL_FFMPEG=0
- AC_DEFINE([PIX_FMT_VDPAU_MPEG4_IN_AVUTIL], [1], [Whether AVUtil defines PIX_FMT_VDPAU_MPEG4.])
-+
-+ # check for yasm
-+ AC_CHECK_PROG(HAVE_YASM,yasm,"yes","no",)
- fi
-
- # Python
-@@ -1547,6 +1550,7 @@
- `if test "$use_arch" != "no"; then echo --arch=$use_arch; fi`\
- `if test "$use_cpu" != "no"; then echo --cpu=$use_cpu; fi`\
- --target-os=$(tolower $(uname -s)) \
-+ `if test "$HAVE_YASM" = "yes"; then echo --enable-yasm; fi` \
- --disable-muxers \
- --enable-muxer=spdif \
- --enable-muxer=adts \
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-404-add_lame_check-0.6.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-404-add_lame_check-0.6.patch
deleted file mode 100644
index a459219108..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-404-add_lame_check-0.6.patch
+++ /dev/null
@@ -1,125 +0,0 @@
-diff -Naur xbmc-pvr-3513480/configure.in xbmc-pvr-3513480.patch/configure.in
---- xbmc-pvr-3513480/configure.in 2011-04-25 05:46:35.000000000 +0200
-+++ xbmc-pvr-3513480.patch/configure.in 2011-04-25 05:50:02.982401390 +0200
-@@ -72,6 +72,8 @@
- rsxs_disabled="== RSXS disabled. =="
- pulse_not_found="== Could not find libpulse. PulseAudio support disabled. =="
- pulse_disabled="== PulseAudio support manually disabled. =="
-+lame_not_found="== Could not find libmp3lame. LAME support disabled. =="
-+lame_disabled="== LAME support manually disabled. =="
- dvdcss_enabled="== DVDCSS support enabled. =="
- dvdcss_disabled="== DVDCSS support disabled. =="
- hal_not_found="== Could not find hal. HAL support disabled. =="
-@@ -244,6 +246,12 @@
- [use_ffmpeg_libvorbis=$enableval],
- [use_ffmpeg_libvorbis=no])
-
-+AC_ARG_ENABLE([lame],
-+ [AS_HELP_STRING([--enable-lame],
-+ [enable lame support (default is yes)])],
-+ [use_lame=$enableval],
-+ [use_lame=yes])
-+
- AC_ARG_ENABLE([dvdcss],
- [AS_HELP_STRING([--enable-dvdcss],
- [enable DVDCSS support (default is yes)])],
-@@ -758,6 +766,20 @@
- USE_PULSE=0
- fi
-
-+# LAME
-+if test "$use_lame" = "yes"; then
-+ AC_CHECK_LIB([mp3lame], [main],
-+ AC_DEFINE([HAVE_LIBMP3LAME], [1], [Define to 1 if you have the 'libmp3lame' library (-lmp3lame).]),
-+ use_lame=no;AC_MSG_RESULT($lame_not_found))
-+else
-+ AC_MSG_RESULT($lame_disabled)
-+fi
-+if test "$use_lame" = "yes"; then
-+ AC_SUBST([HAVE_LIBMP3LAME], 1)
-+else
-+ AC_SUBST([HAVE_LIBMP3LAME], 0)
-+fi
-+
- # HAL
- if test "$host_vendor" = "apple" ; then
- use_hal="no"
-@@ -1311,6 +1333,12 @@
- final_message="$final_message\n HAL Support:\tNo"
- fi
-
-+if test "$use_lame" = "yes"; then
-+ final_message="$final_message\n LAME:\t\tYes"
-+else
-+ final_message="$final_message\n LAME:\t\tNo"
-+fi
-+
- # DVDCSS
- if test "$use_dvdcss" = "yes"; then
- AC_MSG_NOTICE($dvdcss_enabled)
-diff -Naur xbmc-pvr-3513480/configure.in.orig xbmc-pvr-3513480.patch/configure.in.orig
-diff -Naur xbmc-pvr-3513480/Makefile.in.orig xbmc-pvr-3513480.patch/Makefile.in.orig
-diff -Naur xbmc-pvr-3513480/xbmc/cdrip/CDDARipper.cpp xbmc-pvr-3513480.patch/xbmc/cdrip/CDDARipper.cpp
---- xbmc-pvr-3513480/xbmc/cdrip/CDDARipper.cpp 2011-04-25 02:36:33.000000000 +0200
-+++ xbmc-pvr-3513480.patch/xbmc/cdrip/CDDARipper.cpp 2011-04-25 05:48:10.487548571 +0200
-@@ -27,7 +27,11 @@
- #include "CDDAReader.h"
- #include "utils/StringUtils.h"
- #include "Util.h"
-+
-+#ifdef HAVE_LIBMP3LAME
- #include "EncoderLame.h"
-+#endif
-+
- #include "EncoderWav.h"
- #include "EncoderVorbis.h"
- #include "EncoderFFmpeg.h"
-@@ -78,9 +82,16 @@
- case CDDARIP_ENCODER_FLAC:
- m_pEncoder = new CEncoderFlac();
- break;
-- default:
-+#ifdef HAVE_LIBMP3LAME
-+ case CDDARIP_ENCODER_LAME:
- m_pEncoder = new CEncoderLame();
- break;
-+#else
-+ default:
-+ CLog::Log(LOGERROR,"invalid encoder selected");
-+ return false;
-+ break;
-+#endif
- }
-
- // we have to set the tags before we init the Encoder
-diff -Naur xbmc-pvr-3513480/xbmc/cdrip/Makefile.in xbmc-pvr-3513480.patch/xbmc/cdrip/Makefile.in
---- xbmc-pvr-3513480/xbmc/cdrip/Makefile.in 2011-04-25 02:36:33.000000000 +0200
-+++ xbmc-pvr-3513480.patch/xbmc/cdrip/Makefile.in 2011-04-25 05:51:13.013064387 +0200
-@@ -3,10 +3,13 @@
- Encoder.cpp \
- EncoderFFmpeg.cpp \
- EncoderFlac.cpp \
-- EncoderLame.cpp \
- EncoderVorbis.cpp \
- EncoderWav.cpp \
-
-+ifeq (@HAVE_LIBMP3LAME@,1)
-+ SRCS+=EncoderLame.cpp
-+endif
-+
- LIB=cdrip.a
-
- include @abs_top_srcdir@/Makefile.include
-diff -Naur xbmc-pvr-3513480/xbmc/settings/GUISettings.cpp xbmc-pvr-3513480.patch/xbmc/settings/GUISettings.cpp
---- xbmc-pvr-3513480/xbmc/settings/GUISettings.cpp 2011-04-25 05:47:12.000000000 +0200
-+++ xbmc-pvr-3513480.patch/xbmc/settings/GUISettings.cpp 2011-04-25 05:48:47.956833472 +0200
-@@ -324,7 +324,9 @@
- AddPath(acd,"audiocds.recordingpath",20000,"select writable folder",BUTTON_CONTROL_PATH_INPUT,false,657);
- AddString(acd, "audiocds.trackpathformat", 13307, "%A - %B/[%N. ][%A - ]%T", EDIT_CONTROL_INPUT, false, 16016);
- map encoders;
-+#ifdef HAVE_LIBMP3LAME
- encoders.insert(make_pair(34000,CDDARIP_ENCODER_LAME));
-+#endif
- encoders.insert(make_pair(34001,CDDARIP_ENCODER_VORBIS));
- encoders.insert(make_pair(34002,CDDARIP_ENCODER_WAV));
- encoders.insert(make_pair(34005,CDDARIP_ENCODER_FLAC));
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch
deleted file mode 100644
index 821c1cc7bd..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-diff -Naur xbmc-a3c804b/xbmc/interfaces/python/XBPython.cpp xbmc-a3c804b.patch/xbmc/interfaces/python/XBPython.cpp
---- xbmc-a3c804b/xbmc/interfaces/python/XBPython.cpp 2011-08-17 23:40:00.000000000 +0200
-+++ xbmc-a3c804b.patch/xbmc/interfaces/python/XBPython.cpp 2011-08-18 03:50:49.652475572 +0200
-@@ -335,11 +335,9 @@
- // at http://docs.python.org/using/cmdline.html#environment-variables
-
- #if !defined(_WIN32)
-- /* PYTHONOPTIMIZE is set off intentionally when using external Python.
-- Reason for this is because we cannot be sure what version of Python
-- was used to compile the various Python object files (i.e. .pyo,
-- .pyc, etc.). */
-- // check if we are running as real xbmc.app or just binary
-+ // Required for python to find optimized code (pyo) files
-+ setenv("PYTHONOPTIMIZE", "1", 1);
-+ // check if we are running as real xbmc.app or just binary
- if (!CUtil::GetFrameworksPath(true).IsEmpty())
- {
- // using external python, it's build looking for xxx/lib/python2.6
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-452-change_lcd_content-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-452-change_lcd_content-0.1.patch
deleted file mode 100644
index 0427b534f9..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-452-change_lcd_content-0.1.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Naur xbmc-pvr-3513480/userdata/LCD.xml xbmc-pvr-3513480.patch/userdata/LCD.xml
---- xbmc-pvr-3513480/userdata/LCD.xml 2011-04-25 02:36:33.000000000 +0200
-+++ xbmc-pvr-3513480.patch/userdata/LCD.xml 2011-04-25 05:27:34.956125133 +0200
-@@ -21,7 +21,7 @@
- Freemem: $INFO[System.FreeMemory]
-
-
-- XBMC running...
-+ *** OpenELEC ***
- $INFO[System.Time] $INFO[System.Date]
- Freemem: $INFO[System.FreeMemory]
- $INFO[System.ScreenWidth]x$INFO[System.ScreenHeight] $INFO[System.ScreenMode]
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-453-add_openelec.tv_RSS_news-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-453-add_openelec.tv_RSS_news-0.1.patch
deleted file mode 100644
index 5b32c0cce7..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-453-add_openelec.tv_RSS_news-0.1.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-diff -Naur xbmc-10.1-Dharma/userdata/RssFeeds.xml xbmc-10.1-Dharma.patch/userdata/RssFeeds.xml
---- xbmc-10.1-Dharma/userdata/RssFeeds.xml 2011-03-08 02:49:24.000000000 +0100
-+++ xbmc-10.1-Dharma.patch/userdata/RssFeeds.xml 2011-06-14 17:07:08.450880123 +0200
-@@ -3,6 +3,7 @@
-
-
-
-+ http://openelec.tv/news?format=feed&type=rss
- http://feeds.feedburner.com/xbmc
-
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-454-disable_backslash-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-454-disable_backslash-0.1.patch
deleted file mode 100644
index 0888920258..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-454-disable_backslash-0.1.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Naur xbmc-30a9070/system/keymaps/keyboard.xml xbmc-30a9070.patch/system/keymaps/keyboard.xml
---- xbmc-30a9070/system/keymaps/keyboard.xml 2011-07-28 06:20:13.000000000 +0200
-+++ xbmc-30a9070.patch/system/keymaps/keyboard.xml 2011-07-28 09:39:57.210973380 +0200
-@@ -90,7 +90,7 @@
- Number7
- Number8
- Number9
-- ToggleFullScreen
-+
- FirstPage
- LastPage
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-457-fix_connection_check-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-457-fix_connection_check-0.1.patch
deleted file mode 100644
index f4982ec635..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-457-fix_connection_check-0.1.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff -Naur xbmc-10.1-Dharma/xbmc/FileSystem/FileCurl.cpp xbmc-10.1-Dharma.patch/xbmc/FileSystem/FileCurl.cpp
---- xbmc-10.1-Dharma/xbmc/filesystem/FileCurl.cpp 2011-03-08 02:49:14.000000000 +0100
-+++ xbmc-10.1-Dharma.patch/xbmc/filesystem/FileCurl.cpp 2011-10-17 19:21:04.180783870 +0200
-@@ -803,9 +803,9 @@
- // Detect whether we are "online" or not! Very simple and dirty!
- bool CFileCurl::IsInternet(bool checkDNS /* = true */)
- {
-- CStdString strURL = "http://www.google.com";
-+ CStdString strURL = "http://www.openelec.tv";
- if (!checkDNS)
-- strURL = "http://74.125.19.103"; // www.google.com ip
-+ strURL = "http://212.101.13.10"; // www.openelec.tv ip
-
- bool found = Exists(strURL);
- Close();
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-463-add_remote_devinput-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-463-add_remote_devinput-0.1.patch
deleted file mode 100644
index 85d635b61b..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-463-add_remote_devinput-0.1.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-diff -Naur xbmc-10.1-Dharma/system/Lircmap.xml xbmc-10.1-Dharma.patch/system/Lircmap.xml
---- xbmc-10.1-Dharma/system/Lircmap.xml 2011-06-18 01:43:43.132101246 +0200
-+++ xbmc-10.1-Dharma.patch/system/Lircmap.xml 2011-06-18 01:44:53.777025290 +0200
-@@ -365,7 +365,6 @@
-
-
- cx23885_remote
-- devinput
- KEY_LEFT
- KEY_RIGHT
- KEY_UP
-@@ -452,4 +451,59 @@
- yellow
- blue
-
-+
-+
-+ KEY_LEFT
-+ KEY_RIGHT
-+ KEY_UP
-+ KEY_DOWN
-+
-+ KEY_ENTER
-+ KEY_DELETE
-+ KEY_PROG1
-+ KEY_EXIT
-+ KEY_RECORD
-+ KEY_PLAY
-+ KEY_PAUSE
-+ KEY_STOP
-+ KEY_FASTFORWARD
-+ KEY_REWIND
-+ KEY_VOLUMEUP
-+ KEY_VOLUMEDOWN
-+ KEY_CHANNELUP
-+ KEY_CHANNELDOWN
-+ KEY_NEXT
-+ KEY_PREVIOUS
-+ KEY_EPG
-+ KEY_SUBTITLE
-+ KEY_LANGUAGE
-+ KEY_INFO
-+ KEY_ZOOM
-+ KEY_MUTE
-+ KEY_POWER
-+ KEY_EJECT
-+
-+
-+ KEY_VIDEO
-+ KEY_AUDIO
-+ KEY_CAMERA
-+ KEY_TUNER
-+ KEY_TEXT
-+ KEY_NUMERIC_1
-+ KEY_NUMERIC_2
-+ KEY_NUMERIC_3
-+ KEY_NUMERIC_4
-+ KEY_NUMERIC_5
-+ KEY_NUMERIC_6
-+ KEY_NUMERIC_7
-+ KEY_NUMERIC_8
-+ KEY_NUMERIC_9
-+ KEY_NUMERIC_0
-+ KEY_NUMERIC_STAR
-+ KEY_NUMERIC_POUND
-+ KEY_RED
-+ KEY_GREEN
-+ KEY_YELLOW
-+ KEY_BLUE
-+
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-806.01-cdrip-PR616.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-806.01-cdrip-PR616.patch
deleted file mode 100644
index 830722aabf..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-806.01-cdrip-PR616.patch
+++ /dev/null
@@ -1,144 +0,0 @@
-From ab72a555c5dd8585ac6e101d9f5966e25500867d Mon Sep 17 00:00:00 2001
-From: Giftie
-Date: Thu, 5 Jan 2012 19:32:14 -0700
-Subject: [PATCH] Updated auto cd rip modified:
- language/English/strings.xml modified:
- xbmc/cdrip/CDDARipper.cpp modified:
- xbmc/settings/GUISettings.cpp modified:
- xbmc/settings/GUISettings.h modified:
- xbmc/storage/MediaManager.cpp modified: xbmc/Autorun.cpp
-
- Author: Giftie
- Committer: Giftie
----
- language/English/strings.xml | 5 ++++-
- xbmc/Autorun.cpp | 15 ++++++++++++---
- xbmc/settings/GUISettings.cpp | 8 +++++++-
- xbmc/settings/GUISettings.h | 5 +++++
- xbmc/storage/MediaManager.cpp | 7 +++++--
- 5 files changed, 33 insertions(+), 7 deletions(-)
-
-diff --git a/language/English/strings.xml b/language/English/strings.xml
-index ca2ac4d..ae22214 100644
---- a/language/English/strings.xml
-+++ b/language/English/strings.xml
-@@ -1344,7 +1344,7 @@
- Show EXIF picture information
- Use a fullscreen window rather than true fullscreen
- Queue songs on selection
-- Play audio CDs automatically
-+
- Playback
- DVDs
- Play DVDs automatically
-@@ -1355,6 +1355,9 @@
- Security
- Input devices
- Power saving
-+ Rip
-+ Audio CD Insert Action
-+ Play
-
- Remove
- Games
-diff --git a/xbmc/Autorun.cpp b/xbmc/Autorun.cpp
-index 846b28d..3cd6f75 100644
---- a/xbmc/Autorun.cpp
-+++ b/xbmc/Autorun.cpp
-@@ -43,6 +43,9 @@
- #include "dialogs/GUIDialogYesNo.h"
- #include "utils/URIUtils.h"
- #include "utils/log.h"
-+#ifdef HAS_CDDA_RIPPER
-+#include "cdrip/CDDARipper.h"
-+#endif
-
- using namespace std;
- using namespace XFILE;
-@@ -69,13 +72,19 @@ void CAutorun::ExecuteAutorun(const CStdString& path, bool bypassSettings, bool
-
- g_application.ResetScreenSaver();
- g_application.WakeUpScreenSaverAndDPMS(); // turn off the screensaver if it's active
--
-+#ifdef HAS_CDDA_RIPPER
-+ if ( g_guiSettings.GetInt("audiocds.autoaction") == AUTOCD_RIP && pInfo->IsAudio(1) && !g_settings.GetCurrentProfile().musicLocked())
-+ {
-+ CCDDARipper ripper;
-+ ripper.RipCD();
-+ }
-+#endif
- PlayDisc(path, bypassSettings, startFromBeginning);
- }
-
- bool CAutorun::PlayDisc(const CStdString& path, bool bypassSettings, bool startFromBeginning)
- {
-- if ( !bypassSettings && !g_guiSettings.GetBool("audiocds.autorun") && !g_guiSettings.GetBool("dvds.autorun"))
-+ if ( !bypassSettings && !g_guiSettings.GetInt("audiocds.autoaction") == AUTOCD_PLAY && !g_guiSettings.GetBool("dvds.autorun"))
- return false;
-
- int nSize = g_playlistPlayer.GetPlaylist( PLAYLIST_MUSIC ).size();
-@@ -276,7 +285,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
- }
- }
- // then music
-- if (!bPlaying && (bypassSettings || g_guiSettings.GetBool("audiocds.autorun")) && bAllowMusic)
-+ if (!bPlaying && (bypassSettings || g_guiSettings.GetInt("audiocds.autoaction") == AUTOCD_PLAY) && bAllowMusic)
- {
- for (int i = 0; i < vecItems.Size(); i++)
- {
-diff --git a/xbmc/settings/GUISettings.cpp b/xbmc/settings/GUISettings.cpp
-index 6cce6ac..a0c7bf5 100644
---- a/xbmc/settings/GUISettings.cpp
-+++ b/xbmc/settings/GUISettings.cpp
-@@ -318,7 +318,13 @@ void CGUISettings::Initialize()
- AddString(scr, "scrobbler.librefmpass", 15219, "", EDIT_CONTROL_MD5_INPUT, false, 15219);
-
- CSettingsCategory* acd = AddCategory(3, "audiocds", 620);
-- AddBool(acd, "audiocds.autorun", 14085, false);
-+ map autocd;
-+ autocd.insert(make_pair(16018, AUTOCD_NONE));
-+ autocd.insert(make_pair(14098, AUTOCD_PLAY));
-+#ifdef HAS_CDDA_RIPPER
-+ autocd.insert(make_pair(14096, AUTOCD_RIP));
-+#endif
-+ AddInt(acd,"audiocds.autoaction",14097,AUTOCD_NONE, autocd, SPIN_CONTROL_TEXT);
- AddBool(acd, "audiocds.usecddb", 227, true);
- AddSeparator(acd, "audiocds.sep1");
- AddPath(acd,"audiocds.recordingpath",20000,"select writable folder",BUTTON_CONTROL_PATH_INPUT,false,657);
-diff --git a/xbmc/settings/GUISettings.h b/xbmc/settings/GUISettings.h
-index 5501064..8751624 100644
---- a/xbmc/settings/GUISettings.h
-+++ b/xbmc/settings/GUISettings.h
-@@ -64,6 +64,11 @@
- #define KARAOKE_COLOR_START 0
- #define KARAOKE_COLOR_END 4
-
-+// CDDA Autoaction defines
-+#define AUTOCD_NONE 0
-+#define AUTOCD_PLAY 1
-+#define AUTOCD_RIP 2
-+
- // CDDA ripper defines
- #define CDDARIP_ENCODER_LAME 0
- #define CDDARIP_ENCODER_VORBIS 1
-diff --git a/xbmc/storage/MediaManager.cpp b/xbmc/storage/MediaManager.cpp
-index ced4ad0..316e8c9 100644
---- a/xbmc/storage/MediaManager.cpp
-+++ b/xbmc/storage/MediaManager.cpp
-@@ -624,8 +624,11 @@ void CMediaManager::ProcessEvents()
-
- void CMediaManager::OnStorageAdded(const CStdString &label, const CStdString &path)
- {
-- if (g_guiSettings.GetBool("audiocds.autorun") || g_guiSettings.GetBool("dvds.autorun"))
-- CJobManager::GetInstance().AddJob(new CAutorunMediaJob(label, path), this, CJob::PRIORITY_HIGH);
-+ if (g_guiSettings.GetInt("audiocds.autoaction") != AUTOCD_NONE || g_guiSettings.GetBool("dvds.autorun"))
-+ if ( g_guiSettings.GetInt("audiocds.autoaction") == AUTOCD_RIP)
-+ CJobManager::GetInstance().AddJob(new CAutorunMediaJob(label, path), this, CJob::PRIORITY_LOW);
-+ else
-+ CJobManager::GetInstance().AddJob(new CAutorunMediaJob(label, path), this, CJob::PRIORITY_HIGH);
- else
- CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(13021), label, TOAST_DISPLAY_TIME, false);
- }
---
-1.7.5.4
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-806.02-cdrip-PR718.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-806.02-cdrip-PR718.patch
deleted file mode 100644
index f8fd6b6c73..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-806.02-cdrip-PR718.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-diff -Naur xbmc-pvr-fc63e66/language/English/strings.xml xbmc-pvr-fc63e66.patch/language/English/strings.xml
---- xbmc-pvr-fc63e66/language/English/strings.xml 2012-03-19 21:20:31.531809910 +0100
-+++ xbmc-pvr-fc63e66.patch/language/English/strings.xml 2012-03-19 21:21:56.576430020 +0100
-@@ -1360,6 +1360,7 @@
- Rip
- Audio CD Insert Action
- Play
-+ Eject disc when Audio CD ripping is complete
-
- Remove
- Games
-diff -Naur xbmc-pvr-fc63e66/xbmc/cdrip/CDDARipper.cpp xbmc-pvr-fc63e66.patch/xbmc/cdrip/CDDARipper.cpp
---- xbmc-pvr-fc63e66/xbmc/cdrip/CDDARipper.cpp 2012-03-16 22:27:56.000000000 +0100
-+++ xbmc-pvr-fc63e66.patch/xbmc/cdrip/CDDARipper.cpp 2012-03-19 21:21:07.725417655 +0100
-@@ -332,6 +332,11 @@
- }
-
- CLog::Log(LOGINFO, "Ripped CD succesfull");
-+ if (g_guiSettings.GetBool("audiocds.ejectonrip"))
-+ {
-+ CLog::Log(LOGINFO, "Ejecting CD");
-+ CIoSupport::EjectTray();
-+ }
- return true;
- }
-
-diff -Naur xbmc-pvr-fc63e66/xbmc/settings/GUISettings.cpp xbmc-pvr-fc63e66.patch/xbmc/settings/GUISettings.cpp
---- xbmc-pvr-fc63e66/xbmc/settings/GUISettings.cpp 2012-03-19 21:20:31.533809950 +0100
-+++ xbmc-pvr-fc63e66.patch/xbmc/settings/GUISettings.cpp 2012-03-19 21:21:07.734417841 +0100
-@@ -349,6 +349,7 @@
- AddInt(acd, "audiocds.quality", 622, CDDARIP_QUALITY_CBR, qualities, SPIN_CONTROL_TEXT);
- AddInt(acd, "audiocds.bitrate", 623, 192, 128, 32, 320, SPIN_CONTROL_INT_PLUS, MASK_KBPS);
- AddInt(acd, "audiocds.compressionlevel", 665, 5, 0, 1, 8, SPIN_CONTROL_INT_PLUS);
-+ AddBool(acd, "audiocds.ejectonrip", 14099, false);
-
- #ifdef HAS_KARAOKE
- CSettingsCategory* kar = AddCategory(3, "karaoke", 13327);
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-901.01-ffmpeg-10.2-28b186f.patch.disable b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-901.01-ffmpeg-10.2-28b186f.patch.disable
deleted file mode 100644
index d505fdb2d6..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-901.01-ffmpeg-10.2-28b186f.patch.disable
+++ /dev/null
@@ -1,3193 +0,0 @@
-diff -Naur xbmc-11.0.1/configure.in xbmc-11.0.1.patch/configure.in
---- xbmc-11.0.1/configure.in 2012-03-21 23:57:58.000000000 +0100
-+++ xbmc-11.0.1.patch/configure.in 2012-06-05 15:19:23.820493772 +0200
-@@ -2024,7 +2024,7 @@
- --disable-amd3dnow \
- --disable-armv5te \
- --disable-armv6t2 \
-- --disable-static \
-+ --enable-static \
- `if test "$use_debug" = "no"; then echo --disable-debug; fi` \
- --disable-muxers \
- --enable-muxer=spdif \
-@@ -2038,7 +2038,6 @@
- --disable-ffplay \
- --disable-ffserver \
- --disable-ffmpeg \
-- --enable-shared \
- --disable-doc \
- --disable-decoder=mpeg_xvmc \
- --enable-postproc \
-@@ -2046,6 +2045,7 @@
- --enable-protocol=http \
- --enable-pthreads \
- --enable-runtime-cpudetect \
-+ --disable-openmp \
- --cc="$CC" &&
- sed -ie "s#YASM=yasm#YASM=${prefix}/bin/yasm#" config.mak &&
- sed -ie "s#YASMDEP=yasm#YASMDEP=${prefix}/bin/yasm#" config.mak &&
-diff -Naur xbmc-11.0.1/lib/DllAvCodec.h xbmc-11.0.1.patch/lib/DllAvCodec.h
---- xbmc-11.0.1/lib/DllAvCodec.h 2012-03-21 23:57:36.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllAvCodec.h 2012-06-05 15:19:23.822493812 +0200
-@@ -24,7 +24,7 @@
- #include "config.h"
- #endif
- #include "DynamicDll.h"
--#include "DllAvCore.h"
-+#include "DllAvUtil.h"
- #include "utils/log.h"
-
- extern "C" {
-@@ -76,28 +76,6 @@
- #endif
- }
-
--/* Some convenience macros introduced at this particular revision of libavcodec.
-- */
--#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52,25,0)
--#define CH_LAYOUT_5POINT0_BACK (CH_LAYOUT_SURROUND|CH_BACK_LEFT|CH_BACK_RIGHT)
--#define CH_LAYOUT_5POINT1_BACK (CH_LAYOUT_5POINT0_BACK|CH_LOW_FREQUENCY)
--#undef CH_LAYOUT_7POINT1_WIDE
--#define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_5POINT1_BACK|\
-- CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER)
--#endif
--
--#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52,64,0)
--// API added on: 2010-03-31
--#define AVMediaType CodecType
--#define AVMEDIA_TYPE_UNKNOWN CODEC_TYPE_UNKNOWN
--#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
--#define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO
--#define AVMEDIA_TYPE_DATA CODEC_TYPE_DATA
--#define AVMEDIA_TYPE_SUBTITLE CODEC_TYPE_SUBTITLE
--#define AVMEDIA_TYPE_ATTACHMENT CODEC_TYPE_ATTACHMENT
--#define AVMEDIA_TYPE_NB CODEC_TYPE_NB
--#endif
--
- #include "threads/SingleLock.h"
-
- class DllAvCodecInterface
-@@ -106,20 +84,20 @@
- virtual ~DllAvCodecInterface() {}
- virtual void avcodec_register_all(void)=0;
- virtual void avcodec_flush_buffers(AVCodecContext *avctx)=0;
-- virtual int avcodec_open_dont_call(AVCodecContext *avctx, AVCodec *codec)=0;
-+ virtual int avcodec_open2_dont_call(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)=0;
- virtual AVCodec *avcodec_find_decoder(enum CodecID id)=0;
- virtual AVCodec *avcodec_find_encoder(enum CodecID id)=0;
- virtual int avcodec_close_dont_call(AVCodecContext *avctx)=0;
- virtual AVFrame *avcodec_alloc_frame(void)=0;
- virtual int avpicture_fill(AVPicture *picture, uint8_t *ptr, PixelFormat pix_fmt, int width, int height)=0;
- virtual int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt)=0;
-- virtual int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt)=0;
-+ virtual int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)=0;
- virtual int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)=0;
- virtual int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples)=0;
- virtual int avpicture_get_size(PixelFormat pix_fmt, int width, int height)=0;
-- virtual AVCodecContext *avcodec_alloc_context(void)=0;
-+ virtual AVCodecContext *avcodec_alloc_context3(AVCodec *codec)=0;
- virtual void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)=0;
-- virtual void avcodec_get_context_defaults(AVCodecContext *s)=0;
-+ virtual void avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec)=0;
- virtual AVCodecParserContext *av_parser_init(int codec_id)=0;
- virtual int av_parser_parse2(AVCodecParserContext *s,AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size,
-@@ -137,7 +115,6 @@
- virtual enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat *fmt)=0;
- virtual int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic)=0;
- virtual void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic)=0;
-- virtual int avcodec_thread_init(AVCodecContext *s, int thread_count)=0;
- virtual AVCodec *av_codec_next(AVCodec *c)=0;
- virtual AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int out_channels,
- enum AVSampleFormat in_fmt , int in_channels,
-@@ -151,7 +128,7 @@
- virtual int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name)=0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
-
- // Use direct layer
- class DllAvCodec : public DllDynamic, DllAvCodecInterface
-@@ -166,12 +143,12 @@
- ::avcodec_register_all();
- }
- virtual void avcodec_flush_buffers(AVCodecContext *avctx) { ::avcodec_flush_buffers(avctx); }
-- virtual int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
-+ virtual int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
-- return ::avcodec_open(avctx, codec);
-+ return ::avcodec_open2(avctx, codec, options);
- }
-- virtual int avcodec_open_dont_call(AVCodecContext *avctx, AVCodec *codec) { *(int *)0x0 = 0; return 0; }
-+ virtual int avcodec_open2_dont_call(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) { *(int *)0x0 = 0; return 0; }
- virtual int avcodec_close_dont_call(AVCodecContext *avctx) { *(int *)0x0 = 0; return 0; }
- virtual AVCodec *avcodec_find_decoder(enum CodecID id) { return ::avcodec_find_decoder(id); }
- virtual AVCodec *avcodec_find_encoder(enum CodecID id) { return ::avcodec_find_encoder(id); }
-@@ -182,33 +159,21 @@
- }
- virtual AVFrame *avcodec_alloc_frame() { return ::avcodec_alloc_frame(); }
- virtual int avpicture_fill(AVPicture *picture, uint8_t *ptr, PixelFormat pix_fmt, int width, int height) { return ::avpicture_fill(picture, ptr, pix_fmt, width, height); }
--#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,23,0)
-- // API added on: 2009-04-07
- virtual int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt) { return ::avcodec_decode_video2(avctx, picture, got_picture_ptr, avpkt); }
-- virtual int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt) { return ::avcodec_decode_audio3(avctx, samples, frame_size_ptr, avpkt); }
-+ virtual int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt) { return ::avcodec_decode_audio4(avctx, frame, got_frame_ptr, avpkt); }
- virtual int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) { return ::avcodec_decode_subtitle2(avctx, sub, got_sub_ptr, avpkt); }
--#else
-- virtual int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt) { return ::avcodec_decode_video(avctx, picture, got_picture_ptr, avpkt->data, avpkt->size); }
-- virtual int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt) { return ::avcodec_decode_audio2(avctx, samples, frame_size_ptr, avpkt->data, avpkt->size); }
-- virtual int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) { return ::avcodec_decode_subtitle(avctx, sub, got_sub_ptr, avpkt->data, avpkt->size); }
--#endif
- virtual int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples) { return ::avcodec_encode_audio(avctx, buf, buf_size, samples); }
- virtual int avpicture_get_size(PixelFormat pix_fmt, int width, int height) { return ::avpicture_get_size(pix_fmt, width, height); }
-- virtual AVCodecContext *avcodec_alloc_context() { return ::avcodec_alloc_context(); }
-+ virtual AVCodecContext *avcodec_alloc_context3(AVCodec *codec) { return ::avcodec_alloc_context3(codec); }
- virtual void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) { ::avcodec_string(buf, buf_size, enc, encode); }
-- virtual void avcodec_get_context_defaults(AVCodecContext *s) { ::avcodec_get_context_defaults(s); }
-+ virtual void avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec) { ::avcodec_get_context_defaults3(s, codec); }
-
- virtual AVCodecParserContext *av_parser_init(int codec_id) { return ::av_parser_init(codec_id); }
- virtual int av_parser_parse2(AVCodecParserContext *s,AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size,
- int64_t pts, int64_t dts, int64_t pos)
- {
--#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,21,0)
-- // API added on : 2009-03-05
- return ::av_parser_parse2(s, avctx, poutbuf, poutbuf_size, buf, buf_size, pts, dts, pos);
--#else
-- return ::av_parser_parse(s, avctx, poutbuf, poutbuf_size, buf, buf_size, pts, dts);
--#endif
- }
- virtual void av_parser_close(AVCodecParserContext *s) { ::av_parser_close(s); }
-
-@@ -225,7 +190,6 @@
- virtual int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic) { return ::avcodec_default_get_buffer(s, pic); }
- virtual void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic) { ::avcodec_default_release_buffer(s, pic); }
- virtual enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat *fmt) { return ::avcodec_default_get_format(s, fmt); }
-- virtual int avcodec_thread_init(AVCodecContext *s, int thread_count) { return ::avcodec_thread_init(s, thread_count); }
- virtual AVCodec *av_codec_next(AVCodec *c) { return ::av_codec_next(c); }
- virtual AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int out_channels,
- enum AVSampleFormat in_fmt , int in_channels,
-@@ -256,12 +220,12 @@
- {
- DECLARE_DLL_WRAPPER(DllAvCodec, DLL_PATH_LIBAVCODEC)
- DEFINE_FUNC_ALIGNED1(void, __cdecl, avcodec_flush_buffers, AVCodecContext*)
-- DEFINE_FUNC_ALIGNED2(int, __cdecl, avcodec_open_dont_call, AVCodecContext*, AVCodec *)
-+ DEFINE_FUNC_ALIGNED3(int, __cdecl, avcodec_open2_dont_call, AVCodecContext*, AVCodec *, AVDictionary **)
- DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_video2, AVCodecContext*, AVFrame*, int*, AVPacket*)
-- DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_audio3, AVCodecContext*, int16_t*, int*, AVPacket*)
-+ DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_audio4, AVCodecContext*, AVFrame*, int*, AVPacket*)
- DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_subtitle2, AVCodecContext*, AVSubtitle*, int*, AVPacket*)
- DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_encode_audio, AVCodecContext*, uint8_t*, int, const short*)
-- DEFINE_FUNC_ALIGNED0(AVCodecContext*, __cdecl, avcodec_alloc_context)
-+ DEFINE_FUNC_ALIGNED1(AVCodecContext*, __cdecl, avcodec_alloc_context3, AVCodec *)
- DEFINE_FUNC_ALIGNED1(AVCodecParserContext*, __cdecl, av_parser_init, int)
- DEFINE_FUNC_ALIGNED9(int, __cdecl, av_parser_parse2, AVCodecParserContext*,AVCodecContext*, uint8_t**, int*, const uint8_t*, int, int64_t, int64_t, int64_t)
- DEFINE_METHOD1(int, av_dup_packet, (AVPacket *p1))
-@@ -278,7 +242,7 @@
- DEFINE_METHOD5(int, avpicture_fill, (AVPicture *p1, uint8_t *p2, PixelFormat p3, int p4, int p5))
- DEFINE_METHOD3(int, avpicture_get_size, (PixelFormat p1, int p2, int p3))
- DEFINE_METHOD4(void, avcodec_string, (char *p1, int p2, AVCodecContext *p3, int p4))
-- DEFINE_METHOD1(void, avcodec_get_context_defaults, (AVCodecContext *p1))
-+ DEFINE_METHOD2(void, avcodec_get_context_defaults3, (AVCodecContext *p1, AVCodec *p2))
- DEFINE_METHOD1(void, av_parser_close, (AVCodecParserContext *p1))
- DEFINE_METHOD1(void, avpicture_free, (AVPicture *p1))
- DEFINE_METHOD1(AVBitStreamFilterContext*, av_bitstream_filter_init, (const char *p1))
-@@ -290,7 +254,6 @@
- DEFINE_METHOD2(void, avcodec_default_release_buffer, (AVCodecContext *p1, AVFrame *p2))
- DEFINE_METHOD2(enum PixelFormat, avcodec_default_get_format, (struct AVCodecContext *p1, const enum PixelFormat *p2))
-
-- DEFINE_METHOD2(int, avcodec_thread_init, (AVCodecContext *p1, int p2))
- DEFINE_METHOD1(AVCodec*, av_codec_next, (AVCodec *p1))
- DEFINE_METHOD6(AVAudioConvert*, av_audio_convert_alloc, (enum AVSampleFormat p1, int p2,
- enum AVSampleFormat p3, int p4,
-@@ -301,7 +264,7 @@
- const void * const p4[6], const int p5[6], int p6))
- BEGIN_METHOD_RESOLVE()
- RESOLVE_METHOD(avcodec_flush_buffers)
-- RESOLVE_METHOD_RENAME(avcodec_open,avcodec_open_dont_call)
-+ RESOLVE_METHOD_RENAME(avcodec_open2,avcodec_open2_dont_call)
- RESOLVE_METHOD_RENAME(avcodec_close,avcodec_close_dont_call)
- RESOLVE_METHOD(avcodec_find_decoder)
- RESOLVE_METHOD(avcodec_find_encoder)
-@@ -309,13 +272,13 @@
- RESOLVE_METHOD_RENAME(avcodec_register_all, avcodec_register_all_dont_call)
- RESOLVE_METHOD(avpicture_fill)
- RESOLVE_METHOD(avcodec_decode_video2)
-- RESOLVE_METHOD(avcodec_decode_audio3)
-+ RESOLVE_METHOD(avcodec_decode_audio4)
- RESOLVE_METHOD(avcodec_decode_subtitle2)
- RESOLVE_METHOD(avcodec_encode_audio)
- RESOLVE_METHOD(avpicture_get_size)
-- RESOLVE_METHOD(avcodec_alloc_context)
-+ RESOLVE_METHOD(avcodec_alloc_context3)
- RESOLVE_METHOD(avcodec_string)
-- RESOLVE_METHOD(avcodec_get_context_defaults)
-+ RESOLVE_METHOD(avcodec_get_context_defaults3)
- RESOLVE_METHOD(av_parser_init)
- RESOLVE_METHOD(av_parser_parse2)
- RESOLVE_METHOD(av_parser_close)
-@@ -328,7 +291,6 @@
- RESOLVE_METHOD(avcodec_default_get_buffer)
- RESOLVE_METHOD(avcodec_default_release_buffer)
- RESOLVE_METHOD(avcodec_default_get_format)
-- RESOLVE_METHOD(avcodec_thread_init)
- RESOLVE_METHOD(av_codec_next)
- RESOLVE_METHOD(av_audio_convert_alloc)
- RESOLVE_METHOD(av_audio_convert_free)
-@@ -339,15 +301,15 @@
- END_METHOD_RESOLVE()
-
- /* dependencies of libavcodec */
-- DllAvCore m_dllAvCore;
-+ DllAvUtil m_dllAvUtil;
- // DllAvUtil loaded implicitely by m_dllAvCore
-
- public:
- static CCriticalSection m_critSection;
-- int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
-+ int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
-- return avcodec_open_dont_call(avctx,codec);
-+ return avcodec_open2_dont_call(avctx,codec, options);
- }
- int avcodec_close(AVCodecContext *avctx)
- {
-@@ -361,7 +323,7 @@
- }
- virtual bool Load()
- {
-- if (!m_dllAvCore.Load())
-+ if (!m_dllAvUtil.Load())
- return false;
- return DllDynamic::Load();
- }
-diff -Naur xbmc-11.0.1/lib/DllAvCore.h xbmc-11.0.1.patch/lib/DllAvCore.h
---- xbmc-11.0.1/lib/DllAvCore.h 2012-03-21 23:57:39.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllAvCore.h 1970-01-01 01:00:00.000000000 +0100
-@@ -1,182 +0,0 @@
--#pragma once
--/*
-- * Copyright (C) 2005-2010 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, Inc., 51 Franklin Street, Fifth Floor,
-- * Boston, MA 02110-1301, USA.
-- * http://www.gnu.org/copyleft/gpl.html
-- *
-- */
--
--#if (defined HAVE_CONFIG_H) && (!defined WIN32)
-- #include "config.h"
--#endif
--#include "DynamicDll.h"
--#include "DllAvUtil.h"
--#include "utils/log.h"
--
--extern "C" {
--#ifdef USE_EXTERNAL_FFMPEG
-- #ifdef HAVE_LIBAVUTIL_SAMPLEFMT_H
-- // libavcore was merged to libavutil on 2010-02-15
-- #include
-- #include
-- #endif
--
-- #ifdef HAVE_LIBAVCORE_AVCORE_H
-- #include
-- #endif
-- #ifdef HAVE_LIBAVCORE_SAMPLEFMT_H
-- #include
-- #endif
--
-- /* Needed for old FFmpeg versions as used below */
-- #ifdef HAVE_LIBAVCODEC_AVCODEC_H
-- #include
-- #else
-- #include
-- #endif
--#else
-- #include "libavcore/avcore.h"
-- #include "libavcore/samplefmt.h"
--#endif
--}
--
--/* Compatibility for old external FFmpeg versions. */
--
--#ifdef USE_EXTERNAL_FFMPEG
--
--#ifndef LIBAVCORE_VERSION_INT
--// API added on: 2010-07-21, removed on 2010-02-15
--#define LIBAVCORE_VERSION_INT 0
--#endif
--
--#ifndef AV_SAMPLE_FMT_NONE
--// API added on: 2010-11-02
--#define AVSampleFormat SampleFormat
--#define AV_SAMPLE_FMT_NONE SAMPLE_FMT_NONE
--#define AV_SAMPLE_FMT_U8 SAMPLE_FMT_U8
--#define AV_SAMPLE_FMT_S16 SAMPLE_FMT_S16
--#define AV_SAMPLE_FMT_S32 SAMPLE_FMT_S32
--#define AV_SAMPLE_FMT_FLT SAMPLE_FMT_FLT
--#define AV_SAMPLE_FMT_DBL SAMPLE_FMT_DBL
--#endif
--
--#ifndef AV_CH_FRONT_LEFT
--// API added on: 2010-11-21
--#define AV_CH_FRONT_LEFT CH_FRONT_LEFT
--#define AV_CH_FRONT_RIGHT CH_FRONT_RIGHT
--#define AV_CH_FRONT_CENTER CH_FRONT_CENTER
--#define AV_CH_LOW_FREQUENCY CH_LOW_FREQUENCY
--#define AV_CH_BACK_LEFT CH_BACK_LEFT
--#define AV_CH_BACK_RIGHT CH_BACK_RIGHT
--#define AV_CH_FRONT_LEFT_OF_CENTER CH_FRONT_LEFT_OF_CENTER
--#define AV_CH_FRONT_RIGHT_OF_CENTER CH_FRONT_RIGHT_OF_CENTER
--#define AV_CH_BACK_CENTER CH_BACK_CENTER
--#define AV_CH_SIDE_LEFT CH_SIDE_LEFT
--#define AV_CH_SIDE_RIGHT CH_SIDE_RIGHT
--#define AV_CH_TOP_CENTER CH_TOP_CENTER
--#define AV_CH_TOP_FRONT_LEFT CH_TOP_FRONT_LEFT
--#define AV_CH_TOP_FRONT_CENTER CH_TOP_FRONT_CENTER
--#define AV_CH_TOP_FRONT_RIGHT CH_TOP_FRONT_RIGHT
--#define AV_CH_TOP_BACK_LEFT CH_TOP_BACK_LEFT
--#define AV_CH_TOP_BACK_CENTER CH_TOP_BACK_CENTER
--#define AV_CH_TOP_BACK_RIGHT CH_TOP_BACK_RIGHT
--#define AV_CH_STEREO_LEFT CH_STEREO_LEFT
--#define AV_CH_STEREO_RIGHT CH_STEREO_RIGHT
--
--#define AV_CH_LAYOUT_NATIVE CH_LAYOUT_NATIVE
--
--#define AV_CH_LAYOUT_MONO CH_LAYOUT_MONO
--#define AV_CH_LAYOUT_STEREO CH_LAYOUT_STEREO
--#define AV_CH_LAYOUT_2_1 CH_LAYOUT_2_1
--#define AV_CH_LAYOUT_SURROUND CH_LAYOUT_SURROUND
--#define AV_CH_LAYOUT_4POINT0 CH_LAYOUT_4POINT0
--#define AV_CH_LAYOUT_2_2 CH_LAYOUT_2_2
--#define AV_CH_LAYOUT_QUAD CH_LAYOUT_QUAD
--#define AV_CH_LAYOUT_5POINT0 CH_LAYOUT_5POINT0
--#define AV_CH_LAYOUT_5POINT1 CH_LAYOUT_5POINT1
--#define AV_CH_LAYOUT_5POINT0_BACK CH_LAYOUT_5POINT0_BACK
--#define AV_CH_LAYOUT_5POINT1_BACK CH_LAYOUT_5POINT1_BACK
--#define AV_CH_LAYOUT_7POINT0 CH_LAYOUT_7POINT0
--#define AV_CH_LAYOUT_7POINT1 CH_LAYOUT_7POINT1
--#define AV_CH_LAYOUT_7POINT1_WIDE CH_LAYOUT_7POINT1_WIDE
--#define AV_CH_LAYOUT_STEREO_DOWNMIX CH_LAYOUT_STEREO_DOWNMIX
--#endif
--
--#endif // USE_EXTERNAL_FFMPEG
--
--class DllAvCoreInterface
--{
--public:
-- virtual ~DllAvCoreInterface() {}
-- virtual int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) = 0;
--};
--
--#if (defined USE_EXTERNAL_FFMPEG)
--
--// Use direct layer
--class DllAvCore : public DllDynamic, DllAvCoreInterface
--{
--public:
-- virtual ~DllAvCore() {}
--#if LIBAVCORE_VERSION_INT >= AV_VERSION_INT(0,12,0) || LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(50,38,0)
-- // API added on: 2010-11-02, moved to libavutil on 2010-02-15
-- virtual int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) { return ::av_get_bits_per_sample_fmt(sample_fmt); }
--#else
-- // from avcodec.h
-- virtual int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) { return ::av_get_bits_per_sample_format(sample_fmt); }
--#endif
--
-- // DLL faking.
-- virtual bool ResolveExports() { return true; }
-- virtual bool Load() {
--#if LIBAVCORE_VERSION_INT > 0
-- CLog::Log(LOGDEBUG, "DllAvCore: Using libavcore system library");
--#endif
-- return true;
-- }
-- virtual void Unload() {}
--};
--
--#else
--
--class DllAvCore : public DllDynamic, DllAvCoreInterface
--{
-- DECLARE_DLL_WRAPPER(DllAvCore, DLL_PATH_LIBAVCORE)
--
-- LOAD_SYMBOLS()
--
-- DEFINE_METHOD1(int, av_get_bits_per_sample_fmt, (enum AVSampleFormat p1))
--
-- BEGIN_METHOD_RESOLVE()
-- RESOLVE_METHOD(av_get_bits_per_sample_fmt)
-- END_METHOD_RESOLVE()
--
-- /* dependency of libavcore */
-- DllAvUtil m_dllAvUtil;
--
--public:
-- virtual bool Load()
-- {
-- if (!m_dllAvUtil.Load())
-- return false;
-- return DllDynamic::Load();
-- }
--};
--
--#endif
--
-diff -Naur xbmc-11.0.1/lib/DllAvFilter.h xbmc-11.0.1.patch/lib/DllAvFilter.h
---- xbmc-11.0.1/lib/DllAvFilter.h 2012-03-21 23:57:39.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllAvFilter.h 2012-06-05 15:19:23.835494072 +0200
-@@ -24,8 +24,8 @@
- #include "config.h"
- #endif
- #include "DynamicDll.h"
--#include "DllAvCore.h"
- #include "DllAvCodec.h"
-+#include "DllSwResample.h"
- #include "utils/log.h"
-
- extern "C" {
-@@ -43,24 +43,17 @@
- #if (defined USE_EXTERNAL_FFMPEG)
- #if (defined HAVE_LIBAVFILTER_AVFILTER_H)
- #include
-+ #include
-+ #include
- #elif (defined HAVE_FFMPEG_AVFILTER_H)
- #include
-- #endif
-- /* for av_vsrc_buffer_add_frame */
-- #if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,8,0)
-- #include
-- #elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,7,0)
-- int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter,
-- AVFrame *frame);
-- #elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,3,0)
-- int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter,
-- AVFrame *frame, int64_t pts);
-- #else
-- int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter,
-- AVFrame *frame, int64_t pts, AVRational pixel_aspect);
-+ #include
-+ #include
- #endif
- #else
- #include "libavfilter/avfiltergraph.h"
-+ #include "libavfilter/buffersink.h"
-+ #include "libavfilter/avcodec.h"
- #endif
- }
-
-@@ -82,21 +75,16 @@
- virtual int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)=0;
- virtual int avfilter_poll_frame(AVFilterLink *link)=0;
- virtual int avfilter_request_frame(AVFilterLink *link)=0;
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,13,0)
- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int flags)=0;
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,7,0)
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame)=0;
--#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,3,0)
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts)=0;
--#else
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts, AVRational pixel_aspect)=0;
--#endif
- virtual AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)=0;
- virtual void avfilter_unref_buffer(AVFilterBufferRef *ref)=0;
- virtual int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)=0;
-+ virtual int av_buffersink_get_buffer_ref(AVFilterContext *buffer_sink, AVFilterBufferRef **bufref, int flags)=0;
-+ virtual AVBufferSinkParams *av_buffersink_params_alloc()=0;
-+ virtual int av_buffersink_poll_frame(AVFilterContext *ctx)=0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
- // Use direct mapping
- class DllAvFilter : public DllDynamic, DllAvFilterInterface
- {
-@@ -115,12 +103,7 @@
- virtual void avfilter_graph_free(AVFilterGraph **graph)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(1,76,0)
- ::avfilter_graph_free(graph);
--#else
-- ::avfilter_graph_free(*graph);
-- *graph = NULL;
--#endif
- }
- void avfilter_register_all()
- {
-@@ -133,56 +116,31 @@
- virtual AVFilterInOut *avfilter_inout_alloc()
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- return ::avfilter_inout_alloc();
--#else
-- return (AVFilterInOut*)::av_mallocz(sizeof(AVFilterInOut));
--#endif
- }
- virtual void avfilter_inout_free(AVFilterInOut **inout)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- ::avfilter_inout_free(inout);
--#else
-- *inout = NULL;
--#endif
- }
- virtual int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs, void *log_ctx)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if ( LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(1,79,0) \
-- && LIBAVFILTER_VERSION_INT < AV_VERSION_INT(2,0,0) ) \
-- ||( LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,16,0))
- return ::avfilter_graph_parse(graph, filters, inputs, outputs, log_ctx);
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
-- return ::avfilter_graph_parse(graph, filters, *inputs, *outputs, log_ctx);
--#else
-- return ::avfilter_graph_parse(graph, filters, *inputs, *outputs, (AVClass*)log_ctx);
--#endif
- }
- virtual int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
- {
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
- return ::avfilter_graph_config(graphctx, log_ctx);
--#else
-- return ::avfilter_graph_config(graphctx, (AVClass*)log_ctx);
--#endif
- }
- virtual int avfilter_poll_frame(AVFilterLink *link) { return ::avfilter_poll_frame(link); }
- virtual int avfilter_request_frame(AVFilterLink *link) { return ::avfilter_request_frame(link); }
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,13,0)
- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int flags) { return ::av_vsrc_buffer_add_frame(buffer_filter, frame, flags); }
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,7,0)
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame) { return ::av_vsrc_buffer_add_frame(buffer_filter, frame); }
--#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,3,0)
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts) { return ::av_vsrc_buffer_add_frame(buffer_filter, frame, pts); }
--#else
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts, AVRational pixel_aspect) { return ::av_vsrc_buffer_add_frame(buffer_filter, frame, pts, pixel_aspect); }
--#endif
- virtual AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h) { return ::avfilter_get_video_buffer(link, perms, w, h); }
- virtual void avfilter_unref_buffer(AVFilterBufferRef *ref) { ::avfilter_unref_buffer(ref); }
- virtual int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad) { return ::avfilter_link(src, srcpad, dst, dstpad); }
-+ virtual int av_buffersink_get_buffer_ref(AVFilterContext *buffer_sink, AVFilterBufferRef **bufref, int flags) { return ::av_buffersink_get_buffer_ref(buffer_sink, bufref, flags); }
-+ virtual AVBufferSinkParams *av_buffersink_params_alloc() { return ::av_buffersink_params_alloc(); }
-+ virtual int av_buffersink_poll_frame(AVFilterContext *ctx) { return av_buffersink_poll_frame(ctx); }
- // DLL faking.
- virtual bool ResolveExports() { return true; }
- virtual bool Load() {
-@@ -200,45 +158,24 @@
-
- DEFINE_METHOD3(int, avfilter_open_dont_call, (AVFilterContext **p1, AVFilter *p2, const char *p3))
- DEFINE_METHOD1(void, avfilter_free_dont_call, (AVFilterContext *p1))
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(1,76,0)
- DEFINE_METHOD1(void, avfilter_graph_free_dont_call, (AVFilterGraph **p1))
--#else
-- DEFINE_METHOD1(void, avfilter_graph_free_dont_call, (AVFilterGraph *p1))
--#endif
- DEFINE_METHOD0(void, avfilter_register_all_dont_call)
- DEFINE_METHOD6(int, avfilter_graph_create_filter, (AVFilterContext **p1, AVFilter *p2, const char *p3, const char *p4, void *p5, AVFilterGraph *p6))
- DEFINE_METHOD1(AVFilter*, avfilter_get_by_name, (const char *p1))
- DEFINE_METHOD0(AVFilterGraph*, avfilter_graph_alloc)
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- DEFINE_METHOD0(AVFilterInOut*, avfilter_inout_alloc_dont_call)
- DEFINE_METHOD1(void, avfilter_inout_free_dont_call, (AVFilterInOut **p1))
--#endif
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,16,0)
-- DEFINE_METHOD5(int, avfilter_graph_parse_dont_call, (AVFilterGraph *p1, const char *p2, AVFilterInOut **p3, AVFilterInOut **p4, void *p5))
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
-- DEFINE_METHOD5(int, avfilter_graph_parse_dont_call, (AVFilterGraph *p1, const char *p2, AVFilterInOut *p3, AVFilterInOut *p4, void *p5))
--#else
-- DEFINE_METHOD5(int, avfilter_graph_parse_dont_call, (AVFilterGraph *p1, const char *p2, AVFilterInOut *p3, AVFilterInOut *p4, AVClass *p5))
--#endif
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
-- DEFINE_METHOD2(int, avfilter_graph_config_dont_call, (AVFilterGraph *p1, void *p2))
--#else
-- DEFINE_METHOD2(int, avfilter_graph_config_dont_call, (AVFilterGraph *p1, AVClass *p2))
--#endif
-+ DEFINE_FUNC_ALIGNED5(int, __cdecl, avfilter_graph_parse_dont_call, AVFilterGraph *, const char *, AVFilterInOut **, AVFilterInOut **, void *)
-+ DEFINE_FUNC_ALIGNED2(int, __cdecl, avfilter_graph_config_dont_call, AVFilterGraph *, void *)
- DEFINE_FUNC_ALIGNED1(int, __cdecl, avfilter_poll_frame, AVFilterLink *)
- DEFINE_FUNC_ALIGNED1(int, __cdecl, avfilter_request_frame, AVFilterLink*)
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,13,0)
- DEFINE_METHOD3(int, av_vsrc_buffer_add_frame, (AVFilterContext *p1, AVFrame *p2, int p3))
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,7,0)
-- DEFINE_METHOD2(int, av_vsrc_buffer_add_frame, (AVFilterContext *p1, AVFrame *p2))
--#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,3,0)
-- DEFINE_METHOD3(int, av_vsrc_buffer_add_frame, (AVFilterContext *p1, AVFrame *p2, int64_t p3))
--#else
-- DEFINE_METHOD4(int, av_vsrc_buffer_add_frame, (AVFilterContext *p1, AVFrame *p2, int64_t p3, AVRational p4))
--#endif
- DEFINE_METHOD4(AVFilterBufferRef*, avfilter_get_video_buffer, (AVFilterLink *p1, int p2, int p3, int p4))
- DEFINE_METHOD1(void, avfilter_unref_buffer, (AVFilterBufferRef *p1))
- DEFINE_METHOD4(int, avfilter_link, (AVFilterContext *p1, unsigned p2, AVFilterContext *p3, unsigned p4))
-+ DEFINE_FUNC_ALIGNED3(int , __cdecl, av_buffersink_get_buffer_ref, AVFilterContext *, AVFilterBufferRef **, int);
-+ DEFINE_FUNC_ALIGNED0(AVBufferSinkParams*, __cdecl, av_buffersink_params_alloc);
-+ DEFINE_FUNC_ALIGNED1(int , __cdecl, av_buffersink_poll_frame, AVFilterContext *);
-
- BEGIN_METHOD_RESOLVE()
- RESOLVE_METHOD_RENAME(avfilter_open, avfilter_open_dont_call)
-@@ -248,10 +185,8 @@
- RESOLVE_METHOD(avfilter_graph_create_filter)
- RESOLVE_METHOD(avfilter_get_by_name)
- RESOLVE_METHOD(avfilter_graph_alloc)
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- RESOLVE_METHOD_RENAME(avfilter_inout_alloc, avfilter_inout_alloc_dont_call)
- RESOLVE_METHOD_RENAME(avfilter_inout_free, avfilter_inout_free_dont_call)
--#endif
- RESOLVE_METHOD_RENAME(avfilter_graph_parse, avfilter_graph_parse_dont_call)
- RESOLVE_METHOD_RENAME(avfilter_graph_config, avfilter_graph_config_dont_call)
- RESOLVE_METHOD(avfilter_poll_frame)
-@@ -260,10 +195,14 @@
- RESOLVE_METHOD(avfilter_get_video_buffer)
- RESOLVE_METHOD(avfilter_unref_buffer)
- RESOLVE_METHOD(avfilter_link)
-+ RESOLVE_METHOD(av_buffersink_get_buffer_ref)
-+ RESOLVE_METHOD(av_buffersink_params_alloc)
-+ RESOLVE_METHOD(av_buffersink_poll_frame)
- END_METHOD_RESOLVE()
-
- /* dependencies of libavfilter */
- DllAvUtil m_dllAvUtil;
-+ DllSwResample m_dllSwResample;
-
- public:
- int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
-@@ -279,12 +218,7 @@
- void avfilter_graph_free(AVFilterGraph **graph)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(1,76,0)
- avfilter_graph_free_dont_call(graph);
--#else
-- avfilter_graph_free_dont_call(*graph);
-- m_dllAvUtil.av_freep(graph);
--#endif
- }
- void avfilter_register_all()
- {
-@@ -294,45 +228,29 @@
- AVFilterInOut* avfilter_inout_alloc()
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- return avfilter_inout_alloc_dont_call();
--#else
-- return (AVFilterInOut*)m_dllAvUtil.av_mallocz(sizeof(AVFilterInOut));
--#endif
- }
- int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs, void *log_ctx)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,16,0)
- return avfilter_graph_parse_dont_call(graph, filters, inputs, outputs, log_ctx);
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
-- return avfilter_graph_parse_dont_call(graph, filters, *inputs, *outputs, log_ctx);
--#else
-- return avfilter_graph_parse_dont_call(graph, filters, *inputs, *outputs, (AVClass*)log_ctx);
--#endif
- }
- void avfilter_inout_free(AVFilterInOut **inout)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- avfilter_inout_free_dont_call(inout);
--#else
-- *inout = NULL;
--#endif
- }
- int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
- return avfilter_graph_config_dont_call(graphctx, log_ctx);
--#else
-- return avfilter_graph_config_dont_call(graphctx, (AVClass*)log_ctx);
--#endif
- }
- virtual bool Load()
- {
- if (!m_dllAvUtil.Load())
- return false;
-+ if (!m_dllSwResample.Load())
-+ return false;
- return DllDynamic::Load();
- }
- };
-diff -Naur xbmc-11.0.1/lib/DllAvFormat.h xbmc-11.0.1.patch/lib/DllAvFormat.h
---- xbmc-11.0.1/lib/DllAvFormat.h 2012-03-21 23:57:42.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllAvFormat.h 2012-06-05 15:19:23.837494112 +0200
-@@ -62,57 +62,45 @@
- virtual ~DllAvFormatInterface() {}
- virtual void av_register_all_dont_call(void)=0;
- virtual AVInputFormat *av_find_input_format(const char *short_name)=0;
-- virtual int url_feof(ByteIOContext *s)=0;
-- virtual AVMetadataTag *av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags)=0;
-- virtual void av_close_input_file(AVFormatContext *s)=0;
-- virtual void av_close_input_stream(AVFormatContext *s)=0;
-+ virtual int url_feof(AVIOContext *s)=0;
-+ virtual void avformat_close_input(AVFormatContext **s)=0;
- virtual int av_read_frame(AVFormatContext *s, AVPacket *pkt)=0;
- virtual void av_read_frame_flush(AVFormatContext *s)=0;
- virtual int av_read_play(AVFormatContext *s)=0;
- virtual int av_read_pause(AVFormatContext *s)=0;
- virtual int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)=0;
--#if (!defined USE_EXTERNAL_FFMPEG)
-- virtual int av_find_stream_info_dont_call(AVFormatContext *ic)=0;
-+#if (!defined USE_EXTERNAL_FFMPEG) && (!defined TARGET_DARWIN)
-+ virtual int avformat_find_stream_info_dont_call(AVFormatContext *ic, AVDictionary **options)=0;
- #endif
-- virtual int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, AVInputFormat *fmt, int buf_size, AVFormatParameters *ap)=0;
-- virtual void url_set_interrupt_cb(URLInterruptCB *interrupt_cb)=0;
-- virtual int av_open_input_stream(AVFormatContext **ic_ptr, ByteIOContext *pb, const char *filename, AVInputFormat *fmt, AVFormatParameters *ap)=0;
-- virtual int init_put_byte(ByteIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
-+ virtual int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)=0;
-+ virtual AVIOContext *avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
- int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
- int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
- offset_t (*seek)(void *opaque, offset_t offset, int whence))=0;
- virtual AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened)=0;
- virtual AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)=0;
-- virtual int av_probe_input_buffer(ByteIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)=0;
-- virtual void dump_format(AVFormatContext *ic, int index, const char *url, int is_output)=0;
-- virtual int url_fdopen(ByteIOContext **s, URLContext *h)=0;
-- virtual int url_fopen(ByteIOContext **s, const char *filename, int flags)=0;
-- virtual int url_fclose(ByteIOContext *s)=0;
-- virtual int url_open_dyn_buf(ByteIOContext **s)=0;
-- virtual int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer)=0;
-- virtual offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence)=0;
-- virtual int get_buffer(ByteIOContext *s, unsigned char *buf, int size)=0;
-- virtual int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size)=0;
-- virtual void put_byte(ByteIOContext *s, int b)=0;
-- virtual void put_buffer(ByteIOContext *s, const unsigned char *buf, int size)=0;
-- virtual void put_be24(ByteIOContext *s, unsigned int val)=0;
-- virtual void put_be32(ByteIOContext *s, unsigned int val)=0;
-- virtual void put_be16(ByteIOContext *s, unsigned int val)=0;
-+ virtual int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)=0;
-+ virtual void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)=0;
-+ virtual int avio_open(AVIOContext **s, const char *filename, int flags)=0;
-+ virtual int avio_close(AVIOContext *s)=0;
-+ virtual int avio_open_dyn_buf(AVIOContext **s)=0;
-+ virtual int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)=0;
-+ virtual offset_t avio_seek(AVIOContext *s, offset_t offset, int whence)=0;
-+ virtual int avio_read(AVIOContext *s, unsigned char *buf, int size)=0;
-+ virtual void avio_w8(AVIOContext *s, int b)=0;
-+ virtual void avio_write(AVIOContext *s, const unsigned char *buf, int size)=0;
-+ virtual void avio_wb24(AVIOContext *s, unsigned int val)=0;
-+ virtual void avio_wb32(AVIOContext *s, unsigned int val)=0;
-+ virtual void avio_wb16(AVIOContext *s, unsigned int val)=0;
- virtual AVFormatContext *avformat_alloc_context(void)=0;
-- virtual AVStream *av_new_stream(AVFormatContext *s, int id)=0;
-+ virtual AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)=0;
- virtual AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type)=0;
-- virtual int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap)=0;
-- virtual ByteIOContext *av_alloc_put_byte(unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
-- int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
-- int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
-- offset_t (*seek)(void *opaque, offset_t offset, int whence))=0;
-- virtual int av_write_header (AVFormatContext *s)=0;
-+ virtual int avformat_write_header (AVFormatContext *s, AVDictionary **options)=0;
- virtual int av_write_trailer(AVFormatContext *s)=0;
- virtual int av_write_frame (AVFormatContext *s, AVPacket *pkt)=0;
-- virtual int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags)=0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
-
- // Use direct mapping
- class DllAvFormat : public DllDynamic, DllAvFormatInterface
-@@ -126,78 +114,45 @@
- }
- virtual void av_register_all_dont_call() { *(int* )0x0 = 0; }
- virtual AVInputFormat *av_find_input_format(const char *short_name) { return ::av_find_input_format(short_name); }
-- virtual int url_feof(ByteIOContext *s) { return ::url_feof(s); }
--#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,31,0)
-- // API added on: 2009-03-01
-- virtual AVMetadataTag *av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags){ return ::av_metadata_get(m, key, prev, flags); }
--#else
-- virtual AVMetadataTag *av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags){ return NULL; }
--#endif
-- virtual void av_close_input_file(AVFormatContext *s) { ::av_close_input_file(s); }
-- virtual void av_close_input_stream(AVFormatContext *s) { ::av_close_input_stream(s); }
-+ virtual int url_feof(AVIOContext *s) { return ::url_feof(s); }
-+ virtual void avformat_close_input(AVFormatContext **s) { ::avformat_close_input(s); }
- virtual int av_read_frame(AVFormatContext *s, AVPacket *pkt) { return ::av_read_frame(s, pkt); }
- virtual void av_read_frame_flush(AVFormatContext *s) { ::av_read_frame_flush(s); }
- virtual int av_read_play(AVFormatContext *s) { return ::av_read_play(s); }
- virtual int av_read_pause(AVFormatContext *s) { return ::av_read_pause(s); }
- virtual int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { return ::av_seek_frame(s, stream_index, timestamp, flags); }
-- virtual int av_find_stream_info(AVFormatContext *ic)
-+ virtual int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
-- return ::av_find_stream_info(ic);
-+ return ::avformat_find_stream_info(ic, options);
- }
-- virtual int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, AVInputFormat *fmt, int buf_size, AVFormatParameters *ap) { return ::av_open_input_file(ic_ptr, filename, fmt, buf_size, ap); }
-- virtual void url_set_interrupt_cb(URLInterruptCB *interrupt_cb) { ::url_set_interrupt_cb(interrupt_cb); }
-- virtual int av_open_input_stream(AVFormatContext **ic_ptr, ByteIOContext *pb, const char *filename, AVInputFormat *fmt, AVFormatParameters *ap) { return ::av_open_input_stream(ic_ptr, pb, filename, fmt, ap); }
-- virtual int init_put_byte(ByteIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
-+ virtual int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
-+ { return ::avformat_open_input(ps, filename, fmt, options); }
-+ virtual AVIOContext *avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
- int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
- int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
-- offset_t (*seek)(void *opaque, offset_t offset, int whence)) { return ::init_put_byte(s, buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); }
-+ offset_t (*seek)(void *opaque, offset_t offset, int whence)) { return ::avio_alloc_context(buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); }
- virtual AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened) {return ::av_probe_input_format(pd, is_opened); }
- virtual AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max) {*score_max = 100; return ::av_probe_input_format(pd, is_opened); } // Use av_probe_input_format, this is not exported by ffmpeg's headers
--#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,98,0)
-- // API added on: 2010-02-08
-- virtual int av_probe_input_buffer(ByteIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size) { return ::av_probe_input_buffer(pb, fmt, filename, logctx, offset, max_probe_size); }
--#else
-- virtual int av_probe_input_buffer(ByteIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size) { return -1; }
--#endif
-- virtual void dump_format(AVFormatContext *ic, int index, const char *url, int is_output) { ::dump_format(ic, index, url, is_output); }
-- virtual int url_fdopen(ByteIOContext **s, URLContext *h) { return ::url_fdopen(s, h); }
-- virtual int url_fopen(ByteIOContext **s, const char *filename, int flags) { return ::url_fopen(s, filename, flags); }
-- virtual int url_fclose(ByteIOContext *s) { return ::url_fclose(s); }
-- virtual int url_open_dyn_buf(ByteIOContext **s) { return ::url_open_dyn_buf(s); }
-- virtual int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer) { return ::url_close_dyn_buf(s, pbuffer); }
-- virtual offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence) { return ::url_fseek(s, offset, whence); }
-- virtual int get_buffer(ByteIOContext *s, unsigned char *buf, int size) { return ::get_buffer(s, buf, size); }
-- virtual int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size) { return ::get_partial_buffer(s, buf, size); }
-- virtual void put_byte(ByteIOContext *s, int b) { ::put_byte(s, b); }
-- virtual void put_buffer(ByteIOContext *s, const unsigned char *buf, int size) { ::put_buffer(s, buf, size); }
-- virtual void put_be24(ByteIOContext *s, unsigned int val) { ::put_be24(s, val); }
-- virtual void put_be32(ByteIOContext *s, unsigned int val) { ::put_be32(s, val); }
-- virtual void put_be16(ByteIOContext *s, unsigned int val) { ::put_be16(s, val); }
-+ virtual int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size) { return ::av_probe_input_buffer(pb, fmt, filename, logctx, offset, max_probe_size); }
-+ virtual void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output) { ::av_dump_format(ic, index, url, is_output); }
-+ virtual int avio_open(AVIOContext **s, const char *filename, int flags) { return ::avio_open(s, filename, flags); }
-+ virtual int avio_close(AVIOContext *s) { return ::avio_close(s); }
-+ virtual int avio_open_dyn_buf(AVIOContext **s) { return ::avio_open_dyn_buf(s); }
-+ virtual int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) { return ::avio_close_dyn_buf(s, pbuffer); }
-+ virtual offset_t avio_seek(AVIOContext *s, offset_t offset, int whence) { return ::avio_seek(s, offset, whence); }
-+ virtual int avio_read(AVIOContext *s, unsigned char *buf, int size) { return ::avio_read(s, buf, size); }
-+ virtual void avio_w8(AVIOContext *s, int b) { ::avio_w8(s, b); }
-+ virtual void avio_write(AVIOContext *s, const unsigned char *buf, int size) { ::avio_write(s, buf, size); }
-+ virtual void avio_wb24(AVIOContext *s, unsigned int val) { ::avio_wb24(s, val); }
-+ virtual void avio_wb32(AVIOContext *s, unsigned int val) { ::avio_wb32(s, val); }
-+ virtual void avio_wb16(AVIOContext *s, unsigned int val) { ::avio_wb16(s, val); }
- virtual AVFormatContext *avformat_alloc_context() { return ::avformat_alloc_context(); }
-- virtual AVStream *av_new_stream(AVFormatContext *s, int id) { return ::av_new_stream(s, id); }
--#if LIBAVFORMAT_VERSION_INT < (52<<16 | 45<<8)
-- virtual AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type) { return ::guess_format(short_name, filename, mime_type); }
--#else
-+ virtual AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c) { return ::avformat_new_stream(s, c); }
- virtual AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type) { return ::av_guess_format(short_name, filename, mime_type); }
--#endif
-- virtual int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap) { return ::av_set_parameters(s, ap); }
-- virtual ByteIOContext *av_alloc_put_byte(unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
-- int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
-- int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
-- offset_t (*seek)(void *opaque, offset_t offset, int whence)) { return ::av_alloc_put_byte(buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); }
-- virtual int av_write_header (AVFormatContext *s) { return ::av_write_header (s); }
-+ virtual int avformat_write_header (AVFormatContext *s, AVDictionary **options) { return ::avformat_write_header (s, options); }
- virtual int av_write_trailer(AVFormatContext *s) { return ::av_write_trailer(s); }
- virtual int av_write_frame (AVFormatContext *s, AVPacket *pkt) { return ::av_write_frame(s, pkt); }
--#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,43,0)
-- // API added on: 2009-12-13
-- virtual int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags) { return ::av_metadata_set2(pm, key, value, flags); }
--#elif LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,31,0)
-- // API added on: 2009-03-01
-- virtual int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags) { return ::av_metadata_set(pm, key, value); }
--#else
-- virtual int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags) { return -1; }
--#endif
-
- // DLL faking.
- virtual bool ResolveExports() { return true; }
-@@ -218,108 +173,78 @@
-
- DEFINE_METHOD0(void, av_register_all_dont_call)
- DEFINE_METHOD1(AVInputFormat*, av_find_input_format, (const char *p1))
-- DEFINE_METHOD1(int, url_feof, (ByteIOContext *p1))
-- DEFINE_METHOD4(AVMetadataTag*, av_metadata_get, (AVMetadata *p1, const char *p2, const AVMetadataTag *p3, int p4))
-- DEFINE_METHOD1(void, av_close_input_file, (AVFormatContext *p1))
-- DEFINE_METHOD1(void, av_close_input_stream, (AVFormatContext *p1))
-+ DEFINE_METHOD1(int, url_feof, (AVIOContext *p1))
-+ DEFINE_METHOD1(void, avformat_close_input, (AVFormatContext **p1))
- DEFINE_METHOD1(int, av_read_play, (AVFormatContext *p1))
- DEFINE_METHOD1(int, av_read_pause, (AVFormatContext *p1))
- DEFINE_METHOD1(void, av_read_frame_flush, (AVFormatContext *p1))
- DEFINE_FUNC_ALIGNED2(int, __cdecl, av_read_frame, AVFormatContext *, AVPacket *)
- DEFINE_FUNC_ALIGNED4(int, __cdecl, av_seek_frame, AVFormatContext*, int, int64_t, int)
-- DEFINE_FUNC_ALIGNED1(int, __cdecl, av_find_stream_info_dont_call, AVFormatContext*)
-- DEFINE_FUNC_ALIGNED5(int, __cdecl, av_open_input_file, AVFormatContext**, const char *, AVInputFormat *, int, AVFormatParameters *)
-- DEFINE_FUNC_ALIGNED5(int,__cdecl, av_open_input_stream, AVFormatContext **, ByteIOContext *, const char *, AVInputFormat *, AVFormatParameters *)
-+ DEFINE_FUNC_ALIGNED2(int, __cdecl, avformat_find_stream_info_dont_call, AVFormatContext*, AVDictionary **)
-+ DEFINE_FUNC_ALIGNED4(int, __cdecl, avformat_open_input, AVFormatContext **, const char *, AVInputFormat *, AVDictionary **)
- DEFINE_FUNC_ALIGNED2(AVInputFormat*, __cdecl, av_probe_input_format, AVProbeData*, int)
- DEFINE_FUNC_ALIGNED3(AVInputFormat*, __cdecl, av_probe_input_format2, AVProbeData*, int, int*)
-- DEFINE_FUNC_ALIGNED6(int, __cdecl, av_probe_input_buffer, ByteIOContext *, AVInputFormat **, const char *, void *, unsigned int, unsigned int)
-- DEFINE_FUNC_ALIGNED3(int, __cdecl, get_buffer, ByteIOContext*, unsigned char *, int)
-- DEFINE_FUNC_ALIGNED3(int, __cdecl, get_partial_buffer, ByteIOContext*, unsigned char *, int)
-- DEFINE_FUNC_ALIGNED2(void, __cdecl, put_byte, ByteIOContext*, int)
-- DEFINE_FUNC_ALIGNED3(void, __cdecl, put_buffer, ByteIOContext*, const unsigned char *, int)
-- DEFINE_FUNC_ALIGNED2(void, __cdecl, put_be24, ByteIOContext*, unsigned int)
-- DEFINE_FUNC_ALIGNED2(void, __cdecl, put_be32, ByteIOContext*, unsigned int)
-- DEFINE_FUNC_ALIGNED2(void, __cdecl, put_be16, ByteIOContext*, unsigned int)
-- DEFINE_METHOD1(void, url_set_interrupt_cb, (URLInterruptCB *p1))
-- DEFINE_METHOD8(int, init_put_byte, (ByteIOContext *p1, unsigned char *p2, int p3, int p4, void *p5,
-+ DEFINE_FUNC_ALIGNED6(int, __cdecl, av_probe_input_buffer, AVIOContext *, AVInputFormat **, const char *, void *, unsigned int, unsigned int)
-+ DEFINE_FUNC_ALIGNED3(int, __cdecl, avio_read, AVIOContext*, unsigned char *, int)
-+ DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_w8, AVIOContext*, int)
-+ DEFINE_FUNC_ALIGNED3(void, __cdecl, avio_write, AVIOContext*, const unsigned char *, int)
-+ DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_wb24, AVIOContext*, unsigned int)
-+ DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_wb32, AVIOContext*, unsigned int)
-+ DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_wb16, AVIOContext*, unsigned int)
-+ DEFINE_METHOD7(AVIOContext *, avio_alloc_context, (unsigned char *p1, int p2, int p3, void *p4,
-+ int (*p5)(void *opaque, uint8_t *buf, int buf_size),
- int (*p6)(void *opaque, uint8_t *buf, int buf_size),
-- int (*p7)(void *opaque, uint8_t *buf, int buf_size),
-- offset_t (*p8)(void *opaque, offset_t offset, int whence)))
-- DEFINE_METHOD4(void, dump_format, (AVFormatContext *p1, int p2, const char *p3, int p4))
-- DEFINE_METHOD2(int, url_fdopen, (ByteIOContext **p1, URLContext *p2))
-- DEFINE_METHOD3(int, url_fopen, (ByteIOContext **p1, const char *p2, int p3))
-- DEFINE_METHOD1(int, url_fclose, (ByteIOContext *p1))
-- DEFINE_METHOD1(int, url_open_dyn_buf, (ByteIOContext **p1))
-- DEFINE_METHOD2(int, url_close_dyn_buf, (ByteIOContext *p1, uint8_t **p2))
-- DEFINE_METHOD3(offset_t, url_fseek, (ByteIOContext *p1, offset_t p2, int p3))
-+ offset_t (*p7)(void *opaque, offset_t offset, int whence)))
-+ DEFINE_METHOD4(void, av_dump_format, (AVFormatContext *p1, int p2, const char *p3, int p4))
-+ DEFINE_METHOD3(int, avio_open, (AVIOContext **p1, const char *p2, int p3))
-+ DEFINE_METHOD1(int, avio_close, (AVIOContext *p1))
-+ DEFINE_METHOD1(int, avio_open_dyn_buf, (AVIOContext **p1))
-+ DEFINE_METHOD2(int, avio_close_dyn_buf, (AVIOContext *p1, uint8_t **p2))
-+ DEFINE_METHOD3(offset_t, avio_seek, (AVIOContext *p1, offset_t p2, int p3))
- DEFINE_METHOD0(AVFormatContext *, avformat_alloc_context)
-- DEFINE_METHOD2(AVStream *, av_new_stream, (AVFormatContext *p1, int p2))
--#if LIBAVFORMAT_VERSION_INT < (52<<16 | 45<<8)
-- DEFINE_METHOD3(AVOutputFormat *, guess_format, (const char *p1, const char *p2, const char *p3))
--#else
-+ DEFINE_METHOD2(AVStream *, avformat_new_stream, (AVFormatContext *p1, AVCodec *p2))
- DEFINE_METHOD3(AVOutputFormat *, av_guess_format, (const char *p1, const char *p2, const char *p3))
--#endif
-- DEFINE_METHOD2(int, av_set_parameters, (AVFormatContext *p1, AVFormatParameters *p2));
-- DEFINE_METHOD7(ByteIOContext *, av_alloc_put_byte, (unsigned char *p1, int p2, int p3, void *p4,
-- int(*p5)(void *opaque, uint8_t *buf, int buf_size),
-- int(*p6)(void *opaque, uint8_t *buf, int buf_size),
-- offset_t(*p7)(void *opaque, offset_t offset, int whence)))
-- DEFINE_METHOD1(int, av_write_header , (AVFormatContext *p1))
-+ DEFINE_METHOD2(int, avformat_write_header , (AVFormatContext *p1, AVDictionary **p2))
- DEFINE_METHOD1(int, av_write_trailer, (AVFormatContext *p1))
- DEFINE_METHOD2(int, av_write_frame , (AVFormatContext *p1, AVPacket *p2))
-- DEFINE_METHOD4(int, av_metadata_set2, (AVMetadata **p1, const char *p2, const char *p3, int p4));
- BEGIN_METHOD_RESOLVE()
- RESOLVE_METHOD_RENAME(av_register_all, av_register_all_dont_call)
- RESOLVE_METHOD(av_find_input_format)
- RESOLVE_METHOD(url_feof)
-- RESOLVE_METHOD(av_metadata_get)
-- RESOLVE_METHOD(av_close_input_file)
-- RESOLVE_METHOD(av_close_input_stream)
-+ RESOLVE_METHOD(avformat_close_input)
- RESOLVE_METHOD(av_read_frame)
- RESOLVE_METHOD(av_read_play)
- RESOLVE_METHOD(av_read_pause)
-- RESOLVE_METHOD_RENAME(ff_read_frame_flush, av_read_frame_flush)
-+ RESOLVE_METHOD(av_read_frame_flush)
- RESOLVE_METHOD(av_seek_frame)
-- RESOLVE_METHOD_RENAME(av_find_stream_info, av_find_stream_info_dont_call)
-- RESOLVE_METHOD(av_open_input_file)
-- RESOLVE_METHOD(url_set_interrupt_cb)
-- RESOLVE_METHOD(av_open_input_stream)
-- RESOLVE_METHOD(init_put_byte)
-+ RESOLVE_METHOD_RENAME(avformat_find_stream_info, avformat_find_stream_info_dont_call)
-+ RESOLVE_METHOD(avformat_open_input)
-+ RESOLVE_METHOD(avio_alloc_context)
- RESOLVE_METHOD(av_probe_input_format)
- RESOLVE_METHOD(av_probe_input_format2)
- RESOLVE_METHOD(av_probe_input_buffer)
-- RESOLVE_METHOD(dump_format)
-- RESOLVE_METHOD(url_fdopen)
-- RESOLVE_METHOD(url_fopen)
-- RESOLVE_METHOD(url_fclose)
-- RESOLVE_METHOD(url_open_dyn_buf)
-- RESOLVE_METHOD(url_close_dyn_buf)
-- RESOLVE_METHOD(url_fseek)
-- RESOLVE_METHOD(get_buffer)
-- RESOLVE_METHOD(get_partial_buffer)
-- RESOLVE_METHOD(put_byte)
-- RESOLVE_METHOD(put_buffer)
-- RESOLVE_METHOD(put_be24)
-- RESOLVE_METHOD(put_be32)
-- RESOLVE_METHOD(put_be16)
-+ RESOLVE_METHOD(av_dump_format)
-+ RESOLVE_METHOD(avio_open)
-+ RESOLVE_METHOD(avio_close)
-+ RESOLVE_METHOD(avio_open_dyn_buf)
-+ RESOLVE_METHOD(avio_close_dyn_buf)
-+ RESOLVE_METHOD(avio_seek)
-+ RESOLVE_METHOD(avio_read)
-+ RESOLVE_METHOD(avio_w8)
-+ RESOLVE_METHOD(avio_write)
-+ RESOLVE_METHOD(avio_wb24)
-+ RESOLVE_METHOD(avio_wb32)
-+ RESOLVE_METHOD(avio_wb16)
- RESOLVE_METHOD(avformat_alloc_context)
-- RESOLVE_METHOD(av_new_stream)
--#if LIBAVFORMAT_VERSION_INT < (52<<16 | 45<<8)
-- RESOLVE_METHOD(guess_format)
--#else
-+ RESOLVE_METHOD(avformat_new_stream)
- RESOLVE_METHOD(av_guess_format)
--#endif
-- RESOLVE_METHOD(av_set_parameters)
-- RESOLVE_METHOD(av_alloc_put_byte)
-- RESOLVE_METHOD(av_write_header)
-+ RESOLVE_METHOD(avformat_write_header)
- RESOLVE_METHOD(av_write_trailer)
- RESOLVE_METHOD(av_write_frame)
-- RESOLVE_METHOD(av_metadata_set2)
- END_METHOD_RESOLVE()
-
- /* dependencies of libavformat */
- DllAvCodec m_dllAvCodec;
-- // DllAvCore loaded implicitely by m_dllAvCodec
- // DllAvUtil loaded implicitely by m_dllAvCodec
-
- public:
-@@ -328,10 +253,10 @@
- CSingleLock lock(DllAvCodec::m_critSection);
- av_register_all_dont_call();
- }
-- int av_find_stream_info(AVFormatContext *ic)
-+ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
-- return(av_find_stream_info_dont_call(ic));
-+ return avformat_find_stream_info_dont_call(ic, options);
- }
-
- virtual bool Load()
-diff -Naur xbmc-11.0.1/lib/DllAvUtil.h xbmc-11.0.1.patch/lib/DllAvUtil.h
---- xbmc-11.0.1/lib/DllAvUtil.h 2012-03-21 23:57:41.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllAvUtil.h 2012-06-05 15:19:23.837494112 +0200
-@@ -65,6 +65,7 @@
- #include "libavutil/opt.h"
- #include "libavutil/mem.h"
- #include "libavutil/fifo.h"
-+ #include "libavutil/samplefmt.h"
- #endif
- }
-
-@@ -89,7 +90,7 @@
- virtual int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)=0;
- virtual const AVCRC* av_crc_get_table(AVCRCId crc_id)=0;
- virtual uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)=0;
-- virtual int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out)=0;
-+ virtual int av_opt_set(void *obj, const char *name, const char *val, int search_flags)=0;
- virtual AVFifoBuffer *av_fifo_alloc(unsigned int size) = 0;
- virtual void av_fifo_free(AVFifoBuffer *f) = 0;
- virtual void av_fifo_reset(AVFifoBuffer *f) = 0;
-@@ -97,10 +98,13 @@
- virtual int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int)) = 0;
- virtual int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int)) = 0;
- virtual char *av_strdup(const char *s)=0;
-+ virtual int av_get_bytes_per_sample(enum AVSampleFormat p1) = 0;
-+ virtual AVDictionaryEntry *av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags) = 0;
-+ virtual int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)=0;
-+ virtual int av_samples_get_buffer_size (int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align) = 0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
--
-+#if defined (USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
- // Use direct layer
- class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
- {
-@@ -117,12 +121,7 @@
- virtual int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) { return ::av_rescale_q(a, bq, cq); }
- virtual const AVCRC* av_crc_get_table(AVCRCId crc_id) { return ::av_crc_get_table(crc_id); }
- virtual uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length) { return ::av_crc(ctx, crc, buffer, length); }
--#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,7,0)
-- // API added on: 2008-12-16
-- virtual int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out) { return ::av_set_string3(obj, name, val, alloc, o_out); }
--#else
-- virtual int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out) { return AVERROR(ENOENT); }
--#endif
-+ virtual int av_opt_set(void *obj, const char *name, const char *val, int search_flags) { return ::av_opt_set(obj, name, val, search_flags); }
- virtual AVFifoBuffer *av_fifo_alloc(unsigned int size) {return ::av_fifo_alloc(size); }
- virtual void av_fifo_free(AVFifoBuffer *f) { ::av_fifo_free(f); }
- virtual void av_fifo_reset(AVFifoBuffer *f) { ::av_fifo_reset(f); }
-@@ -132,6 +131,12 @@
- virtual int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int))
- { return ::av_fifo_generic_write(f, src, size, func); }
- virtual char *av_strdup(const char *s) { return ::av_strdup(s); }
-+ virtual int av_get_bytes_per_sample(enum AVSampleFormat p1)
-+ { return ::av_get_bytes_per_sample(p1); }
-+ virtual AVDictionaryEntry *av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags){ return ::av_dict_get(m, key, prev, flags); }
-+ virtual int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags) { return ::av_dict_set(pm, key, value, flags); }
-+ virtual int av_samples_get_buffer_size (int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
-+ { return ::av_samples_get_buffer_size(linesize, nb_channels, nb_samples, sample_fmt, align); }
-
- // DLL faking.
- virtual bool ResolveExports() { return true; }
-@@ -160,7 +165,7 @@
- DEFINE_METHOD3(int64_t, av_rescale_q, (int64_t p1, AVRational p2, AVRational p3));
- DEFINE_METHOD1(const AVCRC*, av_crc_get_table, (AVCRCId p1))
- DEFINE_METHOD4(uint32_t, av_crc, (const AVCRC *p1, uint32_t p2, const uint8_t *p3, size_t p4));
-- DEFINE_METHOD5(int, av_set_string3, (void *p1, const char *p2, const char *p3, int p4, const AVOption **p5));
-+ DEFINE_METHOD4(int, av_opt_set, (void *p1, const char *p2, const char *p3, int p4));
- DEFINE_METHOD1(AVFifoBuffer*, av_fifo_alloc, (unsigned int p1))
- DEFINE_METHOD1(void, av_fifo_free, (AVFifoBuffer *p1))
- DEFINE_METHOD1(void, av_fifo_reset, (AVFifoBuffer *p1))
-@@ -168,6 +173,10 @@
- DEFINE_METHOD4(int, av_fifo_generic_read, (AVFifoBuffer *p1, void *p2, int p3, void (*p4)(void*, void*, int)))
- DEFINE_METHOD4(int, av_fifo_generic_write, (AVFifoBuffer *p1, void *p2, int p3, int (*p4)(void*, void*, int)))
- DEFINE_METHOD1(char*, av_strdup, (const char *p1))
-+ DEFINE_METHOD1(int, av_get_bytes_per_sample, (enum AVSampleFormat p1))
-+ DEFINE_METHOD4(AVDictionaryEntry *, av_dict_get, (AVDictionary *p1, const char *p2, const AVDictionaryEntry *p3, int p4))
-+ DEFINE_METHOD4(int, av_dict_set, (AVDictionary **p1, const char *p2, const char *p3, int p4));
-+ DEFINE_METHOD5(int, av_samples_get_buffer_size, (int *p1, int p2, int p3, enum AVSampleFormat p4, int p5))
-
- public:
- BEGIN_METHOD_RESOLVE()
-@@ -181,7 +190,7 @@
- RESOLVE_METHOD(av_rescale_q)
- RESOLVE_METHOD(av_crc_get_table)
- RESOLVE_METHOD(av_crc)
-- RESOLVE_METHOD(av_set_string3)
-+ RESOLVE_METHOD(av_opt_set)
- RESOLVE_METHOD(av_fifo_alloc)
- RESOLVE_METHOD(av_fifo_free)
- RESOLVE_METHOD(av_fifo_reset)
-@@ -189,6 +198,10 @@
- RESOLVE_METHOD(av_fifo_generic_read)
- RESOLVE_METHOD(av_fifo_generic_write)
- RESOLVE_METHOD(av_strdup)
-+ RESOLVE_METHOD(av_get_bytes_per_sample)
-+ RESOLVE_METHOD(av_dict_get)
-+ RESOLVE_METHOD(av_dict_set)
-+ RESOLVE_METHOD(av_samples_get_buffer_size)
- END_METHOD_RESOLVE()
- };
-
-diff -Naur xbmc-11.0.1/lib/DllPostProc.h xbmc-11.0.1.patch/lib/DllPostProc.h
---- xbmc-11.0.1/lib/DllPostProc.h 2012-03-21 23:57:44.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllPostProc.h 2012-06-05 15:19:23.870494772 +0200
-@@ -87,7 +87,7 @@
- virtual void pp_free_context(pp_context *ppContext)=0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
-
- // We call directly.
- class DllPostProc : public DllDynamic, DllPostProcInterface
-diff -Naur xbmc-11.0.1/lib/DllSwResample.h xbmc-11.0.1.patch/lib/DllSwResample.h
---- xbmc-11.0.1/lib/DllSwResample.h 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllSwResample.h 2012-06-05 15:19:23.870494772 +0200
-@@ -0,0 +1,87 @@
-+#pragma once
-+/*
-+ * Copyright (C) 2005-2010 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
-+ *
-+ */
-+
-+#if (defined HAVE_CONFIG_H) && (!defined WIN32)
-+ #include "config.h"
-+#endif
-+#include "DynamicDll.h"
-+
-+extern "C" {
-+#ifndef HAVE_MMX
-+#define HAVE_MMX
-+#endif
-+#ifndef __STDC_CONSTANT_MACROS
-+#define __STDC_CONSTANT_MACROS
-+#endif
-+#ifndef __GNUC__
-+#pragma warning(disable:4244)
-+#endif
-+#if (defined USE_EXTERNAL_FFMPEG)
-+ #include
-+#else
-+ #include "libswresample/swresample.h"
-+#endif
-+}
-+
-+
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
-+
-+// Use direct mapping
-+class DllSwResample : public DllDynamic
-+{
-+public:
-+ virtual ~DllSwResample() {}
-+
-+ // DLL faking.
-+ virtual bool ResolveExports() { return true; }
-+ virtual bool Load() {
-+ CLog::Log(LOGDEBUG, "DllAvFormat: Using libswresample system library");
-+ return true;
-+ }
-+ virtual void Unload() {}
-+};
-+
-+#else
-+
-+class DllSwResample : public DllDynamic
-+{
-+ DECLARE_DLL_WRAPPER(DllSwResample, DLL_PATH_LIBSWRESAMPLE)
-+
-+ LOAD_SYMBOLS()
-+
-+ BEGIN_METHOD_RESOLVE()
-+ END_METHOD_RESOLVE()
-+
-+ /* dependencies of libavformat */
-+ DllAvUtil m_dllAvUtil;
-+
-+public:
-+
-+ virtual bool Load()
-+ {
-+ if (!m_dllAvUtil.Load())
-+ return false;
-+ return DllDynamic::Load();
-+ }
-+};
-+
-+#endif
-diff -Naur xbmc-11.0.1/lib/DllSwScale.h xbmc-11.0.1.patch/lib/DllSwScale.h
---- xbmc-11.0.1/lib/DllSwScale.h 2012-03-21 23:57:39.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/DllSwScale.h 2012-06-05 15:19:23.871494792 +0200
-@@ -92,7 +92,7 @@
- virtual void sws_freeContext(struct SwsContext *context)=0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
-
- // We call into this library directly.
- class DllSwScale : public DllDynamic, public DllSwScaleInterface
-diff -Naur xbmc-11.0.1/lib/Makefile.in xbmc-11.0.1.patch/lib/Makefile.in
---- xbmc-11.0.1/lib/Makefile.in 2012-03-21 23:57:41.000000000 +0100
-+++ xbmc-11.0.1.patch/lib/Makefile.in 2012-06-05 15:19:23.880494972 +0200
-@@ -1,21 +1,18 @@
- ARCH=@ARCH@
-
-+AR=@AR@
- LD=@LD@
- CC=@CC@
- CXX=@CXX@
--SHELL=@SHELL@
--ifeq ($(findstring osx,$(ARCH)),osx)
--ifeq ($(findstring arm,$(ARCH)),arm)
--LDFLAGS=-arch armv7 -iphoneos_version_min 4.1 -bundle -undefined dynamic_lookup -read_only_relocs suppress
--else
--LDFLAGS=-bundle -undefined dynamic_lookup -read_only_relocs suppress
--endif
--else
--LDFLAGS=-shared -fPIC -rdynamic
--endif
- SYSDIR=@abs_top_srcdir@/system/players/dvdplayer
--WRAPPER=@abs_top_srcdir@/xbmc/cores/DllLoader/exports/wrapper.o
--WRAPPER_MACH_ALIAS=@abs_top_srcdir@/xbmc/cores/DllLoader/exports/wrapper_mach_alias
-+
-+AVFORMAT_SO=avformat-53-$(ARCH).so
-+AVCODEC_SO=avcodec-53-$(ARCH).so
-+AVUTIL_SO=avutil-51-$(ARCH).so
-+AVFILTER_SO=avfilter-2-$(ARCH).so
-+SWSCALE_SO=swscale-2-$(ARCH).so
-+POSTPROC_SO=postproc-52-$(ARCH).so
-+SWRESAMPLE_SO=swresample-0-$(ARCH).so
-
- DIRS=
- ifneq (@USE_EXTERNAL_FFMPEG@,1)
-@@ -24,123 +21,55 @@
-
- LIBS=
- ifneq (@USE_EXTERNAL_FFMPEG@,1)
-- LIBS+=avutil-50-$(ARCH).so \
-- avcodec-52-$(ARCH).so \
-- avcore-0-$(ARCH).so \
-- avformat-52-$(ARCH).so \
-- postproc-51-$(ARCH).so \
-- avfilter-1-$(ARCH).so \
-- swscale-0-$(ARCH).so
--endif
--
--ifneq (,$(findstring powerpc,$(ARCH)))
-- ARCH_DIR=ppc
--else
--ifeq ($(findstring arm,$(ARCH)),arm)
-- ARCH_DIR=arm
--else
-- ARCH_DIR=x86
--endif
-+ LIBS+=$(AVUTIL_SO) \
-+ $(AVCODEC_SO) \
-+ $(AVFORMAT_SO) \
-+ $(POSTPROC_SO) \
-+ $(AVFILTER_SO) \
-+ $(SWSCALE_SO) \
-+ $(SWRESAMPLE_SO)
- endif
-
- .PHONY: $(DIRS) codecs
-
--codecs: $(addprefix $(SYSDIR)/, $(LIBS));
--
--
--ifeq ($(findstring osx,$(ARCH)), osx)
--# Add -lbundle1.o for powerpc-osx
--ifeq ($(ARCH), powerpc-osx)
--BUNDLE1_O = -lbundle1.o
--endif
--
--$(SYSDIR)/avutil-50-$(ARCH).so: $(WRAPPER) ffmpeg/libavutil/libavutil.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavutil/*.o \
-- ffmpeg/libavutil/$(ARCH_DIR)/*.o $(BUNDLE1_O)
--
--$(SYSDIR)/avcodec-52-$(ARCH).so: $(WRAPPER) ffmpeg/libavcodec/libavcodec.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavcodec/*.o \
-- ffmpeg/libavcodec/$(ARCH_DIR)/*.o $(BUNDLE1_O)
--
--$(SYSDIR)/avcore-0-$(ARCH).so: $(WRAPPER) ffmpeg/libavcore/libavcore.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavcore/*.o $(BUNDLE1_O)
--
--$(SYSDIR)/avformat-52-$(ARCH).so: $(WRAPPER) ffmpeg/libavformat/libavformat.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavformat/*.o $(BUNDLE1_O)
--
--ifeq ($(findstring x86,$(ARCH_DIR)), x86)
--$(SYSDIR)/avfilter-1-$(ARCH).so: $(WRAPPER) ffmpeg/libavfilter/libavfilter.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavfilter/$(ARCH_DIR)/*.o \
-- ffmpeg/libavfilter/*.o $(BUNDLE1_O)
--else # No libavfilter/ppc or libavfilter/arm
--$(SYSDIR)/avfilter-1-$(ARCH).so: $(WRAPPER) ffmpeg/libavfilter/libavfilter.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavfilter/*.o $(BUNDLE1_O)
--endif
-+ifneq ($(findstring osx,$(ARCH)), osx)
-
--ifneq ($(findstring arm,$(ARCH)), arm)
--$(SYSDIR)/swscale-0-$(ARCH).so: $(WRAPPER) ffmpeg/libswscale/libswscale.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libswscale/*.o \
-- ffmpeg/libswscale/$(ARCH_DIR)/*.o $(BUNDLE1_O)
--else # No ARM version of swscale available yet.
--$(SYSDIR)/swscale-0-$(ARCH).so: $(WRAPPER) ffmpeg/libswscale/libswscale.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libswscale/*.o
--endif
--
--$(SYSDIR)/postproc-51-$(ARCH).so: $(WRAPPER) ffmpeg/libpostproc/libpostproc.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libpostproc/*.o $(BUNDLE1_O)
--
--ffmpeg/libavutil/libavutil.dylib : ffmpeg;
--ffmpeg/libavcodec/libavcodec.dylib : ffmpeg;
--ffmpeg/libavcore/libavcore.dylib : ffmpeg;
--ffmpeg/libavformat/libavformat.dylib : ffmpeg;
--ffmpeg/libavformat/libavfilter.dylib : ffmpeg;
--ffmpeg/libswscale/libswscale.dylib : ffmpeg;
--ffmpeg/libpostproc/libpostproc.dylib : ffmpeg;
--ffmpeg:
-- $(MAKE) -C $@
--
--else
-+codecs: $(addprefix $(SYSDIR)/, $(LIBS));
-
--$(SYSDIR)/avutil-50-$(ARCH).so: ffmpeg/libavutil/libavutil.so
-+$(SYSDIR)/$(AVUTIL_SO): ffmpeg/libavutil/libavutil.so
- cp ffmpeg/libavutil/libavutil.so $@
-
--$(SYSDIR)/avcodec-52-$(ARCH).so: $(WRAPPER) ffmpeg/libavcodec/libavcodec.so
-+$(SYSDIR)/$(AVCODEC_SO): ffmpeg/libavcodec/libavcodec.so
- cp ffmpeg/libavcodec/libavcodec.so $@
-
--$(SYSDIR)/avcore-0-$(ARCH).so: $(WRAPPER) ffmpeg/libavcore/libavcore.so
-- cp ffmpeg/libavcore/libavcore.so $@
--
--$(SYSDIR)/avformat-52-$(ARCH).so: $(WRAPPER) ffmpeg/libavformat/libavformat.so
-+$(SYSDIR)/$(AVFORMAT_SO): ffmpeg/libavformat/libavformat.so
- cp ffmpeg/libavformat/libavformat.so $@
-
--$(SYSDIR)/avfilter-1-$(ARCH).so: $(WRAPPER) ffmpeg/libavfilter/libavfilter.so
-+$(SYSDIR)/$(AVFILTER_SO): ffmpeg/libavfilter/libavfilter.so
- cp ffmpeg/libavfilter/libavfilter.so $@
-
--$(SYSDIR)/swscale-0-$(ARCH).so: $(WRAPPER) ffmpeg/libswscale/libswscale.so
-+$(SYSDIR)/$(SWSCALE_SO): ffmpeg/libswscale/libswscale.so
- cp ffmpeg/libswscale/libswscale.so $@
-
--$(SYSDIR)/postproc-51-$(ARCH).so: $(WRAPPER) ffmpeg/libpostproc/libpostproc.so
-+$(SYSDIR)/$(POSTPROC_SO): ffmpeg/libpostproc/libpostproc.so
- cp ffmpeg/libpostproc/libpostproc.so $@
-
-+$(SYSDIR)/$(SWRESAMPLE_SO): ffmpeg/libswresample/libswresample.so
-+ cp ffmpeg/libswresample/libswresample.so $@
-+
- ffmpeg/libavutil/libavutil.so : ffmpeg;
- ffmpeg/libavcodec/libavcodec.so : ffmpeg;
--ffmpeg/libavcore/libavcore.so : ffmpeg;
- ffmpeg/libavformat/libavformat.so : ffmpeg;
- ffmpeg/libavfilter/libavfilter.so : ffmpeg;
- ffmpeg/libswscale/libswscale.so : ffmpeg;
- ffmpeg/libpostproc/libpostproc.so : ffmpeg;
-+ffmpeg/libswresample/libswresample.so : ffmpeg;
-+endif
-+
- ffmpeg:
- $(MAKE) -C $@
--
-+ifeq ($(findstring osx,$(ARCH)), osx)
-+ $(AR) d ffmpeg/libavcodec/libavcodec.a inverse.o
- endif
-
- clean:
-diff -Naur xbmc-11.0.1/xbmc/cdrip/EncoderFFmpeg.cpp xbmc-11.0.1.patch/xbmc/cdrip/EncoderFFmpeg.cpp
---- xbmc-11.0.1/xbmc/cdrip/EncoderFFmpeg.cpp 2012-03-21 23:57:32.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cdrip/EncoderFFmpeg.cpp 2012-06-05 15:19:23.881494992 +0200
-@@ -59,11 +59,7 @@
-
- CStdString filename = URIUtils::GetFileName(strFile);
- AVOutputFormat *fmt = NULL;
--#if LIBAVFORMAT_VERSION_MAJOR < 52
-- fmt = m_dllAvFormat.guess_format(NULL, filename.c_str(), NULL);
--#else
- fmt = m_dllAvFormat.av_guess_format(NULL, filename.c_str(), NULL);
--#endif
- if (!fmt)
- {
- CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Unable to guess the output format for the file %s", filename.c_str());
-@@ -82,7 +78,7 @@
- }
-
- m_Format = m_dllAvFormat.avformat_alloc_context();
-- m_Format->pb = m_dllAvFormat.av_alloc_put_byte(m_BCBuffer, sizeof(m_BCBuffer), URL_RDONLY, this, NULL, MuxerReadPacket, NULL);
-+ m_Format->pb = m_dllAvFormat.avio_alloc_context(m_BCBuffer, sizeof(m_BCBuffer), AVIO_FLAG_READ, this, NULL, MuxerReadPacket, NULL);
- if (!m_Format->pb)
- {
- m_dllAvUtil.av_freep(&m_Format);
-@@ -93,17 +89,8 @@
- m_Format->oformat = fmt;
- m_Format->bit_rate = g_guiSettings.GetInt("audiocds.bitrate") * 1000;
-
-- /* setup the muxer */
-- if (m_dllAvFormat.av_set_parameters(m_Format, NULL) != 0)
-- {
-- m_dllAvUtil.av_freep(&m_Format->pb);
-- m_dllAvUtil.av_freep(&m_Format);
-- CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to set the muxer parameters");
-- return false;
-- }
--
- /* add a stream to it */
-- m_Stream = m_dllAvFormat.av_new_stream(m_Format, 1);
-+ m_Stream = m_dllAvFormat.avformat_new_stream(m_Format, codec);
- if (!m_Stream)
- {
- m_dllAvUtil.av_freep(&m_Format->pb);
-@@ -144,7 +131,7 @@
- return false;
- }
-
-- if (m_dllAvCodec.avcodec_open(m_CodecCtx, codec))
-+ if (m_dllAvCodec.avcodec_open2(m_CodecCtx, codec, NULL))
- {
- CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to open the codec");
- m_dllAvUtil.av_freep(&m_Stream);
-@@ -179,7 +166,7 @@
- SetTag("encoder" , "XBMC FFmpeg Encoder");
-
- /* write the header */
-- if (m_dllAvFormat.av_write_header(m_Format) != 0)
-+ if (m_dllAvFormat.avformat_write_header(m_Format, NULL) != 0)
- {
- CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to write the header");
- delete[] m_Buffer;
-@@ -194,7 +181,7 @@
-
- void CEncoderFFmpeg::SetTag(const CStdString tag, const CStdString value)
- {
-- m_dllAvFormat.av_metadata_set2(&m_Format->metadata, tag.c_str(), value.c_str(), 0);
-+ m_dllAvUtil.av_dict_set(&m_Format->metadata, tag.c_str(), value.c_str(), 0);
- }
-
- int CEncoderFFmpeg::MuxerReadPacket(void *opaque, uint8_t *buf, int buf_size)
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp 2012-06-05 15:19:23.882495012 +0200
-@@ -29,10 +29,6 @@
-
- CDVDAudioCodecFFmpeg::CDVDAudioCodecFFmpeg() : CDVDAudioCodec()
- {
-- m_iBufferSize1 = 0;
-- m_pBuffer1 = (BYTE*)_aligned_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE, 16);
-- memset(m_pBuffer1, 0, AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
--
- m_iBufferSize2 = 0;
- m_pBuffer2 = (BYTE*)_aligned_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE, 16);
- memset(m_pBuffer2, 0, AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
-@@ -45,11 +41,11 @@
- m_channelMap[0] = PCM_INVALID;
- m_channels = 0;
- m_layout = 0;
-+ m_pFrame1 = NULL;
- }
-
- CDVDAudioCodecFFmpeg::~CDVDAudioCodecFFmpeg()
- {
-- _aligned_free(m_pBuffer1);
- _aligned_free(m_pBuffer2);
- Dispose();
- }
-@@ -59,12 +55,10 @@
- AVCodec* pCodec;
- m_bOpenedCodec = false;
-
-- if (!m_dllAvCore.Load() || !m_dllAvUtil.Load() || !m_dllAvCodec.Load())
-+ if (!m_dllAvUtil.Load() || !m_dllAvCodec.Load())
- return false;
-
- m_dllAvCodec.avcodec_register_all();
-- m_pCodecContext = m_dllAvCodec.avcodec_alloc_context();
-- m_dllAvCodec.avcodec_get_context_defaults(m_pCodecContext);
-
- pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec);
- if (!pCodec)
-@@ -73,6 +67,7 @@
- return false;
- }
-
-+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
- m_pCodecContext->debug_mv = 0;
- m_pCodecContext->debug = 0;
- m_pCodecContext->workaround_bugs = 1;
-@@ -97,13 +92,14 @@
- memcpy(m_pCodecContext->extradata, hints.extradata, hints.extrasize);
- }
-
-- if (m_dllAvCodec.avcodec_open(m_pCodecContext, pCodec) < 0)
-+ if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0)
- {
- CLog::Log(LOGDEBUG,"CDVDAudioCodecFFmpeg::Open() Unable to open codec");
- Dispose();
- return false;
- }
-
-+ m_pFrame1 = m_dllAvCodec.avcodec_alloc_frame();
- m_bOpenedCodec = true;
- m_iSampleFormat = AV_SAMPLE_FMT_NONE;
- return true;
-@@ -111,6 +107,9 @@
-
- void CDVDAudioCodecFFmpeg::Dispose()
- {
-+ if (m_pFrame1) m_dllAvUtil.av_free(m_pFrame1);
-+ m_pFrame1 = NULL;
-+
- if (m_pConvert)
- {
- m_dllAvCodec.av_audio_convert_free(m_pConvert);
-@@ -135,7 +134,7 @@
-
- int CDVDAudioCodecFFmpeg::Decode(BYTE* pData, int iSize)
- {
-- int iBytesUsed;
-+ int iBytesUsed, got_frame;
- if (!m_pCodecContext) return -1;
-
- m_iBufferSize1 = AVCODEC_MAX_AUDIO_FRAME_SIZE ;
-@@ -145,10 +144,17 @@
- m_dllAvCodec.av_init_packet(&avpkt);
- avpkt.data = pData;
- avpkt.size = iSize;
-- iBytesUsed = m_dllAvCodec.avcodec_decode_audio3( m_pCodecContext
-- , (int16_t*)m_pBuffer1
-- , &m_iBufferSize1
-+ iBytesUsed = m_dllAvCodec.avcodec_decode_audio4( m_pCodecContext
-+ , m_pFrame1
-+ , &got_frame
- , &avpkt);
-+ if (iBytesUsed < 0 || !got_frame)
-+ {
-+ m_iBufferSize1 = 0;
-+ m_iBufferSize2 = 0;
-+ return iBytesUsed;
-+ }
-+ m_iBufferSize1 = m_dllAvUtil.av_samples_get_buffer_size(NULL, m_pCodecContext->channels, m_pFrame1->nb_samples, m_pCodecContext->sample_fmt, 1);
-
- /* some codecs will attempt to consume more data than what we gave */
- if (iBytesUsed > iSize)
-@@ -184,9 +190,9 @@
- return iBytesUsed;
- }
-
-- const void *ibuf[6] = { m_pBuffer1 };
-+ const void *ibuf[6] = { m_pFrame1->data[0] };
- void *obuf[6] = { m_pBuffer2 };
-- int istr[6] = { m_dllAvCore.av_get_bits_per_sample_fmt(m_pCodecContext->sample_fmt)/8 };
-+ int istr[6] = { m_dllAvUtil.av_get_bytes_per_sample(m_pCodecContext->sample_fmt) };
- int ostr[6] = { 2 };
- int len = m_iBufferSize1 / istr[0];
- if(m_dllAvCodec.av_audio_convert(m_pConvert, obuf, ostr, ibuf, istr, len) < 0)
-@@ -208,7 +214,7 @@
- {
- if(m_iBufferSize1)
- {
-- *dst = m_pBuffer1;
-+ *dst = m_pFrame1->data[0];
- return m_iBufferSize1;
- }
- if(m_iBufferSize2)
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h 2012-06-05 15:19:23.882495012 +0200
-@@ -23,7 +23,6 @@
-
- #include "DVDAudioCodec.h"
- #include "DllAvCodec.h"
--#include "DllAvCore.h"
- #include "DllAvFormat.h"
- #include "DllAvUtil.h"
-
-@@ -51,7 +50,7 @@
- enum AVSampleFormat m_iSampleFormat;
- enum PCMChannels m_channelMap[PCM_MAX_CH + 1];
-
-- BYTE *m_pBuffer1;
-+ AVFrame* m_pFrame1;
- int m_iBufferSize1;
-
- BYTE *m_pBuffer2;
-@@ -64,7 +63,6 @@
- int64_t m_layout;
-
- DllAvCodec m_dllAvCodec;
-- DllAvCore m_dllAvCore;
- DllAvUtil m_dllAvUtil;
-
- void BuildChannelMap();
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp 2012-06-05 15:19:23.883495032 +0200
-@@ -79,11 +79,7 @@
- /* get the muxer */
- AVOutputFormat *fOut = NULL;
-
--#if LIBAVFORMAT_VERSION_MAJOR < 52
-- fOut = m_dllAvFormat.guess_format(muxerName.c_str(), NULL, NULL);
--#else
- fOut = m_dllAvFormat.av_guess_format(muxerName.c_str(), NULL, NULL);
--#endif
- if (!fOut)
- {
- CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Failed to get the FFmpeg %s muxer", muxerName.c_str());
-@@ -103,7 +99,7 @@
- muxer.m_pFormat->oformat = fOut;
-
- /* allocate a put_byte struct so we can grab the output */
-- muxer.m_pFormat->pb = m_dllAvFormat.av_alloc_put_byte(muxer.m_BCBuffer, sizeof(muxer.m_BCBuffer), URL_RDONLY, &muxer, NULL, MuxerReadPacket, NULL);
-+ muxer.m_pFormat->pb = m_dllAvFormat.avio_alloc_context(muxer.m_BCBuffer, sizeof(muxer.m_BCBuffer), AVIO_FLAG_READ, &muxer, NULL, MuxerReadPacket, NULL);
- if (!muxer.m_pFormat->pb)
- {
- CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Failed to allocate ByteIOContext");
-@@ -112,21 +108,10 @@
- }
-
- /* this is streamed, no file, and ignore the index */
-- muxer.m_pFormat->pb->is_streamed = 1;
-+ muxer.m_pFormat->pb->seekable = 0;
- muxer.m_pFormat->flags |= AVFMT_NOFILE | AVFMT_FLAG_IGNIDX;
- muxer.m_pFormat->bit_rate = hints.bitrate;
-
-- /* setup the muxer */
-- if (m_dllAvFormat.av_set_parameters(muxer.m_pFormat, NULL) != 0)
-- {
-- CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Failed to set the %s muxer parameters", muxerName.c_str());
-- Dispose();
-- return false;
-- }
--
--#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,92,0)
-- // API added on: 2011-01-02
--
- /* While this is strictly only needed on big-endian systems, we do it on
- * both to avoid as much dead code as possible.
- * CoreAudio (at least on the cases we've seen) wants IEC 61937 in
-@@ -138,8 +123,7 @@
- #endif
-
- /* request output of wanted endianness */
-- if (!fOut->priv_class || m_dllAvUtil.av_set_string3(muxer.m_pFormat->priv_data, "spdif_flags", spdifFlags, 0, NULL) != 0)
--#endif
-+ if (!fOut->priv_class || m_dllAvUtil.av_opt_set(muxer.m_pFormat->priv_data, "spdif_flags", spdifFlags, 0) != 0)
- {
- #if defined(WORDS_BIGENDIAN) && !defined(__APPLE__)
- CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Unable to set big-endian stream mode (FFmpeg too old?), disabling passthrough");
-@@ -149,7 +133,7 @@
- }
-
- /* add a stream to it */
-- muxer.m_pStream = m_dllAvFormat.av_new_stream(muxer.m_pFormat, 1);
-+ muxer.m_pStream = m_dllAvFormat.avformat_new_stream(muxer.m_pFormat, NULL);
- if (!muxer.m_pStream)
- {
- CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Failed to allocate AVStream context");
-@@ -159,8 +143,6 @@
-
-
- /* set the stream's parameters */
-- muxer.m_pStream->stream_copy = 1;
--
- m_SampleRate = hints.samplerate;
- if(!m_SampleRate && hints.codec == CODEC_ID_AC3)
- m_SampleRate = 48000;
-@@ -176,7 +158,7 @@
- codec->extradata_size = hints.extrasize;
- memcpy(codec->extradata, hints.extradata, hints.extrasize);
-
-- muxer.m_WroteHeader = m_dllAvFormat.av_write_header(muxer.m_pFormat) == 0;
-+ muxer.m_WroteHeader = m_dllAvFormat.avformat_write_header(muxer.m_pFormat, NULL) == 0;
- if (!muxer.m_WroteHeader)
- {
- CLog::Log(LOGERROR, "CDVDAudioCodecPassthrough::SetupMuxer - Failed to write the frame header");
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp 2012-06-05 15:19:23.943496230 +0200
-@@ -55,7 +55,7 @@
- bool CDVDAudioEncoderFFmpeg::Initialize(unsigned int channels, enum PCMChannels *channelMap, unsigned int bitsPerSample, unsigned int sampleRate)
- {
- Reset();
-- if (!channelMap || !m_dllAvUtil.Load() || !m_dllAvCore.Load() || !m_dllAvCodec.Load())
-+ if (!channelMap || !m_dllAvUtil.Load() || !m_dllAvCodec.Load())
- return false;
-
- m_dllAvCodec.avcodec_register_all();
-@@ -65,7 +65,7 @@
- return false;
-
- /* always assume 6 channels, 5.1... m_remap will give us what we want */
-- m_CodecCtx = m_dllAvCodec.avcodec_alloc_context();
-+ m_CodecCtx = m_dllAvCodec.avcodec_alloc_context3(codec);
- m_CodecCtx->bit_rate = AC3_ENCODE_BITRATE;
- m_CodecCtx->sample_rate = sampleRate;
- m_CodecCtx->channels = 6;
-@@ -104,7 +104,7 @@
- }
- }
-
-- if (m_dllAvCodec.avcodec_open(m_CodecCtx, codec))
-+ if (m_dllAvCodec.avcodec_open2(m_CodecCtx, codec, NULL))
- {
- m_dllAvUtil.av_freep(&m_CodecCtx);
- return false;
-@@ -149,7 +149,7 @@
-
- if (m_AudioConvert)
- m_TmpBuffer2 = new uint8_t[m_NeededFrames * m_CodecCtx->channels *
-- m_dllAvCore.av_get_bits_per_sample_fmt(m_CodecCtx->sample_fmt) / 8];
-+ m_dllAvUtil.av_get_bytes_per_sample(m_CodecCtx->sample_fmt)];
-
- return true;
- }
-@@ -186,7 +186,7 @@
- void *convInBuf[] = { m_TmpBuffer };
- int convInStr[] = { m_BitsPerSample / 8 };
- void *convOutBuf[] = { m_TmpBuffer2 };
-- int convOutStr[] = { m_dllAvCore.av_get_bits_per_sample_fmt(m_CodecCtx->sample_fmt) / 8 };
-+ int convOutStr[] = { m_dllAvUtil.av_get_bytes_per_sample(m_CodecCtx->sample_fmt) };
- if (m_dllAvCodec.av_audio_convert(m_AudioConvert, convOutBuf, convOutStr,
- convInBuf, convInStr, m_NeededFrames * m_CodecCtx->channels) < 0) {
- CLog::Log(LOGERROR, "CDVDAudioEncoderFFmpeg: Audio conversion failed");
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.h xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.h
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.h 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.h 2012-06-05 15:19:23.944496250 +0200
-@@ -43,7 +43,6 @@
- virtual int GetData(uint8_t **data);
- private:
- DllAvCodec m_dllAvCodec;
-- DllAvCore m_dllAvCore;
- DllAvUtil m_dllAvUtil;
-
- AVCodecContext *m_CodecCtx;
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp 2012-06-05 15:19:23.944496250 +0200
-@@ -49,7 +49,14 @@
-
- m_dllAvCodec.avcodec_register_all();
-
-- m_pCodecContext = m_dllAvCodec.avcodec_alloc_context();
-+ AVCodec* pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec);
-+ if (!pCodec)
-+ {
-+ CLog::Log(LOGDEBUG,"%s - Unable to find codec %d", __FUNCTION__, hints.codec);
-+ return false;
-+ }
-+
-+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
- m_pCodecContext->debug_mv = 0;
- m_pCodecContext->debug = 0;
- m_pCodecContext->workaround_bugs = FF_BUG_AUTODETECT;
-@@ -100,14 +107,7 @@
- delete[] parse_extra;
- }
-
-- AVCodec* pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec);
-- if (!pCodec)
-- {
-- CLog::Log(LOGDEBUG,"%s - Unable to find codec %d", __FUNCTION__, hints.codec);
-- return false;
-- }
--
-- if (m_dllAvCodec.avcodec_open(m_pCodecContext, pCodec) < 0)
-+ if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0)
- {
- CLog::Log(LOGDEBUG,"CDVDVideoCodecFFmpeg::Open() Unable to open codec");
- return false;
-@@ -134,19 +134,12 @@
- {
- for(unsigned i=0;i= (52<<10)
- if(sub.rects[i])
- {
- m_dllAvUtil.av_free(sub.rects[i]->pict.data[0]);
- m_dllAvUtil.av_free(sub.rects[i]->pict.data[1]);
- m_dllAvUtil.av_freep(&sub.rects[i]);
- }
--#else
-- if(sub.rects[i].bitmap)
-- m_dllAvUtil.av_freep(&sub.rects[i].bitmap);
-- if(m_Subtitle.rects[i].rgba_palette)
-- m_dllAvUtil.av_freep(&sub.rects[i].rgba_palette);
--#endif
- }
- if(sub.rects)
- m_dllAvUtil.av_freep(&sub.rects);
-@@ -294,7 +287,6 @@
- overlay->source_width = m_width;
- overlay->source_height = m_height;
-
--#if LIBAVCODEC_VERSION_INT >= (52<<10)
- BYTE* s = rect.pict.data[0];
- BYTE* t = overlay->data;
- for(int i=0;idata;
-- for(int i=0;ilinesize;
-- }
--
-- memcpy(overlay->palette, rect.rgba_palette, rect.nb_colors*4);
--
-- m_dllAvUtil.av_freep(&rect.bitmap);
-- m_dllAvUtil.av_freep(&rect.rgba_palette);
--#endif
- m_SubtitleIndex++;
-
- return overlay;
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp 2012-06-05 15:19:23.946496292 +0200
-@@ -123,12 +123,11 @@
- CDVDVideoCodecFFmpeg::CDVDVideoCodecFFmpeg() : CDVDVideoCodec()
- {
- m_pCodecContext = NULL;
-- m_pConvertFrame = NULL;
- m_pFrame = NULL;
- m_pFilterGraph = NULL;
- m_pFilterIn = NULL;
- m_pFilterOut = NULL;
-- m_pFilterLink = NULL;
-+ m_pBufferRef = NULL;
-
- m_iPictureWidth = 0;
- m_iPictureHeight = 0;
-@@ -163,9 +162,13 @@
- m_dllAvFilter.avfilter_register_all();
-
- m_bSoftware = hints.software;
-- m_pCodecContext = m_dllAvCodec.avcodec_alloc_context();
-+
-+ m_formats.push_back(PIX_FMT_YUV420P);
-+ m_formats.push_back(PIX_FMT_YUVJ420P);
-+ m_formats.push_back(PIX_FMT_NONE); /* always add none to get a terminated list in ffmpeg world */
-
- pCodec = NULL;
-+ m_pCodecContext = NULL;
-
- if (hints.codec == CODEC_ID_H264)
- {
-@@ -196,6 +199,7 @@
-
- CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Creating VDPAU(%ix%i, %d)",hints.width, hints.height, hints.codec);
- CVDPAU* vdp = new CVDPAU();
-+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
- m_pCodecContext->codec_id = hints.codec;
- m_pCodecContext->width = hints.width;
- m_pCodecContext->height = hints.height;
-@@ -207,7 +211,7 @@
- m_pCodecContext->codec_id = CODEC_ID_NONE; // ffmpeg will complain if this has been set
- break;
- }
-- m_pCodecContext->codec_id = CODEC_ID_NONE; // ffmpeg will complain if this has been set
-+ m_dllAvUtil.av_freep(&m_pCodecContext);
- CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Failed to get VDPAU device");
- vdp->Release();
- }
-@@ -226,21 +230,26 @@
-
- CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Using codec: %s",pCodec->long_name ? pCodec->long_name : pCodec->name);
-
-+ if(m_pCodecContext == NULL)
-+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
-+
- m_pCodecContext->opaque = (void*)this;
- m_pCodecContext->debug_mv = 0;
- m_pCodecContext->debug = 0;
- m_pCodecContext->workaround_bugs = FF_BUG_AUTODETECT;
- m_pCodecContext->get_format = GetFormat;
- m_pCodecContext->codec_tag = hints.codec_tag;
-+ /* Only allow slice threading, since frame threading is more
-+ * sensitive to changes in frame sizes, and it causes crashes
-+ * during HW accell */
-+ m_pCodecContext->thread_type = FF_THREAD_SLICE;
-
- #if defined(__APPLE__) && defined(__arm__)
- // ffmpeg with enabled neon will crash and burn if this is enabled
- m_pCodecContext->flags &= CODEC_FLAG_EMU_EDGE;
- #else
- if (pCodec->id != CODEC_ID_H264 && pCodec->capabilities & CODEC_CAP_DR1
--#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,69,0)
- && pCodec->id != CODEC_ID_VP8
--#endif
- )
- m_pCodecContext->flags |= CODEC_FLAG_EMU_EDGE;
- #endif
-@@ -272,16 +281,16 @@
- if (it->m_name == "surfaces")
- m_uSurfacesCount = std::atoi(it->m_value.c_str());
- else
-- m_dllAvUtil.av_set_string3(m_pCodecContext, it->m_name.c_str(), it->m_value.c_str(), 0, NULL);
-+ m_dllAvUtil.av_opt_set(m_pCodecContext, it->m_name.c_str(), it->m_value.c_str(), 0);
- }
-
- int num_threads = std::min(8 /*MAX_THREADS*/, g_cpuInfo.getCPUCount());
- if( num_threads > 1 && !hints.software && m_pHardware == NULL // thumbnail extraction fails when run threaded
- && ( pCodec->id == CODEC_ID_H264
- || pCodec->id == CODEC_ID_MPEG4 ))
-- m_dllAvCodec.avcodec_thread_init(m_pCodecContext, num_threads);
-+ m_pCodecContext->thread_count = num_threads;
-
-- if (m_dllAvCodec.avcodec_open(m_pCodecContext, pCodec) < 0)
-+ if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0)
- {
- CLog::Log(LOGDEBUG,"CDVDVideoCodecFFmpeg::Open() Unable to open codec");
- return false;
-@@ -290,14 +299,7 @@
- m_pFrame = m_dllAvCodec.avcodec_alloc_frame();
- if (!m_pFrame) return false;
-
-- if(pCodec->name)
-- m_name = CStdString("ff-") + pCodec->name;
-- else
-- m_name = "ffmpeg";
--
-- if(m_pHardware)
-- m_name += "-" + m_pHardware->Name();
--
-+ UpdateName();
- return true;
- }
-
-@@ -306,13 +308,6 @@
- if (m_pFrame) m_dllAvUtil.av_free(m_pFrame);
- m_pFrame = NULL;
-
-- if (m_pConvertFrame)
-- {
-- m_dllAvCodec.avpicture_free(m_pConvertFrame);
-- m_dllAvUtil.av_free(m_pConvertFrame);
-- }
-- m_pConvertFrame = NULL;
--
- if (m_pCodecContext)
- {
- if (m_pCodecContext->codec) m_dllAvCodec.avcodec_close(m_pCodecContext);
-@@ -458,9 +453,6 @@
- return VC_ERROR;
- }
-
-- if (len != iSize && m_pCodecContext->skip_frame != AVDISCARD_NONREF)
-- CLog::Log(LOGWARNING, "%s - avcodec_decode_video didn't consume the full packet. size: %d, consumed: %d", __FUNCTION__, iSize, len);
--
- if (!iGotPicture)
- return VC_BUFFER;
-
-@@ -478,67 +470,32 @@
- if(m_pCodecContext->codec_id == CODEC_ID_H264)
- m_started = true;
-
-- if(m_pCodecContext->pix_fmt != PIX_FMT_YUV420P
-- && m_pCodecContext->pix_fmt != PIX_FMT_YUVJ420P
-- && m_pHardware == NULL)
-- {
-- if (!m_dllSwScale.IsLoaded() && !m_dllSwScale.Load())
-- return VC_ERROR;
--
-- if (!m_pConvertFrame)
-- {
-- // Allocate an AVFrame structure
-- m_pConvertFrame = (AVPicture*)m_dllAvUtil.av_mallocz(sizeof(AVPicture));
-- // Due to a bug in swsscale we need to allocate one extra line of data
-- if(m_dllAvCodec.avpicture_alloc( m_pConvertFrame
-- , PIX_FMT_YUV420P
-- , m_pCodecContext->width
-- , m_pCodecContext->height+1) < 0)
-- {
-- m_dllAvUtil.av_free(m_pConvertFrame);
-- m_pConvertFrame = NULL;
-- return VC_ERROR;
-- }
-- }
-+ if(m_pHardware == NULL)
-+ {
-+ bool need_scale = std::find( m_formats.begin()
-+ , m_formats.end()
-+ , m_pCodecContext->pix_fmt) == m_formats.end();
-
-- // convert the picture
-- struct SwsContext *context = m_dllSwScale.sws_getContext(m_pCodecContext->width, m_pCodecContext->height,
-- m_pCodecContext->pix_fmt, m_pCodecContext->width, m_pCodecContext->height,
-- PIX_FMT_YUV420P, SWS_FAST_BILINEAR | SwScaleCPUFlags(), NULL, NULL, NULL);
-+ bool need_reopen = false;
-+ if(!m_filters.Equals(m_filters_next))
-+ need_reopen = true;
-
-- if(context == NULL)
-+ if(m_pFilterIn)
- {
-- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::Decode - unable to obtain sws context for w:%i, h:%i, pixfmt: %i", m_pCodecContext->width, m_pCodecContext->height, m_pCodecContext->pix_fmt);
-- return VC_ERROR;
-+ if(m_pFilterIn->outputs[0]->format != m_pCodecContext->pix_fmt
-+ || m_pFilterIn->outputs[0]->w != m_pCodecContext->width
-+ || m_pFilterIn->outputs[0]->h != m_pCodecContext->height)
-+ need_reopen = true;
- }
-
-- m_dllSwScale.sws_scale(context
-- , m_pFrame->data
-- , m_pFrame->linesize
-- , 0
-- , m_pCodecContext->height
-- , m_pConvertFrame->data
-- , m_pConvertFrame->linesize);
--
-- m_dllSwScale.sws_freeContext(context);
-- }
-- else
-- {
-- // no need to convert, just free any existing convert buffers
-- if (m_pConvertFrame)
-+ // try to setup new filters
-+ if (need_reopen || (need_scale && m_pFilterGraph == NULL))
- {
-- m_dllAvCodec.avpicture_free(m_pConvertFrame);
-- m_dllAvUtil.av_free(m_pConvertFrame);
-- m_pConvertFrame = NULL;
-- }
-- }
-+ m_filters = m_filters_next;
-
-- // try to setup new filters
-- if (!m_filters.Equals(m_filters_next))
-- {
-- m_filters = m_filters_next;
-- if(FilterOpen(m_filters) < 0)
-- FilterClose();
-+ if(FilterOpen(m_filters, need_scale) < 0)
-+ FilterClose();
-+ }
- }
-
- int result;
-@@ -564,12 +521,6 @@
- if (m_pHardware)
- m_pHardware->Reset();
-
-- if (m_pConvertFrame)
-- {
-- m_dllAvCodec.avpicture_free(m_pConvertFrame);
-- m_dllAvUtil.av_free(m_pConvertFrame);
-- m_pConvertFrame = NULL;
-- }
- m_filters = "";
- FilterClose();
- }
-@@ -579,10 +530,10 @@
- pDvdVideoPicture->iWidth = m_pCodecContext->width;
- pDvdVideoPicture->iHeight = m_pCodecContext->height;
-
-- if(m_pFilterLink)
-+ if(m_pBufferRef)
- {
-- pDvdVideoPicture->iWidth = m_pFilterLink->cur_buf->video->w;
-- pDvdVideoPicture->iHeight = m_pFilterLink->cur_buf->video->h;
-+ pDvdVideoPicture->iWidth = m_pBufferRef->video->w;
-+ pDvdVideoPicture->iHeight = m_pBufferRef->video->h;
- }
-
- /* crop of 10 pixels if demuxer asked it */
-@@ -598,12 +549,8 @@
-
- /* use variable in the frame */
- AVRational pixel_aspect = m_pCodecContext->sample_aspect_ratio;
-- if (m_pFilterLink)
--#ifdef HAVE_AVFILTERBUFFERREFVIDEOPROPS_SAMPLE_ASPECT_RATIO
-- pixel_aspect = m_pFilterLink->cur_buf->video->sample_aspect_ratio;
--#else
-- pixel_aspect = m_pFilterLink->cur_buf->video->pixel_aspect;
--#endif
-+ if (m_pBufferRef)
-+ pixel_aspect = m_pBufferRef->video->sample_aspect_ratio;
-
- if (pixel_aspect.num == 0)
- aspect_ratio = 0;
-@@ -632,8 +579,6 @@
- pDvdVideoPicture->iFlags = DVP_FLAG_ALLOCATED;
- pDvdVideoPicture->iFlags |= m_pFrame->interlaced_frame ? DVP_FLAG_INTERLACED : 0;
- pDvdVideoPicture->iFlags |= m_pFrame->top_field_first ? DVP_FLAG_TOP_FIELD_FIRST: 0;
-- if(m_pCodecContext->pix_fmt == PIX_FMT_YUVJ420P)
-- pDvdVideoPicture->color_range = 1;
-
- pDvdVideoPicture->chroma_position = m_pCodecContext->chroma_sample_location;
- pDvdVideoPicture->color_primaries = m_pCodecContext->color_primaries;
-@@ -677,14 +622,6 @@
- if(!GetPictureCommon(pDvdVideoPicture))
- return false;
-
-- if(m_pConvertFrame)
-- {
-- for (int i = 0; i < 4; i++)
-- pDvdVideoPicture->data[i] = m_pConvertFrame->data[i];
-- for (int i = 0; i < 4; i++)
-- pDvdVideoPicture->iLineSize[i] = m_pConvertFrame->linesize[i];
-- }
-- else
- {
- for (int i = 0; i < 4; i++)
- pDvdVideoPicture->data[i] = m_pFrame->data[i];
-@@ -693,20 +630,38 @@
- }
-
- pDvdVideoPicture->iFlags |= pDvdVideoPicture->data[0] ? 0 : DVP_FLAG_DROPPED;
-- pDvdVideoPicture->format = DVDVideoPicture::FMT_YUV420P;
- pDvdVideoPicture->extended_format = 0;
-+ pDvdVideoPicture->color_range = 0;
-+
-+ PixelFormat pix_fmt;
-+ if(m_pBufferRef)
-+ pix_fmt = (PixelFormat)m_pBufferRef->format;
-+ else
-+ pix_fmt = m_pCodecContext->pix_fmt;
-+
-+ switch(pix_fmt)
-+ {
-+ case PIX_FMT_YUVJ420P:
-+ pDvdVideoPicture->format = DVDVideoPicture::FMT_YUV420P;
-+ pDvdVideoPicture->color_range = 1;
-+ break;
-+ default:
-+ pDvdVideoPicture->format = DVDVideoPicture::FMT_YUV420P;
-+ break;
-+ }
-
- return true;
- }
-
--int CDVDVideoCodecFFmpeg::FilterOpen(const CStdString& filters)
-+int CDVDVideoCodecFFmpeg::FilterOpen(const CStdString& filters, bool scale)
- {
- int result;
-+ AVBufferSinkParams *buffersink_params;
-
- if (m_pFilterGraph)
- FilterClose();
-
-- if (filters.IsEmpty())
-+ if (filters.IsEmpty() && !scale)
- return 0;
-
- if (!(m_pFilterGraph = m_dllAvFilter.avfilter_graph_alloc()))
-@@ -715,17 +670,8 @@
- return -1;
- }
-
-- // CrHasher HACK (if an alternative becomes available use it!): In order to display the output
-- // produced by a combination of filters we insert "nullsink" as the last filter and we use
-- // its input pin as our output pin.
-- //
-- // input --> .. --> last_filter --> [in] nullsink [null] [in] --> output
-- // | |
-- // | |
-- // +------------------------+
-- //
- AVFilter* srcFilter = m_dllAvFilter.avfilter_get_by_name("buffer");
-- AVFilter* outFilter = m_dllAvFilter.avfilter_get_by_name("nullsink"); // should be last filter in the graph for now
-+ AVFilter* outFilter = m_dllAvFilter.avfilter_get_by_name("buffersink"); // should be last filter in the graph for now
-
- CStdString args;
-
-@@ -744,11 +690,19 @@
- return result;
- }
-
-- if ((result = m_dllAvFilter.avfilter_graph_create_filter(&m_pFilterOut, outFilter, "out", NULL, NULL/*nullsink=>NULL*/, m_pFilterGraph)) < 0)
-+ buffersink_params = m_dllAvFilter.av_buffersink_params_alloc();
-+ buffersink_params->pixel_fmts = &m_formats[0];
-+#ifdef FF_API_OLD_VSINK_API
-+ if ((result = m_dllAvFilter.avfilter_graph_create_filter(&m_pFilterOut, outFilter, "out", NULL, (void*)buffersink_params->pixel_fmts, m_pFilterGraph)) < 0)
-+#else
-+ if ((result = m_dllAvFilter.avfilter_graph_create_filter(&m_pFilterOut, outFilter, "out", NULL, buffersink_params, m_pFilterGraph)) < 0)
-+#endif
- {
-+ m_dllAvUtil.av_freep(&buffersink_params);
- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterOpen - avfilter_graph_create_filter: out");
- return result;
- }
-+ m_dllAvUtil.av_freep(&buffersink_params);
-
- if (!filters.empty())
- {
-@@ -794,6 +748,12 @@
-
- void CDVDVideoCodecFFmpeg::FilterClose()
- {
-+ if(m_pBufferRef)
-+ {
-+ m_dllAvFilter.avfilter_unref_buffer(m_pBufferRef);
-+ m_pBufferRef = NULL;
-+ }
-+
- if (m_pFilterGraph)
- {
- m_dllAvFilter.avfilter_graph_free(&m_pFilterGraph);
-@@ -801,7 +761,6 @@
- // Disposed by above code
- m_pFilterIn = NULL;
- m_pFilterOut = NULL;
-- m_pFilterLink = NULL;
- }
- }
-
-@@ -809,20 +768,9 @@
- {
- int result, frames;
-
-- m_pFilterLink = m_pFilterOut->inputs[0];
--
- if (frame)
- {
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,13,0)
- result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame, 0);
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,7,0)
-- result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame);
--#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,3,0)
-- result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame, frame->pts);
--#else
-- result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame, frame->pts, m_pCodecContext->sample_aspect_ratio);
--#endif
--
- if (result < 0)
- {
- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - av_vsrc_buffer_add_frame");
-@@ -830,7 +778,13 @@
- }
- }
-
-- if ((frames = m_dllAvFilter.avfilter_poll_frame(m_pFilterLink)) < 0)
-+ if(m_pBufferRef)
-+ {
-+ m_dllAvFilter.avfilter_unref_buffer(m_pBufferRef);
-+ m_pBufferRef = NULL;
-+ }
-+
-+ if ((frames = m_dllAvFilter.av_buffersink_poll_frame(m_pFilterOut)) < 0)
- {
- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - avfilter_poll_frame");
- return VC_ERROR;
-@@ -838,19 +792,9 @@
-
- if (frames > 0)
- {
-- if (m_pFilterLink->cur_buf)
-- {
-- m_dllAvFilter.avfilter_unref_buffer(m_pFilterLink->cur_buf);
-- m_pFilterLink->cur_buf = NULL;
-- }
--
-- if ((result = m_dllAvFilter.avfilter_request_frame(m_pFilterLink)) < 0)
-- {
-- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - avfilter_request_frame");
-- return VC_ERROR;
-- }
-
-- if (!m_pFilterLink->cur_buf)
-+ result = m_dllAvFilter.av_buffersink_get_buffer_ref(m_pFilterOut, &m_pBufferRef, 0);
-+ if(!m_pBufferRef)
- {
- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - cur_buf");
- return VC_ERROR;
-@@ -861,11 +805,11 @@
- else
- m_pFrame->repeat_pict = -(frames - 1);
-
-- m_pFrame->interlaced_frame = m_pFilterLink->cur_buf->video->interlaced;
-- m_pFrame->top_field_first = m_pFilterLink->cur_buf->video->top_field_first;
-+ m_pFrame->interlaced_frame = m_pBufferRef->video->interlaced;
-+ m_pFrame->top_field_first = m_pBufferRef->video->top_field_first;
-
-- memcpy(m_pFrame->linesize, m_pFilterLink->cur_buf->linesize, 4*sizeof(int));
-- memcpy(m_pFrame->data , m_pFilterLink->cur_buf->data , 4*sizeof(uint8_t*));
-+ memcpy(m_pFrame->linesize, m_pBufferRef->linesize, 4*sizeof(int));
-+ memcpy(m_pFrame->data , m_pBufferRef->data , 4*sizeof(uint8_t*));
-
- if(frames > 1)
- return VC_PICTURE;
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h 2012-06-05 15:19:23.946496292 +0200
-@@ -68,27 +68,36 @@
- {
- SAFE_RELEASE(m_pHardware);
- m_pHardware = hardware;
-- m_name += "-";
-- m_name += m_pHardware->Name();
-+ UpdateName();
- }
-
- protected:
- static enum PixelFormat GetFormat(struct AVCodecContext * avctx, const PixelFormat * fmt);
-
-- int FilterOpen(const CStdString& filters);
-+ int FilterOpen(const CStdString& filters, bool scale);
- void FilterClose();
- int FilterProcess(AVFrame* frame);
-
-+ void UpdateName()
-+ {
-+ if(m_pCodecContext->codec->name)
-+ m_name = CStdString("ff-") + m_pCodecContext->codec->name;
-+ else
-+ m_name = "ffmpeg";
-+
-+ if(m_pHardware)
-+ m_name += "-" + m_pHardware->Name();
-+ }
-+
- AVFrame* m_pFrame;
- AVCodecContext* m_pCodecContext;
-
-- AVPicture* m_pConvertFrame;
- CStdString m_filters;
- CStdString m_filters_next;
- AVFilterGraph* m_pFilterGraph;
- AVFilterContext* m_pFilterIn;
- AVFilterContext* m_pFilterOut;
-- AVFilterLink* m_pFilterLink;
-+ AVFilterBufferRef* m_pBufferRef;
-
- int m_iPictureWidth;
- int m_iPictureHeight;
-@@ -109,4 +118,5 @@
- int m_iLastKeyframe;
- double m_dts;
- bool m_started;
-+ std::vector m_formats;
- };
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp 2012-06-05 15:19:23.947496313 +0200
-@@ -525,8 +525,8 @@
- {
- while (!*(nal_start++));
- nal_end = avc_find_startcode(nal_start, end);
-- av_format_ctx->put_be32(pb, nal_end - nal_start);
-- av_format_ctx->put_buffer(pb, nal_start, nal_end - nal_start);
-+ av_format_ctx->avio_wb32(pb, nal_end - nal_start);
-+ av_format_ctx->avio_write(pb, nal_start, nal_end - nal_start);
- size += 4 + nal_end - nal_start;
- nal_start = nal_end;
- }
-@@ -537,14 +537,14 @@
- const uint8_t *buf_in, uint8_t **buf, int *size)
- {
- ByteIOContext *pb;
-- int ret = av_format_ctx->url_open_dyn_buf(&pb);
-+ int ret = av_format_ctx->avio_open_dyn_buf(&pb);
- if (ret < 0)
- return ret;
-
- avc_parse_nal_units(av_format_ctx, pb, buf_in, *size);
-
- av_util_ctx->av_freep(buf);
-- *size = av_format_ctx->url_close_dyn_buf(pb, buf);
-+ *size = av_format_ctx->avio_close_dyn_buf(pb, buf);
- return 0;
- }
-
-@@ -590,26 +590,26 @@
- }
- assert(sps);
-
-- av_format_ctx->put_byte(pb, 1); /* version */
-- av_format_ctx->put_byte(pb, sps[1]); /* profile */
-- av_format_ctx->put_byte(pb, sps[2]); /* profile compat */
-- av_format_ctx->put_byte(pb, sps[3]); /* level */
-- av_format_ctx->put_byte(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
-- av_format_ctx->put_byte(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
-+ av_format_ctx->avio_w8(pb, 1); /* version */
-+ av_format_ctx->avio_w8(pb, sps[1]); /* profile */
-+ av_format_ctx->avio_w8(pb, sps[2]); /* profile compat */
-+ av_format_ctx->avio_w8(pb, sps[3]); /* level */
-+ av_format_ctx->avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
-+ av_format_ctx->avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
-
-- av_format_ctx->put_be16(pb, sps_size);
-- av_format_ctx->put_buffer(pb, sps, sps_size);
-+ av_format_ctx->avio_wb16(pb, sps_size);
-+ av_format_ctx->avio_write(pb, sps, sps_size);
- if (pps)
- {
-- av_format_ctx->put_byte(pb, 1); /* number of pps */
-- av_format_ctx->put_be16(pb, pps_size);
-- av_format_ctx->put_buffer(pb, pps, pps_size);
-+ av_format_ctx->avio_w8(pb, 1); /* number of pps */
-+ av_format_ctx->avio_wb16(pb, pps_size);
-+ av_format_ctx->avio_write(pb, pps, pps_size);
- }
- av_util_ctx->av_free(start);
- }
- else
- {
-- av_format_ctx->put_buffer(pb, data, len);
-+ av_format_ctx->avio_write(pb, data, len);
- }
- }
- return 0;
-@@ -706,7 +706,7 @@
- }
-
- ByteIOContext *pb;
-- if (m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- {
- return false;
- }
-@@ -717,7 +717,7 @@
- // unhook from ffmpeg's extradata
- extradata = NULL;
- // extract the avcC atom data into extradata then write it into avcCData for VDADecoder
-- extrasize = m_dllAvFormat->url_close_dyn_buf(pb, &extradata);
-+ extrasize = m_dllAvFormat->avio_close_dyn_buf(pb, &extradata);
- // CFDataCreate makes a copy of extradata contents
- avcCData = CFDataCreate(kCFAllocatorDefault, (const uint8_t*)extradata, extrasize);
- // done with the converted extradata, we MUST free using av_free
-@@ -948,12 +948,12 @@
- int demuxer_bytes;
- uint8_t *demuxer_content;
-
-- if(m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if(m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- {
- return VC_ERROR;
- }
- demuxer_bytes = avc_parse_nal_units(m_dllAvFormat, pb, pData, iSize);
-- demuxer_bytes = m_dllAvFormat->url_close_dyn_buf(pb, &demuxer_content);
-+ demuxer_bytes = m_dllAvFormat->avio_close_dyn_buf(pb, &demuxer_content);
- avc_demux = CFDataCreate(kCFAllocatorDefault, demuxer_content, demuxer_bytes);
- m_dllAvUtil->av_free(demuxer_content);
- }
-@@ -961,7 +961,7 @@
- {
- // convert demuxer packet from 3 byte NAL sizes to 4 byte
- ByteIOContext *pb;
-- if (m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- return VC_ERROR;
-
- uint32_t nal_size;
-@@ -970,14 +970,14 @@
- while (nal_start < end)
- {
- nal_size = VDA_RB24(nal_start);
-- m_dllAvFormat->put_be32(pb, nal_size);
-+ m_dllAvFormat->avio_wb32(pb, nal_size);
- nal_start += 3;
-- m_dllAvFormat->put_buffer(pb, nal_start, nal_size);
-+ m_dllAvFormat->avio_write(pb, nal_start, nal_size);
- nal_start += nal_size;
- }
-
- uint8_t *demuxer_content;
-- int demuxer_bytes = m_dllAvFormat->url_close_dyn_buf(pb, &demuxer_content);
-+ int demuxer_bytes = m_dllAvFormat->avio_close_dyn_buf(pb, &demuxer_content);
- avc_demux = CFDataCreate(kCFAllocatorDefault, demuxer_content, demuxer_bytes);
- m_dllAvUtil->av_free(demuxer_content);
- }
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp 2012-06-05 15:19:23.949496352 +0200
-@@ -474,7 +474,7 @@
- {
- b |= 0x80;
- }
-- av_format_ctx->put_byte(pb, b);
-+ av_format_ctx->avio_w8(pb, b);
- }
-
- return numBytes;
-@@ -482,37 +482,37 @@
-
- void quicktime_write_esds(DllAvFormat *av_format_ctx, ByteIOContext *pb, quicktime_esds_t *esds)
- {
-- av_format_ctx->put_byte(pb, 0); // Version
-- av_format_ctx->put_be24(pb, 0); // Flags
-+ av_format_ctx->avio_w8(pb, 0); // Version
-+ av_format_ctx->avio_wb24(pb, 0); // Flags
-
- // elementary stream descriptor tag
-- av_format_ctx->put_byte(pb, 0x03);
-+ av_format_ctx->avio_w8(pb, 0x03);
- quicktime_write_mp4_descr_length(av_format_ctx, pb,
- 3 + 5 + (13 + 5 + esds->decoderConfigLen) + 3, false);
- // 3 bytes + 5 bytes for tag
-- av_format_ctx->put_be16(pb, esds->esid);
-- av_format_ctx->put_byte(pb, esds->stream_priority);
-+ av_format_ctx->avio_wb16(pb, esds->esid);
-+ av_format_ctx->avio_w8(pb, esds->stream_priority);
-
- // decoder configuration description tag
-- av_format_ctx->put_byte(pb, 0x04);
-+ av_format_ctx->avio_w8(pb, 0x04);
- quicktime_write_mp4_descr_length(av_format_ctx, pb,
- 13 + 5 + esds->decoderConfigLen, false);
- // 13 bytes + 5 bytes for tag
-- av_format_ctx->put_byte(pb, esds->objectTypeId); // objectTypeIndication
-- av_format_ctx->put_byte(pb, esds->streamType); // streamType
-- av_format_ctx->put_be24(pb, esds->bufferSizeDB); // buffer size
-- av_format_ctx->put_be32(pb, esds->maxBitrate); // max bitrate
-- av_format_ctx->put_be32(pb, esds->avgBitrate); // average bitrate
-+ av_format_ctx->avio_w8(pb, esds->objectTypeId); // objectTypeIndication
-+ av_format_ctx->avio_w8(pb, esds->streamType); // streamType
-+ av_format_ctx->avio_wb24(pb, esds->bufferSizeDB); // buffer size
-+ av_format_ctx->avio_wb32(pb, esds->maxBitrate); // max bitrate
-+ av_format_ctx->avio_wb32(pb, esds->avgBitrate); // average bitrate
-
- // decoder specific description tag
-- av_format_ctx->put_byte(pb, 0x05);
-+ av_format_ctx->avio_w8(pb, 0x05);
- quicktime_write_mp4_descr_length(av_format_ctx, pb, esds->decoderConfigLen, false);
-- av_format_ctx->put_buffer(pb, esds->decoderConfig, esds->decoderConfigLen);
-+ av_format_ctx->avio_write(pb, esds->decoderConfig, esds->decoderConfigLen);
-
- // sync layer configuration descriptor tag
-- av_format_ctx->put_byte(pb, 0x06); // tag
-- av_format_ctx->put_byte(pb, 0x01); // length
-- av_format_ctx->put_byte(pb, 0x7F); // no SL
-+ av_format_ctx->avio_w8(pb, 0x06); // tag
-+ av_format_ctx->avio_w8(pb, 0x01); // length
-+ av_format_ctx->avio_w8(pb, 0x7F); // no SL
-
- /* no IPI_DescrPointer */
- /* no IP_IdentificationDataSet */
-@@ -666,8 +666,8 @@
- {
- while (!*(nal_start++));
- nal_end = avc_find_startcode(nal_start, end);
-- av_format_ctx->put_be32(pb, nal_end - nal_start);
-- av_format_ctx->put_buffer(pb, nal_start, nal_end - nal_start);
-+ av_format_ctx->avio_wb32(pb, nal_end - nal_start);
-+ av_format_ctx->avio_write(pb, nal_start, nal_end - nal_start);
- size += 4 + nal_end - nal_start;
- nal_start = nal_end;
- }
-@@ -678,14 +678,14 @@
- const uint8_t *buf_in, uint8_t **buf, int *size)
- {
- ByteIOContext *pb;
-- int ret = av_format_ctx->url_open_dyn_buf(&pb);
-+ int ret = av_format_ctx->avio_open_dyn_buf(&pb);
- if (ret < 0)
- return ret;
-
- avc_parse_nal_units(av_format_ctx, pb, buf_in, *size);
-
- av_util_ctx->av_freep(buf);
-- *size = av_format_ctx->url_close_dyn_buf(pb, buf);
-+ *size = av_format_ctx->avio_close_dyn_buf(pb, buf);
- return 0;
- }
-
-@@ -770,26 +770,26 @@
- }
- assert(sps);
-
-- av_format_ctx->put_byte(pb, 1); /* version */
-- av_format_ctx->put_byte(pb, sps[1]); /* profile */
-- av_format_ctx->put_byte(pb, sps[2]); /* profile compat */
-- av_format_ctx->put_byte(pb, sps[3]); /* level */
-- av_format_ctx->put_byte(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
-- av_format_ctx->put_byte(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
-+ av_format_ctx->avio_w8(pb, 1); /* version */
-+ av_format_ctx->avio_w8(pb, sps[1]); /* profile */
-+ av_format_ctx->avio_w8(pb, sps[2]); /* profile compat */
-+ av_format_ctx->avio_w8(pb, sps[3]); /* level */
-+ av_format_ctx->avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
-+ av_format_ctx->avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
-
-- av_format_ctx->put_be16(pb, sps_size);
-- av_format_ctx->put_buffer(pb, sps, sps_size);
-+ av_format_ctx->avio_wb16(pb, sps_size);
-+ av_format_ctx->avio_write(pb, sps, sps_size);
- if (pps)
- {
-- av_format_ctx->put_byte(pb, 1); /* number of pps */
-- av_format_ctx->put_be16(pb, pps_size);
-- av_format_ctx->put_buffer(pb, pps, pps_size);
-+ av_format_ctx->avio_w8(pb, 1); /* number of pps */
-+ av_format_ctx->avio_wb16(pb, pps_size);
-+ av_format_ctx->avio_write(pb, pps, pps_size);
- }
- av_util_ctx->av_free(start);
- }
- else
- {
-- av_format_ctx->put_buffer(pb, data, len);
-+ av_format_ctx->avio_write(pb, data, len);
- }
- }
- return 0;
-@@ -1086,7 +1086,7 @@
- ByteIOContext *pb;
- quicktime_esds_t *esds;
-
-- if (m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- return false;
-
- esds = quicktime_set_esds(m_dllAvFormat, extradata, extrasize);
-@@ -1095,7 +1095,7 @@
- // unhook from ffmpeg's extradata
- extradata = NULL;
- // extract the esds atom decoderConfig from extradata
-- extrasize = m_dllAvFormat->url_close_dyn_buf(pb, &extradata);
-+ extrasize = m_dllAvFormat->avio_close_dyn_buf(pb, &extradata);
- free(esds->decoderConfig);
- free(esds);
-
-@@ -1152,7 +1152,7 @@
- // NAL reformating to bitstream format required
-
- ByteIOContext *pb;
-- if (m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- return false;
-
- m_convert_bytestream = true;
-@@ -1161,7 +1161,7 @@
- // unhook from ffmpeg's extradata
- extradata = NULL;
- // extract the avcC atom data into extradata getting size into extrasize
-- extrasize = m_dllAvFormat->url_close_dyn_buf(pb, &extradata);
-+ extrasize = m_dllAvFormat->avio_close_dyn_buf(pb, &extradata);
-
- // check for interlaced and get number of ref frames
- if (!validate_avcC_spc(extradata, extrasize, &m_max_ref_frames))
-@@ -1301,17 +1301,17 @@
- if (m_convert_bytestream)
- {
- // convert demuxer packet from bytestream (AnnexB) to bitstream
-- if(m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if(m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- return VC_ERROR;
-
- demux_size = avc_parse_nal_units(m_dllAvFormat, pb, pData, iSize);
-- demux_size = m_dllAvFormat->url_close_dyn_buf(pb, &demux_buff);
-+ demux_size = m_dllAvFormat->avio_close_dyn_buf(pb, &demux_buff);
- sampleBuff = CreateSampleBufferFrom(m_fmt_desc, demux_buff, demux_size);
- }
- else if (m_convert_3byteTo4byteNALSize)
- {
- // convert demuxer packet from 3 byte NAL sizes to 4 byte
-- if (m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- return VC_ERROR;
-
- uint32_t nal_size;
-@@ -1320,13 +1320,13 @@
- while (nal_start < end)
- {
- nal_size = VDA_RB24(nal_start);
-- m_dllAvFormat->put_be32(pb, nal_size);
-+ m_dllAvFormat->avio_wb32(pb, nal_size);
- nal_start += 3;
-- m_dllAvFormat->put_buffer(pb, nal_start, nal_size);
-+ m_dllAvFormat->avio_write(pb, nal_start, nal_size);
- nal_start += nal_size;
- }
-
-- demux_size = m_dllAvFormat->url_close_dyn_buf(pb, &demux_buff);
-+ demux_size = m_dllAvFormat->avio_close_dyn_buf(pb, &demux_buff);
- sampleBuff = CreateSampleBufferFrom(m_fmt_desc, demux_buff, demux_size);
- }
- else
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp 2012-06-05 15:19:23.950496372 +0200
-@@ -223,7 +223,6 @@
- }
-
- pic->type = FF_BUFFER_TYPE_USER;
-- pic->age = 1;
- pic->data[0] = (uint8_t*)wrapper;
- pic->data[1] = NULL;
- pic->data[2] = NULL;
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp 2012-06-05 15:19:23.951496392 +0200
-@@ -1197,14 +1197,12 @@
-
- if(pic->reference)
- {
-- pic->age = pA->ip_age[0];
- pA->ip_age[0]= pA->ip_age[1]+1;
- pA->ip_age[1]= 1;
- pA->b_age++;
- }
- else
- {
-- pic->age = pA->b_age;
- pA->ip_age[0]++;
- pA->ip_age[1]++;
- pA->b_age = 1;
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp 2012-06-05 15:19:23.955496472 +0200
-@@ -160,7 +160,7 @@
- #define g_demuxer (*((CDVDDemuxFFmpeg**)g_tls.Get()))
- #endif
-
--static int interrupt_cb(void)
-+static int interrupt_cb(void* unused)
- {
- if(g_demuxer && g_demuxer->Aborted())
- return 1;
-@@ -178,7 +178,7 @@
-
- static int dvd_file_read(void *h, uint8_t* buf, int size)
- {
-- if(interrupt_cb())
-+ if(interrupt_cb(NULL))
- return -1;
-
- CDVDInputStream* pInputStream = (CDVDInputStream*)h;
-@@ -192,7 +192,7 @@
- */
- static offset_t dvd_file_seek(void *h, offset_t pos, int whence)
- {
-- if(interrupt_cb())
-+ if(interrupt_cb(NULL))
- return -1;
-
- CDVDInputStream* pInputStream = (CDVDInputStream*)h;
-@@ -236,6 +236,7 @@
- m_speed = DVD_PLAYSPEED_NORMAL;
- g_demuxer = this;
- m_program = UINT_MAX;
-+ const AVIOInterruptCB int_cb = { interrupt_cb, NULL };
-
- if (!pInput) return false;
-
-@@ -246,10 +247,6 @@
-
- // register codecs
- m_dllAvFormat.av_register_all();
-- m_dllAvFormat.url_set_interrupt_cb(interrupt_cb);
--
-- // could be used for interupting ffmpeg while opening a file (eg internet streams)
-- // url_set_interrupt_cb(NULL);
-
- m_pInput = pInput;
- strFile = m_pInput->GetFileName();
-@@ -284,14 +281,14 @@
- // try mmsh, then mmst
- CStdString strFile2;
- strFile2.Format("mmsh://%s",strFile.substr(6,strFile.size()-6).c_str());
-- result = m_dllAvFormat.av_open_input_file(&m_pFormatContext, strFile2.c_str(), iformat, FFMPEG_FILE_BUFFER_SIZE, NULL);
-+ result = m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile2.c_str(), iformat, NULL);
- if (result < 0)
- {
- strFile = "mmst://";
- strFile += strFile2.Mid(7).c_str();
- }
- }
-- if (result < 0 && m_dllAvFormat.av_open_input_file(&m_pFormatContext, strFile.c_str(), iformat, FFMPEG_FILE_BUFFER_SIZE, NULL) < 0 )
-+ if (result < 0 && m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, NULL) < 0 )
- {
- CLog::Log(LOGDEBUG, "Error, could not open file %s", strFile.c_str());
- Dispose();
-@@ -301,24 +298,16 @@
- else
- {
- unsigned char* buffer = (unsigned char*)m_dllAvUtil.av_malloc(FFMPEG_FILE_BUFFER_SIZE);
-- m_ioContext = m_dllAvFormat.av_alloc_put_byte(buffer, FFMPEG_FILE_BUFFER_SIZE, 0, m_pInput, dvd_file_read, NULL, dvd_file_seek);
-+ m_ioContext = m_dllAvFormat.avio_alloc_context(buffer, FFMPEG_FILE_BUFFER_SIZE, 0, m_pInput, dvd_file_read, NULL, dvd_file_seek);
- m_ioContext->max_packet_size = m_pInput->GetBlockSize();
- if(m_ioContext->max_packet_size)
- m_ioContext->max_packet_size *= FFMPEG_FILE_BUFFER_SIZE / m_ioContext->max_packet_size;
-
- if(m_pInput->Seek(0, SEEK_POSSIBLE) == 0)
-- m_ioContext->is_streamed = 1;
-+ m_ioContext->seekable = 0;
-
- if( iformat == NULL )
- {
--#if defined(USE_EXTERNAL_FFMPEG) && LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52,98,0)
-- // API added on: 2011-02-09
-- // Old versions of ffmpeg do not have av_probe_input_format, so we need
-- // to always probe using the lower-level functions as well.
-- const bool legacyProbing = true;
--#else
-- const bool legacyProbing = false;
--#endif
- // let ffmpeg decide which demuxer we have to open
-
- bool trySPDIFonly = (m_pInput->GetContent() == "audio/x-spdif-compressed");
-@@ -331,7 +320,7 @@
- // want to probe for spdif (DTS or IEC 61937) compressed audio
- // specifically, or in case the file is a wav which may contain DTS or
- // IEC 61937 (e.g. ac3-in-wav) and we want to check for those formats.
-- if (legacyProbing || trySPDIFonly || (iformat && strcmp(iformat->name, "wav") == 0))
-+ if (trySPDIFonly || (iformat && strcmp(iformat->name, "wav") == 0))
- {
- AVProbeData pd;
- BYTE probe_buffer[FFMPEG_FILE_BUFFER_SIZE + AVPROBE_PADDING_SIZE];
-@@ -341,7 +330,7 @@
- pd.filename = strFile.c_str();
-
- // read data using avformat's buffers
-- pd.buf_size = m_dllAvFormat.get_buffer(m_ioContext, pd.buf, m_ioContext->max_packet_size ? m_ioContext->max_packet_size : m_ioContext->buffer_size);
-+ pd.buf_size = m_dllAvFormat.avio_read(m_ioContext, pd.buf, m_ioContext->max_packet_size ? m_ioContext->max_packet_size : m_ioContext->buffer_size);
- if (pd.buf_size <= 0)
- {
- CLog::Log(LOGERROR, "%s - error reading from input stream, %s", __FUNCTION__, strFile.c_str());
-@@ -350,10 +339,7 @@
- memset(pd.buf+pd.buf_size, 0, AVPROBE_PADDING_SIZE);
-
- // restore position again
-- m_dllAvFormat.url_fseek(m_ioContext , 0, SEEK_SET);
--
-- if (legacyProbing && !trySPDIFonly)
-- iformat = m_dllAvFormat.av_probe_input_format(&pd, 1);
-+ m_dllAvFormat.avio_seek(m_ioContext , 0, SEEK_SET);
-
- // the advancedsetting is for allowing the user to force outputting the
- // 44.1 kHz DTS wav file as PCM, so that an A/V receiver can decode
-@@ -424,7 +410,10 @@
-
-
- // open the demuxer
-- if (m_dllAvFormat.av_open_input_stream(&m_pFormatContext, m_ioContext, strFile.c_str(), iformat, NULL) < 0)
-+ m_pFormatContext = m_dllAvFormat.avformat_alloc_context();
-+ m_pFormatContext->pb = m_ioContext;
-+
-+ if (m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, NULL) < 0)
- {
- CLog::Log(LOGERROR, "%s - Error, could not open file %s", __FUNCTION__, strFile.c_str());
- Dispose();
-@@ -432,8 +421,11 @@
- }
- }
-
-+ // set the interrupt callback, appeared in libavformat 53.15.0
-+ m_pFormatContext->interrupt_callback = int_cb;
-+
- // analyse very short to speed up mjpeg playback start
-- if (iformat && (strcmp(iformat->name, "mjpeg") == 0) && m_ioContext->is_streamed)
-+ if (iformat && (strcmp(iformat->name, "mjpeg") == 0) && m_ioContext->seekable == 0)
- m_pFormatContext->max_analyze_duration = 500000;
-
- // we need to know if this is matroska or avi later
-@@ -447,8 +439,8 @@
- m_pFormatContext->max_analyze_duration = 500000;
-
-
-- CLog::Log(LOGDEBUG, "%s - av_find_stream_info starting", __FUNCTION__);
-- int iErr = m_dllAvFormat.av_find_stream_info(m_pFormatContext);
-+ CLog::Log(LOGDEBUG, "%s - avformat_find_stream_info starting", __FUNCTION__);
-+ int iErr = m_dllAvFormat.avformat_find_stream_info(m_pFormatContext, NULL);
- if (iErr < 0)
- {
- CLog::Log(LOGWARNING,"could not find codec parameters for %s", strFile.c_str());
-@@ -471,7 +463,7 @@
- m_pFormatContext->flags |= AVFMT_FLAG_NONBLOCK;
-
- // print some extra information
-- m_dllAvFormat.dump_format(m_pFormatContext, 0, strFile.c_str(), 0);
-+ m_dllAvFormat.av_dump_format(m_pFormatContext, 0, strFile.c_str(), 0);
-
- UpdateCurrentPTS();
-
-@@ -510,20 +502,12 @@
-
- if (m_pFormatContext)
- {
-- if (m_ioContext)
-+ if (m_ioContext && m_pFormatContext->pb && m_pFormatContext->pb != m_ioContext)
- {
-- if(m_pFormatContext->pb && m_pFormatContext->pb != m_ioContext)
-- {
-- CLog::Log(LOGWARNING, "CDVDDemuxFFmpeg::Dispose - demuxer changed our byte context behind our back, possible memleak");
-- m_ioContext = m_pFormatContext->pb;
-- }
-- m_dllAvFormat.av_close_input_stream(m_pFormatContext);
-- if (m_ioContext->buffer)
-- m_dllAvUtil.av_free(m_ioContext->buffer);
-- m_dllAvUtil.av_free(m_ioContext);
-+ CLog::Log(LOGWARNING, "CDVDDemuxFFmpeg::Dispose - demuxer changed our byte context behind our back, possible memleak");
-+ m_ioContext = m_pFormatContext->pb;
- }
-- else
-- m_dllAvFormat.av_close_input_file(m_pFormatContext);
-+ m_dllAvFormat.avformat_close_input(&m_pFormatContext);
- }
- m_ioContext = NULL;
- m_pFormatContext = NULL;
-@@ -773,19 +757,12 @@
- {
- stream->duration = duration;
- duration = m_dllAvUtil.av_rescale_rnd(stream->duration, (int64_t)stream->time_base.num * AV_TIME_BASE, stream->time_base.den, AV_ROUND_NEAR_INF);
-- if ((m_pFormatContext->duration == (int64_t)AV_NOPTS_VALUE && m_pFormatContext->file_size > 0)
-+ if ((m_pFormatContext->duration == (int64_t)AV_NOPTS_VALUE)
- || (m_pFormatContext->duration != (int64_t)AV_NOPTS_VALUE && duration > m_pFormatContext->duration))
- m_pFormatContext->duration = duration;
- }
- }
-
-- // check if stream seem to have grown since start
-- if(m_pFormatContext->file_size > 0 && m_pFormatContext->pb)
-- {
-- if(m_pFormatContext->pb->pos > m_pFormatContext->file_size)
-- m_pFormatContext->file_size = m_pFormatContext->pb->pos;
-- }
--
- pPacket->iStreamId = pkt.stream_index; // XXX just for now
- }
- m_dllAvCodec.av_free_packet(&pkt);
-@@ -923,19 +900,6 @@
- if (!m_pFormatContext)
- return 0;
-
-- /* apperently ffmpeg messes up sometimes, so check for negative value too */
-- if (m_pFormatContext->duration == (int64_t)AV_NOPTS_VALUE || m_pFormatContext->duration < 0LL)
-- {
-- // no duration is available for us
-- // try to calculate it
-- int iLength = 0;
-- if (m_iCurrentPts != DVD_NOPTS_VALUE && m_pFormatContext->file_size > 0 && m_pFormatContext->pb && m_pFormatContext->pb->pos > 0)
-- {
-- iLength = (int)(((m_iCurrentPts * m_pFormatContext->file_size) / m_pFormatContext->pb->pos) / 1000) & 0xFFFFFFFF;
-- }
-- return iLength;
-- }
--
- return (int)(m_pFormatContext->duration / (AV_TIME_BASE / 1000));
- }
-
-@@ -970,6 +934,12 @@
-
- void CDVDDemuxFFmpeg::AddStream(int iId)
- {
-+ if(iId >= MAX_STREAMS)
-+ {
-+ CLog::Log(LOGWARNING, "%s - streams id %d exeeds maximum supported", __FUNCTION__, iId);
-+ return;
-+ }
-+
- AVStream* pStream = m_pFormatContext->streams[iId];
- if (pStream)
- {
-@@ -987,8 +957,8 @@
- st->iBitRate = pStream->codec->bit_rate;
- st->iBitsPerSample = pStream->codec->bits_per_coded_sample;
-
-- if(m_dllAvFormat.av_metadata_get(pStream->metadata, "title", NULL, 0))
-- st->m_description = m_dllAvFormat.av_metadata_get(pStream->metadata, "title", NULL, 0)->value;
-+ if(m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0))
-+ st->m_description = m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0)->value;
-
- break;
- }
-@@ -1077,8 +1047,8 @@
- if(pStream->codec)
- st->identifier = pStream->codec->sub_id;
-
-- if(m_dllAvFormat.av_metadata_get(pStream->metadata, "title", NULL, 0))
-- st->m_description = m_dllAvFormat.av_metadata_get(pStream->metadata, "title", NULL, 0)->value;
-+ if(m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0))
-+ st->m_description = m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0)->value;
-
- break;
- }
-@@ -1089,7 +1059,7 @@
- {
- std::string fileName = "special://temp/fonts/";
- XFILE::CDirectory::Create(fileName);
-- AVMetadataTag *nameTag = m_dllAvFormat.av_metadata_get(pStream->metadata, "filename", NULL, 0);
-+ AVDictionaryEntry *nameTag = m_dllAvUtil.av_dict_get(pStream->metadata, "filename", NULL, 0);
- if (!nameTag) {
- CLog::Log(LOGERROR, "%s: TTF attachment has no name", __FUNCTION__);
- break;
-@@ -1138,7 +1108,7 @@
- // API added on: 2010-10-15
- // (Note that while the function was available earlier, the generic
- // metadata tags were not populated by default)
-- AVMetadataTag *langTag = m_dllAvFormat.av_metadata_get(pStream->metadata, "language", NULL, 0);
-+ AVDictionaryEntry *langTag = m_dllAvUtil.av_dict_get(pStream->metadata, "language", NULL, 0);
- if (langTag)
- strncpy(m_streams[iId]->language, langTag->value, 3);
- #else
-@@ -1248,7 +1218,7 @@
- // API added on: 2010-10-15
- // (Note that while the function was available earlier, the generic
- // metadata tags were not populated by default)
-- AVMetadataTag *titleTag = m_dllAvFormat.av_metadata_get(m_pFormatContext->chapters[chapterIdx-1]->metadata,
-+ AVDictionaryEntry *titleTag = m_dllAvUtil.av_dict_get(m_pFormatContext->chapters[chapterIdx-1]->metadata,
- "title", NULL, 0);
- if (titleTag)
- strChapterName = titleTag->value;
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h 2012-06-05 15:19:23.956496492 +0200
-@@ -128,7 +128,7 @@
- #define MAX_STREAMS 100
- CDemuxStream* m_streams[MAX_STREAMS]; // maximum number of streams that ffmpeg can handle
-
-- ByteIOContext* m_ioContext;
-+ AVIOContext* m_ioContext;
-
- DllAvFormat m_dllAvFormat;
- DllAvCodec m_dllAvCodec;
-diff -Naur xbmc-11.0.1/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
---- xbmc-11.0.1/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2012-03-21 23:57:34.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2012-06-05 15:19:23.957496512 +0200
-@@ -413,6 +413,7 @@
- {
- if(m_pVideoCodec)
- m_pVideoCodec->Reset();
-+ picture.iFlags &= ~DVP_FLAG_ALLOCATED;
- m_packets.clear();
- m_started = false;
- }
-@@ -420,6 +421,7 @@
- {
- if(m_pVideoCodec)
- m_pVideoCodec->Reset();
-+ picture.iFlags &= ~DVP_FLAG_ALLOCATED;
- m_packets.clear();
-
- m_pullupCorrection.Flush();
-diff -Naur xbmc-11.0.1/xbmc/DllPaths_generated.h.in xbmc-11.0.1.patch/xbmc/DllPaths_generated.h.in
---- xbmc-11.0.1/xbmc/DllPaths_generated.h.in 2012-03-21 23:57:32.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/DllPaths_generated.h.in 2012-06-05 15:19:23.957496512 +0200
-@@ -74,13 +74,13 @@
- #define DLL_PATH_LIBMAD "@MAD_SONAME@"
-
- /* ffmpeg */
--#define DLL_PATH_LIBAVCODEC "special://xbmcbin/system/players/dvdplayer/avcodec-52-@ARCH@.so"
--#define DLL_PATH_LIBAVCORE "special://xbmcbin/system/players/dvdplayer/avcore-0-@ARCH@.so"
--#define DLL_PATH_LIBAVFORMAT "special://xbmcbin/system/players/dvdplayer/avformat-52-@ARCH@.so"
--#define DLL_PATH_LIBAVUTIL "special://xbmcbin/system/players/dvdplayer/avutil-50-@ARCH@.so"
--#define DLL_PATH_LIBPOSTPROC "special://xbmcbin/system/players/dvdplayer/postproc-51-@ARCH@.so"
--#define DLL_PATH_LIBSWSCALE "special://xbmcbin/system/players/dvdplayer/swscale-0-@ARCH@.so"
--#define DLL_PATH_LIBAVFILTER "special://xbmcbin/system/players/dvdplayer/avfilter-1-@ARCH@.so"
-+#define DLL_PATH_LIBAVCODEC "special://xbmcbin/system/players/dvdplayer/avcodec-53-@ARCH@.so"
-+#define DLL_PATH_LIBAVFORMAT "special://xbmcbin/system/players/dvdplayer/avformat-53-@ARCH@.so"
-+#define DLL_PATH_LIBAVUTIL "special://xbmcbin/system/players/dvdplayer/avutil-51-@ARCH@.so"
-+#define DLL_PATH_LIBPOSTPROC "special://xbmcbin/system/players/dvdplayer/postproc-52-@ARCH@.so"
-+#define DLL_PATH_LIBSWSCALE "special://xbmcbin/system/players/dvdplayer/swscale-2-@ARCH@.so"
-+#define DLL_PATH_LIBAVFILTER "special://xbmcbin/system/players/dvdplayer/avfilter-2-@ARCH@.so"
-+#define DLL_PATH_LIBSWRESAMPLE "special://xbmcbin/system/players/dvdplayer/swresample-0-@ARCH@.so"
-
- /* cdrip */
- #if defined(_LINUX) && !defined(__APPLE__)
-diff -Naur xbmc-11.0.1/xbmc/DllPaths_win32.h xbmc-11.0.1.patch/xbmc/DllPaths_win32.h
---- xbmc-11.0.1/xbmc/DllPaths_win32.h 2012-03-21 23:57:32.000000000 +0100
-+++ xbmc-11.0.1.patch/xbmc/DllPaths_win32.h 2012-06-05 15:19:23.958496532 +0200
-@@ -58,13 +58,13 @@
- #define DLL_PATH_LIBRTMP "special://xbmcbin/system/players/dvdplayer/librtmp.dll"
-
- /* ffmpeg */
--#define DLL_PATH_LIBAVCODEC "special://xbmcbin/system/players/dvdplayer/avcodec-52.dll"
--#define DLL_PATH_LIBAVCORE "special://xbmcbin/system/players/dvdplayer/avcore-0.dll"
--#define DLL_PATH_LIBAVFORMAT "special://xbmcbin/system/players/dvdplayer/avformat-52.dll"
--#define DLL_PATH_LIBAVUTIL "special://xbmcbin/system/players/dvdplayer/avutil-50.dll"
--#define DLL_PATH_LIBAVFILTER "special://xbmcbin/system/players/dvdplayer/avfilter-1.dll"
--#define DLL_PATH_LIBPOSTPROC "special://xbmcbin/system/players/dvdplayer/postproc-51.dll"
--#define DLL_PATH_LIBSWSCALE "special://xbmcbin/system/players/dvdplayer/swscale-0.dll"
-+#define DLL_PATH_LIBAVCODEC "special://xbmcbin/system/players/dvdplayer/avcodec-53.dll"
-+#define DLL_PATH_LIBAVFORMAT "special://xbmcbin/system/players/dvdplayer/avformat-53.dll"
-+#define DLL_PATH_LIBAVUTIL "special://xbmcbin/system/players/dvdplayer/avutil-51.dll"
-+#define DLL_PATH_LIBAVFILTER "special://xbmcbin/system/players/dvdplayer/avfilter-2.dll"
-+#define DLL_PATH_LIBPOSTPROC "special://xbmcbin/system/players/dvdplayer/postproc-52.dll"
-+#define DLL_PATH_LIBSWSCALE "special://xbmcbin/system/players/dvdplayer/swscale-2.dll"
-+#define DLL_PATH_LIBSWRESAMPLE "special://xbmcbin/system/players/dvdplayer/swresample-0.dll"
-
- /* cdrip */
- #define DLL_PATH_LAME_ENC "special://xbmcbin/system/cdrip/lame_enc.dll"
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-901.03-ffmpeg_crystalhd_implementation.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-901.03-ffmpeg_crystalhd_implementation.patch
deleted file mode 100644
index 68c31b264a..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-901.03-ffmpeg_crystalhd_implementation.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From 5c62df65cb2ef1c7dcebbf07bd6d180960ab6715 Mon Sep 17 00:00:00 2001
-From: theuni
-Date: Wed, 4 Apr 2012 14:53:51 -0400
-Subject: [PATCH] ffmpeg: disable ffmpeg's crystalhd implementation for now
-
----
- configure.in | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/configure.in b/configure.in
-index 0d80719..40e9fb5 100755
---- a/configure.in
-+++ b/configure.in
-@@ -2041,6 +2041,7 @@ XB_CONFIG_MODULE([lib/ffmpeg], [
- --disable-ffmpeg \
- --disable-doc \
- --disable-decoder=mpeg_xvmc \
-+ --disable-crystalhd \
- --enable-postproc \
- --enable-gpl \
- --enable-protocol=http \
-@@ -2080,6 +2081,7 @@ XB_CONFIG_MODULE([lib/ffmpeg], [
- --disable-ffplay \
- --disable-ffserver \
- --disable-ffmpeg \
-+ --disable-crystalhd \
- --enable-shared \
- --disable-doc \
- --enable-postproc \
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-901.41-avfilter-depends-on-avformat.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-901.41-avfilter-depends-on-avformat.patch
deleted file mode 100644
index 04708b7219..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-901.41-avfilter-depends-on-avformat.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From d1e06c28d3eb6cd689b8cbc5b96babe81707baa7 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker
-Date: Sun, 15 Apr 2012 14:00:22 +0200
-Subject: [PATCH] ffmpeg: avfilter depends on avformat
-
----
- lib/DllAvFilter.h | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/lib/DllAvFilter.h b/lib/DllAvFilter.h
-index 5c83654..6ae5d15 100644
---- a/lib/DllAvFilter.h
-+++ b/lib/DllAvFilter.h
-@@ -25,6 +25,7 @@
- #endif
- #include "DynamicDll.h"
- #include "DllAvCodec.h"
-+#include "DllAvFormat.h"
- #include "DllSwResample.h"
- #include "utils/log.h"
-
-@@ -203,6 +204,7 @@ class DllAvFilter : public DllDynamic, DllAvFilterInterface
- /* dependencies of libavfilter */
- DllAvUtil m_dllAvUtil;
- DllSwResample m_dllSwResample;
-+ DllAvFormat m_dllAvFormat;
-
- public:
- int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
-@@ -251,6 +253,8 @@ class DllAvFilter : public DllDynamic, DllAvFilterInterface
- return false;
- if (!m_dllSwResample.Load())
- return false;
-+ if (!m_dllAvFormat.Load())
-+ return false;
- return DllDynamic::Load();
- }
- };
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.01-xvba_support_vdpau_rework-c633159.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.01-xvba_support_vdpau_rework-c633159.patch
deleted file mode 100644
index 98a4fa1a77..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.01-xvba_support_vdpau_rework-c633159.patch
+++ /dev/null
@@ -1,14563 +0,0 @@
-diff -Naur xbmc-pvr-11.0.1/configure.in xbmc-pvr-11.0.1.patch/configure.in
---- xbmc-pvr-11.0.1/configure.in 2012-05-14 14:11:49.081856910 +0200
-+++ xbmc-pvr-11.0.1.patch/configure.in 2012-05-14 14:15:12.045218673 +0200
-@@ -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. =="
-+xvba_not_found="== Could not find amdxvba.h. XVBA support disabled. =="
-+xvba_disabled="== XVBA support manually disabled. =="
- vdadecoder_enabled="== VDADecoder support enabled. =="
- vdadecoder_disabled="== VDADecoder support manually disabled. =="
- vtbdecoder_enabled="== VTBDecoder support enabled. =="
-@@ -204,6 +206,12 @@
- [enable CrystalHD decoding (default is auto)])],
- [use_crystalhd=$enableval],
- [use_crystalhd=auto])
-+
-+AC_ARG_ENABLE([xvba],
-+ [AS_HELP_STRING([--enable-xvba],
-+ [enable XVBA decoding (default is auto)])],
-+ [use_xvba=$enableval],
-+ [use_xvba=auto])
-
- AC_ARG_ENABLE([vdadecoder],
- [AS_HELP_STRING([--enable-vdadecoder],
-@@ -1382,6 +1390,38 @@
- USE_CRYSTALHD=0
- fi
-
-+# XVBA
-+if test "x$use_xvba" != "xno"; then
-+ if test "$host_vendor" = "apple" ; then
-+ if test "x$use_xvba" = "xyes"; then
-+ AC_MSG_ERROR([XVBA not supported on this platform])
-+ else
-+ use_xvba="no"
-+ AC_MSG_NOTICE($xvba_disabled)
-+ fi
-+ USE_XVBA=0
-+ else
-+ initial_val=$use_xvba
-+ AC_CHECK_HEADER([amd/amdxvba.h],, use_xvba=no, [#include ])
-+
-+ if test "x$use_xvba" = "xno"; then
-+ if test "x$initial_val" = "xyes"; then
-+ AC_MSG_ERROR($xvba_not_found)
-+ else
-+ AC_MSG_RESULT($xvba_not_found)
-+ fi
-+ USE_XVBA=0
-+ else
-+ AC_DEFINE([HAVE_LIBXVBA], [1], [Define to 1 if you have the 'xvba' header (amdxvba.h)])
-+ USE_XVBA=1
-+ fi
-+ fi
-+else
-+ AC_MSG_NOTICE($xvba_disabled)
-+ USE_XVBA=0
-+fi
-+
-+
- # VDADecoder
- if test "x$use_vdadecoder" != "xno"; then
- if test "$host_vendor" = "apple" ; then
-@@ -1578,6 +1618,12 @@
- final_message="$final_message\n CrystalHD:\tNo"
- fi
-
-+if test "x$use_xvba" != "xno"; then
-+ final_message="$final_message\n XVBA:\t\tYes"
-+else
-+ final_message="$final_message\n XVBA:\t\tNo"
-+fi
-+
- if test "x$use_vdadecoder" != "xno"; then
- final_message="$final_message\n VDADecoder:\tYes"
- else
-@@ -1952,6 +1998,7 @@
- AC_SUBST(USE_VDPAU)
- AC_SUBST(USE_VAAPI)
- AC_SUBST(USE_CRYSTALHD)
-+AC_SUBST(USE_XVBA)
- AC_SUBST(USE_LIBSMBCLIENT)
- AC_SUBST(USE_LIBNFS)
- AC_SUBST(USE_LIBAFPCLIENT)
-@@ -2094,6 +2141,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` \
-+ `if test "x$use_xvba" != "xno"; then echo --enable-xvba; else echo --disable-xvba; fi` \
- --enable-protocol=http \
- --enable-pthreads \
- --enable-runtime-cpudetect \
-diff -Naur xbmc-pvr-11.0.1/language/Dutch/strings.xml xbmc-pvr-11.0.1.patch/language/Dutch/strings.xml
---- xbmc-pvr-11.0.1/language/Dutch/strings.xml 2012-05-14 14:14:51.670808009 +0200
-+++ xbmc-pvr-11.0.1.patch/language/Dutch/strings.xml 2012-05-14 14:15:12.051218793 +0200
-@@ -1236,7 +1236,8 @@
- Hardwareversnelling inschakelen (OpenMax)
- Pixelshaders
- Hardware acceleratie toestaan (VideoToolbox)
--
-+ Vdpau OpenGL interop RGB inschakelen
-+ Vdpau OpenGL interop YUV inschakelen
- A/V-synchronisatiemethode
- Audiosignaal
- Videosignaal (Drop/Dupe audio)
-@@ -1542,6 +1543,7 @@
- Spline36
- Spline36 geoptimaliseerd
- Software menging
-+ VDPAU Bob
-
- Kwaliteitsverbetering video
-
-diff -Naur xbmc-pvr-11.0.1/language/English/strings.xml xbmc-pvr-11.0.1.patch/language/English/strings.xml
---- xbmc-pvr-11.0.1/language/English/strings.xml 2012-05-14 14:14:51.673808069 +0200
-+++ xbmc-pvr-11.0.1.patch/language/English/strings.xml 2012-05-14 14:15:12.053218833 +0200
-@@ -1234,6 +1234,9 @@
- Allow hardware acceleration (OpenMax)
- Pixel Shaders
- Allow hardware acceleration (VideoToolbox)
-+ Allow Vdpau OpenGL interop RGB
-+ Allow Vdpau OpenGL interop YUV
-+ Allow hardware acceleration (XVBA)
-
- A/V sync method
- Audio clock
-@@ -1540,6 +1543,8 @@
- Spline36
- Spline36 optimized
- Software Blend
-+ VDPAU Bob
-+ XVBA
-
- Post-processing
-
-diff -Naur xbmc-pvr-11.0.1/language/German/strings.xml xbmc-pvr-11.0.1.patch/language/German/strings.xml
---- xbmc-pvr-11.0.1/language/German/strings.xml 2012-03-27 17:55:51.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/language/German/strings.xml 2012-05-14 14:15:12.059218956 +0200
-@@ -1268,6 +1268,8 @@
- Hardwarebeschleunigung erlauben (OpenMax)
- Pixel Shaders
- Hardwarebeschleunigung erlauben (VideoToolbox)
-+ Vdpau OpenGL interop RGB erlauben
-+ Vdpau OpenGL interop YUV erlauben
-
- A/V Sync Methode
- Audio Takt
-@@ -1567,6 +1569,7 @@
- Zeitlich (Hälfte)
- Zeitlich/Räumlich (Hälfte)
- DXVA
-+ VDPAU Bob
-
- Video Nachbearbeitung
- Deaktiviert
-diff -Naur xbmc-pvr-11.0.1/language/Swedish/strings.xml xbmc-pvr-11.0.1.patch/language/Swedish/strings.xml
---- xbmc-pvr-11.0.1/language/Swedish/strings.xml 2012-03-27 17:55:51.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/language/Swedish/strings.xml 2012-05-14 14:15:12.062219016 +0200
-@@ -1412,6 +1412,7 @@
- Spline36
- Spline36-optimerad
- Mjukvarublandning
-+ VDPAU Bob
- Efterbearbetning
- Visa insommningstimeout
- Byt till kanal
-diff -Naur xbmc-pvr-11.0.1/lib/UnrarXLib/extract.cpp xbmc-pvr-11.0.1.patch/lib/UnrarXLib/extract.cpp
---- xbmc-pvr-11.0.1/lib/UnrarXLib/extract.cpp 2012-03-27 17:55:39.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/lib/UnrarXLib/extract.cpp 2012-05-14 14:15:12.095219681 +0200
-@@ -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-pvr-11.0.1/lib/UnrarXLib/unpack15.cpp xbmc-pvr-11.0.1.patch/lib/UnrarXLib/unpack15.cpp
---- xbmc-pvr-11.0.1/lib/UnrarXLib/unpack15.cpp 2012-03-27 17:55:39.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/lib/UnrarXLib/unpack15.cpp 2012-05-14 14:15:12.095219681 +0200
-@@ -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-pvr-11.0.1/lib/UnrarXLib/unpack.cpp xbmc-pvr-11.0.1.patch/lib/UnrarXLib/unpack.cpp
---- xbmc-pvr-11.0.1/lib/UnrarXLib/unpack.cpp 2012-03-27 17:55:39.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/lib/UnrarXLib/unpack.cpp 2012-05-14 14:15:12.096219701 +0200
-@@ -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-pvr-11.0.1/system/shaders/yuv2rgb_basic.glsl xbmc-pvr-11.0.1.patch/system/shaders/yuv2rgb_basic.glsl
---- xbmc-pvr-11.0.1/system/shaders/yuv2rgb_basic.glsl 2012-03-27 17:55:54.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/system/shaders/yuv2rgb_basic.glsl 2012-05-14 14:15:12.097219721 +0200
-@@ -70,6 +70,18 @@
- rgb.a = gl_Color.a;
- gl_FragColor = rgb;
-
-+#elif defined(XBMC_VDPAU_NV12)
-+
-+ vec4 yuv, rgb;
-+ yuv.rgba = vec4( texture2D(m_sampY, stretch(m_cordY)).r
-+ , texture2D(m_sampU, stretch(m_cordU)).r
-+ , texture2D(m_sampV, stretch(m_cordV)).g
-+ , 1.0 );
-+
-+ rgb = m_yuvmat * yuv;
-+ rgb.a = gl_Color.a;
-+ gl_FragColor = rgb;
-+
- #elif defined(XBMC_YUY2) || defined(XBMC_UYVY)
-
- #if(XBMC_texture_rectangle)
-diff -Naur xbmc-pvr-11.0.1/xbmc/Application.cpp xbmc-pvr-11.0.1.patch/xbmc/Application.cpp
---- xbmc-pvr-11.0.1/xbmc/Application.cpp 2012-03-27 17:55:35.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/Application.cpp 2012-05-14 14:15:12.101219801 +0200
-@@ -391,8 +391,6 @@
- #endif
- m_currentStack = new CFileItemList;
-
-- m_frameCount = 0;
--
- m_bPresentFrame = false;
- m_bPlatformDirectories = true;
-
-@@ -2026,28 +2024,18 @@
-
- bool CApplication::WaitFrame(unsigned int timeout)
- {
-- bool done = false;
--
- // Wait for all other frames to be presented
-- CSingleLock lock(m_frameMutex);
-- //wait until event is set, but modify remaining time
-+ m_frameEvent.Reset();
-
-- TightConditionVariable > cv(m_frameCond, InversePredicate(m_frameCount));
-- cv.wait(lock,timeout);
-- done = m_frameCount == 0;
-+ if (!g_renderManager.HasFrame() && !m_frameEvent.WaitMSec(timeout))
-+ return false;
-
-- return done;
-+ return g_renderManager.HasFrame();
- }
-
- void CApplication::NewFrame()
- {
-- // We just posted another frame. Keep track and notify.
-- {
-- CSingleLock lock(m_frameMutex);
-- m_frameCount++;
-- }
--
-- m_frameCond.notifyAll();
-+ m_frameEvent.Set();
- }
-
- void CApplication::Render()
-@@ -2081,12 +2069,13 @@
- m_bPresentFrame = false;
- if (!extPlayerActive && g_graphicsContext.IsFullScreenVideo() && !IsPaused())
- {
-- CSingleLock lock(m_frameMutex);
--
-- TightConditionVariable cv(m_frameCond,m_frameCount);
-- cv.wait(lock,100);
-+ uint64_t timeout = CurrentHostCounter() + CurrentHostFrequency()/10;
-+ while (!g_renderManager.HasFrame() && CurrentHostCounter() < timeout)
-+ {
-+ m_frameEvent.WaitMSec(100);
-+ }
-+ m_bPresentFrame = g_renderManager.HasFrame();
-
-- m_bPresentFrame = m_frameCount > 0;
- decrement = m_bPresentFrame;
- hasRendered = true;
- }
-@@ -2169,18 +2158,14 @@
- m_lastFrameTime = XbmcThreads::SystemClockMillis();
-
- if (flip)
-+ {
- g_graphicsContext.Flip(dirtyRegions);
-+ g_renderManager.NotifyDisplayFlip();
-+ }
- CTimeUtils::UpdateFrameTime(flip);
-
- g_renderManager.UpdateResolution();
- g_renderManager.ManageCaptures();
--
-- {
-- CSingleLock lock(m_frameMutex);
-- if(m_frameCount > 0 && decrement)
-- m_frameCount--;
-- }
-- m_frameCond.notifyAll();
- }
-
- void CApplication::SetStandAlone(bool value)
-@@ -5399,12 +5384,6 @@
- // See if we're playing a video, and are in GUI mode
- if ( IsPlayingVideo() && g_windowManager.GetActiveWindow() != WINDOW_FULLSCREEN_VIDEO)
- {
-- // Reset frame count so that timing is FPS will be correct.
-- {
-- CSingleLock lock(m_frameMutex);
-- m_frameCount = 0;
-- }
--
- // then switch to fullscreen mode
- g_windowManager.ActivateWindow(WINDOW_FULLSCREEN_VIDEO);
- return true;
-@@ -5580,7 +5559,6 @@
-
- bool CApplication::IsPresentFrame()
- {
-- CSingleLock lock(m_frameMutex);
- bool ret = m_bPresentFrame;
-
- return ret;
-diff -Naur xbmc-pvr-11.0.1/xbmc/Application.h xbmc-pvr-11.0.1.patch/xbmc/Application.h
---- xbmc-pvr-11.0.1/xbmc/Application.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/Application.h 2012-05-14 14:15:12.102219821 +0200
-@@ -351,9 +351,7 @@
- bool m_bTestMode;
- bool m_bSystemScreenSaverEnable;
-
-- int m_frameCount;
-- CCriticalSection m_frameMutex;
-- XbmcThreads::ConditionVariable m_frameCond;
-+ CEvent m_frameEvent;
-
- void Mute();
- void UnMute();
-diff -Naur xbmc-pvr-11.0.1/xbmc/ApplicationMessenger.cpp xbmc-pvr-11.0.1.patch/xbmc/ApplicationMessenger.cpp
---- xbmc-pvr-11.0.1/xbmc/ApplicationMessenger.cpp 2012-03-27 17:55:35.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/ApplicationMessenger.cpp 2012-05-14 14:15:12.106219903 +0200
-@@ -75,7 +75,7 @@
-
- using namespace std;
-
--CDelayedMessage::CDelayedMessage(ThreadMessage& msg, unsigned int delay)
-+CDelayedMessage::CDelayedMessage(ThreadMessage& msg, unsigned int delay) : CThread("CDelayedMessage")
- {
- m_msg.dwMessage = msg.dwMessage;
- m_msg.dwParam1 = msg.dwParam1;
-diff -Naur xbmc-pvr-11.0.1/xbmc/cdrip/CDDAReader.cpp xbmc-pvr-11.0.1.patch/xbmc/cdrip/CDDAReader.cpp
---- xbmc-pvr-11.0.1/xbmc/cdrip/CDDAReader.cpp 2012-03-27 17:55:35.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cdrip/CDDAReader.cpp 2012-05-14 14:15:12.106219903 +0200
-@@ -29,7 +29,7 @@
-
- #define SECTOR_COUNT 52
-
--CCDDAReader::CCDDAReader()
-+CCDDAReader::CCDDAReader() : CThread("CCDDAReader")
- {
- m_sRipBuffer[0].pbtStream = NULL;
- m_sRipBuffer[1].pbtStream = NULL;
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/DllLoader/exports/emu_kernel32.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/DllLoader/exports/emu_kernel32.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/DllLoader/exports/emu_kernel32.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/DllLoader/exports/emu_kernel32.cpp 2012-05-14 14:15:12.107219923 +0200
-@@ -240,15 +240,6 @@
- #endif
- }
-
--extern "C" BOOL WINAPI dllGetProcessTimes(HANDLE hProcess, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime)
--{
-- // since the xbox has only one process, we just take the current thread
-- HANDLE h = GetCurrentThread();
-- BOOL res = GetThreadTimes(h, lpCreationTime, lpExitTime, lpKernelTime, lpUserTime);
--
-- return res;
--}
--
- extern "C" int WINAPI dllDuplicateHandle(HANDLE hSourceProcessHandle, // handle to source process
- HANDLE hSourceHandle, // handle to duplicate
- HANDLE hTargetProcessHandle, // handle to target process
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/DllLoader/exports/emu_kernel32.h xbmc-pvr-11.0.1.patch/xbmc/cores/DllLoader/exports/emu_kernel32.h
---- xbmc-pvr-11.0.1/xbmc/cores/DllLoader/exports/emu_kernel32.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/DllLoader/exports/emu_kernel32.h 2012-05-14 14:15:12.108219943 +0200
-@@ -686,7 +686,6 @@
-
- extern "C" HGLOBAL WINAPI dllLoadResource(HMODULE module, HRSRC res);
- extern "C" HRSRC WINAPI dllFindResourceA(HMODULE module, LPCTSTR name, LPCTSTR type);
--extern "C" BOOL WINAPI dllGetProcessTimes(HANDLE hProcess, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime);
- extern "C" int WINAPI dllGetLocaleInfoA(LCID Locale, LCTYPE LCType, LPTSTR lpLCData, int cchData);
- extern "C" UINT WINAPI dllGetConsoleCP();
- extern "C" UINT WINAPI dllGetConsoleOutputCP();
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/DummyVideoPlayer.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/DummyVideoPlayer.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/DummyVideoPlayer.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/DummyVideoPlayer.cpp 2012-05-14 14:15:12.109219963 +0200
-@@ -33,7 +33,7 @@
-
- CDummyVideoPlayer::CDummyVideoPlayer(IPlayerCallback& callback)
- : IPlayer(callback),
-- CThread()
-+ CThread("CDummyVideoPlayer")
- {
- m_paused = false;
- m_clock = 0;
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp 2012-05-14 14:15:12.111220003 +0200
-@@ -325,7 +325,7 @@
- #pragma mark -
- #endif
- CMPCOutputThread::CMPCOutputThread(void *device, DllLibCrystalHD *dll, bool has_bcm70015) :
-- CThread(),
-+ CThread("CMPCOutputThread"),
- m_dll(dll),
- m_device(device),
- m_has_bcm70015(has_bcm70015),
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp 2012-05-14 14:11:52.781931376 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp 2012-05-14 14:32:47.792343580 +0200
-@@ -56,6 +56,9 @@
- #ifdef HAVE_LIBVA
- #include "VAAPI.h"
- #endif
-+#ifdef HAVE_LIBXVBA
-+#include "XVBA.h"
-+#endif
-
- using namespace boost;
-
-@@ -71,14 +74,14 @@
- while(*cur != PIX_FMT_NONE)
- {
- #ifdef HAVE_LIBVDPAU
-- if(CVDPAU::IsVDPAUFormat(*cur) && g_guiSettings.GetBool("videoplayer.usevdpau"))
-+ if(VDPAU::CDecoder::IsVDPAUFormat(*cur) && g_guiSettings.GetBool("videoplayer.usevdpau"))
- {
- if(ctx->GetHardware())
- return *cur;
-
- CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::GetFormat - Creating VDPAU(%ix%i)", avctx->width, avctx->height);
-- CVDPAU* vdp = new CVDPAU();
-- if(vdp->Open(avctx, *cur))
-+ VDPAU::CDecoder* vdp = new VDPAU::CDecoder();
-+ if(vdp->Open(avctx, *cur, ctx->m_uSurfacesCount))
- {
- ctx->SetHardware(vdp);
- return *cur;
-@@ -100,6 +103,19 @@
- dec->Release();
- }
- #endif
-+#ifdef HAVE_LIBXVBA
-+ if(*cur == PIX_FMT_XVBA_VLD && g_guiSettings.GetBool("videoplayer.usexvba"))
-+ {
-+ XVBA::CDecoder* dec = new XVBA::CDecoder();
-+ if(dec->Open(avctx, *cur))
-+ {
-+ ctx->SetHardware(dec);
-+ return *cur;
-+ }
-+ else
-+ dec->Release();
-+ }
-+#endif
- #ifdef HAVE_LIBVA
- // mpeg4 vaapi decoding is disabled
- if(*cur == PIX_FMT_VAAPI_VLD && g_guiSettings.GetBool("videoplayer.usevaapi")
-@@ -141,6 +157,7 @@
- m_iLastKeyframe = 0;
- m_dts = DVD_NOPTS_VALUE;
- m_started = false;
-+ m_decoderPts = DVD_NOPTS_VALUE;
- }
-
- CDVDVideoCodecFFmpeg::~CDVDVideoCodecFFmpeg()
-@@ -198,14 +215,26 @@
- continue;
-
- CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Creating VDPAU(%ix%i, %d)",hints.width, hints.height, hints.codec);
-- CVDPAU* vdp = new CVDPAU();
-+ VDPAU::CDecoder* vdp = new VDPAU::CDecoder();
- m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
- m_pCodecContext->codec_id = hints.codec;
- m_pCodecContext->width = hints.width;
- m_pCodecContext->height = hints.height;
- m_pCodecContext->coded_width = hints.width;
- m_pCodecContext->coded_height = hints.height;
-- if(vdp->Open(m_pCodecContext, pCodec->pix_fmts ? pCodec->pix_fmts[0] : PIX_FMT_NONE))
-+
-+ // check number of surfaces used in renderer
-+ unsigned int surfaces = 0;
-+ for(CDVDCodecOptions::iterator it = options.begin(); it != options.end(); it++)
-+ {
-+ if (it->m_name == "surfaces")
-+ {
-+ surfaces = std::atoi(it->m_value.c_str());
-+ break;
-+ }
-+ }
-+
-+ if(vdp->Open(m_pCodecContext, pCodec->pix_fmts ? pCodec->pix_fmts[0] : PIX_FMT_NONE, surfaces))
- {
- m_pHardware = vdp;
- m_pCodecContext->codec_id = CODEC_ID_NONE; // ffmpeg will complain if this has been set
-@@ -333,6 +362,14 @@
- {
- if( m_pCodecContext )
- {
-+ if (bDrop && m_pHardware && m_pHardware->CanSkipDeint())
-+ {
-+ m_requestSkipDeint = true;
-+ bDrop = false;
-+ }
-+ else
-+ m_requestSkipDeint = false;
-+
- // i don't know exactly how high this should be set
- // couldn't find any good docs on it. think it varies
- // from codec to codec on what it does
-@@ -515,6 +552,7 @@
- void CDVDVideoCodecFFmpeg::Reset()
- {
- m_started = false;
-+ m_decoderPts = DVD_NOPTS_VALUE;
- m_iLastKeyframe = m_pCodecContext->has_b_frames;
- m_dllAvCodec.avcodec_flush_buffers(m_pCodecContext);
-
-@@ -608,6 +646,22 @@
- else
- pDvdVideoPicture->pts = DVD_NOPTS_VALUE;
-
-+ if (pDvdVideoPicture->pts != DVD_NOPTS_VALUE)
-+ m_decoderPts = pDvdVideoPicture->pts;
-+ else
-+ m_decoderPts = m_dts;
-+
-+ if (m_requestSkipDeint)
-+ {
-+ pDvdVideoPicture->iFlags |= DVP_FLAG_DROPDEINT;
-+ m_skippedDeint = 1;
-+ }
-+ else
-+ m_skippedDeint = 0;
-+
-+ m_requestSkipDeint = false;
-+ pDvdVideoPicture->iFlags |= m_codecControlState;
-+
- if(!m_started)
- pDvdVideoPicture->iFlags |= DVP_FLAG_DROPPED;
-
-@@ -827,3 +881,14 @@
- else
- return 0;
- }
-+
-+void CDVDVideoCodecFFmpeg::SetSpeed(int speed)
-+{
-+ if (m_pHardware)
-+ m_pHardware->SetSpeed(speed);
-+}
-+
-+void CDVDVideoCodecFFmpeg::SetCodecControl(int state)
-+{
-+ m_codecControlState = state;
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h 2012-05-14 14:11:52.782931396 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h 2012-05-14 14:30:28.105682654 +0200
-@@ -29,7 +29,6 @@
- #include "DllSwScale.h"
- #include "DllAvFilter.h"
-
--class CVDPAU;
- class CCriticalSection;
-
- class CDVDVideoCodecFFmpeg : public CDVDVideoCodec
-@@ -45,6 +44,8 @@
- virtual bool GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture) = 0;
- virtual int Check (AVCodecContext* avctx) = 0;
- virtual void Reset () {}
-+ virtual bool CanSkipDeint() {return false; }
-+ virtual void SetSpeed(int speed) {}
- virtual const std::string Name() = 0;
- virtual CCriticalSection* Section() { return NULL; }
- };
-@@ -61,6 +62,9 @@
- virtual unsigned int SetFilters(unsigned int filters);
- virtual const char* GetName() { return m_name.c_str(); }; // m_name is never changed after open
- virtual unsigned GetConvergeCount();
-+ virtual bool GetPts(double &pts, int &skippedDeint, int &interlaced) {pts=m_decoderPts; skippedDeint=m_skippedDeint; if (m_pFrame) interlaced = m_pFrame->interlaced_frame; return true;}
-+ virtual void SetSpeed(int speed);
-+ virtual void SetCodecControl(int state);
-
- bool IsHardwareAllowed() { return !m_bSoftware; }
- IHardwareDecoder * GetHardware() { return m_pHardware; };
-@@ -118,5 +122,9 @@
- int m_iLastKeyframe;
- double m_dts;
- bool m_started;
-+ double m_decoderPts, m_decoderInterval;
-+ int m_skippedDeint;
-+ bool m_requestSkipDeint;
-+ int m_codecControlState;
- std::vector m_formats;
- };
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h 2012-05-14 14:15:12.117220123 +0200
-@@ -34,7 +34,8 @@
-
- namespace DXVA { class CSurfaceContext; }
- namespace VAAPI { struct CHolder; }
--class CVDPAU;
-+namespace VDPAU { class CVdpauRenderPicture; }
-+namespace XVBA { class CXvbaRenderPicture; }
- class COpenMax;
- class COpenMaxVideo;
- struct OpenMaxVideoBuffer;
-@@ -59,11 +60,14 @@
- DXVA::CSurfaceContext* context;
- };
- struct {
-- CVDPAU* vdpau;
-+ VDPAU::CVdpauRenderPicture* vdpau;
- };
- struct {
- VAAPI::CHolder* vaapi;
- };
-+ struct {
-+ XVBA::CXvbaRenderPicture* xvba;
-+ };
-
- struct {
- COpenMax *openMax;
-@@ -102,6 +106,7 @@
- enum EFormat {
- FMT_YUV420P = 0,
- FMT_VDPAU,
-+ FMT_VDPAU_420,
- FMT_NV12,
- FMT_UYVY,
- FMT_YUY2,
-@@ -109,6 +114,7 @@
- FMT_VAAPI,
- FMT_OMXEGL,
- FMT_CVBREF,
-+ FMT_XVBA,
- } format;
- };
-
-@@ -125,6 +131,10 @@
-
- #define DVP_FLAG_NOSKIP 0x00000010 // indicate this picture should never be dropped
- #define DVP_FLAG_DROPPED 0x00000020 // indicate that this picture has been dropped in decoder stage, will have no data
-+#define DVP_FLAG_DROPDEINT 0x00000040 // indicate that this picture was requested to have been dropped in deint stage
-+
-+#define DVP_FLAG_SKIP_PROC 0x00000100
-+#define DVP_FLAG_DRAIN 0x00000200
-
- // DVP_FLAG 0x00000100 - 0x00000f00 is in use by libmpeg2!
-
-@@ -143,6 +153,10 @@
- #define VC_PICTURE 0x00000004 // the decoder got a picture, call Decode(NULL, 0) again to parse the rest of the data
- #define VC_USERDATA 0x00000008 // the decoder found some userdata, call Decode(NULL, 0) again to parse the rest of the data
- #define VC_FLUSHED 0x00000010 // the decoder lost it's state, we need to restart decoding again
-+#define VC_DROPPED 0x00000020 // needed to identify if a picture was dropped
-+#define VC_HURRY 0x00000040
-+#define VC_SKIPPROC 0x00000080
-+
- class CDVDVideoCodec
- {
- public:
-@@ -207,7 +221,6 @@
- */
- virtual void SetDropState(bool bDrop) = 0;
-
--
- enum EFilterFlags {
- FILTER_NONE = 0x0,
- FILTER_DEINTERLACE_YADIF = 0x1, /* use first deinterlace mode */
-@@ -237,4 +250,16 @@
- {
- return 0;
- }
-+
-+ virtual bool GetPts(double &pts, int &skippedDeint, int &interlaced)
-+ {
-+ return false;
-+ }
-+
-+ virtual void SetSpeed(int speed)
-+ {
-+ return;
-+ }
-+
-+ virtual void SetCodecControl(int state) {}
- };
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in 2012-05-14 14:15:12.118220144 +0200
-@@ -17,6 +17,10 @@
- DVDVideoCodecCrystalHD.cpp \
-
- endif
-+ifeq (@USE_XVBA@,1)
-+SRCS+= XVBA.cpp \
-+
-+endif
- ifeq (@USE_VDA@,1)
- SRCS+= DVDVideoCodecVDA.cpp \
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp 2012-05-14 14:14:51.682808251 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp 2012-05-14 14:15:12.128220346 +0200
-@@ -1,5 +1,5 @@
- /*
-- * Copyright (C) 2005-2009 Team XBMC
-+ * Copyright (C) 2005-2011 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
-@@ -33,11 +33,16 @@
- #include "settings/AdvancedSettings.h"
- #include "Application.h"
- #include "utils/MathUtils.h"
-+#include "utils/TimeUtils.h"
- #include "DVDCodecs/DVDCodecUtils.h"
-+#include "cores/VideoRenderers/RenderFlags.h"
-+
-+using namespace VDPAU;
-+#define NUM_RENDER_PICS 9
-
- #define ARSIZE(x) (sizeof(x) / sizeof((x)[0]))
-
--CVDPAU::Desc decoder_profiles[] = {
-+CDecoder::Desc decoder_profiles[] = {
- {"MPEG1", VDP_DECODER_PROFILE_MPEG1},
- {"MPEG2_SIMPLE", VDP_DECODER_PROFILE_MPEG2_SIMPLE},
- {"MPEG2_MAIN", VDP_DECODER_PROFILE_MPEG2_MAIN},
-@@ -51,14 +56,16 @@
- {"MPEG4_PART2_ASP", VDP_DECODER_PROFILE_MPEG4_PART2_ASP},
- #endif
- };
--const size_t decoder_profile_count = sizeof(decoder_profiles)/sizeof(CVDPAU::Desc);
-+const size_t decoder_profile_count = sizeof(decoder_profiles)/sizeof(CDecoder::Desc);
-
--static float studioCSC[3][4] =
--{
-- { 1.0f, 0.0f, 1.57480000f,-0.78740000f},
-- { 1.0f,-0.18737736f,-0.46813736f, 0.32775736f},
-- { 1.0f, 1.85556000f, 0.0f,-0.92780000f}
--};
-+//static float studioCSC[3][4] =
-+//{
-+// { 1.0f, 0.0f, 1.57480000f,-0.78740000f},
-+// { 1.0f,-0.18737736f,-0.46813736f, 0.32775736f},
-+// { 1.0f, 1.85556000f, 0.0f,-0.92780000f}
-+//};
-+static float studioCSCKCoeffs601[3] = {0.299, 0.587, 0.114}; //BT601 {Kr, Kg, Kb}
-+static float studioCSCKCoeffs709[3] = {0.2126, 0.7152, 0.0722}; //BT709 {Kr, Kg, Kb}
-
- static struct SInterlaceMapping
- {
-@@ -69,59 +76,32 @@
- , {VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF , VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL}
- , {VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL , VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL}
- , {VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF, VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL}
--, {VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE , VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE}
-+, {VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE , VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE}
- , {VS_INTERLACEMETHOD_NONE , (VdpVideoMixerFeature)-1}
- };
-
- //since libvdpau 0.4, vdp_device_create_x11() installs a callback on the Display*,
- //if we unload libvdpau with dlclose(), we segfault on XCloseDisplay,
- //so we just keep a static handle to libvdpau around
--void* CVDPAU::dl_handle;
--
--CVDPAU::CVDPAU()
--{
-- glXBindTexImageEXT = NULL;
-- glXReleaseTexImageEXT = NULL;
-- vdp_device = VDP_INVALID_HANDLE;
-- surfaceNum = presentSurfaceNum = 0;
-- picAge.b_age = picAge.ip_age[0] = picAge.ip_age[1] = 256*256*256*64;
-- vdpauConfigured = false;
-- m_DisplayState = VDPAU_OPEN;
-- m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
-- m_mixerstep = 0;
-+void* CDecoder::dl_handle;
-
-- m_glPixmap = 0;
-- m_Pixmap = 0;
-- if (!glXBindTexImageEXT)
-- glXBindTexImageEXT = (PFNGLXBINDTEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXBindTexImageEXT");
-- if (!glXReleaseTexImageEXT)
-- glXReleaseTexImageEXT = (PFNGLXRELEASETEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXReleaseTexImageEXT");
--
-- totalAvailableOutputSurfaces = 0;
-- outputSurface = presentSurface = VDP_INVALID_HANDLE;
-- vdp_flip_target = VDP_INVALID_HANDLE;
-- vdp_flip_queue = VDP_INVALID_HANDLE;
-- vid_width = vid_height = OutWidth = OutHeight = 0;
-- memset(&outRect, 0, sizeof(VdpRect));
-- memset(&outRectVid, 0, sizeof(VdpRect));
--
-- tmpBrightness = 0;
-- tmpContrast = 0;
-- tmpDeintMode = 0;
-- tmpDeintGUI = 0;
-- tmpDeint = 0;
-- max_references = 0;
--
-- for (int i = 0; i < NUM_OUTPUT_SURFACES; i++)
-- outputSurfaces[i] = VDP_INVALID_HANDLE;
-+//-----------------------------------------------------------------------------
-+// CVDPAU
-+//-----------------------------------------------------------------------------
-
-- videoMixer = VDP_INVALID_HANDLE;
-- m_BlackBar = NULL;
-+CDecoder::CDecoder() : m_vdpauOutput(&m_inMsgEvent)
-+{
-+ m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE;
-+ m_vdpauConfig.videoSurfaces = &m_videoSurfaces;
-+ m_vdpauConfig.videoSurfaceSec = &m_videoSurfaceSec;
-
-- upScale = g_advancedSettings.m_videoVDPAUScaling;
-+ m_picAge.b_age = m_picAge.ip_age[0] = m_picAge.ip_age[1] = 256*256*256*64;
-+ m_vdpauConfigured = false;
-+ m_DisplayState = VDPAU_OPEN;
-+ m_speed = DVD_PLAYSPEED_NORMAL;
- }
-
--bool CVDPAU::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces)
-+bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces)
- {
- if(avctx->coded_width == 0
- || avctx->coded_height == 0)
-@@ -129,6 +109,8 @@
- CLog::Log(LOGWARNING,"(VDPAU) no width/height available, can't init");
- return false;
- }
-+ m_vdpauConfig.numRenderBuffers = surfaces;
-+ m_decoderThread = CThread::GetCurrentThreadId();
-
- if (!dl_handle)
- {
-@@ -140,8 +122,6 @@
- error = "dlerror() returned NULL";
-
- CLog::Log(LOGNOTICE,"(VDPAU) Unable to get handle to libvdpau: %s", error);
-- //g_application.m_guiDialogKaiToast.QueueNotification(CGUIDialogKaiToast::Error, "VDPAU", error, 10000);
--
- return false;
- }
- }
-@@ -150,8 +130,9 @@
- return false;
-
- InitVDPAUProcs();
-+ m_presentPicture = 0;
-
-- if (vdp_device != VDP_INVALID_HANDLE)
-+ if (m_vdpauConfig.vdpDevice != VDP_INVALID_HANDLE)
- {
- SpewHardwareAvailable();
-
-@@ -169,25 +150,23 @@
-
- /* attempt to create a decoder with this width/height, some sizes are not supported by hw */
- VdpStatus vdp_st;
-- vdp_st = vdp_decoder_create(vdp_device, profile, avctx->coded_width, avctx->coded_height, 5, &decoder);
-+ vdp_st = m_vdpauConfig.vdpProcs.vdp_decoder_create(m_vdpauConfig.vdpDevice, profile, avctx->coded_width, avctx->coded_height, 5, &m_vdpauConfig.vdpDecoder);
-
- if(vdp_st != VDP_STATUS_OK)
- {
-- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) checking for decoder support\n", vdp_get_error_string(vdp_st), vdp_st);
-+ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) checking for decoder support\n", m_vdpauConfig.vdpProcs.vdp_get_error_string(vdp_st), vdp_st);
- FiniVDPAUProcs();
- return false;
- }
-
-- vdp_decoder_destroy(decoder);
-+ m_vdpauConfig.vdpProcs.vdp_decoder_destroy(m_vdpauConfig.vdpDecoder);
- CheckStatus(vdp_st, __LINE__);
- }
-
-- InitCSCMatrix(avctx->coded_height);
--
- /* finally setup ffmpeg */
-- avctx->get_buffer = CVDPAU::FFGetBuffer;
-- avctx->release_buffer = CVDPAU::FFReleaseBuffer;
-- avctx->draw_horiz_band = CVDPAU::FFDrawSlice;
-+ avctx->get_buffer = CDecoder::FFGetBuffer;
-+ avctx->release_buffer = CDecoder::FFReleaseBuffer;
-+ avctx->draw_horiz_band = CDecoder::FFDrawSlice;
- avctx->slice_flags=SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD;
-
- g_Windowing.Register(this);
-@@ -196,17 +175,20 @@
- return false;
- }
-
--CVDPAU::~CVDPAU()
-+CDecoder::~CDecoder()
- {
- Close();
- }
-
--void CVDPAU::Close()
-+void CDecoder::Close()
- {
- CLog::Log(LOGNOTICE, " (VDPAU) %s", __FUNCTION__);
-
-+ CSingleLock lock(m_DecoderSection);
-+
- FiniVDPAUOutput();
- FiniVDPAUProcs();
-+ m_vdpauOutput.Dispose();
-
- while (!m_videoSurfaces.empty())
- {
-@@ -222,188 +204,118 @@
- m_dllAvUtil.Unload();
- }
-
--bool CVDPAU::MakePixmapGL()
-+long CDecoder::Release()
- {
-- int num=0;
-- int fbConfigIndex = 0;
--
-- int doubleVisAttributes[] = {
-- GLX_RENDER_TYPE, GLX_RGBA_BIT,
-- GLX_RED_SIZE, 8,
-- GLX_GREEN_SIZE, 8,
-- GLX_BLUE_SIZE, 8,
-- GLX_ALPHA_SIZE, 8,
-- GLX_DEPTH_SIZE, 8,
-- GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
-- GLX_BIND_TO_TEXTURE_RGBA_EXT, True,
-- GLX_DOUBLEBUFFER, True,
-- GLX_Y_INVERTED_EXT, True,
-- GLX_X_RENDERABLE, True,
-- None
-- };
--
-- int pixmapAttribs[] = {
-- GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
-- GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT,
-- None
-- };
-+ // check if we should do some pre-cleanup here
-+ // a second decoder might need resources
-+ if (m_vdpauConfigured == true)
-+ {
-+ CSingleLock lock(m_DecoderSection);
-+ CLog::Log(LOGNOTICE,"CVDPAU::Release pre-cleanup");
-+
-+ Message *reply;
-+ if (m_vdpauOutput.m_controlPort.SendOutMessageSync(COutputControlProtocol::PRECLEANUP,
-+ &reply,
-+ 2000))
-+ {
-+ bool success = reply->signal == COutputControlProtocol::ACC ? true : false;
-+ reply->Release();
-+ if (!success)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::%s - pre-cleanup returned error", __FUNCTION__);
-+ m_DisplayState = VDPAU_ERROR;
-+ }
-+ }
-+ else
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::%s - pre-cleanup timed out", __FUNCTION__);
-+ m_DisplayState = VDPAU_ERROR;
-+ }
-
-- GLXFBConfig *fbConfigs;
-- fbConfigs = glXChooseFBConfig(m_Display, DefaultScreen(m_Display), doubleVisAttributes, &num);
-- if (fbConfigs==NULL)
-- {
-- CLog::Log(LOGERROR, "GLX Error: MakePixmap: No compatible framebuffers found");
-- return false;
-+ for(unsigned int i = 0; i < m_videoSurfaces.size(); ++i)
-+ {
-+ vdpau_render_state *render = m_videoSurfaces[i];
-+ if (render->surface != VDP_INVALID_HANDLE && !(render->state & FF_VDPAU_STATE_USED_FOR_RENDER))
-+ {
-+ m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(render->surface);
-+ render->surface = VDP_INVALID_HANDLE;
-+ }
-+ }
- }
-- CLog::Log(LOGDEBUG, "Found %d fbconfigs.", num);
-- fbConfigIndex = 0;
-- CLog::Log(LOGDEBUG, "Using fbconfig index %d.", fbConfigIndex);
-+ IHardwareDecoder::Release();
-+}
-
-- m_glPixmap = glXCreatePixmap(m_Display, fbConfigs[fbConfigIndex], m_Pixmap, pixmapAttribs);
-+long CDecoder::ReleasePicReference()
-+{
-+ return IHardwareDecoder::Release();
-+}
-
-- if (!m_glPixmap)
-+void CDecoder::SetWidthHeight(int width, int height)
-+{
-+ int vdpauMaxHeight = g_advancedSettings.m_videoVDPAUmaxHeight;
-+ if (vdpauMaxHeight > 0 && height > vdpauMaxHeight)
- {
-- CLog::Log(LOGINFO, "GLX Error: Could not create Pixmap");
-- XFree(fbConfigs);
-- return false;
-+ width = MathUtils::round_int((double)width * vdpauMaxHeight / height);
-+ height = vdpauMaxHeight;
- }
-- XFree(fbConfigs);
-
-- return true;
--}
-+ m_vdpauConfig.upscale = g_advancedSettings.m_videoVDPAUScaling;
-
--bool CVDPAU::MakePixmap(int width, int height)
--{
- //pick the smallest dimensions, so we downscale with vdpau and upscale with opengl when appropriate
- //this requires the least amount of gpu memory bandwidth
-- if (g_graphicsContext.GetWidth() < width || g_graphicsContext.GetHeight() < height || upScale)
-+ if (g_graphicsContext.GetWidth() < width || g_graphicsContext.GetHeight() < height || m_vdpauConfig.upscale >= 0)
- {
- //scale width to desktop size if the aspect ratio is the same or bigger than the desktop
- if ((double)height * g_graphicsContext.GetWidth() / width <= (double)g_graphicsContext.GetHeight())
- {
-- OutWidth = g_graphicsContext.GetWidth();
-- OutHeight = MathUtils::round_int((double)height * g_graphicsContext.GetWidth() / width);
-+ m_vdpauConfig.outWidth = g_graphicsContext.GetWidth();
-+ m_vdpauConfig.outHeight = MathUtils::round_int((double)height * g_graphicsContext.GetWidth() / width);
- }
- else //scale height to the desktop size if the aspect ratio is smaller than the desktop
- {
-- OutHeight = g_graphicsContext.GetHeight();
-- OutWidth = MathUtils::round_int((double)width * g_graphicsContext.GetHeight() / height);
-+ m_vdpauConfig.outHeight = g_graphicsContext.GetHeight();
-+ m_vdpauConfig.outWidth = MathUtils::round_int((double)width * g_graphicsContext.GetHeight() / height);
- }
- }
- else
- { //let opengl scale
-- OutWidth = width;
-- OutHeight = height;
-- }
--
-- CLog::Log(LOGNOTICE,"Creating %ix%i pixmap", OutWidth, OutHeight);
--
-- // Get our window attribs.
-- XWindowAttributes wndattribs;
-- XGetWindowAttributes(m_Display, DefaultRootWindow(m_Display), &wndattribs); // returns a status but I don't know what success is
--
-- m_Pixmap = XCreatePixmap(m_Display,
-- DefaultRootWindow(m_Display),
-- OutWidth,
-- OutHeight,
-- wndattribs.depth);
-- if (!m_Pixmap)
-- {
-- CLog::Log(LOGERROR, "GLX Error: MakePixmap: Unable to create XPixmap");
-- return false;
-- }
--
-- XGCValues values = {};
-- GC xgc;
-- values.foreground = BlackPixel (m_Display, DefaultScreen (m_Display));
-- xgc = XCreateGC(m_Display, m_Pixmap, GCForeground, &values);
-- XFillRectangle(m_Display, m_Pixmap, xgc, 0, 0, OutWidth, OutHeight);
-- XFreeGC(m_Display, xgc);
--
-- if(!MakePixmapGL())
-- return false;
--
-- return true;
--}
--
--void CVDPAU::BindPixmap()
--{
-- CSharedLock lock(m_DecoderSection);
--
-- { CSharedLock dLock(m_DisplaySection);
-- if (m_DisplayState != VDPAU_OPEN)
-- return;
-- }
--
-- if (m_glPixmap)
-- {
-- if(presentSurface != VDP_INVALID_HANDLE)
-- {
-- VdpPresentationQueueStatus status;
-- VdpTime time;
-- VdpStatus vdp_st;
-- vdp_st = vdp_presentation_queue_query_surface_status(
-- vdp_flip_queue, presentSurface, &status, &time);
-- CheckStatus(vdp_st, __LINE__);
-- while(status != VDP_PRESENTATION_QUEUE_STATUS_VISIBLE && vdp_st == VDP_STATUS_OK)
-- {
-- Sleep(1);
-- vdp_st = vdp_presentation_queue_query_surface_status(
-- vdp_flip_queue, presentSurface, &status, &time);
-- CheckStatus(vdp_st, __LINE__);
-- }
-- }
--
-- glXBindTexImageEXT(m_Display, m_glPixmap, GLX_FRONT_LEFT_EXT, NULL);
-- }
-- else CLog::Log(LOGERROR,"(VDPAU) BindPixmap called without valid pixmap");
--}
--
--void CVDPAU::ReleasePixmap()
--{
-- CSharedLock lock(m_DecoderSection);
--
-- { CSharedLock dLock(m_DisplaySection);
-- if (m_DisplayState != VDPAU_OPEN)
-- return;
-- }
--
-- if (m_glPixmap)
-- {
-- glXReleaseTexImageEXT(m_Display, m_glPixmap, GLX_FRONT_LEFT_EXT);
-+ m_vdpauConfig.outWidth = width;
-+ m_vdpauConfig.outHeight = height;
- }
-- else CLog::Log(LOGERROR,"(VDPAU) ReleasePixmap called without valid pixmap");
-+ CLog::Log(LOGDEBUG, "CVDPAU::SetWidthHeight Setting OutWidth: %i OutHeight: %i vdpauMaxHeight: %i", m_vdpauConfig.outWidth, m_vdpauConfig.outHeight, vdpauMaxHeight);
- }
-
--void CVDPAU::OnLostDevice()
-+void CDecoder::OnLostDevice()
- {
- CLog::Log(LOGNOTICE,"CVDPAU::OnLostDevice event");
-
-- CExclusiveLock lock(m_DecoderSection);
-+ CSingleLock lock(m_DecoderSection);
- FiniVDPAUOutput();
- FiniVDPAUProcs();
-
- m_DisplayState = VDPAU_LOST;
-+ lock.Leave();
- m_DisplayEvent.Reset();
- }
-
--void CVDPAU::OnResetDevice()
-+void CDecoder::OnResetDevice()
- {
- CLog::Log(LOGNOTICE,"CVDPAU::OnResetDevice event");
-
-- CExclusiveLock lock(m_DisplaySection);
-+ CSingleLock lock(m_DecoderSection);
- if (m_DisplayState == VDPAU_LOST)
- {
- m_DisplayState = VDPAU_RESET;
-+ lock.Leave();
- m_DisplayEvent.Set();
- }
- }
-
--int CVDPAU::Check(AVCodecContext* avctx)
-+int CDecoder::Check(AVCodecContext* avctx)
- {
- EDisplayState state;
-
-- { CSharedLock lock(m_DisplaySection);
-+ { CSingleLock lock(m_DecoderSection);
- state = m_DisplayState;
- }
-
-@@ -417,16 +329,13 @@
- }
- else
- {
-- CSharedLock lock(m_DisplaySection);
-+ CSingleLock lock(m_DecoderSection);
- state = m_DisplayState;
- }
- }
- if (state == VDPAU_RESET || state == VDPAU_ERROR)
- {
-- CLog::Log(LOGNOTICE,"Attempting recovery");
--
-- CSingleLock gLock(g_graphicsContext);
-- CExclusiveLock lock(m_DecoderSection);
-+ CSingleLock lock(m_DecoderSection);
-
- FiniVDPAUOutput();
- FiniVDPAUProcs();
-@@ -441,7 +350,7 @@
- return 0;
- }
-
--bool CVDPAU::IsVDPAUFormat(PixelFormat format)
-+bool CDecoder::IsVDPAUFormat(PixelFormat format)
- {
- if ((format >= PIX_FMT_VDPAU_H264) && (format <= PIX_FMT_VDPAU_VC1)) return true;
- #if (defined PIX_FMT_VDPAU_MPEG4_IN_AVUTIL)
-@@ -450,90 +359,28 @@
- else return false;
- }
-
--void CVDPAU::CheckFeatures()
--{
-- if (videoMixer == VDP_INVALID_HANDLE)
-- {
-- CLog::Log(LOGNOTICE, " (VDPAU) Creating the video mixer");
-- // Creation of VideoMixer.
-- VdpVideoMixerParameter parameters[] = {
-- VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH,
-- VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT,
-- VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE
-- };
--
-- void const * parameter_values[] = {
-- &surface_width,
-- &surface_height,
-- &vdp_chroma_type
-- };
--
-- tmpBrightness = 0;
-- tmpContrast = 0;
-- tmpNoiseReduction = 0;
-- tmpSharpness = 0;
--
-- VdpStatus vdp_st = VDP_STATUS_ERROR;
-- vdp_st = vdp_video_mixer_create(vdp_device,
-- m_feature_count,
-- m_features,
-- ARSIZE(parameters),
-- parameters,
-- parameter_values,
-- &videoMixer);
-- CheckStatus(vdp_st, __LINE__);
--
-- SetHWUpscaling();
-- }
--
-- if (tmpBrightness != g_settings.m_currentVideoSettings.m_Brightness ||
-- tmpContrast != g_settings.m_currentVideoSettings.m_Contrast)
-- {
-- SetColor();
-- tmpBrightness = g_settings.m_currentVideoSettings.m_Brightness;
-- tmpContrast = g_settings.m_currentVideoSettings.m_Contrast;
-- }
-- if (tmpNoiseReduction != g_settings.m_currentVideoSettings.m_NoiseReduction)
-- {
-- tmpNoiseReduction = g_settings.m_currentVideoSettings.m_NoiseReduction;
-- SetNoiseReduction();
-- }
-- if (tmpSharpness != g_settings.m_currentVideoSettings.m_Sharpness)
-- {
-- tmpSharpness = g_settings.m_currentVideoSettings.m_Sharpness;
-- SetSharpness();
-- }
-- if ( tmpDeintMode != g_settings.m_currentVideoSettings.m_DeinterlaceMode ||
-- tmpDeintGUI != g_settings.m_currentVideoSettings.m_InterlaceMethod ||
-- (tmpDeintGUI == VS_INTERLACEMETHOD_AUTO && tmpDeint != AutoInterlaceMethod()))
-- {
-- tmpDeintMode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
-- tmpDeintGUI = g_settings.m_currentVideoSettings.m_InterlaceMethod;
-- if (tmpDeintGUI == VS_INTERLACEMETHOD_AUTO)
-- tmpDeint = AutoInterlaceMethod();
-- else
-- tmpDeint = tmpDeintGUI;
--
-- SetDeinterlacing();
-- }
--}
--
--bool CVDPAU::Supports(VdpVideoMixerFeature feature)
-+bool CDecoder::Supports(VdpVideoMixerFeature feature)
- {
-- for(int i = 0; i < m_feature_count; i++)
-+ for(int i = 0; i < m_vdpauConfig.featureCount; i++)
- {
-- if(m_features[i] == feature)
-+ if(m_vdpauConfig.vdpFeatures[i] == feature)
- return true;
- }
- return false;
- }
-
--bool CVDPAU::Supports(EINTERLACEMETHOD method)
-+bool CDecoder::Supports(EINTERLACEMETHOD method)
- {
- if(method == VS_INTERLACEMETHOD_VDPAU_BOB
- || method == VS_INTERLACEMETHOD_AUTO)
- return true;
-
-+ if (g_guiSettings.GetBool("videoplayer.usevdpauinteropyuv"))
-+ {
-+ if (method == VS_INTERLACEMETHOD_RENDER_BOB)
-+ return true;
-+ }
-+
- for(SInterlaceMapping* p = g_interlace_mapping; p->method != VS_INTERLACEMETHOD_NONE; p++)
- {
- if(p->method == method)
-@@ -542,149 +389,12 @@
- return false;
- }
-
--EINTERLACEMETHOD CVDPAU::AutoInterlaceMethod()
--{
-- return VS_INTERLACEMETHOD_VDPAU_TEMPORAL;
--}
--
--void CVDPAU::SetColor()
--{
-- VdpStatus vdp_st;
--
-- if (tmpBrightness != g_settings.m_currentVideoSettings.m_Brightness)
-- m_Procamp.brightness = (float)((g_settings.m_currentVideoSettings.m_Brightness)-50) / 100;
-- if (tmpContrast != g_settings.m_currentVideoSettings.m_Contrast)
-- m_Procamp.contrast = (float)((g_settings.m_currentVideoSettings.m_Contrast)+50) / 100;
--
-- if(vid_height >= 600 || vid_width > 1024)
-- vdp_st = vdp_generate_csc_matrix(&m_Procamp, VDP_COLOR_STANDARD_ITUR_BT_709, &m_CSCMatrix);
-- else
-- vdp_st = vdp_generate_csc_matrix(&m_Procamp, VDP_COLOR_STANDARD_ITUR_BT_601, &m_CSCMatrix);
--
-- VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX };
-- if (g_guiSettings.GetBool("videoplayer.vdpaustudiolevel"))
-- {
-- void const * pm_CSCMatix[] = { &studioCSC };
-- vdp_st = vdp_video_mixer_set_attribute_values(videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix);
-- }
-- else
-- {
-- void const * pm_CSCMatix[] = { &m_CSCMatrix };
-- vdp_st = vdp_video_mixer_set_attribute_values(videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix);
-- }
-- CheckStatus(vdp_st, __LINE__);
--}
--
--void CVDPAU::SetNoiseReduction()
--{
-- if(!Supports(VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION))
-- return;
--
-- VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION };
-- VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL };
-- VdpStatus vdp_st;
--
-- if (!g_settings.m_currentVideoSettings.m_NoiseReduction)
-- {
-- VdpBool enabled[]= {0};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- CheckStatus(vdp_st, __LINE__);
-- return;
-- }
-- VdpBool enabled[]={1};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- CheckStatus(vdp_st, __LINE__);
-- void* nr[] = { &g_settings.m_currentVideoSettings.m_NoiseReduction };
-- CLog::Log(LOGNOTICE,"Setting Noise Reduction to %f",g_settings.m_currentVideoSettings.m_NoiseReduction);
-- vdp_st = vdp_video_mixer_set_attribute_values(videoMixer, ARSIZE(attributes), attributes, nr);
-- CheckStatus(vdp_st, __LINE__);
--}
--
--void CVDPAU::SetSharpness()
--{
-- if(!Supports(VDP_VIDEO_MIXER_FEATURE_SHARPNESS))
-- return;
--
-- VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_SHARPNESS };
-- VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL };
-- VdpStatus vdp_st;
--
-- if (!g_settings.m_currentVideoSettings.m_Sharpness)
-- {
-- VdpBool enabled[]={0};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- CheckStatus(vdp_st, __LINE__);
-- return;
-- }
-- VdpBool enabled[]={1};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- CheckStatus(vdp_st, __LINE__);
-- void* sh[] = { &g_settings.m_currentVideoSettings.m_Sharpness };
-- CLog::Log(LOGNOTICE,"Setting Sharpness to %f",g_settings.m_currentVideoSettings.m_Sharpness);
-- vdp_st = vdp_video_mixer_set_attribute_values(videoMixer, ARSIZE(attributes), attributes, sh);
-- CheckStatus(vdp_st, __LINE__);
--}
--
--void CVDPAU::SetHWUpscaling()
--{
--#ifdef VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1
-- if(!Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1) || !upScale)
-- return;
--
-- VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 };
-- VdpStatus vdp_st;
-- VdpBool enabled[]={1};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- CheckStatus(vdp_st, __LINE__);
--#endif
--}
--
--void CVDPAU::SetDeinterlacing()
-+EINTERLACEMETHOD CDecoder::AutoInterlaceMethod()
- {
-- VdpStatus vdp_st;
-- EDEINTERLACEMODE mode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
-- EINTERLACEMETHOD method = g_settings.m_currentVideoSettings.m_InterlaceMethod;
-- if (method == VS_INTERLACEMETHOD_AUTO)
-- method = AutoInterlaceMethod();
--
-- VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL,
-- VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL,
-- VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE };
-- if (mode == VS_DEINTERLACEMODE_OFF)
-- {
-- VdpBool enabled[]={0,0,0};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- }
-- else
-- {
-- if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF)
-- {
-- VdpBool enabled[]={1,0,0};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- }
-- else if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF)
-- {
-- VdpBool enabled[]={1,1,0};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- }
-- else if (method == VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE)
-- {
-- VdpBool enabled[]={1,0,1};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- }
-- else
-- {
-- VdpBool enabled[]={0,0,0};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- }
-- }
--
-- CheckStatus(vdp_st, __LINE__);
-+ return VS_INTERLACEMETHOD_RENDER_BOB;
- }
-
--void CVDPAU::InitVDPAUProcs()
-+void CDecoder::InitVDPAUProcs()
- {
- char* error;
-
-@@ -694,151 +404,115 @@
- if (error)
- {
- CLog::Log(LOGERROR,"(VDPAU) - %s in %s",error,__FUNCTION__);
-- vdp_device = VDP_INVALID_HANDLE;
--
-- //g_application.m_guiDialogKaiToast.QueueNotification(CGUIDialogKaiToast::Error, "VDPAU", error, 10000);
--
-+ m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE;
- return;
- }
-
- if (dl_vdp_device_create_x11)
- {
-- CSingleLock lock(g_graphicsContext);
-- m_Display = g_Windowing.GetDisplay();
-+ m_Display = XOpenDisplay(NULL);
- }
-
- int mScreen = DefaultScreen(m_Display);
- VdpStatus vdp_st;
-
- // Create Device
-- // tested on 64bit Ubuntu 11.10 and it deadlocked without this
-- XLockDisplay(m_Display);
- vdp_st = dl_vdp_device_create_x11(m_Display, //x_display,
- mScreen, //x_screen,
-- &vdp_device,
-- &vdp_get_proc_address);
-- XUnlockDisplay(m_Display);
-+ &m_vdpauConfig.vdpDevice,
-+ &m_vdpauConfig.vdpProcs.vdp_get_proc_address);
-
-- CLog::Log(LOGNOTICE,"vdp_device = 0x%08x vdp_st = 0x%08x",vdp_device,vdp_st);
-+ CLog::Log(LOGNOTICE,"vdp_device = 0x%08x vdp_st = 0x%08x",m_vdpauConfig.vdpDevice,vdp_st);
- if (vdp_st != VDP_STATUS_OK)
- {
- CLog::Log(LOGERROR,"(VDPAU) unable to init VDPAU - vdp_st = 0x%x. Falling back.",vdp_st);
-- vdp_device = VDP_INVALID_HANDLE;
-+ m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE;
- return;
- }
-
-- if (vdp_st != VDP_STATUS_OK)
-- {
-- CLog::Log(LOGERROR,"(VDPAU) - Unable to create X11 device in %s",__FUNCTION__);
-- vdp_device = VDP_INVALID_HANDLE;
-- return;
-- }
- #define VDP_PROC(id, proc) \
- do { \
-- vdp_st = vdp_get_proc_address(vdp_device, id, (void**)&proc); \
-+ vdp_st = m_vdpauConfig.vdpProcs.vdp_get_proc_address(m_vdpauConfig.vdpDevice, id, (void**)&proc); \
- CheckStatus(vdp_st, __LINE__); \
- } while(0);
-
-- VDP_PROC(VDP_FUNC_ID_GET_ERROR_STRING , vdp_get_error_string);
-- VDP_PROC(VDP_FUNC_ID_DEVICE_DESTROY , vdp_device_destroy);
-- VDP_PROC(VDP_FUNC_ID_GENERATE_CSC_MATRIX , vdp_generate_csc_matrix);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_CREATE , vdp_video_surface_create);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY , vdp_video_surface_destroy);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , vdp_video_surface_put_bits_y_cb_cr);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR , vdp_video_surface_get_bits_y_cb_cr);
-- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR , vdp_output_surface_put_bits_y_cb_cr);
-- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE , vdp_output_surface_put_bits_native);
-- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , vdp_output_surface_create);
-- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , vdp_output_surface_destroy);
-- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE , vdp_output_surface_get_bits_native);
-- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, vdp_output_surface_render_output_surface);
-- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED , vdp_output_surface_put_bits_indexed);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_CREATE , vdp_video_mixer_create);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES , vdp_video_mixer_set_feature_enables);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_DESTROY , vdp_video_mixer_destroy);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_RENDER , vdp_video_mixer_render);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES , vdp_video_mixer_set_attribute_values);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT , vdp_video_mixer_query_parameter_support);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT , vdp_video_mixer_query_feature_support);
-- VDP_PROC(VDP_FUNC_ID_DECODER_CREATE , vdp_decoder_create);
-- VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , vdp_decoder_destroy);
-- VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , vdp_decoder_render);
-- VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , vdp_decoder_query_caps);
-- VDP_PROC(VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER , vdp_preemption_callback_register);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY , vdp_presentation_queue_target_destroy);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE , vdp_presentation_queue_create);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY , vdp_presentation_queue_destroy);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY , vdp_presentation_queue_display);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, vdp_presentation_queue_block_until_surface_idle);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 , vdp_presentation_queue_target_create_x11);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS , vdp_presentation_queue_query_surface_status);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME , vdp_presentation_queue_get_time);
--
-+ VDP_PROC(VDP_FUNC_ID_GET_ERROR_STRING , m_vdpauConfig.vdpProcs.vdp_get_error_string);
-+ VDP_PROC(VDP_FUNC_ID_DEVICE_DESTROY , m_vdpauConfig.vdpProcs.vdp_device_destroy);
-+ VDP_PROC(VDP_FUNC_ID_GENERATE_CSC_MATRIX , m_vdpauConfig.vdpProcs.vdp_generate_csc_matrix);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_CREATE , m_vdpauConfig.vdpProcs.vdp_video_surface_create);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY , m_vdpauConfig.vdpProcs.vdp_video_surface_destroy);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , m_vdpauConfig.vdpProcs.vdp_video_surface_put_bits_y_cb_cr);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR , m_vdpauConfig.vdpProcs.vdp_video_surface_get_bits_y_cb_cr);
-+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR , m_vdpauConfig.vdpProcs.vdp_output_surface_put_bits_y_cb_cr);
-+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE , m_vdpauConfig.vdpProcs.vdp_output_surface_put_bits_native);
-+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , m_vdpauConfig.vdpProcs.vdp_output_surface_create);
-+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , m_vdpauConfig.vdpProcs.vdp_output_surface_destroy);
-+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE , m_vdpauConfig.vdpProcs.vdp_output_surface_get_bits_native);
-+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, m_vdpauConfig.vdpProcs.vdp_output_surface_render_output_surface);
-+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED , m_vdpauConfig.vdpProcs.vdp_output_surface_put_bits_indexed);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_CREATE , m_vdpauConfig.vdpProcs.vdp_video_mixer_create);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES , m_vdpauConfig.vdpProcs.vdp_video_mixer_set_feature_enables);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_DESTROY , m_vdpauConfig.vdpProcs.vdp_video_mixer_destroy);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_RENDER , m_vdpauConfig.vdpProcs.vdp_video_mixer_render);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES , m_vdpauConfig.vdpProcs.vdp_video_mixer_set_attribute_values);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT , m_vdpauConfig.vdpProcs.vdp_video_mixer_query_parameter_support);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT , m_vdpauConfig.vdpProcs.vdp_video_mixer_query_feature_support);
-+ VDP_PROC(VDP_FUNC_ID_DECODER_CREATE , m_vdpauConfig.vdpProcs.vdp_decoder_create);
-+ VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , m_vdpauConfig.vdpProcs.vdp_decoder_destroy);
-+ VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , m_vdpauConfig.vdpProcs.vdp_decoder_render);
-+ VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , m_vdpauConfig.vdpProcs.vdp_decoder_query_caps);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY , m_vdpauConfig.vdpProcs.vdp_presentation_queue_target_destroy);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE , m_vdpauConfig.vdpProcs.vdp_presentation_queue_create);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY , m_vdpauConfig.vdpProcs.vdp_presentation_queue_destroy);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY , m_vdpauConfig.vdpProcs.vdp_presentation_queue_display);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, m_vdpauConfig.vdpProcs.vdp_presentation_queue_block_until_surface_idle);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 , m_vdpauConfig.vdpProcs.vdp_presentation_queue_target_create_x11);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS , m_vdpauConfig.vdpProcs.vdp_presentation_queue_query_surface_status);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME , m_vdpauConfig.vdpProcs.vdp_presentation_queue_get_time);
-+
- #undef VDP_PROC
-
- // set all vdpau resources to invalid
-- vdp_flip_target = VDP_INVALID_HANDLE;
-- vdp_flip_queue = VDP_INVALID_HANDLE;
-- videoMixer = VDP_INVALID_HANDLE;
-- totalAvailableOutputSurfaces = 0;
-- presentSurface = VDP_INVALID_HANDLE;
-- outputSurface = VDP_INVALID_HANDLE;
-- for (int i = 0; i < NUM_OUTPUT_SURFACES; i++)
-- outputSurfaces[i] = VDP_INVALID_HANDLE;
--
-- m_vdpauOutputMethod = OUTPUT_NONE;
--
-- CExclusiveLock lock(m_DisplaySection);
- m_DisplayState = VDPAU_OPEN;
-- vdpauConfigured = false;
-+ m_vdpauConfigured = false;
- }
-
--void CVDPAU::FiniVDPAUProcs()
-+void CDecoder::FiniVDPAUProcs()
- {
-- if (vdp_device == VDP_INVALID_HANDLE) return;
-+ if (m_vdpauConfig.vdpDevice == VDP_INVALID_HANDLE) return;
-
- VdpStatus vdp_st;
-- vdp_st = vdp_device_destroy(vdp_device);
-+ vdp_st = m_vdpauConfig.vdpProcs.vdp_device_destroy(m_vdpauConfig.vdpDevice);
- CheckStatus(vdp_st, __LINE__);
-- vdp_device = VDP_INVALID_HANDLE;
-- vdpauConfigured = false;
-+ m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE;
- }
-
--void CVDPAU::InitCSCMatrix(int Height)
-+void CDecoder::FiniVDPAUOutput()
- {
-+ if (m_vdpauConfig.vdpDevice == VDP_INVALID_HANDLE || !m_vdpauConfigured) return;
-+
-+ CLog::Log(LOGNOTICE, " (VDPAU) %s", __FUNCTION__);
-+
-+ // uninit output
-+ m_vdpauOutput.Dispose();
-+ m_vdpauConfigured = false;
-+
- VdpStatus vdp_st;
-- m_Procamp.struct_version = VDP_PROCAMP_VERSION;
-- m_Procamp.brightness = 0.0;
-- m_Procamp.contrast = 1.0;
-- m_Procamp.saturation = 1.0;
-- m_Procamp.hue = 0;
-- vdp_st = vdp_generate_csc_matrix(&m_Procamp,
-- (Height < 720)? VDP_COLOR_STANDARD_ITUR_BT_601 : VDP_COLOR_STANDARD_ITUR_BT_709,
-- &m_CSCMatrix);
-- CheckStatus(vdp_st, __LINE__);
--}
--
--void CVDPAU::FiniVDPAUOutput()
--{
-- FiniOutputMethod();
--
-- if (vdp_device == VDP_INVALID_HANDLE || !vdpauConfigured) return;
-
-- CLog::Log(LOGNOTICE, " (VDPAU) %s", __FUNCTION__);
--
-- VdpStatus vdp_st;
--
-- vdp_st = vdp_decoder_destroy(decoder);
-+ vdp_st = m_vdpauConfig.vdpProcs.vdp_decoder_destroy(m_vdpauConfig.vdpDecoder);
- if (CheckStatus(vdp_st, __LINE__))
- return;
-- decoder = VDP_INVALID_HANDLE;
-+ m_vdpauConfig.vdpDecoder = VDP_INVALID_HANDLE;
-
-- for (unsigned int i = 0; i < m_videoSurfaces.size(); ++i)
-+ CSingleLock lock(m_videoSurfaceSec);
-+ CLog::Log(LOGDEBUG, "CVDPAU::FiniVDPAUOutput destroying %d video surfaces", (int)m_videoSurfaces.size());
-+
-+ for(unsigned int i = 0; i < m_videoSurfaces.size(); ++i)
- {
- vdpau_render_state *render = m_videoSurfaces[i];
- if (render->surface != VDP_INVALID_HANDLE)
- {
-- vdp_st = vdp_video_surface_destroy(render->surface);
-+ vdp_st = m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(render->surface);
- render->surface = VDP_INVALID_HANDLE;
- }
- if (CheckStatus(vdp_st, __LINE__))
-@@ -846,8 +520,7 @@
- }
- }
-
--
--void CVDPAU::ReadFormatOf( PixelFormat fmt
-+void CDecoder::ReadFormatOf( PixelFormat fmt
- , VdpDecoderProfile &vdp_decoder_profile
- , VdpChromaType &vdp_chroma_type)
- {
-@@ -885,170 +558,78 @@
- }
- }
-
--
--bool CVDPAU::ConfigVDPAU(AVCodecContext* avctx, int ref_frames)
-+bool CDecoder::ConfigVDPAU(AVCodecContext* avctx, int ref_frames)
- {
- FiniVDPAUOutput();
-
- VdpStatus vdp_st;
- VdpDecoderProfile vdp_decoder_profile;
-- vid_width = avctx->width;
-- vid_height = avctx->height;
-- surface_width = avctx->coded_width;
-- surface_height = avctx->coded_height;
--
-- past[1] = past[0] = current = future = NULL;
-- CLog::Log(LOGNOTICE, " (VDPAU) screenWidth:%i vidWidth:%i surfaceWidth:%i",OutWidth,vid_width,surface_width);
-- CLog::Log(LOGNOTICE, " (VDPAU) screenHeight:%i vidHeight:%i surfaceHeight:%i",OutHeight,vid_height,surface_height);
-- ReadFormatOf(avctx->pix_fmt, vdp_decoder_profile, vdp_chroma_type);
-+
-+ m_vdpauConfig.vidWidth = avctx->width;
-+ m_vdpauConfig.vidHeight = avctx->height;
-+ m_vdpauConfig.surfaceWidth = avctx->coded_width;
-+ m_vdpauConfig.surfaceHeight = avctx->coded_height;
-+
-+ SetWidthHeight(avctx->width,avctx->height);
-+
-+ CLog::Log(LOGNOTICE, " (VDPAU) screenWidth:%i vidWidth:%i surfaceWidth:%i",m_vdpauConfig.outWidth,m_vdpauConfig.vidWidth,m_vdpauConfig.surfaceWidth);
-+ CLog::Log(LOGNOTICE, " (VDPAU) screenHeight:%i vidHeight:%i surfaceHeight:%i",m_vdpauConfig.outHeight,m_vdpauConfig.vidHeight,m_vdpauConfig.surfaceHeight);
-+
-+ ReadFormatOf(avctx->pix_fmt, vdp_decoder_profile, m_vdpauConfig.vdpChromaType);
-
- if(avctx->pix_fmt == PIX_FMT_VDPAU_H264)
- {
-- max_references = ref_frames;
-- if (max_references > 16) max_references = 16;
-- if (max_references < 5) max_references = 5;
-+ m_vdpauConfig.maxReferences = ref_frames;
-+ if (m_vdpauConfig.maxReferences > 16) m_vdpauConfig.maxReferences = 16;
-+ if (m_vdpauConfig.maxReferences < 5) m_vdpauConfig.maxReferences = 5;
- }
- else
-- max_references = 2;
-+ m_vdpauConfig.maxReferences = 2;
-
-- vdp_st = vdp_decoder_create(vdp_device,
-+ vdp_st = m_vdpauConfig.vdpProcs.vdp_decoder_create(m_vdpauConfig.vdpDevice,
- vdp_decoder_profile,
-- surface_width,
-- surface_height,
-- max_references,
-- &decoder);
-- if (CheckStatus(vdp_st, __LINE__))
-- return false;
--
-- m_vdpauOutputMethod = OUTPUT_NONE;
--
-- vdpauConfigured = true;
-- return true;
--}
--
--bool CVDPAU::ConfigOutputMethod(AVCodecContext *avctx, AVFrame *pFrame)
--{
-- VdpStatus vdp_st;
--
-- if (m_vdpauOutputMethod == OUTPUT_PIXMAP)
-- return true;
--
-- FiniOutputMethod();
--
-- MakePixmap(avctx->width,avctx->height);
--
-- vdp_st = vdp_presentation_queue_target_create_x11(vdp_device,
-- m_Pixmap, //x_window,
-- &vdp_flip_target);
-- if (CheckStatus(vdp_st, __LINE__))
-- return false;
--
-- vdp_st = vdp_presentation_queue_create(vdp_device,
-- vdp_flip_target,
-- &vdp_flip_queue);
-+ m_vdpauConfig.surfaceWidth,
-+ m_vdpauConfig.surfaceHeight,
-+ m_vdpauConfig.maxReferences,
-+ &m_vdpauConfig.vdpDecoder);
- if (CheckStatus(vdp_st, __LINE__))
- return false;
-
-- totalAvailableOutputSurfaces = 0;
--
-- int tmpMaxOutputSurfaces = NUM_OUTPUT_SURFACES;
-- if (vid_width == FULLHD_WIDTH)
-- tmpMaxOutputSurfaces = NUM_OUTPUT_SURFACES_FOR_FULLHD;
--
-- // Creation of outputSurfaces
-- for (int i = 0; i < NUM_OUTPUT_SURFACES && i < tmpMaxOutputSurfaces; i++)
-- {
-- vdp_st = vdp_output_surface_create(vdp_device,
-- VDP_RGBA_FORMAT_B8G8R8A8,
-- OutWidth,
-- OutHeight,
-- &outputSurfaces[i]);
-- if (CheckStatus(vdp_st, __LINE__))
-+ // initialize output
-+ CSingleLock lock(g_graphicsContext);
-+ m_vdpauConfig.stats = &m_bufferStats;
-+ m_vdpauConfig.vdpau = this;
-+ m_bufferStats.Reset();
-+ m_vdpauOutput.Start();
-+ Message *reply;
-+ if (m_vdpauOutput.m_controlPort.SendOutMessageSync(COutputControlProtocol::INIT,
-+ &reply,
-+ 2000,
-+ &m_vdpauConfig,
-+ sizeof(m_vdpauConfig)))
-+ {
-+ bool success = reply->signal == COutputControlProtocol::ACC ? true : false;
-+ reply->Release();
-+ if (!success)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::%s - vdpau output returned error", __FUNCTION__);
-+ m_vdpauOutput.Dispose();
- return false;
-- totalAvailableOutputSurfaces++;
-- }
-- CLog::Log(LOGNOTICE, " (VDPAU) Total Output Surfaces Available: %i of a max (tmp: %i const: %i)",
-- totalAvailableOutputSurfaces,
-- tmpMaxOutputSurfaces,
-- NUM_OUTPUT_SURFACES);
--
-- // create 3 pitches of black lines needed for clipping top
-- // and bottom lines when de-interlacing
-- m_BlackBar = new uint32_t[3*OutWidth];
-- memset(m_BlackBar, 0, 3*OutWidth*sizeof(uint32_t));
--
-- surfaceNum = presentSurfaceNum = 0;
-- outputSurface = presentSurface = VDP_INVALID_HANDLE;
-- videoMixer = VDP_INVALID_HANDLE;
--
-- m_vdpauOutputMethod = OUTPUT_PIXMAP;
--
-- return true;
--}
--
--bool CVDPAU::FiniOutputMethod()
--{
-- VdpStatus vdp_st;
--
-- if (vdp_flip_queue != VDP_INVALID_HANDLE)
-- {
-- vdp_st = vdp_presentation_queue_destroy(vdp_flip_queue);
-- vdp_flip_queue = VDP_INVALID_HANDLE;
-- CheckStatus(vdp_st, __LINE__);
-- }
--
-- if (vdp_flip_target != VDP_INVALID_HANDLE)
-- {
-- vdp_st = vdp_presentation_queue_target_destroy(vdp_flip_target);
-- vdp_flip_target = VDP_INVALID_HANDLE;
-- CheckStatus(vdp_st, __LINE__);
-- }
--
-- if (m_glPixmap)
-- {
-- CLog::Log(LOGDEBUG, "GLX: Destroying glPixmap");
-- glXDestroyPixmap(m_Display, m_glPixmap);
-- m_glPixmap = None;
-- }
--
-- if (m_Pixmap)
-- {
-- CLog::Log(LOGDEBUG, "GLX: Destroying XPixmap");
-- XFreePixmap(m_Display, m_Pixmap);
-- m_Pixmap = None;
-- }
--
-- outputSurface = presentSurface = VDP_INVALID_HANDLE;
--
-- for (int i = 0; i < totalAvailableOutputSurfaces; i++)
-- {
-- if (outputSurfaces[i] == VDP_INVALID_HANDLE)
-- continue;
-- vdp_st = vdp_output_surface_destroy(outputSurfaces[i]);
-- outputSurfaces[i] = VDP_INVALID_HANDLE;
-- CheckStatus(vdp_st, __LINE__);
-- }
--
-- if (videoMixer != VDP_INVALID_HANDLE)
-- {
-- vdp_st = vdp_video_mixer_destroy(videoMixer);
-- videoMixer = VDP_INVALID_HANDLE;
-- if (CheckStatus(vdp_st, __LINE__));
-+ }
- }
--
-- if (m_BlackBar)
-+ else
- {
-- delete [] m_BlackBar;
-- m_BlackBar = NULL;
-+ CLog::Log(LOGERROR, "VDPAU::%s - failed to init output", __FUNCTION__);
-+ m_vdpauOutput.Dispose();
-+ return false;
- }
-
-- while (!m_DVDVideoPics.empty())
-- m_DVDVideoPics.pop();
--
-+ m_inMsgEvent.Reset();
-+ m_vdpauConfigured = true;
- return true;
- }
-
--void CVDPAU::SpewHardwareAvailable() //Copyright (c) 2008 Wladimir J. van der Laan -- VDPInfo
-+void CDecoder::SpewHardwareAvailable() //CopyrighVDPAUt (c) 2008 Wladimir J. van der Laan -- VDPInfo
- {
- VdpStatus rv;
- CLog::Log(LOGNOTICE,"VDPAU Decoder capabilities:");
-@@ -1058,7 +639,7 @@
- {
- VdpBool is_supported = false;
- uint32_t max_level, max_macroblocks, max_width, max_height;
-- rv = vdp_decoder_query_caps(vdp_device, decoder_profiles[x].id,
-+ rv = m_vdpauConfig.vdpProcs.vdp_decoder_query_caps(m_vdpauConfig.vdpDevice, decoder_profiles[x].id,
- &is_supported, &max_level, &max_macroblocks, &max_width, &max_height);
- if(rv == VDP_STATUS_OK && is_supported)
- {
-@@ -1067,13 +648,13 @@
- }
- }
- CLog::Log(LOGNOTICE,"------------------------------------");
-- m_feature_count = 0;
-+ m_vdpauConfig.featureCount = 0;
- #define CHECK_SUPPORT(feature) \
- do { \
- VdpBool supported; \
-- if(vdp_video_mixer_query_feature_support(vdp_device, feature, &supported) == VDP_STATUS_OK && supported) { \
-+ if(m_vdpauConfig.vdpProcs.vdp_video_mixer_query_feature_support(m_vdpauConfig.vdpDevice, feature, &supported) == VDP_STATUS_OK && supported) { \
- CLog::Log(LOGNOTICE, "Mixer feature: "#feature); \
-- m_features[m_feature_count++] = feature; \
-+ m_vdpauConfig.vdpFeatures[m_vdpauConfig.featureCount++] = feature; \
- } \
- } while(false)
-
-@@ -1097,7 +678,7 @@
-
- }
-
--bool CVDPAU::IsSurfaceValid(vdpau_render_state *render)
-+bool CDecoder::IsSurfaceValid(vdpau_render_state *render)
- {
- // find render state in queue
- bool found(false);
-@@ -1124,34 +705,34 @@
- return true;
- }
-
--int CVDPAU::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
-+int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
- {
- //CLog::Log(LOGNOTICE,"%s",__FUNCTION__);
- CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
-- CVDPAU* vdp = (CVDPAU*)ctx->GetHardware();
-- struct pictureAge* pA = &vdp->picAge;
-+ CDecoder* vdp = (CDecoder*)ctx->GetHardware();
-+ struct PictureAge* pA = &vdp->m_picAge;
-
- // while we are waiting to recover we can't do anything
-- CSharedLock lock(vdp->m_DecoderSection);
-+ CSingleLock lock(vdp->m_DecoderSection);
-
-- { CSharedLock dLock(vdp->m_DisplaySection);
-- if(vdp->m_DisplayState != VDPAU_OPEN)
-- {
-- CLog::Log(LOGWARNING, "CVDPAU::FFGetBuffer - returning due to awaiting recovery");
-- return -1;
-- }
-+ if(vdp->m_DisplayState != VDPAU_OPEN)
-+ {
-+ CLog::Log(LOGWARNING, "CVDPAU::FFGetBuffer - returning due to awaiting recovery");
-+ return -1;
- }
-
- vdpau_render_state * render = NULL;
-
- // find unused surface
-- for(unsigned int i = 0; i < vdp->m_videoSurfaces.size(); i++)
-- {
-- if(!(vdp->m_videoSurfaces[i]->state & (FF_VDPAU_STATE_USED_FOR_REFERENCE | FF_VDPAU_STATE_USED_FOR_RENDER)))
-+ { CSingleLock lock(vdp->m_videoSurfaceSec);
-+ for(unsigned int i = 0; i < vdp->m_videoSurfaces.size(); i++)
- {
-- render = vdp->m_videoSurfaces[i];
-- render->state = 0;
-- break;
-+ if(!(vdp->m_videoSurfaces[i]->state & (FF_VDPAU_STATE_USED_FOR_REFERENCE | FF_VDPAU_STATE_USED_FOR_RENDER)))
-+ {
-+ render = vdp->m_videoSurfaces[i];
-+ render->state = 0;
-+ break;
-+ }
- }
- }
-
-@@ -1160,21 +741,22 @@
- {
- // create a new surface
- VdpDecoderProfile profile;
-- ReadFormatOf(avctx->pix_fmt, profile, vdp->vdp_chroma_type);
-+ ReadFormatOf(avctx->pix_fmt, profile, vdp->m_vdpauConfig.vdpChromaType);
- render = (vdpau_render_state*)calloc(sizeof(vdpau_render_state), 1);
- if (render == NULL)
- {
- CLog::Log(LOGWARNING, "CVDPAU::FFGetBuffer - calloc failed");
- return -1;
- }
-+ CSingleLock lock(vdp->m_videoSurfaceSec);
- render->surface = VDP_INVALID_HANDLE;
- vdp->m_videoSurfaces.push_back(render);
- }
-
- if (render->surface == VDP_INVALID_HANDLE)
- {
-- vdp_st = vdp->vdp_video_surface_create(vdp->vdp_device,
-- vdp->vdp_chroma_type,
-+ vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_video_surface_create(vdp->m_vdpauConfig.vdpDevice,
-+ vdp->m_vdpauConfig.vdpChromaType,
- avctx->coded_width,
- avctx->coded_height,
- &render->surface);
-@@ -1214,15 +796,16 @@
- return 0;
- }
-
--void CVDPAU::FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic)
-+void CDecoder::FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic)
- {
- //CLog::Log(LOGNOTICE,"%s",__FUNCTION__);
- CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
-- CVDPAU* vdp = (CVDPAU*)ctx->GetHardware();
-+ CDecoder* vdp = (CDecoder*)ctx->GetHardware();
-+
- vdpau_render_state * render;
- unsigned int i;
-
-- CSharedLock lock(vdp->m_DecoderSection);
-+ CSingleLock lock(vdp->m_DecoderSection);
-
- render=(vdpau_render_state*)pic->data[0];
- if(!render)
-@@ -1231,6 +814,8 @@
- return;
- }
-
-+ CSingleLock vLock(vdp->m_videoSurfaceSec);
-+ render->state &= ~FF_VDPAU_STATE_USED_FOR_REFERENCE;
- for(i=0; i<4; i++)
- pic->data[i]= NULL;
-
-@@ -1245,21 +830,18 @@
- }
-
-
--void CVDPAU::FFDrawSlice(struct AVCodecContext *s,
-+void CDecoder::FFDrawSlice(struct AVCodecContext *s,
- const AVFrame *src, int offset[4],
- int y, int type, int height)
- {
- CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)s->opaque;
-- CVDPAU* vdp = (CVDPAU*)ctx->GetHardware();
-+ CDecoder* vdp = (CDecoder*)ctx->GetHardware();
-
- // while we are waiting to recover we can't do anything
-- CSharedLock lock(vdp->m_DecoderSection);
--
-- { CSharedLock dLock(vdp->m_DisplaySection);
-- if(vdp->m_DisplayState != VDPAU_OPEN)
-- return;
-- }
-+ CSingleLock lock(vdp->m_DecoderSection);
-
-+ if(vdp->m_DisplayState != VDPAU_OPEN)
-+ return;
-
- if(src->linesize[0] || src->linesize[1] || src->linesize[2]
- || offset[0] || offset[1] || offset[2])
-@@ -1289,59 +871,41 @@
- if(s->pix_fmt == PIX_FMT_VDPAU_H264)
- max_refs = render->info.h264.num_ref_frames;
-
-- if(vdp->decoder == VDP_INVALID_HANDLE
-- || vdp->vdpauConfigured == false
-- || vdp->max_references < max_refs)
-+ if(vdp->m_vdpauConfig.vdpDecoder == VDP_INVALID_HANDLE
-+ || vdp->m_vdpauConfigured == false
-+ || vdp->m_vdpauConfig.maxReferences < max_refs)
- {
- if(!vdp->ConfigVDPAU(s, max_refs))
- return;
- }
-
-- vdp_st = vdp->vdp_decoder_render(vdp->decoder,
-+ uint64_t startTime = CurrentHostCounter();
-+ uint16_t decoded, processed, rend;
-+ vdp->m_bufferStats.Get(decoded, processed, rend);
-+ vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_decoder_render(vdp->m_vdpauConfig.vdpDecoder,
- render->surface,
- (VdpPictureInfo const *)&(render->info),
- render->bitstream_buffers_used,
- render->bitstream_buffers);
- vdp->CheckStatus(vdp_st, __LINE__);
-+ uint64_t diff = CurrentHostCounter() - startTime;
-+ if (diff*1000/CurrentHostFrequency() > 30)
-+ CLog::Log(LOGWARNING,"CVDPAU::DrawSlice - VdpDecoderRender long decoding: %d ms, dec: %d, proc: %d, rend: %d", (int)((diff*1000)/CurrentHostFrequency()), decoded, processed, rend);
-+
- }
-
--int CVDPAU::Decode(AVCodecContext *avctx, AVFrame *pFrame)
--{
-- //CLog::Log(LOGNOTICE,"%s",__FUNCTION__);
-- VdpStatus vdp_st;
-- VdpTime time;
-
-+int CDecoder::Decode(AVCodecContext *avctx, AVFrame *pFrame, bool bSoftDrain, bool bHardDrain)
-+{
- int result = Check(avctx);
- if (result)
- return result;
-
-- CSharedLock lock(m_DecoderSection);
-+ CSingleLock lock(m_DecoderSection);
-
-- if (!vdpauConfigured)
-+ if (!m_vdpauConfigured)
- return VC_ERROR;
-
-- // configure vdpau output
-- if (!ConfigOutputMethod(avctx, pFrame))
-- return VC_FLUSHED;
--
-- outputSurface = outputSurfaces[surfaceNum];
--
-- CheckFeatures();
--
-- if (( (int)outRectVid.x1 != OutWidth ) ||
-- ( (int)outRectVid.y1 != OutHeight ))
-- {
-- outRectVid.x0 = 0;
-- outRectVid.y0 = 0;
-- outRectVid.x1 = OutWidth;
-- outRectVid.y1 = OutHeight;
-- }
--
-- EDEINTERLACEMODE mode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
-- EINTERLACEMETHOD method = g_settings.m_currentVideoSettings.m_InterlaceMethod;
-- if (method == VS_INTERLACEMETHOD_AUTO)
-- method = AutoInterlaceMethod();
--
- if(pFrame)
- { // we have a new frame from decoder
-
-@@ -1349,7 +913,10 @@
- if(!render) // old style ffmpeg gave data on plane 0
- render = (vdpau_render_state*)pFrame->data[0];
- if(!render)
-+ {
-+ CLog::Log(LOGERROR, "CVDPAU::Decode: no valid frame");
- return VC_ERROR;
-+ }
-
- // ffmpeg vc-1 decoder does not flush, make sure the data buffer is still valid
- if (!IsSurfaceValid(render))
-@@ -1358,256 +925,175 @@
- return VC_BUFFER;
- }
-
-+ CSingleLock lock(m_videoSurfaceSec);
- render->state |= FF_VDPAU_STATE_USED_FOR_RENDER;
-+ lock.Leave();
-+
-+ // send frame to output for processing
-+ CVdpauDecodedPicture pic;
-+ memset(&pic.DVDPic, 0, sizeof(pic.DVDPic));
-+ ((CDVDVideoCodecFFmpeg*)avctx->opaque)->GetPictureCommon(&pic.DVDPic);
-+ pic.render = render;
-+ m_bufferStats.IncDecoded();
-+ m_vdpauOutput.m_dataPort.SendOutMessage(COutputDataProtocol::NEWFRAME, &pic, sizeof(pic));
-
-- ClearUsedForRender(&past[0]);
-- past[0] = past[1];
-- past[1] = current;
-- current = future;
-- future = render;
--
-- DVDVideoPicture DVDPic;
-- memset(&DVDPic, 0, sizeof(DVDVideoPicture));
-- ((CDVDVideoCodecFFmpeg*)avctx->opaque)->GetPictureCommon(&DVDPic);
-- m_DVDVideoPics.push(DVDPic);
--
-- int pics = m_DVDVideoPics.size();
-- if (pics < 2)
-- return VC_BUFFER;
-- else if (pics > 2)
-- {
-- // this should not normally happen
-- CLog::Log(LOGERROR, "CVDPAU::Decode - invalid number of pictures in queue");
-- while (pics-- != 2)
-- m_DVDVideoPics.pop();
-+ m_codecControl = pic.DVDPic.iFlags & (DVP_FLAG_DRAIN | DVP_FLAG_SKIP_PROC);
-+ if (m_codecControl & DVP_FLAG_SKIP_PROC)
-+ {
-+ m_bufferStats.SetCmd(DVP_FLAG_SKIP_PROC);
- }
-+ }
-
-- if (mode == VS_DEINTERLACEMODE_FORCE
-- || (mode == VS_DEINTERLACEMODE_AUTO && m_DVDVideoPics.front().iFlags & DVP_FLAG_INTERLACED))
-+ int retval = 0;
-+ uint16_t decoded, processed, render;
-+ Message *msg;
-+ while (m_vdpauOutput.m_controlPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputControlProtocol::ERROR)
- {
-- if((method == VS_INTERLACEMETHOD_VDPAU_BOB
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF
-- || method == VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE ))
-+ m_DisplayState = VDPAU_ERROR;
-+ retval |= VC_ERROR;
-+ }
-+ msg->Release();
-+ }
-+
-+ m_bufferStats.Get(decoded, processed, render);
-+
-+ uint64_t startTime = CurrentHostCounter();
-+ while (!retval)
-+ {
-+ if (m_vdpauOutput.m_dataPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputDataProtocol::PICTURE)
- {
-- if(method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF
-- || avctx->skip_frame == AVDISCARD_NONREF)
-- m_mixerstep = 0;
-- else
-- m_mixerstep = 1;
--
-- if(m_DVDVideoPics.front().iFlags & DVP_FLAG_TOP_FIELD_FIRST)
-- m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD;
-- else
-- m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD;
-+ if (m_presentPicture)
-+ {
-+ m_presentPicture->ReturnUnused();
-+ m_presentPicture = 0;
-+ }
-+
-+ m_presentPicture = *(CVdpauRenderPicture**)msg->data;
-+ m_presentPicture->vdpau = this;
-+ m_bufferStats.DecRender();
-+ m_bufferStats.Get(decoded, processed, render);
-+ retval |= VC_PICTURE;
-+ msg->Release();
-+ break;
-+ }
-+ msg->Release();
-+ }
-+ else if (m_vdpauOutput.m_controlPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputControlProtocol::STATS)
-+ {
-+ m_bufferStats.Get(decoded, processed, render);
- }
- else
- {
-- m_mixerstep = 0;
-- m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
-+ m_DisplayState = VDPAU_ERROR;
-+ retval |= VC_ERROR;
- }
-+ msg->Release();
- }
-- else
-+
-+ if ((m_codecControl & DVP_FLAG_DRAIN))
- {
-- m_mixerstep = 0;
-- m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
-+ if (decoded + processed + render < 4)
-+ {
-+ retval |= VC_BUFFER;
-+ }
- }
--
-- }
-- else if(m_mixerstep == 1)
-- { // no new frame given, output second field of old frame
--
-- if(avctx->skip_frame == AVDISCARD_NONREF)
-+ else
- {
-- ClearUsedForRender(&past[1]);
-- m_DVDVideoPics.pop();
-- return VC_BUFFER;
-+ if (decoded < 4 && (processed + render) < 3)
-+ {
-+ retval |= VC_BUFFER;
-+ }
- }
-
-- m_mixerstep = 2;
-- if(m_mixerfield == VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD)
-- m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD;
-- else
-- m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD;
-+ if (!retval && !m_inMsgEvent.WaitMSec(2000))
-+ break;
- }
-- else
-+ uint64_t diff = CurrentHostCounter() - startTime;
-+ if (retval & VC_PICTURE)
- {
-- CLog::Log(LOGERROR, "CVDPAU::Decode - invalid mixer state reached");
-- return VC_BUFFER;
-+ m_bufferStats.SetParams(diff, m_speed);
- }
-+ if (diff*1000/CurrentHostFrequency() > 50)
-+ CLog::Log(LOGDEBUG,"CVDPAU::Decode long wait: %d", (int)((diff*1000)/CurrentHostFrequency()));
-
-- VdpVideoSurface past_surfaces[2] = { VDP_INVALID_HANDLE, VDP_INVALID_HANDLE };
-- VdpVideoSurface futu_surfaces[1] = { VDP_INVALID_HANDLE };
--
-- if(m_mixerfield == VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME)
-- {
-- if (past[0])
-- past_surfaces[1] = past[0]->surface;
-- if (past[1])
-- past_surfaces[0] = past[1]->surface;
-- futu_surfaces[0] = future->surface;
-- }
-- else
-+ if (!retval)
- {
-- if(m_mixerstep == 1)
-- { // first field
-- if (past[1])
-- {
-- past_surfaces[1] = past[1]->surface;
-- past_surfaces[0] = past[1]->surface;
-- }
-- futu_surfaces[0] = current->surface;
-- }
-- else
-- { // second field
-- if (past[1])
-- past_surfaces[1] = past[1]->surface;
-- past_surfaces[0] = current->surface;
-- futu_surfaces[0] = future->surface;
-- }
-+ CLog::Log(LOGERROR, "VDPAU::%s - timed out waiting for output message", __FUNCTION__);
-+ m_DisplayState = VDPAU_ERROR;
-+ retval |= VC_ERROR;
- }
-
-- vdp_st = vdp_presentation_queue_block_until_surface_idle(vdp_flip_queue,outputSurface,&time);
--
-- VdpRect sourceRect = {0,0,vid_width, vid_height};
--
-- vdp_st = vdp_video_mixer_render(videoMixer,
-- VDP_INVALID_HANDLE,
-- 0,
-- m_mixerfield,
-- 2,
-- past_surfaces,
-- current->surface,
-- 1,
-- futu_surfaces,
-- &sourceRect,
-- outputSurface,
-- &(outRectVid),
-- &(outRectVid),
-- 0,
-- NULL);
-- CheckStatus(vdp_st, __LINE__);
--
-- surfaceNum++;
-- if (surfaceNum >= totalAvailableOutputSurfaces) surfaceNum = 0;
-+ return retval;
-+}
-
-- if(m_mixerfield == VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME)
-- {
-- ClearUsedForRender(&past[0]);
-- return VC_BUFFER | VC_PICTURE;
-- }
-- else
-- {
-- // in order to clip top and bottom lines when de-interlacing
-- // we black those lines as a work around for not working
-- // background colour using the mixer
-- // pixel perfect is preferred over overscanning or zooming
-+bool CDecoder::GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture)
-+{
-+ CSingleLock lock(m_DecoderSection);
-
-- VdpRect clipRect = outRectVid;
-- clipRect.y1 = clipRect.y0 + 2;
-- uint32_t *data[] = {m_BlackBar};
-- uint32_t pitches[] = {outRectVid.x1};
-- vdp_st = vdp_output_surface_put_bits_native(outputSurface,
-- (void**)data,
-- pitches,
-- &clipRect);
-- CheckStatus(vdp_st, __LINE__);
-+ if (m_DisplayState != VDPAU_OPEN)
-+ return false;
-
-- clipRect = outRectVid;
-- clipRect.y0 = clipRect.y1 - 2;
-- vdp_st = vdp_output_surface_put_bits_native(outputSurface,
-- (void**)data,
-- pitches,
-- &clipRect);
-- CheckStatus(vdp_st, __LINE__);
-+ *picture = m_presentPicture->DVDPic;
-+ picture->vdpau = m_presentPicture;
-
-- if(m_mixerstep == 1)
-- return VC_PICTURE;
-- else
-- {
-- ClearUsedForRender(&past[1]);
-- return VC_BUFFER | VC_PICTURE;
-- }
-- }
-+ return true;
- }
-
--bool CVDPAU::GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture)
-+void CDecoder::Reset()
- {
-- CSharedLock lock(m_DecoderSection);
--
-- { CSharedLock dLock(m_DisplaySection);
-- if (m_DisplayState != VDPAU_OPEN)
-- return false;
-- }
-+ CSingleLock lock(m_DecoderSection);
-
-- *picture = m_DVDVideoPics.front();
-- // if this is the first field of an interlaced frame, we'll need
-- // this same picture for the second field later
-- if (m_mixerstep != 1)
-- m_DVDVideoPics.pop();
--
-- picture->format = DVDVideoPicture::FMT_VDPAU;
-- picture->iFlags &= DVP_FLAG_DROPPED;
-- picture->iWidth = OutWidth;
-- picture->iHeight = OutHeight;
-- picture->vdpau = this;
-+ if (!m_vdpauConfigured)
-+ return;
-
-- if(m_mixerstep)
-- {
-- picture->iRepeatPicture = -0.5;
-- if(m_mixerstep > 1)
-+ Message *reply;
-+ if (m_vdpauOutput.m_controlPort.SendOutMessageSync(COutputControlProtocol::FLUSH,
-+ &reply,
-+ 2000))
-+ {
-+ bool success = reply->signal == COutputControlProtocol::ACC ? true : false;
-+ reply->Release();
-+ if (!success)
- {
-- picture->dts = DVD_NOPTS_VALUE;
-- picture->pts = DVD_NOPTS_VALUE;
-+ CLog::Log(LOGERROR, "VDPAU::%s - flush returned error", __FUNCTION__);
-+ m_DisplayState = VDPAU_ERROR;
- }
-+ else
-+ m_bufferStats.Reset();
-+ }
-+ else
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::%s - flush timed out", __FUNCTION__);
-+ m_DisplayState = VDPAU_ERROR;
- }
-- return true;
- }
-
--void CVDPAU::Reset()
-+bool CDecoder::CanSkipDeint()
- {
-- // invalidate surfaces and picture queue when seeking
-- ClearUsedForRender(&past[0]);
-- ClearUsedForRender(&past[1]);
-- ClearUsedForRender(¤t);
-- ClearUsedForRender(&future);
--
-- while (!m_DVDVideoPics.empty())
-- m_DVDVideoPics.pop();
-+ return m_bufferStats.CanSkipDeint();
- }
-
--void CVDPAU::Present()
-+void CDecoder::SetSpeed(int speed)
- {
-- //CLog::Log(LOGNOTICE,"%s",__FUNCTION__);
-- VdpStatus vdp_st;
--
-- CSharedLock lock(m_DecoderSection);
--
-- { CSharedLock dLock(m_DisplaySection);
-- if (m_DisplayState != VDPAU_OPEN)
-- return;
-- }
--
-- presentSurface = outputSurface;
-+ m_speed = speed;
-+}
-
-- vdp_st = vdp_presentation_queue_display(vdp_flip_queue,
-- presentSurface,
-- 0,
-- 0,
-- 0);
-- CheckStatus(vdp_st, __LINE__);
-+void CDecoder::ReturnRenderPicture(CVdpauRenderPicture *renderPic)
-+{
-+ m_vdpauOutput.m_dataPort.SendOutMessage(COutputDataProtocol::RETURNPIC, &renderPic, sizeof(renderPic));
- }
-
--bool CVDPAU::CheckStatus(VdpStatus vdp_st, int line)
-+bool CDecoder::CheckStatus(VdpStatus vdp_st, int line)
- {
- if (vdp_st != VDP_STATUS_OK)
- {
-- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", vdp_get_error_string(vdp_st), vdp_st, __FILE__, line);
--
-- CExclusiveLock lock(m_DisplaySection);
-+ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_vdpauConfig.vdpProcs.vdp_get_error_string(vdp_st), vdp_st, __FILE__, line);
-
- if(m_DisplayState == VDPAU_OPEN)
- {
-@@ -1625,4 +1111,2432 @@
- return false;
- }
-
-+//-----------------------------------------------------------------------------
-+// RenderPicture
-+//-----------------------------------------------------------------------------
-+
-+CVdpauRenderPicture* CVdpauRenderPicture::Acquire()
-+{
-+ CSingleLock lock(*renderPicSection);
-+
-+ if (refCount == 0)
-+ vdpau->Acquire();
-+
-+ refCount++;
-+ return this;
-+}
-+
-+long CVdpauRenderPicture::Release()
-+{
-+ CSingleLock lock(*renderPicSection);
-+
-+ refCount--;
-+ if (refCount > 0)
-+ return refCount;
-+
-+ lock.Leave();
-+ vdpau->ReturnRenderPicture(this);
-+ vdpau->ReleasePicReference();
-+
-+ return refCount;
-+}
-+
-+void CVdpauRenderPicture::ReturnUnused()
-+{
-+ { CSingleLock lock(*renderPicSection);
-+ if (refCount > 0)
-+ return;
-+ }
-+ if (vdpau)
-+ vdpau->ReturnRenderPicture(this);
-+}
-+
-+//-----------------------------------------------------------------------------
-+// Mixer
-+//-----------------------------------------------------------------------------
-+CMixer::CMixer(CEvent *inMsgEvent) :
-+ CThread("Vdpau Mixer Thread"),
-+ m_controlPort("ControlPort", inMsgEvent, &m_outMsgEvent),
-+ m_dataPort("DataPort", inMsgEvent, &m_outMsgEvent)
-+{
-+ m_inMsgEvent = inMsgEvent;
-+}
-+
-+CMixer::~CMixer()
-+{
-+ Dispose();
-+}
-+
-+void CMixer::Start()
-+{
-+ Create();
-+}
-+
-+void CMixer::Dispose()
-+{
-+ m_bStop = true;
-+ m_outMsgEvent.Set();
-+ StopThread();
-+
-+ m_controlPort.Purge();
-+ m_dataPort.Purge();
-+}
-+
-+void CMixer::OnStartup()
-+{
-+ CLog::Log(LOGNOTICE, "CMixer::OnStartup: Output Thread created");
-+}
-+
-+void CMixer::OnExit()
-+{
-+ CLog::Log(LOGNOTICE, "CMixer::OnExit: Output Thread terminated");
-+}
-+
-+enum MIXER_STATES
-+{
-+ M_TOP = 0, // 0
-+ M_TOP_ERROR, // 1
-+ M_TOP_UNCONFIGURED, // 2
-+ M_TOP_CONFIGURED, // 3
-+ M_TOP_CONFIGURED_WAIT1, // 4
-+ M_TOP_CONFIGURED_STEP1, // 5
-+ M_TOP_CONFIGURED_WAIT2, // 6
-+ M_TOP_CONFIGURED_STEP2, // 7
-+};
-+
-+int MIXER_parentStates[] = {
-+ -1,
-+ 0, //TOP_ERROR
-+ 0, //TOP_UNCONFIGURED
-+ 0, //TOP_CONFIGURED
-+ 3, //TOP_CONFIGURED_WAIT1
-+ 3, //TOP_CONFIGURED_STEP1
-+ 3, //TOP_CONFIGURED_WAIT2
-+ 3, //TOP_CONFIGURED_STEP2
-+};
-+
-+void CMixer::StateMachine(int signal, Protocol *port, Message *msg)
-+{
-+ for (int state = m_state; ; state = MIXER_parentStates[state])
-+ {
-+ switch (state)
-+ {
-+ case M_TOP: // TOP
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case CMixerControlProtocol::FLUSH:
-+ Flush();
-+ msg->Reply(CMixerControlProtocol::ACC);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ {
-+ std::string portName = port == NULL ? "timer" : port->portName;
-+ CLog::Log(LOGWARNING, "CMixer::%s - signal: %d form port: %s not handled for state: %d", __FUNCTION__, signal, portName.c_str(), m_state);
-+ }
-+ return;
-+
-+ case M_TOP_ERROR: // TOP
-+ break;
-+
-+ case M_TOP_UNCONFIGURED:
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case CMixerControlProtocol::INIT:
-+ CVdpauConfig *data;
-+ data = (CVdpauConfig*)msg->data;
-+ if (data)
-+ {
-+ m_config = *data;
-+ }
-+ Init();
-+ if (!m_vdpError)
-+ {
-+ m_state = M_TOP_CONFIGURED_WAIT1;
-+ msg->Reply(CMixerControlProtocol::ACC);
-+ }
-+ else
-+ {
-+ msg->Reply(CMixerControlProtocol::ERROR);
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case M_TOP_CONFIGURED:
-+ if (port == &m_dataPort)
-+ {
-+ switch (signal)
-+ {
-+ case CMixerDataProtocol::FRAME:
-+ CVdpauDecodedPicture *frame;
-+ frame = (CVdpauDecodedPicture*)msg->data;
-+ if (frame)
-+ {
-+ m_decodedPics.push(*frame);
-+ }
-+ m_extTimeout = 0;
-+ return;
-+ case CMixerDataProtocol::BUFFER:
-+ VdpOutputSurface *surf;
-+ surf = (VdpOutputSurface*)msg->data;
-+ if (surf)
-+ {
-+ m_outputSurfaces.push(*surf);
-+ }
-+ m_extTimeout = 0;
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case M_TOP_CONFIGURED_WAIT1:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case CMixerControlProtocol::TIMEOUT:
-+ if (!m_decodedPics.empty() && !m_outputSurfaces.empty())
-+ {
-+ m_state = M_TOP_CONFIGURED_STEP1;
-+ m_bStateMachineSelfTrigger = true;
-+ }
-+ else
-+ {
-+// if (m_extTimeout != 0)
-+// {
-+// SetPostProcFeatures(false);
-+// CLog::Log(LOGWARNING,"CVDPAU::Mixer timeout - decoded: %d, outputSurf: %d", (int)m_decodedPics.size(), (int)m_outputSurfaces.size());
-+// }
-+ m_extTimeout = 100;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case M_TOP_CONFIGURED_STEP1:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case CMixerControlProtocol::TIMEOUT:
-+ m_mixerInput.push_front(m_decodedPics.front());
-+ m_decodedPics.pop();
-+ if (m_mixerInput.size() < 2)
-+ {
-+ m_state = M_TOP_CONFIGURED_WAIT1;
-+ m_extTimeout = 0;
-+ return;
-+ }
-+ InitCycle();
-+ ProcessPicture();
-+ if (m_vdpError)
-+ {
-+ m_state = M_TOP_CONFIGURED_WAIT1;
-+ m_extTimeout = 1000;
-+ return;
-+ }
-+ if (m_processPicture.DVDPic.format != DVDVideoPicture::FMT_VDPAU_420)
-+ m_outputSurfaces.pop();
-+ m_config.stats->IncProcessed();
-+ m_config.stats->DecDecoded();
-+ m_dataPort.SendInMessage(CMixerDataProtocol::PICTURE,&m_processPicture,sizeof(m_processPicture));
-+ if (m_mixersteps > 1)
-+ {
-+ m_state = M_TOP_CONFIGURED_WAIT2;
-+ m_extTimeout = 0;
-+ }
-+ else
-+ {
-+ FiniCycle();
-+ m_state = M_TOP_CONFIGURED_WAIT1;
-+ m_extTimeout = 0;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case M_TOP_CONFIGURED_WAIT2:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case CMixerControlProtocol::TIMEOUT:
-+ if (!m_outputSurfaces.empty())
-+ {
-+ m_state = M_TOP_CONFIGURED_STEP2;
-+ m_bStateMachineSelfTrigger = true;
-+ }
-+ else
-+ {
-+// if (m_extTimeout != 0)
-+// {
-+// SetPostProcFeatures(false);
-+// CLog::Log(LOGNOTICE,"---mixer wait2 decoded: %d, outputSurf: %d", (int)m_decodedPics.size(), (int)m_outputSurfaces.size());
-+// }
-+ m_extTimeout = 100;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case M_TOP_CONFIGURED_STEP2:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case CMixerControlProtocol::TIMEOUT:
-+ m_processPicture.outputSurface = m_outputSurfaces.front();
-+ m_mixerstep = 1;
-+ ProcessPicture();
-+ if (m_vdpError)
-+ {
-+ m_state = M_TOP_CONFIGURED_WAIT1;
-+ m_extTimeout = 1000;
-+ return;
-+ }
-+ if (m_processPicture.DVDPic.format != DVDVideoPicture::FMT_VDPAU_420)
-+ m_outputSurfaces.pop();
-+ m_config.stats->IncProcessed();
-+ m_dataPort.SendInMessage(CMixerDataProtocol::PICTURE,&m_processPicture,sizeof(m_processPicture));
-+ FiniCycle();
-+ m_state = M_TOP_CONFIGURED_WAIT1;
-+ m_extTimeout = 0;
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ default: // we are in no state, should not happen
-+ CLog::Log(LOGERROR, "CMixer::%s - no valid state: %d", __FUNCTION__, m_state);
-+ return;
-+ }
-+ } // for
-+}
-+
-+void CMixer::Process()
-+{
-+ Message *msg;
-+ Protocol *port;
-+ bool gotMsg;
-+
-+ m_state = M_TOP_UNCONFIGURED;
-+ m_extTimeout = 1000;
-+ m_bStateMachineSelfTrigger = false;
-+
-+ while (!m_bStop)
-+ {
-+ gotMsg = false;
-+
-+ if (m_bStateMachineSelfTrigger)
-+ {
-+ m_bStateMachineSelfTrigger = false;
-+ // self trigger state machine
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ continue;
-+ }
-+ // check control port
-+ else if (m_controlPort.ReceiveOutMessage(&msg))
-+ {
-+ gotMsg = true;
-+ port = &m_controlPort;
-+ }
-+ // check data port
-+ else if (m_dataPort.ReceiveOutMessage(&msg))
-+ {
-+ gotMsg = true;
-+ port = &m_dataPort;
-+ }
-+
-+ if (gotMsg)
-+ {
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ continue;
-+ }
-+
-+ // wait for message
-+ else if (m_outMsgEvent.WaitMSec(m_extTimeout))
-+ {
-+ continue;
-+ }
-+ // time out
-+ else
-+ {
-+ msg = m_controlPort.GetMessage();
-+ msg->signal = CMixerControlProtocol::TIMEOUT;
-+ port = 0;
-+ // signal timeout to state machine
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ }
-+ }
-+ Uninit();
-+}
-+
-+void CMixer::CreateVdpauMixer()
-+{
-+ CLog::Log(LOGNOTICE, " (VDPAU) Creating the video mixer");
-+
-+ InitCSCMatrix(m_config.vidWidth);
-+
-+ VdpVideoMixerParameter parameters[] = {
-+ VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH,
-+ VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT,
-+ VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE};
-+
-+ void const * parameter_values[] = {
-+ &m_config.surfaceWidth,
-+ &m_config.surfaceHeight,
-+ &m_config.vdpChromaType};
-+
-+ VdpStatus vdp_st = VDP_STATUS_ERROR;
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_create(m_config.vdpDevice,
-+ m_config.featureCount,
-+ m_config.vdpFeatures,
-+ ARSIZE(parameters),
-+ parameters,
-+ parameter_values,
-+ &m_videoMixer);
-+ CheckStatus(vdp_st, __LINE__);
-+
-+ // create 3 pitches of black lines needed for clipping top
-+ // and bottom lines when de-interlacing
-+ m_BlackBar = new uint32_t[3*m_config.outWidth];
-+ memset(m_BlackBar, 0, 3*m_config.outWidth*sizeof(uint32_t));
-+
-+}
-+
-+void CMixer::InitCSCMatrix(int Width)
-+{
-+ VdpStatus vdp_st;
-+ m_Procamp.struct_version = VDP_PROCAMP_VERSION;
-+ m_Procamp.brightness = 0.0;
-+ m_Procamp.contrast = 1.0;
-+ m_Procamp.saturation = 1.0;
-+ m_Procamp.hue = 0;
-+ vdp_st = m_config.vdpProcs.vdp_generate_csc_matrix(&m_Procamp,
-+ (Width < 1000)? VDP_COLOR_STANDARD_ITUR_BT_601 : VDP_COLOR_STANDARD_ITUR_BT_709,
-+ &m_CSCMatrix);
-+ CheckStatus(vdp_st, __LINE__);
-+}
-+
-+void CMixer::CheckFeatures()
-+{
-+ if (m_Upscale != m_config.upscale)
-+ {
-+ SetHWUpscaling();
-+ m_Upscale = m_config.upscale;
-+ }
-+ if (m_Brightness != g_settings.m_currentVideoSettings.m_Brightness ||
-+ m_Contrast != g_settings.m_currentVideoSettings.m_Contrast)
-+ {
-+ SetColor();
-+ m_Brightness = g_settings.m_currentVideoSettings.m_Brightness;
-+ m_Contrast = g_settings.m_currentVideoSettings.m_Contrast;
-+ }
-+ if (m_NoiseReduction != g_settings.m_currentVideoSettings.m_NoiseReduction)
-+ {
-+ m_NoiseReduction = g_settings.m_currentVideoSettings.m_NoiseReduction;
-+ SetNoiseReduction();
-+ }
-+ if (m_Sharpness != g_settings.m_currentVideoSettings.m_Sharpness)
-+ {
-+ m_Sharpness = g_settings.m_currentVideoSettings.m_Sharpness;
-+ SetSharpness();
-+ }
-+ if (m_DeintMode != g_settings.m_currentVideoSettings.m_DeinterlaceMode ||
-+ m_Deint != g_settings.m_currentVideoSettings.m_InterlaceMethod)
-+ {
-+ m_DeintMode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
-+ m_Deint = g_settings.m_currentVideoSettings.m_InterlaceMethod;
-+ SetDeinterlacing();
-+ }
-+}
-+
-+void CMixer::SetPostProcFeatures(bool postProcEnabled)
-+{
-+ if (m_PostProc != postProcEnabled)
-+ {
-+ if (postProcEnabled)
-+ {
-+ SetNoiseReduction();
-+ SetSharpness();
-+ SetDeinterlacing();
-+ SetHWUpscaling();
-+ }
-+ else
-+ PostProcOff();
-+ m_PostProc = postProcEnabled;
-+ }
-+}
-+
-+void CMixer::PostProcOff()
-+{
-+ VdpStatus vdp_st;
-+
-+ if (m_videoMixer == VDP_INVALID_HANDLE)
-+ return;
-+
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL,
-+ VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL,
-+ VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE};
-+
-+ VdpBool enabled[]={0,0,0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION};
-+
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_SHARPNESS))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_SHARPNESS};
-+
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ DisableHQScaling();
-+}
-+
-+
-+bool CMixer::GenerateStudioCSCMatrix(VdpColorStandard colorStandard, VdpCSCMatrix &studioCSCMatrix)
-+{
-+ // instead use studioCSCKCoeffs601[3], studioCSCKCoeffs709[3] to generate float[3][4] matrix (float studioCSC[3][4])
-+ // m00 = mRY = red: luma factor (contrast factor) (1.0)
-+ // m10 = mGY = green: luma factor (contrast factor) (1.0)
-+ // m20 = mBY = blue: luma factor (contrast factor) (1.0)
-+ //
-+ // m01 = mRB = red: blue color diff coeff (0.0)
-+ // m11 = mGB = green: blue color diff coeff (-2Kb(1-Kb)/(Kg))
-+ // m21 = mBB = blue: blue color diff coeff ((1-Kb)/0.5)
-+ //
-+ // m02 = mRR = red: red color diff coeff ((1-Kr)/0.5)
-+ // m12 = mGR = green: red color diff coeff (-2Kr(1-Kr)/(Kg))
-+ // m22 = mBR = blue: red color diff coeff (0.0)
-+ //
-+ // m03 = mRC = red: colour zero offset (brightness factor) (-(1-Kr)/0.5 * (128/255))
-+ // m13 = mGC = green: colour zero offset (brightness factor) ((256/255) * (Kb(1-Kb) + Kr(1-Kr)) / Kg)
-+ // m23 = mBC = blue: colour zero offset (brightness factor) (-(1-Kb)/0.5 * (128/255))
-+
-+ // columns
-+ int Y = 0;
-+ int Cb = 1;
-+ int Cr = 2;
-+ int C = 3;
-+ // rows
-+ int R = 0;
-+ int G = 1;
-+ int B = 2;
-+ // colour standard coefficients for red, geen, blue
-+ double Kr, Kg, Kb;
-+ // colour diff zero position (use standard 8-bit coding precision)
-+ double CDZ = 128; //256*0.5
-+ // range excursion (use standard 8-bit coding precision)
-+ double EXC = 255; //256-1
-+
-+ if (colorStandard == VDP_COLOR_STANDARD_ITUR_BT_601)
-+ {
-+ Kr = studioCSCKCoeffs601[0];
-+ Kg = studioCSCKCoeffs601[1];
-+ Kb = studioCSCKCoeffs601[2];
-+ }
-+ else // assume VDP_COLOR_STANDARD_ITUR_BT_709
-+ {
-+ Kr = studioCSCKCoeffs709[0];
-+ Kg = studioCSCKCoeffs709[1];
-+ Kb = studioCSCKCoeffs709[2];
-+ }
-+ // we keep luma unscaled to retain the levels present in source so that 16-235 luma is converted to RGB 16-235
-+ studioCSCMatrix[R][Y] = 1.0;
-+ studioCSCMatrix[G][Y] = 1.0;
-+ studioCSCMatrix[B][Y] = 1.0;
-+
-+ studioCSCMatrix[R][Cb] = 0.0;
-+ studioCSCMatrix[G][Cb] = (double)-2 * Kb * (1 - Kb) / Kg;
-+ studioCSCMatrix[B][Cb] = (double)(1 - Kb) / 0.5;
-+
-+ studioCSCMatrix[R][Cr] = (double)(1 - Kr) / 0.5;
-+ studioCSCMatrix[G][Cr] = (double)-2 * Kr * (1 - Kr) / Kg;
-+ studioCSCMatrix[B][Cr] = 0.0;
-+
-+ studioCSCMatrix[R][C] = (double)-1 * studioCSCMatrix[R][Cr] * CDZ/EXC;
-+ studioCSCMatrix[G][C] = (double)-1 * (studioCSCMatrix[G][Cb] + studioCSCMatrix[G][Cr]) * CDZ/EXC;
-+ studioCSCMatrix[B][C] = (double)-1 * studioCSCMatrix[B][Cb] * CDZ/EXC;
-+
-+ return true;
-+}
-+
-+void CMixer::SetColor()
-+{
-+ VdpStatus vdp_st;
-+
-+ if (m_Brightness != g_settings.m_currentVideoSettings.m_Brightness)
-+ m_Procamp.brightness = (float)((g_settings.m_currentVideoSettings.m_Brightness)-50) / 100;
-+ if (m_Contrast != g_settings.m_currentVideoSettings.m_Contrast)
-+ m_Procamp.contrast = (float)((g_settings.m_currentVideoSettings.m_Contrast)+50) / 100;
-+
-+ VdpColorStandard colorStandard;
-+// if(vid_height >= 600 || vid_width > 1024)
-+ if(m_config.surfaceWidth > 1000)
-+ colorStandard = VDP_COLOR_STANDARD_ITUR_BT_709;
-+ //vdp_st = vdp_generate_csc_matrix(&m_Procamp, VDP_COLOR_STANDARD_ITUR_BT_709, &m_CSCMatrix);
-+ else
-+ colorStandard = VDP_COLOR_STANDARD_ITUR_BT_601;
-+ //vdp_st = vdp_generate_csc_matrix(&m_Procamp, VDP_COLOR_STANDARD_ITUR_BT_601, &m_CSCMatrix);
-+
-+ VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX };
-+ if (g_guiSettings.GetBool("videoplayer.vdpaustudiolevel"))
-+ {
-+ float studioCSC[3][4];
-+ GenerateStudioCSCMatrix(colorStandard, studioCSC);
-+ void const * pm_CSCMatix[] = { &studioCSC };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix);
-+ }
-+ else
-+ {
-+ vdp_st = m_config.vdpProcs.vdp_generate_csc_matrix(&m_Procamp, colorStandard, &m_CSCMatrix);
-+ void const * pm_CSCMatix[] = { &m_CSCMatrix };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix);
-+ }
-+ CheckStatus(vdp_st, __LINE__);
-+}
-+
-+void CMixer::SetNoiseReduction()
-+{
-+ if(!m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION))
-+ return;
-+
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION };
-+ VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL };
-+ VdpStatus vdp_st;
-+
-+ if (!g_settings.m_currentVideoSettings.m_NoiseReduction)
-+ {
-+ VdpBool enabled[]= {0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ return;
-+ }
-+ VdpBool enabled[]={1};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ void* nr[] = { &g_settings.m_currentVideoSettings.m_NoiseReduction };
-+ CLog::Log(LOGNOTICE,"Setting Noise Reduction to %f",g_settings.m_currentVideoSettings.m_NoiseReduction);
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, nr);
-+ CheckStatus(vdp_st, __LINE__);
-+}
-+
-+void CMixer::SetSharpness()
-+{
-+ if(!m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_SHARPNESS))
-+ return;
-+
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_SHARPNESS };
-+ VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL };
-+ VdpStatus vdp_st;
-+
-+ if (!g_settings.m_currentVideoSettings.m_Sharpness)
-+ {
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ return;
-+ }
-+ VdpBool enabled[]={1};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ void* sh[] = { &g_settings.m_currentVideoSettings.m_Sharpness };
-+ CLog::Log(LOGNOTICE,"Setting Sharpness to %f",g_settings.m_currentVideoSettings.m_Sharpness);
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, sh);
-+ CheckStatus(vdp_st, __LINE__);
-+}
-+
-+EINTERLACEMETHOD CMixer::GetDeinterlacingMethod(bool log /* = false */)
-+{
-+ EINTERLACEMETHOD method = g_settings.m_currentVideoSettings.m_InterlaceMethod;
-+ if (method == VS_INTERLACEMETHOD_AUTO)
-+ {
-+ int deint = -1;
-+ if (m_config.outHeight >= 720)
-+ deint = g_advancedSettings.m_videoVDPAUdeintHD;
-+ else
-+ deint = g_advancedSettings.m_videoVDPAUdeintSD;
-+
-+ if (deint != -1)
-+ {
-+ if (m_config.vdpau->Supports(EINTERLACEMETHOD(deint)))
-+ {
-+ method = EINTERLACEMETHOD(deint);
-+ if (log)
-+ CLog::Log(LOGNOTICE, "CVDPAU::GetDeinterlacingMethod: set de-interlacing to %d", deint);
-+ }
-+ else
-+ {
-+ if (log)
-+ CLog::Log(LOGWARNING, "CVDPAU::GetDeinterlacingMethod: method for de-interlacing (advanced settings) not supported");
-+ }
-+ }
-+ }
-+ return method;
-+}
-+
-+void CMixer::SetDeinterlacing()
-+{
-+ VdpStatus vdp_st;
-+
-+ if (m_videoMixer == VDP_INVALID_HANDLE)
-+ return;
-+
-+ EDEINTERLACEMODE mode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
-+ EINTERLACEMETHOD method = GetDeinterlacingMethod(true);
-+
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL,
-+ VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL,
-+ VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE };
-+
-+ if (mode == VS_DEINTERLACEMODE_OFF)
-+ {
-+ VdpBool enabled[] = {0,0,0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ }
-+ else
-+ {
-+ if (method == VS_INTERLACEMETHOD_AUTO)
-+ {
-+ VdpBool enabled[] = {1,1,0};
-+ if (g_advancedSettings.m_videoVDPAUtelecine)
-+ enabled[2] = 1;
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ }
-+ else if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL
-+ || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF)
-+ {
-+ VdpBool enabled[] = {1,0,0};
-+ if (g_advancedSettings.m_videoVDPAUtelecine)
-+ enabled[2] = 1;
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ }
-+ else if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL
-+ || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF)
-+ {
-+ VdpBool enabled[] = {1,1,0};
-+ if (g_advancedSettings.m_videoVDPAUtelecine)
-+ enabled[2] = 1;
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ }
-+ else
-+ {
-+ VdpBool enabled[]={0,0,0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ }
-+ }
-+ CheckStatus(vdp_st, __LINE__);
-+
-+ SetDeintSkipChroma();
-+
-+ m_config.useInteropYuv = g_guiSettings.GetBool("videoplayer.usevdpauinteropyuv");
-+}
-+
-+void CMixer::SetDeintSkipChroma()
-+{
-+ VdpVideoMixerAttribute attribute[] = { VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE};
-+ VdpStatus vdp_st;
-+
-+ uint8_t val;
-+ if (g_advancedSettings.m_videoVDPAUdeintSkipChromaHD && m_config.outHeight >= 720)
-+ val = 1;
-+ else
-+ val = 0;
-+
-+ void const *values[]={&val};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attribute), attribute, values);
-+
-+ CheckStatus(vdp_st, __LINE__);
-+}
-+
-+void CMixer::SetHWUpscaling()
-+{
-+#ifdef VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1
-+
-+ VdpStatus vdp_st;
-+ VdpBool enabled[]={1};
-+ switch (m_config.upscale)
-+ {
-+ case 9:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 8:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 7:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 6:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 5:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 4:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 3:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 2:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 1:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ default:
-+ DisableHQScaling();
-+ return;
-+ }
-+ CheckStatus(vdp_st, __LINE__);
-+#endif
-+}
-+
-+void CMixer::DisableHQScaling()
-+{
-+ VdpStatus vdp_st;
-+
-+ if (m_videoMixer == VDP_INVALID_HANDLE)
-+ return;
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+}
-+
-+
-+void CMixer::Init()
-+{
-+ m_Brightness = 0.0;
-+ m_Contrast = 0.0;
-+ m_NoiseReduction = 0.0;
-+ m_Sharpness = 0.0;
-+ m_DeintMode = 0;
-+ m_Deint = 0;
-+ m_PostProc = false;
-+ m_vdpError = false;
-+
-+ m_config.upscale = g_advancedSettings.m_videoVDPAUScaling;
-+ m_config.useInteropYuv = g_guiSettings.GetBool("videoplayer.usevdpauinteropyuv");
-+
-+ CreateVdpauMixer();
-+}
-+
-+void CMixer::Uninit()
-+{
-+ Flush();
-+ while (!m_outputSurfaces.empty())
-+ {
-+ m_outputSurfaces.pop();
-+ }
-+ m_config.vdpProcs.vdp_video_mixer_destroy(m_videoMixer);
-+}
-+
-+void CMixer::Flush()
-+{
-+ while (!m_mixerInput.empty())
-+ {
-+ CVdpauDecodedPicture pic = m_mixerInput.back();
-+ m_mixerInput.pop_back();
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ if (pic.render)
-+ pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ while (!m_decodedPics.empty())
-+ {
-+ CVdpauDecodedPicture pic = m_decodedPics.front();
-+ m_decodedPics.pop();
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ if (pic.render)
-+ pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ Message *msg;
-+ while (m_dataPort.ReceiveOutMessage(&msg))
-+ {
-+ if (msg->signal == CMixerDataProtocol::FRAME)
-+ {
-+ CVdpauDecodedPicture pic = *(CVdpauDecodedPicture*)msg->data;
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ if (pic.render)
-+ pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ else if (msg->signal == CMixerDataProtocol::BUFFER)
-+ {
-+ VdpOutputSurface *surf;
-+ surf = (VdpOutputSurface*)msg->data;
-+ m_outputSurfaces.push(*surf);
-+ }
-+ msg->Release();
-+ }
-+}
-+
-+void CMixer::InitCycle()
-+{
-+ CheckFeatures();
-+ uint64_t latency;
-+ int speed;
-+ m_config.stats->GetParams(latency, speed);
-+ latency = (latency*1000)/CurrentHostFrequency();
-+ if (speed != DVD_PLAYSPEED_NORMAL)
-+ SetPostProcFeatures(false);
-+ else
-+ SetPostProcFeatures(true);
-+
-+ m_config.stats->SetCanSkipDeint(false);
-+
-+ EDEINTERLACEMODE mode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
-+ EINTERLACEMETHOD method = GetDeinterlacingMethod();
-+ bool interlaced = m_mixerInput[1].DVDPic.iFlags & DVP_FLAG_INTERLACED;
-+
-+ if (mode == VS_DEINTERLACEMODE_FORCE ||
-+ (mode == VS_DEINTERLACEMODE_AUTO && interlaced))
-+ {
-+ if((method == VS_INTERLACEMETHOD_AUTO && interlaced)
-+ || method == VS_INTERLACEMETHOD_VDPAU_BOB
-+ || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL
-+ || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF
-+ || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL
-+ || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF
-+ || method == VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE )
-+ {
-+ if(method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF
-+ || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF
-+ || !g_graphicsContext.IsFullScreenVideo())
-+ m_mixersteps = 1;
-+ else
-+ {
-+ m_mixersteps = 2;
-+ m_config.stats->SetCanSkipDeint(true);
-+ }
-+
-+ if (m_mixerInput[1].DVDPic.iFlags & DVP_FLAG_DROPDEINT)
-+ {
-+ m_mixersteps = 1;
-+ }
-+
-+ if(m_mixerInput[1].DVDPic.iFlags & DVP_FLAG_TOP_FIELD_FIRST)
-+ m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD;
-+ else
-+ m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD;
-+
-+ m_mixerInput[1].DVDPic.format = DVDVideoPicture::FMT_VDPAU;
-+ m_mixerInput[1].DVDPic.iFlags &= ~(DVP_FLAG_TOP_FIELD_FIRST |
-+ DVP_FLAG_REPEAT_TOP_FIELD |
-+ DVP_FLAG_INTERLACED);
-+ m_config.useInteropYuv = false;
-+ }
-+ else if (method == VS_INTERLACEMETHOD_RENDER_BOB && m_config.useInteropYuv)
-+ {
-+ m_mixersteps = 1;
-+ m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
-+ m_mixerInput[1].DVDPic.format = DVDVideoPicture::FMT_VDPAU_420;
-+ }
-+ else
-+ {
-+ CLog::Log(LOGERROR, "CMixer::%s - interlace method not supported", __FUNCTION__);
-+ m_mixersteps = 1;
-+ m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
-+ m_mixerInput[1].DVDPic.format = DVDVideoPicture::FMT_VDPAU;
-+ m_mixerInput[1].DVDPic.iFlags &= ~(DVP_FLAG_TOP_FIELD_FIRST |
-+ DVP_FLAG_REPEAT_TOP_FIELD |
-+ DVP_FLAG_INTERLACED);
-+ }
-+ }
-+ else
-+ {
-+ m_mixersteps = 1;
-+ m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
-+
-+ if (m_config.useInteropYuv)
-+ m_mixerInput[1].DVDPic.format = DVDVideoPicture::FMT_VDPAU_420;
-+ else
-+ {
-+ m_mixerInput[1].DVDPic.format = DVDVideoPicture::FMT_VDPAU;
-+ m_mixerInput[1].DVDPic.iFlags &= ~(DVP_FLAG_TOP_FIELD_FIRST |
-+ DVP_FLAG_REPEAT_TOP_FIELD |
-+ DVP_FLAG_INTERLACED);
-+ }
-+ }
-+ m_mixerstep = 0;
-+
-+ if (m_mixerInput[1].DVDPic.format == DVDVideoPicture::FMT_VDPAU)
-+ {
-+ m_processPicture.outputSurface = m_outputSurfaces.front();
-+ m_mixerInput[1].DVDPic.iWidth = m_config.outWidth;
-+ m_mixerInput[1].DVDPic.iHeight = m_config.outHeight;
-+ }
-+ else
-+ {
-+ m_mixerInput[1].DVDPic.iWidth = m_config.vidWidth;
-+ m_mixerInput[1].DVDPic.iHeight = m_config.vidHeight;
-+ }
-+
-+ m_processPicture.DVDPic = m_mixerInput[1].DVDPic;
-+ m_processPicture.render = m_mixerInput[1].render;
-+}
-+
-+void CMixer::FiniCycle()
-+{
-+ while (m_mixerInput.size() > 3)
-+ {
-+ CVdpauDecodedPicture &tmp = m_mixerInput.back();
-+ if (tmp.render && m_processPicture.DVDPic.format != DVDVideoPicture::FMT_VDPAU_420)
-+ {
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ tmp.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ m_mixerInput.pop_back();
-+// m_config.stats->DecDecoded();
-+ }
-+}
-+
-+void CMixer::ProcessPicture()
-+{
-+ if (m_processPicture.DVDPic.format == DVDVideoPicture::FMT_VDPAU_420)
-+ return;
-+
-+ int cmd = 0;
-+ m_config.stats->GetCmd(cmd);
-+ if (cmd & DVP_FLAG_SKIP_PROC)
-+ {
-+ m_processPicture.DVDPic.iFlags |= DVP_FLAG_DROPPED;
-+ return;
-+ }
-+
-+ VdpStatus vdp_st;
-+
-+ if (m_mixerstep == 1)
-+ {
-+ if(m_mixerfield == VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD)
-+ m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD;
-+ else
-+ m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD;
-+ }
-+
-+ VdpVideoSurface past_surfaces[4] = { VDP_INVALID_HANDLE, VDP_INVALID_HANDLE, VDP_INVALID_HANDLE, VDP_INVALID_HANDLE };
-+ VdpVideoSurface futu_surfaces[2] = { VDP_INVALID_HANDLE, VDP_INVALID_HANDLE };
-+ uint32_t pastCount = 4;
-+ uint32_t futuCount = 2;
-+
-+ if(m_mixerfield == VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME)
-+ {
-+ // use only 2 past 1 future for progressive/weave
-+ // (only used for postproc anyway eg noise reduction)
-+ if (m_mixerInput.size() > 3)
-+ past_surfaces[1] = m_mixerInput[3].render->surface;
-+ if (m_mixerInput.size() > 2)
-+ past_surfaces[0] = m_mixerInput[2].render->surface;
-+ futu_surfaces[0] = m_mixerInput[0].render->surface;
-+ pastCount = 2;
-+ futuCount = 1;
-+ }
-+ else
-+ {
-+ if(m_mixerstep == 0)
-+ { // first field
-+ if (m_mixerInput.size() > 3)
-+ {
-+ past_surfaces[3] = m_mixerInput[3].render->surface;
-+ past_surfaces[2] = m_mixerInput[3].render->surface;
-+ }
-+ if (m_mixerInput.size() > 2)
-+ {
-+ past_surfaces[1] = m_mixerInput[2].render->surface;
-+ past_surfaces[0] = m_mixerInput[2].render->surface;
-+ }
-+ futu_surfaces[0] = m_mixerInput[1].render->surface;
-+ futu_surfaces[1] = m_mixerInput[0].render->surface;;
-+ }
-+ else
-+ { // second field
-+ if (m_mixerInput.size() > 3)
-+ {
-+ past_surfaces[3] = m_mixerInput[3].render->surface;
-+ }
-+ if (m_mixerInput.size() > 2)
-+ {
-+ past_surfaces[2] = m_mixerInput[2].render->surface;
-+ past_surfaces[1] = m_mixerInput[2].render->surface;
-+ }
-+ past_surfaces[0] = m_mixerInput[1].render->surface;
-+ futu_surfaces[0] = m_mixerInput[1].render->surface;
-+ futu_surfaces[1] = m_mixerInput[1].render->surface;
-+
-+ m_processPicture.DVDPic.pts = DVD_NOPTS_VALUE;
-+ m_processPicture.DVDPic.dts = DVD_NOPTS_VALUE;
-+ }
-+ m_processPicture.DVDPic.iRepeatPicture = 0.0;
-+ } // interlaced
-+
-+ VdpRect sourceRect;
-+ sourceRect.x0 = 0;
-+ sourceRect.y0 = 0;
-+ sourceRect.x1 = m_config.vidWidth;
-+ sourceRect.y1 = m_config.vidHeight;
-+
-+ VdpRect destRect;
-+ destRect.x0 = 0;
-+ destRect.y0 = 0;
-+ destRect.x1 = m_config.outWidth;
-+ destRect.y1 = m_config.outHeight;
-+
-+ // start vdpau video mixer
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_render(m_videoMixer,
-+ VDP_INVALID_HANDLE,
-+ 0,
-+ m_mixerfield,
-+ pastCount,
-+ past_surfaces,
-+ m_mixerInput[1].render->surface,
-+ futuCount,
-+ futu_surfaces,
-+ &sourceRect,
-+ m_processPicture.outputSurface,
-+ &destRect,
-+ &destRect,
-+ 0,
-+ NULL);
-+ CheckStatus(vdp_st, __LINE__);
-+
-+ if (m_mixerfield != VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME)
-+ {
-+ // in order to clip top and bottom lines when de-interlacing
-+ // we black those lines as a work around for not working
-+ // background colour using the mixer
-+ // pixel perfect is preferred over overscanning or zooming
-+
-+ VdpRect clipRect = destRect;
-+ clipRect.y1 = clipRect.y0 + 2;
-+ uint32_t *data[] = {m_BlackBar};
-+ uint32_t pitches[] = {destRect.x1};
-+ vdp_st = m_config.vdpProcs.vdp_output_surface_put_bits_native(m_processPicture.outputSurface,
-+ (void**)data,
-+ pitches,
-+ &clipRect);
-+ CheckStatus(vdp_st, __LINE__);
-+
-+ clipRect = destRect;
-+ clipRect.y0 = clipRect.y1 - 2;
-+ vdp_st = m_config.vdpProcs.vdp_output_surface_put_bits_native(m_processPicture.outputSurface,
-+ (void**)data,
-+ pitches,
-+ &clipRect);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+}
-+
-+
-+bool CMixer::CheckStatus(VdpStatus vdp_st, int line)
-+{
-+ if (vdp_st != VDP_STATUS_OK)
-+ {
-+ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.vdpProcs.vdp_get_error_string(vdp_st), vdp_st, __FILE__, line);
-+ m_vdpError = true;
-+ return true;
-+ }
-+ return false;
-+}
-+
-+//-----------------------------------------------------------------------------
-+// Output
-+//-----------------------------------------------------------------------------
-+COutput::COutput(CEvent *inMsgEvent) :
-+ CThread("Vdpau Output Thread"),
-+ m_controlPort("OutputControlPort", inMsgEvent, &m_outMsgEvent),
-+ m_dataPort("OutputDataPort", inMsgEvent, &m_outMsgEvent),
-+ m_mixer(&m_outMsgEvent)
-+{
-+ m_inMsgEvent = inMsgEvent;
-+
-+ CVdpauRenderPicture pic;
-+ pic.renderPicSection = &m_bufferPool.renderPicSec;
-+ pic.refCount = 0;
-+ for (unsigned int i = 0; i < NUM_RENDER_PICS; i++)
-+ {
-+ m_bufferPool.allRenderPics.push_back(pic);
-+ }
-+ for (unsigned int i = 0; i < m_bufferPool.allRenderPics.size(); ++i)
-+ {
-+ m_bufferPool.freeRenderPics.push_back(&m_bufferPool.allRenderPics[i]);
-+ }
-+}
-+
-+void COutput::Start()
-+{
-+ Create();
-+}
-+
-+COutput::~COutput()
-+{
-+ Dispose();
-+
-+ m_bufferPool.freeRenderPics.clear();
-+ m_bufferPool.usedRenderPics.clear();
-+ m_bufferPool.allRenderPics.clear();
-+}
-+
-+void COutput::Dispose()
-+{
-+ CSingleLock lock(g_graphicsContext);
-+ m_bStop = true;
-+ m_outMsgEvent.Set();
-+ StopThread();
-+ m_controlPort.Purge();
-+ m_dataPort.Purge();
-+}
-+
-+void COutput::OnStartup()
-+{
-+ CLog::Log(LOGNOTICE, "COutput::OnStartup: Output Thread created");
-+}
-+
-+void COutput::OnExit()
-+{
-+ CLog::Log(LOGNOTICE, "COutput::OnExit: Output Thread terminated");
-+}
-+
-+enum OUTPUT_STATES
-+{
-+ O_TOP = 0, // 0
-+ O_TOP_ERROR, // 1
-+ O_TOP_UNCONFIGURED, // 2
-+ O_TOP_CONFIGURED, // 3
-+ O_TOP_CONFIGURED_IDLE, // 4
-+ O_TOP_CONFIGURED_WORK, // 5
-+};
-+
-+int VDPAU_OUTPUT_parentStates[] = {
-+ -1,
-+ 0, //TOP_ERROR
-+ 0, //TOP_UNCONFIGURED
-+ 0, //TOP_CONFIGURED
-+ 3, //TOP_CONFIGURED_IDLE
-+ 3, //TOP_CONFIGURED_WORK
-+};
-+
-+void COutput::StateMachine(int signal, Protocol *port, Message *msg)
-+{
-+ for (int state = m_state; ; state = VDPAU_OUTPUT_parentStates[state])
-+ {
-+ switch (state)
-+ {
-+ case O_TOP: // TOP
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::FLUSH:
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ case COutputControlProtocol::PRECLEANUP:
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ else if (port == &m_dataPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputDataProtocol::RETURNPIC:
-+ CVdpauRenderPicture *pic;
-+ pic = *((CVdpauRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ {
-+ std::string portName = port == NULL ? "timer" : port->portName;
-+ CLog::Log(LOGWARNING, "COutput::%s - signal: %d form port: %s not handled for state: %d", __FUNCTION__, signal, portName.c_str(), m_state);
-+ }
-+ return;
-+
-+ case O_TOP_ERROR:
-+ break;
-+
-+ case O_TOP_UNCONFIGURED:
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::INIT:
-+ CVdpauConfig *data;
-+ data = (CVdpauConfig*)msg->data;
-+ if (data)
-+ {
-+ m_config = *data;
-+ }
-+ Init();
-+ Message *reply;
-+ if (m_mixer.m_controlPort.SendOutMessageSync(CMixerControlProtocol::INIT,
-+ &reply, 1000, &m_config, sizeof(m_config)))
-+ {
-+ if (reply->signal != CMixerControlProtocol::ACC)
-+ m_vdpError = true;
-+ reply->Release();
-+ }
-+
-+ // set initial number of
-+ m_bufferPool.numOutputSurfaces = 4;
-+ EnsureBufferPool();
-+ if (!m_vdpError)
-+ {
-+ m_state = O_TOP_CONFIGURED_IDLE;
-+ msg->Reply(COutputControlProtocol::ACC);
-+ }
-+ else
-+ {
-+ m_state = O_TOP_ERROR;
-+ msg->Reply(COutputControlProtocol::ERROR);
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED:
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::FLUSH:
-+ Flush();
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ case COutputControlProtocol::PRECLEANUP:
-+ Flush();
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ else if (port == &m_dataPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputDataProtocol::NEWFRAME:
-+ CVdpauDecodedPicture *frame;
-+ frame = (CVdpauDecodedPicture*)msg->data;
-+ if (frame)
-+ {
-+ m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::FRAME,
-+ frame,sizeof(CVdpauDecodedPicture));
-+ }
-+ return;
-+ case COutputDataProtocol::RETURNPIC:
-+ CVdpauRenderPicture *pic;
-+ pic = *((CVdpauRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ m_controlPort.SendInMessage(COutputControlProtocol::STATS);
-+ m_state = O_TOP_CONFIGURED_WORK;
-+ m_extTimeout = 0;
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ else if (port == &m_mixer.m_dataPort)
-+ {
-+ switch (signal)
-+ {
-+ case CMixerDataProtocol::PICTURE:
-+ CVdpauProcessedPicture *pic;
-+ pic = (CVdpauProcessedPicture*)msg->data;
-+ m_bufferPool.processedPics.push(*pic);
-+ m_state = O_TOP_CONFIGURED_WORK;
-+ m_extTimeout = 0;
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED_IDLE:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::TIMEOUT:
-+// uint16_t decoded, processed, render;
-+// m_config.stats->Get(decoded, processed, render);
-+// CLog::Log(LOGDEBUG, "CVDPAU::COutput - timeout idle: decoded: %d, proc: %d, render: %d", decoded, processed, render);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED_WORK:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::TIMEOUT:
-+ if (HasWork())
-+ {
-+ CVdpauRenderPicture *pic;
-+ pic = ProcessMixerPicture();
-+ if (pic)
-+ {
-+ m_config.stats->DecProcessed();
-+ m_config.stats->IncRender();
-+ m_dataPort.SendInMessage(COutputDataProtocol::PICTURE, &pic, sizeof(pic));
-+ }
-+ m_extTimeout = 1;
-+ }
-+ else
-+ {
-+ m_state = O_TOP_CONFIGURED_IDLE;
-+ m_extTimeout = 100;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ default: // we are in no state, should not happen
-+ CLog::Log(LOGERROR, "COutput::%s - no valid state: %d", __FUNCTION__, m_state);
-+ return;
-+ }
-+ } // for
-+}
-+
-+void COutput::Process()
-+{
-+ Message *msg;
-+ Protocol *port;
-+ bool gotMsg;
-+
-+ m_state = O_TOP_UNCONFIGURED;
-+ m_extTimeout = 1000;
-+ m_bStateMachineSelfTrigger = false;
-+
-+ while (!m_bStop)
-+ {
-+ gotMsg = false;
-+
-+ if (m_bStateMachineSelfTrigger)
-+ {
-+ m_bStateMachineSelfTrigger = false;
-+ // self trigger state machine
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ continue;
-+ }
-+ // check control port
-+ else if (m_controlPort.ReceiveOutMessage(&msg))
-+ {
-+ gotMsg = true;
-+ port = &m_controlPort;
-+ }
-+ // check data port
-+ else if (m_dataPort.ReceiveOutMessage(&msg))
-+ {
-+ gotMsg = true;
-+ port = &m_dataPort;
-+ }
-+ // check mixer data port
-+ else if (m_mixer.m_dataPort.ReceiveInMessage(&msg))
-+ {
-+ gotMsg = true;
-+ port = &m_mixer.m_dataPort;
-+ }
-+ if (gotMsg)
-+ {
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ continue;
-+ }
-+
-+ // wait for message
-+ else if (m_outMsgEvent.WaitMSec(m_extTimeout))
-+ {
-+ continue;
-+ }
-+ // time out
-+ else
-+ {
-+ msg = m_controlPort.GetMessage();
-+ msg->signal = COutputControlProtocol::TIMEOUT;
-+ port = 0;
-+ // signal timeout to state machine
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ }
-+ }
-+ Flush();
-+ Uninit();
-+}
-+
-+bool COutput::Init()
-+{
-+ if (!CreateGlxContext())
-+ return false;
-+
-+ if (!GLInit())
-+ return false;
-+
-+ m_mixer.Start();
-+ m_vdpError = false;
-+
-+ return true;
-+}
-+
-+bool COutput::Uninit()
-+{
-+ m_mixer.Dispose();
-+ GLUnmapSurfaces();
-+ GLUnbindPixmaps();
-+ ReleaseBufferPool();
-+ DestroyGlxContext();
-+ return true;
-+}
-+
-+void COutput::Flush()
-+{
-+ Message *reply;
-+ if (m_mixer.m_controlPort.SendOutMessageSync(CMixerControlProtocol::FLUSH,
-+ &reply,
-+ 2000))
-+ {
-+ reply->Release();
-+ }
-+ else
-+ CLog::Log(LOGERROR, "Coutput::%s - failed to flush mixer", __FUNCTION__);
-+
-+ Message *msg;
-+ while (m_mixer.m_dataPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == CMixerDataProtocol::PICTURE)
-+ {
-+ CVdpauProcessedPicture pic = *(CVdpauProcessedPicture*)msg->data;
-+ if (pic.DVDPic.format == DVDVideoPicture::FMT_VDPAU_420)
-+ {
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ if (pic.render)
-+ pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ }
-+ msg->Release();
-+ }
-+
-+ while (m_dataPort.ReceiveOutMessage(&msg))
-+ {
-+ if (msg->signal == COutputDataProtocol::NEWFRAME)
-+ {
-+ CVdpauDecodedPicture pic = *(CVdpauDecodedPicture*)msg->data;
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ if (pic.render)
-+ pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ else if (msg->signal == COutputDataProtocol::RETURNPIC)
-+ {
-+ CVdpauRenderPicture *pic;
-+ pic = *((CVdpauRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ }
-+ msg->Release();
-+ }
-+
-+ while (m_dataPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputDataProtocol::PICTURE)
-+ {
-+ CVdpauRenderPicture *pic;
-+ pic = *((CVdpauRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ }
-+ }
-+
-+ // reset used render flag which was cleared on mixer flush
-+ std::deque::iterator it;
-+ for (it = m_bufferPool.usedRenderPics.begin(); it != m_bufferPool.usedRenderPics.end(); ++it)
-+ {
-+ if ((*it)->DVDPic.format == DVDVideoPicture::FMT_VDPAU_420)
-+ {
-+ std::map::iterator it2;
-+ it2 = m_bufferPool.glVideoSurfaceMap.find((*it)->sourceIdx);
-+ if (it2 == m_bufferPool.glVideoSurfaceMap.end())
-+ {
-+ CLog::Log(LOGDEBUG, "COutput::Flush - gl surface not found");
-+ continue;
-+ }
-+ vdpau_render_state *render = it2->second.sourceVuv;
-+ if (render)
-+ render->state |= FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ }
-+}
-+
-+bool COutput::HasWork()
-+{
-+ if (m_config.usePixmaps)
-+ {
-+ if (!m_bufferPool.processedPics.empty() && FindFreePixmap() >= 0)
-+ return true;
-+ if (!m_bufferPool.notVisiblePixmaps.empty() && !m_bufferPool.freeRenderPics.empty())
-+ return true;
-+ return false;
-+ }
-+ else
-+ {
-+ if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty())
-+ return true;
-+ return false;
-+ }
-+}
-+
-+CVdpauRenderPicture* COutput::ProcessMixerPicture()
-+{
-+ CVdpauRenderPicture *retPic = 0;
-+
-+ if (m_config.usePixmaps)
-+ {
-+ if (!m_bufferPool.processedPics.empty() && FindFreePixmap() >= 0)
-+ {
-+ unsigned int i = FindFreePixmap();
-+ VdpauBufferPool::Pixmaps *pixmap = &m_bufferPool.pixmaps[i];
-+ pixmap->used = true;
-+ CVdpauProcessedPicture pic = m_bufferPool.processedPics.front();
-+ m_bufferPool.processedPics.pop();
-+ pixmap->surface = pic.outputSurface;
-+ pixmap->DVDPic = pic.DVDPic;
-+ pixmap->id = i;
-+ m_bufferPool.notVisiblePixmaps.push_back(pixmap);
-+ VdpStatus vdp_st;
-+ m_config.vdpProcs.vdp_presentation_queue_display(pixmap->vdp_flip_queue,
-+ pixmap->surface,0,0,0);
-+ }
-+ if (!m_bufferPool.notVisiblePixmaps.empty() && !m_bufferPool.freeRenderPics.empty())
-+ {
-+ VdpStatus vdp_st;
-+ VdpTime time;
-+ VdpPresentationQueueStatus status;
-+ VdpauBufferPool::Pixmaps *pixmap = m_bufferPool.notVisiblePixmaps.front();
-+ vdp_st = m_config.vdpProcs.vdp_presentation_queue_query_surface_status(
-+ pixmap->vdp_flip_queue, pixmap->surface, &status, &time);
-+
-+ if (vdp_st == VDP_STATUS_OK && status == VDP_PRESENTATION_QUEUE_STATUS_VISIBLE)
-+ {
-+ retPic = m_bufferPool.freeRenderPics.front();
-+ m_bufferPool.freeRenderPics.pop_front();
-+ m_bufferPool.usedRenderPics.push_back(retPic);
-+ retPic->sourceIdx = pixmap->id;
-+ retPic->DVDPic = pixmap->DVDPic;
-+ retPic->valid = true;
-+ retPic->texture[0] = pixmap->texture;
-+ retPic->crop = CRect(0,0,0,0);
-+ m_bufferPool.notVisiblePixmaps.pop_front();
-+ m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::BUFFER, &pixmap->surface, sizeof(pixmap->surface));
-+ }
-+ }
-+ } // pixmap
-+ else if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty())
-+ {
-+ retPic = m_bufferPool.freeRenderPics.front();
-+ m_bufferPool.freeRenderPics.pop_front();
-+ m_bufferPool.usedRenderPics.push_back(retPic);
-+ CVdpauProcessedPicture procPic = m_bufferPool.processedPics.front();
-+ m_bufferPool.processedPics.pop();
-+
-+ retPic->DVDPic = procPic.DVDPic;
-+ retPic->valid = true;
-+ if (retPic->DVDPic.format == DVDVideoPicture::FMT_VDPAU)
-+ {
-+ m_config.useInteropYuv = false;
-+ m_bufferPool.numOutputSurfaces = NUM_RENDER_PICS;
-+ EnsureBufferPool();
-+ GLMapSurfaces();
-+ retPic->sourceIdx = procPic.outputSurface;
-+ retPic->texture[0] = m_bufferPool.glOutputSurfaceMap[procPic.outputSurface].texture[0];
-+ retPic->crop = CRect(0,0,0,0);
-+ }
-+ else
-+ {
-+ m_config.useInteropYuv = true;
-+ GLMapSurfaces();
-+ retPic->sourceIdx = procPic.render->surface;
-+ for (unsigned int i=0; i<4; ++i)
-+ retPic->texture[i] = m_bufferPool.glVideoSurfaceMap[procPic.render->surface].texture[i];
-+ retPic->texWidth = m_config.surfaceWidth;
-+ retPic->texHeight = m_config.surfaceHeight;
-+ retPic->crop.x1 = 0;
-+ retPic->crop.y1 = 0;
-+ retPic->crop.x2 = m_config.surfaceWidth - m_config.vidWidth;
-+ retPic->crop.y2 = m_config.surfaceHeight - m_config.vidHeight;
-+ }
-+ }
-+ return retPic;
-+}
-+
-+void COutput::ProcessReturnPicture(CVdpauRenderPicture *pic)
-+{
-+ std::deque::iterator it;
-+ it = std::find(m_bufferPool.usedRenderPics.begin(), m_bufferPool.usedRenderPics.end(), pic);
-+ if (it == m_bufferPool.usedRenderPics.end())
-+ {
-+ CLog::Log(LOGWARNING, "COutput::ProcessReturnPicture - pic not found");
-+ return;
-+ }
-+ m_bufferPool.usedRenderPics.erase(it);
-+ m_bufferPool.freeRenderPics.push_back(pic);
-+ if (!pic->valid)
-+ {
-+ CLog::Log(LOGDEBUG, "COutput::%s - return of invalid render pic", __FUNCTION__);
-+ return;
-+ }
-+
-+ if (m_config.usePixmaps)
-+ {
-+ m_bufferPool.pixmaps[pic->sourceIdx].used = false;
-+ return;
-+ }
-+ else if (pic->DVDPic.format == DVDVideoPicture::FMT_VDPAU_420)
-+ {
-+ std::map::iterator it;
-+ it = m_bufferPool.glVideoSurfaceMap.find(pic->sourceIdx);
-+ if (it == m_bufferPool.glVideoSurfaceMap.end())
-+ {
-+ CLog::Log(LOGDEBUG, "COutput::ProcessReturnPicture - gl surface not found");
-+ return;
-+ }
-+ vdpau_render_state *render = it->second.sourceVuv;
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ else if (pic->DVDPic.format == DVDVideoPicture::FMT_VDPAU)
-+ {
-+ std::map::iterator it;
-+ it = m_bufferPool.glOutputSurfaceMap.find(pic->sourceIdx);
-+ if (it == m_bufferPool.glOutputSurfaceMap.end())
-+ {
-+ CLog::Log(LOGDEBUG, "COutput::ProcessReturnPicture - gl surface not found");
-+ return;
-+ }
-+ VdpOutputSurface outSurf = it->second.sourceRgb;
-+ m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::BUFFER, &outSurf, sizeof(outSurf));
-+ }
-+}
-+
-+int COutput::FindFreePixmap()
-+{
-+ // find free pixmap
-+ unsigned int i;
-+ for (i = 0; i < m_bufferPool.pixmaps.size(); ++i)
-+ {
-+ if (!m_bufferPool.pixmaps[i].used)
-+ break;
-+ }
-+ if (i == m_bufferPool.pixmaps.size())
-+ return -1;
-+ else
-+ return i;
-+}
-+
-+bool COutput::EnsureBufferPool()
-+{
-+ VdpStatus vdp_st;
-+
-+ // Creation of outputSurfaces
-+ VdpOutputSurface outputSurface;
-+ for (int i = m_bufferPool.outputSurfaces.size(); i < m_bufferPool.numOutputSurfaces; i++)
-+ {
-+ vdp_st = m_config.vdpProcs.vdp_output_surface_create(m_config.vdpDevice,
-+ VDP_RGBA_FORMAT_B8G8R8A8,
-+ m_config.outWidth,
-+ m_config.outHeight,
-+ &outputSurface);
-+ if (CheckStatus(vdp_st, __LINE__))
-+ return false;
-+ m_bufferPool.outputSurfaces.push_back(outputSurface);
-+
-+ m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::BUFFER,
-+ &outputSurface,
-+ sizeof(VdpOutputSurface));
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput::InitBufferPool - Output Surface created");
-+ }
-+
-+
-+ if (m_config.usePixmaps && m_bufferPool.pixmaps.empty())
-+ {
-+ // create pixmpas
-+ VdpauBufferPool::Pixmaps pixmap;
-+ int numPixmaps = NUM_RENDER_PICS;
-+ for (unsigned int i = 0; i < numPixmaps; i++)
-+ {
-+ pixmap.pixmap = None;
-+ pixmap.glPixmap = None;
-+ pixmap.vdp_flip_queue = VDP_INVALID_HANDLE;
-+ pixmap.vdp_flip_target = VDP_INVALID_HANDLE;
-+ MakePixmap(pixmap);
-+ glXMakeCurrent(m_Display, None, NULL);
-+ vdp_st = m_config.vdpProcs.vdp_presentation_queue_target_create_x11(m_config.vdpDevice,
-+ pixmap.pixmap, //x_window,
-+ &pixmap.vdp_flip_target);
-+
-+ CheckStatus(vdp_st, __LINE__);
-+
-+ vdp_st = m_config.vdpProcs.vdp_presentation_queue_create(m_config.vdpDevice,
-+ pixmap.vdp_flip_target,
-+ &pixmap.vdp_flip_queue);
-+ CheckStatus(vdp_st, __LINE__);
-+ glXMakeCurrent(m_Display, m_glPixmap, m_glContext);
-+
-+ pixmap.id = i;
-+ pixmap.used = false;
-+ m_bufferPool.pixmaps.push_back(pixmap);
-+ }
-+ GLBindPixmaps();
-+ }
-+
-+ return true;
-+}
-+
-+void COutput::ReleaseBufferPool()
-+{
-+ VdpStatus vdp_st;
-+
-+ CSingleLock lock(m_bufferPool.renderPicSec);
-+
-+ if (m_config.usePixmaps)
-+ {
-+ for (unsigned int i = 0; i < m_bufferPool.pixmaps.size(); ++i)
-+ {
-+ if (m_bufferPool.pixmaps[i].vdp_flip_queue != VDP_INVALID_HANDLE)
-+ {
-+ vdp_st = m_config.vdpProcs.vdp_presentation_queue_destroy(m_bufferPool.pixmaps[i].vdp_flip_queue);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+ if (m_bufferPool.pixmaps[i].vdp_flip_target != VDP_INVALID_HANDLE)
-+ {
-+ vdp_st = m_config.vdpProcs.vdp_presentation_queue_target_destroy(m_bufferPool.pixmaps[i].vdp_flip_target);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+ if (m_bufferPool.pixmaps[i].glPixmap)
-+ {
-+ glXDestroyPixmap(m_Display, m_bufferPool.pixmaps[i].glPixmap);
-+ }
-+ if (m_bufferPool.pixmaps[i].pixmap)
-+ {
-+ XFreePixmap(m_Display, m_bufferPool.pixmaps[i].pixmap);
-+ }
-+ }
-+ m_bufferPool.pixmaps.clear();
-+ }
-+
-+ // release all output surfaces
-+ for (unsigned int i = 0; i < m_bufferPool.outputSurfaces.size(); ++i)
-+ {
-+ if (m_bufferPool.outputSurfaces[i] == VDP_INVALID_HANDLE)
-+ continue;
-+ vdp_st = m_config.vdpProcs.vdp_output_surface_destroy(m_bufferPool.outputSurfaces[i]);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+ m_bufferPool.outputSurfaces.clear();
-+
-+ // invalidate all used render pictures
-+ for (unsigned int i = 0; i < m_bufferPool.usedRenderPics.size(); ++i)
-+ {
-+ m_bufferPool.usedRenderPics[i]->valid = false;
-+ }
-+}
-+
-+void COutput::InitMixer()
-+{
-+ for (unsigned int i = 0; i < m_bufferPool.outputSurfaces.size(); ++i)
-+ {
-+ m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::BUFFER,
-+ &m_bufferPool.outputSurfaces[i],
-+ sizeof(VdpOutputSurface));
-+ }
-+}
-+
-+bool COutput::MakePixmap(VdpauBufferPool::Pixmaps &pixmap)
-+{
-+ CLog::Log(LOGNOTICE,"Creating %ix%i pixmap", m_config.outWidth, m_config.outHeight);
-+
-+ // Get our window attribs.
-+ XWindowAttributes wndattribs;
-+ XGetWindowAttributes(m_Display, DefaultRootWindow(m_Display), &wndattribs);
-+
-+ pixmap.pixmap = XCreatePixmap(m_Display,
-+ DefaultRootWindow(m_Display),
-+ m_config.outWidth,
-+ m_config.outHeight,
-+ wndattribs.depth);
-+ if (!pixmap.pixmap)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COUtput::MakePixmap - GLX Error: MakePixmap: Unable to create XPixmap");
-+ return false;
-+ }
-+
-+// XGCValues values = {};
-+// GC xgc;
-+// values.foreground = BlackPixel (m_Display, DefaultScreen (m_Display));
-+// xgc = XCreateGC(m_Display, pixmap.pixmap, GCForeground, &values);
-+// XFillRectangle(m_Display, pixmap.pixmap, xgc, 0, 0, m_config.outWidth, m_config.outHeight);
-+// XFreeGC(m_Display, xgc);
-+
-+ if(!MakePixmapGL(pixmap))
-+ return false;
-+
-+ return true;
-+}
-+
-+bool COutput::MakePixmapGL(VdpauBufferPool::Pixmaps &pixmap)
-+{
-+ int num=0;
-+ int fbConfigIndex = 0;
-+
-+ int doubleVisAttributes[] = {
-+ GLX_RENDER_TYPE, GLX_RGBA_BIT,
-+ GLX_RED_SIZE, 8,
-+ GLX_GREEN_SIZE, 8,
-+ GLX_BLUE_SIZE, 8,
-+ GLX_ALPHA_SIZE, 8,
-+ GLX_DEPTH_SIZE, 8,
-+ GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
-+ GLX_BIND_TO_TEXTURE_RGBA_EXT, True,
-+ GLX_DOUBLEBUFFER, False,
-+ GLX_Y_INVERTED_EXT, True,
-+ GLX_X_RENDERABLE, True,
-+ None
-+ };
-+
-+ int pixmapAttribs[] = {
-+ GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
-+ GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT,
-+ None
-+ };
-+
-+ GLXFBConfig *fbConfigs;
-+ fbConfigs = glXChooseFBConfig(m_Display, DefaultScreen(m_Display), doubleVisAttributes, &num);
-+ if (fbConfigs==NULL)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput::MakPixmapGL - No compatible framebuffers found");
-+ return false;
-+ }
-+ fbConfigIndex = 0;
-+
-+ pixmap.glPixmap = glXCreatePixmap(m_Display, fbConfigs[fbConfigIndex], pixmap.pixmap, pixmapAttribs);
-+
-+ if (!pixmap.glPixmap)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput::MakPixmapGL - Could not create Pixmap");
-+ XFree(fbConfigs);
-+ return false;
-+ }
-+ XFree(fbConfigs);
-+ return true;
-+}
-+
-+bool COutput::GLInit()
-+{
-+ glXBindTexImageEXT = NULL;
-+ glXReleaseTexImageEXT = NULL;
-+#ifdef GL_NV_vdpau_interop
-+ glVDPAUInitNV = NULL;
-+ glVDPAUFiniNV = NULL;
-+ glVDPAURegisterOutputSurfaceNV = NULL;
-+ glVDPAURegisterVideoSurfaceNV = NULL;
-+ glVDPAUIsSurfaceNV = NULL;
-+ glVDPAUUnregisterSurfaceNV = NULL;
-+ glVDPAUSurfaceAccessNV = NULL;
-+ glVDPAUMapSurfacesNV = NULL;
-+ glVDPAUUnmapSurfacesNV = NULL;
-+ glVDPAUGetSurfaceivNV = NULL;
-+#endif
-+
-+ m_config.usePixmaps = !g_guiSettings.GetBool("videoplayer.usevdpauinteroprgb");
-+
-+#ifdef GL_NV_vdpau_interop
-+ if (glewIsSupported("GL_NV_vdpau_interop"))
-+ {
-+ if (!glVDPAUInitNV)
-+ glVDPAUInitNV = (PFNGLVDPAUINITNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUInitNV");
-+ if (!glVDPAUFiniNV)
-+ glVDPAUFiniNV = (PFNGLVDPAUFININVPROC)glXGetProcAddress((GLubyte *) "glVDPAUFiniNV");
-+ if (!glVDPAURegisterOutputSurfaceNV)
-+ glVDPAURegisterOutputSurfaceNV = (PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAURegisterOutputSurfaceNV");
-+ if (!glVDPAURegisterVideoSurfaceNV)
-+ glVDPAURegisterVideoSurfaceNV = (PFNGLVDPAUREGISTERVIDEOSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAURegisterVideoSurfaceNV");
-+ if (!glVDPAUIsSurfaceNV)
-+ glVDPAUIsSurfaceNV = (PFNGLVDPAUISSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAUIsSurfaceNV");
-+ if (!glVDPAUUnregisterSurfaceNV)
-+ glVDPAUUnregisterSurfaceNV = (PFNGLVDPAUUNREGISTERSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAUUnregisterSurfaceNV");
-+ if (!glVDPAUSurfaceAccessNV)
-+ glVDPAUSurfaceAccessNV = (PFNGLVDPAUSURFACEACCESSNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUSurfaceAccessNV");
-+ if (!glVDPAUMapSurfacesNV)
-+ glVDPAUMapSurfacesNV = (PFNGLVDPAUMAPSURFACESNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUMapSurfacesNV");
-+ if (!glVDPAUUnmapSurfacesNV)
-+ glVDPAUUnmapSurfacesNV = (PFNGLVDPAUUNMAPSURFACESNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUUnmapSurfacesNV");
-+ if (!glVDPAUGetSurfaceivNV)
-+ glVDPAUGetSurfaceivNV = (PFNGLVDPAUGETSURFACEIVNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUGetSurfaceivNV");
-+
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput GL interop supported");
-+ }
-+ else
-+#endif
-+ {
-+ m_config.usePixmaps = true;
-+ g_guiSettings.SetBool("videoplayer.usevdpauinteroprgb",false);
-+ g_guiSettings.SetBool("videoplayer.usevdpauinteropyuv",false);
-+ }
-+ if (!glXBindTexImageEXT)
-+ glXBindTexImageEXT = (PFNGLXBINDTEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXBindTexImageEXT");
-+ if (!glXReleaseTexImageEXT)
-+ glXReleaseTexImageEXT = (PFNGLXRELEASETEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXReleaseTexImageEXT");
-+
-+#ifdef GL_NV_vdpau_interop
-+ if (!m_config.usePixmaps)
-+ {
-+ while (glGetError() != GL_NO_ERROR);
-+ glVDPAUInitNV(reinterpret_cast(m_config.vdpDevice), reinterpret_cast(m_config.vdpProcs.vdp_get_proc_address));
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput - GLInitInterop glVDPAUInitNV failed");
-+ m_vdpError = true;
-+ return false;
-+ }
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput: vdpau gl interop initialized");
-+ }
-+#endif
-+ return true;
-+}
-+
-+void COutput::GLMapSurfaces()
-+{
-+#ifdef GL_NV_vdpau_interop
-+ if (m_config.usePixmaps)
-+ return;
-+
-+ if (m_config.useInteropYuv)
-+ {
-+ VdpauBufferPool::GLVideoSurface glSurface;
-+ if (m_config.videoSurfaces->size() != m_bufferPool.glVideoSurfaceMap.size())
-+ {
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ for (int i = 0; i < m_config.videoSurfaces->size(); i++)
-+ {
-+ if ((*m_config.videoSurfaces)[i]->surface == VDP_INVALID_HANDLE)
-+ continue;
-+
-+ if (m_bufferPool.glVideoSurfaceMap.find((*m_config.videoSurfaces)[i]->surface) == m_bufferPool.glVideoSurfaceMap.end())
-+ {
-+ glSurface.sourceVuv = (*m_config.videoSurfaces)[i];
-+ while (glGetError() != GL_NO_ERROR) ;
-+ glGenTextures(4, glSurface.texture);
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput error creating texture");
-+ m_vdpError = true;
-+ }
-+ glSurface.glVdpauSurface = glVDPAURegisterVideoSurfaceNV(reinterpret_cast((*m_config.videoSurfaces)[i]->surface),
-+ GL_TEXTURE_2D, 4, glSurface.texture);
-+
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput error register video surface");
-+ m_vdpError = true;
-+ }
-+ glVDPAUSurfaceAccessNV(glSurface.glVdpauSurface, GL_READ_ONLY);
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput error setting access");
-+ m_vdpError = true;
-+ }
-+ glVDPAUMapSurfacesNV(1, &glSurface.glVdpauSurface);
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput error mapping surface");
-+ m_vdpError = true;
-+ }
-+ m_bufferPool.glVideoSurfaceMap[(*m_config.videoSurfaces)[i]->surface] = glSurface;
-+ if (m_vdpError)
-+ return;
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput registered surface");
-+ }
-+ }
-+ }
-+ }
-+ else
-+ {
-+ if (m_bufferPool.glOutputSurfaceMap.size() != m_bufferPool.numOutputSurfaces)
-+ {
-+ VdpauBufferPool::GLVideoSurface glSurface;
-+ for (int i=m_bufferPool.glOutputSurfaceMap.size(); i(m_bufferPool.outputSurfaces[i]),
-+ GL_TEXTURE_2D, 1, glSurface.texture);
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput error register output surface");
-+ m_vdpError = true;
-+ }
-+ glVDPAUSurfaceAccessNV(glSurface.glVdpauSurface, GL_READ_ONLY);
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput error setting access");
-+ m_vdpError = true;
-+ }
-+ glVDPAUMapSurfacesNV(1, &glSurface.glVdpauSurface);
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput error mapping surface");
-+ m_vdpError = true;
-+ }
-+ m_bufferPool.glOutputSurfaceMap[m_bufferPool.outputSurfaces[i]] = glSurface;
-+ if (m_vdpError)
-+ return;
-+ }
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput registered output surfaces");
-+ }
-+ }
-+#endif
-+}
-+
-+void COutput::GLUnmapSurfaces()
-+{
-+#ifdef GL_NV_vdpau_interop
-+ if (m_config.usePixmaps)
-+ return;
-+
-+ { CSingleLock lock(*m_config.videoSurfaceSec);
-+ std::map::iterator it;
-+ for (it = m_bufferPool.glVideoSurfaceMap.begin(); it != m_bufferPool.glVideoSurfaceMap.end(); ++it)
-+ {
-+ glVDPAUUnregisterSurfaceNV(it->second.glVdpauSurface);
-+ glDeleteTextures(4, it->second.texture);
-+ }
-+ m_bufferPool.glVideoSurfaceMap.clear();
-+ }
-+
-+ std::map::iterator it;
-+ for (it = m_bufferPool.glOutputSurfaceMap.begin(); it != m_bufferPool.glOutputSurfaceMap.end(); ++it)
-+ {
-+ glVDPAUUnregisterSurfaceNV(it->second.glVdpauSurface);
-+ glDeleteTextures(1, it->second.texture);
-+ }
-+ m_bufferPool.glOutputSurfaceMap.clear();
-+
-+ glVDPAUFiniNV();
-+
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput: vdpau gl interop finished");
-+
-+#endif
-+}
-+
-+void COutput::GLBindPixmaps()
-+{
-+ if (!m_config.usePixmaps)
-+ return;
-+
-+ for (unsigned int i = 0; i < m_bufferPool.pixmaps.size(); i++)
-+ {
-+ // create texture
-+ glGenTextures(1, &m_bufferPool.pixmaps[i].texture);
-+
-+ //bind texture
-+ glBindTexture(GL_TEXTURE_2D, m_bufferPool.pixmaps[i].texture);
-+
-+ // bind pixmap
-+ glXBindTexImageEXT(m_Display, m_bufferPool.pixmaps[i].glPixmap, GLX_FRONT_LEFT_EXT, NULL);
-+
-+ glBindTexture(GL_TEXTURE_2D, 0);
-+ }
-+
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput: bound pixmaps");
-+}
-+
-+void COutput::GLUnbindPixmaps()
-+{
-+ if (!m_config.usePixmaps)
-+ return;
-+
-+ for (unsigned int i = 0; i < m_bufferPool.pixmaps.size(); i++)
-+ {
-+ // create texture
-+ if (!glIsTexture(m_bufferPool.pixmaps[i].texture))
-+ continue;
-+
-+ //bind texture
-+ glBindTexture(GL_TEXTURE_2D, m_bufferPool.pixmaps[i].texture);
-+
-+ // release pixmap
-+ glXReleaseTexImageEXT(m_Display, m_bufferPool.pixmaps[i].glPixmap, GLX_FRONT_LEFT_EXT);
-+
-+ glBindTexture(GL_TEXTURE_2D, 0);
-+
-+ glDeleteTextures(1, &m_bufferPool.pixmaps[i].texture);
-+ }
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput: unbound pixmaps");
-+}
-+
-+bool COutput::CheckStatus(VdpStatus vdp_st, int line)
-+{
-+ if (vdp_st != VDP_STATUS_OK)
-+ {
-+ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.vdpProcs.vdp_get_error_string(vdp_st), vdp_st, __FILE__, line);
-+ m_vdpError = true;
-+ return true;
-+ }
-+ return false;
-+}
-+
-+bool COutput::CreateGlxContext()
-+{
-+ GLXContext glContext;
-+ Window window;
-+
-+ m_Display = g_Windowing.GetDisplay();
-+ glContext = g_Windowing.GetGlxContext();
-+ m_Window = g_Windowing.GetWmWindow();
-+
-+ // Get our window attribs.
-+ XWindowAttributes wndattribs;
-+ XGetWindowAttributes(m_Display, m_Window, &wndattribs);
-+
-+ // Get visual Info
-+ XVisualInfo visInfo;
-+ visInfo.visualid = wndattribs.visual->visualid;
-+ int nvisuals = 0;
-+ XVisualInfo* visuals = XGetVisualInfo(m_Display, VisualIDMask, &visInfo, &nvisuals);
-+ if (nvisuals != 1)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput::CreateGlxContext - could not find visual");
-+ return false;
-+ }
-+ visInfo = visuals[0];
-+ XFree(visuals);
-+
-+ m_pixmap = XCreatePixmap(m_Display,
-+ DefaultRootWindow(m_Display),
-+ 192,
-+ 108,
-+ visInfo.depth);
-+ if (!m_pixmap)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput::CreateGlxContext - Unable to create XPixmap");
-+ return false;
-+ }
-+
-+ // create gl pixmap
-+ m_glPixmap = glXCreateGLXPixmap(m_Display, &visInfo, m_pixmap);
-+
-+ if (!m_glPixmap)
-+ {
-+ CLog::Log(LOGINFO, "VDPAU::COutput::CreateGlxContext - Could not create glPixmap");
-+ return false;
-+ }
-+
-+ m_glContext = glXCreateContext(m_Display, &visInfo, glContext, True);
-+
-+ if (!glXMakeCurrent(m_Display, m_glPixmap, m_glContext))
-+ {
-+ CLog::Log(LOGINFO, "VDPAU::COutput::CreateGlxContext - Could not make Pixmap current");
-+ return false;
-+ }
-+
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput::CreateGlxContext - created context");
-+ return true;
-+}
-+
-+bool COutput::DestroyGlxContext()
-+{
-+ if (m_glContext)
-+ {
-+ glXMakeCurrent(m_Display, None, NULL);
-+ glXDestroyContext(m_Display, m_glContext);
-+ }
-+ m_glContext = 0;
-+
-+ if (m_glPixmap)
-+ glXDestroyPixmap(m_Display, m_glPixmap);
-+ m_glPixmap = 0;
-+
-+ if (m_pixmap)
-+ XFreePixmap(m_Display, m_pixmap);
-+ m_pixmap = 0;
-+
-+ return true;
-+}
-+
-+
- #endif
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h 2012-05-14 14:15:12.131220406 +0200
-@@ -1,4 +1,3 @@
--
- #pragma once
- /*
- * Copyright (C) 2005-2009 Team XBMC
-@@ -21,6 +20,24 @@
- *
- */
-
-+/**
-+ * design goals:
-+ * - improve performance
-+ * max out hw resources: e.g. make 1080p60 play on ION2
-+ * allow advanced de-interlacing on ION
-+ *
-+ * - add vdpau/opengl interop
-+ *
-+ * - remove tight dependency to render thread
-+ * prior design needed to hijack render thread in order to do
-+ * gl interop functions. In particular this was a problem for
-+ * init and clear down. Introduction of GL_NV_vdpau_interop
-+ * increased the need to be independent from render thread
-+ *
-+ * - move to an actor based design in order to reduce the number
-+ * of locks needed.
-+ */
-+
- #include "DllAvUtil.h"
- #include "DVDVideoCodec.h"
- #include "DVDVideoCodecFFmpeg.h"
-@@ -37,118 +54,31 @@
- #include "settings/VideoSettings.h"
- #include "guilib/DispResource.h"
- #include "threads/Event.h"
--namespace Surface { class CSurface; }
--
--#define NUM_OUTPUT_SURFACES 4
--#define NUM_VIDEO_SURFACES_MPEG2 10 // (1 frame being decoded, 2 reference)
--#define NUM_VIDEO_SURFACES_H264 32 // (1 frame being decoded, up to 16 references)
--#define NUM_VIDEO_SURFACES_VC1 10 // (same as MPEG-2)
--#define NUM_OUTPUT_SURFACES_FOR_FULLHD 2
--#define FULLHD_WIDTH 1920
--
--class CVDPAU
-- : public CDVDVideoCodecFFmpeg::IHardwareDecoder
-- , public IDispResource
--{
--public:
--
-- struct pictureAge
-- {
-- int b_age;
-- int ip_age[2];
-- };
--
-- struct Desc
-- {
-- const char *name;
-- uint32_t id;
-- uint32_t aux; /* optional extra parameter... */
-- };
-+#include "threads/Thread.h"
-+#include "utils/ActorProtocol.h"
-
-- CVDPAU();
-- virtual ~CVDPAU();
--
-- virtual bool Open (AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces = 0);
-- virtual int Decode (AVCodecContext* avctx, AVFrame* frame);
-- virtual bool GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture);
-- virtual void Reset();
-- virtual void Close();
--
-- virtual int Check(AVCodecContext* avctx);
--
-- virtual const std::string Name() { return "vdpau"; }
--
-- bool MakePixmap(int width, int height);
-- bool MakePixmapGL();
--
-- void ReleasePixmap();
-- void BindPixmap();
--
-- PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT;
-- PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT;
-- GLXPixmap m_glPixmap;
-- Pixmap m_Pixmap;
-+using namespace Actor;
-
-- static void FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic);
-- static void FFDrawSlice(struct AVCodecContext *s,
-- const AVFrame *src, int offset[4],
-- int y, int type, int height);
-- static int FFGetBuffer(AVCodecContext *avctx, AVFrame *pic);
-
-- void Present();
-- bool ConfigVDPAU(AVCodecContext *avctx, int ref_frames);
-- void SpewHardwareAvailable();
-- void InitCSCMatrix(int Height);
-- bool CheckStatus(VdpStatus vdp_st, int line);
-- bool IsSurfaceValid(vdpau_render_state *render);
--
-- void CheckFeatures();
-- void SetColor();
-- void SetNoiseReduction();
-- void SetSharpness();
-- void SetDeinterlacing();
-- void SetHWUpscaling();
-+#define FULLHD_WIDTH 1920
-+#define MAX_PIC_Q_LENGTH 20 //for non-interop_yuv this controls the max length of the decoded pic to render completion Q
-
-- pictureAge picAge;
-- vdpau_render_state *past[2], *current, *future;
-- int tmpDeintMode, tmpDeintGUI, tmpDeint;
-- float tmpNoiseReduction, tmpSharpness;
-- float tmpBrightness, tmpContrast;
-- int OutWidth, OutHeight;
-- bool upScale;
-- std::queue m_DVDVideoPics;
--
-- static inline void ClearUsedForRender(vdpau_render_state **st)
-- {
-- if (*st) {
-- (*st)->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-- *st = NULL;
-- }
-- }
-+namespace VDPAU
-+{
-
-- VdpProcamp m_Procamp;
-- VdpCSCMatrix m_CSCMatrix;
-- VdpDevice HasDevice() { return vdp_device != VDP_INVALID_HANDLE; };
-- VdpChromaType vdp_chroma_type;
-+/**
-+ * VDPAU interface to driver
-+ */
-
-+struct VDPAU_procs
-+{
-+ VdpGetProcAddress * vdp_get_proc_address;
-+ VdpDeviceDestroy * vdp_device_destroy;
-
-- // protected:
-- void InitVDPAUProcs();
-- void FiniVDPAUProcs();
-- void FiniVDPAUOutput();
-- bool ConfigOutputMethod(AVCodecContext *avctx, AVFrame *pFrame);
-- bool FiniOutputMethod();
--
-- VdpDevice vdp_device;
-- VdpGetProcAddress * vdp_get_proc_address;
-- VdpPresentationQueueTarget vdp_flip_target;
-- VdpPresentationQueue vdp_flip_queue;
-- VdpDeviceDestroy * vdp_device_destroy;
--
-- VdpVideoSurfaceCreate * vdp_video_surface_create;
-- VdpVideoSurfaceDestroy * vdp_video_surface_destroy;
-- VdpVideoSurfacePutBitsYCbCr * vdp_video_surface_put_bits_y_cb_cr;
-- VdpVideoSurfaceGetBitsYCbCr * vdp_video_surface_get_bits_y_cb_cr;
-+ VdpVideoSurfaceCreate * vdp_video_surface_create;
-+ VdpVideoSurfaceDestroy * vdp_video_surface_destroy;
-+ VdpVideoSurfacePutBitsYCbCr * vdp_video_surface_put_bits_y_cb_cr;
-+ VdpVideoSurfaceGetBitsYCbCr * vdp_video_surface_get_bits_y_cb_cr;
-
- VdpOutputSurfacePutBitsYCbCr * vdp_output_surface_put_bits_y_cb_cr;
- VdpOutputSurfacePutBitsNative * vdp_output_surface_put_bits_native;
-@@ -158,15 +88,15 @@
- VdpOutputSurfaceRenderOutputSurface * vdp_output_surface_render_output_surface;
- VdpOutputSurfacePutBitsIndexed * vdp_output_surface_put_bits_indexed;
-
-- VdpVideoMixerCreate * vdp_video_mixer_create;
-- VdpVideoMixerSetFeatureEnables * vdp_video_mixer_set_feature_enables;
-- VdpVideoMixerQueryParameterSupport * vdp_video_mixer_query_parameter_support;
-- VdpVideoMixerQueryFeatureSupport * vdp_video_mixer_query_feature_support;
-- VdpVideoMixerDestroy * vdp_video_mixer_destroy;
-- VdpVideoMixerRender * vdp_video_mixer_render;
-- VdpVideoMixerSetAttributeValues * vdp_video_mixer_set_attribute_values;
-+ VdpVideoMixerCreate * vdp_video_mixer_create;
-+ VdpVideoMixerSetFeatureEnables * vdp_video_mixer_set_feature_enables;
-+ VdpVideoMixerQueryParameterSupport * vdp_video_mixer_query_parameter_support;
-+ VdpVideoMixerQueryFeatureSupport * vdp_video_mixer_query_feature_support;
-+ VdpVideoMixerDestroy * vdp_video_mixer_destroy;
-+ VdpVideoMixerRender * vdp_video_mixer_render;
-+ VdpVideoMixerSetAttributeValues * vdp_video_mixer_set_attribute_values;
-
-- VdpGenerateCSCMatrix * vdp_generate_csc_matrix;
-+ VdpGenerateCSCMatrix * vdp_generate_csc_matrix;
-
- VdpPresentationQueueTargetDestroy * vdp_presentation_queue_target_destroy;
- VdpPresentationQueueCreate * vdp_presentation_queue_create;
-@@ -179,64 +109,467 @@
-
- VdpGetErrorString * vdp_get_error_string;
-
-- VdpDecoderCreate * vdp_decoder_create;
-- VdpDecoderDestroy * vdp_decoder_destroy;
-- VdpDecoderRender * vdp_decoder_render;
-- VdpDecoderQueryCapabilities * vdp_decoder_query_caps;
-+ VdpDecoderCreate * vdp_decoder_create;
-+ VdpDecoderDestroy * vdp_decoder_destroy;
-+ VdpDecoderRender * vdp_decoder_render;
-+ VdpDecoderQueryCapabilities * vdp_decoder_query_caps;
-
- VdpPreemptionCallbackRegister * vdp_preemption_callback_register;
-
-- VdpOutputSurface outputSurfaces[NUM_OUTPUT_SURFACES];
-- VdpOutputSurface outputSurface;
-- VdpOutputSurface presentSurface;
--
-- VdpDecoder decoder;
-- VdpVideoMixer videoMixer;
-- VdpRect outRect;
-- VdpRect outRectVid;
-+};
-
-- static void* dl_handle;
-- VdpStatus (*dl_vdp_device_create_x11)(Display* display, int screen, VdpDevice* device, VdpGetProcAddress **get_proc_address);
-- VdpStatus (*dl_vdp_get_proc_address)(VdpDevice device, VdpFuncId function_id, void** function_pointer);
-- VdpStatus (*dl_vdp_preemption_callback_register)(VdpDevice device, VdpPreemptionCallback callback, void* context);
-+//-----------------------------------------------------------------------------
-+// VDPAU data structs
-+//-----------------------------------------------------------------------------
-
-- int surfaceNum;
-- int presentSurfaceNum;
-- int totalAvailableOutputSurfaces;
-- uint32_t vid_width, vid_height;
-- int surface_width, surface_height;
-- uint32_t max_references;
-- Display* m_Display;
-- bool vdpauConfigured;
-- uint32_t *m_BlackBar;
-+class CDecoder;
-+
-+/**
-+ * Buffer statistics used to control number of frames in queue
-+ */
-+
-+class CVdpauBufferStats
-+{
-+public:
-+ uint16_t decodedPics;
-+ uint16_t processedPics;
-+ uint16_t renderPics;
-+ uint64_t latency; // time decoder has waited for a frame, ideally there is no latency
-+ int playSpeed;
-+ bool canSkipDeint;
-+ int processCmd;
-+
-+ void IncDecoded() { CSingleLock l(m_sec); decodedPics++;}
-+ void DecDecoded() { CSingleLock l(m_sec); decodedPics--;}
-+ void IncProcessed() { CSingleLock l(m_sec); processedPics++;}
-+ void DecProcessed() { CSingleLock l(m_sec); processedPics--;}
-+ void IncRender() { CSingleLock l(m_sec); renderPics++;}
-+ void DecRender() { CSingleLock l(m_sec); renderPics--;}
-+ void Reset() { CSingleLock l(m_sec); decodedPics=0; processedPics=0;renderPics=0;latency=0;}
-+ void Get(uint16_t &decoded, uint16_t &processed, uint16_t &render) {CSingleLock l(m_sec); decoded = decodedPics, processed=processedPics, render=renderPics;}
-+ void SetParams(uint64_t time, int speed) { CSingleLock l(m_sec); latency = time; playSpeed = speed; }
-+ void GetParams(uint64_t &lat, int &speed) { CSingleLock l(m_sec); lat = latency; speed = playSpeed; }
-+ void SetCmd(int cmd) { CSingleLock l(m_sec); processCmd = cmd; }
-+ void GetCmd(int &cmd) { CSingleLock l(m_sec); cmd = processCmd; processCmd = 0; }
-+ void SetCanSkipDeint(bool canSkip) { CSingleLock l(m_sec); canSkipDeint = canSkip; }
-+ bool CanSkipDeint() { CSingleLock l(m_sec); if (canSkipDeint) return true; else return false;}
-+private:
-+ CCriticalSection m_sec;
-+};
-+
-+/**
-+ * CVdpauConfig holds all configuration parameters needed by vdpau
-+ * The structure is sent to the internal classes CMixer and COutput
-+ * for init.
-+ */
-+
-+struct CVdpauConfig
-+{
-+ int surfaceWidth;
-+ int surfaceHeight;
-+ int vidWidth;
-+ int vidHeight;
-+ int outWidth;
-+ int outHeight;
-+ VDPAU_procs vdpProcs;
-+ VdpDevice vdpDevice;
-+ VdpDecoder vdpDecoder;
-+ VdpChromaType vdpChromaType;
-+ CVdpauBufferStats *stats;
-+ CDecoder *vdpau;
-+ int featureCount;
-+ int upscale;
-+ VdpVideoMixerFeature vdpFeatures[10];
-+ std::vector *videoSurfaces;
-+ CCriticalSection *videoSurfaceSec;
-+ bool usePixmaps;
-+ int numRenderBuffers;
-+ uint32_t maxReferences;
-+ bool useInteropYuv;
-+};
-+
-+/**
-+ * Holds a decoded frame
-+ * Input to COutput for further processing
-+ */
-+struct CVdpauDecodedPicture
-+{
-+ DVDVideoPicture DVDPic;
-+ vdpau_render_state *render;
-+};
-+
-+/**
-+ * Frame after having been processed by vdpau mixer
-+ */
-+struct CVdpauProcessedPicture
-+{
-+ DVDVideoPicture DVDPic;
-+ vdpau_render_state *render;
-+ VdpOutputSurface outputSurface;
-+};
-
-+/**
-+ * Ready to render textures
-+ * Sent from COutput back to CDecoder
-+ * Objects are referenced by DVDVideoPicture and are sent
-+ * to renderer
-+ */
-+class CVdpauRenderPicture
-+{
-+ friend class CDecoder;
-+ friend class COutput;
-+public:
-+ DVDVideoPicture DVDPic;
-+ int texWidth, texHeight;
-+ CRect crop;
-+ GLuint texture[4];
-+ uint32_t sourceIdx;
-+ bool valid;
-+ CDecoder *vdpau;
-+ CVdpauRenderPicture* Acquire();
-+ long Release();
-+private:
-+ void ReturnUnused();
-+ int refCount;
-+ CCriticalSection *renderPicSection;
-+};
-
-+//-----------------------------------------------------------------------------
-+// Mixer
-+//-----------------------------------------------------------------------------
-+
-+class CMixerControlProtocol : public Protocol
-+{
-+public:
-+ CMixerControlProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {};
-+ enum OutSignal
-+ {
-+ INIT = 0,
-+ FLUSH,
-+ TIMEOUT,
-+ };
-+ enum InSignal
-+ {
-+ ACC,
-+ ERROR,
-+ };
-+};
-+
-+class CMixerDataProtocol : public Protocol
-+{
-+public:
-+ CMixerDataProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {};
-+ enum OutSignal
-+ {
-+ FRAME,
-+ BUFFER,
-+ };
-+ enum InSignal
-+ {
-+ PICTURE,
-+ };
-+};
-+
-+/**
-+ * Embeds the vdpau video mixer
-+ * Embedded by COutput class, gets decoded frames from COutput, processes
-+ * them in mixer ands sends processed frames back to COutput
-+ */
-+class CMixer : private CThread
-+{
-+public:
-+ CMixer(CEvent *inMsgEvent);
-+ virtual ~CMixer();
-+ void Start();
-+ void Dispose();
-+ CMixerControlProtocol m_controlPort;
-+ CMixerDataProtocol m_dataPort;
-+protected:
-+ void OnStartup();
-+ void OnExit();
-+ void Process();
-+ void StateMachine(int signal, Protocol *port, Message *msg);
-+ void Init();
-+ void Uninit();
-+ void Flush();
-+ void CreateVdpauMixer();
-+ void ProcessPicture();
-+ void InitCycle();
-+ void FiniCycle();
-+ void CheckFeatures();
-+ void SetPostProcFeatures(bool postProcEnabled);
-+ void PostProcOff();
-+ void InitCSCMatrix(int Width);
-+ bool GenerateStudioCSCMatrix(VdpColorStandard colorStandard, VdpCSCMatrix &studioCSCMatrix);
-+ void SetColor();
-+ void SetNoiseReduction();
-+ void SetSharpness();
-+ void SetDeintSkipChroma();
-+ void SetDeinterlacing();
-+ void SetHWUpscaling();
-+ void DisableHQScaling();
-+ EINTERLACEMETHOD GetDeinterlacingMethod(bool log = false);
-+ bool CheckStatus(VdpStatus vdp_st, int line);
-+ CEvent m_outMsgEvent;
-+ CEvent *m_inMsgEvent;
-+ int m_state;
-+ bool m_bStateMachineSelfTrigger;
-+
-+ // extended state variables for state machine
-+ int m_extTimeout;
-+ bool m_vdpError;
-+ CVdpauConfig m_config;
-+ VdpVideoMixer m_videoMixer;
-+ VdpProcamp m_Procamp;
-+ VdpCSCMatrix m_CSCMatrix;
-+ bool m_PostProc;
-+ float m_Brightness;
-+ float m_Contrast;
-+ float m_NoiseReduction;
-+ float m_Sharpness;
-+ int m_DeintMode;
-+ int m_Deint;
-+ int m_Upscale;
-+ uint32_t *m_BlackBar;
- VdpVideoMixerPictureStructure m_mixerfield;
-- int m_mixerstep;
-+ int m_mixerstep;
-+ int m_mixersteps;
-+ CVdpauProcessedPicture m_processPicture;
-+ std::queue m_outputSurfaces;
-+ std::queue m_decodedPics;
-+ std::deque m_mixerInput;
-+};
-+
-+//-----------------------------------------------------------------------------
-+// Output
-+//-----------------------------------------------------------------------------
-+
-+/**
-+ * Buffer pool holds allocated vdpau and gl resources
-+ * Embedded in COutput
-+ */
-+struct VdpauBufferPool
-+{
-+ struct Pixmaps
-+ {
-+ unsigned short id;
-+ bool used;
-+ DVDVideoPicture DVDPic;
-+ GLuint texture;
-+ Pixmap pixmap;
-+ GLXPixmap glPixmap;
-+ VdpPresentationQueueTarget vdp_flip_target;
-+ VdpPresentationQueue vdp_flip_queue;
-+ VdpOutputSurface surface;
-+ };
-+ struct GLVideoSurface
-+ {
-+ GLuint texture[4];
-+#ifdef GL_NV_vdpau_interop
-+ GLvdpauSurfaceNV glVdpauSurface;
-+#endif
-+ vdpau_render_state *sourceVuv;
-+ VdpOutputSurface sourceRgb;
-+ };
-+ unsigned short numOutputSurfaces;
-+ std::vector pixmaps;
-+ std::vector outputSurfaces;
-+ std::deque notVisiblePixmaps;
-+ std::vector allRenderPics;
-+ std::map glVideoSurfaceMap;
-+ std::map glOutputSurfaceMap;
-+ std::queue processedPics;
-+ std::deque usedRenderPics;
-+ std::deque freeRenderPics;
-+ CCriticalSection renderPicSec;
-+};
-+
-+class COutputControlProtocol : public Protocol
-+{
-+public:
-+ COutputControlProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {};
-+ enum OutSignal
-+ {
-+ INIT,
-+ FLUSH,
-+ PRECLEANUP,
-+ TIMEOUT,
-+ };
-+ enum InSignal
-+ {
-+ ACC,
-+ ERROR,
-+ STATS,
-+ };
-+};
-+
-+class COutputDataProtocol : public Protocol
-+{
-+public:
-+ COutputDataProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {};
-+ enum OutSignal
-+ {
-+ NEWFRAME = 0,
-+ RETURNPIC,
-+ };
-+ enum InSignal
-+ {
-+ PICTURE,
-+ };
-+};
-+
-+/**
-+ * COutput is embedded in CDecoder and embeds CMixer
-+ * The class has its own OpenGl context which is shared with render thread
-+ * COuput generated ready to render textures and passes them back to
-+ * CDecoder
-+ */
-+class COutput : private CThread
-+{
-+public:
-+ COutput(CEvent *inMsgEvent);
-+ virtual ~COutput();
-+ void Start();
-+ void Dispose();
-+ COutputControlProtocol m_controlPort;
-+ COutputDataProtocol m_dataPort;
-+protected:
-+ void OnStartup();
-+ void OnExit();
-+ void Process();
-+ void StateMachine(int signal, Protocol *port, Message *msg);
-+ bool HasWork();
-+ CVdpauRenderPicture *ProcessMixerPicture();
-+ void ProcessReturnPicture(CVdpauRenderPicture *pic);
-+ int FindFreePixmap();
-+ bool Init();
-+ bool Uninit();
-+ void Flush();
-+ bool CreateGlxContext();
-+ bool DestroyGlxContext();
-+ bool EnsureBufferPool();
-+ void ReleaseBufferPool();
-+ void InitMixer();
-+ bool GLInit();
-+ void GLMapSurfaces();
-+ void GLUnmapSurfaces();
-+ void GLBindPixmaps();
-+ void GLUnbindPixmaps();
-+ bool MakePixmap(VdpauBufferPool::Pixmaps &pixmap);
-+ bool MakePixmapGL(VdpauBufferPool::Pixmaps &pixmap);
-+ bool CheckStatus(VdpStatus vdp_st, int line);
-+ CEvent m_outMsgEvent;
-+ CEvent *m_inMsgEvent;
-+ int m_state;
-+ bool m_bStateMachineSelfTrigger;
-+
-+ // extended state variables for state machine
-+ int m_extTimeout;
-+ bool m_vdpError;
-+ CVdpauConfig m_config;
-+ VdpauBufferPool m_bufferPool;
-+ CMixer m_mixer;
-+ Display *m_Display;
-+ Window m_Window;
-+ GLXContext m_glContext;
-+ GLXWindow m_glWindow;
-+ Pixmap m_pixmap;
-+ GLXPixmap m_glPixmap;
-+
-+ // gl functions
-+ PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT;
-+ PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT;
-+#ifdef GL_NV_vdpau_interop
-+ PFNGLVDPAUINITNVPROC glVDPAUInitNV;
-+ PFNGLVDPAUFININVPROC glVDPAUFiniNV;
-+ PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC glVDPAURegisterOutputSurfaceNV;
-+ PFNGLVDPAUREGISTERVIDEOSURFACENVPROC glVDPAURegisterVideoSurfaceNV;
-+ PFNGLVDPAUISSURFACENVPROC glVDPAUIsSurfaceNV;
-+ PFNGLVDPAUUNREGISTERSURFACENVPROC glVDPAUUnregisterSurfaceNV;
-+ PFNGLVDPAUSURFACEACCESSNVPROC glVDPAUSurfaceAccessNV;
-+ PFNGLVDPAUMAPSURFACESNVPROC glVDPAUMapSurfacesNV;
-+ PFNGLVDPAUUNMAPSURFACESNVPROC glVDPAUUnmapSurfacesNV;
-+ PFNGLVDPAUGETSURFACEIVNVPROC glVDPAUGetSurfaceivNV;
-+#endif
-+};
-+
-+//-----------------------------------------------------------------------------
-+// VDPAU decoder
-+//-----------------------------------------------------------------------------
-+
-+/**
-+ * VDPAU main class
-+ */
-+class CDecoder
-+ : public CDVDVideoCodecFFmpeg::IHardwareDecoder
-+ , public IDispResource
-+{
-+ friend class CVdpauRenderPicture;
-+
-+public:
-+
-+ struct PictureAge
-+ {
-+ int b_age;
-+ int ip_age[2];
-+ };
-+
-+ struct Desc
-+ {
-+ const char *name;
-+ uint32_t id;
-+ uint32_t aux; /* optional extra parameter... */
-+ };
-+
-+ CDecoder();
-+ virtual ~CDecoder();
-+
-+ virtual bool Open (AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces = 0);
-+ virtual int Decode (AVCodecContext* avctx, AVFrame* frame) {return Decode(avctx, frame, false, false);};
-+ virtual int Decode (AVCodecContext* avctx, AVFrame* frame, bool bSoftDrain = false, bool bHardDrain = false);
-+ virtual bool GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture);
-+ virtual void Reset();
-+ virtual void Close();
-+ virtual long Release();
-+ virtual bool CanSkipDeint();
-+ virtual void SetSpeed(int speed);
-+
-+ virtual int Check(AVCodecContext* avctx);
-+ virtual const std::string Name() { return "vdpau"; }
-
- bool Supports(VdpVideoMixerFeature feature);
- bool Supports(EINTERLACEMETHOD method);
- EINTERLACEMETHOD AutoInterlaceMethod();
-+ static bool IsVDPAUFormat(PixelFormat fmt);
-
-- VdpVideoMixerFeature m_features[10];
-- int m_feature_count;
-+ static void FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic);
-+ static void FFDrawSlice(struct AVCodecContext *s,
-+ const AVFrame *src, int offset[4],
-+ int y, int type, int height);
-+ static int FFGetBuffer(AVCodecContext *avctx, AVFrame *pic);
-+
-+ virtual void OnLostDevice();
-+ virtual void OnResetDevice();
-+
-+protected:
-+ void SetWidthHeight(int width, int height);
-+ bool ConfigVDPAU(AVCodecContext *avctx, int ref_frames);
-+ void SpewHardwareAvailable();
-+ bool CheckStatus(VdpStatus vdp_st, int line);
-+ bool IsSurfaceValid(vdpau_render_state *render);
-+ void InitVDPAUProcs();
-+ void FiniVDPAUProcs();
-+ void FiniVDPAUOutput();
-+ void ReturnRenderPicture(CVdpauRenderPicture *renderPic);
-+ long ReleasePicReference();
-
-- static bool IsVDPAUFormat(PixelFormat fmt);
- static void ReadFormatOf( PixelFormat fmt
- , VdpDecoderProfile &decoder_profile
- , VdpChromaType &chroma_type);
-
-- std::vector m_videoSurfaces;
-- DllAvUtil m_dllAvUtil;
--
-- enum VDPAUOutputMethod
-- {
-- OUTPUT_NONE,
-- OUTPUT_PIXMAP,
-- OUTPUT_GL_INTEROP_RGB,
-- OUTPUT_GL_INTEROP_YUV
-- };
-- VDPAUOutputMethod m_vdpauOutputMethod;
-+ VdpStatus (*dl_vdp_device_create_x11)(Display* display, int screen, VdpDevice* device, VdpGetProcAddress **get_proc_address);
-+ VdpStatus (*dl_vdp_get_proc_address)(VdpDevice device, VdpFuncId function_id, void** function_pointer);
-+ VdpStatus (*dl_vdp_preemption_callback_register)(VdpDevice device, VdpPreemptionCallback callback, void* context);
-
- // OnLostDevice triggers transition from all states to LOST
- // internal errors trigger transition from OPEN to RESET
-@@ -247,9 +580,27 @@
- , VDPAU_LOST
- , VDPAU_ERROR
- } m_DisplayState;
-- CSharedSection m_DecoderSection;
-- CSharedSection m_DisplaySection;
-+ CCriticalSection m_DecoderSection;
- CEvent m_DisplayEvent;
-- virtual void OnLostDevice();
-- virtual void OnResetDevice();
-+
-+ static void* dl_handle;
-+ DllAvUtil m_dllAvUtil;
-+ Display* m_Display;
-+ ThreadIdentifier m_decoderThread;
-+ bool m_vdpauConfigured;
-+ CVdpauConfig m_vdpauConfig;
-+ std::vector m_videoSurfaces;
-+ CCriticalSection m_videoSurfaceSec;
-+ PictureAge m_picAge;
-+
-+ COutput m_vdpauOutput;
-+ CVdpauBufferStats m_bufferStats;
-+ CEvent m_inMsgEvent;
-+ CVdpauRenderPicture *m_presentPicture;
-+
-+ int m_speed;
-+ int m_codecControl;
- };
-+
-+}
-+
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp 2012-05-14 14:15:12.135220486 +0200
-@@ -0,0 +1,2382 @@
-+/*
-+ * 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
-+ *
-+ */
-+
-+#include "system.h"
-+#ifdef HAVE_LIBXVBA
-+#include
-+#include
-+#include "XVBA.h"
-+#include "windowing/WindowingFactory.h"
-+#include "guilib/GraphicContext.h"
-+#include "settings/GUISettings.h"
-+#include "settings/Settings.h"
-+#include "utils/TimeUtils.h"
-+#include "cores/dvdplayer/DVDClock.h"
-+
-+using namespace XVBA;
-+
-+// XVBA interface
-+
-+#define XVBA_LIBRARY "libXvBAW.so.1"
-+
-+typedef Bool (*XVBAQueryExtensionProc) (Display *dpy, int *vers);
-+typedef Status (*XVBACreateContextProc) (void *input, void *output);
-+typedef Status (*XVBADestroyContextProc) (void *context);
-+typedef Bool (*XVBAGetSessionInfoProc) (void *input, void *output);
-+typedef Status (*XVBACreateSurfaceProc) (void *input, void *output);
-+typedef Status (*XVBACreateGLSharedSurfaceProc)(void *input, void *output);
-+typedef Status (*XVBADestroySurfaceProc) (void *surface);
-+typedef Status (*XVBACreateDecodeBuffersProc) (void *input, void *output);
-+typedef Status (*XVBADestroyDecodeBuffersProc) (void *input);
-+typedef Status (*XVBAGetCapDecodeProc) (void *input, void *output);
-+typedef Status (*XVBACreateDecodeProc) (void *input, void *output);
-+typedef Status (*XVBADestroyDecodeProc) (void *session);
-+typedef Status (*XVBAStartDecodePictureProc) (void *input);
-+typedef Status (*XVBADecodePictureProc) (void *input);
-+typedef Status (*XVBAEndDecodePictureProc) (void *input);
-+typedef Status (*XVBASyncSurfaceProc) (void *input, void *output);
-+typedef Status (*XVBAGetSurfaceProc) (void *input);
-+typedef Status (*XVBATransferSurfaceProc) (void *input);
-+
-+static struct
-+{
-+ XVBAQueryExtensionProc QueryExtension;
-+ XVBACreateContextProc CreateContext;
-+ XVBADestroyContextProc DestroyContext;
-+ XVBAGetSessionInfoProc GetSessionInfo;
-+ XVBACreateSurfaceProc CreateSurface;
-+ XVBACreateGLSharedSurfaceProc CreateGLSharedSurface;
-+ XVBADestroySurfaceProc DestroySurface;
-+ XVBACreateDecodeBuffersProc CreateDecodeBuffers;
-+ XVBADestroyDecodeBuffersProc DestroyDecodeBuffers;
-+ XVBAGetCapDecodeProc GetCapDecode;
-+ XVBACreateDecodeProc CreateDecode;
-+ XVBADestroyDecodeProc DestroyDecode;
-+ XVBAStartDecodePictureProc StartDecodePicture;
-+ XVBADecodePictureProc DecodePicture;
-+ XVBAEndDecodePictureProc EndDecodePicture;
-+ XVBASyncSurfaceProc SyncSurface;
-+ XVBAGetSurfaceProc GetSurface;
-+ XVBATransferSurfaceProc TransferSurface;
-+}g_XVBA_vtable;
-+
-+//-----------------------------------------------------------------------------
-+//-----------------------------------------------------------------------------
-+
-+CXVBAContext *CXVBAContext::m_context = 0;
-+CCriticalSection CXVBAContext::m_section;
-+Display *CXVBAContext::m_display = 0;
-+void *CXVBAContext::m_dlHandle = 0;
-+
-+CXVBAContext::CXVBAContext()
-+{
-+ m_context = 0;
-+// m_dlHandle = 0;
-+ m_xvbaContext = 0;
-+ m_refCount = 0;
-+}
-+
-+void CXVBAContext::Release()
-+{
-+ CSingleLock lock(m_section);
-+
-+ m_refCount--;
-+ if (m_refCount <= 0)
-+ {
-+ Close();
-+ delete this;
-+ m_context = 0;
-+ }
-+}
-+
-+void CXVBAContext::Close()
-+{
-+ CLog::Log(LOGNOTICE, "XVBA::Close - closing decoder context");
-+
-+ DestroyContext();
-+// if (m_dlHandle)
-+// {
-+// dlclose(m_dlHandle);
-+// m_dlHandle = 0;
-+// }
-+}
-+
-+bool CXVBAContext::EnsureContext(CXVBAContext **ctx)
-+{
-+ CSingleLock lock(m_section);
-+
-+ if (m_context)
-+ {
-+ m_context->m_refCount++;
-+ *ctx = m_context;
-+ return true;
-+ }
-+
-+ m_context = new CXVBAContext();
-+ *ctx = m_context;
-+ {
-+ CSingleLock gLock(g_graphicsContext);
-+ if (!m_context->LoadSymbols() || !m_context->CreateContext())
-+ {
-+ delete m_context;
-+ m_context = 0;
-+ return false;
-+ }
-+ }
-+
-+ m_context->m_refCount++;
-+
-+ *ctx = m_context;
-+ return true;
-+}
-+
-+bool CXVBAContext::LoadSymbols()
-+{
-+ if (!m_dlHandle)
-+ {
-+ m_dlHandle = dlopen(XVBA_LIBRARY, RTLD_LAZY);
-+ if (!m_dlHandle)
-+ {
-+ const char* error = dlerror();
-+ if (!error)
-+ error = "dlerror() returned NULL";
-+
-+ CLog::Log(LOGERROR,"XVBA::LoadSymbols: Unable to get handle to lib: %s", error);
-+ return false;
-+ }
-+ }
-+ else
-+ return true;
-+
-+#define INIT_PROC(PREFIX, PROC) do { \
-+ g_##PREFIX##_vtable.PROC = (PREFIX##PROC##Proc) \
-+ dlsym(m_dlHandle, #PREFIX #PROC); \
-+ } while (0)
-+
-+#define INIT_PROC_CHECK(PREFIX, PROC) do { \
-+ dlerror(); \
-+ INIT_PROC(PREFIX, PROC); \
-+ if (dlerror()) { \
-+ dlclose(m_dlHandle); \
-+ m_dlHandle = NULL; \
-+ return false; \
-+ } \
-+ } while (0)
-+
-+#define XVBA_INIT_PROC(PROC) INIT_PROC_CHECK(XVBA, PROC)
-+
-+ XVBA_INIT_PROC(QueryExtension);
-+ XVBA_INIT_PROC(CreateContext);
-+ XVBA_INIT_PROC(DestroyContext);
-+ XVBA_INIT_PROC(GetSessionInfo);
-+ XVBA_INIT_PROC(CreateSurface);
-+ XVBA_INIT_PROC(CreateGLSharedSurface);
-+ XVBA_INIT_PROC(DestroySurface);
-+ XVBA_INIT_PROC(CreateDecodeBuffers);
-+ XVBA_INIT_PROC(DestroyDecodeBuffers);
-+ XVBA_INIT_PROC(GetCapDecode);
-+ XVBA_INIT_PROC(CreateDecode);
-+ XVBA_INIT_PROC(DestroyDecode);
-+ XVBA_INIT_PROC(StartDecodePicture);
-+ XVBA_INIT_PROC(DecodePicture);
-+ XVBA_INIT_PROC(EndDecodePicture);
-+ XVBA_INIT_PROC(SyncSurface);
-+ XVBA_INIT_PROC(GetSurface);
-+ XVBA_INIT_PROC(TransferSurface);
-+
-+#undef XVBA_INIT_PROC
-+#undef INIT_PROC
-+
-+ return true;
-+}
-+
-+bool CXVBAContext::CreateContext()
-+{
-+ if (m_xvbaContext)
-+ return true;
-+
-+ CLog::Log(LOGNOTICE,"XVBA::CreateContext - creating decoder context");
-+
-+ Drawable window;
-+ { CSingleLock lock(g_graphicsContext);
-+ if (!m_display)
-+ m_display = XOpenDisplay(NULL);
-+ window = 0;
-+ }
-+
-+ int version;
-+ if (!g_XVBA_vtable.QueryExtension(m_display, &version))
-+ return false;
-+ CLog::Log(LOGNOTICE,"XVBA::CreateContext - opening xvba version: %i", version);
-+
-+ // create XVBA Context
-+ XVBA_Create_Context_Input contextInput;
-+ XVBA_Create_Context_Output contextOutput;
-+ contextInput.size = sizeof(contextInput);
-+ contextInput.display = m_display;
-+ contextInput.draw = window;
-+ contextOutput.size = sizeof(contextOutput);
-+ if(Success != g_XVBA_vtable.CreateContext(&contextInput, &contextOutput))
-+ {
-+ CLog::Log(LOGERROR,"XVBA::CreateContext - failed to create context");
-+ return false;
-+ }
-+ m_xvbaContext = contextOutput.context;
-+
-+ return true;
-+}
-+
-+void CXVBAContext::DestroyContext()
-+{
-+ if (!m_xvbaContext)
-+ return;
-+
-+ g_XVBA_vtable.DestroyContext(m_xvbaContext);
-+ m_xvbaContext = 0;
-+// XCloseDisplay(m_display);
-+}
-+
-+void *CXVBAContext::GetContext()
-+{
-+ return m_xvbaContext;
-+}
-+
-+//-----------------------------------------------------------------------------
-+//-----------------------------------------------------------------------------
-+
-+static unsigned int decoderId = 0;
-+
-+CDecoder::CDecoder() : m_xvbaOutput(&m_inMsgEvent)
-+{
-+ m_xvbaConfig.context = 0;
-+ m_xvbaConfig.xvbaSession = 0;
-+ m_xvbaConfig.videoSurfaces = &m_videoSurfaces;
-+ m_xvbaConfig.videoSurfaceSec = &m_videoSurfaceSec;
-+ m_xvbaConfig.apiSec = &m_apiSec;
-+
-+ m_displayState = XVBA_OPEN;
-+}
-+
-+CDecoder::~CDecoder()
-+{
-+ Close();
-+}
-+
-+typedef struct {
-+ unsigned int size;
-+ unsigned int num_of_decodecaps;
-+ XVBADecodeCap decode_caps_list[];
-+} XVBA_GetCapDecode_Output_Base;
-+
-+void CDecoder::OnLostDevice()
-+{
-+ CLog::Log(LOGNOTICE,"XVBA::OnLostDevice event");
-+
-+ CSingleLock lock(m_decoderSection);
-+ DestroySession();
-+ if (m_xvbaConfig.context)
-+ m_xvbaConfig.context->Release();
-+ m_xvbaConfig.context = 0;
-+
-+ m_displayState = XVBA_LOST;
-+ m_displayEvent.Reset();
-+}
-+
-+void CDecoder::OnResetDevice()
-+{
-+ CLog::Log(LOGNOTICE,"XVBA::OnResetDevice event");
-+
-+ CSingleLock lock(m_decoderSection);
-+ if (m_displayState == XVBA_LOST)
-+ {
-+ m_displayState = XVBA_RESET;
-+ lock.Leave();
-+ m_displayEvent.Set();
-+ }
-+}
-+
-+bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat fmt, unsigned int surfaces)
-+{
-+ std::string Vendor = g_Windowing.GetRenderVendor();
-+ std::transform(Vendor.begin(), Vendor.end(), Vendor.begin(), ::tolower);
-+ if (Vendor.compare(0, 3, "ati") != 0)
-+ {
-+ return false;
-+ }
-+
-+ m_decoderId = decoderId++;
-+
-+ CLog::Log(LOGNOTICE,"(XVBA::Open) opening xvba decoder, id: %d", m_decoderId);
-+
-+ if(avctx->coded_width == 0
-+ || avctx->coded_height == 0)
-+ {
-+ CLog::Log(LOGWARNING,"(XVBA) no width/height available, can't init");
-+ return false;
-+ }
-+
-+ if (!m_dllAvUtil.Load())
-+ return false;
-+
-+ if (!CXVBAContext::EnsureContext(&m_xvbaConfig.context))
-+ return false;
-+
-+ // xvba get session info
-+ XVBA_GetSessionInfo_Input sessionInput;
-+ XVBA_GetSessionInfo_Output sessionOutput;
-+ sessionInput.size = sizeof(sessionInput);
-+ sessionInput.context = m_xvbaConfig.context->GetContext();
-+ sessionOutput.size = sizeof(sessionOutput);
-+ if (Success != g_XVBA_vtable.GetSessionInfo(&sessionInput, &sessionOutput))
-+ {
-+ CLog::Log(LOGERROR,"(XVBA) can't get session info");
-+ return false;
-+ }
-+ if (sessionOutput.getcapdecode_output_size == 0)
-+ {
-+ CLog::Log(LOGERROR,"(XVBA) session decode not supported");
-+ return false;
-+ }
-+
-+ // get decoder capabilities
-+ XVBA_GetCapDecode_Input capInput;
-+ XVBA_GetCapDecode_Output *capOutput;
-+ capInput.size = sizeof(capInput);
-+ capInput.context = m_xvbaConfig.context->GetContext();
-+ capOutput = (XVBA_GetCapDecode_Output *)calloc(sessionOutput.getcapdecode_output_size, 1);
-+ capOutput->size = sessionOutput.getcapdecode_output_size;
-+ if (Success != g_XVBA_vtable.GetCapDecode(&capInput, capOutput))
-+ {
-+ CLog::Log(LOGERROR,"(XVBA) can't get decode capabilities");
-+ return false;
-+ }
-+
-+ int match = -1;
-+ if (avctx->codec_id == CODEC_ID_H264)
-+ {
-+ // search for profile high
-+ for (unsigned int i = 0; i < capOutput->num_of_decodecaps; ++i)
-+ {
-+ if (capOutput->decode_caps_list[i].capability_id == XVBA_H264 &&
-+ capOutput->decode_caps_list[i].flags == XVBA_H264_HIGH)
-+ {
-+ match = (int) i;
-+ break;
-+ }
-+ }
-+ if (match < 0)
-+ {
-+ CLog::Log(LOGNOTICE, "(XVBA::Open) - profile XVBA_H264_HIGH not found");
-+ }
-+ }
-+ else if (avctx->codec_id == CODEC_ID_VC1)
-+ {
-+ // search for profile advanced
-+ for (unsigned int i = 0; i < capOutput->num_of_decodecaps; ++i)
-+ {
-+ if (capOutput->decode_caps_list[i].capability_id == XVBA_VC1 &&
-+ capOutput->decode_caps_list[i].flags == XVBA_VC1_ADVANCED)
-+ {
-+ match = (int) i;
-+ break;
-+ }
-+ }
-+ if (match < 0)
-+ {
-+ CLog::Log(LOGNOTICE, "(XVBA::Open) - profile XVBA_VC1_ADVANCED not found");
-+ }
-+ }
-+ else if (avctx->codec_id == CODEC_ID_MPEG2VIDEO)
-+ {
-+ // search for profile high
-+ for (unsigned int i = 0; i < capOutput->num_of_decodecaps; ++i)
-+ {
-+ if (capOutput->decode_caps_list[i].capability_id == XVBA_MPEG2_VLD)
-+ {
-+ // XXX: uncomment when implemented
-+ // match = (int) i;
-+ // break;
-+ }
-+ }
-+ if (match < 0)
-+ {
-+ CLog::Log(LOGNOTICE, "(XVBA::Open) - profile XVBA_MPEG2_VLD not found");
-+ }
-+ }
-+ else if (avctx->codec_id == CODEC_ID_WMV3)
-+ {
-+ // search for profile high
-+ for (unsigned int i = 0; i < capOutput->num_of_decodecaps; ++i)
-+ {
-+ if (capOutput->decode_caps_list[i].capability_id == XVBA_VC1 &&
-+ capOutput->decode_caps_list[i].flags == XVBA_VC1_MAIN)
-+ {
-+ match = (int) i;
-+ break;
-+ }
-+ }
-+ if (match < 0)
-+ {
-+ CLog::Log(LOGNOTICE, "(XVBA::Open) - profile XVBA_VC1_MAIN not found");
-+ }
-+ }
-+
-+ if (match < 0)
-+ {
-+ free(capOutput);
-+ return false;
-+ }
-+
-+ CLog::Log(LOGNOTICE,"(XVBA) using decoder capability id: %i flags: %i",
-+ capOutput->decode_caps_list[match].capability_id,
-+ capOutput->decode_caps_list[match].flags);
-+ CLog::Log(LOGNOTICE,"(XVBA) using surface type: %x",
-+ capOutput->decode_caps_list[match].surface_type);
-+
-+ m_xvbaConfig.decoderCap = capOutput->decode_caps_list[match];
-+
-+ free(capOutput);
-+
-+ // set some varables
-+ m_xvbaConfig.xvbaSession = 0;
-+ m_xvbaBufferPool.data_buffer = 0;
-+ m_xvbaBufferPool.iq_matrix_buffer = 0;
-+ m_xvbaBufferPool.picture_descriptor_buffer = 0;
-+ picAge.b_age = picAge.ip_age[0] = picAge.ip_age[1] = 256*256*256*64;
-+ m_presentPicture = 0;
-+ m_xvbaConfig.numRenderBuffers = surfaces;
-+ m_decoderThread = CThread::GetCurrentThreadId();
-+ m_speed = DVD_PLAYSPEED_NORMAL;
-+
-+ if (1) //g_guiSettings.GetBool("videoplayer.usexvbasharedsurface"))
-+ m_xvbaConfig.useSharedSurfaces = true;
-+ else
-+ m_xvbaConfig.useSharedSurfaces = false;
-+
-+ m_displayState = XVBA_OPEN;
-+
-+ // setup ffmpeg
-+ avctx->thread_count = 1;
-+ avctx->get_buffer = CDecoder::FFGetBuffer;
-+ avctx->release_buffer = CDecoder::FFReleaseBuffer;
-+ avctx->draw_horiz_band = CDecoder::FFDrawSlice;
-+ avctx->slice_flags = SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD;
-+
-+ g_Windowing.Register(this);
-+ return true;
-+}
-+
-+void CDecoder::Close()
-+{
-+ CLog::Log(LOGNOTICE, "XVBA::Close - closing decoder, id: %d", m_decoderId);
-+
-+ if (!m_xvbaConfig.context)
-+ return;
-+
-+ DestroySession();
-+ if (m_xvbaConfig.context)
-+ m_xvbaConfig.context->Release();
-+ m_xvbaConfig.context = 0;
-+
-+ while (!m_videoSurfaces.empty())
-+ {
-+ xvba_render_state *render = m_videoSurfaces.back();
-+ if(render->buffers_alllocated > 0)
-+ m_dllAvUtil.av_free(render->buffers);
-+ m_videoSurfaces.pop_back();
-+ free(render);
-+ }
-+
-+ g_Windowing.Unregister(this);
-+ m_dllAvUtil.Unload();
-+}
-+
-+long CDecoder::Release()
-+{
-+ // check if we should do some pre-cleanup here
-+ // a second decoder might need resources
-+ if (m_xvbaConfig.xvbaSession)
-+ {
-+ CSingleLock lock(m_decoderSection);
-+ CLog::Log(LOGNOTICE,"XVBA::Release pre-cleanup");
-+
-+ Message *reply;
-+ if (m_xvbaOutput.m_controlPort.SendOutMessageSync(COutputControlProtocol::PRECLEANUP,
-+ &reply,
-+ 2000))
-+ {
-+ bool success = reply->signal == COutputControlProtocol::ACC ? true : false;
-+ reply->Release();
-+ if (!success)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::%s - pre-cleanup returned error", __FUNCTION__);
-+ m_displayState = XVBA_ERROR;
-+ }
-+ }
-+ else
-+ {
-+ CLog::Log(LOGERROR, "XVBA::%s - pre-cleanup timed out", __FUNCTION__);
-+ m_displayState = XVBA_ERROR;
-+ }
-+
-+ for(unsigned int i = 0; i < m_videoSurfaces.size(); ++i)
-+ {
-+ xvba_render_state *render = m_videoSurfaces[i];
-+ if (render->surface && !(render->state & FF_XVBA_STATE_USED_FOR_RENDER))
-+ {
-+ g_XVBA_vtable.DestroySurface(render->surface);
-+ render->surface = 0;
-+ render->picture_descriptor = 0;
-+ render->iq_matrix = 0;
-+ }
-+ }
-+ }
-+ IHardwareDecoder::Release();
-+}
-+
-+long CDecoder::ReleasePicReference()
-+{
-+ return IHardwareDecoder::Release();
-+}
-+
-+bool CDecoder::Supports(EINTERLACEMETHOD method)
-+{
-+ if(method == VS_INTERLACEMETHOD_AUTO)
-+ return true;
-+
-+ if (1) //g_guiSettings.GetBool("videoplayer.usexvbasharedsurface"))
-+ {
-+ if (method == VS_INTERLACEMETHOD_XVBA)
-+ return true;
-+ }
-+
-+ return false;
-+}
-+
-+void CDecoder::ResetState()
-+{
-+ picAge.b_age = picAge.ip_age[0] = picAge.ip_age[1] = 256*256*256*64;
-+
-+ m_displayState = XVBA_OPEN;
-+}
-+
-+int CDecoder::Check(AVCodecContext* avctx)
-+{
-+ EDisplayState state;
-+
-+ { CSingleLock lock(m_decoderSection);
-+ state = m_displayState;
-+ }
-+
-+ if (state == XVBA_LOST)
-+ {
-+ CLog::Log(LOGNOTICE,"XVBA::Check waiting for display reset event");
-+ if (!m_displayEvent.WaitMSec(2000))
-+ {
-+ CLog::Log(LOGERROR, "XVBA::Check - device didn't reset in reasonable time");
-+ state = XVBA_RESET;;
-+ }
-+ else
-+ { CSingleLock lock(m_decoderSection);
-+ state = m_displayState;
-+ }
-+ }
-+ if (state == XVBA_RESET || state == XVBA_ERROR)
-+ {
-+ CLog::Log(LOGNOTICE,"XVBA::Check - Attempting recovery");
-+
-+ CSingleLock gLock(g_graphicsContext);
-+ CSingleLock lock(m_decoderSection);
-+
-+ DestroySession();
-+ ResetState();
-+ CXVBAContext::EnsureContext(&m_xvbaConfig.context);
-+
-+ if (state == XVBA_RESET)
-+ return VC_FLUSHED;
-+ else
-+ return VC_ERROR;
-+ }
-+ return 0;
-+}
-+
-+void CDecoder::SetError(const char* function, const char* msg, int line)
-+{
-+ CLog::Log(LOGERROR, "XVBA::%s - %s, line %d", function, msg, line);
-+ CSingleLock lock(m_decoderSection);
-+ m_displayState = XVBA_ERROR;
-+}
-+
-+bool CDecoder::CreateSession(AVCodecContext* avctx)
-+{
-+ m_xvbaConfig.surfaceWidth = (avctx->coded_width+15) & ~15;
-+ m_xvbaConfig.surfaceHeight = (avctx->coded_height+15) & ~15;
-+
-+ m_xvbaConfig.vidWidth = avctx->width;
-+ m_xvbaConfig.vidHeight = avctx->height;
-+
-+ XVBA_Create_Decode_Session_Input sessionInput;
-+ XVBA_Create_Decode_Session_Output sessionOutput;
-+
-+ sessionInput.size = sizeof(sessionInput);
-+ sessionInput.width = m_xvbaConfig.surfaceWidth;
-+ sessionInput.height = m_xvbaConfig.surfaceHeight;
-+ sessionInput.context = m_xvbaConfig.context->GetContext();
-+ sessionInput.decode_cap = &m_xvbaConfig.decoderCap;
-+ sessionOutput.size = sizeof(sessionOutput);
-+
-+ if (Success != g_XVBA_vtable.CreateDecode(&sessionInput, &sessionOutput))
-+ {
-+ SetError(__FUNCTION__, "failed to create decoder session", __LINE__);
-+ CLog::Log(LOGERROR, "Decoder failed with following stats: m_surfaceWidth %u, m_surfaceHeight %u,"
-+ " m_vidWidth %u, m_vidHeight %u, coded_width %d, coded_height %d",
-+ m_xvbaConfig.surfaceWidth,
-+ m_xvbaConfig.surfaceHeight,
-+ m_xvbaConfig.vidWidth,
-+ m_xvbaConfig.vidHeight,
-+ avctx->coded_width,
-+ avctx->coded_height);
-+ return false;
-+ }
-+ m_xvbaConfig.xvbaSession = sessionOutput.session;
-+
-+ // create decode buffers
-+ XVBA_Create_DecodeBuff_Input bufferInput;
-+ XVBA_Create_DecodeBuff_Output bufferOutput;
-+
-+ bufferInput.size = sizeof(bufferInput);
-+ bufferInput.session = m_xvbaConfig.xvbaSession;
-+ bufferInput.buffer_type = XVBA_PICTURE_DESCRIPTION_BUFFER;
-+ bufferInput.num_of_buffers = 1;
-+ bufferOutput.size = sizeof(bufferOutput);
-+ if (Success != g_XVBA_vtable.CreateDecodeBuffers(&bufferInput, &bufferOutput)
-+ || bufferOutput.num_of_buffers_in_list != 1)
-+ {
-+ SetError(__FUNCTION__, "failed to create picture buffer", __LINE__);
-+ return false;
-+ }
-+ m_xvbaBufferPool.picture_descriptor_buffer = bufferOutput.buffer_list;
-+
-+ // data buffer
-+ bufferInput.buffer_type = XVBA_DATA_BUFFER;
-+ if (Success != g_XVBA_vtable.CreateDecodeBuffers(&bufferInput, &bufferOutput)
-+ || bufferOutput.num_of_buffers_in_list != 1)
-+ {
-+ SetError(__FUNCTION__, "failed to create data buffer", __LINE__);
-+ return false;
-+ }
-+ m_xvbaBufferPool.data_buffer = bufferOutput.buffer_list;
-+
-+ // QO Buffer
-+ bufferInput.buffer_type = XVBA_QM_BUFFER;
-+ if (Success != g_XVBA_vtable.CreateDecodeBuffers(&bufferInput, &bufferOutput)
-+ || bufferOutput.num_of_buffers_in_list != 1)
-+ {
-+ SetError(__FUNCTION__, "failed to create qm buffer", __LINE__);
-+ return false;
-+ }
-+ m_xvbaBufferPool.iq_matrix_buffer = bufferOutput.buffer_list;
-+
-+
-+ // initialize output
-+ CSingleLock lock(g_graphicsContext);
-+ m_xvbaConfig.stats = &m_bufferStats;
-+ m_bufferStats.Reset();
-+ m_xvbaOutput.Start();
-+ Message *reply;
-+ if (m_xvbaOutput.m_controlPort.SendOutMessageSync(COutputControlProtocol::INIT,
-+ &reply,
-+ 2000,
-+ &m_xvbaConfig,
-+ sizeof(m_xvbaConfig)))
-+ {
-+ bool success = reply->signal == COutputControlProtocol::ACC ? true : false;
-+ reply->Release();
-+ if (!success)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::%s - vdpau output returned error", __FUNCTION__);
-+ m_xvbaOutput.Dispose();
-+ return false;
-+ }
-+ }
-+ else
-+ {
-+ CLog::Log(LOGERROR, "XVBA::%s - failed to init output", __FUNCTION__);
-+ m_xvbaOutput.Dispose();
-+ return false;
-+ }
-+ m_inMsgEvent.Reset();
-+
-+ return true;
-+}
-+
-+void CDecoder::DestroySession()
-+{
-+ m_xvbaOutput.Dispose();
-+
-+ XVBA_Destroy_Decode_Buffers_Input bufInput;
-+ bufInput.size = sizeof(bufInput);
-+ bufInput.num_of_buffers_in_list = 1;
-+
-+ for (unsigned int i=0; isurface)
-+ {
-+ g_XVBA_vtable.DestroySurface(render->surface);
-+ render->surface = 0;
-+ render->picture_descriptor = 0;
-+ render->iq_matrix = 0;
-+ }
-+ }
-+
-+ if (m_xvbaConfig.xvbaSession)
-+ g_XVBA_vtable.DestroyDecode(m_xvbaConfig.xvbaSession);
-+ m_xvbaConfig.xvbaSession = 0;
-+}
-+
-+bool CDecoder::IsSurfaceValid(xvba_render_state *render)
-+{
-+ // find render state in queue
-+ bool found(false);
-+ unsigned int i;
-+ for(i = 0; i < m_videoSurfaces.size(); ++i)
-+ {
-+ if(m_videoSurfaces[i] == render)
-+ {
-+ found = true;
-+ break;
-+ }
-+ }
-+ if (!found)
-+ {
-+ CLog::Log(LOGERROR,"%s - video surface not found", __FUNCTION__);
-+ return false;
-+ }
-+ if (m_videoSurfaces[i]->surface == 0)
-+ {
-+ m_videoSurfaces[i]->state = 0;
-+ return false;
-+ }
-+
-+ return true;
-+}
-+
-+bool CDecoder::EnsureDataControlBuffers(unsigned int num)
-+{
-+ if (m_xvbaBufferPool.data_control_buffers.size() >= num)
-+ return true;
-+
-+ unsigned int missing = num - m_xvbaBufferPool.data_control_buffers.size();
-+
-+ XVBA_Create_DecodeBuff_Input bufferInput;
-+ XVBA_Create_DecodeBuff_Output bufferOutput;
-+ bufferInput.size = sizeof(bufferInput);
-+ bufferInput.session = m_xvbaConfig.xvbaSession;
-+ bufferInput.buffer_type = XVBA_DATA_CTRL_BUFFER;
-+ bufferInput.num_of_buffers = 1;
-+ bufferOutput.size = sizeof(bufferOutput);
-+
-+ for (unsigned int i=0; iopaque;
-+ CDecoder* xvba = (CDecoder*)ctx->GetHardware();
-+ unsigned int i;
-+
-+ CSingleLock lock(xvba->m_decoderSection);
-+
-+ xvba_render_state * render = NULL;
-+ render = (xvba_render_state*)pic->data[0];
-+ if(!render)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::FFReleaseBuffer - invalid context handle provided");
-+ return;
-+ }
-+
-+ for(i=0; i<4; i++)
-+ pic->data[i]= NULL;
-+
-+ // find render state in queue
-+ if (!xvba->IsSurfaceValid(render))
-+ {
-+ CLog::Log(LOGDEBUG, "XVBA::FFReleaseBuffer - ignoring invalid buffer");
-+ return;
-+ }
-+
-+ render->state &= ~FF_XVBA_STATE_USED_FOR_REFERENCE;
-+}
-+
-+void CDecoder::FFDrawSlice(struct AVCodecContext *avctx,
-+ const AVFrame *src, int offset[4],
-+ int y, int type, int height)
-+{
-+ CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
-+ CDecoder* xvba = (CDecoder*)ctx->GetHardware();
-+
-+ CSingleLock lock(xvba->m_decoderSection);
-+
-+ if(xvba->m_displayState != XVBA_OPEN)
-+ return;
-+
-+ if(src->linesize[0] || src->linesize[1] || src->linesize[2]
-+ || offset[0] || offset[1] || offset[2])
-+ {
-+ CLog::Log(LOGERROR, "XVBA::FFDrawSlice - invalid linesizes or offsets provided");
-+ return;
-+ }
-+
-+ xvba_render_state * render;
-+
-+ render = (xvba_render_state*)src->data[0];
-+ if(!render)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::FFDrawSlice - invalid context handle provided");
-+ return;
-+ }
-+
-+ // ffmpeg vc-1 decoder does not flush, make sure the data buffer is still valid
-+ if (!xvba->IsSurfaceValid(render))
-+ {
-+ CLog::Log(LOGWARNING, "XVBA::FFDrawSlice - ignoring invalid buffer");
-+ return;
-+ }
-+
-+ // decoding
-+ XVBA_Decode_Picture_Start_Input startInput;
-+ startInput.size = sizeof(startInput);
-+ startInput.session = xvba->m_xvbaConfig.xvbaSession;
-+ startInput.target_surface = render->surface;
-+ { CSingleLock lock(xvba->m_apiSec);
-+ if (Success != g_XVBA_vtable.StartDecodePicture(&startInput))
-+ {
-+ xvba->SetError(__FUNCTION__, "failed to start decoding", __LINE__);
-+ return;
-+ }
-+ }
-+
-+ XVBA_Decode_Picture_Input picInput;
-+ picInput.size = sizeof(picInput);
-+ picInput.session = xvba->m_xvbaConfig.xvbaSession;
-+ XVBABufferDescriptor *list[2];
-+ picInput.buffer_list = list;
-+ list[0] = xvba->m_xvbaBufferPool.picture_descriptor_buffer;
-+ picInput.num_of_buffers_in_list = 1;
-+ if (avctx->codec_id == CODEC_ID_H264)
-+ {
-+ list[1] = xvba->m_xvbaBufferPool.iq_matrix_buffer;
-+ picInput.num_of_buffers_in_list = 2;
-+ }
-+
-+ { CSingleLock lock(xvba->m_apiSec);
-+ if (Success != g_XVBA_vtable.DecodePicture(&picInput))
-+ {
-+ xvba->SetError(__FUNCTION__, "failed to decode picture 1", __LINE__);
-+ return;
-+ }
-+ }
-+
-+ if (!xvba->EnsureDataControlBuffers(render->num_slices))
-+ return;
-+
-+ XVBADataCtrl *dataControl;
-+ int location = 0;
-+ xvba->m_xvbaBufferPool.data_buffer->data_size_in_buffer = 0;
-+ for (unsigned int j = 0; j < render->num_slices; ++j)
-+ {
-+ int startCodeSize = 0;
-+ uint8_t startCode[] = {0x00,0x00,0x01};
-+ if (avctx->codec_id == CODEC_ID_H264)
-+ {
-+ startCodeSize = 3;
-+ memcpy((uint8_t*)xvba->m_xvbaBufferPool.data_buffer->bufferXVBA+location,
-+ startCode, 3);
-+ }
-+ else if (avctx->codec_id == CODEC_ID_VC1 &&
-+ (memcmp(render->buffers[j].buffer, startCode, 3) != 0))
-+ {
-+ startCodeSize = 4;
-+ uint8_t sdf = 0x0d;
-+ memcpy((uint8_t*)xvba->m_xvbaBufferPool.data_buffer->bufferXVBA+location,
-+ startCode, 3);
-+ memcpy((uint8_t*)xvba->m_xvbaBufferPool.data_buffer->bufferXVBA+location+3,
-+ &sdf, 1);
-+ }
-+ // check for potential buffer overwrite
-+ unsigned int bytesToCopy = render->buffers[j].size;
-+ unsigned int freeBufferSize = xvba->m_xvbaBufferPool.data_buffer->buffer_size -
-+ xvba->m_xvbaBufferPool.data_buffer->data_size_in_buffer;
-+ if (bytesToCopy >= freeBufferSize)
-+ {
-+ xvba->SetError(__FUNCTION__, "bitstream buffer too large, maybe corrupted packet", __LINE__);
-+ return;
-+ }
-+ memcpy((uint8_t*)xvba->m_xvbaBufferPool.data_buffer->bufferXVBA+location+startCodeSize,
-+ render->buffers[j].buffer,
-+ render->buffers[j].size);
-+ dataControl = (XVBADataCtrl*)xvba->m_xvbaBufferPool.data_control_buffers[j]->bufferXVBA;
-+ dataControl->SliceDataLocation = location;
-+ dataControl->SliceBytesInBuffer = render->buffers[j].size+startCodeSize;
-+ dataControl->SliceBitsInBuffer = dataControl->SliceBytesInBuffer * 8;
-+ xvba->m_xvbaBufferPool.data_buffer->data_size_in_buffer += dataControl->SliceBytesInBuffer;
-+ location += dataControl->SliceBytesInBuffer;
-+ }
-+
-+ int bufSize = xvba->m_xvbaBufferPool.data_buffer->data_size_in_buffer;
-+ int padding = bufSize % 128;
-+ if (padding)
-+ {
-+ padding = 128 - padding;
-+ xvba->m_xvbaBufferPool.data_buffer->data_size_in_buffer += padding;
-+ memset((uint8_t*)xvba->m_xvbaBufferPool.data_buffer->bufferXVBA+bufSize,0,padding);
-+ }
-+
-+ picInput.num_of_buffers_in_list = 2;
-+ for (unsigned int i = 0; i < render->num_slices; ++i)
-+ {
-+ list[0] = xvba->m_xvbaBufferPool.data_buffer;
-+ list[0]->data_offset = 0;
-+ list[1] = xvba->m_xvbaBufferPool.data_control_buffers[i];
-+ list[1]->data_size_in_buffer = sizeof(*dataControl);
-+ { CSingleLock lock(xvba->m_apiSec);
-+ if (Success != g_XVBA_vtable.DecodePicture(&picInput))
-+ {
-+ xvba->SetError(__FUNCTION__, "failed to decode picture 2", __LINE__);
-+ return;
-+ }
-+ }
-+ }
-+ XVBA_Decode_Picture_End_Input endInput;
-+ endInput.size = sizeof(endInput);
-+ endInput.session = xvba->m_xvbaConfig.xvbaSession;
-+ { CSingleLock lock(xvba->m_apiSec);
-+ if (Success != g_XVBA_vtable.EndDecodePicture(&endInput))
-+ {
-+ xvba->SetError(__FUNCTION__, "failed to decode picture 3", __LINE__);
-+ return;
-+ }
-+ }
-+
-+ // decode sync and error
-+ XVBA_Surface_Sync_Input syncInput;
-+ XVBA_Surface_Sync_Output syncOutput;
-+ syncInput.size = sizeof(syncInput);
-+ syncInput.session = xvba->m_xvbaConfig.xvbaSession;
-+ syncInput.surface = render->surface;
-+ syncInput.query_status = XVBA_GET_SURFACE_STATUS;
-+ syncOutput.size = sizeof(syncOutput);
-+ int64_t start = CurrentHostCounter();
-+ while (1)
-+ {
-+ { CSingleLock lock(xvba->m_apiSec);
-+ if (Success != g_XVBA_vtable.SyncSurface(&syncInput, &syncOutput))
-+ {
-+ xvba->SetError(__FUNCTION__, "failed sync surface 1", __LINE__);
-+ return;
-+ }
-+ }
-+ if (!(syncOutput.status_flags & XVBA_STILL_PENDING))
-+ break;
-+ if (CurrentHostCounter() - start > CurrentHostFrequency())
-+ {
-+ xvba->SetError(__FUNCTION__, "timed out waiting for surface", __LINE__);
-+ break;
-+ }
-+ usleep(100);
-+ }
-+ render->state |= FF_XVBA_STATE_DECODED;
-+}
-+
-+int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
-+{
-+ CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
-+ CDecoder* xvba = (CDecoder*)ctx->GetHardware();
-+ struct pictureAge* pA = &xvba->picAge;
-+
-+ pic->data[0] =
-+ pic->data[1] =
-+ pic->data[2] =
-+ pic->data[3] = 0;
-+
-+ pic->linesize[0] =
-+ pic->linesize[1] =
-+ pic->linesize[2] =
-+ pic->linesize[3] = 0;
-+
-+ CSingleLock lock(xvba->m_decoderSection);
-+
-+ if(xvba->m_displayState != XVBA_OPEN)
-+ return -1;
-+
-+ if (xvba->m_xvbaConfig.xvbaSession == 0)
-+ {
-+ if (!xvba->CreateSession(avctx))
-+ return -1;
-+ }
-+
-+ xvba_render_state * render = NULL;
-+ // find unused surface
-+ { CSingleLock lock(xvba->m_videoSurfaceSec);
-+ for(unsigned int i = 0; i < xvba->m_videoSurfaces.size(); ++i)
-+ {
-+ if(!(xvba->m_videoSurfaces[i]->state & (FF_XVBA_STATE_USED_FOR_REFERENCE | FF_XVBA_STATE_USED_FOR_RENDER)))
-+ {
-+ render = xvba->m_videoSurfaces[i];
-+ render->state = 0;
-+ break;
-+ }
-+ }
-+ }
-+
-+ // create a new render state
-+ if (render == NULL)
-+ {
-+ render = (xvba_render_state*)calloc(sizeof(xvba_render_state), 1);
-+ if (render == NULL)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::FFGetBuffer - calloc failed");
-+ return -1;
-+ }
-+ render->surface = 0;
-+ render->buffers_alllocated = 0;
-+ CSingleLock lock(xvba->m_videoSurfaceSec);
-+ xvba->m_videoSurfaces.push_back(render);
-+ }
-+
-+ // create a new surface
-+ if (render->surface == 0)
-+ {
-+ XVBA_Create_Surface_Input surfaceInput;
-+ XVBA_Create_Surface_Output surfaceOutput;
-+ surfaceInput.size = sizeof(surfaceInput);
-+ surfaceInput.surface_type = xvba->m_xvbaConfig.decoderCap.surface_type;
-+ surfaceInput.width = xvba->m_xvbaConfig.surfaceWidth;
-+ surfaceInput.height = xvba->m_xvbaConfig.surfaceHeight;
-+ surfaceInput.session = xvba->m_xvbaConfig.xvbaSession;
-+ surfaceOutput.size = sizeof(surfaceOutput);
-+ { CSingleLock lock(xvba->m_apiSec);
-+ if (Success != g_XVBA_vtable.CreateSurface(&surfaceInput, &surfaceOutput))
-+ {
-+ xvba->SetError(__FUNCTION__, "failed to create video surface", __LINE__);
-+ return -1;
-+ }
-+ }
-+ render->surface = surfaceOutput.surface;
-+ render->picture_descriptor = (XVBAPictureDescriptor *)xvba->m_xvbaBufferPool.picture_descriptor_buffer->bufferXVBA;
-+ render->iq_matrix = (XVBAQuantMatrixAvc *)xvba->m_xvbaBufferPool.iq_matrix_buffer->bufferXVBA;
-+ CLog::Log(LOGDEBUG, "XVBA::FFGetBuffer - created video surface");
-+ }
-+
-+ if (render == NULL)
-+ return -1;
-+
-+ pic->data[0] = (uint8_t*)render;
-+
-+ if(pic->reference)
-+ {
-+ pic->age = pA->ip_age[0];
-+ pA->ip_age[0]= pA->ip_age[1]+1;
-+ pA->ip_age[1]= 1;
-+ pA->b_age++;
-+ }
-+ else
-+ {
-+ pic->age = pA->b_age;
-+ pA->ip_age[0]++;
-+ pA->ip_age[1]++;
-+ pA->b_age = 1;
-+ }
-+ pic->type= FF_BUFFER_TYPE_USER;
-+
-+ render->state |= FF_XVBA_STATE_USED_FOR_REFERENCE;
-+ render->state &= ~FF_XVBA_STATE_DECODED;
-+ pic->reordered_opaque= avctx->reordered_opaque;
-+
-+ return 0;
-+}
-+
-+int CDecoder::Decode(AVCodecContext* avctx, AVFrame* frame)
-+{
-+ int result = Check(avctx);
-+ if (result)
-+ return result;
-+
-+ CSingleLock lock(m_decoderSection);
-+
-+ if(frame)
-+ { // we have a new frame from decoder
-+
-+ xvba_render_state * render = (xvba_render_state*)frame->data[0];
-+ if(!render)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::Decode - no render buffer");
-+ return VC_ERROR;
-+ }
-+
-+ // ffmpeg vc-1 decoder does not flush, make sure the data buffer is still valid
-+ if (!IsSurfaceValid(render))
-+ {
-+ CLog::Log(LOGWARNING, "XVBA::Decode - ignoring invalid buffer");
-+ return VC_BUFFER;
-+ }
-+ if (!(render->state & FF_XVBA_STATE_DECODED))
-+ {
-+ CLog::Log(LOGDEBUG, "XVBA::Decode - ffmpeg failed");
-+ return VC_BUFFER;
-+ }
-+
-+ CSingleLock lock(m_videoSurfaceSec);
-+ render->state |= FF_XVBA_STATE_USED_FOR_RENDER;
-+ lock.Leave();
-+
-+ // send frame to output for processing
-+ CXvbaDecodedPicture pic;
-+ memset(&pic.DVDPic, 0, sizeof(pic.DVDPic));
-+ ((CDVDVideoCodecFFmpeg*)avctx->opaque)->GetPictureCommon(&pic.DVDPic);
-+ pic.render = render;
-+ m_bufferStats.IncDecoded();
-+ m_xvbaOutput.m_dataPort.SendOutMessage(COutputDataProtocol::NEWFRAME, &pic, sizeof(pic));
-+
-+ m_codecControl = pic.DVDPic.iFlags & (DVP_FLAG_DRAIN | DVP_FLAG_SKIP_PROC);
-+ if (m_codecControl & DVP_FLAG_SKIP_PROC)
-+ {
-+ m_bufferStats.SetCmd(DVP_FLAG_SKIP_PROC);
-+ }
-+ }
-+
-+ int retval = 0;
-+ uint16_t decoded, processed, render;
-+ Message *msg;
-+ while (m_xvbaOutput.m_controlPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputControlProtocol::ERROR)
-+ {
-+ m_displayState = XVBA_ERROR;
-+ retval |= VC_ERROR;
-+ }
-+ msg->Release();
-+ }
-+
-+ m_bufferStats.Get(decoded, processed, render);
-+
-+ uint64_t startTime = CurrentHostCounter();
-+ while (!retval)
-+ {
-+ if (m_xvbaOutput.m_dataPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputDataProtocol::PICTURE)
-+ {
-+ if (m_presentPicture)
-+ {
-+ m_presentPicture->ReturnUnused();
-+ m_presentPicture = 0;
-+ }
-+
-+ m_presentPicture = *(CXvbaRenderPicture**)msg->data;
-+ m_presentPicture->xvba = this;
-+ m_bufferStats.DecRender();
-+ m_bufferStats.Get(decoded, processed, render);
-+ retval |= VC_PICTURE;
-+ }
-+ msg->Release();
-+ }
-+ else if (m_xvbaOutput.m_controlPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputControlProtocol::STATS)
-+ {
-+ m_bufferStats.Get(decoded, processed, render);
-+ }
-+ else
-+ {
-+ m_displayState = XVBA_ERROR;
-+ retval |= VC_ERROR;
-+ }
-+ msg->Release();
-+ }
-+
-+ if ((m_codecControl & DVP_FLAG_DRAIN))
-+ {
-+ if (decoded + processed + render < 2)
-+ {
-+ retval |= VC_BUFFER;
-+ }
-+ }
-+ else
-+ {
-+ if (decoded + processed + render < 4)
-+ {
-+ retval |= VC_BUFFER;
-+ }
-+ }
-+
-+ if (!retval && !m_inMsgEvent.WaitMSec(2000))
-+ break;
-+ }
-+ uint64_t diff = CurrentHostCounter() - startTime;
-+ if (retval & VC_PICTURE)
-+ {
-+ m_bufferStats.SetParams(diff, m_speed);
-+ if (diff*1000/CurrentHostFrequency() > 50)
-+ CLog::Log(LOGDEBUG,"XVBA::Decode long wait: %d", (int)((diff*1000)/CurrentHostFrequency()));
-+ }
-+
-+ if (!retval)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::%s - timed out waiting for output message", __FUNCTION__);
-+ m_displayState = XVBA_ERROR;
-+ retval |= VC_ERROR;
-+ }
-+
-+ return retval;
-+
-+}
-+
-+bool CDecoder::GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture)
-+{
-+ CSingleLock lock(m_decoderSection);
-+
-+ if (m_displayState != XVBA_OPEN)
-+ return false;
-+
-+ *picture = m_presentPicture->DVDPic;
-+ picture->xvba = m_presentPicture;
-+
-+ return true;
-+}
-+
-+void CDecoder::ReturnRenderPicture(CXvbaRenderPicture *renderPic)
-+{
-+ m_xvbaOutput.m_dataPort.SendOutMessage(COutputDataProtocol::RETURNPIC, &renderPic, sizeof(renderPic));
-+}
-+
-+
-+//void CDecoder::CopyYV12(int index, uint8_t *dest)
-+//{
-+// CSharedLock lock(m_decoderSection);
-+//
-+// { CSharedLock dLock(m_displaySection);
-+// if(m_displayState != XVBA_OPEN)
-+// return;
-+// }
-+//
-+// if (!m_flipBuffer[index].outPic)
-+// {
-+// CLog::Log(LOGWARNING, "XVBA::Present: present picture is NULL");
-+// return;
-+// }
-+//
-+// XVBA_GetSurface_Target target;
-+// target.size = sizeof(target);
-+// target.surfaceType = XVBA_YV12;
-+// target.flag = XVBA_FRAME;
-+//
-+// XVBA_Get_Surface_Input input;
-+// input.size = sizeof(input);
-+// input.session = m_xvbaSession;
-+// input.src_surface = m_flipBuffer[index].outPic->render->surface;
-+// input.target_buffer = dest;
-+// input.target_pitch = m_surfaceWidth;
-+// input.target_width = m_surfaceWidth;
-+// input.target_height = m_surfaceHeight;
-+// input.target_parameter = target;
-+// { CSingleLock lock(m_apiSec);
-+// if (Success != g_XVBA_vtable.GetSurface(&input))
-+// {
-+// CLog::Log(LOGERROR,"(XVBA::CopyYV12) failed to get surface");
-+// }
-+// }
-+//}
-+
-+void CDecoder::Reset()
-+{
-+ CSingleLock lock(m_decoderSection);
-+
-+ if (!m_xvbaConfig.xvbaSession)
-+ return;
-+
-+ Message *reply;
-+ if (m_xvbaOutput.m_controlPort.SendOutMessageSync(COutputControlProtocol::FLUSH,
-+ &reply,
-+ 2000))
-+ {
-+ bool success = reply->signal == COutputControlProtocol::ACC ? true : false;
-+ reply->Release();
-+ if (!success)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::%s - flush returned error", __FUNCTION__);
-+ m_displayState = XVBA_ERROR;
-+ }
-+ else
-+ m_bufferStats.Reset();
-+ }
-+ else
-+ {
-+ CLog::Log(LOGERROR, "XVBA::%s - flush timed out", __FUNCTION__);
-+ m_displayState = XVBA_ERROR;
-+ }
-+}
-+
-+bool CDecoder::CanSkipDeint()
-+{
-+ return m_bufferStats.CanSkipDeint();
-+}
-+
-+void CDecoder::SetSpeed(int speed)
-+{
-+ m_speed = speed;
-+}
-+
-+//-----------------------------------------------------------------------------
-+// RenderPicture
-+//-----------------------------------------------------------------------------
-+
-+CXvbaRenderPicture* CXvbaRenderPicture::Acquire()
-+{
-+ CSingleLock lock(*renderPicSection);
-+
-+ if (refCount == 0)
-+ xvba->Acquire();
-+
-+ refCount++;
-+ return this;
-+}
-+
-+long CXvbaRenderPicture::Release()
-+{
-+ CSingleLock lock(*renderPicSection);
-+
-+ refCount--;
-+ if (refCount > 0)
-+ return refCount;
-+
-+ lock.Leave();
-+ xvba->ReturnRenderPicture(this);
-+ xvba->ReleasePicReference();
-+
-+ return refCount;
-+}
-+
-+void CXvbaRenderPicture::Transfer()
-+{
-+ CSingleLock lock(*renderPicSection);
-+
-+ if (valid)
-+ xvbaOutput->TransferSurface(sourceIdx);
-+}
-+
-+void CXvbaRenderPicture::ReturnUnused()
-+{
-+ { CSingleLock lock(*renderPicSection);
-+ if (refCount > 0)
-+ return;
-+ }
-+ if (xvba)
-+ xvba->ReturnRenderPicture(this);
-+}
-+
-+//-----------------------------------------------------------------------------
-+// Output
-+//-----------------------------------------------------------------------------
-+COutput::COutput(CEvent *inMsgEvent) :
-+ CThread("XVBA Output Thread"),
-+ m_controlPort("OutputControlPort", inMsgEvent, &m_outMsgEvent),
-+ m_dataPort("OutputDataPort", inMsgEvent, &m_outMsgEvent)
-+{
-+ m_inMsgEvent = inMsgEvent;
-+
-+ CXvbaRenderPicture pic;
-+ pic.renderPicSection = &m_bufferPool.renderPicSec;
-+ pic.refCount = 0;
-+ for (unsigned int i = 0; i < NUM_RENDER_PICS; i++)
-+ {
-+ m_bufferPool.allRenderPics.push_back(pic);
-+ }
-+ for (unsigned int i = 0; i < m_bufferPool.allRenderPics.size(); ++i)
-+ {
-+ m_bufferPool.freeRenderPics.push_back(&m_bufferPool.allRenderPics[i]);
-+ }
-+}
-+
-+void COutput::Start()
-+{
-+ Create();
-+}
-+
-+COutput::~COutput()
-+{
-+ Dispose();
-+
-+ m_bufferPool.freeRenderPics.clear();
-+ m_bufferPool.usedRenderPics.clear();
-+ m_bufferPool.allRenderPics.clear();
-+}
-+
-+void COutput::Dispose()
-+{
-+ CSingleLock lock(g_graphicsContext);
-+ m_bStop = true;
-+ m_outMsgEvent.Set();
-+ StopThread();
-+ m_controlPort.Purge();
-+ m_dataPort.Purge();
-+}
-+
-+void COutput::OnStartup()
-+{
-+ CLog::Log(LOGNOTICE, "COutput::OnStartup: Output Thread created");
-+}
-+
-+void COutput::OnExit()
-+{
-+ CLog::Log(LOGNOTICE, "COutput::OnExit: Output Thread terminated");
-+}
-+
-+enum OUTPUT_STATES
-+{
-+ O_TOP = 0, // 0
-+ O_TOP_ERROR, // 1
-+ O_TOP_UNCONFIGURED, // 2
-+ O_TOP_CONFIGURED, // 3
-+ O_TOP_CONFIGURED_WAIT_RES1, // 4
-+ O_TOP_CONFIGURED_WAIT_DEC, // 5
-+ O_TOP_CONFIGURED_STEP1, // 6
-+ O_TOP_CONFIGURED_WAIT_RES2, // 7
-+ O_TOP_CONFIGURED_STEP2, // 8
-+};
-+
-+int OUTPUT_parentStates[] = {
-+ -1,
-+ 0, //TOP_ERROR
-+ 0, //TOP_UNCONFIGURED
-+ 0, //TOP_CONFIGURED
-+ 3, //TOP_CONFIGURED_WAIT_RES1
-+ 3, //TOP_CONFIGURED_WAIT_DEC
-+ 3, //TOP_CONFIGURED_STEP1
-+ 3, //TOP_CONFIGURED_WAIT_RES2
-+ 3, //TOP_CONFIGURED_STEP2
-+};
-+
-+void COutput::StateMachine(int signal, Protocol *port, Message *msg)
-+{
-+ for (int state = m_state; ; state = OUTPUT_parentStates[state])
-+ {
-+ switch (state)
-+ {
-+ case O_TOP: // TOP
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::FLUSH:
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ case COutputControlProtocol::PRECLEANUP:
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ else if (port == &m_dataPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputDataProtocol::RETURNPIC:
-+ CXvbaRenderPicture *pic;
-+ pic = *((CXvbaRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ {
-+ std::string portName = port == NULL ? "timer" : port->portName;
-+ CLog::Log(LOGWARNING, "COutput::%s - signal: %d form port: %s not handled for state: %d", __FUNCTION__, signal, portName.c_str(), m_state);
-+ }
-+ return;
-+
-+ case O_TOP_ERROR:
-+ m_extTimeout = 1000;
-+ break;
-+
-+ case O_TOP_UNCONFIGURED:
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::INIT:
-+ CXvbaConfig *data;
-+ data = (CXvbaConfig*)msg->data;
-+ if (data)
-+ {
-+ m_config = *data;
-+ }
-+ Init();
-+ EnsureBufferPool();
-+ if (!m_xvbaError)
-+ {
-+ m_state = O_TOP_CONFIGURED_WAIT_RES1;
-+ msg->Reply(COutputControlProtocol::ACC);
-+ }
-+ else
-+ {
-+ m_state = O_TOP_ERROR;
-+ msg->Reply(COutputControlProtocol::ERROR);
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED:
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::FLUSH:
-+ m_state = O_TOP_CONFIGURED_WAIT_RES1;
-+ Flush();
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ case COutputControlProtocol::PRECLEANUP:
-+ m_state = O_TOP_CONFIGURED_WAIT_RES1;
-+ Flush();
-+ PreReleaseBufferPool();
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ else if (port == &m_dataPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputDataProtocol::NEWFRAME:
-+ CXvbaDecodedPicture *frame;
-+ frame = (CXvbaDecodedPicture*)msg->data;
-+ if (frame)
-+ {
-+ m_decodedPics.push(*frame);
-+ m_extTimeout = 0;
-+ }
-+ return;
-+ case COutputDataProtocol::RETURNPIC:
-+ CXvbaRenderPicture *pic;
-+ pic = *((CXvbaRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ m_controlPort.SendInMessage(COutputControlProtocol::STATS);
-+ m_extTimeout = 0;
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED_WAIT_RES1:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::TIMEOUT:
-+ if (!m_decodedPics.empty() && FindFreeSurface() >= 0 && !m_bufferPool.freeRenderPics.empty())
-+ {
-+ m_state = O_TOP_CONFIGURED_WAIT_DEC;
-+ m_bStateMachineSelfTrigger = true;
-+ }
-+ else
-+ {
-+ if (m_extTimeout != 0)
-+ {
-+ uint16_t decoded, processed, render;
-+ m_config.stats->Get(decoded, processed, render);
-+// CLog::Log(LOGDEBUG, "CVDPAU::COutput - timeout idle: decoded: %d, proc: %d, render: %d", decoded, processed, render);
-+ }
-+ m_extTimeout = 100;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED_WAIT_DEC:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::TIMEOUT:
-+ if (IsDecodingFinished())
-+ {
-+ m_state = O_TOP_CONFIGURED_STEP1;
-+ m_bStateMachineSelfTrigger = true;
-+ }
-+ else
-+ {
-+ m_extTimeout = 1;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED_STEP1:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::TIMEOUT:
-+ m_processPicture = m_decodedPics.front();
-+ m_decodedPics.pop();
-+ InitCycle();
-+ CXvbaRenderPicture *pic;
-+ pic = ProcessPicture();
-+ if (pic)
-+ {
-+ m_config.stats->IncRender();
-+ m_dataPort.SendInMessage(COutputDataProtocol::PICTURE, &pic, sizeof(pic));
-+ }
-+ if (m_xvbaError)
-+ {
-+ m_state = O_TOP_ERROR;
-+ return;
-+ }
-+ if (m_deinterlacing && !m_deintSkip)
-+ {
-+ m_state = O_TOP_CONFIGURED_WAIT_RES2;
-+ m_extTimeout = 0;
-+ }
-+ else
-+ {
-+ FiniCycle();
-+ m_state = O_TOP_CONFIGURED_WAIT_RES1;
-+ m_extTimeout = 0;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED_WAIT_RES2:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::TIMEOUT:
-+ if (FindFreeSurface() >= 0 && !m_bufferPool.freeRenderPics.empty())
-+ {
-+ m_state = O_TOP_CONFIGURED_STEP2;
-+ m_bStateMachineSelfTrigger = true;
-+ }
-+ else
-+ {
-+ if (m_extTimeout != 0)
-+ {
-+ uint16_t decoded, processed, render;
-+ m_config.stats->Get(decoded, processed, render);
-+ CLog::Log(LOGDEBUG, "CVDPAU::COutput - timeout idle: decoded: %d, proc: %d, render: %d", decoded, processed, render);
-+ }
-+ m_extTimeout = 100;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED_STEP2:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::TIMEOUT:
-+ CXvbaRenderPicture *pic;
-+ m_deintStep = 1;
-+ pic = ProcessPicture();
-+ if (pic)
-+ {
-+ m_config.stats->IncRender();
-+ m_dataPort.SendInMessage(COutputDataProtocol::PICTURE, &pic, sizeof(pic));
-+ }
-+ if (m_xvbaError)
-+ {
-+ m_state = O_TOP_ERROR;
-+ return;
-+ }
-+ FiniCycle();
-+ m_state = O_TOP_CONFIGURED_WAIT_RES1;
-+ m_extTimeout = 0;
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ default: // we are in no state, should not happen
-+ CLog::Log(LOGERROR, "COutput::%s - no valid state: %d", __FUNCTION__, m_state);
-+ return;
-+ }
-+ } // for
-+}
-+
-+void COutput::Process()
-+{
-+ Message *msg;
-+ Protocol *port;
-+ bool gotMsg;
-+
-+ m_state = O_TOP_UNCONFIGURED;
-+ m_extTimeout = 1000;
-+ m_bStateMachineSelfTrigger = false;
-+
-+ while (!m_bStop)
-+ {
-+ gotMsg = false;
-+
-+ if (m_bStateMachineSelfTrigger)
-+ {
-+ m_bStateMachineSelfTrigger = false;
-+ // self trigger state machine
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ continue;
-+ }
-+ // check control port
-+ else if (m_controlPort.ReceiveOutMessage(&msg))
-+ {
-+ gotMsg = true;
-+ port = &m_controlPort;
-+ }
-+ // check data port
-+ else if (m_dataPort.ReceiveOutMessage(&msg))
-+ {
-+ gotMsg = true;
-+ port = &m_dataPort;
-+ }
-+ if (gotMsg)
-+ {
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ continue;
-+ }
-+
-+ // wait for message
-+ else if (m_outMsgEvent.WaitMSec(m_extTimeout))
-+ {
-+ continue;
-+ }
-+ // time out
-+ else
-+ {
-+ msg = m_controlPort.GetMessage();
-+ msg->signal = COutputControlProtocol::TIMEOUT;
-+ port = 0;
-+ // signal timeout to state machine
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ }
-+ }
-+ Flush();
-+ Uninit();
-+}
-+
-+bool COutput::Init()
-+{
-+ if (!CreateGlxContext())
-+ return false;
-+
-+ m_xvbaError = false;
-+ m_processPicture.render = 0;
-+
-+ return true;
-+}
-+
-+bool COutput::Uninit()
-+{
-+ ReleaseBufferPool();
-+ DestroyGlxContext();
-+ return true;
-+}
-+
-+void COutput::Flush()
-+{
-+ while (!m_decodedPics.empty())
-+ {
-+ CXvbaDecodedPicture pic = m_decodedPics.front();
-+ m_decodedPics.pop();
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ if (pic.render)
-+ pic.render->state &= ~(FF_XVBA_STATE_USED_FOR_RENDER | FF_XVBA_STATE_DECODED);
-+ }
-+
-+ if (m_processPicture.render)
-+ {
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ m_processPicture.render->state &= ~(FF_XVBA_STATE_USED_FOR_RENDER | FF_XVBA_STATE_DECODED);
-+ m_processPicture.render = 0;
-+ }
-+
-+ Message *msg;
-+ while (m_dataPort.ReceiveOutMessage(&msg))
-+ {
-+ if (msg->signal == COutputDataProtocol::NEWFRAME)
-+ {
-+ CXvbaDecodedPicture pic = *(CXvbaDecodedPicture*)msg->data;
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ if (pic.render)
-+ pic.render->state &= ~(FF_XVBA_STATE_USED_FOR_RENDER | FF_XVBA_STATE_DECODED);
-+ }
-+ else if (msg->signal == COutputDataProtocol::RETURNPIC)
-+ {
-+ CXvbaRenderPicture *pic;
-+ pic = *((CXvbaRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ }
-+ msg->Release();
-+ }
-+
-+ while (m_dataPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputDataProtocol::PICTURE)
-+ {
-+ CXvbaRenderPicture *pic;
-+ pic = *((CXvbaRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ }
-+ }
-+}
-+
-+bool COutput::IsDecodingFinished()
-+{
-+ return true;
-+
-+ // check for decoding to be finished
-+ CXvbaDecodedPicture decodedPic = m_decodedPics.front();
-+
-+ XVBA_Surface_Sync_Input syncInput;
-+ XVBA_Surface_Sync_Output syncOutput;
-+ syncInput.size = sizeof(syncInput);
-+ syncInput.session = m_config.xvbaSession;
-+ syncInput.surface = decodedPic.render->surface;
-+ syncInput.query_status = XVBA_GET_SURFACE_STATUS;
-+ syncOutput.size = sizeof(syncOutput);
-+ { CSingleLock lock(*(m_config.apiSec));
-+ if (Success != g_XVBA_vtable.SyncSurface(&syncInput, &syncOutput))
-+ {
-+ CLog::Log(LOGERROR,"XVBA - failed sync surface");
-+ m_xvbaError = true;
-+ return false;
-+ }
-+ }
-+ if (!(syncOutput.status_flags & XVBA_STILL_PENDING))
-+ return true;
-+
-+ return false;
-+}
-+
-+void COutput::TransferSurface(uint32_t source)
-+{
-+ XvbaBufferPool::GLVideoSurface *glSurface = &m_bufferPool.glSurfaces[source];
-+
-+ if (glSurface->transferred)
-+ return;
-+
-+ glSurface->transferred = true;
-+
-+ // transfer surface
-+ XVBA_Transfer_Surface_Input transInput;
-+ transInput.size = sizeof(transInput);
-+ transInput.session = m_config.xvbaSession;
-+ transInput.src_surface = glSurface->render->surface;
-+ transInput.target_surface = glSurface->glSurface;
-+ transInput.flag = glSurface->field;
-+ { CSingleLock lock(*(m_config.apiSec));
-+ if (Success != g_XVBA_vtable.TransferSurface(&transInput))
-+ {
-+ CLog::Log(LOGERROR,"(XVBA) failed to transfer surface");
-+ m_xvbaError = true;
-+ return;
-+ }
-+ }
-+}
-+
-+CXvbaRenderPicture* COutput::ProcessPicture()
-+{
-+ CXvbaRenderPicture *retPic = 0;
-+
-+ if (m_deintStep == 1)
-+ {
-+ if(m_field == XVBA_TOP_FIELD)
-+ m_field = XVBA_BOTTOM_FIELD;
-+ else
-+ m_field = XVBA_TOP_FIELD;
-+ }
-+
-+ // find unused shared surface
-+ unsigned int idx = FindFreeSurface();
-+ XvbaBufferPool::GLVideoSurface *glSurface = &m_bufferPool.glSurfaces[idx];
-+ glSurface->used = true;
-+ glSurface->field = m_field;
-+ glSurface->render = m_processPicture.render;
-+ glSurface->transferred = false;
-+
-+ int cmd = 0;
-+ m_config.stats->GetCmd(cmd);
-+
-+// if (!(cmd & DVP_FLAG_SKIP_PROC))
-+// {
-+ // transfer surface
-+ XVBA_Transfer_Surface_Input transInput;
-+ transInput.size = sizeof(transInput);
-+ transInput.session = m_config.xvbaSession;
-+ transInput.src_surface = m_processPicture.render->surface;
-+ transInput.target_surface = glSurface->glSurface;
-+ transInput.flag = m_field;
-+ { CSingleLock lock(*(m_config.apiSec));
-+ if (Success != g_XVBA_vtable.TransferSurface(&transInput))
-+ {
-+ CLog::Log(LOGERROR,"(XVBA) failed to transfer surface");
-+ m_xvbaError = true;
-+ return retPic;
-+ }
-+ }
-+
-+ // make sure that transfer is completed
-+// uint64_t maxTimeout = 1000000000LL;
-+// GLsync ReadyFence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
-+// glClientWaitSync(ReadyFence, GL_SYNC_FLUSH_COMMANDS_BIT, maxTimeout);
-+// glDeleteSync(ReadyFence);
-+// glFinish();GL_SYNC_FLUSH_COMMANDS_BIT
-+// }
-+// else
-+// {
-+// CLog::Log(LOGDEBUG,"XVBA::ProcessPicture - skipped transfer surface");
-+// m_processPicture.DVDPic.iFlags |= DVP_FLAG_DROPPED;
-+// }
-+
-+ // prepare render pic
-+ retPic = m_bufferPool.freeRenderPics.front();
-+ m_bufferPool.freeRenderPics.pop_front();
-+ m_bufferPool.usedRenderPics.push_back(retPic);
-+ retPic->sourceIdx = glSurface->id;
-+ retPic->DVDPic = m_processPicture.DVDPic;
-+ retPic->valid = true;
-+ retPic->texture = glSurface->texture;
-+ retPic->crop = CRect(0,0,0,0);
-+ retPic->texWidth = m_config.surfaceWidth;
-+ retPic->texHeight = m_config.surfaceHeight;
-+ retPic->xvbaOutput = this;
-+
-+ // set repeat pic for de-interlacing
-+ if (m_deinterlacing)
-+ {
-+ if (m_deintStep == 1)
-+ {
-+ retPic->DVDPic.pts = DVD_NOPTS_VALUE;
-+ retPic->DVDPic.dts = DVD_NOPTS_VALUE;
-+ }
-+ retPic->DVDPic.iRepeatPicture = 0.0;
-+ }
-+
-+ return retPic;
-+}
-+
-+void COutput::ProcessReturnPicture(CXvbaRenderPicture *pic)
-+{
-+ std::deque::iterator it;
-+ it = std::find(m_bufferPool.usedRenderPics.begin(), m_bufferPool.usedRenderPics.end(), pic);
-+ if (it == m_bufferPool.usedRenderPics.end())
-+ {
-+ CLog::Log(LOGWARNING, "COutput::ProcessReturnPicture - pic not found");
-+ return;
-+ }
-+ m_bufferPool.usedRenderPics.erase(it);
-+ m_bufferPool.freeRenderPics.push_back(pic);
-+ if (!pic->valid)
-+ {
-+ CLog::Log(LOGDEBUG, "COutput::%s - return of invalid render pic", __FUNCTION__);
-+ return;
-+ }
-+
-+ if (m_config.useSharedSurfaces)
-+ {
-+ xvba_render_state *render = m_bufferPool.glSurfaces[pic->sourceIdx].render;
-+ if (render)
-+ {
-+ // check if video surface if referenced by other glSurfaces
-+ bool referenced(false);
-+ for (unsigned int i=0; isourceIdx)
-+ continue;
-+ if (m_bufferPool.glSurfaces[i].render == render)
-+ {
-+ referenced = true;
-+ break;
-+ }
-+ }
-+ if (m_processPicture.render == render)
-+ referenced = true;
-+
-+ // release video surface
-+ if (!referenced)
-+ {
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ render->state &= ~(FF_XVBA_STATE_USED_FOR_RENDER | FF_XVBA_STATE_DECODED);
-+ }
-+
-+ // unreference video surface
-+ m_bufferPool.glSurfaces[pic->sourceIdx].render = 0;
-+ }
-+ m_bufferPool.glSurfaces[pic->sourceIdx].used = false;
-+ return;
-+ }
-+}
-+
-+int COutput::FindFreeSurface()
-+{
-+ // find free shared surface
-+ unsigned int i;
-+ for (i = 0; i < m_bufferPool.glSurfaces.size(); ++i)
-+ {
-+ if (!m_bufferPool.glSurfaces[i].used)
-+ break;
-+ }
-+ if (i == m_bufferPool.glSurfaces.size())
-+ return -1;
-+ else
-+ return i;
-+}
-+
-+void COutput::InitCycle()
-+{
-+ uint64_t latency;
-+ int speed;
-+ m_config.stats->GetParams(latency, speed);
-+ latency = (latency*1000)/CurrentHostFrequency();
-+
-+ m_config.stats->SetCanSkipDeint(false);
-+
-+ EDEINTERLACEMODE mode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
-+ EINTERLACEMETHOD method = g_settings.m_currentVideoSettings.m_InterlaceMethod;
-+ bool interlaced = m_processPicture.DVDPic.iFlags & DVP_FLAG_INTERLACED;
-+
-+ if (mode == VS_DEINTERLACEMODE_FORCE ||
-+ (mode == VS_DEINTERLACEMODE_AUTO && interlaced))
-+ {
-+ if((method == VS_INTERLACEMETHOD_AUTO && interlaced)
-+ || method == VS_INTERLACEMETHOD_XVBA)
-+ {
-+ m_deinterlacing = true;
-+ m_deintSkip = false;
-+ m_config.stats->SetCanSkipDeint(true);
-+
-+ if (m_processPicture.DVDPic.iFlags & DVP_FLAG_DROPDEINT)
-+ {
-+ m_deintSkip = true;
-+ }
-+
-+ // do only half deinterlacing
-+ if (speed != DVD_PLAYSPEED_NORMAL || !g_graphicsContext.IsFullScreenVideo())
-+ {
-+ m_config.stats->SetCanSkipDeint(false);
-+ m_deintSkip = true;
-+ }
-+
-+ if(m_processPicture.DVDPic.iFlags & DVP_FLAG_TOP_FIELD_FIRST)
-+ m_field = XVBA_TOP_FIELD;
-+ else
-+ m_field = XVBA_BOTTOM_FIELD;
-+ }
-+ }
-+ else
-+ {
-+ m_deinterlacing = false;
-+ m_field = XVBA_FRAME;
-+ }
-+
-+ m_processPicture.DVDPic.format = DVDVideoPicture::FMT_XVBA;
-+ m_processPicture.DVDPic.iFlags &= ~(DVP_FLAG_TOP_FIELD_FIRST |
-+ DVP_FLAG_REPEAT_TOP_FIELD |
-+ DVP_FLAG_INTERLACED);
-+ m_processPicture.DVDPic.iWidth = m_config.vidWidth;
-+ m_processPicture.DVDPic.iHeight = m_config.vidHeight;
-+
-+ m_deintStep = 0;
-+}
-+
-+void COutput::FiniCycle()
-+{
-+// { CSingleLock lock(*m_config.videoSurfaceSec);
-+// m_processPicture.render->state &= ~FF_XVBA_STATE_USED_FOR_RENDER;
-+// }
-+ m_processPicture.render = 0;
-+ m_config.stats->DecDecoded();
-+}
-+
-+bool COutput::EnsureBufferPool()
-+{
-+ if (m_config.useSharedSurfaces && m_bufferPool.glSurfaces.empty())
-+ {
-+ GLenum textureTarget;
-+ if (!glewIsSupported("GL_ARB_texture_non_power_of_two") && glewIsSupported("GL_ARB_texture_rectangle"))
-+ {
-+ textureTarget = GL_TEXTURE_RECTANGLE_ARB;
-+ }
-+ else
-+ textureTarget = GL_TEXTURE_2D;
-+
-+ // create shared surfaces
-+ XvbaBufferPool::GLVideoSurface surface;
-+ for (unsigned int i = 0; i < NUM_RENDER_PICS; ++i)
-+ {
-+ glEnable(textureTarget);
-+ glGenTextures(1, &surface.texture);
-+ glBindTexture(textureTarget, surface.texture);
-+ glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-+ glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-+ glTexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-+ glTexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
-+ glTexImage2D(textureTarget, 0, GL_RGBA, m_config.surfaceWidth, m_config.surfaceHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
-+
-+ XVBA_Create_GLShared_Surface_Input surfInput;
-+ XVBA_Create_GLShared_Surface_Output surfOutput;
-+ surfInput.size = sizeof(surfInput);
-+ surfInput.session = m_config.xvbaSession;
-+ surfInput.gltexture = surface.texture;
-+ surfInput.glcontext = m_glContext;
-+ surfOutput.size = sizeof(surfOutput);
-+ surfOutput.surface = 0;
-+ if (Success != g_XVBA_vtable.CreateGLSharedSurface(&surfInput, &surfOutput))
-+ {
-+ CLog::Log(LOGERROR,"(XVBA) failed to create shared surface");
-+ m_xvbaError = true;
-+ break;
-+ }
-+ CLog::Log(LOGDEBUG, "XVBA::GetTexture - created shared surface");
-+
-+ surface.glSurface = surfOutput.surface;
-+ surface.id = i;
-+ surface.used = false;
-+ surface.render = 0;
-+ m_bufferPool.glSurfaces.push_back(surface);
-+ }
-+ glDisable(textureTarget);
-+ }
-+
-+ return true;
-+}
-+
-+void COutput::ReleaseBufferPool()
-+{
-+ CSingleLock lock(m_bufferPool.renderPicSec);
-+
-+ if (m_config.useSharedSurfaces)
-+ {
-+ for (unsigned int i = 0; i < m_bufferPool.glSurfaces.size(); ++i)
-+ {
-+ if (!m_bufferPool.glSurfaces[i].glSurface)
-+ continue;
-+ g_XVBA_vtable.DestroySurface(m_bufferPool.glSurfaces[i].glSurface);
-+ glDeleteTextures(1, &m_bufferPool.glSurfaces[i].texture);
-+ }
-+ m_bufferPool.glSurfaces.clear();
-+ }
-+ // invalidate all used render pictures
-+ for (unsigned int i = 0; i < m_bufferPool.usedRenderPics.size(); ++i)
-+ {
-+ m_bufferPool.usedRenderPics[i]->valid = false;
-+ unsigned int idx = m_bufferPool.usedRenderPics[i]->sourceIdx;
-+ if (m_bufferPool.glSurfaces[idx].render)
-+ {
-+ { CSingleLock lock(*m_config.videoSurfaceSec);
-+ m_bufferPool.glSurfaces[idx].render->state &= ~(FF_XVBA_STATE_USED_FOR_RENDER | FF_XVBA_STATE_DECODED);
-+ m_bufferPool.glSurfaces[idx].render = 0;
-+ }
-+ }
-+ }
-+}
-+
-+void COutput::PreReleaseBufferPool()
-+{
-+ CSingleLock lock(m_bufferPool.renderPicSec);
-+
-+ if (m_config.useSharedSurfaces)
-+ {
-+ for (unsigned int i = 0; i < m_bufferPool.glSurfaces.size(); ++i)
-+ {
-+ if (!m_bufferPool.glSurfaces[i].used)
-+ {
-+ g_XVBA_vtable.DestroySurface(m_bufferPool.glSurfaces[i].glSurface);
-+ glDeleteTextures(1, &m_bufferPool.glSurfaces[i].texture);
-+ m_bufferPool.glSurfaces[i].glSurface = 0;
-+ m_bufferPool.glSurfaces[i].used = true;
-+ }
-+ }
-+ }
-+}
-+
-+bool COutput::CreateGlxContext()
-+{
-+ GLXContext glContext;
-+ Window window;
-+
-+ m_Display = g_Windowing.GetDisplay();
-+ glContext = g_Windowing.GetGlxContext();
-+ m_Window = g_Windowing.GetWmWindow();
-+
-+ // Get our window attribs.
-+ XWindowAttributes wndattribs;
-+ XGetWindowAttributes(m_Display, m_Window, &wndattribs);
-+
-+ // Get visual Info
-+ XVisualInfo visInfo;
-+ visInfo.visualid = wndattribs.visual->visualid;
-+ int nvisuals = 0;
-+ XVisualInfo* visuals = XGetVisualInfo(m_Display, VisualIDMask, &visInfo, &nvisuals);
-+ if (nvisuals != 1)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::COutput::CreateGlxContext - could not find visual");
-+ return false;
-+ }
-+ visInfo = visuals[0];
-+ XFree(visuals);
-+
-+ m_pixmap = XCreatePixmap(m_Display,
-+ DefaultRootWindow(m_Display),
-+ 192,
-+ 108,
-+ visInfo.depth);
-+ if (!m_pixmap)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::COutput::CreateGlxContext - Unable to create XPixmap");
-+ return false;
-+ }
-+
-+ // create gl pixmap
-+ m_glPixmap = glXCreateGLXPixmap(m_Display, &visInfo, m_pixmap);
-+
-+ if (!m_glPixmap)
-+ {
-+ CLog::Log(LOGINFO, "XVBA::COutput::CreateGlxContext - Could not create glPixmap");
-+ return false;
-+ }
-+
-+ m_glContext = glXCreateContext(m_Display, &visInfo, glContext, True);
-+
-+ if (!glXMakeCurrent(m_Display, m_glPixmap, m_glContext))
-+ {
-+ CLog::Log(LOGINFO, "XVBA::COutput::CreateGlxContext - Could not make Pixmap current");
-+ return false;
-+ }
-+
-+ CLog::Log(LOGNOTICE, "XVBA::COutput::CreateGlxContext - created context");
-+ return true;
-+}
-+
-+bool COutput::DestroyGlxContext()
-+{
-+ if (m_glContext)
-+ {
-+ glXMakeCurrent(m_Display, None, NULL);
-+ glXDestroyContext(m_Display, m_glContext);
-+ }
-+ m_glContext = 0;
-+
-+ if (m_glPixmap)
-+ glXDestroyPixmap(m_Display, m_glPixmap);
-+ m_glPixmap = 0;
-+
-+ if (m_pixmap)
-+ XFreePixmap(m_Display, m_pixmap);
-+ m_pixmap = 0;
-+
-+ return true;
-+}
-+
-+#endif
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h 2012-05-14 14:15:12.137220527 +0200
-@@ -0,0 +1,386 @@
-+/*
-+ * 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 "X11/Xlib.h"
-+#include "amd/amdxvba.h"
-+#include "DllAvCodec.h"
-+#include "DVDCodecs/Video/DVDVideoCodecFFmpeg.h"
-+#include "threads/Thread.h"
-+#include "threads/CriticalSection.h"
-+#include "threads/SharedSection.h"
-+#include "threads/Event.h"
-+#include "guilib/DispResource.h"
-+#include "guilib/Geometry.h"
-+#include "libavcodec/xvba.h"
-+#include "utils/ActorProtocol.h"
-+#include "settings/VideoSettings.h"
-+#include
-+#include
-+#include
-+#include
-+
-+using namespace Actor;
-+
-+
-+namespace XVBA
-+{
-+
-+//-----------------------------------------------------------------------------
-+// XVBA data structs
-+//-----------------------------------------------------------------------------
-+
-+class CDecoder;
-+class CXVBAContext;
-+class COutput;
-+
-+#define NUM_RENDER_PICS 9
-+
-+/**
-+ * Buffer statistics used to control number of frames in queue
-+ */
-+
-+class CXvbaBufferStats
-+{
-+public:
-+ uint16_t decodedPics;
-+ uint16_t processedPics;
-+ uint16_t renderPics;
-+ uint64_t latency; // time decoder has waited for a frame, ideally there is no latency
-+ int playSpeed;
-+ bool canSkipDeint;
-+ int processCmd;
-+
-+ void IncDecoded() { CSingleLock l(m_sec); decodedPics++;}
-+ void DecDecoded() { CSingleLock l(m_sec); decodedPics--;}
-+ void IncProcessed() { CSingleLock l(m_sec); processedPics++;}
-+ void DecProcessed() { CSingleLock l(m_sec); processedPics--;}
-+ void IncRender() { CSingleLock l(m_sec); renderPics++;}
-+ void DecRender() { CSingleLock l(m_sec); renderPics--;}
-+ void Reset() { CSingleLock l(m_sec); decodedPics=0; processedPics=0;renderPics=0;latency=0;}
-+ void Get(uint16_t &decoded, uint16_t &processed, uint16_t &render) {CSingleLock l(m_sec); decoded = decodedPics, processed=processedPics, render=renderPics;}
-+ void SetParams(uint64_t time, int speed) { CSingleLock l(m_sec); latency = time; playSpeed = speed; }
-+ void GetParams(uint64_t &lat, int &speed) { CSingleLock l(m_sec); lat = latency; speed = playSpeed; }
-+ void SetCmd(int cmd) { CSingleLock l(m_sec); processCmd = cmd; }
-+ void GetCmd(int &cmd) { CSingleLock l(m_sec); cmd = processCmd; processCmd = 0; }
-+ void SetCanSkipDeint(bool canSkip) { CSingleLock l(m_sec); canSkipDeint = canSkip; }
-+ bool CanSkipDeint() { CSingleLock l(m_sec); if (canSkipDeint) return true; else return false;}
-+private:
-+ CCriticalSection m_sec;
-+};
-+
-+/**
-+ * CXvbaConfig holds all configuration parameters needed by vdpau
-+ * The structure is sent to the internal classes CMixer and COutput
-+ * for init.
-+ */
-+
-+struct CXvbaConfig
-+{
-+ int surfaceWidth;
-+ int surfaceHeight;
-+ int vidWidth;
-+ int vidHeight;
-+ int outWidth;
-+ int outHeight;
-+ bool useSharedSurfaces;
-+
-+ CXVBAContext *context;
-+ XVBADecodeCap decoderCap;
-+ void *xvbaSession;
-+ std::vector *videoSurfaces;
-+ CCriticalSection *videoSurfaceSec;
-+ CCriticalSection *apiSec;
-+
-+ CXvbaBufferStats *stats;
-+ int numRenderBuffers;
-+ uint32_t maxReferences;
-+};
-+
-+/**
-+ * Holds a decoded frame
-+ * Input to COutput for further processing
-+ */
-+struct CXvbaDecodedPicture
-+{
-+ DVDVideoPicture DVDPic;
-+ xvba_render_state *render;
-+};
-+
-+/**
-+ * Ready to render textures
-+ * Sent from COutput back to CDecoder
-+ * Objects are referenced by DVDVideoPicture and are sent
-+ * to renderer
-+ */
-+class CXvbaRenderPicture
-+{
-+ friend class CDecoder;
-+ friend class COutput;
-+public:
-+ DVDVideoPicture DVDPic;
-+ int texWidth, texHeight;
-+ CRect crop;
-+ GLuint texture;
-+ uint32_t sourceIdx;
-+ bool valid;
-+ CDecoder *xvba;
-+ CXvbaRenderPicture* Acquire();
-+ long Release();
-+ void Transfer();
-+private:
-+ void ReturnUnused();
-+ int refCount;
-+ CCriticalSection *renderPicSection;
-+ COutput *xvbaOutput;
-+};
-+
-+//-----------------------------------------------------------------------------
-+// Output
-+//-----------------------------------------------------------------------------
-+
-+/**
-+ * Buffer pool holds allocated xvba and gl resources
-+ * Embedded in COutput
-+ */
-+struct XvbaBufferPool
-+{
-+ struct GLVideoSurface
-+ {
-+ unsigned int id;
-+ bool used;
-+ bool transferred;
-+ GLuint texture;
-+ void *glSurface;
-+ xvba_render_state *render;
-+ XVBA_SURFACE_FLAG field;
-+ };
-+ std::vector glSurfaces;
-+ std::vector allRenderPics;
-+ std::deque usedRenderPics;
-+ std::deque freeRenderPics;
-+ CCriticalSection renderPicSec;
-+};
-+
-+class COutputControlProtocol : public Protocol
-+{
-+public:
-+ COutputControlProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {};
-+ enum OutSignal
-+ {
-+ INIT,
-+ FLUSH,
-+ PRECLEANUP,
-+ TIMEOUT,
-+ };
-+ enum InSignal
-+ {
-+ ACC,
-+ ERROR,
-+ STATS,
-+ };
-+};
-+
-+class COutputDataProtocol : public Protocol
-+{
-+public:
-+ COutputDataProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {};
-+ enum OutSignal
-+ {
-+ NEWFRAME = 0,
-+ RETURNPIC,
-+ };
-+ enum InSignal
-+ {
-+ PICTURE,
-+ };
-+};
-+
-+/**
-+ * COutput is embedded in CDecoder and embeds CMixer
-+ * The class has its own OpenGl context which is shared with render thread
-+ * COuput generated ready to render textures and passes them back to
-+ * CDecoder
-+ */
-+class COutput : private CThread
-+{
-+public:
-+ COutput(CEvent *inMsgEvent);
-+ virtual ~COutput();
-+ void Start();
-+ void Dispose();
-+ void TransferSurface(uint32_t source);
-+ COutputControlProtocol m_controlPort;
-+ COutputDataProtocol m_dataPort;
-+protected:
-+ void OnStartup();
-+ void OnExit();
-+ void Process();
-+ void StateMachine(int signal, Protocol *port, Message *msg);
-+ bool HasWork();
-+ bool IsDecodingFinished();
-+ CXvbaRenderPicture* ProcessPicture();
-+ void ProcessReturnPicture(CXvbaRenderPicture *pic);
-+ int FindFreeSurface();
-+ void InitCycle();
-+ void FiniCycle();
-+ bool Init();
-+ bool Uninit();
-+ void Flush();
-+ bool CreateGlxContext();
-+ bool DestroyGlxContext();
-+ bool EnsureBufferPool();
-+ void ReleaseBufferPool();
-+ void PreReleaseBufferPool();
-+ CEvent m_outMsgEvent;
-+ CEvent *m_inMsgEvent;
-+ int m_state;
-+ bool m_bStateMachineSelfTrigger;
-+
-+ // extended state variables for state machine
-+ int m_extTimeout;
-+ bool m_xvbaError;
-+ CXvbaConfig m_config;
-+ XvbaBufferPool m_bufferPool;
-+ Display *m_Display;
-+ Window m_Window;
-+ GLXContext m_glContext;
-+ GLXWindow m_glWindow;
-+ Pixmap m_pixmap;
-+ GLXPixmap m_glPixmap;
-+ std::queue m_decodedPics;
-+ CXvbaDecodedPicture m_processPicture;
-+ XVBA_SURFACE_FLAG m_field;
-+ bool m_deinterlacing;
-+ int m_deintStep;
-+ bool m_deintSkip;
-+};
-+
-+//-----------------------------------------------------------------------------
-+// XVBA decoder
-+//-----------------------------------------------------------------------------
-+
-+class CXVBAContext
-+{
-+public:
-+ static bool EnsureContext(CXVBAContext **ctx);
-+ void *GetContext();
-+ void Release();
-+private:
-+ CXVBAContext();
-+ void Close();
-+ bool LoadSymbols();
-+ bool CreateContext();
-+ void DestroyContext();
-+ static CXVBAContext *m_context;
-+ static CCriticalSection m_section;
-+ static Display *m_display;
-+ int m_refCount;
-+ static void *m_dlHandle;
-+ void *m_xvbaContext;
-+};
-+
-+class CDecoder : public CDVDVideoCodecFFmpeg::IHardwareDecoder,
-+ public IDispResource
-+{
-+ friend class CXvbaRenderPicture;
-+
-+public:
-+
-+ struct pictureAge
-+ {
-+ int b_age;
-+ int ip_age[2];
-+ };
-+
-+ enum EDisplayState
-+ { XVBA_OPEN
-+ , XVBA_RESET
-+ , XVBA_LOST
-+ , XVBA_ERROR
-+ };
-+
-+ CDecoder();
-+ virtual ~CDecoder();
-+ virtual void OnLostDevice();
-+ virtual void OnResetDevice();
-+
-+ virtual bool Open(AVCodecContext* avctx, const enum PixelFormat fmt, unsigned int surfaces = 0);
-+ virtual int Decode (AVCodecContext* avctx, AVFrame* frame);
-+ virtual bool GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture);
-+ virtual void Reset();
-+ virtual void Close();
-+ virtual int Check(AVCodecContext* avctx);
-+ virtual long Release();
-+ virtual const std::string Name() { return "xvba"; }
-+ virtual bool CanSkipDeint();
-+ virtual void SetSpeed(int speed);
-+
-+ bool Supports(EINTERLACEMETHOD method);
-+ long ReleasePicReference();
-+
-+protected:
-+ bool CreateSession(AVCodecContext* avctx);
-+ void DestroySession();
-+ bool EnsureDataControlBuffers(unsigned int num);
-+ void ResetState();
-+ void SetError(const char* function, const char* msg, int line);
-+ bool IsSurfaceValid(xvba_render_state *render);
-+ void ReturnRenderPicture(CXvbaRenderPicture *renderPic);
-+
-+ // callbacks for ffmpeg
-+ static void FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic);
-+ static void FFDrawSlice(struct AVCodecContext *avctx,
-+ const AVFrame *src, int offset[4],
-+ int y, int type, int height);
-+ static int FFGetBuffer(AVCodecContext *avctx, AVFrame *pic);
-+
-+ DllAvUtil m_dllAvUtil;
-+ CCriticalSection m_decoderSection;
-+ CEvent m_displayEvent;
-+ EDisplayState m_displayState;
-+ CXvbaConfig m_xvbaConfig;
-+ std::vector m_videoSurfaces;
-+ CCriticalSection m_apiSec, m_videoSurfaceSec;
-+ ThreadIdentifier m_decoderThread;
-+
-+ unsigned int m_decoderId;
-+ struct XVBABufferPool
-+ {
-+ XVBABufferDescriptor *picture_descriptor_buffer;
-+ XVBABufferDescriptor *iq_matrix_buffer;
-+ XVBABufferDescriptor *data_buffer;
-+ std::vector data_control_buffers;
-+ };
-+ XVBABufferPool m_xvbaBufferPool;
-+
-+ pictureAge picAge;
-+
-+ COutput m_xvbaOutput;
-+ CXvbaBufferStats m_bufferStats;
-+ CEvent m_inMsgEvent;
-+ CXvbaRenderPicture *m_presentPicture;
-+
-+ int m_speed;
-+ int m_codecControl;
-+};
-+
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp 2012-05-14 14:11:52.793931617 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp 2012-05-14 14:35:25.789526441 +0200
-@@ -19,7 +19,6 @@
- *
- */
-
--#include "threads/SystemClock.h"
- #include "system.h"
- #ifndef __STDC_CONSTANT_MACROS
- #define __STDC_CONSTANT_MACROS
-@@ -44,6 +43,7 @@
- #include "filesystem/Directory.h"
- #include "utils/log.h"
- #include "threads/Thread.h"
-+#include "threads/SystemClock.h"
- #include "utils/TimeUtils.h"
-
- void CDemuxStreamAudioFFmpeg::GetStreamInfo(std::string& strInfo)
-@@ -154,16 +154,12 @@
- ++it;
- }
-
--#ifdef _MSC_VER
--static __declspec(thread) CDVDDemuxFFmpeg* g_demuxer = 0;
--#else
--static TLS g_tls;
--#define g_demuxer (*((CDVDDemuxFFmpeg**)g_tls.Get()))
--#endif
-+static XbmcThreads::ThreadLocal g_demuxer;
-
- static int interrupt_cb(void* unused)
- {
-- if(g_demuxer && g_demuxer->Aborted())
-+ CDVDDemuxFFmpeg* demuxer = g_demuxer.get();
-+ if(demuxer && demuxer->Aborted())
- return 1;
- return 0;
- }
-@@ -235,7 +231,7 @@
- std::string strFile;
- m_iCurrentPts = DVD_NOPTS_VALUE;
- m_speed = DVD_PLAYSPEED_NORMAL;
-- g_demuxer = this;
-+ g_demuxer.set(this);
- m_program = UINT_MAX;
- const AVIOInterruptCB int_cb = { interrupt_cb, NULL };
-
-@@ -499,7 +495,7 @@
-
- void CDVDDemuxFFmpeg::Dispose()
- {
-- g_demuxer = this;
-+ g_demuxer.set(this);
-
- if (m_pFormatContext)
- {
-@@ -540,7 +536,7 @@
-
- void CDVDDemuxFFmpeg::Flush()
- {
-- g_demuxer = this;
-+ g_demuxer.set(this);
-
- // naughty usage of an internal ffmpeg function
- if (m_pFormatContext)
-@@ -556,7 +552,7 @@
-
- void CDVDDemuxFFmpeg::SetSpeed(int iSpeed)
- {
-- g_demuxer = this;
-+ g_demuxer.set(this);
-
- if(!m_pFormatContext)
- return;
-@@ -618,7 +614,7 @@
-
- DemuxPacket* CDVDDemuxFFmpeg::Read()
- {
-- g_demuxer = this;
-+ g_demuxer.set(this);
-
- AVPacket pkt;
- DemuxPacket* pPacket = NULL;
-@@ -810,7 +806,7 @@
-
- bool CDVDDemuxFFmpeg::SeekTime(int time, bool backwords, double *startpts)
- {
-- g_demuxer = this;
-+ g_demuxer.set(this);
-
- if(time < 0)
- time = 0;
-@@ -870,7 +866,7 @@
-
- bool CDVDDemuxFFmpeg::SeekByte(__int64 pos)
- {
-- g_demuxer = this;
-+ g_demuxer.set(this);
-
- CSingleLock lock(m_critSection);
- int ret = m_dllAvFormat.av_seek_frame(m_pFormatContext, -1, pos, AVSEEK_FLAG_BYTE);
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp 2012-05-14 14:15:12.140220588 +0200
-@@ -21,6 +21,7 @@
-
- #include "DVDPerformanceCounter.h"
- #include "DVDMessageQueue.h"
-+#include "utils/TimeUtils.h"
-
- #include "dvd_config.h"
-
-@@ -68,22 +69,16 @@
-
- inline __int64 get_thread_cpu_usage(ProcessPerformance* p)
- {
-- if (p->hThread)
-+ if (p->thread)
- {
-- FILETIME dummy;
-- FILETIME current_time_thread;
-- FILETIME current_time_system;
- ULARGE_INTEGER old_time_thread;
- ULARGE_INTEGER old_time_system;
-
- old_time_thread.QuadPart = p->timer_thread.QuadPart;
- old_time_system.QuadPart = p->timer_system.QuadPart;
-
-- GetThreadTimes(p->hThread, &dummy, &dummy, ¤t_time_thread, &dummy);
-- GetSystemTimeAsFileTime(¤t_time_system);
--
-- FILETIME_TO_ULARGE_INTEGER(p->timer_thread, current_time_thread);
-- FILETIME_TO_ULARGE_INTEGER(p->timer_system, current_time_system);
-+ p->timer_thread.QuadPart = p->thread->GetAbsoluteUsage();
-+ p->timer_system.QuadPart = CurrentHostCounter();
-
- __int64 threadTime = (p->timer_thread.QuadPart - old_time_thread.QuadPart);
- __int64 systemTime = (p->timer_system.QuadPart - old_time_system.QuadPart);
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPerformanceCounter.h xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPerformanceCounter.h
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPerformanceCounter.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPerformanceCounter.h 2012-05-14 14:15:12.141220608 +0200
-@@ -24,7 +24,7 @@
- #define FILETIME_TO_ULARGE_INTEGER(ularge, filetime) { ularge.u.HighPart = filetime.dwHighDateTime; ularge.u.LowPart = filetime.dwLowDateTime; }
-
- #include "system.h"
--
-+#include "threads/Thread.h"
- #include "threads/SingleLock.h"
-
- class CDVDMessageQueue;
-@@ -33,7 +33,7 @@
- {
- ULARGE_INTEGER timer_thread;
- ULARGE_INTEGER timer_system;
-- HANDLE hThread;
-+ CThread* thread;
- } ProcessPerformance;
-
- class CDVDPerformanceCounter
-@@ -45,20 +45,20 @@
- bool Initialize();
- void DeInitialize();
-
-- void EnableAudioQueue(CDVDMessageQueue* pQueue) { CSingleLock lock(m_critSection); m_pAudioQueue = pQueue; }
-- void DisableAudioQueue() { CSingleLock lock(m_critSection); m_pAudioQueue = NULL; }
-+ void EnableAudioQueue(CDVDMessageQueue* pQueue) { CSingleLock lock(m_critSection); m_pAudioQueue = pQueue; }
-+ void DisableAudioQueue() { CSingleLock lock(m_critSection); m_pAudioQueue = NULL; }
-
-- void EnableVideoQueue(CDVDMessageQueue* pQueue) { CSingleLock lock(m_critSection); m_pVideoQueue = pQueue; }
-- void DisableVideoQueue() { CSingleLock lock(m_critSection); m_pVideoQueue = NULL; }
-+ void EnableVideoQueue(CDVDMessageQueue* pQueue) { CSingleLock lock(m_critSection); m_pVideoQueue = pQueue; }
-+ void DisableVideoQueue() { CSingleLock lock(m_critSection); m_pVideoQueue = NULL; }
-
-- void EnableVideoDecodePerformance(HANDLE hThread) { CSingleLock lock(m_critSection); m_videoDecodePerformance.hThread = hThread; }
-- void DisableVideoDecodePerformance() { CSingleLock lock(m_critSection); m_videoDecodePerformance.hThread = NULL; }
-+ void EnableVideoDecodePerformance(CThread *thread) { CSingleLock lock(m_critSection); m_videoDecodePerformance.thread = thread; }
-+ void DisableVideoDecodePerformance() { CSingleLock lock(m_critSection); m_videoDecodePerformance.thread = NULL; }
-
-- void EnableAudioDecodePerformance(HANDLE hThread) { CSingleLock lock(m_critSection); m_audioDecodePerformance.hThread = hThread; }
-- void DisableAudioDecodePerformance() { CSingleLock lock(m_critSection); m_audioDecodePerformance.hThread = NULL; }
-+ void EnableAudioDecodePerformance(CThread *thread) { CSingleLock lock(m_critSection); m_audioDecodePerformance.thread = thread; }
-+ void DisableAudioDecodePerformance() { CSingleLock lock(m_critSection); m_audioDecodePerformance.thread = NULL; }
-
-- void EnableMainPerformance(HANDLE hThread) { CSingleLock lock(m_critSection); m_mainPerformance.hThread = hThread; }
-- void DisableMainPerformance() { CSingleLock lock(m_critSection); m_mainPerformance.hThread = NULL; }
-+ void EnableMainPerformance(CThread *thread) { CSingleLock lock(m_critSection); m_mainPerformance.thread = thread; }
-+ void DisableMainPerformance() { CSingleLock lock(m_critSection); m_mainPerformance.thread = NULL; }
-
- CDVDMessageQueue* m_pAudioQueue;
- CDVDMessageQueue* m_pVideoQueue;
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp 2012-05-14 14:15:12.142220628 +0200
-@@ -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-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayer.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayer.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayer.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayer.cpp 2012-05-14 14:15:12.145220688 +0200
-@@ -348,7 +348,7 @@
-
- // if playing a file close it first
- // this has to be changed so we won't have to close it.
-- if(ThreadHandle())
-+ if(IsRunning())
- CloseFile();
-
- m_bAbortRequest = false;
-@@ -366,7 +366,7 @@
- m_ready.Reset();
-
- #if defined(HAS_VIDEO_PLAYBACK)
-- g_renderManager.PreInit();
-+ g_renderManager.PreInit(&m_clock);
- #endif
-
- Create();
-@@ -440,9 +440,8 @@
-
- m_messenger.Init();
-
-- g_dvdPerformanceCounter.EnableMainPerformance(ThreadHandle());
--
- CUtil::ClearTempFonts();
-+ g_dvdPerformanceCounter.EnableMainPerformance(this);
- }
-
- bool CDVDPlayer::OpenInputStream()
-@@ -1585,7 +1584,7 @@
-
- }
- else if (m_CurrentVideo.id >= 0
-- && m_CurrentVideo.inited == true
-+ && (m_CurrentVideo.inited == true || GetPlaySpeed() < 0)
- && m_SpeedState.lastpts != m_dvdPlayerVideo.GetCurrentPts()
- && m_SpeedState.lasttime != GetTime())
- {
-@@ -2262,6 +2261,11 @@
- if (speed != DVD_PLAYSPEED_PAUSE && m_playSpeed != DVD_PLAYSPEED_PAUSE && speed != m_playSpeed)
- m_callback.OnPlayBackSpeedChanged(speed / DVD_PLAYSPEED_NORMAL);
-
-+ if (m_playSpeed < 0 && speed >= 0)
-+ {
-+ m_messenger.Put(new CDVDMsgPlayerSeek(GetTime(), true, true, true));
-+ }
-+
- // if playspeed is different then DVD_PLAYSPEED_NORMAL or DVD_PLAYSPEED_PAUSE
- // audioplayer, stops outputing audio to audiorendere, but still tries to
- // sleep an correct amount for each packet
-@@ -2278,6 +2282,7 @@
- // until our buffers are somewhat filled
- if(m_pDemuxer)
- m_pDemuxer->SetSpeed(speed);
-+
- }
- else if (pMsg->IsType(CDVDMsg::PLAYER_CHANNEL_SELECT_NUMBER) && m_messenger.GetPacketCount(CDVDMsg::PLAYER_CHANNEL_SELECT_NUMBER) == 0)
- {
-@@ -2897,7 +2902,7 @@
- m_dvdPlayerAudio.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
-
- /* audio normally won't consume full cpu, so let it have prio */
-- m_dvdPlayerAudio.SetPriority(GetThreadPriority(*this)+1);
-+ m_dvdPlayerAudio.SetPriority(GetPriority()+1);
-
- return true;
- }
-@@ -2962,11 +2967,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.
-- m_dvdPlayerVideo.SetPrioritySched_RR();
-+ m_dvdPlayerVideo.SetPriority(GetSchedRRPriority());
- #else
- /* use same priority for video thread as demuxing thread, as */
- /* otherwise demuxer will starve if video consumes the full cpu */
-- m_dvdPlayerVideo.SetPriority(GetThreadPriority(*this));
-+ m_dvdPlayerVideo.SetPriority(GetPriority());
- #endif
- return true;
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2012-05-14 14:11:52.795931658 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2012-05-14 14:38:53.481710398 +0200
-@@ -189,7 +189,7 @@
- return false;
- }
-
-- if(g_guiSettings.GetBool("videoplayer.usedisplayasclock") && g_VideoReferenceClock.ThreadHandle() == NULL)
-+ if(g_guiSettings.GetBool("videoplayer.usedisplayasclock") && !g_VideoReferenceClock.IsRunning())
- {
- g_VideoReferenceClock.Create();
- //we have to wait for the clock to start otherwise alsa can cause trouble
-@@ -247,6 +247,7 @@
- m_stalled = m_messageQueue.GetPacketCount(CDVDMsg::DEMUXER_PACKET) == 0;
- m_started = false;
- m_codecname = m_pVideoCodec->GetName();
-+ g_renderManager.EnableBuffering(false);
- }
-
- void CDVDPlayerVideo::CloseStream(bool bWaitForBuffers)
-@@ -291,7 +292,7 @@
- m_iCurrentPts = DVD_NOPTS_VALUE;
- m_FlipTimeStamp = m_pClock->GetAbsoluteClock();
-
-- g_dvdPerformanceCounter.EnableVideoDecodePerformance(ThreadHandle());
-+ g_dvdPerformanceCounter.EnableVideoDecodePerformance(this);
- }
-
- void CDVDPlayerVideo::Process()
-@@ -311,8 +312,10 @@
-
- int iDropped = 0; //frames dropped in a row
- bool bRequestDrop = false;
-+ int iDropDirective;
-
- m_videoStats.Start();
-+ m_droppingStats.Reset();
-
- while (!m_bStop)
- {
-@@ -416,6 +419,8 @@
- picture.iFlags &= ~DVP_FLAG_ALLOCATED;
- m_packets.clear();
- m_started = false;
-+ m_droppingStats.Reset();
-+ g_renderManager.EnableBuffering(false);
- }
- else if (pMsg->IsType(CDVDMsg::GENERAL_FLUSH)) // private message sent by (CDVDPlayerVideo::Flush())
- {
-@@ -428,6 +433,8 @@
- //we need to recalculate the framerate
- //TODO: this needs to be set on a streamchange instead
- ResetFrameRateCalc();
-+ m_droppingStats.Reset();
-+ g_renderManager.EnableBuffering(false);
-
- m_stalled = true;
- m_started = false;
-@@ -445,6 +452,10 @@
- m_speed = static_cast(pMsg)->m_value;
- if(m_speed == DVD_PLAYSPEED_PAUSE)
- m_iNrOfPicturesNotToSkip = 0;
-+ m_droppingStats.Reset();
-+// g_renderManager.EnableBuffering(m_speed == DVD_PLAYSPEED_NORMAL);
-+ if (m_pVideoCodec)
-+ m_pVideoCodec->SetSpeed(m_speed);
- }
- else if (pMsg->IsType(CDVDMsg::PLAYER_STARTED))
- {
-@@ -479,6 +490,29 @@
- m_iNrOfPicturesNotToSkip = 1;
- }
-
-+ bRequestDrop = false;
-+ iDropDirective = CalcDropRequirement(pts);
-+ if (iDropDirective & EOS_VERYLATE)
-+ {
-+ if (m_bAllowDrop)
-+ {
-+ m_pullupCorrection.Flush();
-+ bRequestDrop = true;
-+ }
-+ }
-+ int codecControl = 0;
-+ if (iDropDirective & EOS_BUFFER_LEVEL)
-+ {
-+ if (iDropDirective & EOS_BUFFER_LEVEL)
-+ codecControl |= DVP_FLAG_DRAIN;
-+ }
-+ m_pVideoCodec->SetCodecControl(codecControl);
-+ if (iDropDirective & EOS_DROPPED)
-+ {
-+ m_iDroppedFrames++;
-+ iDropped++;
-+ }
-+
- #ifdef PROFILE
- bRequestDrop = false;
- #else
-@@ -488,6 +522,7 @@
- bRequestDrop = false;
- m_iDroppedRequest = 0;
- m_iLateFrames = 0;
-+ m_droppingStats.m_requestOutputDrop = false;
- }
- #endif
-
-@@ -526,7 +561,7 @@
- if(m_pVideoCodec->GetConvergeCount() > 0)
- {
- m_packets.push_back(DVDMessageListItem(pMsg, 0));
-- if(m_packets.size() > m_pVideoCodec->GetConvergeCount()
-+ if(m_packets.size() > m_pVideoCodec->GetConvergeCount()
- || m_packets.size() * frametime > DVD_SEC_TO_TIME(10))
- m_packets.pop_front();
- }
-@@ -536,11 +571,13 @@
- // picture from a demux packet, this should be reasonable
- // for libavformat as a demuxer as it normally packetizes
- // pictures when they come from demuxer
-- if(bRequestDrop && !bPacketDrop && (iDecoderState & VC_BUFFER) && !(iDecoderState & VC_PICTURE))
-- {
-- m_iDroppedFrames++;
-- iDropped++;
-- }
-+// if(bRequestDrop && !bPacketDrop && (iDecoderState & VC_BUFFER) && !(iDecoderState & VC_PICTURE))
-+// {
-+// m_iDroppedFrames++;
-+// iDropped++;
-+// }
-+
-+ bRequestDrop = false;
-
- // loop while no error
- while (!m_bStop)
-@@ -563,6 +600,8 @@
-
- m_pVideoCodec->Reset();
- m_packets.clear();
-+ picture.iFlags &= ~DVP_FLAG_ALLOCATED;
-+ g_renderManager.DiscardBuffer();
- break;
- }
-
-@@ -672,11 +711,15 @@
- CDVDCodecUtils::FreePicture(pTempYUVPackedPicture);
- #endif
-
-+ if (!m_bFpsInvalid)
-+ frametime = (double)DVD_TIME_BASE/m_fFrameRate;
-+
- if(m_started == false)
- {
- m_codecname = m_pVideoCodec->GetName();
- m_started = true;
- m_messageParent.Put(new CDVDMsgInt(CDVDMsg::PLAYER_STARTED, DVDPLAYER_VIDEO));
-+ g_renderManager.EnableBuffering(true);
- }
-
- // guess next frame pts. iDuration is always valid
-@@ -1039,6 +1082,10 @@
- flags |= CONF_FLAGS_FORMAT_VDPAU;
- formatstr = "VDPAU";
- break;
-+ case DVDVideoPicture::FMT_VDPAU_420:
-+ flags |= CONF_FLAGS_FORMAT_VDPAU_420;
-+ formatstr = "VDPAU_420";
-+ break;
- case DVDVideoPicture::FMT_DXVA:
- flags |= CONF_FLAGS_FORMAT_DXVA;
- formatstr = "DXVA";
-@@ -1054,6 +1101,10 @@
- flags |= CONF_FLAGS_FORMAT_CVBREF;
- formatstr = "BGRA";
- break;
-+ case DVDVideoPicture::FMT_XVBA:
-+ flags |= CONF_FLAGS_FORMAT_XVBA;
-+ formatstr = "XVBA";
-+ break;
- }
-
- if(m_bAllowFullscreen)
-@@ -1162,50 +1213,63 @@
- m_FlipTimeStamp += max(0.0, iSleepTime);
- m_FlipTimeStamp += iFrameDuration;
-
-- if (iSleepTime <= 0 && m_speed)
-- m_iLateFrames++;
-- else
-- m_iLateFrames = 0;
-+// if (iSleepTime <= 0 && m_speed)
-+// m_iLateFrames++;
-+// else
-+// m_iLateFrames = 0;
-+//
-+// // ask decoder to drop frames next round, as we are very late
-+// if(m_iLateFrames > 10)
-+// {
-+// if (!(pPicture->iFlags & DVP_FLAG_NOSKIP))
-+// {
-+// //if we're calculating the framerate,
-+// //don't drop frames until we've calculated a stable framerate
-+// if (m_bAllowDrop || m_speed != DVD_PLAYSPEED_NORMAL)
-+// {
-+// result |= EOS_VERYLATE;
-+// m_pullupCorrection.Flush(); //dropped frames mess up the pattern, so just flush it
-+// }
-+//
-+// //if we requested 5 drops in a row and we're still late, drop on output
-+// //this keeps a/v sync if the decoder can't drop, or we're still calculating the framerate
-+// if (m_iDroppedRequest > 5)
-+// {
-+// m_iDroppedRequest--; //decrease so we only drop half the frames
-+// return result | EOS_DROPPED;
-+// }
-+// m_iDroppedRequest++;
-+// }
-+// }
-+// else
-+// {
-+// m_iDroppedRequest = 0;
-+// }
-+
-+ if ((m_droppingStats.m_requestOutputDrop && !(pPicture->iFlags & DVP_FLAG_NOSKIP))
-+ || (pPicture->iFlags & DVP_FLAG_DROPPED))
-+ {
-+ m_droppingStats.AddOutputDropGain(pts, 1/m_fFrameRate);
-+ m_droppingStats.m_requestOutputDrop = false;
-+ CLog::Log(LOGDEBUG,"%s - dropped in output", __FUNCTION__);
-+ return result | EOS_DROPPED;
-+ }
-
-- // ask decoder to drop frames next round, as we are very late
-- if(m_iLateFrames > 10)
-+ if( m_speed < 0 )
- {
-- if (!(pPicture->iFlags & DVP_FLAG_NOSKIP))
-+ double decoderPts = m_droppingStats.m_lastDecoderPts;
-+ double renderPts = m_droppingStats.m_lastRenderPts;
-+ if (pts > renderPts)
- {
-- //if we're calculating the framerate,
-- //don't drop frames until we've calculated a stable framerate
-- if (m_bAllowDrop || m_speed != DVD_PLAYSPEED_NORMAL)
-+ if (decoderPts >= renderPts)
- {
-- result |= EOS_VERYLATE;
-- m_pullupCorrection.Flush(); //dropped frames mess up the pattern, so just flush it
-+ Sleep(200);
- }
--
-- //if we requested 5 drops in a row and we're still late, drop on output
-- //this keeps a/v sync if the decoder can't drop, or we're still calculating the framerate
-- if (m_iDroppedRequest > 5)
-- {
-- m_iDroppedRequest--; //decrease so we only drop half the frames
-- return result | EOS_DROPPED;
-- }
-- m_iDroppedRequest++;
-- }
-- }
-- else
-- {
-- m_iDroppedRequest = 0;
-- }
--
-- if( m_speed < 0 )
-- {
-- if( iClockSleep < -DVD_MSEC_TO_TIME(200)
-- && !(pPicture->iFlags & DVP_FLAG_NOSKIP) )
- return result | EOS_DROPPED;
-+ }
- }
-
-- if( (pPicture->iFlags & DVP_FLAG_DROPPED) )
-- return result | EOS_DROPPED;
--
-- if( m_speed != DVD_PLAYSPEED_NORMAL && limited )
-+ if( m_speed != DVD_PLAYSPEED_NORMAL && m_speed >= 0 && limited )
- {
- // calculate frame dropping pattern to render at this speed
- // we do that by deciding if this or next frame is closest
-@@ -1241,6 +1305,16 @@
- mDisplayField = FS_BOT;
- }
-
-+ int buffer = g_renderManager.WaitForBuffer(m_bStop);
-+ while (buffer < 0 && !CThread::m_bStop &&
-+ CDVDClock::GetAbsoluteClock(false) < iCurrentClock + iSleepTime + DVD_MSEC_TO_TIME(500) )
-+ {
-+ Sleep(1);
-+ buffer = g_renderManager.WaitForBuffer(m_bStop);
-+ }
-+ if (buffer < 0)
-+ return EOS_DROPPED;
-+
- ProcessOverlays(pPicture, pts);
- AutoCrop(pPicture);
-
-@@ -1257,7 +1331,7 @@
- if (index < 0)
- return EOS_DROPPED;
-
-- g_renderManager.FlipPage(CThread::m_bStop, (iCurrentClock + iSleepTime) / DVD_TIME_BASE, -1, mDisplayField);
-+ g_renderManager.FlipPage(CThread::m_bStop, pts, -1, mDisplayField, m_speed);
-
- return result;
- #else
-@@ -1271,7 +1345,8 @@
- if ((pPicture->format == DVDVideoPicture::FMT_YUV420P) ||
- (pPicture->format == DVDVideoPicture::FMT_NV12) ||
- (pPicture->format == DVDVideoPicture::FMT_YUY2) ||
-- (pPicture->format == DVDVideoPicture::FMT_UYVY))
-+ (pPicture->format == DVDVideoPicture::FMT_UYVY) ||
-+ (pPicture->format == DVDVideoPicture::FMT_VDPAU_420))
- {
- RECT crop;
-
-@@ -1500,7 +1575,7 @@
- double frameduration = m_pullupCorrection.GetFrameDuration();
-
- if (frameduration == DVD_NOPTS_VALUE ||
-- (g_advancedSettings.m_videoFpsDetect == 1 && m_pullupCorrection.GetPatternLength() > 1))
-+ (g_advancedSettings.m_videoFpsDetect == 1 && (m_pullupCorrection.GetPatternLength() > 1 && !m_bFpsInvalid)))
- {
- //reset the stored framerates if no good framerate was detected
- m_fStableFrameRate = 0.0;
-@@ -1556,3 +1631,142 @@
- m_iFrameRateCount = 0;
- }
- }
-+
-+int CDVDPlayerVideo::CalcDropRequirement(double pts)
-+{
-+ int result = 0;
-+ double iSleepTime;
-+ double iDecoderPts, iRenderPts;
-+ double iInterval;
-+ int interlaced;
-+ double iGain;
-+ double iLateness;
-+ bool bNewFrame;
-+ int iSkippedDeint = 0;
-+ int iBufferLevel;
-+
-+ // get decoder stats
-+ if (!m_pVideoCodec->GetPts(iDecoderPts, iSkippedDeint, interlaced))
-+ iDecoderPts = pts;
-+
-+ // get render stats
-+ g_renderManager.GetStats(iSleepTime, iRenderPts, iBufferLevel);
-+
-+ if (iBufferLevel < 2)
-+ {
-+ result |= EOS_BUFFER_LEVEL;
-+ if (iBufferLevel < 1)
-+ CLog::Log(LOGDEBUG,"--------------------- hurry: %d", iBufferLevel);
-+ }
-+
-+ bNewFrame = iDecoderPts != m_droppingStats.m_lastDecoderPts;
-+
-+ if (interlaced)
-+ iInterval = 2/m_fFrameRate*(double)DVD_TIME_BASE;
-+ else
-+ iInterval = 1/m_fFrameRate*(double)DVD_TIME_BASE;
-+
-+ // add any gains regardless of being late
-+ if (m_droppingStats.m_lastDecoderPts > 0
-+ && bNewFrame
-+ && m_bAllowDrop
-+ && m_droppingStats.m_dropRequests > 0)
-+ {
-+ iGain = (iDecoderPts - m_droppingStats.m_lastDecoderPts - iInterval)/(double)DVD_TIME_BASE;
-+ if (iSkippedDeint)
-+ {
-+ CDroppingStats::CGain gain;
-+ gain.gain = 1/m_fFrameRate;
-+ gain.pts = iDecoderPts;
-+ m_droppingStats.m_gain.push_back(gain);
-+ m_droppingStats.m_totalGain += gain.gain;
-+ result |= EOS_DROPPED;
-+ m_droppingStats.m_dropRequests = 0;
-+ CLog::Log(LOGDEBUG,"CDVDPlayerVideo::CalcDropRequirement - dropped de-interlacing cycle, Sleeptime: %f, Bufferlevel: %d", iSleepTime, iBufferLevel);
-+ }
-+ else if (iGain > 1/m_fFrameRate)
-+ {
-+ CDroppingStats::CGain gain;
-+ gain.gain = iGain;
-+ gain.pts = iDecoderPts;
-+ m_droppingStats.m_gain.push_back(gain);
-+ m_droppingStats.m_totalGain += iGain;
-+ result |= EOS_DROPPED;
-+ m_droppingStats.m_dropRequests = 0;
-+ CLog::Log(LOGDEBUG,"CDVDPlayerVideo::CalcDropRequirement - dropped in decoder, Sleeptime: %f, Bufferlevel: %d, Gain: %f", iSleepTime, iBufferLevel, iGain);
-+ }
-+
-+ }
-+ m_droppingStats.m_lastDecoderPts = iDecoderPts;
-+
-+ // subtract gains
-+ while (!m_droppingStats.m_gain.empty() &&
-+ iRenderPts >= m_droppingStats.m_gain.front().pts)
-+ {
-+ m_droppingStats.m_totalGain -= m_droppingStats.m_gain.front().gain;
-+ m_droppingStats.m_gain.pop_front();
-+ }
-+
-+// if (iSleepTime < 0)
-+// {
-+// CLog::Log(LOGNOTICE,"----- sleep: %f, gain :%f",
-+// iSleepTime, m_droppingStats.m_totalGain);
-+// }
-+
-+ // calculate lateness
-+ iLateness = iSleepTime + m_droppingStats.m_totalGain;
-+ if (iLateness < 0 && m_speed)
-+ {
-+ if (bNewFrame)
-+ m_droppingStats.m_lateFrames++;
-+
-+ // if lateness is smaller than frametime, we observe this state
-+ // for 10 cycles
-+ if (m_droppingStats.m_lateFrames > 10 || iLateness < -2/m_fFrameRate)
-+ {
-+ // is frame allowed to skip
-+ if (m_iNrOfPicturesNotToSkip <= 0)
-+ {
-+ result |= EOS_VERYLATE;
-+
-+ // drop in output
-+ if (m_droppingStats.m_dropRequests > 7 && g_graphicsContext.IsFullScreenVideo())
-+ {
-+ m_droppingStats.m_dropRequests--; //decrease so we only drop half the frames
-+ m_droppingStats.m_requestOutputDrop = true;
-+ CLog::Log(LOGNOTICE,"-------- drop output");
-+ }
-+ else if (bNewFrame)
-+ m_droppingStats.m_dropRequests++;
-+ }
-+ }
-+ }
-+ else
-+ {
-+ m_droppingStats.m_dropRequests = 0;
-+ m_droppingStats.m_lateFrames = 0;
-+ m_droppingStats.m_requestOutputDrop = false;
-+ }
-+ m_droppingStats.m_lastRenderPts = iRenderPts;
-+ return result;
-+}
-+
-+void CDroppingStats::Reset()
-+{
-+ m_gain.clear();
-+ m_totalGain = 0;
-+ m_lastDecoderPts = 0;
-+ m_lastRenderPts = 0;
-+ m_lateFrames = 0;
-+ m_dropRequests = 0;
-+ m_requestOutputDrop = false;
-+}
-+
-+void CDroppingStats::AddOutputDropGain(double pts, double frametime)
-+{
-+ CDroppingStats::CGain gain;
-+ gain.gain = frametime;
-+ gain.pts = pts;
-+ m_gain.push_back(gain);
-+ m_totalGain += frametime;
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayerVideo.h xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerVideo.h
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayerVideo.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerVideo.h 2012-05-14 14:15:12.150220789 +0200
-@@ -38,6 +38,26 @@
-
- #define VIDEO_PICTURE_QUEUE_SIZE 1
-
-+class CDroppingStats
-+{
-+public:
-+ void Reset();
-+ void AddOutputDropGain(double pts, double frametime);
-+ struct CGain
-+ {
-+ double gain;
-+ double pts;
-+ };
-+ std::deque m_gain;
-+ double m_totalGain;
-+ double m_lastDecoderPts;
-+ double m_lastRenderPts;
-+ unsigned int m_lateFrames;
-+ unsigned int m_dropRequests;
-+ bool m_requestOutputDrop;
-+};
-+
-+
- class CDVDPlayerVideo : public CThread
- {
- public:
-@@ -111,6 +131,7 @@
- #define EOS_ABORT 1
- #define EOS_DROPPED 2
- #define EOS_VERYLATE 4
-+#define EOS_BUFFER_LEVEL 8
-
- void AutoCrop(DVDVideoPicture* pPicture);
- void AutoCrop(DVDVideoPicture *pPicture, RECT &crop);
-@@ -130,9 +151,11 @@
- int m_iLateFrames;
- int m_iDroppedFrames;
- int m_iDroppedRequest;
-+ double m_iLastSleepTime;
-
- void ResetFrameRateCalc();
- void CalcFrameRate();
-+ int CalcDropRequirement(double pts);
-
- double m_fFrameRate; //framerate of the video currently playing
- bool m_bCalcFrameRate; //if we should calculate the framerate from the timestamps
-@@ -193,5 +216,7 @@
- CPullupCorrection m_pullupCorrection;
-
- std::list m_packets;
-+
-+ CDroppingStats m_droppingStats;
- };
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/paplayer/PAPlayer.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/paplayer/PAPlayer.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/paplayer/PAPlayer.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/paplayer/PAPlayer.cpp 2012-05-14 14:15:12.151220809 +0200
-@@ -52,7 +52,7 @@
- // Supporting all open audio codec standards.
- // First one being nullsoft's nsv audio decoder format
-
--PAPlayer::PAPlayer(IPlayerCallback& callback) : IPlayer(callback)
-+PAPlayer::PAPlayer(IPlayerCallback& callback) : CThread("PAPlayer"), IPlayer(callback)
- {
- m_bIsPlaying = false;
- m_bPaused = false;
-@@ -168,7 +168,7 @@
-
- *m_currentFile = file;
-
-- if (ThreadHandle() == NULL)
-+ if (!IsRunning())
- Create();
-
- m_startEvent.Set();
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp 2012-05-14 14:15:12.155220890 +0200
-@@ -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,9 @@
- #ifdef HAVE_LIBVDPAU
- vdpau = NULL;
- #endif
-+#ifdef HAVE_LIBXVBA
-+ xvba = NULL;
-+#endif
- }
-
- CLinuxRendererGL::YUVBUFFER::~YUVBUFFER()
-@@ -224,7 +230,7 @@
-
- void CLinuxRendererGL::ManageTextures()
- {
-- m_NumYV12Buffers = 2;
-+// m_NumYV12Buffers = NUM_BUFFERS;
- //m_iYV12RenderBuffer = 0;
- return;
- }
-@@ -241,6 +247,11 @@
- else
- CLog::Log(LOGNOTICE,"Using GL_TEXTURE_2D");
-
-+ // function pointer for texture might change in
-+ // call to LoadShaders
-+ for (int i = 0 ; i < m_NumYV12Buffers ; i++)
-+ (this->*m_textureDelete)(i);
-+
- // create the yuv textures
- LoadShaders();
-
-@@ -567,6 +578,18 @@
-
- glFinish();
- m_bValidated = false;
-+ m_iYV12RenderBuffer = 0;
-+}
-+
-+void CLinuxRendererGL::ReleaseBuffer(int idx)
-+{
-+ YUVBUFFER &buf = m_buffers[idx];
-+#ifdef HAVE_LIBVDPAU
-+ SAFE_RELEASE(buf.vdpau);
-+#endif
-+#ifdef HAVE_LIBXVBA
-+ SAFE_RELEASE(buf.xvba);
-+#endif
- }
-
- void CLinuxRendererGL::Update(bool bPauseDrawing)
-@@ -640,6 +663,18 @@
-
- glDisable(GL_POLYGON_STIPPLE);
- }
-+ else if( CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_VDPAU_420
-+ && !(flags & (RENDER_FLAG_TOP | RENDER_FLAG_BOT)))
-+ {
-+ glDisable(GL_BLEND);
-+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-+ Render(flags | RENDER_FLAG_TOP, index);
-+
-+ glEnable(GL_BLEND);
-+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-+ glColor4f(1.0f, 1.0f, 1.0f, 128 / 255.0f);
-+ Render(flags | RENDER_FLAG_BOT , index);
-+ }
- else
- Render(flags, index);
-
-@@ -718,11 +753,6 @@
-
- m_buffers[m_iYV12RenderBuffer].flipindex = ++m_flipindex;
-
--#ifdef HAVE_LIBVDPAU
-- if((m_renderMethod & RENDER_VDPAU) && m_buffers[m_iYV12RenderBuffer].vdpau)
-- m_buffers[m_iYV12RenderBuffer].vdpau->Present();
--#endif
--
- return;
- }
-
-@@ -737,7 +767,6 @@
- m_resolution = RES_DESKTOP;
-
- m_iYV12RenderBuffer = 0;
-- m_NumYV12Buffers = 2;
-
- // setup the background colour
- m_clearColour = (float)(g_advancedSettings.m_videoBlackBarColour & 0xff) / 0xff;
-@@ -817,7 +846,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 +927,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");
-@@ -1026,12 +1060,24 @@
- m_textureCreate = &CLinuxRendererGL::CreateVDPAUTexture;
- m_textureDelete = &CLinuxRendererGL::DeleteVDPAUTexture;
- }
-+ else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_VDPAU_420)
-+ {
-+ m_textureUpload = &CLinuxRendererGL::UploadVDPAUTexture420;
-+ m_textureCreate = &CLinuxRendererGL::CreateVDPAUTexture420;
-+ m_textureDelete = &CLinuxRendererGL::DeleteVDPAUTexture420;
-+ }
- else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_VAAPI)
- {
- m_textureUpload = &CLinuxRendererGL::UploadVAAPITexture;
- 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
- {
- // setup default YV12 texture handlers
-@@ -1132,6 +1178,13 @@
- RenderVAAPI(renderBuffer, m_currentField);
- }
- #endif
-+#ifdef HAVE_LIBXVBA
-+ else if (m_renderMethod & RENDER_XVBA)
-+ {
-+ UpdateVideoFilter();
-+ RenderXVBA(renderBuffer, m_currentField);
-+ }
-+#endif
- else
- {
- RenderSoftware(renderBuffer, m_currentField);
-@@ -1434,17 +1487,12 @@
- void CLinuxRendererGL::RenderVDPAU(int index, int field)
- {
- #ifdef HAVE_LIBVDPAU
-- YUVPLANE &plane = m_buffers[index].fields[field][0];
-- CVDPAU *vdpau = m_buffers[m_iYV12RenderBuffer].vdpau;
--
-- if (!vdpau)
-- return;
-+ YUVPLANE &plane = m_buffers[index].fields[0][1];
-
- glEnable(m_textureTarget);
- glActiveTextureARB(GL_TEXTURE0);
-- glBindTexture(m_textureTarget, plane.id);
-
-- vdpau->BindPixmap();
-+ glBindTexture(m_textureTarget, plane.id);
-
- // Try some clamping or wrapping
- glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-@@ -1502,8 +1550,6 @@
- if (m_pVideoFilterShader)
- m_pVideoFilterShader->Disable();
-
-- vdpau->ReleasePixmap();
--
- glBindTexture (m_textureTarget, 0);
- glDisable(m_textureTarget);
- #endif
-@@ -1598,6 +1644,77 @@
- #endif
- }
-
-+void CLinuxRendererGL::RenderXVBA(int index, int field)
-+{
-+#ifdef HAVE_LIBXVBA
-+ YUVPLANE &plane = m_buffers[index].fields[0][1];
-+
-+ 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];
-@@ -2162,12 +2279,14 @@
- {
- #ifdef HAVE_LIBVDPAU
- YUVPLANE &plane = m_buffers[index].fields[0][0];
-+ YUVFIELDS &fields = m_buffers[index].fields;
-
- SAFE_RELEASE(m_buffers[index].vdpau);
-
- if(plane.id && glIsTexture(plane.id))
- glDeleteTextures(1, &plane.id);
- plane.id = 0;
-+ fields[0][1].id = 0;
- #endif
- }
-
-@@ -2201,8 +2320,156 @@
- void CLinuxRendererGL::UploadVDPAUTexture(int index)
- {
- #ifdef HAVE_LIBVDPAU
-+ VDPAU::CVdpauRenderPicture *vdpau = m_buffers[index].vdpau;
-+
-+ unsigned int flipindex = m_buffers[index].flipindex;
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+ YUVPLANE &plane = fields[0][0];
-+
-+ if (!vdpau)
-+ {
-+ fields[0][1].id = plane.id;
-+ m_eventTexturesDone[index]->Set();
-+ CLog::Log(LOGWARNING,"--------- no vdpau texture, index: %d", index);
-+ return;
-+ }
-+
-+// CLog::Log(LOGNOTICE,"-------- rendered output surf: %d", vdpau->sourceIdx);
-+// CLog::Log(LOGNOTICE,"-------- pts: %f", vdpau->DVDPic.pts);
-+ fields[0][1].id = vdpau->texture[0];
-+
-+ m_eventTexturesDone[index]->Set();
-+#endif
-+}
-+
-+void CLinuxRendererGL::DeleteVDPAUTexture420(int index)
-+{
-+#ifdef HAVE_LIBVDPAU
-+ YUVPLANE &plane = m_buffers[index].fields[0][0];
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+
-+ SAFE_RELEASE(m_buffers[index].vdpau);
-+
-+ if(plane.id && glIsTexture(plane.id))
-+ glDeleteTextures(1, &plane.id);
-+ plane.id = 0;
-+ fields[1][0].id = 0;
-+ fields[1][1].id = 0;
-+ fields[2][0].id = 0;
-+ fields[2][1].id = 0;
-+
-+#endif
-+}
-+
-+bool CLinuxRendererGL::CreateVDPAUTexture420(int index)
-+{
-+#ifdef HAVE_LIBVDPAU
-+ YV12Image &im = m_buffers[index].image;
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+ YUVPLANE &plane = fields[0][0];
-+ GLuint *pbo = m_buffers[index].pbo;
-+
-+ DeleteVDPAUTexture420(index);
-+
-+ memset(&im , 0, sizeof(im));
-+ memset(&fields, 0, sizeof(fields));
-+
-+ im.cshift_x = 1;
-+ im.cshift_y = 1;
-+
-+ im.plane[0] = NULL;
-+ im.plane[1] = NULL;
-+ im.plane[2] = NULL;
-+
-+ for(int p = 0;p<3;p++)
-+ {
-+ pbo[p] = None;
-+ }
-+
-+ glEnable(m_textureTarget);
-+ glGenTextures(1, &plane.id);
-+ glDisable(m_textureTarget);
-+
-+ m_eventTexturesDone[index]->Set();
-+#endif
-+ return true;
-+}
-+
-+void CLinuxRendererGL::UploadVDPAUTexture420(int index)
-+{
-+#ifdef HAVE_LIBVDPAU
-+ VDPAU::CVdpauRenderPicture *vdpau = m_buffers[index].vdpau;
-+ YV12Image &im = m_buffers[index].image;
-+
-+ unsigned int flipindex = m_buffers[index].flipindex;
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+ YUVPLANE &plane = fields[0][0];
-+
-+ if (!vdpau)
-+ {
-+ fields[1][0].id = plane.id;
-+ fields[1][1].id = plane.id;
-+ fields[2][0].id = plane.id;
-+ fields[2][1].id = plane.id;
-+ m_eventTexturesDone[index]->Set();
-+ return;
-+ }
-+
-+ im.height = vdpau->texHeight;
-+ im.width = vdpau->texWidth;
-+
-+ // YUV
-+ for (int f = FIELD_FULL; f<=FIELD_BOT ; f++)
-+ {
-+ int fieldshift = (f==FIELD_FULL) ? 0 : 1;
-+ YUVPLANES &planes = fields[f];
-+
-+ planes[0].texwidth = im.width;
-+ planes[0].texheight = im.height >> fieldshift;
-+
-+ planes[1].texwidth = planes[0].texwidth >> im.cshift_x;
-+ planes[1].texheight = planes[0].texheight >> im.cshift_y;
-+ planes[2].texwidth = planes[1].texwidth;
-+ planes[2].texheight = planes[1].texheight;
-+
-+ for (int p = 0; p < 3; p++)
-+ {
-+ planes[p].pixpertex_x = 1;
-+ planes[p].pixpertex_y = 1;
-+ }
-+ }
-+ // crop
-+// m_sourceRect.x1 += vdpau->crop.x1;
-+// m_sourceRect.x2 -= vdpau->crop.x2;
-+// m_sourceRect.y1 += vdpau->crop.y1;
-+// m_sourceRect.y2 -= vdpau->crop.y2;
-+
-+ // set textures
-+ fields[1][0].id = vdpau->texture[0];
-+ fields[1][1].id = vdpau->texture[2];
-+ fields[2][0].id = vdpau->texture[1];
-+ fields[2][1].id = vdpau->texture[3];
-+
-+ glEnable(m_textureTarget);
-+ for (int f = 1; f < 3; f++)
-+ {
-+ for (int p=0;p<2;p++)
-+ {
-+ glBindTexture(m_textureTarget,fields[f][p].id);
-+ 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);
-+
-+ glBindTexture(m_textureTarget,0);
-+ VerifyGLState();
-+ }
-+ fields[f][2].id = fields[f][1].id;
-+ }
-+ CalculateTextureSourceRects(index, 3);
-+ glDisable(m_textureTarget);
-+
- m_eventTexturesDone[index]->Set();
-- glPixelStorei(GL_UNPACK_ALIGNMENT,1); //what's this for?
- #endif
- }
-
-@@ -2352,6 +2619,93 @@
- #endif
- }
-
-+void CLinuxRendererGL::DeleteXVBATexture(int index)
-+{
-+#ifdef HAVE_LIBXVBA
-+ YUVPLANE &plane = m_buffers[index].fields[0][0];
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+
-+ SAFE_RELEASE(m_buffers[index].xvba);
-+
-+ if(plane.id && glIsTexture(plane.id))
-+ glDeleteTextures(1, &plane.id);
-+ plane.id = 0;
-+ fields[0][1].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];
-+
-+ DeleteXVBATexture(index);
-+
-+ memset(&im , 0, sizeof(im));
-+ memset(&fields, 0, sizeof(fields));
-+
-+ glGenTextures(1, &plane.id);
-+
-+ m_eventTexturesDone[index]->Set();
-+#endif
-+ return true;
-+}
-+
-+void CLinuxRendererGL::UploadXVBATexture(int index)
-+{
-+#ifdef HAVE_LIBXVBA
-+ XVBA::CXvbaRenderPicture *xvba = m_buffers[index].xvba;
-+ YV12Image &im = m_buffers[index].image;
-+
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+ YUVPLANE &plane = fields[0][1];
-+
-+ if (!xvba)
-+ {
-+ fields[0][1].id = fields[0][0].id;
-+ m_eventTexturesDone[index]->Set();
-+ CLog::Log(LOGWARNING,"CLinuxRendererGL::UploadXVBATexture no xvba texture, index: %d", index);
-+ return;
-+ }
-+// xvba->Transfer();
-+
-+ fields[0][1].id = xvba->texture;
-+
-+ im.height = xvba->texHeight;
-+ im.width = xvba->texWidth;
-+
-+ plane.texwidth = xvba->texWidth;
-+ plane.texheight = xvba->texHeight;
-+ plane.pixpertex_x = 1;
-+ plane.pixpertex_y = 1;
-+
-+ plane.rect = m_sourceRect;
-+ plane.width = im.width;
-+ plane.height = im.height;
-+
-+ plane.height /= plane.pixpertex_y;
-+ plane.rect.y1 /= plane.pixpertex_y;
-+ plane.rect.y2 /= plane.pixpertex_y;
-+ plane.width /= plane.pixpertex_x;
-+ plane.rect.x1 /= plane.pixpertex_x;
-+ plane.rect.x2 /= plane.pixpertex_x;
-+
-+ if (m_textureTarget == GL_TEXTURE_2D)
-+ {
-+ plane.height /= plane.texheight;
-+ plane.rect.y1 /= plane.texheight;
-+ plane.rect.y2 /= plane.texheight;
-+ plane.width /= plane.texwidth;
-+ plane.rect.x1 /= plane.texwidth;
-+ plane.rect.x2 /= plane.texwidth;
-+ }
-+
-+ m_eventTexturesDone[index]->Set();
-+#endif
-+}
-+
- void CLinuxRendererGL::UploadYUV422PackedTexture(int source)
- {
- YUVBUFFER& buf = m_buffers[source];
-@@ -2935,6 +3289,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 +3305,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 +3331,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;
- }
-
-@@ -2998,12 +3359,13 @@
- if(method == VS_INTERLACEMETHOD_AUTO)
- return true;
-
-- if(m_renderMethod & RENDER_VDPAU)
-+ if(m_renderMethod & RENDER_VDPAU ||
-+ CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_VDPAU_420)
- {
- #ifdef HAVE_LIBVDPAU
-- CVDPAU *vdpau = m_buffers[m_iYV12RenderBuffer].vdpau;
-- if(vdpau)
-- return vdpau->Supports(method);
-+ VDPAU::CVdpauRenderPicture *vdpauPic = m_buffers[m_iYV12RenderBuffer].vdpau;
-+ if(vdpauPic && vdpauPic->vdpau)
-+ return vdpauPic->vdpau->Supports(method);
- #endif
- return false;
- }
-@@ -3027,6 +3389,16 @@
- return false;
- }
-
-+ if(m_renderMethod & RENDER_XVBA)
-+ {
-+#ifdef HAVE_LIBXVBA
-+ XVBA::CXvbaRenderPicture *xvba = m_buffers[m_iYV12RenderBuffer].xvba;
-+ if(xvba)
-+ return xvba->xvba->Supports(method);
-+#endif
-+ return false;
-+ }
-+
- #ifdef TARGET_DARWIN
- // YADIF too slow for HD but we have no methods to fall back
- // to something that works so just turn it off.
-@@ -3069,7 +3441,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
-@@ -3088,9 +3460,9 @@
- if(m_renderMethod & RENDER_VDPAU)
- {
- #ifdef HAVE_LIBVDPAU
-- CVDPAU *vdpau = m_buffers[m_iYV12RenderBuffer].vdpau;
-- if(vdpau)
-- return vdpau->AutoInterlaceMethod();
-+ VDPAU::CVdpauRenderPicture *vdpauPic = m_buffers[m_iYV12RenderBuffer].vdpau;
-+ if(vdpauPic && vdpauPic->vdpau)
-+ return vdpauPic->vdpau->AutoInterlaceMethod();
- #endif
- return VS_INTERLACEMETHOD_NONE;
- }
-@@ -3136,20 +3508,31 @@
- }
-
- #ifdef HAVE_LIBVDPAU
--void CLinuxRendererGL::AddProcessor(CVDPAU* vdpau)
-+void CLinuxRendererGL::AddProcessor(VDPAU::CVdpauRenderPicture *vdpau, int index)
- {
-- YUVBUFFER &buf = m_buffers[NextYV12Texture()];
-+ YUVBUFFER &buf = m_buffers[index];
-+ VDPAU::CVdpauRenderPicture *pic = vdpau->Acquire();
- SAFE_RELEASE(buf.vdpau);
-- buf.vdpau = (CVDPAU*)vdpau->Acquire();
-+ buf.vdpau = pic;
- }
- #endif
-
- #ifdef HAVE_LIBVA
--void CLinuxRendererGL::AddProcessor(VAAPI::CHolder& holder)
-+void CLinuxRendererGL::AddProcessor(VAAPI::CHolder& holder, int index)
- {
-- YUVBUFFER &buf = m_buffers[NextYV12Texture()];
-+ YUVBUFFER &buf = m_buffers[index];
- buf.vaapi.surface = holder.surface;
- }
- #endif
-
-+#ifdef HAVE_LIBXVBA
-+void CLinuxRendererGL::AddProcessor(XVBA::CXvbaRenderPicture* xvba, int index)
-+{
-+ YUVBUFFER &buf = m_buffers[index];
-+ XVBA::CXvbaRenderPicture *pic = xvba->Acquire();
-+ SAFE_RELEASE(buf.xvba);
-+ buf.xvba = pic;
-+}
-+#endif
-+
- #endif
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/LinuxRendererGL.h xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/LinuxRendererGL.h
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/LinuxRendererGL.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/LinuxRendererGL.h 2012-05-14 14:15:12.156220910 +0200
-@@ -35,13 +35,14 @@
-
- class CRenderCapture;
-
--class CVDPAU;
- class CBaseTexture;
- namespace Shaders { class BaseYUV2RGBShader; }
- namespace Shaders { class BaseVideoFilterShader; }
- namespace VAAPI { struct CHolder; }
-+namespace VDPAU { class CVdpauRenderPicture; }
-+namespace XVBA { class CXvbaRenderPicture; }
-
--#define NUM_BUFFERS 3
-+#define NUM_BUFFERS 10
-
-
- #undef ALIGN
-@@ -94,6 +95,7 @@
- RENDER_VDPAU=0x08,
- RENDER_POT=0x10,
- RENDER_VAAPI=0x20,
-+ RENDER_XVBA=0x40,
- };
-
- enum RenderQuality
-@@ -141,14 +143,19 @@
- virtual void UnInit();
- virtual void Reset(); /* resets renderer after seek for example */
- virtual void Flush();
-+ virtual void ReleaseBuffer(int idx);
-+ virtual void SetProcessorSize(int numBuffers) { m_NumYV12Buffers = numBuffers; }
-+ virtual unsigned int GetProcessorSize() { return m_NumYV12Buffers; }
-
- #ifdef HAVE_LIBVDPAU
-- virtual void AddProcessor(CVDPAU* vdpau);
-+ virtual void AddProcessor(VDPAU::CVdpauRenderPicture* vdpau, int index);
- #endif
- #ifdef HAVE_LIBVA
-- virtual void AddProcessor(VAAPI::CHolder& holder);
-+ virtual void AddProcessor(VAAPI::CHolder& holder, int index);
-+#endif
-+#ifdef HAVE_LIBXVBA
-+ virtual void AddProcessor(XVBA::CXvbaRenderPicture* xvba, int index);
- #endif
--
- virtual void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255);
-
- // Feature support
-@@ -190,6 +197,10 @@
- void DeleteVDPAUTexture(int index);
- bool CreateVDPAUTexture(int index);
-
-+ void UploadVDPAUTexture420(int index);
-+ void DeleteVDPAUTexture420(int index);
-+ bool CreateVDPAUTexture420(int index);
-+
- void UploadVAAPITexture(int index);
- void DeleteVAAPITexture(int index);
- bool CreateVAAPITexture(int index);
-@@ -198,6 +209,10 @@
- void DeleteYUV422PackedTexture(int index);
- bool CreateYUV422PackedTexture(int index);
-
-+ void UploadXVBATexture(int index);
-+ void DeleteXVBATexture(int index);
-+ bool CreateXVBATexture(int index);
-+
- void UploadRGBTexture(int index);
- void ToRGBFrame(YV12Image* im, unsigned flipIndexPlane, unsigned flipIndexBuf);
- void ToRGBFields(YV12Image* im, unsigned flipIndexPlaneTop, unsigned flipIndexPlaneBot, unsigned flipIndexBuf);
-@@ -210,7 +225,9 @@
- void RenderSinglePass(int renderBuffer, int field); // single pass glsl renderer
- void RenderSoftware(int renderBuffer, int field); // single pass s/w yuv2rgb renderer
- void RenderVDPAU(int renderBuffer, int field); // render using vdpau hardware
-+ void RenderVDPAUYV12(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;
-
-@@ -265,11 +282,14 @@
- GLuint pbo[MAX_PLANES];
-
- #ifdef HAVE_LIBVDPAU
-- CVDPAU* vdpau;
-+ VDPAU::CVdpauRenderPicture *vdpau;
- #endif
- #ifdef HAVE_LIBVA
- VAAPI::CHolder& vaapi;
- #endif
-+#ifdef HAVE_LIBXVBA
-+ XVBA::CXvbaRenderPicture *xvba;
-+#endif
- };
-
- typedef YUVBUFFER YUVBUFFERS[NUM_BUFFERS];
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/OverlayRenderer.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/OverlayRenderer.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/OverlayRenderer.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/OverlayRenderer.cpp 2012-05-14 14:15:12.157220930 +0200
-@@ -89,7 +89,7 @@
- CRenderer::CRenderer()
- {
- m_render = 0;
-- m_decode = (m_render + 1) % 2;
-+// m_decode = (m_render + 1) % 2;
- }
-
- CRenderer::~CRenderer()
-@@ -154,9 +154,10 @@
- {
- CSingleLock lock(m_section);
-
-- for(int i = 0; i < 2; i++)
-+ for(int i = 0; i < m_iNumBuffers; i++)
- Release(m_buffers[i]);
-
-+ m_render = 0;
- Release(m_cleanup);
- }
-
-@@ -164,10 +165,23 @@
- {
- CSingleLock lock(m_section);
-
-- m_render = m_decode;
-- m_decode =(m_decode + 1) % 2;
-+// m_render = m_decode;
-+ m_render = (m_render + 1) % m_iNumBuffers;
-+
-+// Release(m_buffers[m_decode]);
-+}
-+
-+void CRenderer::SetBuffer(int idx)
-+{
-+ CSingleLock lock(m_section);
-+ Release(m_buffers[idx]);
-+ m_decode = idx;
-+}
-
-- Release(m_buffers[m_decode]);
-+void CRenderer::ReleaseBuffer(int idx)
-+{
-+ CSingleLock lock(m_section);
-+ Release(m_buffers[idx]);
- }
-
- void CRenderer::Render()
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/OverlayRenderer.h xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/OverlayRenderer.h
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/OverlayRenderer.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/OverlayRenderer.h 2012-05-14 14:15:12.157220930 +0200
-@@ -99,6 +99,9 @@
- void Flip();
- void Render();
- void Flush();
-+ void SetNumBuffers(int numBuffers) { m_iNumBuffers = numBuffers; }
-+ void SetBuffer(int idx);
-+ void ReleaseBuffer(int idx);
-
- protected:
-
-@@ -124,7 +127,8 @@
- void Release(SElementV& list);
-
- CCriticalSection m_section;
-- SElementV m_buffers[2];
-+ SElementV m_buffers[10];
-+ int m_iNumBuffers;
- int m_decode;
- int m_render;
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/RenderFlags.h xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/RenderFlags.h
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/RenderFlags.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/RenderFlags.h 2012-05-14 14:15:12.158220950 +0200
-@@ -76,8 +76,10 @@
- #define CONF_FLAGS_FORMAT_YUY2 0x008000
- #define CONF_FLAGS_FORMAT_DXVA 0x010000
- #define CONF_FLAGS_FORMAT_VDPAU 0x020000
-+#define CONF_FLAGS_FORMAT_VDPAU_420 0x22000
- #define CONF_FLAGS_FORMAT_VAAPI 0x030000
- #define CONF_FLAGS_FORMAT_OMXEGL 0x040000
- #define CONF_FLAGS_FORMAT_CVBREF 0x080000
- #define CONF_FLAGS_FORMAT_BYPASS 0x100000
-+#define CONF_FLAGS_FORMAT_XVBA 0x200000
- #endif
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/RenderManager.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/RenderManager.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/RenderManager.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/RenderManager.cpp 2012-05-14 14:15:12.160220990 +0200
-@@ -26,6 +26,7 @@
- #include "utils/MathUtils.h"
- #include "threads/SingleLock.h"
- #include "utils/log.h"
-+#include "utils/TimeUtils.h"
-
- #include "Application.h"
- #include "settings/Settings.h"
-@@ -53,6 +54,8 @@
- #include "../dvdplayer/DVDCodecs/Video/DVDVideoCodec.h"
- #include "../dvdplayer/DVDCodecs/DVDCodecUtils.h"
-
-+#include "windowing/WindowingFactory.h"
-+
- #define MAXPRESENTDELAY 0.500
-
- /* at any point we want an exclusive lock on rendermanager */
-@@ -246,6 +249,7 @@
- m_bReconfigured = true;
- m_presentstep = PRESENT_IDLE;
- m_presentevent.Set();
-+// ResetRenderBuffer();
- }
-
- return result;
-@@ -277,8 +281,12 @@
- if (!m_pRenderer)
- return;
-
-+ if (m_presentstep == PRESENT_IDLE)
-+ PrepareNextRender();
-+
- if(m_presentstep == PRESENT_FLIP)
- {
-+ FlipRenderBuffer();
- m_overlays.Flip();
- m_pRenderer->FlipPage(m_presentsource);
- m_presentstep = PRESENT_FRAME;
-@@ -286,6 +294,8 @@
- }
- }
-
-+// CLog::Log(LOGNOTICE,"------ current: %d", m_iCurrentRenderBuffer);
-+
- if (g_advancedSettings.m_videoDisableBackgroundDeinterlace)
- {
- CSharedLock lock(m_sharedSection);
-@@ -297,7 +307,7 @@
- m_presentevent.Set();
- }
-
--unsigned int CXBMCRenderManager::PreInit()
-+unsigned int CXBMCRenderManager::PreInit(CDVDClock *pClock)
- {
- CRetakeLock lock(m_sharedSection);
-
-@@ -305,6 +315,7 @@
- m_presenterr = 0.0;
- m_errorindex = 0;
- memset(m_errorbuff, 0, sizeof(m_errorbuff));
-+ m_pClock = pClock;
-
- m_bIsStarted = false;
- m_bPauseDrawing = false;
-@@ -323,6 +334,17 @@
-
- UpdateDisplayLatency();
-
-+ m_swapCount = 1;
-+// std::string Vendor = g_Windowing.GetRenderVendor();
-+// std::transform(Vendor.begin(), Vendor.end(), Vendor.begin(), ::tolower);
-+// if (Vendor.compare(0, 3, "ati") == 0)
-+// {
-+// m_swapCount = 2;
-+// }
-+ ResetRenderBuffer();
-+ m_bUseBuffering = false;
-+ m_overlays.SetNumBuffers(m_iNumRenderBuffers);
-+ m_pRenderer->SetProcessorSize(m_iNumRenderBuffers);
- return m_pRenderer->PreInit();
- }
-
-@@ -351,7 +373,9 @@
-
- CRetakeLock lock(m_sharedSection);
- m_pRenderer->Flush();
-+ m_overlays.Flush();
- m_flushEvent.Set();
-+ ResetRenderBuffer();
- }
- else
- {
-@@ -512,25 +536,21 @@
- m_captures.erase(it);
- }
-
--void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0LL*/, int source /*= -1*/, EFIELDSYNC sync /*= FS_NONE*/)
-+void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0LL*/, int source /*= -1*/, EFIELDSYNC sync /*= FS_NONE*/, int speed /*= 0*/)
- {
-- if(timestamp - GetPresentTime() > MAXPRESENTDELAY)
-- timestamp = GetPresentTime() + MAXPRESENTDELAY;
--
-- /* can't flip, untill timestamp */
-- if(!g_graphicsContext.IsFullScreenVideo())
-- WaitPresentTime(timestamp);
--
-- /* make sure any queued frame was fully presented */
-- double timeout = m_presenttime + 1.0;
-- while(m_presentstep != PRESENT_IDLE && !bStop)
-+ if (!m_bUseBuffering)
- {
-- if(!m_presentevent.WaitMSec(100) && GetPresentTime() > timeout && !bStop)
-+ /* make sure any queued frame was fully presented */
-+ double timeout = m_presenttime + 1.0;
-+ while(m_presentstep != PRESENT_IDLE && !bStop)
- {
-- CLog::Log(LOGWARNING, "CRenderManager::FlipPage - timeout waiting for previous frame");
-- return;
-+ if(!m_presentevent.WaitMSec(100) && GetPresentTime() > timeout && !bStop)
-+ {
-+ CLog::Log(LOGWARNING, "CRenderManager::FlipPage - timeout waiting for previous frame");
-+ return;
-+ }
- }
-- };
-+ }
-
- if(bStop)
- return;
-@@ -538,58 +558,67 @@
- { CRetakeLock lock(m_sharedSection);
- if(!m_pRenderer) return;
-
-- m_presenttime = timestamp;
-- m_presentfield = sync;
-- m_presentstep = PRESENT_FLIP;
-- m_presentsource = source;
-+ double presenttime = timestamp;
-+ EFIELDSYNC presentfield = sync;
-+ EPRESENTMETHOD presentmethod;
-+
- EDEINTERLACEMODE deinterlacemode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
- EINTERLACEMETHOD interlacemethod = AutoInterlaceMethodInternal(g_settings.m_currentVideoSettings.m_InterlaceMethod);
-
- bool invert = false;
-
- if (deinterlacemode == VS_DEINTERLACEMODE_OFF)
-- m_presentmethod = PRESENT_METHOD_SINGLE;
-+ presentmethod = PRESENT_METHOD_SINGLE;
- else
- {
-- if (deinterlacemode == VS_DEINTERLACEMODE_AUTO && m_presentfield == FS_NONE)
-- m_presentmethod = PRESENT_METHOD_SINGLE;
-+ if (deinterlacemode == VS_DEINTERLACEMODE_AUTO && presentfield == FS_NONE)
-+ presentmethod = PRESENT_METHOD_SINGLE;
- else
- {
-- if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BLEND) m_presentmethod = PRESENT_METHOD_BLEND;
-- else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_WEAVE) m_presentmethod = PRESENT_METHOD_WEAVE;
-- else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_WEAVE_INVERTED) { m_presentmethod = PRESENT_METHOD_WEAVE ; invert = true; }
-- else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BOB) m_presentmethod = PRESENT_METHOD_BOB;
-- else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BOB_INVERTED) { m_presentmethod = PRESENT_METHOD_BOB; invert = true; }
-- else if (interlacemethod == VS_INTERLACEMETHOD_DXVA_BOB) m_presentmethod = PRESENT_METHOD_BOB;
-- else if (interlacemethod == VS_INTERLACEMETHOD_DXVA_BEST) m_presentmethod = PRESENT_METHOD_BOB;
-- else m_presentmethod = PRESENT_METHOD_SINGLE;
-+ if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BLEND) presentmethod = PRESENT_METHOD_BLEND;
-+ else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_WEAVE) presentmethod = PRESENT_METHOD_WEAVE;
-+ else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_WEAVE_INVERTED) { presentmethod = PRESENT_METHOD_WEAVE ; invert = true; }
-+ else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BOB) presentmethod = PRESENT_METHOD_BOB;
-+ else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BOB_INVERTED) { presentmethod = PRESENT_METHOD_BOB; invert = true; }
-+ else if (interlacemethod == VS_INTERLACEMETHOD_DXVA_BOB) presentmethod = PRESENT_METHOD_BOB;
-+ else if (interlacemethod == VS_INTERLACEMETHOD_DXVA_BEST) presentmethod = PRESENT_METHOD_BOB;
-+ else presentmethod = PRESENT_METHOD_SINGLE;
-
- /* default to odd field if we want to deinterlace and don't know better */
-- if (deinterlacemode == VS_DEINTERLACEMODE_FORCE && m_presentfield == FS_NONE)
-- m_presentfield = FS_TOP;
-+ if (deinterlacemode == VS_DEINTERLACEMODE_FORCE && presentfield == FS_NONE)
-+ presentfield = FS_TOP;
-
- /* invert present field */
- if(invert)
- {
-- if( m_presentfield == FS_BOT )
-- m_presentfield = FS_TOP;
-+ if( presentfield == FS_BOT )
-+ presentfield = FS_TOP;
- else
-- m_presentfield = FS_BOT;
-+ presentfield = FS_BOT;
- }
- }
- }
-
-+ FlipFreeBuffer();
-+ m_renderBuffers[m_iOutputRenderBuffer].pts = timestamp;
-+ m_renderBuffers[m_iOutputRenderBuffer].presentfield = presentfield;
-+ m_renderBuffers[m_iOutputRenderBuffer].presentmethod = presentmethod;
-+ m_speed = speed;
- }
-
- g_application.NewFrame();
-- /* wait untill render thread have flipped buffers */
-- timeout = m_presenttime + 1.0;
-- while(m_presentstep == PRESENT_FLIP && !bStop)
-+
-+ if (!m_bUseBuffering)
- {
-- if(!m_presentevent.WaitMSec(100) && GetPresentTime() > timeout && !bStop)
-+ /* wait untill render thread have flipped buffers */
-+ double timeout = m_presenttime + 1.0;
-+ while(m_presentstep == PRESENT_FLIP && !bStop)
- {
-- CLog::Log(LOGWARNING, "CRenderManager::FlipPage - timeout waiting for flip to complete");
-- return;
-+ if(!m_presentevent.WaitMSec(100) && GetPresentTime() > timeout && !bStop)
-+ {
-+ CLog::Log(LOGWARNING, "CRenderManager::FlipPage - timeout waiting for flip to complete");
-+ return;
-+ }
- }
- }
- }
-@@ -631,8 +660,12 @@
- if (!m_pRenderer)
- return;
-
-+ if (m_presentstep == PRESENT_IDLE)
-+ PrepareNextRender();
-+
- if(m_presentstep == PRESENT_FLIP)
- {
-+ FlipRenderBuffer();
- m_overlays.Flip();
- m_pRenderer->FlipPage(m_presentsource);
- m_presentstep = PRESENT_FRAME;
-@@ -647,6 +680,8 @@
- WaitPresentTime(m_presenttime);
-
- m_presentevent.Set();
-+
-+ m_rendertime = CurrentHostCounter();
- }
-
- /* simple present method */
-@@ -753,7 +788,7 @@
- return 1;
-
- YV12Image image;
-- int index = m_pRenderer->GetImage(&image);
-+ int index = m_pRenderer->GetImage(&image, (m_iOutputRenderBuffer + 1) % m_iNumRenderBuffers);
-
- if(index < 0)
- return index;
-@@ -776,8 +811,9 @@
- CDVDCodecUtils::CopyDXVA2Picture(&image, &pic);
- }
- #ifdef HAVE_LIBVDPAU
-- else if(pic.format == DVDVideoPicture::FMT_VDPAU)
-- m_pRenderer->AddProcessor(pic.vdpau);
-+ else if(pic.format == DVDVideoPicture::FMT_VDPAU
-+ || pic.format == DVDVideoPicture::FMT_VDPAU_420)
-+ m_pRenderer->AddProcessor(pic.vdpau, index);
- #endif
- #ifdef HAVE_LIBOPENMAX
- else if(pic.format == DVDVideoPicture::FMT_OMXEGL)
-@@ -789,7 +825,11 @@
- #endif
- #ifdef HAVE_LIBVA
- else if(pic.format == DVDVideoPicture::FMT_VAAPI)
-- m_pRenderer->AddProcessor(*pic.vaapi);
-+ m_pRenderer->AddProcessor(*pic.vaapi, index);
-+#endif
-+#ifdef HAVE_LIBXVBA
-+ else if(pic.format == DVDVideoPicture::FMT_XVBA)
-+ m_pRenderer->AddProcessor(pic.xvba, index);
- #endif
- m_pRenderer->ReleaseImage(index, false);
-
-@@ -809,3 +849,212 @@
-
- return mInt;
- }
-+
-+int CXBMCRenderManager::WaitForBuffer(volatile bool& bStop)
-+{
-+ CSharedLock lock(m_sharedSection);
-+ if (!m_pRenderer)
-+ return -1;
-+
-+ //wait up to a second as this is our slowest allowed output rate
-+ double timeout = GetPresentTime() + 0.1;
-+ while(!HasFreeBuffer() && !bStop)
-+ {
-+ lock.Leave();
-+ m_flipEvent.WaitMSec(50);
-+ if(GetPresentTime() > timeout && !bStop)
-+ {
-+ CLog::Log(LOGWARNING, "CRenderManager::WaitForBuffer - timeout waiting for buffer");
-+ return -1;
-+ }
-+ lock.Enter();
-+ }
-+ lock.Leave();
-+
-+ { CRetakeLock lock(m_sharedSection);
-+ m_overlays.SetBuffer((m_iOutputRenderBuffer + 1) % m_iNumRenderBuffers);
-+ }
-+
-+ if (bStop)
-+ return -1;
-+
-+ return 1;
-+}
-+
-+int CXBMCRenderManager::GetNextRenderBufferIndex()
-+{
-+ if (m_iOutputRenderBuffer == m_iCurrentRenderBuffer)
-+ return -1;
-+ return (m_iCurrentRenderBuffer + 1) % m_iNumRenderBuffers;
-+}
-+
-+void CXBMCRenderManager::FlipRenderBuffer()
-+{
-+ m_iCurrentRenderBuffer = GetNextRenderBufferIndex();
-+// CLog::Log(LOGNOTICE,"-------- flip render: %d", m_iCurrentRenderBuffer);
-+}
-+
-+int CXBMCRenderManager::FlipFreeBuffer()
-+{
-+ // See "Render Buffer State Description" in header for information.
-+ if (HasFreeBuffer())
-+ {
-+ m_bAllRenderBuffersDisplayed = false;
-+ m_iOutputRenderBuffer = (m_iOutputRenderBuffer + 1) % m_iNumRenderBuffers;
-+ return m_iOutputRenderBuffer;
-+ }
-+}
-+
-+bool CXBMCRenderManager::HasFreeBuffer()
-+{
-+ if (!m_bUseBuffering)
-+ {
-+ if (m_iOutputRenderBuffer != m_iCurrentRenderBuffer)
-+ return false;
-+ else
-+ return true;
-+ }
-+
-+ int outputPlusSwap = (m_iOutputRenderBuffer + m_swapCount) % m_iNumRenderBuffers;
-+ if ((m_iOutputRenderBuffer == m_iDisplayedRenderBuffer && !m_bAllRenderBuffersDisplayed)
-+ || outputPlusSwap == m_iCurrentRenderBuffer)
-+ return false;
-+ else
-+ return true;
-+}
-+
-+void CXBMCRenderManager::ResetRenderBuffer()
-+{
-+ m_iNumRenderBuffers = 5;
-+ m_iCurrentRenderBuffer = 0;
-+ m_iFlipRequestRenderBuffer = 0;
-+ m_iOutputRenderBuffer = 0;
-+ m_iDisplayedRenderBuffer = 0;
-+ m_bAllRenderBuffersDisplayed = true;
-+ m_sleeptime = 1.0;
-+ m_presentPts = DVD_NOPTS_VALUE;
-+// m_bUseBuffering = true;
-+ m_speed = 0;
-+}
-+
-+void CXBMCRenderManager::PrepareNextRender()
-+{
-+ int idx = GetNextRenderBufferIndex();
-+ if (idx < 0)
-+ {
-+ if (m_speed >= DVD_PLAYSPEED_NORMAL && g_graphicsContext.IsFullScreenVideo())
-+ CLog::Log(LOGNOTICE,"----------- no buffer, out: %d, current: %d, display: %d",
-+ m_iOutputRenderBuffer, m_iCurrentRenderBuffer, m_iDisplayedRenderBuffer);
-+ return;
-+ }
-+
-+ double iClockSleep, iPlayingClock, iCurrentClock;
-+ iPlayingClock = m_pClock->GetClock(iCurrentClock, false);
-+ iClockSleep = m_renderBuffers[idx].pts - iPlayingClock;
-+
-+ if (m_speed)
-+ iClockSleep = iClockSleep * DVD_PLAYSPEED_NORMAL / m_speed;
-+
-+ double presenttime = (iCurrentClock + iClockSleep) / DVD_TIME_BASE;
-+ double clocktime = iCurrentClock / DVD_TIME_BASE;
-+ if(presenttime - clocktime > MAXPRESENTDELAY)
-+ presenttime = clocktime + MAXPRESENTDELAY;
-+
-+ m_sleeptime = presenttime - clocktime;
-+
-+// double interval;
-+// if (g_VideoReferenceClock.GetRefreshRate(&interval) > 0)
-+// {
-+// if (m_swaptime > interval * 0.7)
-+// {
-+// presenttime += interval;
-+// CLog::Log(LOGDEBUG,"------------ very long swaptime");
-+// }
-+// }
-+
-+ if (g_graphicsContext.IsFullScreenVideo() || presenttime <= clocktime+0.01)
-+ {
-+ m_presentPts = m_renderBuffers[idx].pts;
-+ m_presenttime = presenttime;
-+ m_presentmethod = m_renderBuffers[idx].presentmethod;
-+ m_presentfield = m_renderBuffers[idx].presentfield;
-+ m_presentstep = PRESENT_FLIP;
-+ m_presentsource = idx;
-+ }
-+}
-+
-+void CXBMCRenderManager::EnableBuffering(bool enable)
-+{
-+ CRetakeLock lock(m_sharedSection);
-+ m_bUseBuffering = enable;
-+ if (!m_bUseBuffering)
-+ m_iOutputRenderBuffer = m_iCurrentRenderBuffer;
-+
-+ CLog::Log(LOGDEBUG, "CXBMCRenderManager::EnableBuffering - %d", m_bUseBuffering);
-+}
-+
-+void CXBMCRenderManager::DiscardBuffer()
-+{
-+ CRetakeLock lock(m_sharedSection);
-+ m_iOutputRenderBuffer = m_iCurrentRenderBuffer;
-+}
-+
-+void CXBMCRenderManager::NotifyDisplayFlip()
-+{
-+ CRetakeLock lock(m_sharedSection);
-+ if (!m_pRenderer)
-+ return;
-+
-+// if (g_graphicsContext.IsFullScreenVideo())
-+// {
-+// uint64_t diff = CurrentHostCounter() - m_rendertime;
-+// m_swaptime = ((double)(diff))/CurrentHostFrequency();
-+// int waittime = (int)((diff*1000LL)/CurrentHostFrequency());
-+// if (waittime > 15)
-+// {
-+// CLog::Log(LOGNOTICE,"------------------ wait swap buffers: %f, sleep: %f", m_swaptime, m_sleeptime);
-+// }
-+// }
-+
-+ int last = m_iDisplayedRenderBuffer;
-+ m_iDisplayedRenderBuffer = (m_iCurrentRenderBuffer + m_iNumRenderBuffers - m_swapCount) % m_iNumRenderBuffers;
-+ m_iFlipRequestRenderBuffer = m_iCurrentRenderBuffer;
-+
-+// // we have caught up with output so all buffers are re-usable
-+// if (last != m_iDisplayedRenderBuffer
-+// && m_iDisplayedRenderBuffer == m_iOutputRenderBuffer)
-+// {
-+// CLog::Log(LOGNOTICE,"-------------- all displayed");
-+// m_bAllRenderBuffersDisplayed = true;
-+// }
-+
-+ if (last != m_iDisplayedRenderBuffer
-+ && m_iDisplayedRenderBuffer != m_iCurrentRenderBuffer)
-+ {
-+ m_pRenderer->ReleaseBuffer(m_iDisplayedRenderBuffer);
-+ m_overlays.ReleaseBuffer(m_iDisplayedRenderBuffer);
-+ }
-+
-+ lock.Leave();
-+ m_flipEvent.Set();
-+}
-+
-+bool CXBMCRenderManager::GetStats(double &sleeptime, double &pts, int &bufferLevel)
-+{
-+ CSharedLock lock(m_sharedSection);
-+ sleeptime = m_sleeptime;
-+ pts = m_presentPts;
-+ bufferLevel = (m_iOutputRenderBuffer - m_iCurrentRenderBuffer + m_iNumRenderBuffers) % m_iNumRenderBuffers;
-+ return true;
-+}
-+
-+bool CXBMCRenderManager::HasFrame()
-+{
-+ CSharedLock lock(m_sharedSection);
-+ if (m_presentstep == PRESENT_IDLE &&
-+ GetNextRenderBufferIndex() < 0 &&
-+ m_speed > 0)
-+ return false;
-+ else
-+ return true;
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/RenderManager.h xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/RenderManager.h
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/RenderManager.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/RenderManager.h 2012-05-14 14:15:12.161221010 +0200
-@@ -39,10 +39,11 @@
- #include "OverlayRenderer.h"
-
- class CRenderCapture;
-+class CDVDClock;
-
- namespace DXVA { class CProcessor; }
- namespace VAAPI { class CSurfaceHolder; }
--class CVDPAU;
-+namespace VDPAU { struct CVdpauRenderPicture; }
- struct DVDVideoPicture;
-
- #define ERRORBUFFSIZE 30
-@@ -73,8 +74,8 @@
-
- int AddVideoPicture(DVDVideoPicture& picture);
-
-- void FlipPage(volatile bool& bStop, double timestamp = 0.0, int source = -1, EFIELDSYNC sync = FS_NONE);
-- unsigned int PreInit();
-+ void FlipPage(volatile bool& bStop, double timestamp = 0.0, int source = -1, EFIELDSYNC sync = FS_NONE, int speed = 0);
-+ unsigned int PreInit(CDVDClock *pClock);
- void UnInit();
- bool Flush();
-
-@@ -182,6 +183,13 @@
-
- CSharedSection& GetSection() { return m_sharedSection; };
-
-+ int WaitForBuffer(volatile bool& bStop);
-+ void NotifyDisplayFlip();
-+ bool GetStats(double &sleeptime, double &pts, int &bufferLevel);
-+ bool HasFrame();
-+ void EnableBuffering(bool enable);
-+ void DiscardBuffer();
-+
- protected:
- void Render(bool clear, DWORD flags, DWORD alpha);
-
-@@ -190,6 +198,13 @@
- void PresentBob(bool clear, DWORD flags, DWORD alpha);
- void PresentBlend(bool clear, DWORD flags, DWORD alpha);
-
-+ int GetNextRenderBufferIndex();
-+ void FlipRenderBuffer();
-+ int FlipFreeBuffer();
-+ bool HasFreeBuffer();
-+ void ResetRenderBuffer();
-+ void PrepareNextRender();
-+
- EINTERLACEMETHOD AutoInterlaceMethodInternal(EINTERLACEMETHOD mInt);
-
- bool m_bPauseDrawing; // true if we should pause rendering
-@@ -220,6 +235,43 @@
- double m_displayLatency;
- void UpdateDisplayLatency();
-
-+ // Render Buffer State Description:
-+ //
-+ // Output: is the buffer about to or having its texture prepared for render (ie from output thread).
-+ // Cannot go past the "Displayed" buffer (otherwise we will probably overwrite buffers not yet
-+ // displayed or even rendered).
-+ // Current: is the current buffer being or having been submitted for render to back buffer.
-+ // Cannot go past "Output" buffer (else it would be rendering old output).
-+ // FlipRequest: is the render buffer that has last been submitted for render AND importantly has had
-+ // swap-buffer flip subsequently invoked (thus flip to front buffer is requested for vblank
-+ // subsequent to render completion).
-+ // Displayed: is the buffer that is now considered to be safely copied from back buffer to front buffer
-+ // (we assume that after two swap-buffer flips for the same "Current" render buffer that that
-+ // buffer will be safe, but otherwise we consider that only the previous-to-"Current" is guaranteed).
-+ // Last: is the last buffer successfully submitted for render to back buffer (purpose: to rollback to in
-+ // unexpected case where a texture render fails).
-+
-+ int m_iCurrentRenderBuffer;
-+ int m_iNumRenderBuffers;
-+// int m_iLastRenderBuffer;
-+ int m_iFlipRequestRenderBuffer;
-+ int m_iOutputRenderBuffer;
-+ int m_iDisplayedRenderBuffer;
-+ bool m_bAllRenderBuffersDisplayed;
-+ bool m_bUseBuffering;
-+ int m_speed;
-+ CEvent m_flipEvent;
-+
-+ struct
-+ {
-+ double pts;
-+ EFIELDSYNC presentfield;
-+ EPRESENTMETHOD presentmethod;
-+ }m_renderBuffers[5];
-+
-+ double m_sleeptime;
-+ double m_presentPts;
-+
- double m_presenttime;
- double m_presentcorr;
- double m_presenterr;
-@@ -231,7 +283,10 @@
- int m_presentsource;
- CEvent m_presentevent;
- CEvent m_flushEvent;
--
-+ CDVDClock *m_pClock;
-+ uint64_t m_rendertime;
-+ double m_swaptime;
-+ unsigned int m_swapCount;
-
- OVERLAY::CRenderer m_overlays;
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp 2012-05-14 14:15:12.162221031 +0200
-@@ -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";
-+ else if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_VDPAU_420)
-+ m_defines += "#define XBMC_VDPAU_NV12\n";
-
- VertexShader()->LoadSource("yuv2rgb_vertex.glsl", m_defines);
- #elif HAS_GLES == 2
-diff -Naur xbmc-pvr-11.0.1/xbmc/dialogs/GUIDialogCache.cpp xbmc-pvr-11.0.1.patch/xbmc/dialogs/GUIDialogCache.cpp
---- xbmc-pvr-11.0.1/xbmc/dialogs/GUIDialogCache.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/dialogs/GUIDialogCache.cpp 2012-05-14 14:15:12.163221052 +0200
-@@ -29,7 +29,7 @@
- #include "threads/SingleLock.h"
- #include "utils/TimeUtils.h"
-
--CGUIDialogCache::CGUIDialogCache(DWORD dwDelay, const CStdString& strHeader, const CStdString& strMsg)
-+CGUIDialogCache::CGUIDialogCache(DWORD dwDelay, const CStdString& strHeader, const CStdString& strMsg) : CThread("CGUIDialogCache")
- {
- m_pDlg = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/FileCache.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/FileCache.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/FileCache.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/FileCache.cpp 2012-05-14 14:15:12.163221052 +0200
-@@ -79,7 +79,7 @@
- };
-
-
--CFileCache::CFileCache()
-+CFileCache::CFileCache() : CThread("CFileCache")
- {
- m_bDeleteCache = true;
- m_nSeekResult = 0;
-@@ -95,7 +95,7 @@
- m_cacheFull = false;
- }
-
--CFileCache::CFileCache(CCacheStrategy *pCache, bool bDeleteCache)
-+CFileCache::CFileCache(CCacheStrategy *pCache, bool bDeleteCache) : CThread("CFileCache")
- {
- m_pCache = pCache;
- m_bDeleteCache = bDeleteCache;
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/FilePipe.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/FilePipe.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/FilePipe.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/FilePipe.cpp 2012-05-14 14:15:12.164221072 +0200
-@@ -24,6 +24,8 @@
- #include "PipesManager.h"
- #include "utils/StringUtils.h"
-
-+#define INFINITE 0xFFFFFFFF
-+
- using namespace XFILE;
-
- CFilePipe::CFilePipe() : m_pos(0), m_length(-1), m_pipe(NULL)
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/FileRar.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/FileRar.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/FileRar.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/FileRar.cpp 2012-05-14 14:15:12.165221092 +0200
-@@ -43,7 +43,7 @@
- #define SEEKTIMOUT 30000
-
- #ifdef HAS_FILESYSTEM_RAR
--CFileRarExtractThread::CFileRarExtractThread() : hRunning(true), hQuit(true)
-+CFileRarExtractThread::CFileRarExtractThread() : CThread("CFileRarExtractThread"), hRunning(true), hQuit(true)
- {
- m_pArc = NULL;
- m_pCmd = NULL;
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/HTSPDirectory.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/HTSPDirectory.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/HTSPDirectory.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/HTSPDirectory.cpp 2012-05-14 14:15:12.166221112 +0200
-@@ -76,7 +76,7 @@
- static CCriticalSection g_section;
-
-
--CHTSPDirectorySession::CHTSPDirectorySession()
-+CHTSPDirectorySession::CHTSPDirectorySession() : CThread("CHTSPDirectorySession")
- {
- }
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/LastFMDirectory.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/LastFMDirectory.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/LastFMDirectory.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/LastFMDirectory.cpp 2012-05-14 14:15:12.167221132 +0200
-@@ -69,7 +69,7 @@
- m_dlgProgress->Progress();
- }
-
-- CThread thread(this);
-+ CThread thread(this, "CLastFMDirectory");
- m_strSource = url;
- m_strDestination = "special://temp/lastfm.xml";
- thread.Create();
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/MythSession.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/MythSession.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/MythSession.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/MythSession.cpp 2012-05-14 14:15:12.168221152 +0200
-@@ -359,7 +359,7 @@
- return;
- }
-
--CMythSession::CMythSession(const CURL& url)
-+CMythSession::CMythSession(const CURL& url) : CThread("CMythSession")
- {
- m_control = NULL;
- m_event = NULL;
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/PipesManager.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/PipesManager.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/PipesManager.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/PipesManager.cpp 2012-05-14 14:15:12.169221172 +0200
-@@ -23,6 +23,8 @@
- #include "threads/SingleLock.h"
- #include "Application.h"
-
-+#define INFINITE 0xFFFFFFFF
-+
- #ifndef min
- #define min(a,b) ((a) < (b) ? (a) : (b))
- #endif
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/RarManager.h xbmc-pvr-11.0.1.patch/xbmc/filesystem/RarManager.h
---- xbmc-pvr-11.0.1/xbmc/filesystem/RarManager.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/RarManager.h 2012-05-14 14:15:12.169221172 +0200
-@@ -71,7 +71,7 @@
- CRarManager();
- ~CRarManager();
- bool CacheRarredFile(CStdString& strPathInCache, const CStdString& strRarPath,
-- const CStdString& strPathInRar, BYTE bOptions = EXFILE_AUTODELETE,
-+ const CStdString& strPathInRar, uint8_t bOptions = EXFILE_AUTODELETE,
- const CStdString& strDir =RAR_DEFAULT_CACHE, const int64_t iSize=-1);
- bool GetPathInCache(CStdString& strPathInCache, const CStdString& strRarPath,
- const CStdString& strPathInRar = "");
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/SAPDirectory.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/SAPDirectory.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/SAPDirectory.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/SAPDirectory.cpp 2012-05-14 14:15:12.170221192 +0200
-@@ -272,7 +272,7 @@
- using namespace SDP;
-
-
--CSAPSessions::CSAPSessions()
-+CSAPSessions::CSAPSessions() : CThread("CSAPSessions")
- {
- m_socket = INVALID_SOCKET;
- }
-@@ -486,7 +486,7 @@
-
- CSingleLock lock(g_sapsessions.m_section);
-
-- if(g_sapsessions.ThreadHandle() == NULL)
-+ if(!g_sapsessions.IsRunning())
- g_sapsessions.Create();
-
- // check if we can find this session in our cache
-diff -Naur xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp
---- xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp 2012-05-14 14:15:12.171221212 +0200
-@@ -181,9 +181,9 @@
- m_threadState = state;
- }
-
--void CGUIPythonWindow::WaitForActionEvent(unsigned int timeout)
-+void CGUIPythonWindow::WaitForActionEvent()
- {
-- g_pythonParser.WaitForEvent(m_actionEvent, timeout);
-+ g_pythonParser.WaitForEvent(m_actionEvent);
- m_actionEvent.Reset();
- }
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h
---- xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h 2012-05-14 14:15:12.171221212 +0200
-@@ -51,7 +51,7 @@
- virtual bool OnAction(const CAction &action);
- virtual bool OnBack(int actionID);
- void SetCallbackWindow(void* state, void *object);
-- void WaitForActionEvent(unsigned int timeout);
-+ void WaitForActionEvent();
- void PulseActionEvent();
- void SetDestroyAfterDeinit(bool destroy = true);
- protected:
-diff -Naur xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp
---- xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp 2012-05-14 14:15:12.172221232 +0200
-@@ -279,9 +279,9 @@
- UpdateButtons();
- }
-
--void CGUIPythonWindowXML::WaitForActionEvent(unsigned int timeout)
-+void CGUIPythonWindowXML::WaitForActionEvent()
- {
-- g_pythonParser.WaitForEvent(m_actionEvent, timeout);
-+ g_pythonParser.WaitForEvent(m_actionEvent);
- m_actionEvent.Reset();
- }
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h
---- xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h 2012-05-14 14:15:12.173221252 +0200
-@@ -40,7 +40,7 @@
- virtual void AllocResources(bool forceLoad = false);
- virtual void FreeResources(bool forceUnLoad = false);
- void Process(unsigned int currentTime, CDirtyRegionList ®ions);
-- void WaitForActionEvent(unsigned int timeout);
-+ void WaitForActionEvent();
- void PulseActionEvent();
- void AddItem(CFileItemPtr fileItem,int itemPosition);
- void RemoveItem(int itemPosition);
-diff -Naur xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/window.cpp xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/window.cpp
---- xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/window.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/window.cpp 2012-05-14 14:15:12.174221272 +0200
-@@ -540,11 +540,11 @@
-
- CPyThreadState pyState;
- if (WindowXML_Check(self))
-- ((CGUIPythonWindowXML*)self->pWindow)->WaitForActionEvent(INFINITE);
-+ ((CGUIPythonWindowXML*)self->pWindow)->WaitForActionEvent();
- else if (WindowXMLDialog_Check(self))
-- ((CGUIPythonWindowXMLDialog*)self->pWindow)->WaitForActionEvent(INFINITE);
-+ ((CGUIPythonWindowXMLDialog*)self->pWindow)->WaitForActionEvent();
- else
-- ((CGUIPythonWindow*)self->pWindow)->WaitForActionEvent(INFINITE);
-+ ((CGUIPythonWindow*)self->pWindow)->WaitForActionEvent();
- }
- }
- Py_INCREF(Py_None);
-diff -Naur xbmc-pvr-11.0.1/xbmc/interfaces/python/XBPython.cpp xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/XBPython.cpp
---- xbmc-pvr-11.0.1/xbmc/interfaces/python/XBPython.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/XBPython.cpp 2012-05-14 14:15:12.175221293 +0200
-@@ -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-pvr-11.0.1/xbmc/interfaces/python/XBPython.h xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/XBPython.h
---- xbmc-pvr-11.0.1/xbmc/interfaces/python/XBPython.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/XBPython.h 2012-05-14 14:15:12.176221314 +0200
-@@ -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-pvr-11.0.1/xbmc/linux/Makefile.in xbmc-pvr-11.0.1.patch/xbmc/linux/Makefile.in
---- xbmc-pvr-11.0.1/xbmc/linux/Makefile.in 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/Makefile.in 2012-05-14 14:15:12.176221314 +0200
-@@ -10,14 +10,11 @@
- LinuxResourceCounter.cpp \
- LinuxTimezone.cpp \
- PosixMountProvider.cpp \
-- XEventUtils.cpp \
- XFileUtils.cpp \
- XHandle.cpp \
- XLCDproc.cpp \
- XMemUtils.cpp \
-- XSyncUtils.cpp \
- XTimeUtils.cpp \
-- XThreadUtils.cpp \
-
- LIB=linux.a
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/PlatformDefs.h xbmc-pvr-11.0.1.patch/xbmc/linux/PlatformDefs.h
---- xbmc-pvr-11.0.1/xbmc/linux/PlatformDefs.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/PlatformDefs.h 2012-05-14 14:15:12.177221334 +0200
-@@ -182,8 +182,6 @@
- #define EXCEPTION_EXECUTE_HANDLER ...
- //NOTE: dont try to define __except because it breaks g++ (already uses it).
-
--typedef pthread_t ThreadIdentifier;
--
- struct CXHandle; // forward declaration
- typedef CXHandle* HANDLE;
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/PlatformInclude.h xbmc-pvr-11.0.1.patch/xbmc/linux/PlatformInclude.h
---- xbmc-pvr-11.0.1/xbmc/linux/PlatformInclude.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/PlatformInclude.h 2012-05-14 14:15:12.178221354 +0200
-@@ -25,10 +25,7 @@
- #include "PlatformDefs.h"
- #include "XHandlePublic.h"
- #include "XFileUtils.h"
--#include "XSyncUtils.h"
--#include "XEventUtils.h"
- #include "XTimeUtils.h"
--#include "XThreadUtils.h"
- #include "XMemUtils.h"
- #include "ConvUtils.h"
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XEventUtils.cpp xbmc-pvr-11.0.1.patch/xbmc/linux/XEventUtils.cpp
---- xbmc-pvr-11.0.1/xbmc/linux/XEventUtils.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XEventUtils.cpp 1970-01-01 01:00:00.000000000 +0100
-@@ -1,144 +0,0 @@
--/*
-- * Copyright (C) 2005-2008 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 "system.h"
--#include "PlatformDefs.h"
--#include "XEventUtils.h"
--#include "XHandle.h"
--#include "utils/log.h"
--#include "threads/SingleLock.h"
--
--using namespace std;
--
--HANDLE WINAPI CreateEvent(void *pDummySec, bool bManualReset, bool bInitialState, char *szDummyName)
--{
-- CXHandle *pHandle = new CXHandle(CXHandle::HND_EVENT);
-- pHandle->m_bManualEvent = bManualReset;
-- pHandle->m_hCond = new XbmcThreads::ConditionVariable();
-- pHandle->m_hMutex = new CCriticalSection();
-- pHandle->m_bEventSet = false;
--
-- if (bInitialState)
-- SetEvent(pHandle);
--
-- return pHandle;
--}
--
--//
--// The state of a manual-reset event object remains signaled until it is set explicitly to the nonsignaled
--// state by the ResetEvent function. Any number of waiting threads, or threads that subsequently begin wait
--// operations for the specified event object by calling one of the wait functions, can be released while the
--// object's state is signaled.
--//
--// The state of an auto-reset event object remains signaled until a single waiting thread is released, at
--// which time the system automatically sets the state to nonsignaled. If no threads are waiting, the event
--// object's state remains signaled.
--//
--bool WINAPI SetEvent(HANDLE hEvent)
--{
-- if (hEvent == NULL || hEvent->m_hCond == NULL || hEvent->m_hMutex == NULL)
-- return false;
--
-- CSingleLock lock(*(hEvent->m_hMutex));
-- hEvent->m_bEventSet = true;
--
-- // we must guarantee that these handle's won't be deleted, until we are done
-- list events = hEvent->m_hParents;
-- for(list::iterator it = events.begin();it != events.end();it++)
-- DuplicateHandle(GetCurrentProcess(), *it, GetCurrentProcess(), NULL, 0, FALSE, DUPLICATE_SAME_ACCESS);
--
-- lock.Leave();
--
-- for(list::iterator it = events.begin();it != events.end();it++)
-- {
-- SetEvent(*it);
-- CloseHandle(*it);
-- }
--
-- DuplicateHandle(GetCurrentProcess(), hEvent, GetCurrentProcess(), NULL, 0, FALSE, DUPLICATE_SAME_ACCESS);
--
-- if (hEvent->m_bManualEvent == true)
-- hEvent->m_hCond->notifyAll();
-- else
-- hEvent->m_hCond->notify();
--
-- CloseHandle(hEvent);
--
-- return true;
--}
--
--bool WINAPI ResetEvent(HANDLE hEvent)
--{
-- if (hEvent == NULL || hEvent->m_hCond == NULL || hEvent->m_hMutex == NULL)
-- return false;
--
-- CSingleLock lock(*(hEvent->m_hMutex));
-- hEvent->m_bEventSet = false;
--
-- return true;
--}
--
--bool WINAPI PulseEvent(HANDLE hEvent)
--{
-- if (hEvent == NULL || hEvent->m_hCond == NULL || hEvent->m_hMutex == NULL)
-- return false;
--
-- CSingleLock lock(*(hEvent->m_hMutex));
-- // we must guarantee that these handle's won't be deleted, until we are done
-- list events = hEvent->m_hParents;
-- for(list::iterator it = events.begin();it != events.end();it++)
-- DuplicateHandle(GetCurrentProcess(), *it, GetCurrentProcess(), NULL, 0, FALSE, DUPLICATE_SAME_ACCESS);
--
-- if(events.size())
-- {
-- CLog::Log(LOGWARNING,"PulseEvent - ineffecient multiwait detected");
-- hEvent->m_bEventSet = true;
-- }
--
-- lock.Leave();
--
-- for(list::iterator it = events.begin();it != events.end();it++)
-- {
-- SetEvent(*it);
-- CloseHandle(*it);
--
-- if (hEvent->m_bManualEvent == false)
-- break;
-- }
--
-- // for multiwaits, we must yield some time to get the multiwaits to notice it was signaled
-- if(events.size())
-- Sleep(10);
--
-- // we should always unset the event on pulse
-- {
-- CSingleLock lock2(*(hEvent->m_hMutex));
-- hEvent->m_bEventSet = false;
-- }
--
-- if (hEvent->m_bManualEvent == true)
-- hEvent->m_hCond->notifyAll();
-- else
-- hEvent->m_hCond->notify();
--
-- return true;
--}
--
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XEventUtils.h xbmc-pvr-11.0.1.patch/xbmc/linux/XEventUtils.h
---- xbmc-pvr-11.0.1/xbmc/linux/XEventUtils.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.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__
--
--/*
-- * Copyright (C) 2005-2008 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 "XHandlePublic.h"
--
--#ifdef _LINUX
--
--HANDLE WINAPI CreateEvent(void *pDummySec, bool bManualReset, bool bInitialState, char *szDummyName);
--bool WINAPI SetEvent(HANDLE hEvent);
--bool WINAPI ResetEvent(HANDLE hEvent);
--bool WINAPI PulseEvent(HANDLE hEvent);
--
--#endif
--
--
--#endif
--
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XHandle.cpp xbmc-pvr-11.0.1.patch/xbmc/linux/XHandle.cpp
---- xbmc-pvr-11.0.1/xbmc/linux/XHandle.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XHandle.cpp 2012-05-14 14:15:12.185221494 +0200
-@@ -20,12 +20,15 @@
- */
-
- #include "XHandle.h"
--#include "XThreadUtils.h"
- #include "utils/log.h"
- #include "threads/SingleLock.h"
-
- int CXHandle::m_objectTracker[10] = {0};
-
-+HANDLE WINAPI GetCurrentProcess(void) {
-+ return (HANDLE)-1; // -1 a special value - pseudo handle
-+}
-+
- CXHandle::CXHandle()
- {
- Init();
-@@ -47,11 +50,6 @@
-
- Init();
-
-- if (m_threadValid)
-- {
-- CLog::Log(LOGERROR, "%s - thread handle copied instead of passed!", __FUNCTION__);
-- }
--
- if (src.m_hMutex)
- m_hMutex = new CCriticalSection();
-
-@@ -80,7 +78,7 @@
- CLog::Log(LOGERROR,"%s, destroying handle with ref count %d", __FUNCTION__, m_nRefCount);
- assert(false);
- }
--
-+
- if (m_hMutex) {
- delete m_hMutex;
- }
-@@ -93,10 +91,6 @@
- delete m_hCond;
- }
-
-- if (m_threadValid) {
-- pthread_join(m_hThread, NULL);
-- }
--
- if ( fd != 0 ) {
- close(fd);
- }
-@@ -107,11 +101,9 @@
- {
- fd=0;
- m_hMutex=NULL;
-- m_threadValid=false;
- m_hCond=NULL;
- m_type = HND_NULL;
- RecursionCount=0;
-- OwningThread=0;
- m_bManualEvent=FALSE;
- m_bEventSet=FALSE;
- m_nFindFileIterator=0 ;
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XHandle.h xbmc-pvr-11.0.1.patch/xbmc/linux/XHandle.h
---- xbmc-pvr-11.0.1/xbmc/linux/XHandle.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XHandle.h 2012-05-14 14:15:12.186221514 +0200
-@@ -25,7 +25,6 @@
- #ifndef _WIN32
-
- #include
--#include
-
- #include "PlatformDefs.h"
- #include "XHandlePublic.h"
-@@ -36,7 +35,7 @@
- struct CXHandle {
-
- public:
-- typedef enum { HND_NULL = 0, HND_FILE, HND_EVENT, HND_MUTEX, HND_THREAD, HND_FIND_FILE } HandleType;
-+ typedef enum { HND_NULL = 0, HND_FILE, HND_EVENT, HND_MUTEX, HND_FIND_FILE } HandleType;
-
- CXHandle();
- CXHandle(HandleType nType);
-@@ -47,8 +46,6 @@
- inline HandleType GetType() { return m_type; }
- void ChangeType(HandleType newType);
-
-- ThreadIdentifier m_hThread;
-- bool m_threadValid;
- XbmcThreads::ConditionVariable *m_hCond;
- std::list m_hParents;
-
-@@ -62,7 +59,6 @@
- // simulate mutex and critical section
- CCriticalSection *m_hMutex;
- int RecursionCount; // for mutex - for compatibility with WIN32 critical section
-- pthread_t OwningThread;
- int fd;
- bool m_bManualEvent;
- time_t m_tmCreation;
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XMemUtils.cpp xbmc-pvr-11.0.1.patch/xbmc/linux/XMemUtils.cpp
---- xbmc-pvr-11.0.1/xbmc/linux/XMemUtils.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XMemUtils.cpp 2012-05-14 14:15:12.187221534 +0200
-@@ -25,6 +25,10 @@
-
- #include "XMemUtils.h"
-
-+#ifdef __APPLE__
-+#include
-+#endif
-+
- #undef ALIGN
- #define ALIGN(value, alignment) (((value)+(alignment-1))&~(alignment-1))
-
-@@ -49,4 +53,130 @@
- free(pFull);
- }
-
-+#ifndef _WIN32
-+
-+#if defined(_LINUX) && !defined(__APPLE__) && !defined(__FreeBSD__)
-+static FILE* procMeminfoFP = NULL;
-+#endif
-+
-+void GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
-+{
-+ if (!lpBuffer)
-+ return;
-+
-+ memset(lpBuffer, 0, sizeof(MEMORYSTATUSEX));
-+
-+#ifdef __APPLE__
-+ uint64_t physmem;
-+ size_t len = sizeof physmem;
-+ int mib[2] = { CTL_HW, HW_MEMSIZE };
-+ size_t miblen = sizeof(mib) / sizeof(mib[0]);
-+
-+ // Total physical memory.
-+ if (sysctl(mib, miblen, &physmem, &len, NULL, 0) == 0 && len == sizeof (physmem))
-+ lpBuffer->ullTotalPhys = physmem;
-+
-+ // Virtual memory.
-+ mib[0] = CTL_VM; mib[1] = VM_SWAPUSAGE;
-+ struct xsw_usage swap;
-+ len = sizeof(struct xsw_usage);
-+ if (sysctl(mib, miblen, &swap, &len, NULL, 0) == 0)
-+ {
-+ lpBuffer->ullAvailPageFile = swap.xsu_avail;
-+ lpBuffer->ullTotalVirtual = lpBuffer->ullTotalPhys + swap.xsu_total;
-+ }
-+
-+ // In use.
-+ mach_port_t stat_port = mach_host_self();
-+ vm_statistics_data_t vm_stat;
-+ mach_msg_type_number_t count = sizeof(vm_stat) / sizeof(natural_t);
-+ if (host_statistics(stat_port, HOST_VM_INFO, (host_info_t)&vm_stat, &count) == 0)
-+ {
-+ // Find page size.
-+ int pageSize;
-+ mib[0] = CTL_HW; mib[1] = HW_PAGESIZE;
-+ len = sizeof(int);
-+ if (sysctl(mib, miblen, &pageSize, &len, NULL, 0) == 0)
-+ {
-+ uint64_t used = (vm_stat.active_count + vm_stat.inactive_count + vm_stat.wire_count) * pageSize;
-+
-+ lpBuffer->ullAvailPhys = lpBuffer->ullTotalPhys - used;
-+ lpBuffer->ullAvailVirtual = lpBuffer->ullAvailPhys; // FIXME.
-+ }
-+ }
-+#elif defined(__FreeBSD__)
-+ /* sysctl hw.physmem */
-+ size_t physmem = 0, mem_free = 0, pagesize = 0, swap_free = 0;
-+ size_t mem_avail = 0, mem_inactive = 0, mem_cache = 0, len = 0;
-+
-+ /* physmem */
-+ len = sizeof(physmem);
-+ if (sysctlbyname("hw.physmem", &physmem, &len, NULL, 0) == 0) {
-+ lpBuffer->ullTotalPhys = physmem;
-+ lpBuffer->ullTotalVirtual = physmem;
-+ }
-+ /* pagesize */
-+ len = sizeof(pagesize);
-+ if (sysctlbyname("hw.pagesize", &pagesize, &len, NULL, 0) != 0)
-+ pagesize = 4096;
-+ /* mem_inactive */
-+ len = sizeof(mem_inactive);
-+ if (sysctlbyname("vm.stats.vm.v_inactive_count", &mem_inactive, &len, NULL, 0) == 0)
-+ mem_inactive *= pagesize;
-+ /* mem_cache */
-+ len = sizeof(mem_cache);
-+ if (sysctlbyname("vm.stats.vm.v_cache_count", &mem_cache, &len, NULL, 0) == 0)
-+ mem_cache *= pagesize;
-+ /* mem_free */
-+ len = sizeof(mem_free);
-+ if (sysctlbyname("vm.stats.vm.v_free_count", &mem_free, &len, NULL, 0) == 0)
-+ mem_free *= pagesize;
-+
-+ /* mem_avail = mem_inactive + mem_cache + mem_free */
-+ lpBuffer->ullAvailPhys = mem_inactive + mem_cache + mem_free;
-+ lpBuffer->ullAvailVirtual = mem_inactive + mem_cache + mem_free;
-+
-+ if (sysctlbyname("vm.stats.vm.v_swappgsout", &swap_free, &len, NULL, 0) == 0)
-+ lpBuffer->ullAvailPageFile = swap_free * pagesize;
-+#else
-+ struct sysinfo info;
-+ char name[32];
-+ unsigned val;
-+ if (!procMeminfoFP && (procMeminfoFP = fopen("/proc/meminfo", "r")) == NULL)
-+ sysinfo(&info);
-+ else
-+ {
-+ memset(&info, 0, sizeof(struct sysinfo));
-+ info.mem_unit = 4096;
-+ while (fscanf(procMeminfoFP, "%31s %u%*[^\n]\n", name, &val) != EOF)
-+ {
-+ if (strncmp("MemTotal:", name, 9) == 0)
-+ info.totalram = val/4;
-+ else if (strncmp("MemFree:", name, 8) == 0)
-+ info.freeram = val/4;
-+ else if (strncmp("Buffers:", name, 8) == 0)
-+ info.bufferram += val/4;
-+ else if (strncmp("Cached:", name, 7) == 0)
-+ info.bufferram += val/4;
-+ else if (strncmp("SwapTotal:", name, 10) == 0)
-+ info.totalswap = val/4;
-+ else if (strncmp("SwapFree:", name, 9) == 0)
-+ info.freeswap = val/4;
-+ else if (strncmp("HighTotal:", name, 10) == 0)
-+ info.totalhigh = val/4;
-+ else if (strncmp("HighFree:", name, 9) == 0)
-+ info.freehigh = val/4;
-+ }
-+ rewind(procMeminfoFP);
-+ fflush(procMeminfoFP);
-+ }
-+ lpBuffer->ullAvailPageFile = (info.freeswap * info.mem_unit);
-+ lpBuffer->ullAvailPhys = ((info.freeram + info.bufferram) * info.mem_unit);
-+ lpBuffer->ullAvailVirtual = ((info.freeram + info.bufferram) * info.mem_unit);
-+ lpBuffer->ullTotalPhys = (info.totalram * info.mem_unit);
-+ lpBuffer->ullTotalVirtual = (info.totalram * info.mem_unit);
-+#endif
-+}
-+
-+#endif
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XMemUtils.h xbmc-pvr-11.0.1.patch/xbmc/linux/XMemUtils.h
---- xbmc-pvr-11.0.1/xbmc/linux/XMemUtils.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XMemUtils.h 2012-05-14 14:15:12.187221534 +0200
-@@ -22,10 +22,14 @@
- *
- */
-
-+#include "linux/PlatformDefs.h"
-+
- // aligned memory allocation and free. memory returned will be aligned to "alignTo" bytes.
- // this is a linux (actually platfom free) implementation of the win32 CRT methods _aligned_malloc and _aligned_free.
- void *_aligned_malloc(size_t s, size_t alignTo);
- void _aligned_free(void *p) ;
-
-+void GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer);
-+
- #endif
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XSyncUtils.cpp xbmc-pvr-11.0.1.patch/xbmc/linux/XSyncUtils.cpp
---- xbmc-pvr-11.0.1/xbmc/linux/XSyncUtils.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XSyncUtils.cpp 1970-01-01 01:00:00.000000000 +0100
-@@ -1,169 +0,0 @@
--/*
-- * Copyright (C) 2005-2008 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
-- *
-- */
--
--#ifndef _WIN32
--
--
--#include
--#include
--#include
--#include
--#include
--#ifdef __APPLE__
--#include
--#endif
--
--#include "XSyncUtils.h"
--#include "XTimeUtils.h"
--#include "PlatformDefs.h"
--#include "XHandle.h"
--#include "XEventUtils.h"
--
--using namespace std;
--using namespace XbmcThreads;
--
--#include "../utils/log.h"
--#include "../utils/TimeUtils.h"
--
--#if defined(_LINUX) && !defined(__APPLE__) && !defined(__FreeBSD__)
--static FILE* procMeminfoFP = NULL;
--#endif
--
--void GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
--{
-- if (!lpBuffer)
-- return;
--
-- memset(lpBuffer, 0, sizeof(MEMORYSTATUSEX));
--
--#ifdef __APPLE__
-- uint64_t physmem;
-- size_t len = sizeof physmem;
-- int mib[2] = { CTL_HW, HW_MEMSIZE };
-- size_t miblen = sizeof(mib) / sizeof(mib[0]);
--
-- // Total physical memory.
-- if (sysctl(mib, miblen, &physmem, &len, NULL, 0) == 0 && len == sizeof (physmem))
-- lpBuffer->ullTotalPhys = physmem;
--
-- // Virtual memory.
-- mib[0] = CTL_VM; mib[1] = VM_SWAPUSAGE;
-- struct xsw_usage swap;
-- len = sizeof(struct xsw_usage);
-- if (sysctl(mib, miblen, &swap, &len, NULL, 0) == 0)
-- {
-- lpBuffer->ullAvailPageFile = swap.xsu_avail;
-- lpBuffer->ullTotalVirtual = lpBuffer->ullTotalPhys + swap.xsu_total;
-- }
--
-- // In use.
-- mach_port_t stat_port = mach_host_self();
-- vm_statistics_data_t vm_stat;
-- mach_msg_type_number_t count = sizeof(vm_stat) / sizeof(natural_t);
-- if (host_statistics(stat_port, HOST_VM_INFO, (host_info_t)&vm_stat, &count) == 0)
-- {
-- // Find page size.
-- int pageSize;
-- mib[0] = CTL_HW; mib[1] = HW_PAGESIZE;
-- len = sizeof(int);
-- if (sysctl(mib, miblen, &pageSize, &len, NULL, 0) == 0)
-- {
-- uint64_t used = (vm_stat.active_count + vm_stat.inactive_count + vm_stat.wire_count) * pageSize;
--
-- lpBuffer->ullAvailPhys = lpBuffer->ullTotalPhys - used;
-- lpBuffer->ullAvailVirtual = lpBuffer->ullAvailPhys; // FIXME.
-- }
-- }
--#elif defined(__FreeBSD__)
-- /* sysctl hw.physmem */
-- size_t physmem = 0, mem_free = 0, pagesize = 0, swap_free = 0;
-- size_t mem_avail = 0, mem_inactive = 0, mem_cache = 0, len = 0;
--
-- /* physmem */
-- len = sizeof(physmem);
-- if (sysctlbyname("hw.physmem", &physmem, &len, NULL, 0) == 0) {
-- lpBuffer->ullTotalPhys = physmem;
-- lpBuffer->ullTotalVirtual = physmem;
-- }
-- /* pagesize */
-- len = sizeof(pagesize);
-- if (sysctlbyname("hw.pagesize", &pagesize, &len, NULL, 0) != 0)
-- pagesize = 4096;
-- /* mem_inactive */
-- len = sizeof(mem_inactive);
-- if (sysctlbyname("vm.stats.vm.v_inactive_count", &mem_inactive, &len, NULL, 0) == 0)
-- mem_inactive *= pagesize;
-- /* mem_cache */
-- len = sizeof(mem_cache);
-- if (sysctlbyname("vm.stats.vm.v_cache_count", &mem_cache, &len, NULL, 0) == 0)
-- mem_cache *= pagesize;
-- /* mem_free */
-- len = sizeof(mem_free);
-- if (sysctlbyname("vm.stats.vm.v_free_count", &mem_free, &len, NULL, 0) == 0)
-- mem_free *= pagesize;
--
-- /* mem_avail = mem_inactive + mem_cache + mem_free */
-- lpBuffer->ullAvailPhys = mem_inactive + mem_cache + mem_free;
-- lpBuffer->ullAvailVirtual = mem_inactive + mem_cache + mem_free;
--
-- if (sysctlbyname("vm.stats.vm.v_swappgsout", &swap_free, &len, NULL, 0) == 0)
-- lpBuffer->ullAvailPageFile = swap_free * pagesize;
--#else
-- struct sysinfo info;
-- char name[32];
-- unsigned val;
-- if (!procMeminfoFP && (procMeminfoFP = fopen("/proc/meminfo", "r")) == NULL)
-- sysinfo(&info);
-- else
-- {
-- memset(&info, 0, sizeof(struct sysinfo));
-- info.mem_unit = 4096;
-- while (fscanf(procMeminfoFP, "%31s %u%*[^\n]\n", name, &val) != EOF)
-- {
-- if (strncmp("MemTotal:", name, 9) == 0)
-- info.totalram = val/4;
-- else if (strncmp("MemFree:", name, 8) == 0)
-- info.freeram = val/4;
-- else if (strncmp("Buffers:", name, 8) == 0)
-- info.bufferram += val/4;
-- else if (strncmp("Cached:", name, 7) == 0)
-- info.bufferram += val/4;
-- else if (strncmp("SwapTotal:", name, 10) == 0)
-- info.totalswap = val/4;
-- else if (strncmp("SwapFree:", name, 9) == 0)
-- info.freeswap = val/4;
-- else if (strncmp("HighTotal:", name, 10) == 0)
-- info.totalhigh = val/4;
-- else if (strncmp("HighFree:", name, 9) == 0)
-- info.freehigh = val/4;
-- }
-- rewind(procMeminfoFP);
-- fflush(procMeminfoFP);
-- }
-- lpBuffer->ullAvailPageFile = (info.freeswap * info.mem_unit);
-- lpBuffer->ullAvailPhys = ((info.freeram + info.bufferram) * info.mem_unit);
-- lpBuffer->ullAvailVirtual = ((info.freeram + info.bufferram) * info.mem_unit);
-- lpBuffer->ullTotalPhys = (info.totalram * info.mem_unit);
-- lpBuffer->ullTotalVirtual = (info.totalram * info.mem_unit);
--#endif
--}
--
--#endif
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XSyncUtils.h xbmc-pvr-11.0.1.patch/xbmc/linux/XSyncUtils.h
---- xbmc-pvr-11.0.1/xbmc/linux/XSyncUtils.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.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_
--
--/*
-- * Copyright (C) 2005-2008 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 "PlatformDefs.h"
--#include "XHandlePublic.h"
--
--#ifdef _LINUX
--
--#define STATUS_WAIT_0 ((DWORD )0x00000000L)
--#define WAIT_FAILED ((DWORD)0xFFFFFFFF)
--#define WAIT_OBJECT_0 ((STATUS_WAIT_0 ) + 0 )
--#define WAIT_TIMEOUT 258L
--#define INFINITE 0xFFFFFFFF
--#define STATUS_ABANDONED_WAIT_0 0x00000080
--#define WAIT_ABANDONED ((STATUS_ABANDONED_WAIT_0 ) + 0 )
--#define WAIT_ABANDONED_0 ((STATUS_ABANDONED_WAIT_0 ) + 0 )
--
--void GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer);
--
--#endif
--
--#endif
--
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XThreadUtils.cpp xbmc-pvr-11.0.1.patch/xbmc/linux/XThreadUtils.cpp
---- xbmc-pvr-11.0.1/xbmc/linux/XThreadUtils.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XThreadUtils.cpp 1970-01-01 01:00:00.000000000 +0100
-@@ -1,210 +0,0 @@
--/*
-- * 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 "PlatformDefs.h"
--#include "XHandle.h"
--#include "XThreadUtils.h"
--#include "XTimeUtils.h"
--#include "XEventUtils.h"
--#include "system.h"
--#include "utils/log.h"
--
--#ifdef _LINUX
--#include
--#include
--#include
--
--HANDLE WINAPI CreateThread(
-- LPSECURITY_ATTRIBUTES lpThreadAttributes,
-- SIZE_T dwStackSize,
-- LPTHREAD_START_ROUTINE lpStartAddress,
-- LPVOID lpParameter,
-- DWORD dwCreationFlags,
-- LPDWORD lpThreadId
-- ) {
--
-- // a thread handle would actually contain an event
-- // the event would mark if the thread is running or not. it will be used in the Wait functions.
-- HANDLE h = CreateEvent(NULL, TRUE, FALSE, NULL);
-- h->ChangeType(CXHandle::HND_THREAD);
--#ifdef __APPLE__
-- h->m_machThreadPort = MACH_PORT_NULL;
--#endif
-- pthread_attr_t attr;
-- pthread_attr_init(&attr);
-- if (dwStackSize > PTHREAD_STACK_MIN)
-- pthread_attr_setstacksize(&attr, dwStackSize);
-- if (pthread_create(&(h->m_hThread), &attr, (void*(*)(void*))lpStartAddress, lpParameter) == 0)
-- h->m_threadValid = true;
-- else
-- {
-- CloseHandle(h);
-- h = NULL;
-- }
-- pthread_attr_destroy(&attr);
--
-- if (h && lpThreadId)
-- // WARNING: This can truncate thread IDs on x86_64.
-- *lpThreadId = (DWORD)h->m_hThread;
-- return h;
--}
--
--
--#if 0 // Deprecated, use CThread::GetCurrentThreadId() instead
--DWORD WINAPI GetCurrentThreadId(void) {
-- // WARNING: This can truncate thread IDs on x86_64.
-- return (DWORD)pthread_self();
--}
--#endif
--
--HANDLE WINAPI GetCurrentThread(void) {
-- return (HANDLE)-1; // -1 a special value - pseudo handle
--}
--
--HANDLE WINAPI GetCurrentProcess(void) {
-- return (HANDLE)-1; // -1 a special value - pseudo handle
--}
--
--HANDLE _beginthreadex(
-- void *security,
-- unsigned stack_size,
-- int ( *start_address )( void * ),
-- void *arglist,
-- unsigned initflag,
-- unsigned *thrdaddr
--) {
--
-- HANDLE h = CreateThread(NULL, stack_size, start_address, arglist, initflag, (LPDWORD)thrdaddr);
-- return h;
--
--}
--
--uintptr_t _beginthread(
-- void( *start_address )( void * ),
-- unsigned stack_size,
-- void *arglist
--) {
-- HANDLE h = CreateThread(NULL, stack_size, (LPTHREAD_START_ROUTINE)start_address, arglist, 0, NULL);
-- return (uintptr_t)h;
--}
--
--BOOL WINAPI GetThreadTimes (
-- HANDLE hThread,
-- LPFILETIME lpCreationTime,
-- LPFILETIME lpExitTime,
-- LPFILETIME lpKernelTime,
-- LPFILETIME lpUserTime
--) {
-- if (!hThread)
-- return false;
-- if (!hThread->m_threadValid)
-- return false;
--
-- if (hThread == (HANDLE)-1) {
-- if (lpCreationTime)
-- TimeTToFileTime(0,lpCreationTime);
-- if (lpExitTime)
-- TimeTToFileTime(time(NULL),lpExitTime);
-- if (lpKernelTime)
-- TimeTToFileTime(0,lpKernelTime);
-- if (lpUserTime)
-- TimeTToFileTime(0,lpUserTime);
--
-- return true;
-- }
--
-- if (lpCreationTime)
-- TimeTToFileTime(hThread->m_tmCreation,lpCreationTime);
-- if (lpExitTime)
-- TimeTToFileTime(time(NULL),lpExitTime);
-- if (lpKernelTime)
-- TimeTToFileTime(0,lpKernelTime);
--
--#ifdef __APPLE__
-- thread_info_data_t threadInfo;
-- mach_msg_type_number_t threadInfoCount = THREAD_INFO_MAX;
--
-- if (hThread->m_machThreadPort == MACH_PORT_NULL)
-- hThread->m_machThreadPort = pthread_mach_thread_np(hThread->m_hThread);
--
-- kern_return_t ret = thread_info(hThread->m_machThreadPort, THREAD_BASIC_INFO, (thread_info_t)threadInfo, &threadInfoCount);
-- if (ret == KERN_SUCCESS)
-- {
-- thread_basic_info_t threadBasicInfo = (thread_basic_info_t)threadInfo;
--
-- if (lpUserTime)
-- {
-- // User time.
-- unsigned long long time = ((__int64)threadBasicInfo->user_time.seconds * 10000000L) + threadBasicInfo->user_time.microseconds*10L;
-- lpUserTime->dwLowDateTime = (time & 0xFFFFFFFF);
-- lpUserTime->dwHighDateTime = (time >> 32);
-- }
--
-- if (lpKernelTime)
-- {
-- // System time.
-- unsigned long long time = ((__int64)threadBasicInfo->system_time.seconds * 10000000L) + threadBasicInfo->system_time.microseconds*10L;
-- lpKernelTime->dwLowDateTime = (time & 0xFFFFFFFF);
-- lpKernelTime->dwHighDateTime = (time >> 32);
-- }
-- }
-- else
-- {
-- if (lpUserTime)
-- lpUserTime->dwLowDateTime = lpUserTime->dwHighDateTime = 0;
--
-- if (lpKernelTime)
-- lpKernelTime->dwLowDateTime = lpKernelTime->dwHighDateTime = 0;
-- }
--#elif _POSIX_THREAD_CPUTIME != -1
-- if(lpUserTime)
-- {
-- lpUserTime->dwLowDateTime = 0;
-- lpUserTime->dwHighDateTime = 0;
-- clockid_t clock;
-- if (pthread_getcpuclockid(hThread->m_hThread, &clock) == 0)
-- {
-- struct timespec tp = {};
-- clock_gettime(clock, &tp);
-- unsigned long long time = (unsigned long long)tp.tv_sec * 10000000 + (unsigned long long)tp.tv_nsec/100;
-- lpUserTime->dwLowDateTime = (time & 0xFFFFFFFF);
-- lpUserTime->dwHighDateTime = (time >> 32);
-- }
-- }
--#else
-- if (lpUserTime)
-- TimeTToFileTime(0,lpUserTime);
--#endif
-- return true;
--}
--
--BOOL WINAPI SetThreadPriority(HANDLE hThread, int nPriority)
--{
-- return true;
--}
--
--int GetThreadPriority(HANDLE hThread)
--{
-- return 0;
--}
--
--#endif
--
-diff -Naur xbmc-pvr-11.0.1/xbmc/music/infoscanner/MusicInfoScanner.cpp xbmc-pvr-11.0.1.patch/xbmc/music/infoscanner/MusicInfoScanner.cpp
---- xbmc-pvr-11.0.1/xbmc/music/infoscanner/MusicInfoScanner.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/music/infoscanner/MusicInfoScanner.cpp 2012-05-14 14:15:12.192221636 +0200
-@@ -57,7 +57,7 @@
- using namespace XFILE;
- using namespace MUSIC_GRABBER;
-
--CMusicInfoScanner::CMusicInfoScanner()
-+CMusicInfoScanner::CMusicInfoScanner() : CThread("CMusicInfoScanner")
- {
- m_bRunning = false;
- m_pObserver = NULL;
-@@ -99,7 +99,7 @@
-
- // Create the thread to count all files to be scanned
- SetPriority( GetMinPriority() );
-- CThread fileCountReader(this);
-+ CThread fileCountReader(this, "CMusicInfoScanner");
- if (m_pObserver)
- fileCountReader.Create();
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/music/infoscanner/MusicInfoScraper.cpp xbmc-pvr-11.0.1.patch/xbmc/music/infoscanner/MusicInfoScraper.cpp
---- xbmc-pvr-11.0.1/xbmc/music/infoscanner/MusicInfoScraper.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/music/infoscanner/MusicInfoScraper.cpp 2012-05-14 14:15:12.192221636 +0200
-@@ -28,7 +28,7 @@
- using namespace ADDON;
- using namespace std;
-
--CMusicInfoScraper::CMusicInfoScraper(const ADDON::ScraperPtr &scraper)
-+CMusicInfoScraper::CMusicInfoScraper(const ADDON::ScraperPtr &scraper) : CThread("CMusicInfoScraper")
- {
- m_bSucceeded=false;
- m_bCanceled=false;
-diff -Naur xbmc-pvr-11.0.1/xbmc/music/LastFmManager.cpp xbmc-pvr-11.0.1.patch/xbmc/music/LastFmManager.cpp
---- xbmc-pvr-11.0.1/xbmc/music/LastFmManager.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/music/LastFmManager.cpp 2012-05-14 14:15:12.193221656 +0200
-@@ -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-pvr-11.0.1/xbmc/network/AirPlayServer.cpp xbmc-pvr-11.0.1.patch/xbmc/network/AirPlayServer.cpp
---- xbmc-pvr-11.0.1/xbmc/network/AirPlayServer.cpp 2012-03-27 17:55:33.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/network/AirPlayServer.cpp 2012-05-14 14:15:12.194221676 +0200
-@@ -184,7 +184,7 @@
- }
- }
-
--CAirPlayServer::CAirPlayServer(int port, bool nonlocal)
-+CAirPlayServer::CAirPlayServer(int port, bool nonlocal) : CThread("AirPlayServer")
- {
- m_port = port;
- m_nonlocal = nonlocal;
-diff -Naur xbmc-pvr-11.0.1/xbmc/network/AirTunesServer.cpp xbmc-pvr-11.0.1.patch/xbmc/network/AirTunesServer.cpp
---- xbmc-pvr-11.0.1/xbmc/network/AirTunesServer.cpp 2012-03-27 17:55:33.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/network/AirTunesServer.cpp 2012-05-14 14:15:12.195221696 +0200
-@@ -292,7 +292,7 @@
- }
- }
-
--CAirTunesServer::CAirTunesServer(int port, bool nonlocal)
-+CAirTunesServer::CAirTunesServer(int port, bool nonlocal) : CThread("CAirTunesServer")
- {
- m_port = port;
- m_pLibShairport = new DllLibShairport();
-diff -Naur xbmc-pvr-11.0.1/xbmc/network/libscrobbler/scrobbler.cpp xbmc-pvr-11.0.1.patch/xbmc/network/libscrobbler/scrobbler.cpp
---- xbmc-pvr-11.0.1/xbmc/network/libscrobbler/scrobbler.cpp 2012-03-27 17:55:33.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/network/libscrobbler/scrobbler.cpp 2012-05-14 14:15:12.196221716 +0200
-@@ -46,7 +46,7 @@
- #define SCROBBLER_ACTION_NOWPLAYING 2
-
- CScrobbler::CScrobbler(const CStdString &strHandshakeURL, const CStdString &strLogPrefix)
-- : CThread()
-+ : CThread("CScrobbler")
- {
- m_bBanned = false;
- m_bBadAuth = false;
-@@ -67,7 +67,7 @@
- ResetState();
- LoadCredentials();
- LoadJournal();
-- if (!ThreadHandle())
-+ if (!IsRunning())
- Create();
- }
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/network/Network.h xbmc-pvr-11.0.1.patch/xbmc/network/Network.h
---- xbmc-pvr-11.0.1/xbmc/network/Network.h 2012-03-27 17:55:33.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/network/Network.h 2012-05-14 14:15:12.197221736 +0200
-@@ -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-pvr-11.0.1/xbmc/network/TCPServer.cpp xbmc-pvr-11.0.1.patch/xbmc/network/TCPServer.cpp
---- xbmc-pvr-11.0.1/xbmc/network/TCPServer.cpp 2012-03-27 17:55:33.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/network/TCPServer.cpp 2012-05-14 14:15:12.197221736 +0200
-@@ -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-pvr-11.0.1/xbmc/network/UdpClient.cpp xbmc-pvr-11.0.1.patch/xbmc/network/UdpClient.cpp
---- xbmc-pvr-11.0.1/xbmc/network/UdpClient.cpp 2012-03-27 17:55:33.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/network/UdpClient.cpp 2012-05-14 14:15:12.198221756 +0200
-@@ -35,7 +35,7 @@
-
- #define UDPCLIENT_DEBUG_LEVEL LOGDEBUG
-
--CUdpClient::CUdpClient(void) : CThread()
-+CUdpClient::CUdpClient(void) : CThread("CUdpClient")
- {}
-
- CUdpClient::~CUdpClient(void)
-diff -Naur xbmc-pvr-11.0.1/xbmc/network/UdpClient.h xbmc-pvr-11.0.1.patch/xbmc/network/UdpClient.h
---- xbmc-pvr-11.0.1/xbmc/network/UdpClient.h 2012-03-27 17:55:33.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/network/UdpClient.h 2012-05-14 14:15:12.199221776 +0200
-@@ -25,6 +25,7 @@
- #include "threads/CriticalSection.h"
- #include
- #include
-+#include "system.h"
-
- class CUdpClient : CThread
- {
-diff -Naur xbmc-pvr-11.0.1/xbmc/peripherals/Peripherals.cpp xbmc-pvr-11.0.1.patch/xbmc/peripherals/Peripherals.cpp
---- xbmc-pvr-11.0.1/xbmc/peripherals/Peripherals.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/peripherals/Peripherals.cpp 2012-05-14 14:15:12.199221776 +0200
-@@ -19,6 +19,7 @@
- *
- */
-
-+#include "system.h"
- #include "Peripherals.h"
- #include "bus/PeripheralBus.h"
- #include "devices/PeripheralBluetooth.h"
-diff -Naur xbmc-pvr-11.0.1/xbmc/pictures/GUIWindowSlideShow.cpp xbmc-pvr-11.0.1.patch/xbmc/pictures/GUIWindowSlideShow.cpp
---- xbmc-pvr-11.0.1/xbmc/pictures/GUIWindowSlideShow.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/pictures/GUIWindowSlideShow.cpp 2012-05-14 14:15:12.201221817 +0200
-@@ -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 };
-
--CBackgroundPicLoader::CBackgroundPicLoader()
-+CBackgroundPicLoader::CBackgroundPicLoader() : CThread("CBackgroundPicLoader")
- {
- m_pCallback = NULL;
- m_isLoading = false;
-diff -Naur xbmc-pvr-11.0.1/xbmc/rendering/dx/RenderSystemDX.cpp xbmc-pvr-11.0.1.patch/xbmc/rendering/dx/RenderSystemDX.cpp
---- xbmc-pvr-11.0.1/xbmc/rendering/dx/RenderSystemDX.cpp 2012-03-27 17:55:35.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/rendering/dx/RenderSystemDX.cpp 2012-05-14 14:15:12.202221838 +0200
-@@ -569,7 +569,7 @@
-
- //CVideoReferenceClock polls GetRasterStatus too,
- //polling it from two threads at the same time is bad
-- if (g_advancedSettings.m_sleepBeforeFlip > 0 && g_VideoReferenceClock.ThreadHandle() == NULL)
-+ if (g_advancedSettings.m_sleepBeforeFlip > 0 && !g_VideoReferenceClock.IsRunning())
- {
- //save current thread priority and set thread priority to THREAD_PRIORITY_TIME_CRITICAL
- int priority = GetThreadPriority(GetCurrentThread());
-diff -Naur xbmc-pvr-11.0.1/xbmc/settings/AdvancedSettings.cpp xbmc-pvr-11.0.1.patch/xbmc/settings/AdvancedSettings.cpp
---- xbmc-pvr-11.0.1/xbmc/settings/AdvancedSettings.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/settings/AdvancedSettings.cpp 2012-05-14 14:15:12.203221858 +0200
-@@ -96,12 +96,18 @@
- m_videoAllowMpeg4VAAPI = false;
- m_videoDisableBackgroundDeinterlace = false;
- m_videoCaptureUseOcclusionQuery = -1; //-1 is auto detect
-+ m_videoVDPAUdeintHD = -1;
-+ m_videoVDPAUdeintSD = -1;
-+ m_videoVDPAUtelecine = false;
-+ m_videoVDPAUmaxHeight = -1;
-+ m_videoVDPAUdeintSkipChromaHD = false;
- m_DXVACheckCompatibility = false;
- m_DXVACheckCompatibilityPresent = false;
- m_DXVAForceProcessorRenderer = true;
- m_DXVANoDeintProcForProgressive = false;
- m_videoFpsDetect = 1;
- m_videoDefaultLatency = 0.0;
-+ m_vblankPolling = false;
-
- m_musicUseTimeSeeking = true;
- m_musicTimeSeekForward = 10;
-@@ -470,6 +476,11 @@
- XMLUtils::GetBoolean(pElement,"allowmpeg4vaapi",m_videoAllowMpeg4VAAPI);
- XMLUtils::GetBoolean(pElement, "disablebackgrounddeinterlace", m_videoDisableBackgroundDeinterlace);
- XMLUtils::GetInt(pElement, "useocclusionquery", m_videoCaptureUseOcclusionQuery, -1, 1);
-+ XMLUtils::GetInt(pElement,"vdpauHDdeint",m_videoVDPAUdeintHD);
-+ XMLUtils::GetInt(pElement,"vdpauSDdeint",m_videoVDPAUdeintSD);
-+ XMLUtils::GetInt(pElement,"vdpauMaxHeight",m_videoVDPAUmaxHeight);
-+ XMLUtils::GetBoolean(pElement,"vdpauInvTelecine",m_videoVDPAUtelecine);
-+ XMLUtils::GetBoolean(pElement,"vdpauHDdeintSkipChroma",m_videoVDPAUdeintSkipChromaHD);
-
- TiXmlElement* pAdjustRefreshrate = pElement->FirstChildElement("adjustrefreshrate");
- if (pAdjustRefreshrate)
-@@ -559,6 +570,8 @@
- //0 = disable fps detect, 1 = only detect on timestamps with uniform spacing, 2 detect on all timestamps
- XMLUtils::GetInt(pElement, "fpsdetect", m_videoFpsDetect, 0, 2);
-
-+ XMLUtils::GetBoolean(pElement,"vblankpolling", m_vblankPolling);
-+
- // Store global display latency settings
- TiXmlElement* pVideoLatency = pElement->FirstChildElement("latency");
- if (pVideoLatency)
-diff -Naur xbmc-pvr-11.0.1/xbmc/settings/AdvancedSettings.h xbmc-pvr-11.0.1.patch/xbmc/settings/AdvancedSettings.h
---- xbmc-pvr-11.0.1/xbmc/settings/AdvancedSettings.h 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/settings/AdvancedSettings.h 2012-05-14 14:15:12.204221878 +0200
-@@ -111,6 +111,11 @@
- int m_videoPercentSeekBackwardBig;
- CStdString m_videoPPFFmpegDeint;
- CStdString m_videoPPFFmpegPostProc;
-+ int m_videoVDPAUdeintHD;
-+ int m_videoVDPAUdeintSD;
-+ bool m_videoVDPAUtelecine;
-+ int m_videoVDPAUmaxHeight;
-+ bool m_videoVDPAUdeintSkipChromaHD;
- bool m_musicUseTimeSeeking;
- int m_musicTimeSeekForward;
- int m_musicTimeSeekBackward;
-@@ -143,6 +148,7 @@
- bool m_DXVAForceProcessorRenderer;
- bool m_DXVANoDeintProcForProgressive;
- int m_videoFpsDetect;
-+ bool m_vblankPolling;
-
- CStdString m_videoDefaultPlayer;
- CStdString m_videoDefaultDVDPlayer;
-diff -Naur xbmc-pvr-11.0.1/xbmc/settings/GUISettings.cpp xbmc-pvr-11.0.1.patch/xbmc/settings/GUISettings.cpp
---- xbmc-pvr-11.0.1/xbmc/settings/GUISettings.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/settings/GUISettings.cpp 2012-05-14 14:15:12.205221898 +0200
-@@ -588,10 +588,15 @@
-
- #ifdef HAVE_LIBVDPAU
- AddBool(vp, "videoplayer.usevdpau", 13425, true);
-+ AddBool(vp, "videoplayer.usevdpauinteroprgb", 13433, true);
-+ AddBool(vp, "videoplayer.usevdpauinteropyuv", 13434, true);
- #endif
- #ifdef HAVE_LIBVA
- AddBool(vp, "videoplayer.usevaapi", 13426, true);
- #endif
-+#ifdef HAVE_LIBXVBA
-+ AddBool(vp, "videoplayer.usexvba", 13435, true);
-+#endif
- #ifdef HAS_DX
- AddBool(g_sysinfo.IsVistaOrHigher() ? vp: NULL, "videoplayer.usedxva2", 13427, g_sysinfo.IsVistaOrHigher() ? true : false);
- #endif
-diff -Naur xbmc-pvr-11.0.1/xbmc/settings/GUIWindowSettingsCategory.cpp xbmc-pvr-11.0.1.patch/xbmc/settings/GUIWindowSettingsCategory.cpp
---- xbmc-pvr-11.0.1/xbmc/settings/GUIWindowSettingsCategory.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/settings/GUIWindowSettingsCategory.cpp 2012-05-14 14:15:12.207221938 +0200
-@@ -557,6 +557,40 @@
- pControl->SetEnabled(true);
- }
- }
-+ else if (strSetting.Equals("videoplayer.usevdpauinteropyuv"))
-+ {
-+ bool hasInterop = false;
-+#ifdef GL_NV_vdpau_interop
-+ hasInterop = true;
-+#endif
-+ CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
-+ if (pControl && hasInterop && glewIsSupported("GL_NV_vdpau_interop"))
-+ {
-+ pControl->SetEnabled(true);
-+ }
-+ else
-+ {
-+ pControl->SetEnabled(false);
-+ g_guiSettings.SetBool("videoplayer.usevdpauinteropyuv",false);
-+ }
-+ }
-+ else if (strSetting.Equals("videoplayer.usevdpauinteroprgb"))
-+ {
-+ bool hasInterop = false;
-+#ifdef GL_NV_vdpau_interop
-+ hasInterop = true;
-+#endif
-+ CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
-+ if (pControl && hasInterop && glewIsSupported("GL_NV_vdpau_interop"))
-+ {
-+ pControl->SetEnabled(true);
-+ }
-+ else
-+ {
-+ pControl->SetEnabled(false);
-+ g_guiSettings.SetBool("videoplayer.usevdpauinteroprgb",false);
-+ }
-+ }
- else
- #endif
- if (strSetting.Equals("videoscreen.resolution"))
-diff -Naur xbmc-pvr-11.0.1/xbmc/settings/VideoSettings.h xbmc-pvr-11.0.1.patch/xbmc/settings/VideoSettings.h
---- xbmc-pvr-11.0.1/xbmc/settings/VideoSettings.h 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/settings/VideoSettings.h 2012-05-14 14:15:12.208221958 +0200
-@@ -66,6 +66,8 @@
- VS_INTERLACEMETHOD_SW_BLEND = 20,
- VS_INTERLACEMETHOD_AUTO_ION = 21,
-
-+ VS_INTERLACEMETHOD_XVBA = 22,
-+
- VS_INTERLACEMETHOD_MAX // do not use and keep as last enum value.
- };
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/platform/darwin/ThreadSchedImpl.cpp xbmc-pvr-11.0.1.patch/xbmc/threads/platform/darwin/ThreadSchedImpl.cpp
---- xbmc-pvr-11.0.1/xbmc/threads/platform/darwin/ThreadSchedImpl.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/darwin/ThreadSchedImpl.cpp 2012-05-14 14:15:12.208221958 +0200
-@@ -0,0 +1,47 @@
-+/*
-+ * 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
-+ *
-+ */
-+
-+int CThread::GetSchedRRPriority(void)
-+{
-+ return 96;
-+}
-+
-+bool CThread::SetPrioritySched_RR(int iPriority)
-+{
-+ // 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 );
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/platform/linux/ThreadSchedImpl.cpp xbmc-pvr-11.0.1.patch/xbmc/threads/platform/linux/ThreadSchedImpl.cpp
---- xbmc-pvr-11.0.1/xbmc/threads/platform/linux/ThreadSchedImpl.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/linux/ThreadSchedImpl.cpp 2012-05-14 14:15:12.209221978 +0200
-@@ -0,0 +1,30 @@
-+/*
-+ * 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
-+ *
-+ */
-+
-+int CThread::GetSchedRRPriority(void)
-+{
-+ return GetNormalPriority();
-+}
-+
-+bool CThread::SetPrioritySched_RR(int iPriority)
-+{
-+ return false;
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/platform/pthreads/ThreadImpl.cpp xbmc-pvr-11.0.1.patch/xbmc/threads/platform/pthreads/ThreadImpl.cpp
---- xbmc-pvr-11.0.1/xbmc/threads/platform/pthreads/ThreadImpl.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/pthreads/ThreadImpl.cpp 2012-05-14 14:15:12.210221998 +0200
-@@ -0,0 +1,220 @@
-+/*
-+ * 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
-+ *
-+ */
-+
-+#include
-+#include
-+#include
-+#include
-+
-+void CThread::Create(bool bAutoDelete, unsigned stacksize)
-+{
-+ if (m_ThreadId != 0)
-+ {
-+ CLog::Log(LOGERROR, "%s - fatal error creating thread- old thread id not null", __FUNCTION__);
-+ exit(1);
-+ }
-+ m_iLastTime = XbmcThreads::SystemClockMillis() * 10000;
-+ m_iLastUsage = 0;
-+ m_fLastUsage = 0.0f;
-+ m_bAutoDelete = bAutoDelete;
-+ m_bStop = false;
-+ m_StopEvent.Reset();
-+ m_TermEvent.Reset();
-+ m_StartEvent.Reset();
-+
-+ pthread_attr_t attr;
-+ pthread_attr_init(&attr);
-+ if (stacksize > PTHREAD_STACK_MIN)
-+ pthread_attr_setstacksize(&attr, stacksize);
-+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-+ if (pthread_create(&m_ThreadId, &attr, (void*(*)(void*))staticThread, this) != 0)
-+ {
-+ CLog::Log(LOGNOTICE, "%s - fatal error creating thread",__FUNCTION__);
-+ }
-+ pthread_attr_destroy(&attr);
-+}
-+
-+void CThread::TermHandler()
-+{
-+
-+}
-+
-+void CThread::SetThreadInfo()
-+{
-+ m_ThreadOpaque.LwpId = syscall(SYS_gettid);
-+
-+ // start thread with nice level of appication
-+ int appNice = getpriority(PRIO_PROCESS, getpid());
-+ if (setpriority(PRIO_PROCESS, m_ThreadOpaque.LwpId, appNice) != 0)
-+ CLog::Log(LOGERROR, "%s: error %s", __FUNCTION__, strerror(errno));
-+}
-+
-+ThreadIdentifier CThread::GetCurrentThreadId()
-+{
-+ return pthread_self();
-+}
-+
-+bool CThread::IsCurrentThread(const ThreadIdentifier tid)
-+{
-+ return pthread_equal(pthread_self(), tid);
-+}
-+
-+int CThread::GetMinPriority(void)
-+{
-+ // one level lower than application
-+ return -1;
-+}
-+
-+int CThread::GetMaxPriority(void)
-+{
-+ // one level higher than application
-+ return 1;
-+}
-+
-+int CThread::GetNormalPriority(void)
-+{
-+ // same level as application
-+ return 0;
-+}
-+
-+bool CThread::SetPriority(const int iPriority)
-+{
-+ bool bReturn = false;
-+
-+ // wait until thread is running, it needs to get its lwp id
-+ m_StartEvent.Wait();
-+
-+ CSingleLock lock(m_CriticalSection);
-+
-+ // get min prio for SCHED_RR
-+ int minRR = GetMaxPriority() + 1;
-+
-+ if (!m_ThreadId)
-+ bReturn = false;
-+ else if (iPriority >= minRR)
-+ bReturn = SetPrioritySched_RR(iPriority);
-+ else
-+ {
-+ // get user max prio
-+ struct rlimit limit;
-+ int userMaxPrio;
-+ if (getrlimit(RLIMIT_NICE, &limit) == 0)
-+ {
-+ userMaxPrio = limit.rlim_cur - 20;
-+ }
-+ else
-+ userMaxPrio = 0;
-+
-+ // keep priority in bounds
-+ int prio = iPriority;
-+ if (prio >= GetMaxPriority())
-+ prio = std::min(GetMaxPriority(), userMaxPrio);
-+ if (prio < GetMinPriority())
-+ prio = GetMinPriority();
-+
-+ // nice level of application
-+ int appNice = getpriority(PRIO_PROCESS, getpid());
-+ if (prio)
-+ prio = prio > 0 ? appNice-1 : appNice+1;
-+
-+ if (setpriority(PRIO_PROCESS, m_ThreadOpaque.LwpId, prio) == 0)
-+ bReturn = true;
-+ else
-+ CLog::Log(LOGERROR, "%s: error %s", __FUNCTION__, strerror(errno));
-+ }
-+
-+ return bReturn;
-+}
-+
-+int CThread::GetPriority()
-+{
-+ int iReturn;
-+
-+ // lwp id is valid after start signel has fired
-+ m_StartEvent.Wait();
-+
-+ CSingleLock lock(m_CriticalSection);
-+
-+ int appNice = getpriority(PRIO_PROCESS, getpid());
-+ int prio = getpriority(PRIO_PROCESS, m_ThreadOpaque.LwpId);
-+ iReturn = appNice - prio;
-+
-+ return iReturn;
-+}
-+
-+bool CThread::WaitForThreadExit(unsigned int milliseconds)
-+{
-+ bool bReturn = m_TermEvent.WaitMSec(milliseconds);
-+
-+ return bReturn;
-+}
-+
-+int64_t CThread::GetAbsoluteUsage()
-+{
-+ CSingleLock lock(m_CriticalSection);
-+
-+ if (!m_ThreadId)
-+ return 0;
-+
-+ clockid_t clock;
-+ int64_t time = 0;
-+ if (pthread_getcpuclockid(m_ThreadId, &clock) == 0)
-+ {
-+ struct timespec tp;
-+ clock_gettime(clock, &tp);
-+ time = (int64_t)tp.tv_sec * 10000000 + tp.tv_nsec/100;
-+ }
-+ return time;
-+}
-+
-+float CThread::GetRelativeUsage()
-+{
-+ unsigned int iTime = XbmcThreads::SystemClockMillis();
-+ iTime *= 10000; // convert into 100ns tics
-+
-+ // only update every 1 second
-+ if( iTime < m_iLastTime + 1000*10000 ) return m_fLastUsage;
-+
-+ int64_t iUsage = GetAbsoluteUsage();
-+
-+ 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;
-+}
-+
-+int64_t CThread::GetCurrentThreadUsage()
-+{
-+ pthread_t tid = pthread_self();
-+ clockid_t clock;
-+ int64_t time = 0;
-+ if (pthread_getcpuclockid(tid, &clock) == 0)
-+ {
-+ struct timespec tp;
-+ clock_gettime(clock, &tp);
-+ time = (int64_t)tp.tv_sec * 10000000 + tp.tv_nsec/100;
-+ }
-+ return time;
-+}
-+
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/platform/pthreads/ThreadImpl.h xbmc-pvr-11.0.1.patch/xbmc/threads/platform/pthreads/ThreadImpl.h
---- xbmc-pvr-11.0.1/xbmc/threads/platform/pthreads/ThreadImpl.h 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/pthreads/ThreadImpl.h 2012-05-14 14:15:12.210221998 +0200
-@@ -0,0 +1,39 @@
-+/*
-+* 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
-+
-+struct threadOpaque
-+{
-+ pid_t LwpId;
-+};
-+
-+typedef pthread_t ThreadIdentifier;
-+typedef threadOpaque ThreadOpaque;
-+typedef int THREADFUNC;
-+
-+namespace XbmcThreads
-+{
-+ inline static void ThreadSleep(unsigned int millis) { usleep(millis*1000); }
-+}
-+
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/platform/ThreadImpl.cpp xbmc-pvr-11.0.1.patch/xbmc/threads/platform/ThreadImpl.cpp
---- xbmc-pvr-11.0.1/xbmc/threads/platform/ThreadImpl.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/ThreadImpl.cpp 2012-05-14 14:15:12.211222019 +0200
-@@ -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-pvr-11.0.1/xbmc/threads/platform/ThreadImpl.h xbmc-pvr-11.0.1.patch/xbmc/threads/platform/ThreadImpl.h
---- xbmc-pvr-11.0.1/xbmc/threads/platform/ThreadImpl.h 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/ThreadImpl.h 2012-05-14 14:15:12.211222019 +0200
-@@ -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-pvr-11.0.1/xbmc/threads/platform/win/ThreadImpl.cpp xbmc-pvr-11.0.1.patch/xbmc/threads/platform/win/ThreadImpl.cpp
---- xbmc-pvr-11.0.1/xbmc/threads/platform/win/ThreadImpl.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/win/ThreadImpl.cpp 2012-05-14 14:15:12.212222039 +0200
-@@ -0,0 +1,207 @@
-+/*
-+ * 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
-+ *
-+ */
-+
-+#include
-+
-+
-+void CThread::Create(bool bAutoDelete, unsigned stacksize)
-+{
-+ if (m_ThreadId != 0)
-+ {
-+ CLog::Log(LOGERROR, "%s - fatal error creating thread- old thread id not null", __FUNCTION__);
-+ exit(1);
-+ }
-+ m_iLastTime = XbmcThreads::SystemClockMillis() * 10000;
-+ m_iLastUsage = 0;
-+ m_fLastUsage = 0.0f;
-+ m_bAutoDelete = bAutoDelete;
-+ m_bStop = false;
-+ m_StopEvent.Reset();
-+ m_TermEvent.Reset();
-+ m_StartEvent.Reset();
-+
-+ m_ThreadOpaque.handle = CreateThread(NULL,stacksize, (LPTHREAD_START_ROUTINE)&staticThread, this, 0, &m_ThreadId);
-+ if (m_ThreadOpaque.handle == NULL)
-+ {
-+ CLog::Log(LOGERROR, "%s - fatal error creating thread", __FUNCTION__);
-+ }
-+}
-+
-+void CThread::TermHandler()
-+{
-+ CloseHandle(m_ThreadOpaque.handle);
-+ m_ThreadOpaque.handle = NULL;
-+}
-+
-+void CThread::SetThreadInfo()
-+{
-+ 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 = m_ThreadName.c_str();
-+ info.dwThreadID = m_ThreadId;
-+ info.dwFlags = 0;
-+
-+ try
-+ {
-+ RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info);
-+ }
-+ catch(...)
-+ {
-+ }
-+}
-+
-+ThreadIdentifier CThread::GetCurrentThreadId()
-+{
-+ return ::GetCurrentThreadId();
-+}
-+
-+bool CThread::IsCurrentThread(const ThreadIdentifier tid)
-+{
-+ return (::GetCurrentThreadId() == tid);
-+}
-+
-+int CThread::GetMinPriority(void)
-+{
-+ return(THREAD_PRIORITY_IDLE);
-+}
-+
-+int CThread::GetMaxPriority(void)
-+{
-+ return(THREAD_PRIORITY_HIGHEST);
-+}
-+
-+int CThread::GetNormalPriority(void)
-+{
-+ return(THREAD_PRIORITY_NORMAL);
-+}
-+
-+int CThread::GetSchedRRPriority(void)
-+{
-+ return GetNormalPriority();
-+}
-+
-+bool CThread::SetPriority(const int iPriority)
-+{
-+ bool bReturn = false;
-+
-+ CSingleLock lock(m_CriticalSection);
-+ if (m_ThreadOpaque.handle)
-+ {
-+ bReturn = SetThreadPriority(m_ThreadOpaque.handle, iPriority) == TRUE;
-+ }
-+
-+ return bReturn;
-+}
-+
-+int CThread::GetPriority()
-+{
-+ CSingleLock lock(m_CriticalSection);
-+
-+ int iReturn = THREAD_PRIORITY_NORMAL;
-+ if (m_ThreadOpaque.handle)
-+ {
-+ iReturn = GetThreadPriority(m_ThreadOpaque.handle);
-+ }
-+ return iReturn;
-+}
-+
-+bool CThread::WaitForThreadExit(unsigned int milliseconds)
-+{
-+ bool bReturn = true;
-+
-+ CSingleLock lock(m_CriticalSection);
-+ if (m_ThreadId && m_ThreadOpaque.handle != NULL)
-+ {
-+ // boost priority of thread we are waiting on to same as caller
-+ int callee = GetThreadPriority(m_ThreadOpaque.handle);
-+ int caller = GetThreadPriority(GetCurrentThread());
-+ if(caller > callee)
-+ SetThreadPriority(m_ThreadOpaque.handle, caller);
-+
-+ lock.Leave();
-+ bReturn = m_TermEvent.WaitMSec(milliseconds);
-+ lock.Enter();
-+
-+ // restore thread priority if thread hasn't exited
-+ if(caller > callee && m_ThreadOpaque.handle)
-+ SetThreadPriority(m_ThreadOpaque.handle, callee);
-+ }
-+ return bReturn;
-+}
-+
-+int64_t CThread::GetAbsoluteUsage()
-+{
-+ CSingleLock lock(m_CriticalSection);
-+
-+ if (!m_ThreadOpaque.handle)
-+ return 0;
-+
-+ uint64_t time = 0;
-+ FILETIME CreationTime, ExitTime, UserTime, KernelTime;
-+ if( GetThreadTimes(m_ThreadOpaque.handle, &CreationTime, &ExitTime, &KernelTime, &UserTime ) )
-+ {
-+ time = (((uint64_t)UserTime.dwHighDateTime) << 32) + ((uint64_t)UserTime.dwLowDateTime);
-+ time += (((uint64_t)KernelTime.dwHighDateTime) << 32) + ((uint64_t)KernelTime.dwLowDateTime);
-+ }
-+ return time;
-+}
-+
-+float CThread::GetRelativeUsage()
-+{
-+ unsigned int iTime = XbmcThreads::SystemClockMillis();
-+ iTime *= 10000; // convert into 100ns tics
-+
-+ // only update every 1 second
-+ if( iTime < m_iLastTime + 1000*10000 ) return m_fLastUsage;
-+
-+ int64_t iUsage = GetAbsoluteUsage();
-+
-+ 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;
-+}
-+
-+int64_t CThread::GetCurrentThreadUsage()
-+{
-+ HANDLE h = GetCurrentThread();
-+
-+ uint64_t time = 0;
-+ FILETIME CreationTime, ExitTime, UserTime, KernelTime;
-+ if( GetThreadTimes(h, &CreationTime, &ExitTime, &KernelTime, &UserTime ) )
-+ {
-+ time = (((uint64_t)UserTime.dwHighDateTime) << 32) + ((uint64_t)UserTime.dwLowDateTime);
-+ time += (((uint64_t)KernelTime.dwHighDateTime) << 32) + ((uint64_t)KernelTime.dwLowDateTime);
-+ }
-+ return time;
-+}
-+
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/platform/win/ThreadImpl.h xbmc-pvr-11.0.1.patch/xbmc/threads/platform/win/ThreadImpl.h
---- xbmc-pvr-11.0.1/xbmc/threads/platform/win/ThreadImpl.h 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/win/ThreadImpl.h 2012-05-14 14:15:12.212222039 +0200
-@@ -0,0 +1,40 @@
-+/*
-+* 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
-+
-+
-+struct threadOpaque
-+{
-+ HANDLE handle;
-+};
-+
-+typedef DWORD ThreadIdentifier;
-+typedef threadOpaque ThreadOpaque;
-+typedef DWORD THREADFUNC;
-+
-+namespace XbmcThreads
-+{
-+ inline static void ThreadSleep(unsigned int millis) { Sleep(millis); }
-+}
-+
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/Thread.cpp xbmc-pvr-11.0.1.patch/xbmc/threads/Thread.cpp
---- xbmc-pvr-11.0.1/xbmc/threads/Thread.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/Thread.cpp 2012-05-14 14:15:12.214222079 +0200
-@@ -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-pvr-11.0.1/xbmc/threads/Thread.h xbmc-pvr-11.0.1.patch/xbmc/threads/Thread.h
---- xbmc-pvr-11.0.1/xbmc/threads/Thread.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/Thread.h 2012-05-14 14:15:12.215222099 +0200
-@@ -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-pvr-11.0.1/xbmc/threads/ThreadImpl.h xbmc-pvr-11.0.1.patch/xbmc/threads/ThreadImpl.h
---- xbmc-pvr-11.0.1/xbmc/threads/ThreadImpl.h 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/ThreadImpl.h 2012-05-14 14:15:12.215222099 +0200
-@@ -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-pvr-11.0.1/xbmc/utils/ActorProtocol.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/ActorProtocol.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/ActorProtocol.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/ActorProtocol.cpp 2012-05-14 14:15:12.216222119 +0200
-@@ -0,0 +1,254 @@
-+/*
-+ * 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
-+ *
-+ */
-+
-+#include "ActorProtocol.h"
-+
-+using namespace Actor;
-+
-+void Message::Release()
-+{
-+ bool skip;
-+ origin->Lock();
-+ skip = isSync ? !isSyncFini : false;
-+ isSyncFini = true;
-+ origin->Unlock();
-+
-+ if (skip)
-+ return;
-+
-+ // free data buffer
-+ if (data != buffer)
-+ delete [] data;
-+
-+ // delete event in case of sync message
-+ if (event)
-+ delete event;
-+
-+ origin->ReturnMessage(this);
-+}
-+
-+bool Message::Reply(int sig, void *data /* = NULL*/, int size /* = 0 */)
-+{
-+ if (!isSync)
-+ {
-+ if (isOut)
-+ return origin->SendInMessage(sig, data, size);
-+ else
-+ return origin->SendOutMessage(sig, data, size);
-+ }
-+
-+ origin->Lock();
-+
-+ if (!isSyncTimeout)
-+ {
-+ Message *msg = origin->GetMessage();
-+ msg->signal = sig;
-+ msg->isOut = !isOut;
-+ replyMessage = msg;
-+ if (data)
-+ {
-+ if (size > MSG_INTERNAL_BUFFER_SIZE)
-+ msg->data = new uint8_t[size];
-+ else
-+ msg->data = msg->buffer;
-+ memcpy(msg->data, data, size);
-+ }
-+ }
-+
-+ origin->Unlock();
-+
-+ if (event)
-+ event->Set();
-+
-+ return true;
-+}
-+
-+Protocol::~Protocol()
-+{
-+ Message *msg;
-+ Purge();
-+ while (!freeMessageQueue.empty())
-+ {
-+ msg = freeMessageQueue.front();
-+ freeMessageQueue.pop();
-+ delete msg;
-+ }
-+}
-+
-+Message *Protocol::GetMessage()
-+{
-+ Message *msg;
-+
-+ CSingleLock lock(criticalSection);
-+
-+ if (!freeMessageQueue.empty())
-+ {
-+ msg = freeMessageQueue.front();
-+ freeMessageQueue.pop();
-+ }
-+ else
-+ msg = new Message();
-+
-+ msg->isSync = false;
-+ msg->isSyncFini = false;
-+ msg->isSyncTimeout = false;
-+ msg->event = NULL;
-+ msg->data = NULL;
-+ msg->payloadSize = 0;
-+ msg->replyMessage = NULL;
-+ msg->origin = this;
-+
-+ return msg;
-+}
-+
-+void Protocol::ReturnMessage(Message *msg)
-+{
-+ CSingleLock lock(criticalSection);
-+
-+ freeMessageQueue.push(msg);
-+}
-+
-+bool Protocol::SendOutMessage(int signal, void *data /* = NULL */, int size /* = 0 */, Message *outMsg /* = NULL */)
-+{
-+ Message *msg;
-+ if (outMsg)
-+ msg = outMsg;
-+ else
-+ msg = GetMessage();
-+
-+ msg->signal = signal;
-+ msg->isOut = true;
-+
-+ if (data)
-+ {
-+ if (size > MSG_INTERNAL_BUFFER_SIZE)
-+ msg->data = new uint8_t[size];
-+ else
-+ msg->data = msg->buffer;
-+ memcpy(msg->data, data, size);
-+ }
-+
-+ { CSingleLock lock(criticalSection);
-+ outMessages.push(msg);
-+ }
-+ containerOutEvent->Set();
-+
-+ return true;
-+}
-+
-+bool Protocol::SendInMessage(int signal, void *data /* = NULL */, int size /* = 0 */, Message *outMsg /* = NULL */)
-+{
-+ Message *msg;
-+ if (outMsg)
-+ msg = outMsg;
-+ else
-+ msg = GetMessage();
-+
-+ msg->signal = signal;
-+ msg->isOut = false;
-+
-+ if (data)
-+ {
-+ if (size > MSG_INTERNAL_BUFFER_SIZE)
-+ msg->data = new uint8_t[size];
-+ else
-+ msg->data = msg->buffer;
-+ memcpy(msg->data, data, size);
-+ }
-+
-+ { CSingleLock lock(criticalSection);
-+ inMessages.push(msg);
-+ }
-+ containerInEvent->Set();
-+
-+ return true;
-+}
-+
-+
-+bool Protocol::SendOutMessageSync(int signal, Message **retMsg, int timeout, void *data /* = NULL */, int size /* = 0 */)
-+{
-+ Message *msg = GetMessage();
-+ msg->isOut = true;
-+ msg->isSync = true;
-+ msg->event = new CEvent;
-+ msg->event->Reset();
-+ SendOutMessage(signal, data, size, msg);
-+
-+ if (!msg->event->WaitMSec(timeout))
-+ {
-+ msg->origin->Lock();
-+ if (msg->replyMessage)
-+ *retMsg = msg->replyMessage;
-+ else
-+ {
-+ *retMsg = NULL;
-+ msg->isSyncTimeout = true;
-+ }
-+ msg->origin->Unlock();
-+ }
-+ else
-+ *retMsg = msg->replyMessage;
-+
-+ msg->Release();
-+
-+ if (*retMsg)
-+ return true;
-+ else
-+ return false;
-+}
-+
-+bool Protocol::ReceiveOutMessage(Message **msg)
-+{
-+ CSingleLock lock(criticalSection);
-+
-+ if (outMessages.empty() || outDefered)
-+ return false;
-+
-+ *msg = outMessages.front();
-+ outMessages.pop();
-+
-+ return true;
-+}
-+
-+bool Protocol::ReceiveInMessage(Message **msg)
-+{
-+ CSingleLock lock(criticalSection);
-+
-+ if (inMessages.empty() || inDefered)
-+ return false;
-+
-+ *msg = inMessages.front();
-+ inMessages.pop();
-+
-+ return true;
-+}
-+
-+
-+void Protocol::Purge()
-+{
-+ Message *msg;
-+
-+ while (ReceiveInMessage(&msg))
-+ msg->Release();
-+
-+ while (ReceiveOutMessage(&msg))
-+ msg->Release();
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/ActorProtocol.h xbmc-pvr-11.0.1.patch/xbmc/utils/ActorProtocol.h
---- xbmc-pvr-11.0.1/xbmc/utils/ActorProtocol.h 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/ActorProtocol.h 2012-05-14 14:15:12.217222140 +0200
-@@ -0,0 +1,89 @@
-+
-+#pragma once
-+
-+/*
-+ * 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
-+ *
-+ */
-+
-+#include "threads/Thread.h"
-+#include "utils/log.h"
-+#include
-+#include "memory.h"
-+
-+#define MSG_INTERNAL_BUFFER_SIZE 32
-+
-+namespace Actor
-+{
-+
-+class Protocol;
-+
-+class Message
-+{
-+ friend class Protocol;
-+public:
-+ int signal;
-+ bool isSync;
-+ bool isSyncFini;
-+ bool isOut;
-+ bool isSyncTimeout;
-+ int payloadSize;
-+ uint8_t buffer[MSG_INTERNAL_BUFFER_SIZE];
-+ uint8_t *data;
-+ Message *replyMessage;
-+ Protocol *origin;
-+ CEvent *event;
-+
-+ void Release();
-+ bool Reply(int sig, void *data = NULL, int size = 0);
-+
-+private:
-+ Message() {isSync = false; data = NULL; event = NULL; replyMessage = NULL;};
-+};
-+
-+class Protocol
-+{
-+public:
-+ Protocol(std::string name, CEvent* inEvent, CEvent *outEvent)
-+ : inDefered(false), outDefered(false), portName(name) {containerInEvent = inEvent; containerOutEvent = outEvent;};
-+ virtual ~Protocol();
-+ Message *GetMessage();
-+ void ReturnMessage(Message *msg);
-+ bool SendOutMessage(int signal, void *data = NULL, int size = 0, Message *outMsg = NULL);
-+ bool SendInMessage(int signal, void *data = NULL, int size = 0, Message *outMsg = NULL);
-+ bool SendOutMessageSync(int signal, Message **retMsg, int timeout, void *data = NULL, int size = 0);
-+ bool ReceiveOutMessage(Message **msg);
-+ bool ReceiveInMessage(Message **msg);
-+ void Purge();
-+ void DeferIn(bool value) {inDefered = value;};
-+ void DeferOut(bool value) {outDefered = value;};
-+ void Lock() {criticalSection.lock();};
-+ void Unlock() {criticalSection.unlock();};
-+ std::string portName;
-+
-+protected:
-+ CEvent *containerInEvent, *containerOutEvent;
-+ CCriticalSection criticalSection;
-+ std::queue outMessages;
-+ std::queue inMessages;
-+ std::queue freeMessageQueue;
-+ bool inDefered, outDefered;
-+};
-+
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/AlarmClock.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/AlarmClock.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/AlarmClock.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/AlarmClock.cpp 2012-05-14 14:15:12.217222140 +0200
-@@ -28,7 +28,7 @@
-
- using namespace std;
-
--CAlarmClock::CAlarmClock() : m_bIsRunning(false)
-+CAlarmClock::CAlarmClock() : CThread("CAlarmClock"), m_bIsRunning(false)
- {
- }
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/AsyncFileCopy.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/AsyncFileCopy.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/AsyncFileCopy.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/AsyncFileCopy.cpp 2012-05-14 14:15:12.218222160 +0200
-@@ -26,7 +26,7 @@
- #include "log.h"
- #include "utils/TimeUtils.h"
-
--CAsyncFileCopy::CAsyncFileCopy()
-+CAsyncFileCopy::CAsyncFileCopy() : CThread("CAsyncFileCopy")
- {
- m_cancelled = false;
- m_succeeded = false;
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/DownloadQueue.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/DownloadQueue.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/DownloadQueue.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/DownloadQueue.cpp 2012-05-14 14:15:12.218222160 +0200
-@@ -32,7 +32,7 @@
-
- WORD CDownloadQueue::m_wNextQueueId = 0;
-
--CDownloadQueue::CDownloadQueue(void) : CThread()
-+CDownloadQueue::CDownloadQueue(void) : CThread("CDownloadQueue")
- {
- m_bStop = false;
- m_wQueueId = m_wNextQueueId++;
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/DownloadQueue.h xbmc-pvr-11.0.1.patch/xbmc/utils/DownloadQueue.h
---- xbmc-pvr-11.0.1/xbmc/utils/DownloadQueue.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/DownloadQueue.h 2012-05-14 14:15:12.219222180 +0200
-@@ -26,6 +26,8 @@
- #include "threads/CriticalSection.h"
- #include "StdString.h"
-
-+#include "system.h"
-+
- struct TICKET
- {
- TICKET(WORD aQueueId, DWORD aItemId)
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/DownloadQueueManager.h xbmc-pvr-11.0.1.patch/xbmc/utils/DownloadQueueManager.h
---- xbmc-pvr-11.0.1/xbmc/utils/DownloadQueueManager.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/DownloadQueueManager.h 2012-05-14 14:15:12.220222200 +0200
-@@ -22,6 +22,7 @@
- */
-
- #include "DownloadQueue.h"
-+#include "system.h"
-
- #define MAX_DOWNLOAD_QUEUES 3
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/JobManager.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/JobManager.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/JobManager.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/JobManager.cpp 2012-05-14 14:15:12.220222200 +0200
-@@ -24,6 +24,9 @@
- #include "threads/SingleLock.h"
- #include "utils/log.h"
-
-+#include "system.h"
-+
-+
- using namespace std;
-
- bool CJob::ShouldCancel(unsigned int progress, unsigned int total) const
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/LCD.h xbmc-pvr-11.0.1.patch/xbmc/utils/LCD.h
---- xbmc-pvr-11.0.1/xbmc/utils/LCD.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/LCD.h 2012-05-14 14:15:12.221222220 +0200
-@@ -68,8 +68,9 @@
- void LoadSkin(const CStdString &xmlFile);
- void Reset();
- void Render(LCD_MODE mode);
-- ILCD() : m_disableOnPlay(DISABLE_ON_PLAY_NONE),
-- m_eCurrentCharset(CUSTOM_CHARSET_DEFAULT) {}
-+ ILCD() : CThread("ILCD"),
-+ m_disableOnPlay(DISABLE_ON_PLAY_NONE),
-+ m_eCurrentCharset(CUSTOM_CHARSET_DEFAULT) {}
- protected:
- virtual void Process() = 0;
- void StringToLCDCharSet(CStdString& strText);
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/Makefile xbmc-pvr-11.0.1.patch/xbmc/utils/Makefile
---- xbmc-pvr-11.0.1/xbmc/utils/Makefile 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/Makefile 2012-05-14 14:15:12.222222240 +0200
-@@ -59,6 +59,7 @@
- Weather.cpp \
- Win32Exception.cpp \
- XMLUtils.cpp \
-+ ActorProtocol.cpp \
-
- LIB=utils.a
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/RssReader.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/RssReader.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/RssReader.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/RssReader.cpp 2012-05-14 14:15:12.223222260 +0200
-@@ -44,7 +44,7 @@
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
-
--CRssReader::CRssReader() : CThread()
-+CRssReader::CRssReader() : CThread("CRssReader")
- {
- m_pObserver = NULL;
- m_spacesBetweenFeeds = 0;
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/RssReader.h xbmc-pvr-11.0.1.patch/xbmc/utils/RssReader.h
---- xbmc-pvr-11.0.1/xbmc/utils/RssReader.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/RssReader.h 2012-05-14 14:15:12.223222260 +0200
-@@ -39,6 +39,9 @@
-
- #include "tinyXML/tinyxml.h"
-
-+#include "system.h"
-+
-+
- #define RSS_COLOR_BODY 0
- #define RSS_COLOR_HEADLINE 1
- #define RSS_COLOR_CHANNEL 2
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/Splash.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/Splash.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/Splash.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/Splash.cpp 2012-05-14 14:15:12.224222280 +0200
-@@ -31,7 +31,7 @@
-
- using namespace XFILE;
-
--CSplash::CSplash(const CStdString& imageName)
-+CSplash::CSplash(const CStdString& imageName) : CThread("CSplash")
- {
- m_ImageName = imageName;
- fade = 0.5;
-@@ -139,5 +139,5 @@
-
- bool CSplash::IsRunning()
- {
-- return (m_ThreadHandle != NULL);
-+ return (IsRunning());
- }
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/TuxBoxUtil.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/TuxBoxUtil.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/TuxBoxUtil.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/TuxBoxUtil.cpp 2012-05-14 14:15:12.225222300 +0200
-@@ -48,7 +48,7 @@
- CTuxBoxUtil g_tuxbox;
- CTuxBoxService g_tuxboxService;
-
--CTuxBoxService::CTuxBoxService()
-+CTuxBoxService::CTuxBoxService() : CThread("CTuxBoxService")
- {
- }
- CTuxBoxService::~CTuxBoxService()
-diff -Naur xbmc-pvr-11.0.1/xbmc/video/dialogs/GUIDialogVideoSettings.cpp xbmc-pvr-11.0.1.patch/xbmc/video/dialogs/GUIDialogVideoSettings.cpp
---- xbmc-pvr-11.0.1/xbmc/video/dialogs/GUIDialogVideoSettings.cpp 2012-05-14 14:14:51.709808795 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/video/dialogs/GUIDialogVideoSettings.cpp 2012-05-14 14:15:12.226222321 +0200
-@@ -107,12 +107,12 @@
- entries.push_back(make_pair(VS_INTERLACEMETHOD_INVERSE_TELECINE , 16314));
- entries.push_back(make_pair(VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL , 16311));
- entries.push_back(make_pair(VS_INTERLACEMETHOD_VDPAU_TEMPORAL , 16310));
-- entries.push_back(make_pair(VS_INTERLACEMETHOD_VDPAU_BOB , 16021));
-+ entries.push_back(make_pair(VS_INTERLACEMETHOD_VDPAU_BOB , 16326));
- entries.push_back(make_pair(VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF, 16318));
- entries.push_back(make_pair(VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF , 16317));
-- entries.push_back(make_pair(VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE , 16314));
- entries.push_back(make_pair(VS_INTERLACEMETHOD_DXVA_BOB , 16320));
- entries.push_back(make_pair(VS_INTERLACEMETHOD_DXVA_BEST , 16321));
-+ entries.push_back(make_pair(VS_INTERLACEMETHOD_XVBA , 16327));
-
- /* remove unsupported methods */
- for(vector >::iterator it = entries.begin(); it != entries.end();)
-diff -Naur xbmc-pvr-11.0.1/xbmc/video/VideoInfoDownloader.cpp xbmc-pvr-11.0.1.patch/xbmc/video/VideoInfoDownloader.cpp
---- xbmc-pvr-11.0.1/xbmc/video/VideoInfoDownloader.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/video/VideoInfoDownloader.cpp 2012-05-14 14:15:12.227222342 +0200
-@@ -116,7 +116,7 @@
- m_state = FIND_MOVIE;
- m_strMovie = strMovie;
- m_found = 0;
-- if (ThreadHandle())
-+ if (IsRunning())
- StopThread();
- Create();
- while (m_state != DO_NOTHING)
-@@ -160,7 +160,7 @@
- { // threaded version
- m_state = GET_DETAILS;
- m_found = 0;
-- if (ThreadHandle())
-+ if (IsRunning())
- StopThread();
- Create();
- while (!m_found)
-@@ -195,7 +195,7 @@
- { // threaded version
- m_state = GET_EPISODE_DETAILS;
- m_found = 0;
-- if (ThreadHandle())
-+ if (IsRunning())
- StopThread();
- Create();
- while (!m_found)
-@@ -230,7 +230,7 @@
- { // threaded version
- m_state = GET_EPISODE_LIST;
- m_found = 0;
-- if (ThreadHandle())
-+ if (IsRunning())
- StopThread();
- Create();
- while (!m_found)
-diff -Naur xbmc-pvr-11.0.1/xbmc/video/VideoInfoDownloader.h xbmc-pvr-11.0.1.patch/xbmc/video/VideoInfoDownloader.h
---- xbmc-pvr-11.0.1/xbmc/video/VideoInfoDownloader.h 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/video/VideoInfoDownloader.h 2012-05-14 14:15:12.228222362 +0200
-@@ -42,7 +42,7 @@
- class CVideoInfoDownloader : public CThread
- {
- public:
-- CVideoInfoDownloader(const ADDON::ScraperPtr &scraper) : m_info(scraper) {}
-+ CVideoInfoDownloader(const ADDON::ScraperPtr &scraper) : CThread("CVideoInfoDownloader"), m_info(scraper) {}
- virtual ~CVideoInfoDownloader() {}
-
- // threaded lookup functions
-diff -Naur xbmc-pvr-11.0.1/xbmc/video/VideoInfoScanner.cpp xbmc-pvr-11.0.1.patch/xbmc/video/VideoInfoScanner.cpp
---- xbmc-pvr-11.0.1/xbmc/video/VideoInfoScanner.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/video/VideoInfoScanner.cpp 2012-05-14 14:15:12.229222382 +0200
-@@ -54,7 +54,7 @@
- namespace VIDEO
- {
-
-- CVideoInfoScanner::CVideoInfoScanner()
-+ CVideoInfoScanner::CVideoInfoScanner() : CThread("CVideoInfoScanner")
- {
- m_bRunning = false;
- m_pObserver = NULL;
-diff -Naur xbmc-pvr-11.0.1/xbmc/video/VideoReferenceClock.cpp xbmc-pvr-11.0.1.patch/xbmc/video/VideoReferenceClock.cpp
---- xbmc-pvr-11.0.1/xbmc/video/VideoReferenceClock.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/video/VideoReferenceClock.cpp 2012-05-14 14:15:12.231222422 +0200
-@@ -31,6 +31,7 @@
- #include
- #include
- #include "windowing/WindowingFactory.h"
-+ #include "settings/AdvancedSettings.h"
- #define NVSETTINGSCMD "nvidia-settings -nt -q RefreshRate3"
- #elif defined(__APPLE__) && !defined(__arm__)
- #include
-@@ -107,7 +108,7 @@
-
- #endif
-
--CVideoReferenceClock::CVideoReferenceClock()
-+CVideoReferenceClock::CVideoReferenceClock() : CThread("CVideoReferenceClock")
- {
- m_SystemFrequency = CurrentHostFrequency();
- m_ClockSpeed = 1.0;
-@@ -118,7 +119,7 @@
-
- #if defined(HAS_GLX) && defined(HAS_XRANDR)
- m_Dpy = NULL;
-- m_UseNvSettings = true;
-+ m_UseNvSettings = false;
- #endif
- }
-
-@@ -270,12 +271,21 @@
- return false;
- }
-
-+ m_bIsATI = false;
-+ m_bPolling = 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_bPolling = true;
-+ }
-+ if (g_advancedSettings.m_vblankPolling)
-+ {
-+ m_bPolling = true;
-+ CLog::Log(LOGDEBUG, "CVideoReferenceClock: use polling");
- }
-
- m_vInfo = glXChooseVisual(m_Dpy, DefaultScreen(m_Dpy), singleBufferAttributes);
-@@ -285,7 +295,7 @@
- return false;
- }
-
-- if (!m_bIsATI)
-+ if (!m_bPolling)
- {
- Swa.border_pixel = 0;
- Swa.event_mask = StructureNotifyMask;
-@@ -313,7 +323,7 @@
- return false;
- }
-
-- if (!m_bIsATI)
-+ if (!m_bPolling)
- ReturnV = glXMakeCurrent(m_Dpy, m_Window, m_Context);
- else
- ReturnV = glXMakeCurrent(m_Dpy, m_glPixmap, m_Context);
-@@ -324,7 +334,7 @@
- return false;
- }
-
-- if (!m_bIsATI)
-+ if (!m_bPolling)
- {
- m_glXWaitVideoSyncSGI = (int (*)(int, int, unsigned int*))glXGetProcAddress((const GLubyte*)"glXWaitVideoSyncSGI");
- if (!m_glXWaitVideoSyncSGI)
-@@ -369,6 +379,9 @@
- UpdateRefreshrate(true); //forced refreshrate update
- m_MissedVblanks = 0;
-
-+ if (m_bPolling)
-+ SetPriority(1);
-+
- return true;
- }
-
-@@ -567,7 +580,7 @@
- while(!m_bStop)
- {
- //wait for the next vblank
-- if (!m_bIsATI)
-+ if (!m_bPolling)
- {
- ReturnV = m_glXWaitVideoSyncSGI(2, (VblankCount + 1) % 2, &VblankCount);
- m_glXGetVideoSyncSGI(&VblankCount); //the vblank count returned by glXWaitVideoSyncSGI is not always correct
-@@ -591,7 +604,7 @@
- sleepTime = std::max(int(300000LL/m_RefreshRate), sleepTime);
-
- unsigned int iterations = 0;
-- while (VblankCount == PrevVblankCount && !m_bStop)
-+ while (VblankCount == PrevVblankCount && iterations < 500 && !m_bStop)
- {
- usleep(sleepTime);
- m_glXGetVideoSyncSGI(&VblankCount);
-@@ -652,7 +665,7 @@
- }
-
- CLog::Log(LOGDEBUG, "CVideoReferenceClock: Attaching glX context");
-- if (!m_bIsATI)
-+ if (!m_bPolling)
- ReturnV = glXMakeCurrent(m_Dpy, m_Window, m_Context);
- else
- ReturnV = glXMakeCurrent(m_Dpy, m_glPixmap, m_Context);
-@@ -1275,6 +1288,9 @@
-
- if (m_UseVblank) //when true the vblank is used as clock source
- {
-+ if (Target < m_CurrTime)
-+ Target = m_CurrTime + 0.5/m_RefreshRate;
-+
- while (m_CurrTime < Target)
- {
- //calculate how long to sleep before we should have gotten a signal that a vblank happened
-diff -Naur xbmc-pvr-11.0.1/xbmc/video/VideoReferenceClock.h xbmc-pvr-11.0.1.patch/xbmc/video/VideoReferenceClock.h
---- xbmc-pvr-11.0.1/xbmc/video/VideoReferenceClock.h 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/video/VideoReferenceClock.h 2012-05-14 14:15:12.232222442 +0200
-@@ -125,6 +125,7 @@
-
- bool m_UseNvSettings;
- bool m_bIsATI;
-+ bool m_bPolling;
-
- #elif defined(_WIN32) && defined(HAS_DX)
- bool SetupD3D();
-diff -Naur xbmc-pvr-11.0.1/xbmc/win32/PlatformDefs.h xbmc-pvr-11.0.1.patch/xbmc/win32/PlatformDefs.h
---- xbmc-pvr-11.0.1/xbmc/win32/PlatformDefs.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/win32/PlatformDefs.h 2012-05-14 14:15:12.232222442 +0200
-@@ -33,7 +33,6 @@
- typedef __int64 fpos64_t;
- typedef __int64 __off64_t;
- typedef long __off_t;
--typedef unsigned long ThreadIdentifier;
-
- #define ssize_t int
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/win32/WindowHelper.cpp xbmc-pvr-11.0.1.patch/xbmc/win32/WindowHelper.cpp
---- xbmc-pvr-11.0.1/xbmc/win32/WindowHelper.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/win32/WindowHelper.cpp 2012-05-14 14:15:12.233222462 +0200
-@@ -28,7 +28,7 @@
-
- CWHelper g_windowHelper;
-
--CWHelper::CWHelper(void)
-+CWHelper::CWHelper(void) : CThread("CWHelper")
- {
- m_hwnd = NULL;
- m_hProcess = NULL;
-diff -Naur xbmc-pvr-11.0.1/xbmc/windowing/X11/WinSystemX11.cpp xbmc-pvr-11.0.1.patch/xbmc/windowing/X11/WinSystemX11.cpp
---- xbmc-pvr-11.0.1/xbmc/windowing/X11/WinSystemX11.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/windowing/X11/WinSystemX11.cpp 2012-05-14 14:15:12.234222482 +0200
-@@ -35,6 +35,8 @@
- #include
- #include "cores/VideoRenderers/RenderManager.h"
- #include "utils/TimeUtils.h"
-+#include "settings/AdvancedSettings.h"
-+#include "settings/GUISettings.h"
-
- #if defined(HAS_XRANDR)
- #include
-@@ -52,6 +54,7 @@
- m_wmWindow = 0;
- m_bWasFullScreenBeforeMinimize = false;
- m_dpyLostTime = 0;
-+ m_internalModeSwitch = false;
-
- XSetErrorHandler(XErrorHandler);
- }
-@@ -178,6 +181,45 @@
- return false;
- }
-
-+void CWinSystemX11::RefreshWindow()
-+{
-+ // save current mode if this is not an internal request
-+ if (!m_internalModeSwitch)
-+ {
-+ CLog::Log(LOGNOTICE, "CWinSystemX11::RefreshWindow - external or initial xrandr event");
-+ m_xrandrOut = g_xrandr.GetCurrentOutput();
-+ m_xrandrMode = g_xrandr.GetCurrentMode(m_xrandrOut.name);
-+ }
-+ m_internalModeSwitch = false;
-+
-+ g_xrandr.Query(true);
-+ XOutput out = g_xrandr.GetCurrentOutput();
-+ XMode mode = g_xrandr.GetCurrentMode(out.name);
-+
-+ RESOLUTION_INFO res;
-+ unsigned int i;
-+ bool found(false);
-+ for (i = RES_DESKTOP; i < g_settings.m_ResInfo.size(); ++i)
-+ {
-+ if (g_settings.m_ResInfo[i].strId == mode.id)
-+ {
-+ found = true;
-+ break;
-+ }
-+ }
-+
-+ if (!found)
-+ {
-+ CLog::Log(LOGERROR, "CWinSystemX11::RefreshWindow - could not find resolution");
-+ return;
-+ }
-+
-+ g_graphicsContext.SetVideoResolution((RESOLUTION)i, true);
-+ g_guiSettings.SetInt("window.width", mode.w);
-+ g_guiSettings.SetInt("window.height", mode.h);
-+ g_settings.Save();
-+}
-+
- bool CWinSystemX11::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays)
- {
- m_nWidth = res.iWidth;
-@@ -193,13 +235,32 @@
- mode.hz = res.fRefreshRate;
- mode.id = res.strId;
-
-- if(m_bFullScreen)
-+ XOutput currout = g_xrandr.GetCurrentOutput();
-+ XMode currmode = g_xrandr.GetCurrentMode(currout.name);
-+
-+ if (m_xrandrOut.name.empty())
-+ {
-+ m_xrandrOut = currout;
-+ m_xrandrMode = currmode;
-+ }
-+
-+ if(!m_bFullScreen)
- {
-+ // reset to mode we had before internal mode switch
-+ out = m_xrandrOut;
-+ mode = m_xrandrMode;
-+ }
-+
-+ // only call xrandr if mode changes
-+ if (currout.name != out.name || currmode.w != mode.w || currmode.h != mode.h ||
-+ currmode.hz != mode.hz || currmode.id != mode.id)
-+ {
-+ CLog::Log(LOGNOTICE, "CWinSystemX11::SetFullScreen - calling xrandr");
- OnLostDevice();
-+ m_internalModeSwitch = true;
- g_xrandr.SetMode(out, mode);
- }
-- else
-- g_xrandr.RestoreState();
-+
- #endif
-
- int options = SDL_OPENGL;
-@@ -493,6 +554,7 @@
- if (bGotEvent || bTimeout)
- {
- CLog::Log(LOGDEBUG, "%s - notify display reset event", __FUNCTION__);
-+ RefreshWindow();
-
- CSingleLock lock(m_resourceSection);
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/windowing/X11/WinSystemX11.h xbmc-pvr-11.0.1.patch/xbmc/windowing/X11/WinSystemX11.h
---- xbmc-pvr-11.0.1/xbmc/windowing/X11/WinSystemX11.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/windowing/X11/WinSystemX11.h 2012-05-14 14:15:12.234222482 +0200
-@@ -27,6 +27,7 @@
- #include "utils/Stopwatch.h"
- #include
- #include "threads/CriticalSection.h"
-+#include "XRandR.h"
-
- class IDispResource;
-
-@@ -60,6 +61,9 @@
- // Local to WinSystemX11 only
- Display* GetDisplay() { return m_dpy; }
- GLXWindow GetWindow() { return m_glWindow; }
-+ GLXContext GetGlxContext() { return m_glContext; }
-+ Window GetWmWindow() { return m_wmWindow; }
-+ void RefreshWindow();
-
- protected:
- bool RefreshGlxContext();
-@@ -76,6 +80,9 @@
- CCriticalSection m_resourceSection;
- std::vector m_resources;
- uint64_t m_dpyLostTime;
-+ XOutput m_xrandrOut;
-+ XMode m_xrandrMode;
-+ bool m_internalModeSwitch;
-
- private:
- bool IsSuitableVisual(XVisualInfo *vInfo);
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.02-xvba_support-gcc-4.7.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.02-xvba_support-gcc-4.7.patch
deleted file mode 100644
index 078997f175..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.02-xvba_support-gcc-4.7.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-diff -Naur xbmc-11.0.1/xbmc/threads/platform/pthreads/ThreadImpl.h xbmc-11.0.1.patch/xbmc/threads/platform/pthreads/ThreadImpl.h
---- xbmc-11.0.1/xbmc/threads/platform/pthreads/ThreadImpl.h 2012-03-23 07:22:04.215885089 +0100
-+++ xbmc-11.0.1.patch/xbmc/threads/platform/pthreads/ThreadImpl.h 2012-03-23 07:24:07.875383186 +0100
-@@ -22,6 +22,7 @@
- #pragma once
-
- #include
-+#include
-
- struct threadOpaque
- {
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.11-disable_interop.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.11-disable_interop.patch
deleted file mode 100644
index 18b28b23f7..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.11-disable_interop.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Naur xbmc-11.0.1/xbmc/settings/GUIWindowSettingsCategory.cpp xbmc-11.0.1.patch/xbmc/settings/GUIWindowSettingsCategory.cpp
---- xbmc-11.0.1/xbmc/settings/GUIWindowSettingsCategory.cpp 2012-06-30 19:13:51.558262433 +0200
-+++ xbmc-11.0.1.patch/xbmc/settings/GUIWindowSettingsCategory.cpp 2012-06-30 19:59:14.545818328 +0200
-@@ -553,7 +553,7 @@
- {
- bool hasInterop = false;
- #ifdef GL_NV_vdpau_interop
-- hasInterop = true;
-+ hasInterop = false;
- #endif
- CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
- if (pControl && hasInterop && glewIsSupported("GL_NV_vdpau_interop"))
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.12-linuxrenderer_delete_texture_targets_on_reconfigure.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.12-linuxrenderer_delete_texture_targets_on_reconfigure.patch
deleted file mode 100644
index 5f4ae3111c..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-902.12-linuxrenderer_delete_texture_targets_on_reconfigure.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From 9687cc6b6f90fb40e39060eff9e4d8283254b770 Mon Sep 17 00:00:00 2001
-From: xbmc
-Date: Fri, 13 Jul 2012 18:57:37 +0200
-Subject: [PATCH] linuxrenderer: delete texture targets on reconfigure
-
----
- xbmc/cores/VideoRenderers/LinuxRendererGL.cpp | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
-index 7c46cfd..85fc50c 100644
---- a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
-+++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
-@@ -261,6 +261,12 @@ bool CLinuxRendererGL::ValidateRenderTarget()
- else
- CLog::Log(LOGNOTICE,"Using GL_TEXTURE_2D");
-
-+ // function pointer for texture might change in
-+ // call to LoadShaders
-+ glFinish();
-+ for (int i = 0 ; i < m_NumYV12Buffers ; i++)
-+ (this->*m_textureDelete)(i);
-+
- // create the yuv textures
- LoadShaders();
-
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-903.01-fixed_still_frames_at_the_start_of_a_VTS_in_dvd_could_end_up_not_showing.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-903.01-fixed_still_frames_at_the_start_of_a_VTS_in_dvd_could_end_up_not_showing.patch
deleted file mode 100644
index 0cfaf7fff4..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-903.01-fixed_still_frames_at_the_start_of_a_VTS_in_dvd_could_end_up_not_showing.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From 497941802e56121adf03428d964e225c80989afd Mon Sep 17 00:00:00 2001
-From: elupus
-Date: Sat, 7 Apr 2012 00:08:34 +0200
-Subject: [PATCH] fixed: still frames at the start of a VTS in dvd could end
- up not showing
-
-This occured due to a change in behavior in updated ffmpeg. Old code would
-return EOF once after a VTS change to trigger demuxer flush, however
-updated ffmpeg will read multiple times causing demuxer reset actions
-to get executed after actual data having been processed by demuxer.
----
- .../cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp | 7 +++++--
- 1 file changed, 5 insertions(+), 2 deletions(-)
-
-diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
-index dbdff52..3ae4843 100644
---- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
-+++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
-@@ -419,9 +419,12 @@ int CDVDInputStreamNavigator::ProcessBlock(BYTE* dest_buffer, int* read)
- iNavresult = NAVRESULT_HOLD;
- }
- else
-+ {
- iNavresult = m_pDVDPlayer->OnDVDNavResult(buf, DVDNAV_VTS_CHANGE);
--
-- m_bInMenu = (0 == m_dll.dvdnav_is_domain_vts(m_dvdnav));
-+ m_holdmode = HOLDMODE_HELD;
-+ m_lastevent = DVDNAV_NOP;
-+ m_bInMenu = (0 == m_dll.dvdnav_is_domain_vts(m_dvdnav));
-+ }
- }
- break;
-
---
-1.7.10
-
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-981-toggleButtonState.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-981-toggleButtonState.patch
deleted file mode 100644
index 17a606f1b1..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-981-toggleButtonState.patch
+++ /dev/null
@@ -1,304 +0,0 @@
-diff -Naur xbmc-f3b0020/xbmc/guilib/GUIToggleButtonControl.h xbmc-f3b0020.patch/xbmc/guilib/GUIToggleButtonControl.h
---- xbmc-f3b0020/xbmc/guilib/GUIToggleButtonControl.h 2011-12-10 22:16:22.000000000 +0100
-+++ xbmc-f3b0020.patch/xbmc/guilib/GUIToggleButtonControl.h 2011-12-17 18:43:42.183704449 +0100
-@@ -57,6 +57,7 @@
- virtual CStdString GetDescription() const;
- void SetToggleSelect(const CStdString &toggleSelect);
- void SetAltClickActions(const CGUIAction &clickActions);
-+ bool IsSelected() const { return m_bSelected; };
-
- protected:
- virtual bool UpdateColors();
-diff -Naur xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/control.h xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/control.h
---- xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/control.h 2011-12-10 22:16:21.000000000 +0100
-+++ xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/control.h 2011-12-17 18:43:42.216705084 +0100
-@@ -135,6 +135,11 @@
-
- typedef struct {
- PyObject_HEAD_XBMC_CONTROL
-+ bool bIsSelected;
-+ } ControlToggle;
-+
-+ typedef struct {
-+ PyObject_HEAD_XBMC_CONTROL
- std::string strFont;
- color_t textColor;
- std::vector vecLabels;
-@@ -263,7 +268,8 @@
- extern PyTypeObject ControlRadioButton_Type;
- extern PyTypeObject ControlSlider_Type;
- extern PyTypeObject ControlEdit_Type;
--
-+ extern PyTypeObject ControlToggle_Type;
-+
- CGUIControl* ControlLabel_Create(ControlLabel* pControl);
- CGUIControl* ControlFadeLabel_Create(ControlFadeLabel* pControl);
- CGUIControl* ControlTextBox_Create(ControlTextBox* pControl);
-@@ -276,6 +282,7 @@
- CGUIControl* ControlRadioButton_Create(ControlRadioButton* pControl);
- CGUIControl* ControlSlider_Create(ControlSlider* pControl);
- CGUIControl* ControlEdit_Create(ControlEdit* pControl);
-+ CGUIControl* ControlToggle_Create(ControlToggle* pControl);
-
- void initControl_Type();
- void initControlSpin_Type();
-@@ -291,6 +298,7 @@
- void initControlRadioButton_Type();
- void initControlSlider_Type();
- void initControlEdit_Type();
-+ void initControlToggle_Type();
- }
-
- #ifdef __cplusplus
-diff -Naur xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/controltogglebutton.cpp xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/controltogglebutton.cpp
---- xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/controltogglebutton.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/controltogglebutton.cpp 2011-12-17 18:43:42.217705104 +0100
-@@ -0,0 +1,181 @@
-+/*
-+ * 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
-+ *
-+ */
-+
-+#include
-+
-+#include "guilib/GUIToggleButtonControl.h"
-+#include "guilib/GUIFontManager.h"
-+#include "control.h"
-+#include "pyutil.h"
-+
-+using namespace std;
-+
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+
-+namespace PYXBMC
-+{
-+ PyObject* ControlToggle_New(
-+ PyTypeObject *type,
-+ PyObject *args,
-+ PyObject *kwds )
-+ {
-+ static const char *keywords[] = {
-+ "x", "y", "width", "height", "label",
-+ "focusTexture", "noFocusTexture",
-+ "textOffsetX", "textOffsetY", "alignment",
-+ "font", "textColor", "disabledColor", "angle", "shadowColor", "focusedColor", NULL };
-+ ControlToggle *self;
-+ char* cFont = NULL;
-+ char* cTextureFocus = NULL;
-+ char* cTextureNoFocus = NULL;
-+ char* cTextColor = NULL;
-+ char* cDisabledColor = NULL;
-+ char* cShadowColor = NULL;
-+ char* cFocusedColor = NULL;
-+
-+ PyObject* pObjectText;
-+
-+ self = (ControlToggle*)type->tp_alloc(type, 0);
-+ if (!self) return NULL;
-+ new(&self->bIsSelected) bool();
-+
-+ if (!PyArg_ParseTupleAndKeywords(
-+ args,
-+ kwds,
-+ (char*)"llllO|sslllssslss",
-+ (char**)keywords,
-+ &self->dwPosX,
-+ &self->dwPosY,
-+ &self->dwWidth,
-+ &self->dwHeight,
-+ &pObjectText,
-+ &cTextureFocus,
-+ &cTextureNoFocus,
-+ &cFont,
-+ &cTextColor,
-+ &cDisabledColor,
-+ &cShadowColor,
-+ &cFocusedColor))
-+ {
-+ Py_DECREF( self );
-+ return NULL;
-+ }
-+
-+
-+ cTextureFocus :
-+ PyXBMCGetDefaultImage((char*)"button", (char*)"texturefocus", (char*)"button-focus.png");
-+ cTextureNoFocus :
-+ PyXBMCGetDefaultImage((char*)"button", (char*)"texturenofocus", (char*)"button-nofocus.jpg");
-+
-+ return (PyObject*)self;
-+ }
-+
-+ void ControlToggle_Dealloc(ControlToggle* self)
-+ {
-+ self->ob_type->tp_free((PyObject*)self);
-+ }
-+
-+
-+ // isSelected() Method
-+ PyDoc_STRVAR(isSelected__doc__,
-+ "isSelected() -- Returns the toggle buttons's selected status.\n"
-+ "\n"
-+ "example:\n"
-+ " - is = self.togglebutton.isSelected()\n");
-+
-+ PyObject* ControlToggle_IsSelected(ControlToggle *self, PyObject *args)
-+ {
-+ bool isSelected = false;
-+
-+ PyXBMCGUILock();
-+ if (self->pGUIControl)
-+ isSelected = ((CGUIToggleButtonControl*)self->pGUIControl)->IsSelected();
-+ PyXBMCGUIUnlock();
-+
-+ return Py_BuildValue((char*)"b", isSelected);
-+ }
-+
-+
-+ PyMethodDef ControlToggle_methods[] = {
-+ {(char*)"isSelected", (PyCFunction)ControlToggle_IsSelected, METH_VARARGS, isSelected__doc__},
-+ {NULL, NULL, 0, NULL}
-+ };
-+
-+ // ControlRadioButton class
-+ PyDoc_STRVAR(ControlToggle__doc__,
-+ "ControlRadioButton class.\n"
-+ "\n"
-+ "ControlRadioButton(x, y, width, height, label[, focusTexture, noFocusTexture, textOffsetX, textOffsetY,\n"
-+ " alignment, font, textColor, disabledColor, angle, shadowColor, focusedColor,\n"
-+ " radioFocusTexture, noRadioFocusTexture])\n"
-+ "\n"
-+ "x : integer - x coordinate of control.\n"
-+ "y : integer - y coordinate of control.\n"
-+ "width : integer - width of control.\n"
-+ "height : integer - height of control.\n"
-+ "label : string or unicode - text string.\n"
-+ "focusTexture : [opt] string - filename for focus texture.\n"
-+ "noFocusTexture : [opt] string - filename for no focus texture.\n"
-+ "textOffsetX : [opt] integer - x offset of label.\n"
-+ "textOffsetY : [opt] integer - y offset of label.\n"
-+ "alignment : [opt] integer - alignment of label - *Note, see xbfont.h\n"
-+ "font : [opt] string - font used for label text. (e.g. 'font13')\n"
-+ "textColor : [opt] hexstring - color of enabled radio button's label. (e.g. '0xFFFFFFFF')\n"
-+ "disabledColor : [opt] hexstring - color of disabled radio button's label. (e.g. '0xFFFF3300')\n"
-+ "angle : [opt] integer - angle of control. (+ rotates CCW, - rotates CW)\n"
-+ "shadowColor : [opt] hexstring - color of radio button's label's shadow. (e.g. '0xFF000000')\n"
-+ "focusedColor : [opt] hexstring - color of focused radio button's label. (e.g. '0xFF00FFFF')\n"
-+ "radioFocusTexture : [opt] string - filename for radio focus texture.\n"
-+ "noRadioFocusTexture : [opt] string - filename for radio no focus texture.\n"
-+ "\n"
-+ "*Note, You can use the above as keywords for arguments and skip certain optional arguments.\n"
-+ " Once you use a keyword, all following arguments require the keyword.\n"
-+ " After you create the control, you need to add it to the window with addControl().\n"
-+ "\n"
-+ "example:\n"
-+ " - self.radiobutton = xbmcgui.ControlToggleButton(100, 250, 200, 50, 'Status', font='font14')\n");
-+
-+ // Restore code and data sections to normal.
-+
-+ PyTypeObject ControlToggle_Type;
-+
-+ void initControlToggle_Type()
-+ {
-+ PyXBMCInitializeTypeObject(&ControlToggle_Type);
-+
-+ ControlToggle_Type.tp_name = (char*)"xbmcgui.ControlToggleButton";
-+ ControlToggle_Type.tp_basicsize = sizeof(ControlToggle);
-+ ControlToggle_Type.tp_dealloc = (destructor)ControlToggle_Dealloc;
-+ ControlToggle_Type.tp_compare = 0;
-+ ControlToggle_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
-+ ControlToggle_Type.tp_doc = ControlToggle__doc__;
-+ ControlToggle_Type.tp_methods = ControlToggle_methods;
-+ ControlToggle_Type.tp_base = &Control_Type;
-+ ControlToggle_Type.tp_new = ControlToggle_New;
-+ }
-+}
-+
-+#ifdef __cplusplus
-+}
-+#endif
-diff -Naur xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/Makefile.in xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/Makefile.in
---- xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/Makefile.in 2011-12-10 22:16:21.000000000 +0100
-+++ xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/Makefile.in 2011-12-17 18:44:47.447960296 +0100
-@@ -13,6 +13,7 @@
- controlslider.cpp \
- controlspin.cpp \
- controltextbox.cpp \
-+ controltogglebutton.cpp \
- dialog.cpp \
- GUIPythonWindow.cpp \
- GUIPythonWindowDialog.cpp \
-diff -Naur xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/window.cpp xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/window.cpp
---- xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/window.cpp 2011-12-10 22:16:21.000000000 +0100
-+++ xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/window.cpp 2011-12-17 18:43:42.218705123 +0100
-@@ -277,6 +277,12 @@
- if (li.font) ((ControlEdit*)pControl)->strFont = li.font->GetFontName();
- ((ControlButton*)pControl)->align = li.align;
- break;
-+ case CGUIControl::GUICONTROL_TOGGLEBUTTON:
-+ pControl = (Control*)ControlToggle_Type.tp_alloc(&ControlToggle_Type, 0);
-+ new(&((ControlToggle*)pControl)->bIsSelected) bool();
-+
-+ break;
-+
- default:
- break;
- }
-diff -Naur xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/xbmcguimodule.cpp xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/xbmcguimodule.cpp
---- xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/xbmcguimodule.cpp 2011-12-10 22:16:21.000000000 +0100
-+++ xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/xbmcguimodule.cpp 2011-12-17 18:43:42.219705142 +0100
-@@ -138,6 +138,7 @@
- initAction_Type();
- initControlRadioButton_Type();
- initControlEdit_Type();
-+ initControlToggle_Type();
-
- if (PyType_Ready(&Window_Type) < 0 ||
- PyType_Ready(&WindowDialog_Type) < 0 ||
-@@ -160,7 +161,8 @@
- PyType_Ready(&ControlSlider_Type) < 0 ||
- PyType_Ready(&ControlRadioButton_Type) < 0 ||
- PyType_Ready(&ControlEdit_Type) < 0 ||
-- PyType_Ready(&Action_Type) < 0)
-+ PyType_Ready(&Action_Type) < 0 ||
-+ PyType_Ready(&ControlToggle_Type) < 0)
- return;
-
- }
-@@ -200,6 +202,7 @@
- Py_INCREF(&Action_Type);
- Py_INCREF(&ControlRadioButton_Type);
- Py_INCREF(&ControlEdit_Type);
-+ Py_INCREF(&ControlToggle_Type);
-
- pXbmcGuiModule = Py_InitModule3((char*)"xbmcgui", xbmcGuiMethods, xbmcgui_module_documentation);
-
-@@ -227,7 +230,8 @@
- PyModule_AddObject(pXbmcGuiModule, (char*)"Action", (PyObject *)&Action_Type);
- PyModule_AddObject(pXbmcGuiModule, (char*)"ControlRadioButton", (PyObject*)&ControlRadioButton_Type);
- PyModule_AddObject(pXbmcGuiModule, (char*)"ControlEdit", (PyObject*)&ControlEdit_Type);
--
-+ PyModule_AddObject(pXbmcGuiModule, (char*)"ControlToggle", (PyObject*)&ControlToggle_Type);
-+
- PyModule_AddStringConstant(pXbmcGuiModule, (char*)"__author__", (char*)PY_XBMC_AUTHOR);
- PyModule_AddStringConstant(pXbmcGuiModule, (char*)"__date__", (char*)"14 July 2006");
- PyModule_AddStringConstant(pXbmcGuiModule, (char*)"__version__", (char*)"1.2");
-diff -Naur xbmc-f3b0020/XBMC.xcodeproj/project.pbxproj xbmc-f3b0020.patch/XBMC.xcodeproj/project.pbxproj
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-982-UDisk-device-must-be-remount-in-DeviceChanged-event.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-982-UDisk-device-must-be-remount-in-DeviceChanged-event.patch
deleted file mode 100644
index 8a8a5d49e8..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-982-UDisk-device-must-be-remount-in-DeviceChanged-event.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From f025c39679b438cb91a0ef0f205736ff92fddeac Mon Sep 17 00:00:00 2001
-From: Vic Lee
-Date: Thu, 10 Feb 2011 09:36:15 +0800
-Subject: [PATCH 5/5] UDisk: device must be remount in DeviceChanged event
-
-
-Signed-off-by: Vic Lee
----
- xbmc/linux/UDisksProvider.cpp | 2 ++
- 1 files changed, 2 insertions(+), 0 deletions(-)
-
-diff --git a/xbmc/storage/linux/UDisksProvider.cpp b/xbmc/storage/linux/UDisksProvider.cpp
-index 8e9b378..e24502a 100644
---- a/xbmc/storage/linux/UDisksProvider.cpp
-+++ b/xbmc/storage/linux/UDisksProvider.cpp
-@@ -368,6 +368,8 @@ void CUDisksProvider::DeviceChanged(const char *object, IStorageEventsCallback *
- {
- bool mounted = device->m_isMounted;
- device->Update();
-+ if (g_advancedSettings.m_handleMounting)
-+ device->Mount();
- if (!mounted && device->m_isMounted && callback)
- callback->OnStorageAdded(device->m_Label, device->m_MountPath);
- else if (mounted && !device->m_isMounted && callback)
---
-1.7.2.3
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-983-fixed-failure-to-broswe-for-smb-shares.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-983-fixed-failure-to-broswe-for-smb-shares.patch
deleted file mode 100644
index 24af12df39..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-983-fixed-failure-to-broswe-for-smb-shares.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From f52dd9a555e8e4b087ec6fbf040dc1f1155c4136 Mon Sep 17 00:00:00 2001
-From: "S. Davilla"
-Date: Sat, 21 Apr 2012 14:11:56 -0400
-Subject: [PATCH] fixed, failure to broswe for smb shares. this hits all 1st
- time installs
-
----
- xbmc/filesystem/SmbFile.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/xbmc/filesystem/FileSmb.cpp b/xbmc/filesystem/FileSmb.cpp
-index 382553c..c390031 100644
---- a/xbmc/filesystem/FileSmb.cpp
-+++ b/xbmc/filesystem/FileSmb.cpp
-@@ -61,7 +61,6 @@ SMBCSRV* xb_smbc_cache(SMBCCTX* c, const char* server, const char* share, const
- m_IdleTimeout = 0;
- #endif
- m_context = NULL;
-- smbc_init(xb_smbc_auth, 0);
- }
-
- CSMB::~CSMB()
-@@ -149,6 +148,10 @@ void CSMB::Init()
- }
- #endif
-
-+ // reads smb.conf so this MUST be after we create smb.conf
-+ // multiple smbc_init calls are ignored by libsmbclient.
-+ smbc_init(xb_smbc_auth, 0);
-+
- #ifdef TARGET_WINDOWS
- // set the log function
- set_log_callback(xb_smbc_log);
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-984-do-not-remount-non-optical-devices-in-DeviceChanged-event.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-984-do-not-remount-non-optical-devices-in-DeviceChanged-event.patch
deleted file mode 100644
index 6163872d60..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-984-do-not-remount-non-optical-devices-in-DeviceChanged-event.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/xbmc/storage/linux/UDisksProvider.cpp b/xbmc/storage/linux/UDisksProvider.cpp
-index 6afc1a8..c940e69 100644
---- a/xbmc/storage/linux/UDisksProvider.cpp
-+++ b/xbmc/storage/linux/UDisksProvider.cpp
-@@ -356,7 +356,7 @@ void CUDisksProvider::DeviceChanged(const char *object, IStorageEventsCallback *
- {
- bool mounted = device->m_isMounted;
- device->Update();
-- if (g_advancedSettings.m_handleMounting)
-+ if (g_advancedSettings.m_handleMounting && device->m_isOptical)
- device->Mount();
- if (!mounted && device->m_isMounted && callback)
- callback->OnStorageAdded(device->m_Label, device->m_MountPath);
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-990-wiimote.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-990-wiimote.patch
deleted file mode 100644
index 05379ebdf6..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-990-wiimote.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/tools/EventClients/Clients/WiiRemote/WiiUse_WiiRemote.h b/tools/EventClients/Clients/WiiRemote/WiiUse_WiiRemote.h
-index dbdbb94..6f68715 100644
---- a/tools/EventClients/Clients/WiiRemote/WiiUse_WiiRemote.h
-+++ b/tools/EventClients/Clients/WiiRemote/WiiUse_WiiRemote.h
-@@ -27,7 +27,7 @@
- #include "../../lib/c++/xbmcclient.h"
- #endif
- //#ifndef WIN32
--// #include
-+ #include
- //#endif
- #include "wiiuse.h"
- //#define ICON_PATH "../../"
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-991-set_wakeup_at_timer_at_suspend_or_hibernate.patch.disable b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-991-set_wakeup_at_timer_at_suspend_or_hibernate.patch.disable
deleted file mode 100644
index f2cbebb687..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-991-set_wakeup_at_timer_at_suspend_or_hibernate.patch.disable
+++ /dev/null
@@ -1,101 +0,0 @@
-diff --git a/xbmc/ApplicationMessenger.cpp b/xbmc/ApplicationMessenger.cpp
-index 7ef2027..bea711b 100644
---- a/xbmc/ApplicationMessenger.cpp
-+++ b/xbmc/ApplicationMessenger.cpp
-@@ -73,6 +73,9 @@
- #include "utils/JobManager.h"
- #include "storage/DetectDVDType.h"
-
-+#include "pvr/PVRManager.h"
-+
-+using namespace PVR;
- using namespace std;
-
- CDelayedMessage::CDelayedMessage(ThreadMessage& msg, unsigned int delay)
-@@ -261,12 +264,14 @@ void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg)
-
- case TMSG_HIBERNATE:
- {
-+ g_PVRManager.SetWakeupCommand();
- g_powerManager.Hibernate();
- }
- break;
-
- case TMSG_SUSPEND:
- {
-+ g_PVRManager.SetWakeupCommand();
- g_powerManager.Suspend();
- }
- break;
-diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h
-index 94a8c9a..99280c6 100644
---- a/xbmc/pvr/PVRManager.h
-+++ b/xbmc/pvr/PVRManager.h
-@@ -450,6 +450,11 @@ namespace PVR
- */
- void LoadCurrentChannelSettings(void);
-
-+ /*!
-+ * @brief Executes "pvrpowermanagement.setwakeupcmd"
-+ */
-+ bool SetWakeupCommand(void);
-+
- protected:
- /*!
- * @brief PVR update and control thread.
-@@ -525,11 +530,6 @@ namespace PVR
- void ShowProgressDialog(const CStdString &strText, int iProgress);
-
- /*!
-- * @brief Executes "pvrpowermanagement.setwakeupcmd"
-- */
-- bool SetWakeupCommand(void);
--
-- /*!
- * @brief Hide the progress dialog if it's visible.
- */
- void HideProgressDialog(void);
-diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp
-index cfba9bb..4e757d6 100644
---- a/xbmc/pvr/timers/PVRTimers.cpp
-+++ b/xbmc/pvr/timers/PVRTimers.cpp
-@@ -714,8 +714,7 @@ CDateTime CPVRTimers::GetNextEventTime(void) const
- const CDateTimeSpan prewakeup(0, 0, g_guiSettings.GetInt("pvrpowermanagement.prewakeup"), 0);
- const CDateTimeSpan idle(0, 0, g_guiSettings.GetInt("pvrpowermanagement.backendidletime"), 0);
-
-- CDateTime timerwakeuptime;
-- CDateTime dailywakeuptime;
-+ CDateTime retVal;
-
- /* Check next active time */
- CPVRTimerInfoTag timer;
-@@ -724,15 +723,16 @@ CDateTime CPVRTimers::GetNextEventTime(void) const
- const CDateTime start = timer.StartAsUTC();
-
- if ((start - idle) > now) {
-- timerwakeuptime = start - prewakeup;
-+ retVal = start - prewakeup;
- } else {
-- timerwakeuptime = now + idle;
-+ retVal = now + idle;
- }
- }
-
- /* check daily wake up */
- if (dailywakup)
- {
-+ CDateTime dailywakeuptime;
- dailywakeuptime.SetFromDBTime(g_guiSettings.GetString("pvrpowermanagement.dailywakeuptime", false));
- dailywakeuptime = dailywakeuptime.GetAsUTCDateTime();
-
-@@ -746,8 +746,9 @@ CDateTime CPVRTimers::GetNextEventTime(void) const
- const CDateTimeSpan oneDay(1,0,0,0);
- dailywakeuptime += oneDay;
- }
-+ if (dailywakeuptime < retVal)
-+ retVal = dailywakeuptime;
- }
-
-- const CDateTime retVal((dailywakeuptime < timerwakeuptime) ? dailywakeuptime : timerwakeuptime);
- return retVal;
- }
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-999-crosscompile.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-999-crosscompile.patch
deleted file mode 100644
index 9c73a9644e..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-999-crosscompile.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-diff --git a/Makefile.include.in b/Makefile.include.in
-index b70245d..0537b86 100644
---- a/Makefile.include.in
-+++ b/Makefile.include.in
-@@ -1,4 +1,4 @@
--AR=ar
-+AR=@AR@
- ARFLAGS=crus
- RM=rm -rf
- SHELL=@SHELL@
-diff --git a/configure.in b/configure.in
-index 7348529..baea8e0 100755
---- a/configure.in
-+++ b/configure.in
-@@ -22,7 +22,7 @@ AC_DEFUN([XB_FIND_SONAME],
- AC_MSG_CHECKING([for lib$2 soname])
- $1_FILENAME=$($CC -nostdlib -o /dev/null $LDFLAGS -l$2 -Wl,-M 2>/dev/null | grep "^LOAD.*$2" | awk '{V=2; print $V}')
- if [[ ! -z $$1_FILENAME ]]; then
-- $1_SONAME=$(objdump -p $$1_FILENAME | grep "SONAME.*$2" | awk '{V=2; print $V}')
-+ $1_SONAME=$($OBJDUMP -p $$1_FILENAME | grep "SONAME.*$2" | awk '{V=2; print $V}')
- fi
- else
- AC_MSG_CHECKING([for lib$2 dylib])
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-999.002-268d6a0-fix_ASIC_hang.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-999.002-268d6a0-fix_ASIC_hang.patch
deleted file mode 100644
index 9f209e8e04..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-999.002-268d6a0-fix_ASIC_hang.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 268d6a01b6a7dea0d53b042c246c95e87f4fc3d8 Mon Sep 17 00:00:00 2001
-From: xbmc
-Date: Thu, 26 Jul 2012 15:43:24 +0200
-Subject: [PATCH] move deleting gl textures to TextureManager, fixes asic hang
- on AMD
-
----
- xbmc/Application.cpp | 4 ++--
- xbmc/guilib/GUIFontTTFGL.cpp | 3 ++-
- xbmc/guilib/TextureManager.cpp | 13 +++++++++++++
- xbmc/guilib/TextureManager.h | 2 ++
- 4 files changed, 19 insertions(+), 3 deletions(-)
-
-diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp
-index 71d8a4e..b66459a 100644
---- a/xbmc/Application.cpp
-+++ b/xbmc/Application.cpp
-@@ -2231,8 +2231,6 @@ void CApplication::Render()
-
- g_Windowing.EndRender();
-
-- g_TextureManager.FreeUnusedTextures();
--
- // reset our info cache - we do this at the end of Render so that it is
- // fresh for the next process(), or after a windowclose animation (where process()
- // isn't called)
-@@ -2270,6 +2268,8 @@ void CApplication::Render()
- }
- CTimeUtils::UpdateFrameTime(flip);
-
-+ g_TextureManager.FreeUnusedTextures();
-+
- g_renderManager.UpdateResolution();
- g_renderManager.ManageCaptures();
- }
-diff --git a/xbmc/guilib/GUIFontTTFGL.cpp b/xbmc/guilib/GUIFontTTFGL.cpp
-index 87e07ca..6c93eb8 100644
---- a/xbmc/guilib/GUIFontTTFGL.cpp
-+++ b/xbmc/guilib/GUIFontTTFGL.cpp
-@@ -24,6 +24,7 @@
- #include "GUIFontTTFGL.h"
- #include "GUIFontManager.h"
- #include "Texture.h"
-+#include "TextureManager.h"
- #include "GraphicContext.h"
- #include "gui3d.h"
- #include "utils/log.h"
-@@ -234,7 +235,7 @@ void CGUIFontTTFGL::DeleteHardwareTexture()
- if (m_bTextureLoaded)
- {
- if (glIsTexture(m_nTexture))
-- glDeleteTextures(1, (GLuint*) &m_nTexture);
-+ g_TextureManager.ReleaseHwTexture(m_nTexture);
- m_bTextureLoaded = false;
- }
- }
-diff --git a/xbmc/guilib/TextureManager.cpp b/xbmc/guilib/TextureManager.cpp
-index 9ef7889..ccd0d03 100644
---- a/xbmc/guilib/TextureManager.cpp
-+++ b/xbmc/guilib/TextureManager.cpp
-@@ -457,6 +457,19 @@ void CGUITextureManager::FreeUnusedTextures()
- for (ivecTextures i = m_unusedTextures.begin(); i != m_unusedTextures.end(); ++i)
- delete *i;
- m_unusedTextures.clear();
-+
-+#if defined(HAS_GL) || defined(HAS_GLES)
-+ for (unsigned int i = 0; i < m_unusedHwTextures.size(); ++i)
-+ {
-+ glDeleteTextures(1, (GLuint*) &m_unusedHwTextures[i]);
-+ }
-+#endif
-+ m_unusedHwTextures.clear();
-+}
-+
-+void CGUITextureManager::ReleaseHwTexture(unsigned int texture)
-+{
-+ m_unusedHwTextures.push_back(texture);
- }
-
- void CGUITextureManager::Cleanup()
-diff --git a/xbmc/guilib/TextureManager.h b/xbmc/guilib/TextureManager.h
-index dd47f48..001f470 100644
---- a/xbmc/guilib/TextureManager.h
-+++ b/xbmc/guilib/TextureManager.h
-@@ -124,9 +124,11 @@ class CGUITextureManager
- void RemoveTexturePath(const CStdString &texturePath); ///< Remove a path from the paths to check when loading media
-
- void FreeUnusedTextures(); ///< Free textures (called from app thread only)
-+ void ReleaseHwTexture(unsigned int texture);
- protected:
- std::vector m_vecTextures;
- std::vector m_unusedTextures;
-+ std::vector m_unusedHwTextures;
- typedef std::vector::iterator ivecTextures;
- // we have 2 texture bundles (one for the base textures, one for the theme)
- CTextureBundle m_TexBundle[2];
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-999.003-rar-PR1147.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-999.003-rar-PR1147.patch
deleted file mode 100644
index a6a73bf20c..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-999.003-rar-PR1147.patch
+++ /dev/null
@@ -1,148 +0,0 @@
-From f01f95af95f287847c850572abe16b6969967ba7 Mon Sep 17 00:00:00 2001
-From: Anssi Hannula
-Date: Wed, 16 May 2012 19:01:17 +0300
-Subject: [PATCH 1/3] fixed: crashes with corrupted rar files
-
-UnrarXLib does not handle invalid files gracefully enough, and some
-files can cause it to tell CRarFile that it has written more data into
-its buffer than actually fits there, causing CRarFile::Read() to
-eventually overread the buffer.
-
-Add checks in CRarFile for the validity of byte counts retrieved from
-UnrarXLib to prevent crashes in such situations.
-(cherry picked from commit ca9457286994ef0b021744797b8d78fb78260436)
----
- xbmc/filesystem/FileRar.cpp | 17 +++++++++++++++++
- 1 file changed, 17 insertions(+)
-
-diff --git a/xbmc/filesystem/FileRar.cpp b/xbmc/filesystem/FileRar.cpp
-index 9c87a35..d026f8f 100644
---- a/xbmc/filesystem/FileRar.cpp
-+++ b/xbmc/filesystem/FileRar.cpp
-@@ -310,6 +310,14 @@ unsigned int CFileRar::Read(void *lpBuf, int64_t uiBufSize)
-
- m_iDataInBuffer = MAXWINMEMSIZE-m_pExtract->GetDataIO().UnpackToMemorySize;
-
-+ if (m_iDataInBuffer < 0 ||
-+ m_iDataInBuffer > MAXWINMEMSIZE - (m_szStartOfBuffer - m_szBuffer))
-+ {
-+ // invalid data returned by UnrarXLib, prevent a crash
-+ CLog::Log(LOGERROR, "CRarFile::Read - Data buffer in inconsistent state");
-+ m_iDataInBuffer = 0;
-+ }
-+
- if (m_iDataInBuffer == 0)
- break;
-
-@@ -471,6 +479,15 @@ int64_t CFileRar::Seek(int64_t iFilePosition, int iWhence)
- }
- m_iDataInBuffer = m_pExtract->GetDataIO().m_iSeekTo; // keep data
- m_iBufferStart = m_pExtract->GetDataIO().m_iStartOfBuffer;
-+
-+ if (m_iDataInBuffer < 0 || m_iDataInBuffer > MAXWINMEMSIZE)
-+ {
-+ // invalid data returned by UnrarXLib, prevent a crash
-+ CLog::Log(LOGERROR, "CRarFile::Seek - Data buffer in inconsistent state");
-+ m_iDataInBuffer = 0;
-+ return -1;
-+ }
-+
- m_szStartOfBuffer = m_szBuffer+MAXWINMEMSIZE-m_iDataInBuffer;
- m_iFilePosition = iFilePosition;
-
---
-1.7.10
-
-
-From de1be4534cf410896b3102f95b6e02019ed64a90 Mon Sep 17 00:00:00 2001
-From: Anssi Hannula
-Date: Wed, 16 May 2012 17:13:07 +0300
-Subject: [PATCH 2/3] fixed: rars that have unpacked size stored on first
- volume only
-
-Some multi-volume RAR files have their unpacked size set as 0 in all
-volumes except the first one.
-
-Use the previous unpacked size instead of 0 in such cases in order to
-support such files properly.
-(cherry picked from commit 683457d27736c09415a11d80933553f75139a253)
----
- lib/UnrarXLib/volume.cpp | 8 ++++++++
- 1 file changed, 8 insertions(+)
-
-diff --git a/lib/UnrarXLib/volume.cpp b/lib/UnrarXLib/volume.cpp
-index 1f4d5e3..b24e98b 100644
---- a/lib/UnrarXLib/volume.cpp
-+++ b/lib/UnrarXLib/volume.cpp
-@@ -15,6 +15,7 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,char Comman
- Log(Arc.FileName,St(MDataBadCRC),hd->FileName,Arc.FileName);
- }
-
-+ Int64 PrevFullUnpSize = hd->FullUnpSize;
- Int64 PosBeforeClose=Arc.Tell();
- Arc.Close();
-
-@@ -144,6 +145,13 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,char Comman
- }
- }
- #endif
-+
-+ if (hd->FullUnpSize == 0)
-+ {
-+ // some archives only have correct UnpSize in the first volume
-+ hd->FullUnpSize = PrevFullUnpSize;
-+ }
-+
- if (DataIO!=NULL)
- {
- if (HeaderType==ENDARC_HEAD)
---
-1.7.10
-
-
-From d7bed5ddbbc98d7fedac663410d8e7e64bdf20c7 Mon Sep 17 00:00:00 2001
-From: Anssi Hannula
-Date: Wed, 16 May 2012 00:14:49 +0300
-Subject: [PATCH 3/3] fixed: CRarFile::Read() returning wrong data after some
- seek patterns
-
-Certain seek patterns on a file inside a non-compressed rar file can
-cause CmdExtract::UnstoreFile() to think that the destination buffer has
-been filled (as DestUnpSize counter, originally set to the file size,
-reaches zero).
-
-However, counting written bytes using DestUnpSize doesn't make sense for
-the UnpackToMemory codepath used for non-compressed rar files, as there
-can be seeks which can eventually cause more data to be read than what
-the actual file size was. The actual output buffer is internally handled
-by ComprDataIO.
-
-The check in UnstoreFile() will result in not all data being written to
-the destination buffer, causing CRarFile::Read() to return old stale
-data.
-
-Fix that by dropping the unnecessary DestUnpSize handling in
-UnpackToMemory codepath of CmdExtract::UnstoreFile().
-(cherry picked from commit 840cd4ce4ac8c781e7d35db2ed86d575a42c37e7)
----
- lib/UnrarXLib/extract.cpp | 3 ---
- 1 file changed, 3 deletions(-)
-
-diff --git a/lib/UnrarXLib/extract.cpp b/lib/UnrarXLib/extract.cpp
-index b4a8091..368a899 100644
---- a/lib/UnrarXLib/extract.cpp
-+++ b/lib/UnrarXLib/extract.cpp
-@@ -863,10 +863,7 @@ void CmdExtract::UnstoreFile(ComprDataIO &DataIO,Int64 DestUnpSize)
- }
- if (Code > 0)
- {
-- Code=Code=0)
-- DestUnpSize-=Code;
- }
- else
- {
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-999.011-airtunes_reapply_lost_fix.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-999.011-airtunes_reapply_lost_fix.patch
deleted file mode 100644
index 4885fe33e9..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-999.011-airtunes_reapply_lost_fix.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From ab175ba28508445f6aff57386a8ce04b58a86f60 Mon Sep 17 00:00:00 2001
-From: Memphiz
-Date: Fri, 11 May 2012 19:56:37 +0200
-Subject: [PATCH] [fix] - reapply fix for airtunes with AE which was lost
- during merge
-
----
- xbmc/network/AirTunesServer.cpp | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/xbmc/network/AirTunesServer.cpp b/xbmc/network/AirTunesServer.cpp
-index 285a0a6..a60ad09 100644
---- a/xbmc/network/AirTunesServer.cpp
-+++ b/xbmc/network/AirTunesServer.cpp
-@@ -125,11 +125,11 @@ ao_device* CAirTunesServer::AudioOutputFunctions::ao_open_live(int driver_id, ao
- if (ao_get_option(option, "name"))
- item.GetMusicInfoTag()->SetTitle(ao_get_option(option, "name"));
-
-- g_application.getApplicationMessenger().PlayFile(item);
--
- ThreadMessage tMsg2 = { TMSG_GUI_ACTIVATE_WINDOW, WINDOW_VISUALISATION, 0 };
- g_application.getApplicationMessenger().SendMessage(tMsg2, true);
-
-+ g_application.getApplicationMessenger().PlayFile(item);
-+
- return (ao_device*) device;
- }
-
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-999.012-airtunes_implementation_for_windows_using_libshairplay.patch b/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-999.012-airtunes_implementation_for_windows_using_libshairplay.patch
deleted file mode 100644
index 9ea05b6281..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-pvr-11.0.2-999.012-airtunes_implementation_for_windows_using_libshairplay.patch
+++ /dev/null
@@ -1,527 +0,0 @@
-From b73018af2ae69c7cfad0a4461d169a49c7d0dfbf Mon Sep 17 00:00:00 2001
-From: Memphiz
-Date: Tue, 15 May 2012 19:12:07 +0200
-Subject: [PATCH] [airtunes] - implementation for windows using libshairplay
-
----
- xbmc/network/AirTunesServer.cpp | 330 +++++++++++++++++++++++++++++++++++++--
- xbmc/network/AirTunesServer.h | 23 +++
- 2 files changed, 343 insertions(+), 10 deletions(-)
-
-diff --git a/xbmc/network/AirTunesServer.cpp b/xbmc/network/AirTunesServer.cpp
-index a60ad09..e14da90 100644
---- a/xbmc/network/AirTunesServer.cpp
-+++ b/xbmc/network/AirTunesServer.cpp
-@@ -17,7 +17,9 @@
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-+#if !defined(TARGET_WINDOWS)
- #pragma GCC diagnostic ignored "-Wwrite-strings"
-+#endif
-
- #include "AirTunesServer.h"
-
-@@ -37,15 +39,243 @@
- #include "music/tags/MusicInfoTag.h"
- #include "FileItem.h"
- #include "GUIInfoManager.h"
-+#include "guilib/GUIWindowManager.h"
- #include "utils/Variant.h"
- #include "settings/AdvancedSettings.h"
-+#include "utils/EndianSwap.h"
-+
-+#include