Merge pull request #2810 from jmarshallnz/eval_conditions_before_actions
authorMichal Piechowiak <misiek.piechowiak@gmail.com>
Mon, 10 Jun 2013 20:39:21 +0000 (13:39 -0700)
committerMichal Piechowiak <misiek.piechowiak@gmail.com>
Mon, 10 Jun 2013 20:39:21 +0000 (13:39 -0700)
Eval conditions before actions

522 files changed:
Makefile.in
XBMC.xcodeproj/project.pbxproj
configure.in
language/English/strings.po
lib/DllAvCodec.h
lib/DllAvFilter.h
lib/DllAvFormat.h
lib/DllAvUtil.h
lib/DllPostProc.h
lib/DllSwScale.h
lib/UnrarXLib/cmddata.cpp
lib/UnrarXLib/consio.cpp
lib/UnrarXLib/crypt.cpp
lib/UnrarXLib/errhnd.cpp
lib/UnrarXLib/file.cpp
lib/UnrarXLib/filefn.cpp
lib/UnrarXLib/filestr.cpp
lib/UnrarXLib/find.cpp
lib/UnrarXLib/os.hpp
lib/UnrarXLib/pathfn.cpp
lib/UnrarXLib/rar.cpp
lib/UnrarXLib/suballoc.hpp
lib/UnrarXLib/unicode.cpp
lib/addons/library.xbmc.addon/project/VS2010Express/libXBMC_addon.vcxproj
lib/addons/library.xbmc.gui/project/VS2010Express/libXBMC_gui.vcxproj
lib/addons/library.xbmc.pvr/project/VS2010Express/libXBMC_pvr.vcxproj
lib/ffmpeg/libavcodec/vda.h
lib/libRTV/rtv.h
lib/libXDAAP/private.h
project/VS2010Express/XBMC.vcxproj
project/VS2010Express/XBMC.vcxproj.filters
project/Win32BuildSetup/buildpvraddons.bat
system/keymaps/joystick.Logitech.RumblePad.2.xml
system/settings/darwin_osx.xml
system/settings/rbp.xml
system/settings/settings.xml
tools/Linux/packaging/README.debian [new file with mode: 0644]
tools/Linux/packaging/mk-debian-package.sh [new file with mode: 0755]
tools/TexturePacker/MakeDDS.cpp
tools/TexturePacker/Makefile.in
tools/TexturePacker/XBMCTex.cpp
tools/TexturePacker/XBTFWriter.cpp
tools/TexturePacker/cmdlineargs.h
tools/TexturePacker/xwinapi.cpp
tools/android/packaging/Makefile
tools/android/packaging/xbmc/AndroidManifest.xml
tools/android/packaging/xbmc/src/org/xbmc/xbmc/Main.java
tools/buildsteps/linux-debian/configure-depends [new file with mode: 0755]
tools/buildsteps/linux-debian/configure-xbmc [new file with mode: 0755]
tools/buildsteps/linux-debian/make-depends [new file with mode: 0755]
tools/buildsteps/linux-debian/make-xbmc [new file with mode: 0755]
tools/buildsteps/linux-debian/package [new file with mode: 0755]
tools/buildsteps/linux-debian/prepare-depends [new file with mode: 0755]
tools/buildsteps/linux-debian/prepare-xbmc [new file with mode: 0755]
tools/depends/target/Makefile
tools/depends/target/Toolchain.cmake.in
tools/depends/target/libplist/Makefile
tools/depends/target/libshairplay/Makefile
tools/depends/target/libxml2/Makefile
tools/depends/target/mdnsresponder/01-android-embedded.patch [new file with mode: 0644]
tools/depends/target/mdnsresponder/Makefile [new file with mode: 0644]
tools/depends/target/mdnsresponder/makefile.internal [new file with mode: 0644]
tools/depends/target/xbmc-pvr-addons/Makefile
tools/rbp/depends/depends.mk
xbmc/Application.cpp
xbmc/Application.h
xbmc/ApplicationMessenger.cpp
xbmc/ApplicationMessenger.h
xbmc/Autorun.cpp
xbmc/BackgroundInfoLoader.cpp
xbmc/CueDocument.cpp
xbmc/CueDocument.h
xbmc/DllPaths.h
xbmc/DllPaths_generated.h.in
xbmc/DynamicDll.h
xbmc/Favourites.cpp [deleted file]
xbmc/Favourites.h [deleted file]
xbmc/FileItem.cpp
xbmc/GUIInfoManager.cpp
xbmc/GUIPassword.cpp
xbmc/LangInfo.cpp
xbmc/Makefile.in
xbmc/MediaSource.cpp
xbmc/MediaSource.h
xbmc/NfoFile.h
xbmc/SystemGlobals.cpp
xbmc/TextureCacheJob.cpp
xbmc/URL.cpp
xbmc/URL.h
xbmc/Util.cpp
xbmc/Util.h
xbmc/addons/Addon.cpp
xbmc/addons/AddonDll.h
xbmc/addons/AddonInstaller.cpp
xbmc/addons/AddonInstaller.h
xbmc/addons/AddonManager.cpp
xbmc/addons/Repository.cpp
xbmc/addons/ScreenSaver.cpp
xbmc/addons/Skin.cpp
xbmc/addons/Visualisation.cpp
xbmc/addons/include/xbmc_addon_dll.h
xbmc/addons/include/xbmc_pvr_dll.h
xbmc/addons/include/xbmc_pvr_types.h
xbmc/android/activity/XBMCApp.cpp
xbmc/android/activity/XBMCApp.h
xbmc/android/activity/android_main.cpp
xbmc/android/jni/AudioManager.cpp
xbmc/android/jni/AudioManager.h
xbmc/android/jni/BaseColumns.cpp [new file with mode: 0644]
xbmc/android/jni/BaseColumns.h [new file with mode: 0644]
xbmc/android/jni/BitSet.cpp
xbmc/android/jni/BitmapDrawable.h
xbmc/android/jni/BroadcastReceiver.cpp
xbmc/android/jni/BroadcastReceiver.h
xbmc/android/jni/ConnectivityManager.cpp
xbmc/android/jni/ConnectivityManager.h
xbmc/android/jni/ContentResolver.cpp [new file with mode: 0644]
xbmc/android/jni/ContentResolver.h [new file with mode: 0644]
xbmc/android/jni/Context.cpp
xbmc/android/jni/Context.h
xbmc/android/jni/Cursor.cpp [new file with mode: 0644]
xbmc/android/jni/Cursor.h [new file with mode: 0644]
xbmc/android/jni/Enum.cpp
xbmc/android/jni/Intent.cpp
xbmc/android/jni/Intent.h
xbmc/android/jni/IntentFilter.cpp
xbmc/android/jni/JNIBase.h
xbmc/android/jni/JNIThreading.cpp
xbmc/android/jni/Makefile.in
xbmc/android/jni/MediaStore.cpp [new file with mode: 0644]
xbmc/android/jni/MediaStore.h [new file with mode: 0644]
xbmc/android/jni/PackageManager.cpp
xbmc/android/jni/PackageManager.h
xbmc/android/jni/PowerManager.cpp
xbmc/android/jni/PowerManager.h
xbmc/android/jni/URI.cpp
xbmc/android/jni/URI.h
xbmc/android/jni/WifiInfo.cpp
xbmc/android/jni/WifiManager.cpp
xbmc/android/jni/WifiManager.h
xbmc/android/jni/WifiManagerMulticastLock.cpp [new file with mode: 0644]
xbmc/android/jni/WifiManagerMulticastLock.h [new file with mode: 0644]
xbmc/android/jni/jutils.cpp
xbmc/android/jni/jutils/jutils-details.hpp
xbmc/cdrip/CDDARipJob.cpp
xbmc/cdrip/CDDARipJob.h
xbmc/cdrip/CDDARipper.cpp
xbmc/cdrip/DllOgg.h
xbmc/cdrip/DllVorbis.h
xbmc/cdrip/DllVorbisEnc.h
xbmc/cdrip/EncoderFFmpeg.cpp
xbmc/cdrip/EncoderLame.cpp
xbmc/cores/AudioEngine/Sinks/AESinkNULL.cpp
xbmc/cores/DllLoader/DllLoader.cpp
xbmc/cores/DllLoader/DllLoader.h
xbmc/cores/DllLoader/DllLoaderContainer.cpp
xbmc/cores/DllLoader/LibraryLoader.h
xbmc/cores/DllLoader/SoLoader.h
xbmc/cores/DllLoader/Win32DllLoader.h
xbmc/cores/DllLoader/coff.cpp
xbmc/cores/DllLoader/coff.h
xbmc/cores/DllLoader/dll.cpp
xbmc/cores/DllLoader/dll_tracker.h
xbmc/cores/DllLoader/dll_tracker_file.cpp
xbmc/cores/DllLoader/dll_util.cpp
xbmc/cores/DllLoader/exports/emu_kernel32.cpp
xbmc/cores/DllLoader/exports/emu_kernel32.h
xbmc/cores/DllLoader/exports/emu_msvcrt.cpp
xbmc/cores/DllLoader/exports/emu_msvcrt.h
xbmc/cores/DllLoader/exports/emu_socket/inet_aton.c
xbmc/cores/DllLoader/exports/util/EmuFileWrapper.h
xbmc/cores/DllLoader/exports/wrapper.c
xbmc/cores/DllLoader/ldt_keeper.c
xbmc/cores/ExternalPlayer/ExternalPlayer.cpp
xbmc/cores/ExternalPlayer/ExternalPlayer.h
xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
xbmc/cores/VideoRenderers/LinuxRendererGL.h
xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
xbmc/cores/VideoRenderers/RenderManager.cpp
xbmc/cores/VideoRenderers/RenderManager.h
xbmc/cores/VideoRenderers/VideoShaders/ConvolutionKernels.cpp
xbmc/cores/VideoRenderers/WinRenderer.h
xbmc/cores/amlplayer/AMLPlayer.cpp
xbmc/cores/dvdplayer/DVDAudio.h
xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodec.h
xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp
xbmc/cores/dvdplayer/DVDCodecs/Audio/DllLibMad.h
xbmc/cores/dvdplayer/DVDCodecs/DVDCodecs.h
xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp
xbmc/cores/dvdplayer/DVDCodecs/Overlay/libspucc/cc_decoder.c
xbmc/cores/dvdplayer/DVDCodecs/Overlay/libspucc/cc_decoder.h
xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp
xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.h
xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCrystalHD.cpp
xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecOpenMax.cpp
xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp
xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.h
xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp
xbmc/cores/dvdplayer/DVDCodecs/Video/DllLibMpeg2.h
xbmc/cores/dvdplayer/DVDCodecs/Video/OpenMax.cpp
xbmc/cores/dvdplayer/DVDCodecs/Video/OpenMaxVideo.cpp
xbmc/cores/dvdplayer/DVDCodecs/Video/VDA.cpp [new file with mode: 0644]
xbmc/cores/dvdplayer/DVDCodecs/Video/VDA.h [new file with mode: 0644]
xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
xbmc/cores/dvdplayer/DVDDemuxers/DVDDemux.h
xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxBXA.h
xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxCDDA.h
xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h
xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPVRClient.h
xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxUtils.cpp
xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.cpp
xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.h
xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp
xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamFile.cpp
xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamHTSP.h
xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.h
xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamRTMP.cpp
xbmc/cores/dvdplayer/DVDInputStreams/DVDStateSerializer.cpp
xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/config.h
xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/dvdnav_internal.h
xbmc/cores/dvdplayer/DVDPlayer.cpp
xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
xbmc/cores/dvdplayer/DVDPlayerSubtitle.cpp
xbmc/cores/dvdplayer/DVDStreamInfo.h
xbmc/cores/dvdplayer/DVDSubtitles/DllLibass.h
xbmc/cores/dvdplayer/DVDTSCorrection.h
xbmc/cores/omxplayer/OMXAudio.cpp
xbmc/cores/omxplayer/OMXAudio.h
xbmc/cores/omxplayer/OMXAudioCodecOMX.cpp
xbmc/cores/omxplayer/OMXAudioCodecOMX.h
xbmc/cores/omxplayer/OMXImage.cpp
xbmc/cores/omxplayer/OMXPlayer.cpp
xbmc/cores/omxplayer/OMXPlayer.h
xbmc/cores/omxplayer/OMXPlayerAudio.cpp
xbmc/cores/omxplayer/OMXPlayerAudio.h
xbmc/cores/omxplayer/OMXPlayerVideo.cpp
xbmc/cores/omxplayer/OMXPlayerVideo.h
xbmc/cores/omxplayer/OMXVideo.cpp
xbmc/cores/omxplayer/OMXVideo.h
xbmc/cores/paplayer/ASAPCodec.cpp
xbmc/cores/paplayer/NSFCodec.cpp
xbmc/cores/paplayer/OGGcodec.cpp
xbmc/cores/paplayer/SIDCodec.cpp
xbmc/cores/paplayer/SPCCodec.cpp
xbmc/cores/paplayer/SPCCodec.h
xbmc/cores/paplayer/TimidityCodec.cpp
xbmc/cores/paplayer/WAVcodec.cpp
xbmc/dbwrappers/dataset.cpp
xbmc/dbwrappers/mysqldataset.cpp
xbmc/dbwrappers/sqlitedataset.cpp
xbmc/dialogs/GUIDialogContextMenu.cpp
xbmc/dialogs/GUIDialogFavourites.cpp
xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp
xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp
xbmc/epg/GUIEPGGridContainer.h
xbmc/filesystem/AFPFile.cpp
xbmc/filesystem/AFPFile.h
xbmc/filesystem/CDDAFile.cpp
xbmc/filesystem/CacheStrategy.cpp
xbmc/filesystem/CacheStrategy.h
xbmc/filesystem/CircularCache.cpp
xbmc/filesystem/CircularCache.h
xbmc/filesystem/CurlFile.cpp
xbmc/filesystem/DAAPFile.h
xbmc/filesystem/Directory.cpp
xbmc/filesystem/DirectoryCache.cpp
xbmc/filesystem/DirectoryFactory.cpp
xbmc/filesystem/FTPParse.cpp
xbmc/filesystem/FavouritesDirectory.cpp [new file with mode: 0644]
xbmc/filesystem/FavouritesDirectory.h [new file with mode: 0644]
xbmc/filesystem/File.cpp
xbmc/filesystem/File.h
xbmc/filesystem/FileCache.cpp
xbmc/filesystem/FileDirectoryFactory.cpp
xbmc/filesystem/FileFactory.cpp
xbmc/filesystem/FileFactory.h
xbmc/filesystem/HDDirectory.cpp
xbmc/filesystem/HDFile.cpp
xbmc/filesystem/HDFile.h
xbmc/filesystem/HDHomeRunFile.cpp
xbmc/filesystem/IDirectory.cpp
xbmc/filesystem/IFile.h
xbmc/filesystem/ISOFile.h
xbmc/filesystem/LibraryDirectory.cpp
xbmc/filesystem/Makefile.in
xbmc/filesystem/MemBufferCache.cpp
xbmc/filesystem/MusicDatabaseFile.cpp
xbmc/filesystem/MythDirectory.cpp
xbmc/filesystem/MythFile.cpp
xbmc/filesystem/PipeFile.h
xbmc/filesystem/PluginDirectory.cpp
xbmc/filesystem/RSSDirectory.cpp
xbmc/filesystem/RTVFile.cpp
xbmc/filesystem/RTVFile.h
xbmc/filesystem/RarFile.cpp
xbmc/filesystem/RarManager.cpp
xbmc/filesystem/RarManager.h
xbmc/filesystem/SAPDirectory.cpp
xbmc/filesystem/SFTPFile.cpp
xbmc/filesystem/SMBDirectory.cpp
xbmc/filesystem/SmartPlaylistDirectory.cpp
xbmc/filesystem/SmbFile.h
xbmc/filesystem/SpecialProtocol.cpp
xbmc/filesystem/SpecialProtocol.h
xbmc/filesystem/VTPFile.cpp
xbmc/filesystem/VirtualDirectory.cpp
xbmc/filesystem/iso9660.cpp
xbmc/filesystem/iso9660.h
xbmc/filesystem/windows/WINFileSMB.h
xbmc/guilib/AnimatedGif.cpp
xbmc/guilib/DirectXGraphics.h
xbmc/guilib/GUIBaseContainer.cpp
xbmc/guilib/GUIBaseContainer.h
xbmc/guilib/GUIBorderedImage.cpp
xbmc/guilib/GUICallback.h
xbmc/guilib/GUIControlFactory.cpp
xbmc/guilib/GUIEditControl.cpp
xbmc/guilib/GUIFontManager.cpp
xbmc/guilib/GUIFontTTF.cpp
xbmc/guilib/GUIKeyboard.h
xbmc/guilib/GUILabel.cpp
xbmc/guilib/GUILabel.h
xbmc/guilib/GUILabelControl.cpp
xbmc/guilib/GUITextLayout.cpp
xbmc/guilib/GUITextLayout.h
xbmc/guilib/GUITexture.cpp
xbmc/guilib/GUITexture.h
xbmc/guilib/GraphicContext.cpp
xbmc/guilib/IGUIContainer.h [new file with mode: 0644]
xbmc/guilib/Texture.cpp
xbmc/guilib/TextureBundleXBT.cpp
xbmc/guilib/TextureBundleXPR.cpp
xbmc/guilib/XBTFReader.cpp
xbmc/guilib/gui3d.h
xbmc/input/ButtonTranslator.cpp
xbmc/input/KeyboardLayoutConfiguration.h
xbmc/input/touch/generic/GenericTouchSwipeDetector.cpp
xbmc/interfaces/Builtins.cpp
xbmc/interfaces/json-rpc/FavouritesOperations.cpp
xbmc/interfaces/json-rpc/FileOperations.cpp
xbmc/interfaces/json-rpc/PlayerOperations.cpp
xbmc/interfaces/legacy/Dialog.cpp
xbmc/interfaces/legacy/Dialog.h
xbmc/interfaces/legacy/ModuleXbmc.cpp
xbmc/interfaces/legacy/Player.cpp
xbmc/interfaces/legacy/WindowInterceptor.h
xbmc/interfaces/legacy/WindowXML.cpp
xbmc/interfaces/python/LanguageHook.h
xbmc/interfaces/python/XBPyThread.cpp
xbmc/interfaces/python/XBPython.cpp
xbmc/linux/ConvUtils.cpp
xbmc/linux/LinuxTimezone.cpp
xbmc/linux/OMXClock.cpp
xbmc/linux/OMXClock.h
xbmc/linux/OMXCore.cpp
xbmc/linux/PlatformDefs.h
xbmc/linux/PosixMountProvider.cpp
xbmc/linux/XFileUtils.cpp
xbmc/linux/XFileUtils.h
xbmc/linux/XHandle.h
xbmc/linux/XMemUtils.cpp
xbmc/linux/XTimeUtils.cpp
xbmc/main/main.cpp
xbmc/music/MusicDatabase.cpp
xbmc/music/MusicDatabase.h
xbmc/music/windows/GUIWindowMusicPlaylist.cpp
xbmc/network/DNSNameCache.cpp
xbmc/network/GUIDialogAccessPoints.cpp
xbmc/network/Network.cpp
xbmc/network/Network.h
xbmc/network/Socket.cpp
xbmc/network/Socket.h
xbmc/network/UdpClient.cpp
xbmc/network/WakeOnAccess.cpp
xbmc/network/WebServer.cpp
xbmc/network/Zeroconf.cpp
xbmc/network/ZeroconfBrowser.cpp
xbmc/network/ZeroconfBrowser.h
xbmc/network/cddb.h
xbmc/network/httprequesthandler/HTTPVfsHandler.cpp
xbmc/network/linux/NetworkLinux.cpp
xbmc/network/mdns/Makefile [new file with mode: 0644]
xbmc/network/mdns/ZeroconfBrowserMDNS.cpp [new file with mode: 0644]
xbmc/network/mdns/ZeroconfBrowserMDNS.h [new file with mode: 0644]
xbmc/network/mdns/ZeroconfMDNS.cpp [new file with mode: 0644]
xbmc/network/mdns/ZeroconfMDNS.h [new file with mode: 0644]
xbmc/network/upnp/UPnPInternal.cpp
xbmc/network/upnp/UPnPRenderer.cpp
xbmc/network/upnp/UPnPServer.cpp
xbmc/network/upnp/UPnPSettings.cpp
xbmc/network/upnp/UPnPSettings.h
xbmc/network/windows/NetworkWin32.cpp
xbmc/network/windows/ZeroconfBrowserWIN.cpp [deleted file]
xbmc/network/windows/ZeroconfBrowserWIN.h [deleted file]
xbmc/network/windows/ZeroconfWIN.cpp [deleted file]
xbmc/network/windows/ZeroconfWIN.h [deleted file]
xbmc/osx/atv2/xbmcclient.h
xbmc/peripherals/PeripheralTypes.h
xbmc/peripherals/bus/PeripheralBus.cpp
xbmc/peripherals/bus/PeripheralBus.h
xbmc/peripherals/bus/linux/PeripheralBusUSBLibUSB.cpp
xbmc/peripherals/bus/linux/PeripheralBusUSBLibUdev.cpp
xbmc/peripherals/bus/osx/PeripheralBusUSB.cpp
xbmc/peripherals/bus/virtual/PeripheralBusCEC.cpp
xbmc/peripherals/bus/win32/PeripheralBusUSB.cpp
xbmc/pictures/DllImageLib.h
xbmc/pictures/GUIWindowSlideShow.cpp
xbmc/pictures/Picture.cpp
xbmc/playlists/PlayList.cpp
xbmc/playlists/PlayListFactory.cpp
xbmc/playlists/SmartPlayList.cpp
xbmc/powermanagement/DPMSSupport.cpp
xbmc/powermanagement/PowerManager.cpp
xbmc/powermanagement/windows/Win32PowerSyscall.cpp
xbmc/powermanagement/windows/Win32PowerSyscall.h
xbmc/pvr/PVRManager.cpp
xbmc/pvr/addons/PVRClient.cpp
xbmc/pvr/addons/PVRClient.h
xbmc/pvr/addons/PVRClients.cpp
xbmc/pvr/addons/PVRClients.h
xbmc/pvr/windows/GUIWindowPVRCommon.cpp
xbmc/rendering/gl/RenderSystemGL.cpp
xbmc/settings/AdvancedSettings.cpp
xbmc/settings/AdvancedSettings.h
xbmc/settings/DisplaySettings.cpp
xbmc/settings/ISettingsHandler.h
xbmc/settings/MediaSourceSettings.cpp
xbmc/settings/MediaSourceSettings.h
xbmc/settings/Settings.cpp
xbmc/settings/SettingsManager.cpp
xbmc/settings/VideoSettings.h
xbmc/settings/windows/GUIWindowSettingsCategory.cpp
xbmc/settings/windows/GUIWindowSettingsCategory.h
xbmc/storage/DetectDVDType.cpp
xbmc/storage/IoSupport.cpp
xbmc/storage/IoSupport.h
xbmc/storage/MediaManager.cpp
xbmc/storage/cdioSupport.cpp
xbmc/system.h
xbmc/test/TestBasicEnvironment.cpp
xbmc/test/TestUtils.cpp
xbmc/test/TestUtils.h
xbmc/threads/Atomics.cpp
xbmc/threads/platform/pthreads/ThreadImpl.cpp
xbmc/utils/AliasShortcutUtils.cpp
xbmc/utils/BitstreamStats.h
xbmc/utils/CPUInfo.cpp
xbmc/utils/CharsetConverter.cpp
xbmc/utils/CryptThreading.cpp
xbmc/utils/DownloadQueue.cpp [deleted file]
xbmc/utils/DownloadQueue.h [deleted file]
xbmc/utils/DownloadQueueManager.cpp [deleted file]
xbmc/utils/DownloadQueueManager.h [deleted file]
xbmc/utils/EndianSwap.h
xbmc/utils/Environment.cpp
xbmc/utils/FileOperationJob.cpp
xbmc/utils/FileUtils.cpp
xbmc/utils/FileUtils.h
xbmc/utils/JobManager.cpp
xbmc/utils/JobManager.h
xbmc/utils/LangCodeExpander.cpp
xbmc/utils/Makefile.in
xbmc/utils/MathUtils.h
xbmc/utils/PerformanceSample.cpp
xbmc/utils/PerformanceSample.h
xbmc/utils/RegExp.h
xbmc/utils/RssManager.cpp
xbmc/utils/RssManager.h
xbmc/utils/StdString.h
xbmc/utils/Stopwatch.cpp
xbmc/utils/SystemInfo.cpp
xbmc/utils/SystemInfo.h
xbmc/utils/URIUtils.cpp
xbmc/utils/URIUtils.h
xbmc/utils/Weather.cpp
xbmc/utils/XBMCTinyXML.h
xbmc/utils/XMLUtils.cpp
xbmc/utils/fastmemcpy.c
xbmc/utils/fastmemcpy.h
xbmc/utils/md5.cpp
xbmc/utils/test/Makefile
xbmc/utils/test/TestDownloadQueue.cpp [deleted file]
xbmc/utils/test/TestDownloadQueueManager.cpp [deleted file]
xbmc/utils/test/TestMime.cpp
xbmc/utils/test/TestSystemInfo.cpp
xbmc/utils/test/TestURIUtils.cpp
xbmc/video/PlayerController.cpp
xbmc/video/VideoDatabase.h
xbmc/video/VideoInfoScanner.cpp
xbmc/video/VideoReferenceClock.cpp
xbmc/video/VideoReferenceClock.h
xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp
xbmc/video/windows/GUIWindowVideoBase.cpp
xbmc/video/windows/GUIWindowVideoPlaylist.cpp
xbmc/view/GUIViewControl.cpp
xbmc/view/GUIViewControl.h
xbmc/view/ViewDatabase.cpp
xbmc/visualizations/DirectXSpectrum/directx_spectrum.vcxproj
xbmc/visualizations/EGLHelpers/VisMatrixGLES.h
xbmc/visualizations/EGLHelpers/VisShader.h
xbmc/visualizations/Milkdrop/Plugin.vcxproj
xbmc/visualizations/Milkdrop/XmlDocument.h
xbmc/visualizations/WaveForm/Waveform.vcxproj
xbmc/win32/PlatformDefs.h
xbmc/win32/PlatformInclude.h
xbmc/win32/WIN32Util.cpp
xbmc/win32/WIN32Util.h
xbmc/win32/win32env.cpp [deleted file]
xbmc/windowing/WinEventsSDL.cpp
xbmc/windowing/WinEventsSDL.h
xbmc/windowing/X11/XRandR.cpp
xbmc/windowing/osx/WinSystemOSXGL.mm
xbmc/windowing/windows/WinEventsWin32.cpp
xbmc/windowing/windows/WinSystemWin32.cpp
xbmc/windows/GUIMediaWindow.cpp
xbmc/windows/GUIMediaWindow.h
xbmc/windows/GUIWindowDebugInfo.cpp
xbmc/windows/GUIWindowDebugInfo.h
xbmc/windows/GUIWindowFileManager.cpp

index 0dc7b3b..f64ec4f 100644 (file)
@@ -122,6 +122,10 @@ DIRECTORY_ARCHIVES += lib/libUPnP/libupnp.a \
                       xbmc/network/upnp/upnp.a
 endif
 
+ifeq (@USE_MDNSEMBEDDED@,1)
+DIRECTORY_ARCHIVES += xbmc/network/mdns/mdns.a
+endif
+
 ifeq ($(findstring osx,@ARCH@),osx)
 DIRECTORY_ARCHIVES += xbmc/osx/osx.a
 DIRECTORY_ARCHIVES += xbmc/network/osx/network.a
index 2890b5a..4eda502 100644 (file)
@@ -25,6 +25,9 @@
 /* End PBXAggregateTarget section */
 
 /* Begin PBXBuildFile section */
+               0E3036EC1760F68A00D93596 /* FavouritesDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0E3036EA1760F68A00D93596 /* FavouritesDirectory.cpp */; };
+               0E3036ED1760F68A00D93596 /* FavouritesDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0E3036EA1760F68A00D93596 /* FavouritesDirectory.cpp */; };
+               0E3036EE1760F68A00D93596 /* FavouritesDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0E3036EA1760F68A00D93596 /* FavouritesDirectory.cpp */; };
                183FDF8A11AF0B0500B81E9C /* PluginSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 183FDF8811AF0B0500B81E9C /* PluginSource.cpp */; };
                18404DA61396C31B00863BBA /* SlingboxLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 18404DA51396C31B00863BBA /* SlingboxLib.a */; };
                1840B74D13993D8A007C848B /* JSONVariantParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1840B74B13993D8A007C848B /* JSONVariantParser.cpp */; };
                43BF09A21080D1E900E25290 /* AVTransportSCPD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43BF099E1080D1E900E25290 /* AVTransportSCPD.cpp */; settings = {COMPILER_FLAGS = "-I$SRCROOT/lib/libUPnP/Platinum/Source/Core -I$SRCROOT/lib/libUPnP/Platinum/Source/Platinum -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaConnect -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaRenderer -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaServer -I$SRCROOT/lib/libUPnP/Platinum/Source/Extras -I$SRCROOT/lib/libUPnP/Neptune/Source/System/Posix -I$SRCROOT/lib/libUPnP/Neptune/Source/Core"; }; };
                43BF09A31080D1E900E25290 /* RenderingControlSCPD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43BF099F1080D1E900E25290 /* RenderingControlSCPD.cpp */; settings = {COMPILER_FLAGS = "-I$SRCROOT/lib/libUPnP/Platinum/Source/Core -I$SRCROOT/lib/libUPnP/Platinum/Source/Platinum -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaConnect -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaRenderer -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaServer -I$SRCROOT/lib/libUPnP/Platinum/Source/Extras -I$SRCROOT/lib/libUPnP/Neptune/Source/System/Posix -I$SRCROOT/lib/libUPnP/Neptune/Source/Core"; }; };
                43BF09AB1080D2ED00E25290 /* RdrConnectionManagerSCPD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43BF09A81080D2ED00E25290 /* RdrConnectionManagerSCPD.cpp */; settings = {COMPILER_FLAGS = "-I$SRCROOT/lib/libUPnP/Platinum/Source/Core -I$SRCROOT/lib/libUPnP/Platinum/Source/Platinum -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaConnect -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaRenderer -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaServer -I$SRCROOT/lib/libUPnP/Platinum/Source/Extras -I$SRCROOT/lib/libUPnP/Neptune/Source/System/Posix -I$SRCROOT/lib/libUPnP/Neptune/Source/Core"; }; };
+               551C3A45175A12010051AAAD /* VDA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 551C3A43175A12010051AAAD /* VDA.cpp */; };
                552840CC1626163B00ED1333 /* UPnPPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 552840CA1626163B00ED1333 /* UPnPPlayer.cpp */; settings = {COMPILER_FLAGS = "-I$SRCROOT/lib/libUPnP/Platinum/Source/Core -I$SRCROOT/lib/libUPnP/Platinum/Source/Platinum -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaConnect -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaRenderer -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaServer -I$SRCROOT/lib/libUPnP/Platinum/Source/Extras -I$SRCROOT/lib/libUPnP/Neptune/Source/System/Posix -I$SRCROOT/lib/libUPnP/Neptune/Source/Core"; }; };
                552A226915F7E14B0015C0D0 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 552A226815F7E14B0015C0D0 /* main.cpp */; };
                553840F215F360B400CE061B /* PltMimeType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 553840ED15F360B400CE061B /* PltMimeType.cpp */; settings = {COMPILER_FLAGS = "-I$SRCROOT/lib/libUPnP/Platinum/Source/Core -I$SRCROOT/lib/libUPnP/Platinum/Source/Platinum -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaConnect -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaRenderer -I$SRCROOT/lib/libUPnP/Platinum/Source/Devices/MediaServer -I$SRCROOT/lib/libUPnP/Platinum/Source/Extras -I$SRCROOT/lib/libUPnP/Neptune/Source/System/Posix -I$SRCROOT/lib/libUPnP/Neptune/Source/Core"; }; };
                DFF0F3C517528350002DA3A4 /* Crc32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18B7C8E712942603009E7A26 /* Crc32.cpp */; };
                DFF0F3C617528350002DA3A4 /* CryptThreading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5BD02F4148D3A7E001B5583 /* CryptThreading.cpp */; };
                DFF0F3C717528350002DA3A4 /* DatabaseUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 36A9443B15821E2800727135 /* DatabaseUtils.cpp */; };
-               DFF0F3C817528350002DA3A4 /* DownloadQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E310D25F9FD00618676 /* DownloadQueue.cpp */; };
-               DFF0F3C917528350002DA3A4 /* DownloadQueueManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E330D25F9FD00618676 /* DownloadQueueManager.cpp */; };
                DFF0F3CA17528350002DA3A4 /* EdenVideoArtUpdater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CC30E8816296078003E7579 /* EdenVideoArtUpdater.cpp */; };
                DFF0F3CB17528350002DA3A4 /* Environment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF529BAC1741697B00523FB4 /* Environment.cpp */; };
                DFF0F3CC17528350002DA3A4 /* Fanart.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E36C29E90DA72486001F0C9D /* Fanart.cpp */; };
                DFF0F43817528350002DA3A4 /* DatabaseManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1D682715A7D2FD00658B65 /* DatabaseManager.cpp */; };
                DFF0F43917528350002DA3A4 /* DbUrl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 36A9466115CF1FA600727135 /* DbUrl.cpp */; };
                DFF0F43A17528350002DA3A4 /* DynamicDll.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E168C0D25F9FA00618676 /* DynamicDll.cpp */; };
-               DFF0F43B17528350002DA3A4 /* Favourites.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16900D25F9FA00618676 /* Favourites.cpp */; };
                DFF0F43C17528350002DA3A4 /* FileItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16920D25F9FA00618676 /* FileItem.cpp */; };
                DFF0F43D17528350002DA3A4 /* GUIInfoManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E3E0D25F9FD00618676 /* GUIInfoManager.cpp */; };
                DFF0F43E17528350002DA3A4 /* GUILargeTextureManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E17EE0D25F9FA00618676 /* GUILargeTextureManager.cpp */; };
                E38E1FFA0D25F9FD00618676 /* DetectDVDType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16840D25F9FA00618676 /* DetectDVDType.cpp */; };
                E38E1FFB0D25F9FD00618676 /* DNSNameCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16890D25F9FA00618676 /* DNSNameCache.cpp */; };
                E38E1FFC0D25F9FD00618676 /* DynamicDll.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E168C0D25F9FA00618676 /* DynamicDll.cpp */; };
-               E38E1FFE0D25F9FD00618676 /* Favourites.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16900D25F9FA00618676 /* Favourites.cpp */; };
                E38E1FFF0D25F9FD00618676 /* FileItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16920D25F9FA00618676 /* FileItem.cpp */; };
                E38E20010D25F9FD00618676 /* MemBufferCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16970D25F9FA00618676 /* MemBufferCache.cpp */; };
                E38E20020D25F9FD00618676 /* CacheStrategy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16990D25F9FA00618676 /* CacheStrategy.cpp */; };
                E38E22C60D25F9FE00618676 /* BitstreamStats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E270D25F9FD00618676 /* BitstreamStats.cpp */; };
                E38E22C70D25F9FE00618676 /* CharsetConverter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E290D25F9FD00618676 /* CharsetConverter.cpp */; };
                E38E22C80D25F9FE00618676 /* CPUInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E2B0D25F9FD00618676 /* CPUInfo.cpp */; };
-               E38E22CB0D25F9FE00618676 /* DownloadQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E310D25F9FD00618676 /* DownloadQueue.cpp */; };
-               E38E22CC0D25F9FE00618676 /* DownloadQueueManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E330D25F9FD00618676 /* DownloadQueueManager.cpp */; };
                E38E22CD0D25F9FE00618676 /* Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E350D25F9FD00618676 /* Event.cpp */; };
                E38E22D10D25F9FE00618676 /* GUIInfoManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E3E0D25F9FD00618676 /* GUIInfoManager.cpp */; };
                E38E22D20D25F9FE00618676 /* HTMLTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E400D25F9FD00618676 /* HTMLTable.cpp */; };
                E4991449174E605900741B6D /* Crc32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18B7C8E712942603009E7A26 /* Crc32.cpp */; };
                E499144A174E605900741B6D /* CryptThreading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5BD02F4148D3A7E001B5583 /* CryptThreading.cpp */; };
                E499144B174E605900741B6D /* DatabaseUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 36A9443B15821E2800727135 /* DatabaseUtils.cpp */; };
-               E499144C174E605900741B6D /* DownloadQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E310D25F9FD00618676 /* DownloadQueue.cpp */; };
-               E499144D174E605900741B6D /* DownloadQueueManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E330D25F9FD00618676 /* DownloadQueueManager.cpp */; };
                E499144E174E605900741B6D /* EdenVideoArtUpdater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CC30E8816296078003E7579 /* EdenVideoArtUpdater.cpp */; };
                E499144F174E605900741B6D /* Environment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF529BAC1741697B00523FB4 /* Environment.cpp */; };
                E4991450174E605900741B6D /* Fanart.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E36C29E90DA72486001F0C9D /* Fanart.cpp */; };
                E4991533174E642900741B6D /* DatabaseManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1D682715A7D2FD00658B65 /* DatabaseManager.cpp */; };
                E4991534174E642900741B6D /* DbUrl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 36A9466115CF1FA600727135 /* DbUrl.cpp */; };
                E4991535174E642900741B6D /* DynamicDll.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E168C0D25F9FA00618676 /* DynamicDll.cpp */; };
-               E4991536174E642900741B6D /* Favourites.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16900D25F9FA00618676 /* Favourites.cpp */; };
                E4991537174E642900741B6D /* FileItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E16920D25F9FA00618676 /* FileItem.cpp */; };
                E4991538174E642900741B6D /* GUIInfoManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E3E0D25F9FD00618676 /* GUIInfoManager.cpp */; };
                E4991539174E642900741B6D /* GUILargeTextureManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E17EE0D25F9FA00618676 /* GUILargeTextureManager.cpp */; };
 
 /* Begin PBXFileReference section */
                0E30286C1759FCC200D93596 /* SettingsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsManager.h; sourceTree = "<group>"; };
+               0E3036EA1760F68A00D93596 /* FavouritesDirectory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FavouritesDirectory.cpp; sourceTree = "<group>"; };
+               0E3036EB1760F68A00D93596 /* FavouritesDirectory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FavouritesDirectory.h; sourceTree = "<group>"; };
                18308CB41303370800AA309E /* stat_utf8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stat_utf8.h; sourceTree = "<group>"; };
                18308CB51303370800AA309E /* stdio_utf8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stdio_utf8.h; sourceTree = "<group>"; };
                183FDF8811AF0B0500B81E9C /* PluginSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginSource.cpp; sourceTree = "<group>"; };
                43BF09A91080D2ED00E25290 /* RenderingControlSCPD_Full.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = RenderingControlSCPD_Full.xml; sourceTree = "<group>"; };
                43BF09DD1080D39300E25290 /* fastmemcpy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fastmemcpy.h; sourceTree = "<group>"; };
                43FAC87112D6349400F67914 /* IStorageProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IStorageProvider.h; sourceTree = "<group>"; };
+               551C3A43175A12010051AAAD /* VDA.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VDA.cpp; sourceTree = "<group>"; };
+               551C3A44175A12010051AAAD /* VDA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VDA.h; sourceTree = "<group>"; };
                552840CA1626163B00ED1333 /* UPnPPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UPnPPlayer.cpp; sourceTree = "<group>"; };
                552840CB1626163B00ED1333 /* UPnPPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UPnPPlayer.h; sourceTree = "<group>"; };
                552A226815F7E14B0015C0D0 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = main/main.cpp; sourceTree = "<group>"; };
                88ACB01D0DCF409E0083CFDF /* ASAPCodec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASAPCodec.h; sourceTree = "<group>"; };
                88ACB01E0DCF409E0083CFDF /* DllASAP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DllASAP.h; sourceTree = "<group>"; };
                88ECB6580DE013C4003396A7 /* DiskArbitration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DiskArbitration.framework; path = /System/Library/Frameworks/DiskArbitration.framework; sourceTree = "<absolute>"; };
-               8DD76F7E0486A8DE00D96B5E /* XBMC */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = XBMC; sourceTree = BUILT_PRODUCTS_DIR; };
+               8DD76F7E0486A8DE00D96B5E /* XBMC */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = XBMC; sourceTree = BUILT_PRODUCTS_DIR; };
                AE84CB5915A5B8A600A3810E /* TagLibVFSStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TagLibVFSStream.cpp; sourceTree = "<group>"; };
                AE84CB5C15A5B8BA00A3810E /* TagLibVFSStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagLibVFSStream.h; sourceTree = "<group>"; };
                AE89ACA41621DAB800E17DBC /* DVDDemuxBXA.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DVDDemuxBXA.cpp; sourceTree = "<group>"; };
                E38E168A0D25F9FA00618676 /* DNSNameCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNSNameCache.h; sourceTree = "<group>"; };
                E38E168C0D25F9FA00618676 /* DynamicDll.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicDll.cpp; sourceTree = "<group>"; };
                E38E168D0D25F9FA00618676 /* DynamicDll.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicDll.h; sourceTree = "<group>"; };
-               E38E16900D25F9FA00618676 /* Favourites.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Favourites.cpp; sourceTree = "<group>"; };
-               E38E16910D25F9FA00618676 /* Favourites.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Favourites.h; sourceTree = "<group>"; };
                E38E16920D25F9FA00618676 /* FileItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileItem.cpp; sourceTree = "<group>"; };
                E38E16930D25F9FA00618676 /* FileItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileItem.h; sourceTree = "<group>"; };
                E38E16970D25F9FA00618676 /* MemBufferCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemBufferCache.cpp; sourceTree = "<group>"; };
                E38E1E2B0D25F9FD00618676 /* CPUInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPUInfo.cpp; sourceTree = "<group>"; };
                E38E1E2C0D25F9FD00618676 /* CPUInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPUInfo.h; sourceTree = "<group>"; };
                E38E1E2E0D25F9FD00618676 /* CriticalSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CriticalSection.h; sourceTree = "<group>"; };
-               E38E1E310D25F9FD00618676 /* DownloadQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DownloadQueue.cpp; sourceTree = "<group>"; };
-               E38E1E320D25F9FD00618676 /* DownloadQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadQueue.h; sourceTree = "<group>"; };
-               E38E1E330D25F9FD00618676 /* DownloadQueueManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DownloadQueueManager.cpp; sourceTree = "<group>"; };
-               E38E1E340D25F9FD00618676 /* DownloadQueueManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadQueueManager.h; sourceTree = "<group>"; };
                E38E1E350D25F9FD00618676 /* Event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Event.cpp; sourceTree = "<group>"; };
                E38E1E360D25F9FD00618676 /* Event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Event.h; sourceTree = "<group>"; };
                E38E1E3D0D25F9FD00618676 /* fstrcmp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fstrcmp.h; sourceTree = "<group>"; };
                                36A9466215CF1FA600727135 /* DbUrl.h */,
                                E38E168C0D25F9FA00618676 /* DynamicDll.cpp */,
                                E38E168D0D25F9FA00618676 /* DynamicDll.h */,
-                               E38E16900D25F9FA00618676 /* Favourites.cpp */,
-                               E38E16910D25F9FA00618676 /* Favourites.h */,
                                E38E16920D25F9FA00618676 /* FileItem.cpp */,
                                E38E16930D25F9FA00618676 /* FileItem.h */,
                                E38E1E3E0D25F9FD00618676 /* GUIInfoManager.cpp */,
                                E4991590174E6ABE00741B6D /* DVDVideoCodecVideoToolBox.h */,
                                E38E15410D25F9F900618676 /* DVDVideoPPFFmpeg.cpp */,
                                E38E15420D25F9F900618676 /* DVDVideoPPFFmpeg.h */,
+                               551C3A43175A12010051AAAD /* VDA.cpp */,
+                               551C3A44175A12010051AAAD /* VDA.h */,
                        );
                        path = Video;
                        sourceTree = "<group>";
                                E38E16B10D25F9FA00618676 /* DirectoryHistory.h */,
                                E38E16B40D25F9FA00618676 /* DllLibCurl.cpp */,
                                E38E16B50D25F9FA00618676 /* DllLibCurl.h */,
+                               0E3036EA1760F68A00D93596 /* FavouritesDirectory.cpp */,
+                               0E3036EB1760F68A00D93596 /* FavouritesDirectory.h */,
                                E38E16BA0D25F9FA00618676 /* File.cpp */,
                                E38E16BB0D25F9FA00618676 /* File.h */,
                                DF93D6671444A8B0007C6459 /* FileCache.cpp */,
                                F5BD02F5148D3A7E001B5583 /* CryptThreading.h */,
                                36A9443B15821E2800727135 /* DatabaseUtils.cpp */,
                                36A9443C15821E2800727135 /* DatabaseUtils.h */,
-                               E38E1E310D25F9FD00618676 /* DownloadQueue.cpp */,
-                               E38E1E320D25F9FD00618676 /* DownloadQueue.h */,
-                               E38E1E330D25F9FD00618676 /* DownloadQueueManager.cpp */,
-                               E38E1E340D25F9FD00618676 /* DownloadQueueManager.h */,
                                7CC30E8816296078003E7579 /* EdenVideoArtUpdater.cpp */,
                                7CC30E8916296078003E7579 /* EdenVideoArtUpdater.h */,
                                436B38F3106628850049AB3B /* EndianSwap.h */,
                                E38E1FFA0D25F9FD00618676 /* DetectDVDType.cpp in Sources */,
                                E38E1FFB0D25F9FD00618676 /* DNSNameCache.cpp in Sources */,
                                E38E1FFC0D25F9FD00618676 /* DynamicDll.cpp in Sources */,
-                               E38E1FFE0D25F9FD00618676 /* Favourites.cpp in Sources */,
                                E38E1FFF0D25F9FD00618676 /* FileItem.cpp in Sources */,
                                E38E20010D25F9FD00618676 /* MemBufferCache.cpp in Sources */,
                                E38E20020D25F9FD00618676 /* CacheStrategy.cpp in Sources */,
                                E38E22C60D25F9FE00618676 /* BitstreamStats.cpp in Sources */,
                                E38E22C70D25F9FE00618676 /* CharsetConverter.cpp in Sources */,
                                E38E22C80D25F9FE00618676 /* CPUInfo.cpp in Sources */,
-                               E38E22CB0D25F9FE00618676 /* DownloadQueue.cpp in Sources */,
-                               E38E22CC0D25F9FE00618676 /* DownloadQueueManager.cpp in Sources */,
                                E38E22CD0D25F9FE00618676 /* Event.cpp in Sources */,
                                E38E22D10D25F9FE00618676 /* GUIInfoManager.cpp in Sources */,
                                E38E22D20D25F9FE00618676 /* HTMLTable.cpp in Sources */,
                                820023DB171A28A300667D1C /* OSXTextInputResponder.mm in Sources */,
                                DF529BAE1741697B00523FB4 /* Environment.cpp in Sources */,
                                DFE4095B17417FDF00473BD9 /* LegacyPathTranslation.cpp in Sources */,
+                               0E3036EC1760F68A00D93596 /* FavouritesDirectory.cpp in Sources */,
+                               551C3A45175A12010051AAAD /* VDA.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                DFF0F3C517528350002DA3A4 /* Crc32.cpp in Sources */,
                                DFF0F3C617528350002DA3A4 /* CryptThreading.cpp in Sources */,
                                DFF0F3C717528350002DA3A4 /* DatabaseUtils.cpp in Sources */,
-                               DFF0F3C817528350002DA3A4 /* DownloadQueue.cpp in Sources */,
-                               DFF0F3C917528350002DA3A4 /* DownloadQueueManager.cpp in Sources */,
                                DFF0F3CA17528350002DA3A4 /* EdenVideoArtUpdater.cpp in Sources */,
                                DFF0F3CB17528350002DA3A4 /* Environment.cpp in Sources */,
                                DFF0F3CC17528350002DA3A4 /* Fanart.cpp in Sources */,
                                DFF0F43817528350002DA3A4 /* DatabaseManager.cpp in Sources */,
                                DFF0F43917528350002DA3A4 /* DbUrl.cpp in Sources */,
                                DFF0F43A17528350002DA3A4 /* DynamicDll.cpp in Sources */,
-                               DFF0F43B17528350002DA3A4 /* Favourites.cpp in Sources */,
                                DFF0F43C17528350002DA3A4 /* FileItem.cpp in Sources */,
                                DFF0F43D17528350002DA3A4 /* GUIInfoManager.cpp in Sources */,
                                DFF0F43E17528350002DA3A4 /* GUILargeTextureManager.cpp in Sources */,
                                DF3C3C0E1752A7EE000989C3 /* IOSEAGLView.mm in Sources */,
                                DF3C3C0F1752A7EE000989C3 /* IOSExternalTouchController.mm in Sources */,
                                DF3C3C101752A7EE000989C3 /* IOSScreenManager.mm in Sources */,
+                               0E3036EE1760F68A00D93596 /* FavouritesDirectory.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                E4991449174E605900741B6D /* Crc32.cpp in Sources */,
                                E499144A174E605900741B6D /* CryptThreading.cpp in Sources */,
                                E499144B174E605900741B6D /* DatabaseUtils.cpp in Sources */,
-                               E499144C174E605900741B6D /* DownloadQueue.cpp in Sources */,
-                               E499144D174E605900741B6D /* DownloadQueueManager.cpp in Sources */,
                                E499144E174E605900741B6D /* EdenVideoArtUpdater.cpp in Sources */,
                                E499144F174E605900741B6D /* Environment.cpp in Sources */,
                                E4991450174E605900741B6D /* Fanart.cpp in Sources */,
                                E4991533174E642900741B6D /* DatabaseManager.cpp in Sources */,
                                E4991534174E642900741B6D /* DbUrl.cpp in Sources */,
                                E4991535174E642900741B6D /* DynamicDll.cpp in Sources */,
-                               E4991536174E642900741B6D /* Favourites.cpp in Sources */,
                                E4991537174E642900741B6D /* FileItem.cpp in Sources */,
                                E4991538174E642900741B6D /* GUIInfoManager.cpp in Sources */,
                                E4991539174E642900741B6D /* GUILargeTextureManager.cpp in Sources */,
                                E4991592174E6B5C00741B6D /* fstrcmp.c in Sources */,
                                E4991593174E707400741B6D /* cc_decoder.c in Sources */,
                                E4991596174E70BF00741B6D /* yuv2rgb.neon.S in Sources */,
+                               0E3036ED1760F68A00D93596 /* FavouritesDirectory.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index e5ae8d4..aefebff 100644 (file)
@@ -135,6 +135,8 @@ halstorage_not_found="== Could not find hal-storage. HAL support disabled. =="
 hal_disabled="== HAL support disabled. =="
 avahi_not_found="== Could not find libavahi-common or libavahi-client. Avahi support disabled. =="
 avahi_disabled="== Avahi support disabled. =="
+mdnsembedded_not_found="== Could not find mDNSEmbedded. Might prevent zeroconf support. =="
+mdnsembedded_disabled="== mDNSEmbedded support disabled. =="
 vdpau_not_found="== Could not find libvdpau. VDPAU support disabled. =="
 vdpau_disabled="== VDPAU support manually disabled. =="
 vaapi_not_found="== Could not find libva. VAAPI support disabled. =="
@@ -422,6 +424,12 @@ AC_ARG_ENABLE([avahi],
   [disable Avahi support (default is enabled if libavahi-common and libavahi-client is found)])],
   [use_avahi=$enableval],
   [use_avahi=yes])
+  
+  AC_ARG_ENABLE([mdnsembedded],
+  [AS_HELP_STRING([--disable-mdnsembedded],
+  [disable mDNSEmbedded support (default is auto)])],
+  [use_mdnsembedded=$enableval],
+  [use_mdnsembedded=auto])
 
 AC_ARG_ENABLE([non-free],
   [AS_HELP_STRING([--disable-non-free],
@@ -698,7 +706,6 @@ case $use_platform in
      use_cpu=arm1176jzf-s
      use_hardcoded_tables="yes"
      use_alsa="no"
-     USE_TEXTUREPACKER_NATIVE_ROOT="$TEXTUREPACKER_NATIVE_ROOT"
      ARCH="arm"
      AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_ARMEL -DTARGET_RASPBERRY_PI")
      AC_DEFINE(HAS_EGLGLES, [1], [Define if supporting EGL based GLES Framebuffer])
@@ -1252,6 +1259,27 @@ else
   fi
 fi
 
+# mdnsembedded
+if test "$use_mdnsembedded" != "no"; then
+  AC_CHECK_LIB([mDNSEmbedded], [embedded_mDNSInit],,
+    [if test "$use_mdnsembedded" = "yes"; then
+      AC_MSG_ERROR($mdnsembedded_not_found)
+      USE_MDNSEMBEDDED=0
+    elif test "$use_mdnsembedded" != "no"; then
+      AC_MSG_NOTICE($mdnsembedded_not_found)
+      use_mdnsembedded="no"
+      USE_MDNSEMBEDDED=0
+    fi
+   ])
+  if test $use_mdnsembedded != "no"; then
+    USE_MDNSEMBEDDED=1
+  fi
+else
+  AC_MSG_RESULT($mdnsembedded_disabled)
+  USE_MDNSEMBEDDED=0
+fi
+AC_SUBST(USE_MDNSEMBEDDED)
+
 # X11
 if test "$use_x11" = "yes" && test "$host_vendor" != "apple"; then
   AC_MSG_NOTICE($x11_enabled)
@@ -1593,9 +1621,6 @@ fi
 if test "$use_external_ffmpeg" = "yes"; then
   FFMPEG_LIBNAMES="libavcodec libavfilter libavformat libavutil libpostproc libswscale"
 
-  # libavcore is optional
-  PKG_CHECK_EXISTS([libavcore], FFMPEG_LIBNAMES="$FFMPEG_LIBNAMES libavcore")
-
   # one of libswresample or libavresample is needed
   PKG_CHECK_EXISTS([libswresample], FFMPEG_LIBNAMES="$FFMPEG_LIBNAMES libswresample",
                    [PKG_CHECK_EXISTS([libavresample],
@@ -1607,52 +1632,16 @@ if test "$use_external_ffmpeg" = "yes"; then
                     [INCLUDES="$INCLUDES $FFMPEG_CFLAGS"; LIBS="$LIBS $FFMPEG_LIBS"],
                     AC_MSG_ERROR($missing_library))
 
-  # Determine whether AVPacket and relevant functions are defined in libavformat
-  # or libavcodec
-  AC_CHECK_LIB([avcodec], [av_free_packet],
-  [AC_MSG_NOTICE(== AVPacket and relevant functions defined in libavcodec. ==)],
-  [AC_MSG_NOTICE(== AVPacket and relevant functions defined in libavformat. ==)
-   AC_DEFINE([AVPACKET_IN_AVFORMAT], [1], [Whether AVPacket is in libavformat.])])
-
   # in case the headers are in a custom directory
   SAVE_CPPFLAGS="$CPPFLAGS"
   CPPFLAGS="$CPPFLAGS $FFMPEG_CFLAGS"
 
-  # Possible places the ffmpeg headers may be
   AC_CHECK_HEADERS([libavcodec/avcodec.h libavfilter/avfilter.h libavformat/avformat.h libavutil/avutil.h libpostproc/postprocess.h libswscale/swscale.h],,
-  [AC_CHECK_HEADERS([ffmpeg/avcodec.h ffmpeg/avfilter.h ffmpeg/avformat.h ffmpeg/avutil.h postproc/postprocess.h ffmpeg/swscale.h],,
-  [AC_MSG_ERROR($missing_headers)])])
-
-  # optional
-  AC_CHECK_HEADERS([libavcore/avcore.h libavcore/samplefmt.h libavutil/mem.h libavutil/samplefmt.h])
-
-  # old FFmpeg have this in libavcodec/opt.h instead:
-  AC_CHECK_HEADERS([libavutil/opt.h])
-
-  # new FFmpeg have math headers
-  AC_CHECK_HEADERS([libavutil/mathematics.h],,)
-
-  # We'll support the use of rgb2rgb.h if it exists.
-  AC_CHECK_HEADERS([libswscale/rgb2rgb.h],,)
-  AC_CHECK_HEADERS([ffmpeg/rgb2rgb.h],,)
+  [AC_MSG_ERROR($missing_headers)])
 
   # Check for libswresample or libavresample headers.
   AC_CHECK_HEADERS([libswresample/swresample.h libavresample/avresample.h])
 
-  # Check if AVFilterBufferRefVideoProps AVRational member is named
-  # 'pixel_aspect' or 'sample_aspect_ratio'.
-  AC_CHECK_MEMBER([AVFilterBufferRefVideoProps.sample_aspect_ratio],
-    [AC_DEFINE([HAVE_AVFILTERBUFFERREFVIDEOPROPS_SAMPLE_ASPECT_RATIO],
-    [1],
-    [Define to 1 if AVFilterBufferRefVideoProps has member sample_aspect_ratio.])],
-      [AC_CHECK_MEMBER([AVFilterBufferRefVideoProps.sample_aspect_ratio],
-      [AC_DEFINE([HAVE_AVFILTERBUFFERREFVIDEOPROPS_SAMPLE_ASPECT_RATIO],
-      [1],
-      [Define to 1 if AVFilterBufferRefVideoProps has member sample_aspect_ratio.])],
-      ,
-      [[#include <ffmpeg/avfilter.h>]])],
-    [[#include <libavfilter/avfilter.h>]])
-
   AC_MSG_NOTICE($external_ffmpeg_enabled)
   USE_EXTERNAL_FFMPEG=1
   AC_DEFINE([USE_EXTERNAL_FFMPEG], [1], [Whether to use external FFmpeg libraries.])
@@ -1666,21 +1655,10 @@ if test "$use_external_ffmpeg" = "yes"; then
       AC_MSG_RESULT($ffmpeg_vdpau_not_supported)
     fi])
 
-  # Check for 'PIX_FMT_VDPAU_MPEG4' from libavutil
-  if test "x$use_vdpau" != "xno"; then
-    AC_LANG_PUSH([C++])
-    AC_LINK_IFELSE(
-      [AC_LANG_SOURCE([ #include <libavutil/pixfmt.h>
-        int main() { PixelFormat format = PIX_FMT_VDPAU_MPEG4; }])],
-      [AC_DEFINE([PIX_FMT_VDPAU_MPEG4_IN_AVUTIL], [1],
-      [Whether AVUtil defines PIX_FMT_VDPAU_MPEG4.])],)
-    AC_LANG_POP([C++])
-  fi
   CPPFLAGS="$SAVE_CPPFLAGS"
 else
   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.])
 fi
 
 echo "Checking for SWIG installation"
@@ -2177,6 +2155,12 @@ else
   final_message="$final_message\n  Avahi:\tNo"
 fi
 
+if test "$use_mdnsembedded" != "no"; then
+  final_message="$final_message\n  mDNSEmbedded:\tYes"
+else
+  final_message="$final_message\n  mDNSEmbedded:\tNo"
+fi
+
 if test "$use_nonfree" = "yes"; then
   final_message="$final_message\n  Non-free:\tYes"
   HAVE_XBMC_NONFREE=1
@@ -2553,7 +2537,7 @@ XB_CONFIG_MODULE([lib/ffmpeg], [
     ffmpg_config="$ffmpg_config --disable-devices  --disable-doc"
     ffmpg_config="$ffmpg_config --disable-ffplay   --disable-ffmpeg"
     ffmpg_config="$ffmpg_config --disable-ffprobe  --disable-ffserver"
-    ffmpg_config="$ffmpg_config --disable-vda      --disable-crystalhd"
+    ffmpg_config="$ffmpg_config --enable-vda       --disable-crystalhd"
     ffmpg_config="$ffmpg_config --disable-decoder=mpeg_xvmc"
 
     # handle conditional enables/disables
index c73cb43..86210a7 100644 (file)
@@ -6116,6 +6116,7 @@ msgid "%i sec"
 msgstr ""
 
 #: system/settings/darwin.xml
+#: system/settings/settings.xml
 msgctxt "#14046"
 msgid "%i ms"
 msgstr ""
index 96bd68d..cf52a14 100644 (file)
@@ -43,21 +43,7 @@ extern "C" {
 #endif
 
 #if (defined USE_EXTERNAL_FFMPEG)
-  #if (defined HAVE_LIBAVCODEC_AVCODEC_H)
-    #include <libavcodec/avcodec.h>
-    #if (defined HAVE_LIBAVCODEC_OPT_H)
-      #include <libavcodec/opt.h>
-    #endif
-    #if (defined AVPACKET_IN_AVFORMAT)
-      #include <libavformat/avformat.h>
-    #endif
-  #elif (defined HAVE_FFMPEG_AVCODEC_H)
-    #include <ffmpeg/avcodec.h>
-    #include <ffmpeg/opt.h>
-    #if (defined AVPACKET_IN_AVFORMAT)
-      #include <ffmpeg/avformat.h>
-    #endif
-  #endif
+  #include <libavcodec/avcodec.h>
 #else
   #include "libavcodec/avcodec.h"
 #endif
@@ -277,7 +263,6 @@ class DllAvCodec : public DllDynamic, DllAvCodecInterface
 
   /* dependencies of libavcodec */
   DllAvUtil m_dllAvUtil;
-  // DllAvUtil loaded implicitely by m_dllAvCore
 
 public:
     static CCriticalSection m_critSection;
index d44b918..11e9234 100644 (file)
@@ -42,15 +42,9 @@ extern "C" {
 #endif
 
 #if (defined USE_EXTERNAL_FFMPEG)
-  #if (defined HAVE_LIBAVFILTER_AVFILTER_H)
-    #include <libavfilter/avfiltergraph.h>
-    #include <libavfilter/buffersink.h>
-    #include <libavfilter/avcodec.h>
-  #elif (defined HAVE_FFMPEG_AVFILTER_H)
-    #include <ffmpeg/avfiltergraph.h>
-    #include <ffmpeg/buffersink.h>
-    #include <ffmpeg/avcodec.h>
-  #endif
+  #include <libavfilter/avfiltergraph.h>
+  #include <libavfilter/buffersink.h>
+  #include <libavfilter/avcodec.h>
 #else
   #include "libavfilter/avfiltergraph.h"
   #include "libavfilter/buffersink.h"
index 791dc01..c3029db 100644 (file)
@@ -37,11 +37,7 @@ extern "C" {
 #pragma warning(disable:4244)
 #endif
 #if (defined USE_EXTERNAL_FFMPEG)
-  #if (defined HAVE_LIBAVFORMAT_AVFORMAT_H)
-    #include <libavformat/avformat.h>
-  #else
-    #include <ffmpeg/avformat.h>
-  #endif
+  #include <libavformat/avformat.h>
   /* xbmc_read_frame_flush() is defined for us in lib/xbmc-dll-symbols/DllAvFormat.c */
   void xbmc_read_frame_flush(AVFormatContext *s);
 #else
index 4d5bec9..1afee5e 100644 (file)
 
 extern "C" {
 #if (defined USE_EXTERNAL_FFMPEG)
-  #if (defined HAVE_LIBAVUTIL_AVUTIL_H)
-    #include <libavutil/avutil.h>
-    // for av_get_default_channel_layout
-    #include <libavutil/audioconvert.h>
-    #include <libavutil/crc.h>
-    #include <libavutil/fifo.h>
-    // for enum AVSampleFormat
-    #include <libavutil/samplefmt.h>
-    // for LIBAVCODEC_VERSION_INT:
-    #include <libavcodec/avcodec.h>
-  #elif (defined HAVE_FFMPEG_AVUTIL_H)
-    #include <ffmpeg/avutil.h>
-    // for av_get_default_channel_layout
-    #include <ffmpeg/audioconvert.h>
-    #include <ffmpeg/crc.h>
-    #include <ffmpeg/fifo.h>
-    // for enum AVSampleFormat
-    #include <ffmpeg/samplefmt.h>
-    // for LIBAVCODEC_VERSION_INT:
-    #include <ffmpeg/avcodec.h>
-  #endif
-  #if defined(HAVE_LIBAVUTIL_OPT_H)
-    #include <libavutil/opt.h>
-  #elif defined(HAVE_LIBAVCODEC_AVCODEC_H)
-    #include <libavcodec/opt.h>
-  #else
-    #include <ffmpeg/opt.h>
-  #endif
-  #if defined(HAVE_LIBAVUTIL_MEM_H)
-    #include <libavutil/mem.h>
-  #else
-    #include <ffmpeg/mem.h>
-  #endif
-  #if (defined HAVE_LIBAVUTIL_MATHEMATICS_H)
-    #include <libavutil/mathematics.h>
-  #endif
+  #include <libavutil/avutil.h>
+  // for av_get_default_channel_layout
+  #include <libavutil/audioconvert.h>
+  #include <libavutil/crc.h>
+  #include <libavutil/fifo.h>
+  // for LIBAVCODEC_VERSION_INT:
+  #include <libavcodec/avcodec.h>
+  // for enum AVSampleFormat
+  #include <libavutil/samplefmt.h>
+  #include <libavutil/opt.h>
+  #include <libavutil/mem.h>
+  #include <libavutil/mathematics.h>
 #else
   #include "libavutil/avutil.h"
   //for av_get_default_channel_layout
@@ -116,6 +92,7 @@ public:
   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 void av_dict_free(AVDictionary **pm) = 0;
   virtual int av_samples_get_buffer_size (int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align) = 0;
   virtual int64_t av_get_default_channel_layout(int nb_channels)=0;
 };
@@ -152,6 +129,7 @@ public:
     { 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 void av_dict_free(AVDictionary **pm) { ::av_dict_free(pm); }
   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); }
   virtual int64_t av_get_default_channel_layout(int nb_channels) { return ::av_get_default_channel_layout(nb_channels); }
@@ -197,6 +175,7 @@ class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
   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_METHOD1(void, av_dict_free, (AVDictionary **p1));
   DEFINE_METHOD5(int, av_samples_get_buffer_size, (int *p1, int p2, int p3, enum AVSampleFormat p4, int p5))
   DEFINE_METHOD1(int64_t, av_get_default_channel_layout, (int p1))
 
@@ -224,6 +203,7 @@ class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
     RESOLVE_METHOD(av_get_bytes_per_sample)
     RESOLVE_METHOD(av_dict_get)
     RESOLVE_METHOD(av_dict_set)
+    RESOLVE_METHOD(av_dict_free)
     RESOLVE_METHOD(av_samples_get_buffer_size)
     RESOLVE_METHOD(av_get_default_channel_layout)
   END_METHOD_RESOLVE()
index 04115c5..0797eb5 100644 (file)
@@ -39,16 +39,8 @@ extern "C" {
 #endif
   
 #if (defined USE_EXTERNAL_FFMPEG)
-  #if (defined HAVE_LIBAVUTIL_AVUTIL_H)
-    #include <libavutil/avutil.h>
-  #elif (defined HAVE_FFMPEG_AVUTIL_H)
-    #include <ffmpeg/avutil.h>
-  #endif
-  #if (defined HAVE_LIBPOSTPROC_POSTPROCESS_H)
-    #include <libpostproc/postprocess.h>
-  #elif (defined HAVE_POSTPROC_POSTPROCESS_H)
-    #include <postproc/postprocess.h>
-  #endif
+  #include <libavutil/avutil.h>
+  #include <libpostproc/postprocess.h>
 #else
   #include "libavutil/avutil.h"
   #include "libpostproc/postprocess.h"
index fd2ee57..7e98bef 100644 (file)
@@ -45,11 +45,7 @@ extern "C" {
 #endif
 
 #if (defined USE_EXTERNAL_FFMPEG)
-  #if (defined HAVE_LIBSWSCALE_SWSCALE_H)
-    #include <libswscale/swscale.h>
-  #elif (defined HAVE_FFMPEG_SWSCALE_H)
-    #include <ffmpeg/swscale.h>
-  #endif
+  #include <libswscale/swscale.h>
 #else
   #include "libswscale/swscale.h"
 #endif
index da618d2..2d338a1 100644 (file)
@@ -126,7 +126,7 @@ void CommandData::ParseDone()
 }
 
 
-#if !defined(SFX_MODULE) && !defined(_WIN_CE) && !defined(_LINUX)
+#if !defined(SFX_MODULE) && !defined(_WIN_CE) && !defined(TARGET_POSIX)
 void CommandData::ParseEnvVar()
 {
   char *EnvStr=getenv("RAR");
index 0ac3215..cf8ada1 100644 (file)
@@ -1,4 +1,4 @@
-#if !defined(_LINUX) && !defined(_XBMC)
+#if !defined(TARGET_POSIX) && !defined(_XBMC)
 #include "rar.hpp"
 
 #ifndef GUI
index 192a82a..4980e9d 100644 (file)
@@ -201,7 +201,7 @@ void CryptData::SetCryptKeys(char *Password,byte *Salt,bool Encrypt,bool OldOnly
     Key[2]=0x7515A235L;
     Key[3]=0xA4E7F123L;
     memset(Psw,0,sizeof(Psw));
-#if defined(_WIN_32) && !defined(GUI) && !defined(_LINUX)
+#if defined(_WIN_32) && !defined(GUI) && !defined(TARGET_POSIX)
     CharToOemBuff(Password,(char*)Psw,strlen(Password));
 #else
     strncpy((char *)Psw,Password,MAXPASSWORD-1);
index 8f24588..4b74312 100644 (file)
@@ -265,7 +265,7 @@ extern "C"
 void _stdfunction ProcessSignal(int SigType)
 #endif
 {
-#if defined(_WIN_32) && !defined(_LINUX)
+#if defined(_WIN_32) && !defined(TARGET_POSIX)
   if (SigType==CTRL_LOGOFF_EVENT)
     return(TRUE);
 #endif
@@ -280,7 +280,7 @@ void _stdfunction ProcessSignal(int SigType)
 #if defined(USE_RC) && !defined(SFX_MODULE) && !defined(_WIN_CE)
   ExtRes.UnloadDLL();
 #endif
-#if !defined(_LINUX)
+#if !defined(TARGET_POSIX)
   exit(USER_BREAK);
 #endif
 #ifdef _WIN_32
@@ -313,7 +313,7 @@ void ErrorHandler::Throw(int Code)
   throw Code;
 #else
   File::RemoveCreated();
-#if !defined(_XBMC) && !defined(_LINUX)
+#if !defined(_XBMC) && !defined(TARGET_POSIX)
   exit(Code);
 #endif
 #endif
index 4d9860d..e2d1074 100644 (file)
@@ -230,7 +230,7 @@ bool File::Close()
     {*/
       if (!SkipClose)
       {
-#if defined(_WIN_32) || defined(_LINUX)
+#if defined(_WIN_32) || defined(TARGET_POSIX)
         //success=CloseHandle(hFile) != FALSE;
         m_File.Close();
 #else
@@ -320,7 +320,7 @@ void File::Write(const void *Data,int Size)
   while (1)
   {
     bool success = true;
-#if defined(_WIN_32) || defined(_LINUX)
+#if defined(_WIN_32) || defined(TARGET_POSIX)
     DWORD Written=0;
     if (HandleType!=FILE_HANDLENORMAL)
     {
@@ -350,7 +350,7 @@ void File::Write(const void *Data,int Size)
 #endif
       if (ErrHandler.AskRepeatWrite(FileName))
       {
-#if !defined(_WIN_32) && !defined(_LINUX)
+#if !defined(_WIN_32) && !defined(TARGET_POSIX)
         clearerr(hFile);
 #endif
       if (Written<(unsigned int)Size && Written>0)
@@ -485,7 +485,7 @@ bool File::RawSeek(Int64 Offset,int Method)
     Offset=(Method==SEEK_CUR ? Tell():FileLength())+Offset;
     Method=SEEK_SET;
   }*/
-#if defined(_WIN_32) || defined(_LINUX)
+#if defined(_WIN_32) || defined(TARGET_POSIX)
   //LONG HighDist=int64to32(Offset>>32);
   //if (SetFilePointer(hFile,int64to32(Offset),&HighDist,Method)==0xffffffff &&
   if (Offset > FileLength())
@@ -510,7 +510,7 @@ bool File::RawSeek(Int64 Offset,int Method)
 
 Int64 File::Tell()
 {
-#if defined(_WIN_32) || defined(_LINUX)
+#if defined(_WIN_32) || defined(TARGET_POSIX)
   //LONG HighDist=0;
   //uint LowDist=SetFilePointer(hFile,0,&HighDist,FILE_CURRENT);
   //Int64 pos = m_File.GetPosition();
@@ -620,7 +620,7 @@ void File::SetCloseFileTimeByName(const char *Name,RarTime *ftm,RarTime *fta)
 
 void File::GetOpenFileTime(RarTime *ft)
 {
-#if defined(_WIN_32) || defined(_LINUX)
+#if defined(_WIN_32) || defined(TARGET_POSIX)
 /*  FILETIME FileTime;
   GetFileTime(hFile,NULL,NULL,&FileTime);
   *ft=FileTime;*/
@@ -675,7 +675,7 @@ bool File::IsDevice()
 {
   /*if (hFile==BAD_HANDLE)
     return(false);*/
-#if defined(_XBOX) || defined(_LINUX) || defined(_XBMC)
+#if defined(_XBOX) || defined(TARGET_POSIX) || defined(_XBMC)
   return false;
 //#ifdef _WIN_32
 #elif defined(_WIN_32)
index 1165259..4299803 100644 (file)
@@ -1,5 +1,5 @@
 #include "rar.hpp"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "XFileUtils.h"
 #endif
 
@@ -34,7 +34,7 @@ void SetDirTime(const char *Name,RarTime *ftm,RarTime *ftc,RarTime *fta)
 
 bool IsRemovable(const char *Name)
 {
-#if defined(_LINUX)
+#if defined(TARGET_POSIX)
   return false;
 //#ifdef _WIN_32
 #elif defined(_WIN_32)
@@ -54,7 +54,7 @@ bool IsRemovable(const char *Name)
 #ifndef SFX_MODULE
 Int64 GetFreeDisk(const char *Name)
 {
-#if defined(_LINUX)
+#if defined(TARGET_POSIX)
   char Root[NM];
   GetPathRoot(Name,Root);
 
@@ -146,7 +146,7 @@ Int64 GetFreeDisk(const char *Name)
 bool FileExist(const char *Name,const wchar *NameW)
 {
 #ifdef _WIN_32
-#if !defined(_LINUX)
+#if !defined(TARGET_POSIX)
     if (WinNT() && NameW!=NULL && *NameW!=0)
       return(GetFileAttributesW(NameW)!=0xffffffff);
     else
@@ -242,7 +242,7 @@ void PrepareToDelete(const char *Name,const wchar *NameW)
 uint GetFileAttr(const char *Name,const wchar *NameW)
 {
 #ifdef _WIN_32
-#if !defined(_LINUX)
+#if !defined(TARGET_POSIX)
     if (WinNT() && NameW!=NULL && *NameW!=0)
       return(GetFileAttributesW(NameW));
     else
@@ -267,7 +267,7 @@ bool SetFileAttr(const char *Name,const wchar *NameW,uint Attr)
 {
   bool success;
 #ifdef _WIN_32
-#if !defined(_LINUX)
+#if !defined(TARGET_POSIX)
     if (WinNT() && NameW!=NULL && *NameW!=0)
       success=SetFileAttributesW(NameW,Attr)!=0;
     else
@@ -290,7 +290,7 @@ void ConvertNameToFull(const char *Src,char *Dest)
 {
 #ifdef _WIN_32
 //#ifndef _WIN_CE
-#if !defined(_WIN_CE) && !defined(_LINUX)
+#if !defined(_WIN_CE) && !defined(TARGET_POSIX)
   char FullName[NM],*NamePtr;
   if (GetFullPathName(Src,sizeof(FullName),FullName,&NamePtr))
     strcpy(Dest,FullName);
@@ -329,7 +329,7 @@ void ConvertNameToFull(const wchar *Src,wchar *Dest)
 #endif
   {
 //#ifndef _WIN_CE
-#if !defined(_WIN_CE) && !defined(_LINUX)
+#if !defined(_WIN_CE) && !defined(TARGET_POSIX)
     wchar FullName[NM],*NamePtr;
     if (GetFullPathNameW(Src,sizeof(FullName)/sizeof(FullName[0]),FullName,&NamePtr))
       strcpyw(Dest,FullName);
index 571a71b..e43cbfc 100644 (file)
@@ -113,7 +113,7 @@ bool ReadTextFile(char *Name,StringList *List,bool Config,bool AbortOnError,
             CurStr++;
           }
         }
-#if defined(_WIN_32) && !defined(_LINUX)
+#if defined(_WIN_32) && !defined(TARGET_POSIX)
         if (ConvertToAnsi)
           OemToChar(CurStr,CurStr);
 #endif
index 8f28bd4..063577a 100644 (file)
@@ -183,7 +183,7 @@ bool FindFile::FastFind(const char *FindMask,const wchar *FindMaskW,struct FindD
 #ifdef _WIN_32
 HANDLE FindFile::Win32Find(HANDLE hFind,const char *Mask,const wchar *MaskW,struct FindData *fd)
 {
-#if !defined(_LINUX)
+#if !defined(TARGET_POSIX)
 #ifndef _WIN_CE
   if (WinNT())
 #endif
index 165d01b..e7abcdc 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _RAR_OS_
 #define _RAR_OS_
 
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
 #include <windows.h>
 #endif
 
@@ -38,7 +38,7 @@
 
 #include "system.h"
 #include <prsht.h>
-#if defined(_LINUX)
+#if defined(TARGET_POSIX)
 #include "PlatformDefs.h"
 #endif
 
index 2da5ea7..5be0db0 100644 (file)
@@ -343,7 +343,7 @@ bool EnumConfigPaths(char *Path,int Number)
 #elif defined(_WIN_32)
   if (Number!=0)
     return(false);
-#if !defined(_LINUX)
+#if !defined(TARGET_POSIX)
   GetModuleFileName(NULL,Path,NM);
   RemoveNameFromPath(Path);
 #endif
index 1b5ad04..7515f7e 100644 (file)
@@ -13,7 +13,7 @@ extern "C" char **__crt0_glob_function (char *arg) { return 0; }
 extern "C" void   __crt0_load_environment_file (char *progname) { }
 #endif
 
-#if !defined(GUI) && !defined(RARDLL) && !defined(_LINUX) && !defined(_XBMC)
+#if !defined(GUI) && !defined(RARDLL) && !defined(TARGET_POSIX) && !defined(_XBMC)
 int main(int argc, char *argv[])
 {
 #ifdef _UNIX
@@ -129,7 +129,7 @@ int main(int argc, char *argv[])
 #endif
 
 
-#if defined(_LINUX) || defined(_XBMC)
+#if defined(TARGET_POSIX) || defined(_XBMC)
 /*-------------------------------------------------------------------------*\
                                XBOX interface
 \*-------------------------------------------------------------------------*/
index d51666c..c10c7d4 100644 (file)
@@ -11,13 +11,13 @@ const int N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4;
 const int N_INDEXES=N1+N2+N3+N4;
 
 // FIXME, this is probably broken on OS X.
-#if (defined(__GNUC__) || defined(_LINUX)) && !defined(__APPLE__)
+#if (defined(__GNUC__) || defined(TARGET_POSIX)) && !defined(TARGET_DARWIN)
 #define _PACK_ATTR __attribute__ ((__packed__))
 #else
 #define _PACK_ATTR
 #endif /* defined(__GNUC__) */
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #pragma pack(1)
 #endif
 struct RAR_MEM_BLK 
index 89e63fd..135eac4 100644 (file)
@@ -367,7 +367,7 @@ SupportDBCS::SupportDBCS()
 
 void SupportDBCS::Init()
 {
-#if defined(_LINUX)
+#if defined(TARGET_POSIX)
   DBCSMode = true;
   for (int I=0;I<sizeof(IsLeadByte)/sizeof(IsLeadByte[0]);I++)
     IsLeadByte[I]=true;
index e4339a5..7fb54a0 100644 (file)
@@ -47,7 +47,7 @@
     <ClCompile>
       <Optimization>Disabled</Optimization>
       <AdditionalIncludeDirectories>..\..\..\..\..\xbmc\addons\include;..\..\..\..\..\xbmc\addons;..\..\..\..\..\xbmc\cores\dvdplayer\DVDDemuxers;..\..\..\..\..\xbmc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_WIN32;_DEBUG;_WINDOWS;VDR_EXPORTS;_WIN32PC;_WINSOCKAPI_;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>TARGET_WINDOWS;_WIN32;_DEBUG;_WINDOWS;VDR_EXPORTS;_WIN32PC;_WINSOCKAPI_;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <ExceptionHandling>Sync</ExceptionHandling>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -65,7 +65,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
       <AdditionalIncludeDirectories>..\..\..\..\..\xbmc\addons\include;..\..\..\..\..\xbmc\addons;..\..\..\..\..\xbmc\cores\dvdplayer\DVDDemuxers;..\..\..\..\..\xbmc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;HAS_SDL_OPENGL;HAS_SDL;_USRDLL;XBMC_VDR_EXPORTS;_WIN32PC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>TARGET_WINDOWS;WIN32;NDEBUG;_WINDOWS;HAS_SDL_OPENGL;HAS_SDL;_USRDLL;XBMC_VDR_EXPORTS;_WIN32PC;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ExceptionHandling>Sync</ExceptionHandling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <PrecompiledHeader>
index 4d13861..f48b942 100644 (file)
@@ -47,7 +47,7 @@
     <ClCompile>
       <Optimization>Disabled</Optimization>
       <AdditionalIncludeDirectories>..\..\..\..\..\xbmc;..\..\..\..\..\xbmc\addons\include;..\..\..\..\..\xbmc\cores\dvdplayer\DVDDemuxers;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_WIN32;_DEBUG;_WINDOWS;VDR_EXPORTS;_WIN32PC;_WINSOCKAPI_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>TARGET_WINDOWS;_WIN32;_DEBUG;_WINDOWS;VDR_EXPORTS;_WIN32PC;_WINSOCKAPI_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <ExceptionHandling>Sync</ExceptionHandling>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -65,7 +65,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
       <AdditionalIncludeDirectories>..\..\..\..\..\xbmc;..\..\..\..\..\xbmc\addons\include;..\..\..\..\..\xbmc\cores\dvdplayer\DVDDemuxers;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;HAS_SDL_OPENGL;HAS_SDL;_USRDLL;XBMC_VDR_EXPORTS;_WIN32PC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>TARGET_WINDOWS;WIN32;NDEBUG;_WINDOWS;HAS_SDL_OPENGL;HAS_SDL;_USRDLL;XBMC_VDR_EXPORTS;_WIN32PC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ExceptionHandling>Sync</ExceptionHandling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <PrecompiledHeader>
index 0d9986a..11d203e 100644 (file)
@@ -47,7 +47,7 @@
     <ClCompile>
       <Optimization>Disabled</Optimization>
       <AdditionalIncludeDirectories>..\..\..\..\..\xbmc;..\..\..\..\..\xbmc\addons\include;..\..\..\..\..\xbmc\cores\dvdplayer\DVDDemuxers;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_WIN32;_DEBUG;_WINDOWS;VDR_EXPORTS;_WIN32PC;_WINSOCKAPI_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>TARGET_WINDOWS;_WIN32;_DEBUG;_WINDOWS;VDR_EXPORTS;_WIN32PC;_WINSOCKAPI_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <ExceptionHandling>Sync</ExceptionHandling>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -65,7 +65,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
       <AdditionalIncludeDirectories>..\..\..\..\..\xbmc;..\..\..\..\..\xbmc\addons\include;..\..\..\..\..\xbmc\cores\dvdplayer\DVDDemuxers;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;HAS_SDL_OPENGL;HAS_SDL;_USRDLL;XBMC_VDR_EXPORTS;_WIN32PC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>TARGET_WINDOWS;WIN32;NDEBUG;_WINDOWS;HAS_SDL_OPENGL;HAS_SDL;_USRDLL;XBMC_VDR_EXPORTS;_WIN32PC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ExceptionHandling>Sync</ExceptionHandling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <PrecompiledHeader>
index de7070e..e3127d9 100644 (file)
@@ -58,7 +58,7 @@
  *
  * @deprecated Use synchronous decoding mode.
  */
-typedef struct {
+typedef struct vda_frame {
     /**
      * The PTS of the frame.
      *
index bce843c..8edaf99 100644 (file)
@@ -39,7 +39,7 @@ typedef unsigned __int64   u64;
 typedef          __int64   s64;
 #define U64F "I64"
 #endif
-#ifdef _LINUX
+#ifndef _WIN32
 typedef unsigned long long u64;
 typedef signed long long s64;
 #define U64F "l"
index 61db83c..966741c 100644 (file)
@@ -61,11 +61,6 @@ struct DAAP_SClientTAG
 #endif
 
     HTTP_ConnectionWatch *update_watch;
-
-#if !defined(WIN32) && !defined(_LINUX)
-  // why is this here?
-       SDiscover *discover;
-#endif
 };
 
 typedef struct
@@ -133,14 +128,14 @@ struct SDiscoverTAG
                                      and tests it for death */
     ts_mutex mtWorkerLock;
 
-#ifndef _LINUX
+#ifdef _WIN32
     fnDiscUpdated pfnUpdateCallback;
 #endif
     void *pvCallbackArg;
 
     struct CP_SThreadPool *tp;
 
-#ifndef _LINUX
+#ifdef _WIN32
     mdnsd mdnsd_info;
 #endif
     int socket;
@@ -149,7 +144,7 @@ struct SDiscoverTAG
     // answers
     /* answers */
     int pending_hosts;
-#ifndef _LINUX
+#ifdef _WIN32
     SDiscover_HostList *prenamed;
     SDiscover_HostList *pending;
     SDiscover_HostList *have;
index c434815..8d4808c 100644 (file)
     <ClCompile Include="..\..\xbmc\epg\EpgInfoTag.cpp" />
     <ClCompile Include="..\..\xbmc\epg\EpgSearchFilter.cpp" />
     <ClCompile Include="..\..\xbmc\epg\GUIEPGGridContainer.cpp" />
-    <ClCompile Include="..\..\xbmc\Favourites.cpp" />
     <ClCompile Include="..\..\xbmc\FileItem.cpp" />
     <ClCompile Include="..\..\xbmc\filesystem\AddonsDirectory.cpp" />
     <ClCompile Include="..\..\xbmc\filesystem\AFPDirectory.cpp" />
     <ClCompile Include="..\..\xbmc\filesystem\DllLibCurl.cpp" />
     <ClCompile Include="..\..\xbmc\filesystem\File.cpp" />
     <ClCompile Include="..\..\xbmc\filesystem\FileCache.cpp" />
+    <ClCompile Include="..\..\xbmc\filesystem\FavouritesDirectory.cpp" />
     <ClCompile Include="..\..\xbmc\filesystem\FileDirectoryFactory.cpp" />
     <ClCompile Include="..\..\xbmc\filesystem\FileFactory.cpp" />
     <ClCompile Include="..\..\xbmc\filesystem\FileReaderFile.cpp" />
     <ClCompile Include="..\..\xbmc\network\httprequesthandler\HTTPWebinterfaceAddonsHandler.cpp" />
     <ClCompile Include="..\..\xbmc\network\httprequesthandler\HTTPWebinterfaceHandler.cpp" />
     <ClCompile Include="..\..\xbmc\network\httprequesthandler\IHTTPRequestHandler.cpp" />
+    <ClCompile Include="..\..\xbmc\network\mdns\ZeroconfBrowserMDNS.cpp" />
+    <ClCompile Include="..\..\xbmc\network\mdns\ZeroconfMDNS.cpp" />
     <ClCompile Include="..\..\xbmc\network\Network.cpp" />
     <ClCompile Include="..\..\xbmc\network\NetworkServices.cpp" />
     <ClCompile Include="..\..\xbmc\network\Socket.cpp" />
     <ClCompile Include="..\..\xbmc\network\websocket\WebSocketV13.cpp" />
     <ClCompile Include="..\..\xbmc\network\websocket\WebSocketV8.cpp" />
     <ClCompile Include="..\..\xbmc\network\windows\NetworkWin32.cpp" />
-    <ClCompile Include="..\..\xbmc\network\windows\ZeroconfBrowserWIN.cpp" />
-    <ClCompile Include="..\..\xbmc\network\windows\ZeroconfWIN.cpp" />
     <ClCompile Include="..\..\xbmc\network\Zeroconf.cpp" />
     <ClCompile Include="..\..\xbmc\network\ZeroconfBrowser.cpp" />
     <ClCompile Include="..\..\xbmc\NfoFile.cpp" />
     <ClInclude Include="..\..\xbmc\network\httprequesthandler\IHTTPRequestHandler.h" />
     <ClInclude Include="..\..\xbmc\filesystem\CircularCache.h" />
     <ClInclude Include="..\..\xbmc\filesystem\DirectoryCache.h" />
+    <ClInclude Include="..\..\xbmc\filesystem\FavouritesDirectory.h" />
     <ClInclude Include="..\..\xbmc\filesystem\FileCache.h" />
     <ClInclude Include="..\..\xbmc\filesystem\MemBufferCache.h" />
     <ClInclude Include="..\..\xbmc\filesystem\AddonsDirectory.h" />
     <ClInclude Include="..\..\xbmc\filesystem\ZipDirectory.h" />
     <ClInclude Include="..\..\xbmc\filesystem\ZipFile.h" />
     <ClInclude Include="..\..\xbmc\filesystem\ZipManager.h" />
-    <ClInclude Include="..\..\xbmc\network\windows\ZeroconfBrowserWIN.h" />
+    <ClInclude Include="..\..\xbmc\network\mdns\ZeroconfBrowserMDNS.h" />
     <ClInclude Include="..\..\xbmc\peripherals\devices\PeripheralImon.h" />
     <ClInclude Include="..\..\xbmc\system_gl.h">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">true</ExcludedFromBuild>
     <ClCompile Include="..\..\xbmc\utils\CPUInfo.cpp" />
     <ClCompile Include="..\..\xbmc\utils\Crc32.cpp" />
     <ClCompile Include="..\..\xbmc\utils\DatabaseUtils.cpp" />
-    <ClCompile Include="..\..\xbmc\utils\DownloadQueue.cpp" />
-    <ClCompile Include="..\..\xbmc\utils\DownloadQueueManager.cpp" />
     <ClCompile Include="..\..\xbmc\utils\EdenVideoArtUpdater.cpp" />
     <ClCompile Include="..\..\xbmc\utils\EndianSwap.cpp" />
     <ClCompile Include="..\..\xbmc\utils\Fanart.cpp" />
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (OpenGL)|Win32'">true</ExcludedFromBuild>
     </ClCompile>
-    <ClCompile Include="..\..\xbmc\utils\test\TestDownloadQueue.cpp">
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (OpenGL)|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (OpenGL)|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Testsuite|Win32'">true</ExcludedFromBuild>
-    </ClCompile>
-    <ClCompile Include="..\..\xbmc\utils\test\TestDownloadQueueManager.cpp">
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (OpenGL)|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (OpenGL)|Win32'">true</ExcludedFromBuild>
-    </ClCompile>
     <ClCompile Include="..\..\xbmc\utils\test\TestEndianSwap.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (OpenGL)|Win32'">true</ExcludedFromBuild>
     <ClCompile Include="..\..\xbmc\win32\stdio_utf8.cpp" />
     <ClCompile Include="..\..\xbmc\win32\strverscmp.cpp" />
     <ClCompile Include="..\..\xbmc\win32\Win32DelayedDllLoad.cpp" />
-    <ClCompile Include="..\..\xbmc\win32\win32env.cpp" />
     <ClCompile Include="..\..\xbmc\win32\WIN32Util.cpp" />
     <ClCompile Include="..\..\xbmc\win32\WindowHelper.cpp" />
     <ClCompile Include="..\..\xbmc\win32\XBMC_PC.cpp">
     <ClInclude Include="..\..\xbmc\epg\EpgInfoTag.h" />
     <ClInclude Include="..\..\xbmc\epg\EpgSearchFilter.h" />
     <ClInclude Include="..\..\xbmc\epg\GUIEPGGridContainer.h" />
-    <ClInclude Include="..\..\xbmc\Favourites.h" />
     <ClInclude Include="..\..\xbmc\FileItem.h" />
     <ClInclude Include="..\..\xbmc\filesystem\PVRDirectory.h" />
     <ClInclude Include="..\..\xbmc\filesystem\PVRFile.h" />
     <ClInclude Include="..\..\xbmc\network\EventServer.h" />
     <ClInclude Include="..\..\xbmc\network\GUIDialogAccessPoints.h" />
     <ClInclude Include="..\..\xbmc\network\GUIDialogNetworkSetup.h" />
+    <ClInclude Include="..\..\xbmc\network\mdns\ZeroconfMDNS.h" />    
     <ClInclude Include="..\..\xbmc\network\Network.h" />
     <ClInclude Include="..\..\xbmc\network\Socket.h" />
     <ClInclude Include="..\..\xbmc\network\TCPServer.h" />
     <ClInclude Include="..\..\xbmc\network\UdpClient.h" />
     <ClInclude Include="..\..\xbmc\network\WebServer.h" />
     <ClInclude Include="..\..\xbmc\network\windows\NetworkWin32.h" />
-    <ClInclude Include="..\..\xbmc\network\windows\ZeroconfWIN.h" />
     <ClInclude Include="..\..\xbmc\network\Zeroconf.h" />
     <ClInclude Include="..\..\xbmc\network\ZeroconfBrowser.h" />
     <ClInclude Include="..\..\xbmc\NfoFile.h" />
     <ClInclude Include="..\..\xbmc\utils\CPUInfo.h" />
     <ClInclude Include="..\..\xbmc\utils\Crc32.h" />
     <ClInclude Include="..\..\xbmc\utils\DatabaseUtils.h" />
-    <ClInclude Include="..\..\xbmc\utils\DownloadQueue.h" />
-    <ClInclude Include="..\..\xbmc\utils\DownloadQueueManager.h" />
     <ClInclude Include="..\..\xbmc\utils\EdenVideoArtUpdater.h" />
     <ClInclude Include="..\..\xbmc\utils\EndianSwap.h" />
     <ClInclude Include="..\..\xbmc\utils\Fanart.h" />
index 5191d12..da8e592 100644 (file)
     <Filter Include="input\touch\generic">
       <UniqueIdentifier>{d062c356-66f2-49e7-9510-b216701d2298}</UniqueIdentifier>
     </Filter>
+    <Filter Include="network\mdns">
+      <UniqueIdentifier>{4deb3d70-7772-42be-8884-4a550c1ff666}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\xbmc\win32\pch.cpp">
     <ClCompile Include="..\..\xbmc\utils\Crc32.cpp">
       <Filter>utils</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\xbmc\utils\DownloadQueue.cpp">
-      <Filter>utils</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\xbmc\utils\DownloadQueueManager.cpp">
-      <Filter>utils</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\xbmc\utils\Fanart.cpp">
       <Filter>utils</Filter>
     </ClCompile>
     <ClCompile Include="..\..\xbmc\win32\Win32DelayedDllLoad.cpp">
       <Filter>win32</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\xbmc\win32\win32env.cpp">
-      <Filter>win32</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\xbmc\interfaces\json-rpc\InputOperations.cpp">
       <Filter>interfaces\json-rpc</Filter>
     </ClCompile>
     <ClCompile Include="..\..\xbmc\utils\HttpParser.cpp">
       <Filter>utils</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\xbmc\network\windows\ZeroconfWIN.cpp">
-      <Filter>network\windows</Filter>
+    <ClCompile Include="..\..\xbmc\network\mdns\ZeroconfMDNS.cpp">
+      <Filter>network\mdns</Filter>
     </ClCompile>
     <ClCompile Include="..\..\xbmc\peripherals\Peripherals.cpp">
       <Filter>peripherals</Filter>
     <ClCompile Include="..\..\xbmc\filesystem\DirectoryCache.cpp">
       <Filter>filesystem</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\xbmc\filesystem\FavouritesDirectory.cpp">
+      <Filter>filesystem</Filter>
+    </ClCompile>
     <ClCompile Include="..\..\xbmc\filesystem\FileCache.cpp">
       <Filter>filesystem</Filter>
     </ClCompile>
     <ClCompile Include="..\..\xbmc\network\ZeroconfBrowser.cpp">
       <Filter>network</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\xbmc\network\windows\ZeroconfBrowserWIN.cpp">
-      <Filter>network\windows</Filter>
+    <ClCompile Include="..\..\xbmc\network\mdns\ZeroconfBrowserMDNS.cpp">
+      <Filter>network\mdns</Filter>
     </ClCompile>
     <ClCompile Include="..\..\xbmc\cores\AudioEngine\Encoders\AEEncoderFFmpeg.cpp">
       <Filter>cores\AudioEngine\Encoders</Filter>
     <ClCompile Include="..\..\xbmc\ApplicationMessenger.cpp" />
     <ClCompile Include="..\..\xbmc\Autorun.cpp" />
     <ClCompile Include="..\..\xbmc\AutoSwitch.cpp" />
-    <ClCompile Include="..\..\xbmc\Favourites.cpp" />
     <ClCompile Include="..\..\xbmc\DynamicDll.cpp" />
     <ClCompile Include="..\..\xbmc\CueDocument.cpp" />
     <ClCompile Include="..\..\xbmc\FileItem.cpp" />
     <ClCompile Include="..\..\xbmc\utils\test\TestDatabaseUtils.cpp">
       <Filter>utils\test</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\xbmc\utils\test\TestDownloadQueue.cpp">
-      <Filter>utils\test</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\xbmc\utils\test\TestDownloadQueueManager.cpp">
-      <Filter>utils\test</Filter>
-    </ClCompile>
     <ClCompile Include="..\..\xbmc\utils\test\TestEndianSwap.cpp">
       <Filter>utils\test</Filter>
     </ClCompile>
     <ClInclude Include="..\..\xbmc\utils\Crc32.h">
       <Filter>utils</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\xbmc\utils\DownloadQueue.h">
-      <Filter>utils</Filter>
-    </ClInclude>
-    <ClInclude Include="..\..\xbmc\utils\DownloadQueueManager.h">
-      <Filter>utils</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\xbmc\utils\EdenVideoArtUpdater.h">
       <Filter>utils</Filter>
     </ClInclude>
     <ClInclude Include="..\..\xbmc\utils\HttpParser.h">
       <Filter>utils</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\xbmc\network\windows\ZeroconfWIN.h">
-      <Filter>network\windows</Filter>
+    <ClInclude Include="..\..\xbmc\network\mdns\ZeroconfMDNS.h">
+      <Filter>network\mdns</Filter>
     </ClInclude>
     <ClInclude Include="..\..\xbmc\network\DllLibPlist.h">
       <Filter>network</Filter>
     <ClInclude Include="..\..\xbmc\filesystem\DirectoryCache.h">
       <Filter>filesystem</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\xbmc\filesystem\FavouritesDirectory.h">
+      <Filter>filesystem</Filter>
+    </ClInclude>
     <ClInclude Include="..\..\xbmc\filesystem\FileCache.h">
       <Filter>filesystem</Filter>
     </ClInclude>
     <ClInclude Include="..\..\xbmc\network\ZeroconfBrowser.h">
       <Filter>network</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\xbmc\network\windows\ZeroconfBrowserWIN.h">
-      <Filter>network\windows</Filter>
+    <ClInclude Include="..\..\xbmc\network\mdns\ZeroconfBrowserMDNS.h">
+      <Filter>network\mdns</Filter>
     </ClInclude>
     <ClInclude Include="..\..\xbmc\cores\AudioEngine\Encoders\AEEncoderFFmpeg.h">
       <Filter>cores\AudioEngine\Encoders</Filter>
     <ClInclude Include="..\..\xbmc\ApplicationMessenger.h" />
     <ClInclude Include="..\..\xbmc\Autorun.h" />
     <ClInclude Include="..\..\xbmc\AutoSwitch.h" />
-    <ClInclude Include="..\..\xbmc\Favourites.h" />
     <ClInclude Include="..\..\xbmc\DynamicDll.h" />
     <ClInclude Include="..\..\xbmc\CueDocument.h" />
     <ClInclude Include="..\..\xbmc\FileItem.h" />
index 77d10dd..5deaddc 100644 (file)
@@ -9,7 +9,7 @@ SET DEPS_DIR=..\BuildDependencies
 SET TMP_DIR=%DEPS_DIR%\tmp
 
 SET LIBNAME=xbmc-pvr-addons
-SET VERSION=5ef7f7f88c9dd3ca9c1daf57e7c92c005faa5910
+SET VERSION=d9165b4e701f1655df03562acd87eb7309544fc3
 SET SOURCE=%LIBNAME%
 SET GIT_URL=git://github.com/opdenkamp/%LIBNAME%.git
 SET SOURCE_DIR=%TMP_DIR%\%SOURCE%
index 015e878..85cda47 100644 (file)
@@ -2,6 +2,7 @@
   <global>
     <joystick name="Logitech Logitech Cordless RumblePad 2">
       <altname>Logitech Cordless RumblePad 2</altname>
+      <altname>Logitech RumblePad 2 USB</altname>
       <button id="1">FullScreen</button>
       <button id="2">Select</button>
       <button id="3">Back</button>
@@ -28,6 +29,7 @@
   <Home>
     <joystick name="Logitech Logitech Cordless RumblePad 2">
       <altname>Logitech Cordless RumblePad 2</altname>
+      <altname>Logitech RumblePad 2 USB</altname>
       <button id="3">XBMC.ActivateWindow(Favourites)</button>
     </joystick>
   </Home>
@@ -35,6 +37,7 @@
   <MyMusicFiles>
     <joystick name="Logitech Logitech Cordless RumblePad 2">
       <altname>Logitech Cordless RumblePad 2</altname>
+      <altname>Logitech RumblePad 2 USB</altname>
       <button id="4">Queue</button>
     </joystick>
   </MyMusicFiles>
@@ -42,6 +45,7 @@
   <MyMusicLibrary>
     <joystick name="Logitech Logitech Cordless RumblePad 2">
       <altname>Logitech Cordless RumblePad 2</altname>
+      <altname>Logitech RumblePad 2 USB</altname>
       <button id="4">Queue</button>
     </joystick>
   </MyMusicLibrary>
@@ -49,6 +53,7 @@
   <FullscreenVideo>
     <joystick name="Logitech Logitech Cordless RumblePad 2">
       <altname>Logitech Cordless RumblePad 2</altname>
+      <altname>Logitech RumblePad 2 USB</altname>
       <button id="2">Pause</button>
       <button id="3">Stop</button>
       <button id="4">AspectRatio</button>
@@ -66,6 +71,7 @@
   <FullscreenLiveTV>
     <joystick name="Logitech Logitech Cordless RumblePad 2">
       <altname>Logitech Cordless RumblePad 2</altname>
+      <altname>Logitech RumblePad 2 USB</altname>
       <hat    id="1" position="left">PreviousChannelGroup</hat>
       <hat    id="1" position="right">NextChannelGroup</hat>
       <hat    id="1" position="up">ChannelUp</hat>
@@ -76,6 +82,7 @@
   <Visualisation>
     <joystick name="Logitech Logitech Cordless RumblePad 2">
       <altname>Logitech Cordless RumblePad 2</altname>
+      <altname>Logitech RumblePad 2 USB</altname>
       <button id="2">Pause</button>
       <button id="3">Stop</button>
       <button id="4">XBMC.ActivateWindow(VisualisationPresetList)</button>
   <SlideShow>
     <joystick name="Logitech Logitech Cordless RumblePad 2">
       <altname>Logitech Cordless RumblePad 2</altname>
+      <altname>Logitech RumblePad 2 USB</altname>
       <button id="1">ZoomNormal</button>
       <button id="2">Pause</button>
       <button id="3">Stop</button>
   <ScreenCalibration>
     <joystick name="Logitech Logitech Cordless RumblePad 2">
       <altname>Logitech Cordless RumblePad 2</altname>
+      <altname>Logitech RumblePad 2 USB</altname>
       <button id="2">NextCalibration</button>
     </joystick>
   </ScreenCalibration>
   <MyVideoLibrary>
     <joystick name="Logitech Logitech Cordless RumblePad 2">
       <altname>Logitech Cordless RumblePad 2</altname>
+      <altname>Logitech RumblePad 2 USB</altname>
       <button id="4">Queue</button>
       <button id="5">Info</button>
     </joystick>
   <MyVideoFiles>
     <joystick name="Logitech Logitech Cordless RumblePad 2">
       <altname>Logitech Cordless RumblePad 2</altname>
+      <altname>Logitech RumblePad 2 USB</altname>
       <button id="4">Queue</button>
       <button id="5">Info</button>
     </joystick>
   <VirtualKeyboard>
     <joystick name="Logitech Logitech Cordless RumblePad 2">
       <altname>Logitech Cordless RumblePad 2</altname>
+      <altname>Logitech RumblePad 2 USB</altname>
       <button id="1">Symbols</button>
       <button id="3">BackSpace</button>
       <button id="4">Shift</button>
index 2d839d6..528378d 100644 (file)
@@ -9,4 +9,16 @@
       </group>
     </category>
   </section>
+  <section id="videos">
+    <category id="videoplayer">
+      <group id="2">
+        <setting id="videoplayer.usevda" type="boolean" label="13429" help="36160">
+          <level>2</level>
+          <default>true</default>
+        </setting>
+      </group>
+    </category>
+  </section>
 </settings>
+
+
index daa27f3..0369c50 100644 (file)
@@ -1,10 +1,33 @@
 <?xml version="1.0" encoding="utf-8" ?>
-<settings><section id="system">
+<settings>
+  <section id="videos">
+    <category id="videoplayer">
+      <group id="2">
+        <setting id="videoplayer.rendermethod">
+          <visible>false</visible>
+        </setting>
+        <setting id="videoplayer.hqscalers">
+          <visible>false</visible>
+        </setting>
+        <setting id="videoplayer.synctype">
+          <visible>false</visible>
+        </setting>
+      </group>
+    </category>
+  </section>
+
+  <section id="system">
     <category id="videoscreen">
       <group id="1">
         <setting id="videoscreen.screen">
           <visible>false</visible>
         </setting>
+        <setting id="videoscreen.blankdisplays">
+          <visible>false</visible>
+        </setting>
+        <setting id="videoscreen.fakefullscreen">
+          <visible>false</visible>
+        </setting>
       </group>
     </category>
     <category id="audiooutput">
         <setting id="audiooutput.mode">
           <default>2</default> <!-- AUDIO_HDMI -->
         </setting>
+        <setting id="audiooutput.channels">
+          <visible>false</visible>
+        </setting>
+        <setting id="audiooutput.stereoupmix">
+          <visible>false</visible>
+        </setting>
         <setting id="audiooutput.passthroughaac">
           <visible>false</visible>
         </setting>
index 894d6c1..6e32551 100644 (file)
           <level>2</level>
           <default>true</default>
         </setting>
-        <setting id="videoplayer.usevda" type="boolean" label="13429" help="36160">
-          <visible>HasVDADecoder</visible>
-          <level>2</level>
-          <default>true</default>
-        </setting>
         <setting id="videoplayer.useomx" type="boolean" label="13430" help="36161">
           <visible>HAVE_LIBOPENMAX</visible>
           <level>2</level>
diff --git a/tools/Linux/packaging/README.debian b/tools/Linux/packaging/README.debian
new file mode 100644 (file)
index 0000000..6313c58
--- /dev/null
@@ -0,0 +1,31 @@
+--- How to build a XBMC debian package ---
+
+There are two available build methods:
+1.) debuild / debhelper
+  Requirements: debhelper, devscripts, all Xbmc build deps 
+      sudo apt-get install debhelper devscripts
+      sudo apt-get build-dep xbmc (if you have on of our repos/ppas added, else read docs/README.linux or docs/README.ubuntu)
+
+  Result: debian package for your host distribution and architecture only
+  Recommended for local installs
+
+  Example Usage: ./mk-debian-package.sh
+
+2.) pdebuild / pbuilder 
+  Requirements: pbuilder, devscripts, proper pbuilder environment
+      For a comprehensive example how to setup pbuilder read: 
+      https://wiki.ubuntu.com/PbuilderHowto
+
+  Result: debian package for arbitrary debian based distributions and architectures
+  Recommended for hosting your own apt repository or (clean room) compile testing for various distributions
+
+  Example Usage:
+  RELEASEV=13 \
+  DISTS=-"unstable" \
+  ARCHS="i386 amd64" \
+  BUILDER="pdebuild" \
+  PDEBUILD_OPTS="--debbuildopts \"-j4\"" \
+  PBUILDER_BASE="/home/$USER/xbmc-packaging/pbuilder" \
+  DPUT_TARGET="local" \
+  ./mk-debian-package.sh
+
diff --git a/tools/Linux/packaging/mk-debian-package.sh b/tools/Linux/packaging/mk-debian-package.sh
new file mode 100755 (executable)
index 0000000..711c0a9
--- /dev/null
@@ -0,0 +1,170 @@
+#!/bin/bash
+#
+# Copyright (C) 2013 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, see
+# <http://www.gnu.org/licenses/>.
+#
+
+
+RELEASEV=${RELEASEV:-"auto"}
+TAG=${TAG}
+REPO_DIR=${WORKSPACE:-$(cd "$(dirname $0)/../../../" ; pwd)}
+[[ $(which lsb_release) ]] && DISTS=${DISTS:-$(lsb_release -cs)} || DISTS=${DISTS:-"stable"}
+ARCHS=${ARCHS:-$(dpkg --print-architecture)}
+BUILDER=${BUILDER:-"debuild"}
+DEBUILD_OPTS=${DEBUILD_OPTS:-""}
+PDEBUILD_OPTS=${PDEBUILD_OPTS:-""}
+PBUILDER_BASE=${PBUILDER_BASE:-"/var/cache/pbuilder"}
+DPUT_TARGET=${DPUT_TARGET:-"local"}
+DEBIAN=${DEBIAN:-"https://github.com/xbmc/xbmc-packaging/archive/master.tar.gz"}
+
+function usage {
+    echo "$0: this script builds a Xbmc debian package from a git repository."
+    echo "The build is controlled by ENV variables, which van be overridden as appropriate:"
+    echo "BUILDER is either debuild(default) or pdebuild(needs a proper pbuilder setup)"
+    checkEnv
+}
+
+function checkEnv {
+    echo "#------ build environment ------#"
+    echo "REPO_DIR: $REPO_DIR"
+    [[ $RELEASEV == "auto" ]] && getVersion
+    echo "RELEASEV: $RELEASEV"
+    [[ -n $TAG ]] && echo "TAG: $TAG"
+    echo "DISTS: $DISTS"
+    echo "ARCHS: $ARCHS"
+    echo "DEBIAN: $DEBIAN"
+    echo "BUILDER: $BUILDER"
+    echo "CONFIGURATION: $Configuration"
+
+    if ! [[ $(which $BUILDER) ]]
+    then
+        echo "Error: can't find ${BUILDER}, consider using full path to [debuild|pdebuild]"
+        exit 1
+    fi
+
+    if [[ "$BUILDER" =~ "pdebuild" ]]
+    then
+        if ! [[ -d $PBUILDER_BASE ]] ; then echo "Error: $PBUILDER_BASE does not exist"; exit 1; fi
+        echo "PBUILDER_BASE: $PBUILDER_BASE"
+        echo "PDEBUILD_OPTS: $PDEBUILD_OPTS"
+    else
+        echo "DEBUILD_OPTS: $DEBUILD_OPTS"
+    fi
+
+    echo "#-------------------------------#"
+}
+
+function getVersion {
+    local MAJORVER=$(grep VERSION_MAJOR $REPO_DIR/xbmc/GUIInfoManager.h | awk '{ print $3 }')
+    local MINORVER=$(grep VERSION_MINOR $REPO_DIR/xbmc/GUIInfoManager.h | awk '{ print $3 }')
+    RELEASEV=${MAJORVER}.${MINORVER}
+}
+
+function getGitRev {
+    cd $REPO_DIR || exit 1
+    REV=$(git log -1 --pretty=format:"%h")
+    [[ -z $TAG ]] && TAG=$REV
+    [[ -z $TAGREV ]] && TAGREV=0
+}
+
+function archiveRepo {
+    cd $REPO_DIR || exit 1
+    git clean -xfd
+    getGitRev
+    echo $REV > VERSION
+    DEST="xbmc-${RELEASEV}~git$(date '+%Y%m%d.%H%M')-${TAG}"
+    [[ -d debian ]] && rm -rf debian
+    cd ..
+    tar -czf ${DEST}.tar.gz -h --exclude .git $(basename $REPO_DIR)
+    ln -s ${DEST}.tar.gz ${DEST/-/_}.orig.tar.gz
+    echo "Output Archive: ${DEST}.tar.gz"
+
+    cd $REPO_DIR || exit 1
+    getDebian
+}
+
+function getDebian {
+    if [[ -d $DEBIAN ]]
+    then
+        cp -r $DEBIAN .
+    else
+        mkdir tmp && cd tmp
+        curl -L -s $DEBIAN -o debian.tar.gz
+        tar xzf debian.tar.gz
+        cd xbmc-packaging-*
+        for FILE in *.unified; do mv $FILE debian/${FILE%.unified}; done
+        mv debian $REPO_DIR
+        cd $REPO_DIR ; rm -rf tmp
+    fi
+}
+
+function buildDebianPackages {
+    archiveRepo
+    cd $REPO_DIR || exit 1
+    sed -e "s/#PACKAGEVERSION#/${DEST#xbmc-}/g" -e "s/#TAGREV#/${TAGREV}/g" debian/changelog.in > debian/changelog.tmp
+    [ "$Configuration" == "Debug" ] && sed -i "s/XBMC_RELEASE = yes/XBMC_RELEASE = no/" debian/rules
+
+    for dist in $DISTS
+    do
+        sed "s/#DIST#/${dist}/g" debian/changelog.tmp > debian/changelog
+        for arch in $ARCHS
+        do
+            cd $REPO_DIR
+            echo "building: DIST=$dist ARCH=$arch"
+            if [[ "$BUILDER" =~ "pdebuild" ]]
+            then
+                DIST=$dist ARCH=$arch $BUILDER $PDEBUILD_OPTS
+                [ $? -eq 0 ] && uploadPkg || exit 1
+            else
+                $BUILDER $DEBUILD_OPTS
+                echo "output directory: $REPO_DIR/.."
+            fi
+        done
+    done
+}
+
+function uploadPkg {
+    PKG="${PBUILDER_BASE}/${dist}-${arch}/result/${DEST/-/_}-${TAGREV}_${arch}.changes"
+    echo "signing package"
+    debsign $PKG
+    echo "uploading $PKG to $DPUT_TARGET"
+    dput $DPUT_TARGET $PKG
+    UPLOAD_DONE=$?
+}
+
+function cleanup {
+    if [[ $UPLOAD_DONE -eq 0 ]] && [[ "$BUILDER" =~ "pdebuild" ]]
+    then
+        cd $REPO_DIR/.. || exit 1
+        rm ${DEST}*
+        rm ${DEST/-/_}*
+    fi
+}
+
+###
+# main
+###
+if [[ $1 = "-h" ]] || [[ $1 = "--help" ]]
+then
+    usage
+    exit
+fi
+
+checkEnv
+buildDebianPackages
+cleanup
+
index 25e251e..921ed55 100644 (file)
@@ -25,7 +25,7 @@
 #include <SDL/SDL.h>
 #include <SDL/SDL_image.h>
 #include "cmdlineargs.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #define strncasecmp strnicmp
 #endif
 #include "DDSImage.h"
index 2661972..71e3d4a 100644 (file)
@@ -1,4 +1,4 @@
-DEFINES += -D_LINUX -DUSE_LZO_PACKING
+DEFINES += -DTARGET_POSIX -DUSE_LZO_PACKING
 ifneq ($(or $(findstring powerpc,@ARCH@),$(findstring ppc, @ARCH@)),)
 DEFINES += -DHOST_BIGENDIAN
 endif
index 3354a20..0d99d7f 100644 (file)
@@ -19,7 +19,7 @@
  *
  */
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include <sys/types.h>
 #include <sys/stat.h>
 #define __STDC_FORMAT_MACROS
 #include "cmdlineargs.h"
 #include "libsquish/squish.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #define strncasecmp strnicmp
 #endif
 
 #ifdef USE_LZO_PACKING
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "../../lib/win32/liblzo/LZO1X.H"
 #else
 #include <lzo/lzo1x.h>
@@ -576,7 +576,7 @@ int main(int argc, char* argv[])
     {
       OutputFilename = args[++i];
       valid = true;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
       char *c = NULL;
       while ((c = (char *)strchr(OutputFilename.c_str(), '\\')) != NULL) *c = '/';
 #endif
index 89efeb9..5e0e5f4 100644 (file)
@@ -24,9 +24,9 @@
 #include <inttypes.h>
 #include "guilib/XBTF.h"
 #include "utils/EndianSwap.h"
-#if defined(__FreeBSD__)
+#if defined(TARGET_FREEBSD)
 #include <stdlib.h>
-#elif !defined(__APPLE__)
+#elif !defined(TARGET_DARWIN)
 #include <malloc.h>
 #endif
 #include <memory.h>
index d2631cb..912e28a 100644 (file)
@@ -22,7 +22,7 @@
  *
  */
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "PlatformDefs.h"
 #include "xwinapi.h"
 typedef LPSTR PSZ;
@@ -47,7 +47,7 @@ public:
             strcpy (m_cmdline, cmdline);
             ParseCmdLine(); 
         } else {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
           delete[] cmdline;
 #endif
         }
@@ -56,7 +56,7 @@ public:
     CmdLineArgs (const int argc, const char **argv)
     {
       std::string cmdline;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
       cmdline = "\"";
 #endif
       for (int i = 0 ; i<argc ; i++)
@@ -64,14 +64,14 @@ public:
         cmdline += std::string(argv[i]);
         if ( i != (argc-1) )
         {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
           cmdline += "\" \"";
 #else
           cmdline += " ";
 #endif
         }
       }
-#ifdef _LINUX
+#ifdef TARGET_POSIX
       cmdline += "\"";
 #endif
       m_cmdline = new char [cmdline.length() + 1];
index 2d2c0ea..2585753 100644 (file)
@@ -26,7 +26,7 @@
 #include <string.h>
 #include <errno.h>
 #include "xwinapi.h"
-#ifdef __APPLE__
+#ifdef TARGET_DARWIN
 #include "OSXGNUReplacements.h"
 #endif
 
index 9c20f2b..f491c3c 100644 (file)
@@ -3,7 +3,7 @@ include ../../depends/Makefile.include
 OBJS = libcurl.so \
   librtmp.so  libmad.so \
   libafpclient.so  \
-  libplist.so \
+  libplist.so libshairplay.so \
   libxbogg.so libxbvorbis.so libxbvorbisfile.so libxbFLAC.so libxbmpeg2.so \
   libxbmpeg2convert.so libnfs.so libass.so
 
index 9c4bbb3..ffafd1a 100644 (file)
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.BROWSABLE" />
+
+                <data android:mimeType="video/*" />
+                <data android:mimeType="audio/*" />
+                <data android:mimeType="image/*" />
+
+                <data android:scheme="file" />
+                <data android:scheme="content" />
+                <data android:scheme="http" />
+                <data android:scheme="https" />
+                <data android:scheme="ftp" />
+                <data android:scheme="ftps" />
+                <data android:scheme="rtp" />
+                <data android:scheme="rtsp" />
+                <data android:scheme="mms" />
+                <data android:scheme="dav" />
+                <data android:scheme="davs" />
+                <data android:scheme="ssh" />
+                <data android:scheme="sftp" />
+                <data android:scheme="smb" />
+             </intent-filter>
         </activity>
 
         <!--
index 0e5257b..a94f925 100644 (file)
@@ -6,6 +6,7 @@ import android.os.Bundle;
 
 public class Main extends NativeActivity 
 {
+  native void _onNewIntent(Intent intent);
   public Main() 
   {
     super();
@@ -16,4 +17,12 @@ public class Main extends NativeActivity
   {
     super.onCreate(savedInstanceState);
   }
+
+  @Override
+  protected void onNewIntent(Intent intent)
+  {
+    super.onNewIntent(intent);
+    _onNewIntent(intent);
+  }
+
 }
diff --git a/tools/buildsteps/linux-debian/configure-depends b/tools/buildsteps/linux-debian/configure-depends
new file mode 100755 (executable)
index 0000000..96e6aaa
--- /dev/null
@@ -0,0 +1,2 @@
+# We do not use unified dependencies here, but system libs
+exit 0
diff --git a/tools/buildsteps/linux-debian/configure-xbmc b/tools/buildsteps/linux-debian/configure-xbmc
new file mode 100755 (executable)
index 0000000..44380b3
--- /dev/null
@@ -0,0 +1,2 @@
+# Nothing to be done, this is all handled by the package script
+exit 0
diff --git a/tools/buildsteps/linux-debian/make-depends b/tools/buildsteps/linux-debian/make-depends
new file mode 100755 (executable)
index 0000000..d1de8c7
--- /dev/null
@@ -0,0 +1,2 @@
+# noop
+exit 0
diff --git a/tools/buildsteps/linux-debian/make-xbmc b/tools/buildsteps/linux-debian/make-xbmc
new file mode 100755 (executable)
index 0000000..d1de8c7
--- /dev/null
@@ -0,0 +1,2 @@
+# noop
+exit 0
diff --git a/tools/buildsteps/linux-debian/package b/tools/buildsteps/linux-debian/package
new file mode 100755 (executable)
index 0000000..accffd1
--- /dev/null
@@ -0,0 +1,16 @@
+WORKSPACE=${WORKSPACE:-$( cd $(dirname $0)/../../.. ; pwd -P )}
+XBMC_PLATFORM_DIR=linux-debian
+. $WORKSPACE/tools/buildsteps/defaultenv
+
+cd $WORKSPACE
+
+RELEASEV=$VERSION \
+TAG=$TAG \
+DISTS=${DISTS:-"stable"} \
+ARCHS=${ARCHS:-"i386 amd64"} \
+BUILDER=${BUILDER:-"pdebuild"} \
+PDEBUILD_OPTS=${PDEBUILD_OPTS:-"--debbuildopts \"-j$BUILDTHREADS\""} \
+PBUILDER_BASE=${PBUILDER_BASE:-"/home/$USER/xbmc-packaging/pbuilder"} \
+DPUT_TARGET=${DPUT_TARGET:-"local"} \
+Configuration="$Configuration" \
+tools/Linux/packaging/mk-debian-package.sh
diff --git a/tools/buildsteps/linux-debian/prepare-depends b/tools/buildsteps/linux-debian/prepare-depends
new file mode 100755 (executable)
index 0000000..ca916d0
--- /dev/null
@@ -0,0 +1 @@
+exit 0
diff --git a/tools/buildsteps/linux-debian/prepare-xbmc b/tools/buildsteps/linux-debian/prepare-xbmc
new file mode 100755 (executable)
index 0000000..d54f426
--- /dev/null
@@ -0,0 +1,2 @@
+#nothing on linux
+exit 0
index dcf01b9..30e0a73 100644 (file)
@@ -34,7 +34,7 @@ ifeq ($(OS),osx)
 endif
 
 ifeq ($(OS),android)
-  EXCLUDED_DEPENDS = libshairplay
+  DEPENDS += mdnsresponder
 endif
 
 DEPENDS := $(filter-out $(EXCLUDED_DEPENDS),$(DEPENDS))
@@ -72,7 +72,6 @@ libvorbis: libogg
 libflac: libogg gettext
 libass: fontconfig libpng freetype2 expat $(ICONV)
 librtmp: openssl
-libxml2: $(ICONV)
 libmicrohttpd: openssl libgpg-error libgcrypt
 python26: expat gettext libxml2 sqlite3 openssl libffi
 libcdio: $(ICONV)
index aefbbe4..156b501 100644 (file)
@@ -7,6 +7,8 @@ SET(CMAKE_SYSTEM_VERSION 1)
 # specify the cross compiler
 SET(CMAKE_C_COMPILER   @CC@)
 SET(CMAKE_CXX_COMPILER @CXX@)
+SET(CMAKE_AR @AR@ CACHE FILEPATH "Archiver")
+SET(CMAKE_LINKER @LD@ CACHE FILEPATH "Linker")
 
 # where is the target environment 
 SET(CMAKE_FIND_ROOT_PATH  @prefix@/@deps_dir@ @use_toolchain@ @use_toolchain@/usr @use_sdk_path@ @use_sdk_path@/usr @use_toolchain@/sysroot/usr)
index 2d0d322..aa5a9b9 100644 (file)
@@ -8,7 +8,6 @@ SOURCE=$(LIBNAME)-$(VERSION)
 FILENAME=v$(VERSION)
 ARCHIVE=$(SOURCE).tar.gz
 LIBDYLIB=$(PLATFORM)/build/src/libplist++.so
-ICONV=$(shell echo $(LINK_ICONV) | sed -e 's/\-l//')
 CFLAGS+=-fvisibility=default
 all: .installed-$(PLATFORM)
 
@@ -16,13 +15,12 @@ $(TARBALLS_LOCATION)/$(ARCHIVE):
        cd $(TARBALLS_LOCATION); $(RETRIEVE_TOOL) $(RETRIEVE_TOOL_FLAGS) $(BASE_URL)/$(ARCHIVE)
 
 $(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS)
-       echo $(ICONV)
        rm -rf $(PLATFORM); mkdir -p $(PLATFORM)
        cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE)
        cd $(PLATFORM); patch -p1 < ../0001-dontbuildswig.patch
-       cd $(PLATFORM); sed -ie 's/TARGET_LINK_LIBRARIES( plist /TARGET_LINK_LIBRARIES( plist m z $(ICONV) /' src/CMakeLists.txt
+       cd $(PLATFORM); sed -ie 's/TARGET_LINK_LIBRARIES( plist /TARGET_LINK_LIBRARIES( plist m z  /' src/CMakeLists.txt
        cd $(PLATFORM); rm -rf build; mkdir -p build
-       cd $(PLATFORM)/build; $(CMAKE) VERBOSE=1 -DCMAKE_C_FLAGS="$(CFLAGS)" ..
+       cd $(PLATFORM)/build; $(CMAKE) VERBOSE=1 -DCMAKE_C_FLAGS="$(CFLAGS)" -DCMAKE_LD_FLAGS="$(LDFLAGS)" ..
 
 $(LIBDYLIB): $(PLATFORM)
        $(MAKE) -j 1 -C $(PLATFORM)/build VERBOSE=1
index 7665015..991ec80 100644 (file)
@@ -29,6 +29,13 @@ $(LIBDYLIB): $(PLATFORM)
 
 .installed-$(PLATFORM): $(LIBDYLIB)
        $(MAKE) -C $(PLATFORM) install
+ifeq ($(OS),android)
+       rm -f $(PREFIX)/lib/libshairplaylibshairplay.la $(PREFIX)/lib/libshairplay.so $(PREFIX)/lib/libshairplay.so.0
+       mv -f $(PREFIX)/lib/libshairplay.so.0.0.0 $(PREFIX)/lib/libshairplay.so
+       $(RPL) -e "libshairplay.so.0" "libshairplay.so\x00\x00" $(PREFIX)/lib/libshairplay.so
+       -$(READELF) --dynamic $(PREFIX)/lib/libshairplay.so | grep ibrary
+endif
+
        touch $@
 
 clean:
index ecce678..17498e5 100644 (file)
@@ -9,7 +9,7 @@ ARCHIVE=$(SOURCE).tar.gz
 
 # configuration settings
 CONFIGURE=cp -f $(CONFIG_SUB) $(CONFIG_GUESS) .; \
-          ./configure --prefix=$(PREFIX) --without-python --disable-shared
+          ./configure --prefix=$(PREFIX) --without-python --without-iconv --disable-shared
 
 LIBDYLIB=$(PLATFORM)/.libs/$(LIBNAME).a
 
diff --git a/tools/depends/target/mdnsresponder/01-android-embedded.patch b/tools/depends/target/mdnsresponder/01-android-embedded.patch
new file mode 100644 (file)
index 0000000..40c7bd9
--- /dev/null
@@ -0,0 +1,396 @@
+diff -rupN mDNSResponder-333.10/mDNSCore/mDNSEmbeddedAPI.h mDNSResponder-333.10.patched/mDNSCore/mDNSEmbeddedAPI.h
+--- mDNSResponder-333.10/mDNSCore/mDNSEmbeddedAPI.h    2011-06-30 22:56:04.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSCore/mDNSEmbeddedAPI.h    2012-04-15 15:10:42.000000000 +0200
+@@ -1051,6 +1051,10 @@ enum
+       McastResolver_FlagNew    = 2
+       };
++// everyone loves proprietary language extensions in the global namespace
++#ifdef _MSC_VER
++#undef interface
++#endif
+ typedef struct McastResolver
+       {
+       struct McastResolver *next;
+diff -rupN mDNSResponder-333.10/mDNSPosix/mDNSPosix.h mDNSResponder-333.10.patched/mDNSPosix/mDNSPosix.h
+--- mDNSResponder-333.10/mDNSPosix/mDNSPosix.h 2009-08-11 03:13:47.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSPosix/mDNSPosix.h 2012-04-15 15:10:42.000000000 +0200
+@@ -25,6 +25,10 @@
+     extern "C" {
+ #endif
++#ifdef ANDROID
++#include <fcntl.h>
++#endif
++
+ // PosixNetworkInterface is a record extension of the core NetworkInterfaceInfo
+ // type that supports extra fields needed by the Posix platform.
+ //
+diff -rupN mDNSResponder-333.10/mDNSShared/PlatformCommon.c mDNSResponder-333.10.patched/mDNSShared/PlatformCommon.c
+--- mDNSResponder-333.10/mDNSShared/PlatformCommon.c   2011-04-12 00:54:35.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSShared/PlatformCommon.c   2012-04-15 15:10:42.000000000 +0200
+@@ -27,6 +27,10 @@
+ #include "DNSCommon.h"
+ #include "PlatformCommon.h"
++#ifdef ANDROID
++#include <android/log.h>
++#endif
++
+ #ifdef NOT_HAVE_SOCKLEN_T
+     typedef unsigned int socklen_t;
+ #endif
+@@ -143,13 +147,20 @@ mDNSexport void ReadDDNSSettingsFromConf
+ #if MDNS_DEBUGMSGS
+ mDNSexport void mDNSPlatformWriteDebugMsg(const char *msg)
+       {
++#ifdef ANDROID
++      __android_log_print(ANDROID_LOG_DEBUG, "bonjour", "%s", msg);
++#else
+       fprintf(stderr,"%s\n", msg);
+       fflush(stderr);
++#endif
+       }
+ #endif
+ mDNSexport void mDNSPlatformWriteLogMsg(const char *ident, const char *buffer, mDNSLogLevel_t loglevel)
+       {
++#ifdef ANDROID
++      __android_log_print(ANDROID_LOG_DEBUG, "bonjour", "%s", buffer);
++#else
+ #if APPLE_OSX_mDNSResponder && LogTimeStamps
+       extern mDNS mDNSStorage;
+       extern mDNSu32 mDNSPlatformClockDivisor;
+@@ -193,4 +204,5 @@ mDNSexport void mDNSPlatformWriteLogMsg(
+ #endif
+                       syslog(syslog_level, "%s", buffer);
+               }
++#endif
+       }
+diff -rupN mDNSResponder-333.10/mDNSShared/dns_sd.h mDNSResponder-333.10.patched/mDNSShared/dns_sd.h
+--- mDNSResponder-333.10/mDNSShared/dns_sd.h   2011-08-31 03:44:17.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSShared/dns_sd.h   2012-04-15 15:10:42.000000000 +0200
+@@ -93,7 +93,7 @@
+ /* standard calling convention under Win32 is __stdcall */
+ /* Note: When compiling Intel EFI (Extensible Firmware Interface) under MS Visual Studio, the */
+ /* _WIN32 symbol is defined by the compiler even though it's NOT compiling code for Windows32 */
+-#if defined(_WIN32) && !defined(EFI32) && !defined(EFI64)
++#if defined(_WIN32) && !defined(EFI32) && !defined(EFI64) && !defined(DISC_BONJOUR_EMBED)
+ #define DNSSD_API __stdcall
+ #else
+ #define DNSSD_API
+diff -rupN mDNSResponder-333.10/mDNSShared/dnssd_clientshim.c mDNSResponder-333.10.patched/mDNSShared/dnssd_clientshim.c
+--- mDNSResponder-333.10/mDNSShared/dnssd_clientshim.c 2011-06-02 00:44:37.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSShared/dnssd_clientshim.c 2012-04-15 15:10:42.000000000 +0200
+@@ -25,6 +25,13 @@
+ #include "dns_sd.h"                           // Defines the interface to the client layer above
+ #include "mDNSEmbeddedAPI.h"          // The interface we're building on top of
++#ifndef _MSC_VER
++#include <sys/socket.h>
++#include <netinet/in.h>
++#else
++#include <winsock2.h>
++#endif
++
+ extern mDNS mDNSStorage;              // We need to pass the address of this storage to the lower-layer functions
+ #if MDNS_BUILDINGSHAREDLIBRARY || MDNS_BUILDINGSTUBLIBRARY
+@@ -71,6 +78,14 @@ typedef struct
+ typedef struct
+       {
+       mDNS_DirectOP_Dispose  *disposefn;
++      DNSServiceRef                aQuery;
++      DNSServiceGetAddrInfoReply   callback;
++      void                         *context;
++      } mDNS_DirectOP_GetAddrInfo;
++
++typedef struct
++      {
++      mDNS_DirectOP_Dispose  *disposefn;
+       DNSServiceResolveReply  callback;
+       void                   *context;
+       const ResourceRecord   *SRV;
+@@ -659,7 +674,7 @@ DNSServiceErrorType DNSServiceQueryRecor
+       x->q.ExpectUnique        = mDNSfalse;
+       x->q.ForceMCast          = (flags & kDNSServiceFlagsForceMulticast) != 0;
+       x->q.ReturnIntermed      = (flags & kDNSServiceFlagsReturnIntermediates) != 0;
+-      x->q.SuppressUnsable     = (flags & kDNSServiceFlagsSuppressUnusable) != 0;
++      x->q.SuppressUnusable    = (flags & kDNSServiceFlagsSuppressUnusable) != 0;
+       x->q.SearchListIndex     = 0;
+       x->q.AppendSearchDomains = 0;
+       x->q.RetryWithSearchDomains = mDNSfalse;
+diff -rupN mDNSResponder-333.10/mDNSShared/dnssd_ipc.h mDNSResponder-333.10.patched/mDNSShared/dnssd_ipc.h
+--- mDNSResponder-333.10/mDNSShared/dnssd_ipc.h        2011-06-30 22:56:04.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSShared/dnssd_ipc.h        2012-04-15 15:10:42.000000000 +0200
+@@ -29,6 +29,11 @@
+ #ifndef DNSSD_IPC_H
+ #define DNSSD_IPC_H
++#ifdef ANDROID
++#include <sys/socket.h>
++#include <sys/un.h>
++#endif
++
+ #include "dns_sd.h"
+ //
+diff -rupN mDNSResponder-333.10/mDNSShared/uds_daemon.h mDNSResponder-333.10.patched/mDNSShared/uds_daemon.h
+--- mDNSResponder-333.10/mDNSShared/uds_daemon.h       2011-05-18 00:18:08.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSShared/uds_daemon.h       2012-04-15 15:10:42.000000000 +0200
+@@ -22,6 +22,11 @@
+  */
++#ifdef ANDROID
++#include <sys/socket.h>
++#include <sys/un.h>
++#endif
++
+ #include "mDNSEmbeddedAPI.h"
+ #include "dnssd_ipc.h"
+diff -rupN mDNSResponder-333.10/mDNSWindows/mDNSWin32.c mDNSResponder-333.10.patched/mDNSWindows/mDNSWin32.c
+--- mDNSResponder-333.10/mDNSWindows/mDNSWin32.c       2011-08-31 03:42:48.000000000 +0200
++++ mDNSResponder-333.10.patched/mDNSWindows/mDNSWin32.c       2012-04-15 15:17:34.000000000 +0200
+@@ -2843,10 +2843,7 @@ mDNSlocal mStatus       SetupSocket( mDNS * co
+               sa4.sin_family          = AF_INET;
+               sa4.sin_port            = port.NotAnInteger;
+               sa4.sin_addr.s_addr     = ipv4.NotAnInteger;
+-              
+-              err = bind( sock, (struct sockaddr *) &sa4, sizeof( sa4 ) );
+-              check_translated_errno( err == 0, errno_compat(), kUnknownErr );
+-              
++                              
+               // Turn on option to receive destination addresses and receiving interface.
+               
+               option = 1;
+@@ -2887,6 +2884,9 @@ mDNSlocal mStatus        SetupSocket( mDNS * co
+               err = setsockopt( sock, IPPROTO_IP, IP_MULTICAST_TTL, (char *) &option, sizeof( option ) );
+               check_translated_errno( err == 0, errno_compat(), kOptionErr );
++              err = bind( sock, (struct sockaddr *) &sa4, sizeof( sa4 ) );
++              check_translated_errno( err == 0, errno_compat(), kUnknownErr );
++
+       }
+       else if( inAddr->sa_family == AF_INET6 )
+       {
+@@ -2904,10 +2904,7 @@ mDNSlocal mStatus       SetupSocket( mDNS * co
+               sa6.sin6_flowinfo       = 0;
+               sa6.sin6_addr           = sa6p->sin6_addr;
+               sa6.sin6_scope_id       = sa6p->sin6_scope_id;
+-              
+-              err = bind( sock, (struct sockaddr *) &sa6, sizeof( sa6 ) );
+-              check_translated_errno( err == 0, errno_compat(), kUnknownErr );
+-              
++                              
+               // Turn on option to receive destination addresses and receiving interface.
+               
+               option = 1;
+@@ -2957,6 +2954,10 @@ mDNSlocal mStatus       SetupSocket( mDNS * co
+               option = 255;
+               err = setsockopt( sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *) &option, sizeof( option ) );
+               check_translated_errno( err == 0, errno_compat(), kOptionErr );
++              
++              err = bind( sock, (struct sockaddr *) &sa6, sizeof( sa6 ) );
++              check_translated_errno( err == 0, errno_compat(), kUnknownErr );
++
+       }
+       else
+       {
+diff -uPr mDNSResponder-333.10/mDNSCore.orig/mDnsEmbedded.c mDNSResponder-333.10/mDNSCore/mDnsEmbedded.c
+--- mDNSResponder-333.10/mDNSCore/mDnsEmbedded.c       1970-01-01 01:00:00.000000000 +0100
++++ mDNSResponder-333.10/mDNSCore/mDnsEmbedded.c       2013-06-01 13:04:44.000000000 +0100
+@@ -0,0 +1,145 @@
++/**
++ *  @file
++ *  @brief      Wrapper for mDNSEmbeddedAPI with Bonjour.
++ *  @author     2012 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de)
++ *  @copyright  Simplified BSD
++ *
++ *  @cond
++ *  This program is free software: you can redistribute it and/or modify
++ *  it under the terms of the FreeBSD license as published by the FreeBSD
++ *  project.
++ *
++ *  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.
++ *
++ *  You should have received a copy of the FreeBSD license along with this
++ *  program. If not, see <http://www.opensource.org/licenses/bsd-license>.
++ *  @endcond
++ */
++
++#include <stdlib.h>
++#include <assert.h>
++#include <sys/select.h>
++// include order matters
++#include "mDNSEmbeddedAPI.h"
++#ifdef WIN32
++#include "../mDNSWindows/mDNSWin32.h"    // Defines the specific types needed to run mDNS on windows platforms
++#else
++#include <sys/time.h>
++#include "../mDNSPosix/mDNSPosix.h"    // Defines the specific types needed to run mDNS on posix platforms
++#endif
++
++#define RR_CACHE_SIZE 500
++static CacheEntity rrcachestorage[RR_CACHE_SIZE];
++mDNS mDNSStorage;
++//struct mDNS_PlatformSupport_struct {};
++static int mDNSIsInitialized = 0;
++static mDNS_PlatformSupport platformSupport;
++
++const char ProgramName[] = "umundo";
++extern mDNSexport void mDNSPosixGetFDSet(mDNS *m, int *nfds, fd_set *readfds, struct timeval *timeout);
++extern mDNSexport void mDNSPosixProcessFDSet(mDNS *const m, fd_set *readfds);
++
++// promise compiler that these will be there
++mDNSexport int embedded_mDNSmainLoop(struct timeval timeout);
++
++#if WIN32
++mStatus mDNSPoll(DWORD msec);
++static void   embedded_mDNSInit_ReportStatus( int inType, const char *inFormat, ... ) {
++}
++#endif
++
++mDNSexport int embedded_mDNSInit() {
++      mStatus err;
++      if (mDNSIsInitialized != 0) {
++              return 0;
++      }
++
++      mDNSPlatformMemZero( &mDNSStorage, sizeof(mDNSStorage));
++      mDNSPlatformMemZero( &platformSupport, sizeof(platformSupport));
++
++      err = mDNS_Init(
++              &mDNSStorage,
++              &platformSupport,
++              rrcachestorage,
++              RR_CACHE_SIZE,
++              mDNS_Init_AdvertiseLocalAddresses,
++              mDNS_Init_NoInitCallback,
++              mDNS_Init_NoInitCallbackContext
++      );
++      if (err)
++              return err;
++
++#ifdef WIN32
++      platformSupport.reportStatusFunc = embedded_mDNSInit_ReportStatus;
++      err = SetupInterfaceList( &mDNSStorage );
++      if (err)
++              return err;
++      err = uDNS_SetupDNSConfig( &mDNSStorage );
++#endif
++
++      if (err == 0) {
++              mDNSIsInitialized = 1;
++      }
++      return err;
++}
++
++mDNSexport void embedded_mDNSExit() {
++#ifdef WIN32
++      struct timeval tv;
++      tv.tv_sec  = 0;
++      tv.tv_usec = 0;
++//    mDNS_StartExit(&mDNSStorage);
++//    embedded_mDNSmainLoop(tv);
++//    mDNS_FinalExit(&mDNSStorage);
++#else
++      mDNS_Close(&mDNSStorage);
++#endif
++}
++
++#ifdef WIN32
++mDNSexport int embedded_mDNSmainLoop(struct timeval timeout) {
++      mDNS_Execute(&mDNSStorage);
++      mDNSPoll(100);
++//    Sleep(100);
++      return 0;
++}
++
++#else
++
++// From <mDNSDir>/ExampleClientApp.c
++mDNSexport int embedded_mDNSmainLoop(struct timeval timeout) {
++      int nfds = 0;
++      fd_set readfds;
++      int result;
++
++      // 1. Set up the fd_set as usual here.
++      // This example client has no file descriptors of its own,
++      // but a real application would call FD_SET to add them to the set here
++      FD_ZERO(&readfds);
++
++      // 2. Set up the timeout.
++      // This example client has no other work it needs to be doing,
++      // so we set an effectively infinite timeout
++//    timeout.tv_sec = 0x3FFFFFFF;
++//    timeout.tv_usec = 0;
++
++      assert(timeout.tv_sec < 10);
++      // 3. Give the mDNSPosix layer a chance to add its information to the fd_set and timeout
++      mDNSPosixGetFDSet(&mDNSStorage, &nfds, &readfds, &timeout);
++
++      // 4. Call select as normal
++      result = select(nfds, &readfds, NULL, NULL, &timeout);
++
++      if (result > 0) {
++              // 5. Call mDNSPosixProcessFDSet to let the mDNSPosix layer do its work
++              mDNSPosixProcessFDSet(&mDNSStorage, &readfds);
++
++              // 6. This example client has no other work it needs to be doing,
++              // but a real client would do its work here
++              // ... (do work) ...
++      }
++      return result;
++}
++#endif
+diff -uPr mDNSResponder-333.10/mDNSCore.orig/mDnsEmbedded.h mDNSResponder-333.10/mDNSCore/mDnsEmbedded.h
+--- mDNSResponder-333.10/mDNSCore/mDnsEmbedded.h       1970-01-01 01:00:00.000000000 +0100
++++ mDNSResponder-333.10/mDNSCore/mDnsEmbedded.h       2013-06-01 13:00:29.000000000 +0100
+@@ -0,0 +1,32 @@
++/*                                                                                                                                                                                        
++ *      Copyright (C) 2005-2013 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, see                                                                                                                                   
++ *  <http://www.gnu.org/licenses/>.                                                                                                                                                       
++ *                                                                                                                                                                                        
++ */
++
++#ifndef _MDNSEMBEDDED_H_
++#define _MDNSEMBEDDED_H_
++#ifdef __cplusplus
++extern "C" {
++#endif
++int embedded_mDNSInit();
++void embedded_mDNSExit();
++int embedded_mDNSmainLoop(struct timeval timeout);
++#ifdef __cplusplus
++}
++#endif
++#endif //_MDNSEMBEDDED_H_
+--- mDNSResponder-333.10/mDNSShared/dnssd_clientshim.c 2013-06-04 21:24:45.000000000 +0200
++++ mDNSResponder-333.10/mDNSShared/dnssd_clientshim.c 2013-06-04 22:01:48.000000000 +0200
+@@ -414,7 +414,7 @@
+       // Check parameters
+       if (!regtype[0] || !MakeDomainNameFromDNSNameString(&t, regtype))      { errormsg = "Illegal regtype"; goto badparam; }
+-      if (!MakeDomainNameFromDNSNameString(&d, *domain ? domain : "local.")) { errormsg = "Illegal domain";  goto badparam; }
++      if (!MakeDomainNameFromDNSNameString(&d, domain ? domain : "local.")) { errormsg = "Illegal domain";  goto badparam; }
+       // Allocate memory, and handle failure
+       x = (mDNS_DirectOP_Browse *)mDNSPlatformMemAllocate(sizeof(*x));
diff --git a/tools/depends/target/mdnsresponder/Makefile b/tools/depends/target/mdnsresponder/Makefile
new file mode 100644 (file)
index 0000000..c01b7a3
--- /dev/null
@@ -0,0 +1,38 @@
+include ../../Makefile.include
+DEPS= ../../Makefile.include Makefile
+
+
+# lib name, version
+LIBNAME=mDNSResponder
+VERSION=333.10
+OUTPUTNAME=libmDNSEmbedded
+SOURCE=$(LIBNAME)-$(VERSION)
+ARCHIVE=$(SOURCE).tar.gz
+
+LIBDYLIB=$(PLATFORM)/$(OUTPUTNAME).a
+
+all: .installed-$(PLATFORM)
+
+$(TARBALLS_LOCATION)/$(ARCHIVE):
+       cd $(TARBALLS_LOCATION); $(RETRIEVE_TOOL) $(RETRIEVE_TOOL_FLAGS) $(BASE_URL)/$(ARCHIVE)
+
+
+$(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS)
+       rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM)
+       cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE)
+       cd $(PLATFORM); patch -p1 < ../01-android-embedded.patch
+       cd $(PLATFORM); cp ../makefile.internal Makefile
+
+$(LIBDYLIB): $(PLATFORM)
+       cd $(PLATFORM); CC="$(CC)" AR="$(AR)" CFLAGS="$(CFLAGS)" $(MAKE)
+
+.installed-$(PLATFORM): $(LIBDYLIB)
+       cd $(PLATFORM); PREFIX="$(PREFIX)" $(MAKE) install
+       touch $@
+
+clean:
+       make -C $(PLATFORM) clean 
+       rm -f .installed-$(PLATFORM)
+
+distclean::
+       rm -rf $(PLATFORM) .installed-$(PLATFORM)
diff --git a/tools/depends/target/mdnsresponder/makefile.internal b/tools/depends/target/mdnsresponder/makefile.internal
new file mode 100644 (file)
index 0000000..bb7b24b
--- /dev/null
@@ -0,0 +1,33 @@
+DEFINES  ?= -DNOT_HAVE_SA_LEN -DUSES_NETLINK
+INCLUDES ?= -I./mDNSShared -I./mDNSCore
+PREFIX   ?= /usr/local
+LIBDIR   ?= $(PREFIX)/lib
+INCDIR   ?= $(PREFIX)/include
+LIB =    libmDNSEmbedded.a
+
+HEADERS = mDNSShared/dns_sd.h mDNSCore/mDnsEmbedded.h
+
+OBJECTS =  mDNSShared/dnssd_clientshim.o mDNSPosix/mDNSPosix.o mDNSCore/mDNS.o
+OBJECTS += mDNSCore/DNSCommon.o mDNSShared/mDNSDebug.o mDNSShared/GenLinkedList.o
+OBJECTS += mDNSCore/uDNS.o mDNSShared/PlatformCommon.o mDNSPosix/mDNSUNP.o
+OBJECTS += mDNSCore/DNSDigest.o mDNSCore/mDnsEmbedded.o mDNSShared/dnssd_clientlib.o
+
+all: $(LIB)
+install: $(LIBDIR)/$(LIB) $(addprefix $(INCDIR)/,$(HEADERS))
+
+$(INCDIR)/%.h: %.h
+       mkdir -p $(INCDIR)
+       install -m 644 $< $(INCDIR)
+
+$(LIBDIR)/$(LIB): $(LIB)
+       mkdir -p $(LIBDIR)
+       install -m 644 $< $@
+
+$(LIB): $(OBJECTS)
+       $(AR) rvs $@ $^
+
+%.o: %.c
+       $(CC) $(INCLUDES) $(DEFINES) $(CFLAGS) -c $< -o $@
+
+clean:
+       -rm $(OBJECTS) $(LIB)
index 9d47d1d..92a5dc4 100644 (file)
@@ -2,7 +2,7 @@ include ../../Makefile.include
 #DEPS= ../../Makefile.include Makefile
 
 LIBNAME=xbmc-pvr-addons
-VERSION=5ef7f7f88c9dd3ca9c1daf57e7c92c005faa5910
+VERSION=d9165b4e701f1655df03562acd87eb7309544fc3
 GIT_DIR=$(TARBALLS_LOCATION)/$(LIBNAME).git
 BASE_URL=git://github.com/opdenkamp/$(LIBNAME).git
 DYLIB=$(PLATFORM)/addons/pvr.demo/.libs/libpvrdemo-addon.so
index bd317fe..bafa99c 100644 (file)
@@ -19,7 +19,7 @@ ifeq ($(USE_BUILDROOT),1)
        export PKG_CONFIG_PATH=$(PREFIX)/lib/pkgconfig
        export PYTHON_VERSION=2.7
        export PATH:=$(PREFIX)/bin:$(BUILDROOT)/output/host/usr/bin:$(PATH)
-       export TEXTUREPACKER_NATIVE_ROOT=/usr
+       export USE_TEXTUREPACKER_NATIVE_ROOT=/usr
        export PYTHON_LDFLAGS=-L$(SDKSTAGE)/usr/lib -lpython$(PYTHON_VERSION) -lpthread -ldl -lutil -lm
 else
        export CFLAGS=-pipe -O3 -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -mfloat-abi=softfp -mfpu=vfp -mabi=aapcs-linux -Wno-psabi -Wa,-mno-warn-deprecated -Wno-deprecated-declarations
@@ -47,7 +47,7 @@ else
        export PKG_CONFIG_PATH=$(PREFIX)/bin/pkg-config
        export PYTHON_VERSION=2.6
        export PATH:=${PREFIX}/bin:$(PATH):${TOOLCHAIN}/bin
-       export TEXTUREPACKER_NATIVE_ROOT=/usr
+       export USE_TEXTUREPACKER_NATIVE_ROOT=/usr
        export PYTHON_LDFLAGS=-L$(SDKSTAGE)/usr/lib -lpython$(PYTHON_VERSION)
 endif
 export PYTHON_CPPFLAGS=-I$(SDKSTAGE)/usr/include/python$(PYTHON_VERSION)
index 463351c..39182fc 100644 (file)
 #include <SDL/SDL.h>
 #endif
 
-#if defined(FILESYSTEM) && !defined(_LINUX)
+#if defined(FILESYSTEM) && !defined(TARGET_POSIX)
 #include "filesystem/FileDAAP.h"
 #endif
 #ifdef HAS_UPNP
 #include "network/upnp/UPnPSettings.h"
 #include "filesystem/UPnPDirectory.h"
 #endif
-#if defined(_LINUX) && defined(HAS_FILESYSTEM_SMB)
+#if defined(TARGET_POSIX) && defined(HAS_FILESYSTEM_SMB)
 #include "filesystem/SMBDirectory.h"
 #endif
 #ifdef HAS_FILESYSTEM_NFS
 #endif
 #include "network/Zeroconf.h"
 #include "network/ZeroconfBrowser.h"
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #include "threads/platform/win/Win32Exception.h"
 #endif
 #ifdef HAS_EVENT_SERVER
 #include "settings/SkinSettings.h"
 #include "view/ViewStateSettings.h"
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "XHandle.h"
 #endif
 
 #include "android/activity/XBMCApp.h"
 #endif
 
-#ifdef TARGET_LINUX
-#include "linux/LinuxTimezone.h"
-#endif
-
 #ifdef TARGET_WINDOWS
 #include "utils/Environment.h"
 #endif
@@ -602,14 +598,14 @@ bool CApplication::Create()
     g_graphicsContext.ResetOverscan((RESOLUTION)i, CDisplaySettings::Get().GetResolutionInfo(i).Overscan);
   }
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   tzset();   // Initialize timezone information variables
 #endif
 
   // Grab a handle to our thread to be used later in identifying the render thread.
   m_threadID = CThread::GetCurrentThreadId();
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   //floating point precision to 24 bits (faster performance)
   _controlfp(_PC_24, _MCW_PC);
 
@@ -649,11 +645,11 @@ bool CApplication::Create()
   CLog::Log(LOGNOTICE, "Starting XBMC (%s), Platform: Darwin OSX (%s). Built on %s", g_infoManager.GetVersion().c_str(), g_sysinfo.GetUnameVersion().c_str(), __DATE__);
 #elif defined(TARGET_DARWIN_IOS)
   CLog::Log(LOGNOTICE, "Starting XBMC (%s), Platform: Darwin iOS (%s). Built on %s", g_infoManager.GetVersion().c_str(), g_sysinfo.GetUnameVersion().c_str(), __DATE__);
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
   CLog::Log(LOGNOTICE, "Starting XBMC (%s), Platform: FreeBSD (%s). Built on %s", g_infoManager.GetVersion().c_str(), g_sysinfo.GetUnameVersion().c_str(), __DATE__);
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
   CLog::Log(LOGNOTICE, "Starting XBMC (%s), Platform: Linux (%s, %s). Built on %s", g_infoManager.GetVersion().c_str(), g_sysinfo.GetLinuxDistro().c_str(), g_sysinfo.GetUnameVersion().c_str(), __DATE__);
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
   CLog::Log(LOGNOTICE, "Starting XBMC (%s), Platform: %s. Built on %s (compiler %i)", g_infoManager.GetVersion().c_str(), g_sysinfo.GetKernelVersion().c_str(), __DATE__, _MSC_VER);
   CLog::Log(LOGNOTICE, g_cpuInfo.getCPUModel().c_str());
   CLog::Log(LOGNOTICE, CWIN32Util::GetResInfoString());
@@ -698,9 +694,9 @@ bool CApplication::Create()
   // for python scripts that check the OS
 #if defined(TARGET_DARWIN)
   setenv("OS","OS X",true);
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
   setenv("OS","Linux",true);
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
   CEnvironment::setenv("OS", "win32");
 #endif
 
@@ -843,13 +839,13 @@ bool CApplication::CreateGUI()
   //depending on how it's compiled, SDL periodically calls XResetScreenSaver when it's fullscreen
   //this might bring the monitor out of standby, so we have to disable it explicitly
   //by passing 0 for overwrite to setsenv, the user can still override this by setting the environment variable
-#if defined(_LINUX) && !defined(TARGET_DARWIN)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
   setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
 #endif
 
 #endif // HAS_SDL
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   // for nvidia cards - vsync currently ALWAYS enabled.
   // the reason is that after screen has been setup changing this env var will make no difference.
   setenv("__GL_SYNC_TO_VBLANK", "1", 0);
@@ -994,7 +990,7 @@ bool CApplication::InitDirectoriesLinux()
          might be mixed case.
 */
 
-#if defined(_LINUX) && !defined(TARGET_DARWIN)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
   CStdString userName;
   if (getenv("USER"))
     userName = getenv("USER");
@@ -1168,7 +1164,7 @@ bool CApplication::InitDirectoriesOSX()
 
 bool CApplication::InitDirectoriesWin32()
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CStdString xbmcPath;
 
   CUtil::GetHomePath(xbmcPath);
@@ -1211,12 +1207,12 @@ void CApplication::CreateUserDirs()
 
 bool CApplication::Initialize()
 {
-#if defined(HAS_DVD_DRIVE) && !defined(_WIN32) // somehow this throws an "unresolved external symbol" on win32
+#if defined(HAS_DVD_DRIVE) && !defined(TARGET_WINDOWS) // somehow this throws an "unresolved external symbol" on win32
   // turn off cdio logging
   cdio_loglevel_default = CDIO_LOG_ERROR;
 #endif
 
-#ifdef _LINUX // TODO: Win32 has no special://home/ mapping by default, so we
+#ifdef TARGET_POSIX // TODO: Win32 has no special://home/ mapping by default, so we
               //       must create these here. Ideally this should be using special://home/ and
               //       be platform agnostic (i.e. unify the InitDirectories*() functions)
   if (!m_bPlatformDirectories)
@@ -1515,7 +1511,7 @@ void CApplication::StopPVRManager()
 
 void CApplication::StartServices()
 {
-#if !defined(_WIN32) && defined(HAS_DVD_DRIVE)
+#if !defined(TARGET_WINDOWS) && defined(HAS_DVD_DRIVE)
   // Start Thread for DVD Mediatype detection
   CLog::Log(LOGNOTICE, "start dvd mediatype detection");
   m_DetectDVDType.Create(false, THREAD_MINSTACKSIZE);
@@ -1533,7 +1529,7 @@ void CApplication::StopServices()
 {
   m_network->NetworkMessage(CNetwork::SERVICES_DOWN, 0);
 
-#if !defined(_WIN32) && defined(HAS_DVD_DRIVE)
+#if !defined(TARGET_WINDOWS) && defined(HAS_DVD_DRIVE)
   CLog::Log(LOGNOTICE, "stop dvd detect media");
   m_DetectDVDType.StopThread();
 #endif
@@ -3264,7 +3260,7 @@ bool CApplication::Cleanup()
     CSettings::Get().Uninitialize();
     g_advancedSettings.Clear();
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
     CXHandle::DumpObjectTracker();
 
 #ifdef HAS_DVD_DRIVE
@@ -3975,7 +3971,7 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart)
 
     }
 
-#if !defined(TARGET_DARWIN) && !defined(_LINUX)
+#if !defined(TARGET_POSIX)
     g_audioManager.Enable(false);
 #endif
 
@@ -5025,7 +5021,7 @@ void CApplication::ProcessSlow()
     UPNP::CUPnP::GetInstance()->UpdateState();
 #endif
 
-#if defined(_LINUX) && defined(HAS_FILESYSTEM_SMB)
+#if defined(TARGET_POSIX) && defined(HAS_FILESYSTEM_SMB)
   smb.CheckIfIdle();
 #endif
 
index 7200434..00e20ac 100644 (file)
@@ -52,10 +52,10 @@ class CPlayerController;
 #include "settings/ISettingsHandler.h"
 #include "settings/ISettingCallback.h"
 #include "settings/ISubSettings.h"
-#if !defined(_WIN32) && defined(HAS_DVD_DRIVE)
+#if !defined(TARGET_WINDOWS) && defined(HAS_DVD_DRIVE)
 #include "storage/DetectDVDType.h"
 #endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "win32/WIN32Util.h"
 #endif
 #include "utils/Stopwatch.h"
@@ -269,7 +269,7 @@ public:
   MEDIA_DETECT::CAutorun* m_Autorun;
 #endif
 
-#if !defined(_WIN32) && defined(HAS_DVD_DRIVE)
+#if !defined(TARGET_WINDOWS) && defined(HAS_DVD_DRIVE)
   MEDIA_DETECT::CDetectDVDMedia m_DetectDVDType;
 #endif
 
@@ -382,7 +382,7 @@ protected:
   ADDON::AddonPtr m_screenSaver;
 
   // timer information
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CWinIdleTimer m_idleTimer;
   CWinIdleTimer m_screenSaverTimer;
 #else
index 5ab05fd..c6a0410 100644 (file)
@@ -49,7 +49,7 @@
 
 #include "powermanagement/PowerManager.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "WIN32Util.h"
 #define CHalManager CWIN32Util
 #elif defined(TARGET_DARWIN)
@@ -306,6 +306,12 @@ void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg)
       }
       break;
 
+    case TMSG_ACTIVATESCREENSAVER:
+      {
+        g_application.ActivateScreenSaver();
+      }
+      break;
+
     case TMSG_MEDIA_PLAY:
       {
         // first check if we were called from the PlayFile() function
@@ -546,9 +552,9 @@ void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg)
       {
         CLog::Log(LOGNOTICE, "%s: Failed to suspend AudioEngine before launching external program",__FUNCTION__);
       }
-#if defined( _LINUX) && !defined(TARGET_DARWIN)
+#if defined( TARGET_POSIX) && !defined(TARGET_DARWIN)
       CUtil::RunCommandLine(pMsg->strParam.c_str(), (pMsg->dwParam1 == 1));
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
       CWIN32Util::XBMCShellExecute(pMsg->strParam.c_str(), (pMsg->dwParam1 == 1));
 #endif
       /* Resume AE processing of XBMC native audio */
@@ -1153,6 +1159,12 @@ void CApplicationMessenger::InhibitIdleShutdown(bool inhibit)
   SendMessage(tMsg);
 }
 
+void CApplicationMessenger::ActivateScreensaver()
+{
+  ThreadMessage tMsg = {TMSG_ACTIVATESCREENSAVER};
+  SendMessage(tMsg);
+}
+
 void CApplicationMessenger::NetworkMessage(unsigned int dwMessage, unsigned int dwParam)
 {
   ThreadMessage tMsg = {TMSG_NETWORKMESSAGE, dwMessage, dwParam};
index e18d3a6..d26fb67 100644 (file)
@@ -89,6 +89,7 @@ namespace MUSIC_INFO
 #define TMSG_RENDERER_FLUSH       312
 #define TMSG_INHIBITIDLESHUTDOWN  313
 #define TMSG_LOADPROFILE          314
+#define TMSG_ACTIVATESCREENSAVER  315
 
 #define TMSG_NETWORKMESSAGE         500
 
@@ -202,6 +203,7 @@ public:
   void RestartApp();
   void Reset();
   void InhibitIdleShutdown(bool inhibit);
+  void ActivateScreensaver();
   void SwitchToFullscreen(); //
   void Minimize(bool wait = false);
   void ExecOS(const CStdString command, bool waitExit = false);
index 9411b7e..753eb66 100644 (file)
@@ -104,7 +104,7 @@ bool CAutorun::PlayDisc(const CStdString& path, bool bypassSettings, bool startF
   if (mediaPath.IsEmpty())
     mediaPath = path;
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if (mediaPath.IsEmpty() || mediaPath.CompareNoCase("iso9660://") == 0)
     mediaPath = g_mediaManager.TranslateDevicePath("");
 #endif
@@ -455,7 +455,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
 
 void CAutorun::HandleAutorun()
 {
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
   if (!m_bEnable)
   {
     CDetectDVDMedia::m_evAutorun.Reset();
index ed91b92..3c76188 100644 (file)
@@ -136,7 +136,7 @@ void CBackgroundInfoLoader::Load(CFileItemList& items)
   {
     CThread *pThread = new CThread(this, "BackgroundLoader");
     pThread->Create();
-#ifndef _LINUX
+#ifndef TARGET_POSIX
     pThread->SetPriority(THREAD_PRIORITY_BELOW_NORMAL);
 #endif
     m_workers.push_back(pThread);
index 5d85e5d..eef1caf 100644 (file)
@@ -77,6 +77,7 @@ CCueDocument::CCueDocument(void)
   m_replayGainAlbumGain = 0.0f;
   m_iTotalTracks = 0;
   m_iTrack = 0;
+  m_iDiscNumber = 0;
 }
 
 CCueDocument::~CCueDocument(void)
@@ -102,7 +103,7 @@ bool CCueDocument::Parse(const CStdString &strFile)
   {
     if (!ReadNextLine(strLine))
       break;
-    if (strLine.Left(8) == "INDEX 01")
+    if (StringUtils::StartsWith(strLine,"INDEX 01"))
     {
       if (bCurrentFileChanged)
       {
@@ -123,7 +124,7 @@ bool CCueDocument::Parse(const CStdString &strFile)
       if (m_iTotalTracks >= 0)
         m_Track[m_iTotalTracks].iStartTime = time; // start time of the next track
     }
-    else if (strLine.Left(5) == "TITLE")
+    else if (StringUtils::StartsWith(strLine,"TITLE"))
     {
       if (m_iTotalTracks == -1) // No tracks yet
         ExtractQuoteInfo(strLine, m_strAlbum);
@@ -139,16 +140,16 @@ bool CCueDocument::Parse(const CStdString &strFile)
         }
       }
     }
-    else if (strLine.Left(9) == "PERFORMER")
+    else if (StringUtils::StartsWith(strLine,"PERFORMER"))
     {
       if (m_iTotalTracks == -1) // No tracks yet
         ExtractQuoteInfo(strLine, m_strArtist);
       else // New Artist for this track
         ExtractQuoteInfo(strLine, m_Track[m_iTotalTracks].strArtist);
     }
-    else if (strLine.Left(5) == "TRACK")
+    else if (StringUtils::StartsWith(strLine,"TRACK"))
     {
-      int iTrackNumber = ExtractNumericInfo(strLine.c_str() + 5);
+      int iTrackNumber = ExtractNumericInfo(strLine.Mid(5));
 
       m_iTotalTracks++;
 
@@ -163,7 +164,13 @@ bool CCueDocument::Parse(const CStdString &strFile)
 
       bCurrentFileChanged = false;
     }
-    else if (strLine.Left(4) == "FILE")
+    else if (StringUtils::StartsWith(strLine,"REM DISCNUMBER"))
+    {
+      int iDiscNumber = ExtractNumericInfo(strLine.Mid(14));
+      if (iDiscNumber > 0)
+        m_iDiscNumber = iDiscNumber;
+    }
+    else if (StringUtils::StartsWith(strLine,"FILE"))
     {
       // already a file name? then the time computation will be changed
       if(strCurrentFile.size() > 0)
@@ -175,13 +182,13 @@ bool CCueDocument::Parse(const CStdString &strFile)
       if (strCurrentFile.length() > 0)
         ResolvePath(strCurrentFile, strFile);
     }
-    else if (strLine.Left(8) == "REM DATE")
+    else if (StringUtils::StartsWith(strLine,"REM DATE"))
     {
-      int iYear = ExtractNumericInfo(strLine.c_str() + 8);
+      int iYear = ExtractNumericInfo(strLine.Mid(8));
       if (iYear > 0)
         m_iYear = iYear;
     }
-    else if (strLine.Left(9) == "REM GENRE")
+    else if (StringUtils::StartsWith(strLine,"REM GENRE"))
     {
       if (!ExtractQuoteInfo(strLine, m_strGenre))
       {
@@ -194,13 +201,13 @@ bool CCueDocument::Parse(const CStdString &strFile)
         }
       }
     }
-    else if (strLine.Left(25) == "REM REPLAYGAIN_ALBUM_GAIN")
+    else if (StringUtils::StartsWith(strLine,"REM REPLAYGAIN_ALBUM_GAIN"))
       m_replayGainAlbumGain = (float)atof(strLine.Mid(26));
-    else if (strLine.Left(25) == "REM REPLAYGAIN_ALBUM_PEAK")
+    else if (StringUtils::StartsWith(strLine,"REM REPLAYGAIN_ALBUM_PEAK"))
       m_replayGainAlbumPeak = (float)atof(strLine.Mid(26));
-    else if (strLine.Left(25) == "REM REPLAYGAIN_TRACK_GAIN" && m_iTotalTracks >= 0)
+    else if (StringUtils::StartsWith(strLine,"REM REPLAYGAIN_TRACK_GAIN") && m_iTotalTracks >= 0)
       m_Track[m_iTotalTracks].replayGainTrackGain = (float)atof(strLine.Mid(26));
-    else if (strLine.Left(25) == "REM REPLAYGAIN_TRACK_PEAK" && m_iTotalTracks >= 0)
+    else if (StringUtils::StartsWith(strLine,"REM REPLAYGAIN_TRACK_PEAK") && m_iTotalTracks >= 0)
       m_Track[m_iTotalTracks].replayGainTrackPeak = (float)atof(strLine.Mid(26));
   }
 
@@ -236,6 +243,8 @@ void CCueDocument::GetSongs(VECSONGS &songs)
     song.genre = StringUtils::Split(m_strGenre, g_advancedSettings.m_musicItemSeparator);
     song.iYear = m_iYear;
     song.iTrack = m_Track[i].iTrackNumber;
+    if ( m_iDiscNumber > 0 )  
+      song.iTrack |= (m_iDiscNumber << 16); // see CMusicInfoTag::GetDiscNumber()
     if (m_Track[i].strTitle.length() == 0) // No track information for this track!
       song.strTitle.Format("Track %2d", i + 1);
     else
index 740d2d5..4885a4f 100644 (file)
@@ -71,6 +71,7 @@ private:
   int m_iYear;            //album year
   int m_iTrack;   // current track
   int m_iTotalTracks;  // total tracks
+  int m_iDiscNumber;  // Disc number
   float m_replayGainAlbumGain;
   float m_replayGainAlbumPeak;
 
index 2ce617a..7da9d75 100644 (file)
@@ -21,9 +21,9 @@
  *
  */
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "DllPaths_win32.h"
-#elif defined (__ANDROID__)
+#elif defined (TARGET_ANDROID)
 #include "DllPaths_generated_android.h"
 #else
 #include "DllPaths_generated.h"
index 09e5491..95635a7 100644 (file)
 #define DLL_PATH_VORBIS        "@VORBIS_SONAME@"
 
 /* broadcom crystalhd */
-#if defined(_LINUX) && !defined(__APPLE__)
-#define DLL_PATH_LIBCRYSTALHD  "@CRYSTALHD_SONAME@"
-#else
+#if defined(TARGET_DARWIN)
 #define DLL_PATH_LIBCRYSTALHD  "libcrystalhd.dylib"
+#else
+#define DLL_PATH_LIBCRYSTALHD  "@CRYSTALHD_SONAME@"
 #endif
 
 /* libbluray */
 #define DLL_PATH_LIBBLURAY     "@BLURAY_SONAME@"
 
-/* apple vdadecoder */
-#define DLL_PATH_LIBVDADECODER "/System/Library/Frameworks/VideoDecodeAcceleration.framework/Versions/Current/VideoDecodeAcceleration"
-
 #endif
index af26cc8..3ae2628 100644 (file)
@@ -218,7 +218,7 @@ public: \
 #define DEFINE_METHOD10(result, name, args) DEFINE_METHOD_LINKAGE10(result, __cdecl, name, args)
 #define DEFINE_METHOD11(result, name, args) DEFINE_METHOD_LINKAGE11(result, __cdecl, name, args)
 
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
 ///////////////////////////////////////////////////////////
 //
 //  DEFINE_FUNC_ALIGNED 0-X
diff --git a/xbmc/Favourites.cpp b/xbmc/Favourites.cpp
deleted file mode 100644 (file)
index e770738..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- *      Copyright (C) 2005-2013 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, see
- *  <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "Favourites.h"
-#include "filesystem/File.h"
-#include "Util.h"
-#include "profiles/ProfilesManager.h"
-#include "FileItem.h"
-#include "utils/XBMCTinyXML.h"
-#include "utils/log.h"
-#include "utils/StringUtils.h"
-#include "utils/URIUtils.h"
-#include "settings/AdvancedSettings.h"
-#include "video/VideoInfoTag.h"
-
-bool CFavourites::Load(CFileItemList &items)
-{
-  items.Clear();
-  CStdString favourites;
-
-  favourites = "special://xbmc/system/favourites.xml";
-  if(XFILE::CFile::Exists(favourites))
-    CFavourites::LoadFavourites(favourites, items);
-  else
-    CLog::Log(LOGDEBUG, "CFavourites::Load - no system favourites found, skipping");
-  favourites = URIUtils::AddFileToFolder(CProfilesManager::Get().GetProfileUserDataFolder(), "favourites.xml");
-  if(XFILE::CFile::Exists(favourites))
-    CFavourites::LoadFavourites(favourites, items);
-  else
-    CLog::Log(LOGDEBUG, "CFavourites::Load - no userdata favourites found, skipping");
-
-  return true;
-}
-
-bool CFavourites::LoadFavourites(CStdString& strPath, CFileItemList& items)
-{
-  CXBMCTinyXML doc;
-  if (!doc.LoadFile(strPath))
-  {
-    CLog::Log(LOGERROR, "Unable to load %s (row %i column %i)", strPath.c_str(), doc.Row(), doc.Column());
-    return false;
-  }
-  TiXmlElement *root = doc.RootElement();
-  if (!root || strcmp(root->Value(), "favourites"))
-  {
-    CLog::Log(LOGERROR, "Favourites.xml doesn't contain the <favourites> root element");
-    return false;
-  }
-
-  TiXmlElement *favourite = root->FirstChildElement("favourite");
-  while (favourite)
-  {
-    // format:
-    // <favourite name="Cool Video" thumb="foo.jpg">PlayMedia(c:\videos\cool_video.avi)</favourite>
-    // <favourite name="My Album" thumb="bar.tbn">ActivateWindow(MyMusic,c:\music\my album)</favourite>
-    // <favourite name="Apple Movie Trailers" thumb="path_to_thumb.png">RunScript(special://xbmc/scripts/apple movie trailers/default.py)</favourite>
-    const char *name = favourite->Attribute("name");
-    const char *thumb = favourite->Attribute("thumb");
-    if (name && favourite->FirstChild())
-    {
-      if(!items.Contains(favourite->FirstChild()->Value()))
-      {
-        CFileItemPtr item(new CFileItem(name));
-        item->SetPath(favourite->FirstChild()->Value());
-        if (thumb) item->SetArt("thumb", thumb);
-        items.Add(item);
-      }
-    }
-    favourite = favourite->NextSiblingElement("favourite");
-  }
-  return true;
-}
-
-bool CFavourites::Save(const CFileItemList &items)
-{
-  CStdString favourites;
-  CXBMCTinyXML doc;
-  TiXmlElement xmlRootElement("favourites");
-  TiXmlNode *rootNode = doc.InsertEndChild(xmlRootElement);
-  if (!rootNode) return false;
-
-  for (int i = 0; i < items.Size(); i++)
-  {
-    const CFileItemPtr item = items[i];
-    TiXmlElement favNode("favourite");
-    favNode.SetAttribute("name", item->GetLabel().c_str());
-    if (item->HasArt("thumb"))
-      favNode.SetAttribute("thumb", item->GetArt("thumb").c_str());
-    TiXmlText execute(item->GetPath());
-    favNode.InsertEndChild(execute);
-    rootNode->InsertEndChild(favNode);
-  }
-
-  favourites = URIUtils::AddFileToFolder(CProfilesManager::Get().GetProfileUserDataFolder(), "favourites.xml");
-  return doc.SaveFile(favourites);
-}
-
-bool CFavourites::AddOrRemove(CFileItem *item, int contextWindow)
-{
-  if (!item) return false;
-
-  // load our list
-  CFileItemList items;
-  Load(items);
-
-  CStdString executePath(GetExecutePath(item, contextWindow));
-
-  CFileItemPtr match = items.Get(executePath);
-  if (match)
-  { // remove the item
-    items.Remove(match.get());
-  }
-  else
-  { // create our new favourite item
-    CFileItemPtr favourite(new CFileItem(item->GetLabel()));
-    if (item->GetLabel().IsEmpty())
-      favourite->SetLabel(CUtil::GetTitleFromPath(item->GetPath(), item->m_bIsFolder));
-    favourite->SetArt("thumb", item->GetArt("thumb"));
-    favourite->SetPath(executePath);
-    items.Add(favourite);
-  }
-
-  // and save our list again
-  return Save(items);
-}
-
-bool CFavourites::IsFavourite(CFileItem *item, int contextWindow)
-{
-  CFileItemList items;
-  if (!Load(items)) return false;
-
-  return items.Contains(GetExecutePath(item, contextWindow));
-}
-
-CStdString CFavourites::GetExecutePath(const CFileItem *item, int contextWindow)
-{
-  CStdString execute;
-  if (item->m_bIsFolder && (g_advancedSettings.m_playlistAsFolders ||
-                            !(item->IsSmartPlayList() || item->IsPlayList())))
-    execute.Format("ActivateWindow(%i,%s)", contextWindow, StringUtils::Paramify(item->GetPath()).c_str());
-  else if (item->IsScript())
-    execute.Format("RunScript(%s)", StringUtils::Paramify(item->GetPath().Mid(9)).c_str());
-  else if (item->IsAndroidApp())
-    execute.Format("StartAndroidActivity(%s)", StringUtils::Paramify(item->GetPath().Mid(26)).c_str());
-  else  // assume a media file
-  {
-    if (item->IsVideoDb() && item->HasVideoInfoTag())
-      execute.Format("PlayMedia(%s)", StringUtils::Paramify(item->GetVideoInfoTag()->m_strFileNameAndPath).c_str());
-    else
-      execute.Format("PlayMedia(%s)", StringUtils::Paramify(item->GetPath()).c_str());
-  }
-  return execute;
-}
diff --git a/xbmc/Favourites.h b/xbmc/Favourites.h
deleted file mode 100644 (file)
index 36ddd7b..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#pragma once
-
-/*
- *      Copyright (C) 2005-2013 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, see
- *  <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "utils/StdString.h"
-
-class CFileItemList;
-class CFileItem;
-
-class CFavourites
-{
-public:
-  static bool Load(CFileItemList& items);
-  static bool LoadFavourites(CStdString& strPath, CFileItemList& items);
-  static bool AddOrRemove(CFileItem *item, int contextWindow);
-  static bool Save(const CFileItemList& items);
-  static bool IsFavourite(CFileItem *item, int contextWindow);
-private:
-  static CStdString GetExecutePath(const CFileItem *item, int contextWindow);
-};
index b84c9fa..d6b289e 100644 (file)
@@ -780,14 +780,7 @@ bool CFileItem::IsVideo() const
      return true;
   }
 
-  extension = URIUtils::GetExtension(m_strPath);
-
-  if (extension.IsEmpty())
-    return false;
-
-  extension.ToLower();
-
-  return (g_advancedSettings.m_videoExtensions.Find(extension) != -1);
+  return URIUtils::HasExtension(m_strPath, g_advancedSettings.m_videoExtensions);
 }
 
 bool CFileItem::IsEPG() const
@@ -822,15 +815,7 @@ bool CFileItem::IsDiscStub() const
     return dbItem.IsDiscStub();
   }
 
-  CStdString strExtension = URIUtils::GetExtension(m_strPath);
-
-  if (strExtension.IsEmpty())
-    return false;
-
-  strExtension.ToLower();
-  strExtension += '|';
-
-  return (g_advancedSettings.m_discStubExtensions + '|').Find(strExtension) != -1;
+  return URIUtils::HasExtension(m_strPath, g_advancedSettings.m_discStubExtensions);
 }
 
 bool CFileItem::IsAudio() const
@@ -844,24 +829,16 @@ bool CFileItem::IsAudio() const
   if (HasPictureInfoTag()) return false;
   if (IsCDDA()) return true;
 
-  CStdString extension;
   if( m_mimetype.Left(12).Equals("application/") )
   { /* check for some standard types */
-    extension = m_mimetype.Mid(12);
+    CStdString extension = m_mimetype.Mid(12);
     if( extension.Equals("ogg")
      || extension.Equals("mp4")
      || extension.Equals("mxf") )
      return true;
   }
 
-  extension = URIUtils::GetExtension(m_strPath);
-
-  if (extension.IsEmpty())
-    return false;
-
-  extension.ToLower();
-
-  return (g_advancedSettings.m_musicExtensions.Find(extension) != -1);
+  return URIUtils::HasExtension(m_strPath, g_advancedSettings.m_musicExtensions);
 }
 
 bool CFileItem::IsKaraoke() const
@@ -886,12 +863,12 @@ bool CFileItem::IsPicture() const
 
 bool CFileItem::IsLyrics() const
 {
-  return URIUtils::GetExtension(m_strPath).Equals(".cdg", false) || URIUtils::GetExtension(m_strPath).Equals(".lrc", false);
+  return URIUtils::HasExtension(m_strPath, ".cdg|.lrc");
 }
 
 bool CFileItem::IsCUESheet() const
 {
-  return URIUtils::GetExtension(m_strPath).Equals(".cue", false);
+  return URIUtils::HasExtension(m_strPath, ".cue");
 }
 
 bool CFileItem::IsInternetStream(const bool bStrictCheck /* = false */) const
@@ -919,12 +896,7 @@ bool CFileItem::IsFileFolder(EFileFolderType types) const
     || IsZIP()
     || IsRAR()
     || IsRSS()
-    || IsType(".ogg")
-    || IsType(".oga")
-    || IsType(".nsf")
-    || IsType(".sid")
-    || IsType(".sap")
-    || IsType(".xsp")
+    || IsType(".ogg|.oga|.nsf|.sid|.sap|.xsp")
 #if defined(TARGET_ANDROID)
     || IsType(".apk")
 #endif
@@ -951,9 +923,7 @@ bool CFileItem::IsSmartPlayList() const
   if (HasProperty("library.smartplaylist") && GetProperty("library.smartplaylist").asBoolean())
     return true;
 
-  CStdString strExtension = URIUtils::GetExtension(m_strPath);
-  strExtension.ToLower();
-  return (strExtension == ".xsp");
+  return URIUtils::HasExtension(m_strPath, ".xsp");
 }
 
 bool CFileItem::IsPlayList() const
@@ -963,23 +933,22 @@ bool CFileItem::IsPlayList() const
 
 bool CFileItem::IsPythonScript() const
 {
-  return URIUtils::GetExtension(m_strPath).Equals(".py", false);
+  return URIUtils::HasExtension(m_strPath, ".py");
 }
 
 bool CFileItem::IsType(const char *ext) const
 {
-  return URIUtils::GetExtension(m_strPath).Equals(ext, false);
+  return URIUtils::HasExtension(m_strPath, ext);
 }
 
 bool CFileItem::IsNFO() const
 {
-  return URIUtils::GetExtension(m_strPath).Equals(".nfo", false);
+  return URIUtils::HasExtension(m_strPath, ".nfo");
 }
 
 bool CFileItem::IsDVDImage() const
 {
-  CStdString strExtension = URIUtils::GetExtension(m_strPath);
-  return (strExtension.Equals(".img") || strExtension.Equals(".iso") || strExtension.Equals(".nrg"));
+  return URIUtils::HasExtension(m_strPath, ".img|.iso|.nrg");
 }
 
 bool CFileItem::IsOpticalMediaFile() const
@@ -1030,20 +999,17 @@ bool CFileItem::IsZIP() const
 
 bool CFileItem::IsCBZ() const
 {
-  return URIUtils::GetExtension(m_strPath).Equals(".cbz", false);
+  return URIUtils::HasExtension(m_strPath, ".cbz");
 }
 
 bool CFileItem::IsCBR() const
 {
-  return URIUtils::GetExtension(m_strPath).Equals(".cbr", false);
+  return URIUtils::HasExtension(m_strPath, ".cbr");
 }
 
 bool CFileItem::IsRSS() const
 {
-  if (m_strPath.Left(6).Equals("rss://"))
-    return true;
-
-  return URIUtils::GetExtension(m_strPath).Equals(".rss")
+  return m_strPath.Left(6).Equals("rss://") || URIUtils::HasExtension(m_strPath, ".rss")
       || GetMimeType() == "application/rss+xml";
 }
 
@@ -1735,6 +1701,8 @@ void CFileItemList::Assign(const CFileItemList& itemlist, bool append)
   SetPath(itemlist.GetPath());
   SetLabel(itemlist.GetLabel());
   m_sortDetails = itemlist.m_sortDetails;
+  m_sortMethod = itemlist.m_sortMethod;
+  m_sortOrder = itemlist.m_sortOrder;
   m_replaceListing = itemlist.m_replaceListing;
   m_content = itemlist.m_content;
   m_mapProperties = itemlist.m_mapProperties;
index 87cb8ee..fba60ae 100644 (file)
@@ -37,6 +37,7 @@
 #include "pictures/GUIWindowSlideShow.h"
 #include "pictures/PictureInfoTag.h"
 #include "music/tags/MusicInfoTag.h"
+#include "guilib/IGUIContainer.h"
 #include "guilib/GUIWindowManager.h"
 #include "playlists/PlayList.h"
 #include "profiles/ProfilesManager.h"
@@ -2112,13 +2113,13 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI
     bReturn = g_application.IsMusicScanning();
   }
   else if (condition == SYSTEM_PLATFORM_LINUX)
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(TARGET_ANDROID)
+#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
     bReturn = true;
 #else
     bReturn = false;
 #endif
   else if (condition == SYSTEM_PLATFORM_WINDOWS)
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
     bReturn = true;
 #else
     bReturn = false;
@@ -3958,7 +3959,7 @@ string CGUIInfoManager::GetSystemHeatInfo(int info)
   if (CTimeUtils::GetFrameTime() - m_lastSysHeatInfoTime >= SYSHEATUPDATEINTERVAL)
   { // update our variables
     m_lastSysHeatInfoTime = CTimeUtils::GetFrameTime();
-#if defined(_LINUX)
+#if defined(TARGET_POSIX)
     g_cpuInfo.getTemperature(m_cpuTemp);
     m_gpuTemp = GetGPUTemperature();
 #endif
@@ -3977,7 +3978,7 @@ string CGUIInfoManager::GetSystemHeatInfo(int info)
       text.Format("%i%%", m_fanSpeed * 2);
       break;
     case SYSTEM_CPU_USAGE:
-#if defined(TARGET_DARWIN) || defined(_WIN32)
+#if defined(TARGET_DARWIN) || defined(TARGET_WINDOWS)
       text.Format("%d%%", g_cpuInfo.getUsedPercentage());
 #else
       text.Format("%s", g_cpuInfo.GetCoresUsageString());
index f6f345c..64de9cf 100644 (file)
@@ -323,10 +323,10 @@ bool CGUIPassword::CheckMenuLock(int iWindowID)
   int iSwitch = iWindowID;
 
   // check if a settings subcategory was called from other than settings window
-  if (iWindowID >= WINDOW_SCREEN_CALIBRATION && iWindowID <= WINDOW_SETTINGS_APPEARANCE)
+  if (iWindowID >= WINDOW_SCREEN_CALIBRATION && iWindowID <= WINDOW_SETTINGS_MYPVR)
   {
     int iCWindowID = g_windowManager.GetActiveWindow();
-    if (iCWindowID != WINDOW_SETTINGS_MENU && (iCWindowID < WINDOW_SCREEN_CALIBRATION || iCWindowID > WINDOW_SETTINGS_APPEARANCE))
+    if (iCWindowID != WINDOW_SETTINGS_MENU && (iCWindowID < WINDOW_SCREEN_CALIBRATION || iCWindowID > WINDOW_SETTINGS_MYPVR))
       iSwitch = WINDOW_SETTINGS_MENU;
   }
 
index c059563..8df28de 100644 (file)
@@ -156,7 +156,7 @@ void CLangInfo::CRegion::SetGlobalLocale()
   if (m_strRegionLocaleName.length() > 0)
   {
     strLocale = m_strLangLocaleName + "_" + m_strRegionLocaleName;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
     strLocale += ".UTF-8";
 #endif
   }
@@ -167,7 +167,7 @@ void CLangInfo::CRegion::SetGlobalLocale()
   // decimal separator is changed depending of the current language
   // (ie. "," in French or Dutch instead of "."). This breaks atof() and
   // others similar functions.
-#if defined(__FreeBSD__) || defined(TARGET_DARWIN_OSX)
+#if defined(TARGET_FREEBSD) || defined(TARGET_DARWIN_OSX)
   // on FreeBSD and darwin libstdc++ is compiled with "generic" locale support
   if (setlocale(LC_COLLATE, strLocale.c_str()) == NULL
   || setlocale(LC_CTYPE, strLocale.c_str()) == NULL)
@@ -250,7 +250,7 @@ bool CLangInfo::Load(const CStdString& strFileName)
   if (pRootElement->Attribute("locale"))
     m_defaultRegion.m_strLangLocaleName = pRootElement->Attribute("locale");
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   // Windows need 3 chars isolang code
   if (m_defaultRegion.m_strLangLocaleName.length() == 2)
   {
@@ -319,7 +319,7 @@ bool CLangInfo::Load(const CStdString& strFileName)
       if (pRegion->Attribute("locale"))
         region.m_strRegionLocaleName = pRegion->Attribute("locale");
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
       // Windows need 3 chars regions code
       if (region.m_strRegionLocaleName.length() == 2)
       {
index 5a9bd6b..38fe9d5 100644 (file)
@@ -8,7 +8,6 @@ SRCS=Application.cpp \
      DatabaseManager.cpp \
      DbUrl.cpp \
      DynamicDll.cpp \
-     Favourites.cpp \
      FileItem.cpp \
      GUIInfoManager.cpp \
      GUILargeTextureManager.cpp \
index 002028e..eb1b804 100644 (file)
@@ -54,6 +54,7 @@ void CMediaSource::FromNameAndPaths(const CStdString &category, const CStdString
   m_strLockCode = "0";
   m_iBadPwdCount = 0;
   m_iHasLock = 0;
+  m_allowSharing = true;
 
   if (URIUtils::IsMultiPath(strPath))
     m_iDriveType = SOURCE_TYPE_VPATH;
index cc8cf3b..941211f 100644 (file)
@@ -41,7 +41,7 @@ public:
     SOURCE_TYPE_VPATH        = 5,
     SOURCE_TYPE_REMOVABLE    = 6
   };
-  CMediaSource() { m_iDriveType=SOURCE_TYPE_UNKNOWN; m_iLockMode=LOCK_MODE_EVERYONE; m_iBadPwdCount=0; m_iHasLock=0; m_ignore=false; };
+  CMediaSource() { m_iDriveType=SOURCE_TYPE_UNKNOWN; m_iLockMode=LOCK_MODE_EVERYONE; m_iBadPwdCount=0; m_iHasLock=0; m_ignore=false; m_allowSharing=true; };
   virtual ~CMediaSource() {};
 
   bool operator==(const CMediaSource &right) const;
@@ -98,6 +98,7 @@ public:
 
   std::vector<CStdString> vecPaths;
   bool m_ignore; /// <Do not store in xml
+  bool m_allowSharing; /// <Allow browsing of source from UPnP / WebServer
 };
 
 /*!
index 3b98e24..ed53f0c 100644 (file)
@@ -24,9 +24,7 @@
 #if !defined(AFX_NfoFile_H__641CCF68_6D2A_426E_9204_C0E4BEF12D00__INCLUDED_)
 #define AFX_NfoFile_H__641CCF68_6D2A_426E_9204_C0E4BEF12D00__INCLUDED_
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 
 #include "utils/XBMCTinyXML.h"
 #include "addons/Scraper.h"
index 987b7b7..2dd1734 100644 (file)
@@ -24,7 +24,6 @@
 #include "GUILargeTextureManager.h"
 #include "guilib/TextureManager.h"
 #include "utils/AlarmClock.h"
-#include "utils/DownloadQueueManager.h"
 #include "GUIInfoManager.h"
 #include "filesystem/DllLibCurl.h"
 #include "filesystem/DirectoryCache.h"
@@ -71,7 +70,6 @@
   CGUIInfoManager    g_infoManager;
 
   XCURL::DllLibCurlGlobal g_curlInterface;
-  CDownloadQueueManager g_DownloadManager;
   CPartyModeManager     g_partyModeManager;
 
 #ifdef HAS_PYTHON
index cffc70d..787d1e4 100644 (file)
@@ -236,7 +236,7 @@ bool CTextureDDSJob::operator==(const CJob* job) const
 
 bool CTextureDDSJob::DoWork()
 {
-  if (URIUtils::GetExtension(m_original).Equals(".dds"))
+  if (URIUtils::HasExtension(m_original, ".dds"))
     return false;
   CBaseTexture *texture = CBaseTexture::LoadFromFile(m_original);
   if (texture)
index f0d81b4..2b46585 100644 (file)
@@ -27,7 +27,7 @@
 #include "FileItem.h"
 #include "filesystem/StackDirectory.h"
 #include "addons/Addon.h"
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #include <sys\types.h>
 #include <sys\stat.h>
 #endif
@@ -120,7 +120,7 @@ void CURL::Parse(const CStdString& strURL1)
       struct __stat64 s;
       if (XFILE::CFile::Stat(archiveName, &s) == 0)
       {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
         if (!S_ISDIR(s.st_mode))
 #else
         if (!(s.st_mode & S_IFDIR))
@@ -501,7 +501,7 @@ const CStdString CURL::GetFileNameWithoutPath() const
 
 char CURL::GetDirectorySeparator() const
 {
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   if ( IsLocal() )
     return '\\';
   else
index ee38482..cb02bd9 100644 (file)
@@ -22,7 +22,7 @@
 #include "utils/StdString.h"
 #include "utils/UrlOptions.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #undef SetPort // WIN32INCLUDES this is defined as SetPortA in WinSpool.h which is being included _somewhere_
 #endif
 
index 367b62c..f7d1d39 100644 (file)
 #include <mach-o/dyld.h>
 #endif
 
-#if defined(__FreeBSD__)
+#if defined(TARGET_FREEBSD)
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #endif
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include <sys/types.h>
 #include <dirent.h>
 #include <unistd.h>
@@ -63,7 +63,7 @@
 #include "guilib/TextureManager.h"
 #include "utils/fstrcmp.h"
 #include "storage/MediaManager.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "utils/CharsetConverter.h"
 #include <shlobj.h>
 #include "WIN32Util.h"
@@ -86,6 +86,7 @@
 #include "utils/TimeUtils.h"
 #include "utils/URIUtils.h"
 #include "utils/log.h"
+#include "utils/Environment.h"
 
 #include "cores/dvdplayer/DVDSubtitles/DVDSubtitleTagSami.h"
 #include "cores/dvdplayer/DVDSubtitles/DVDSubtitleStream.h"
@@ -242,7 +243,6 @@ void CUtil::CleanString(const CStdString& strFileName, CStdString& strTitle, CSt
 
   CRegExp reTags(true);
   CRegExp reYear;
-  CStdString strExtension = URIUtils::GetExtension(strFileName);
 
   if (!reYear.RegComp(g_advancedSettings.m_videoCleanDateTimeRegExp))
   {
@@ -303,7 +303,7 @@ void CUtil::CleanString(const CStdString& strFileName, CStdString& strTitle, CSt
 
   // restore extension if needed
   if (!bRemoveExtension)
-    strTitleAndYear += strExtension;
+    strTitleAndYear += URIUtils::GetExtension(strFileName);
 }
 
 void CUtil::GetQualifiedFilename(const CStdString &strBasePath, CStdString &strFilename)
@@ -315,7 +315,7 @@ void CUtil::GetQualifiedFilename(const CStdString &strBasePath, CStdString &strF
 
   // If the filename starts "x:", "\\" or "/" it's already fully qualified so return
   if (strFilename.size() > 1)
-#ifdef _LINUX
+#ifdef TARGET_POSIX
     if ( (strFilename[1] == ':') || (strFilename[0] == '/') )
 #else
     if ( strFilename[1] == ':' || (strFilename[0] == '\\' && strFilename[1] == '\\'))
@@ -364,7 +364,7 @@ bool CUtil::TestGetQualifiedFilename()
 bool CUtil::TestMakeLegalPath()
 {
   CStdString path;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   path = "C:\\foo\\bar"; path = MakeLegalPath(path);
   if (path != "C:\\foo\\bar") return false;
   path = "C:\\foo:\\bar\\"; path = MakeLegalPath(path);
@@ -391,18 +391,11 @@ void CUtil::GetHomePath(CStdString& strPath, const CStdString& strTarget)
 {
   CStdString strHomePath;
   strHomePath = ResolveExecutablePath();
-#ifdef _WIN32
-  CStdStringW strPathW, strTargetW;
-  g_charsetConverter.utf8ToW(strTarget, strTargetW);
-  strPathW = _wgetenv(strTargetW);
-  g_charsetConverter.wToUTF8(strPathW,strPath);
-#else
-  strPath = getenv(strTarget);
-#endif
+  strPath = CEnvironment::getenv(strTarget);
 
-  if (strPath != NULL && !strPath.IsEmpty())
+  if (!strPath.IsEmpty())
   {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
     char tmp[1024];
     //expand potential relative path to full path
     if(GetFullPathName(strPath, 1024, tmp, 0) != 0)
@@ -448,7 +441,7 @@ void CUtil::GetHomePath(CStdString& strPath, const CStdString& strTarget)
       strPath = strHomePath;
   }
 
-#if defined(_LINUX) && !defined(TARGET_DARWIN)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
   /* Change strPath accordingly when target is XBMC_HOME and when INSTALL_PATH
    * and BIN_INSTALL_PATH differ
    */
@@ -503,19 +496,8 @@ bool CUtil::IsTVRecording(const CStdString& strFile)
 
 bool CUtil::IsPicture(const CStdString& strFile)
 {
-  CStdString extension = URIUtils::GetExtension(strFile);
-
-  if (extension.IsEmpty())
-    return false;
-
-  extension.ToLower();
-  if (g_advancedSettings.m_pictureExtensions.Find(extension) != -1)
-    return true;
-
-  if (extension == ".tbn" || extension == ".dds")
-    return true;
-
-  return false;
+  return URIUtils::HasExtension(strFile,
+                  g_advancedSettings.m_pictureExtensions + "|.tbn|.dds");
 }
 
 bool CUtil::ExcludeFileOrFolder(const CStdString& strFileOrFolder, const CStdStringArray& regexps)
@@ -779,7 +761,7 @@ void CUtil::StatToStatI64(struct _stati64 *result, struct stat *stat)
   result->st_rdev = stat->st_rdev;
   result->st_size = (int64_t)stat->st_size;
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   result->st_atime = (long)(stat->st_atime & 0xFFFFFFFF);
   result->st_mtime = (long)(stat->st_mtime & 0xFFFFFFFF);
   result->st_ctime = (long)(stat->st_ctime & 0xFFFFFFFF);
@@ -800,7 +782,7 @@ void CUtil::Stat64ToStatI64(struct _stati64 *result, struct __stat64 *stat)
   result->st_gid = stat->st_gid;
   result->st_rdev = stat->st_rdev;
   result->st_size = stat->st_size;
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   result->st_atime = (long)(stat->st_atime & 0xFFFFFFFF);
   result->st_mtime = (long)(stat->st_mtime & 0xFFFFFFFF);
   result->st_ctime = (long)(stat->st_ctime & 0xFFFFFFFF);
@@ -821,7 +803,7 @@ void CUtil::StatI64ToStat64(struct __stat64 *result, struct _stati64 *stat)
   result->st_gid = stat->st_gid;
   result->st_rdev = stat->st_rdev;
   result->st_size = stat->st_size;
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   result->st_atime = stat->st_atime;
   result->st_mtime = stat->st_mtime;
   result->st_ctime = stat->st_ctime;
@@ -841,7 +823,7 @@ void CUtil::Stat64ToStat(struct stat *result, struct __stat64 *stat)
   result->st_uid = stat->st_uid;
   result->st_gid = stat->st_gid;
   result->st_rdev = stat->st_rdev;
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   if (stat->st_size <= LONG_MAX)
     result->st_size = (_off_t)stat->st_size;
 #else
@@ -858,7 +840,7 @@ void CUtil::Stat64ToStat(struct stat *result, struct __stat64 *stat)
   result->st_ctime = (time_t)(stat->st_ctime & 0xFFFFFFFF);
 }
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 void CUtil::Stat64ToStat64i32(struct _stat64i32 *result, struct __stat64 *stat)
 {
   result->st_dev = stat->st_dev;
@@ -868,7 +850,7 @@ void CUtil::Stat64ToStat64i32(struct _stat64i32 *result, struct __stat64 *stat)
   result->st_uid = stat->st_uid;
   result->st_gid = stat->st_gid;
   result->st_rdev = stat->st_rdev;
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   if (stat->st_size <= LONG_MAX)
     result->st_size = (_off_t)stat->st_size;
 #else
@@ -880,7 +862,7 @@ void CUtil::Stat64ToStat64i32(struct _stat64i32 *result, struct __stat64 *stat)
     result->st_size = 0;
     CLog::Log(LOGWARNING, "WARNING: File is larger than 32bit stat can handle, file size will be reported as 0 bytes");
   }
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   result->st_atime = stat->st_atime;
   result->st_mtime = stat->st_mtime;
   result->st_ctime = stat->st_ctime;
@@ -987,7 +969,7 @@ CStdString CUtil::ValidatePath(const CStdString &path, bool bFixDoubleSlashes /*
     return result;
 
   // check the path for incorrect slashes
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if (URIUtils::IsDOSPath(path))
   {
     result.Replace('/', '\\');
@@ -1028,7 +1010,7 @@ CStdString CUtil::ValidatePath(const CStdString &path, bool bFixDoubleSlashes /*
 
 bool CUtil::IsUsingTTFSubtitles()
 {
-  return URIUtils::GetExtension(CSettings::Get().GetString("subtitles.font")).Equals(".ttf");
+  return URIUtils::HasExtension(CSettings::Get().GetString("subtitles.font"), ".ttf");
 }
 
 #ifdef UNIT_TESTING
@@ -1591,7 +1573,7 @@ void CUtil::InitRandomSeed()
   srand(seed);
 }
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 bool CUtil::RunCommandLine(const CStdString& cmdLine, bool waitExit)
 {
   CStdStringArray args;
@@ -1814,7 +1796,7 @@ int CUtil::TranslateRomanNumeral(const char* roman_numeral)
 CStdString CUtil::ResolveExecutablePath()
 {
   CStdString strExecutablePath;
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
   wchar_t szAppPathW[MAX_PATH] = L"";
   ::GetModuleFileNameW(0, szAppPathW, sizeof(szAppPathW)/sizeof(szAppPathW[0]) - 1);
   CStdStringW strPathW = szAppPathW;
@@ -1825,7 +1807,7 @@ CStdString CUtil::ResolveExecutablePath()
 
   GetDarwinExecutablePath(given_path, &path_size);
   strExecutablePath = given_path;
-#elif defined(__FreeBSD__)                                                                                                                                                                   
+#elif defined(TARGET_FREEBSD)                                                                                                                                                                   
   char buf[PATH_MAX];
   size_t buflen;
   int mib[4];
@@ -2029,7 +2011,7 @@ void CUtil::ScanForExternalSubtitles(const CStdString& strMovie, std::vector<CSt
             for (int i = 0; sub_exts[i]; i++)
             {
               //Cache subtitle with same name as movie
-              if (URIUtils::GetExtension(strItem).Equals(sub_exts[i]))
+              if (URIUtils::HasExtension(strItem, sub_exts[i]))
               {
                 vecSubtitles.push_back( items[j]->GetPath() ); 
                 CLog::Log(LOGINFO, "%s: found subtitle file %s\n", __FUNCTION__, items[j]->GetPath().c_str() );
@@ -2053,7 +2035,7 @@ void CUtil::ScanForExternalSubtitles(const CStdString& strMovie, std::vector<CSt
   iSize = vecSubtitles.size();
   for (int i = 0; i < iSize; i++)
   {
-    if (URIUtils::GetExtension(vecSubtitles[i]).Equals(".smi"))
+    if (URIUtils::HasExtension(vecSubtitles[i], ".smi"))
     {
       //Cache multi-language sami subtitle
       CDVDSubtitleStream* pStream = new CDVDSubtitleStream();
@@ -2086,7 +2068,7 @@ int CUtil::ScanArchiveForSubtitles( const CStdString& strArchivePath, const CStd
   CFileItemList ItemList;
  
   // zip only gets the root dir
-  if (URIUtils::GetExtension(strArchivePath).Equals(".zip"))
+  if (URIUtils::HasExtension(strArchivePath, ".zip"))
   {
    CStdString strZipPath;
    URIUtils::CreateArchivePath(strZipPath,"zip",strArchivePath,"");
@@ -2115,7 +2097,7 @@ int CUtil::ScanArchiveForSubtitles( const CStdString& strArchivePath, const CStd
    if (URIUtils::IsRAR(strPathInRar) || URIUtils::IsZIP(strPathInRar))
    {
     CStdString strRarInRar;
-    if (URIUtils::GetExtension(strPathInRar).Equals(".rar"))
+    if (strExt == ".rar")
       URIUtils::CreateArchivePath(strRarInRar, "rar", strArchivePath, strPathInRar);
     else
       URIUtils::CreateArchivePath(strRarInRar, "zip", strArchivePath, strPathInRar);
@@ -2134,7 +2116,7 @@ int CUtil::ScanArchiveForSubtitles( const CStdString& strArchivePath, const CStd
      if (strExt.CompareNoCase(sub_exts[iPos]) == 0)
      {
       CStdString strSourceUrl;
-      if (URIUtils::GetExtension(strArchivePath).Equals(".rar"))
+      if (URIUtils::HasExtension(strArchivePath, ".rar"))
        URIUtils::CreateArchivePath(strSourceUrl, "rar", strArchivePath, strPathInRar);
       else
        strSourceUrl = strPathInRar;
@@ -2155,7 +2137,7 @@ int CUtil::ScanArchiveForSubtitles( const CStdString& strArchivePath, const CStd
  */
 bool CUtil::FindVobSubPair( const std::vector<CStdString>& vecSubtitles, const CStdString& strIdxPath, CStdString& strSubPath )
 {
-  if (URIUtils::GetExtension(strIdxPath) == ".idx")
+  if (URIUtils::HasExtension(strIdxPath, ".idx"))
   {
     CStdString strIdxFile;
     CStdString strIdxDirectory;
@@ -2167,7 +2149,7 @@ bool CUtil::FindVobSubPair( const std::vector<CStdString>& vecSubtitles, const C
       URIUtils::Split(vecSubtitles[j], strSubDirectory, strSubFile);
       if (URIUtils::IsInArchive(vecSubtitles[j]))
         CURL::Decode(strSubDirectory);
-      if (URIUtils::GetExtension(strSubFile) == ".sub" &&
+      if (URIUtils::HasExtension(strSubFile, ".sub") &&
           (URIUtils::ReplaceExtension(strIdxFile,"").Equals(URIUtils::ReplaceExtension(strSubFile,"")) ||
            strSubDirectory.Mid(6, strSubDirectory.length()-11).Equals(URIUtils::ReplaceExtension(strIdxPath,""))))
       {
@@ -2183,7 +2165,7 @@ bool CUtil::FindVobSubPair( const std::vector<CStdString>& vecSubtitles, const C
  */
 bool CUtil::IsVobSub( const std::vector<CStdString>& vecSubtitles, const CStdString& strSubPath )
 {
-  if (URIUtils::GetExtension(strSubPath) == ".sub")
+  if (URIUtils::HasExtension(strSubPath, ".sub"))
   {
     CStdString strSubFile;
     CStdString strSubDirectory;
@@ -2195,7 +2177,7 @@ bool CUtil::IsVobSub( const std::vector<CStdString>& vecSubtitles, const CStdStr
       CStdString strIdxFile;
       CStdString strIdxDirectory;
       URIUtils::Split(vecSubtitles[j], strIdxDirectory, strIdxFile);
-      if (URIUtils::GetExtension(strIdxFile) == ".idx" &&
+      if (URIUtils::HasExtension(strIdxFile, ".idx") &&
           (URIUtils::ReplaceExtension(strIdxFile,"").Equals(URIUtils::ReplaceExtension(strSubFile,"")) ||
            strSubDirectory.Mid(6, strSubDirectory.length()-11).Equals(URIUtils::ReplaceExtension(vecSubtitles[j],""))))
         return true;
@@ -2206,7 +2188,7 @@ bool CUtil::IsVobSub( const std::vector<CStdString>& vecSubtitles, const CStdStr
 
 bool CUtil::CanBindPrivileged()
 {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 
   if (geteuid() == 0)
     return true; //root user can always bind to privileged ports
@@ -2233,17 +2215,17 @@ bool CUtil::CanBindPrivileged()
 
 #endif //HAVE_LIBCAP
 
-#else //_LINUX
+#else //TARGET_POSIX
 
   return true;
 
-#endif //_LINUX
+#endif //TARGET_POSIX
 }
 
 bool CUtil::ValidatePort(int port)
 {
   // check that it's a valid port
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   if (!CUtil::CanBindPrivileged() && (port < 1024 || port > 65535))
     return false;
   else
index 6a902ca..09ed7ee 100644 (file)
@@ -96,12 +96,12 @@ public:
   static void Stat64ToStatI64(struct _stati64 *result, struct __stat64 *stat);
   static void StatI64ToStat64(struct __stat64 *result, struct _stati64 *stat);
   static void Stat64ToStat(struct stat *result, struct __stat64 *stat);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   static void Stat64ToStat64i32(struct _stat64i32 *result, struct __stat64 *stat);
 #endif
   static bool CreateDirectoryEx(const CStdString& strPath);
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   static CStdString MakeLegalFileName(const CStdString &strFile, int LegalType=LEGAL_WIN32_COMPAT);
   static CStdString MakeLegalPath(const CStdString &strPath, int LegalType=LEGAL_WIN32_COMPAT);
 #else
@@ -175,7 +175,7 @@ public:
   // return -1 on error, valid range is 1-3999
   static int TranslateRomanNumeral(const char* roman_numeral);
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   // this will run the command using sudo in a new process.
   // the user that runs xbmc should be allowed to issue the given sudo command.
   // in order to allow a user to run sudo without supplying the password you'll need to edit sudoers
index cb12900..4cee8c6 100644 (file)
@@ -27,7 +27,7 @@
 #if defined(TARGET_DARWIN)
 #include "../osx/OSXGNUReplacements.h"
 #endif
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
 #include "freebsd/FreeBSDGNUReplacements.h"
 #endif
 #include "utils/log.h"
@@ -251,6 +251,7 @@ CAddon::CAddon(const cp_extension_t *ext)
   , m_parent(AddonPtr())
 {
   BuildLibName(ext);
+  Props().libname = m_strLibName;
   BuildProfilePath();
   m_userSettingsPath = URIUtils::AddFileToFolder(Profile(), "settings.xml");
   m_enabled = true;
@@ -391,6 +392,7 @@ void CAddon::BuildLibName(const cp_extension_t *extension)
       case ADDON_PVRDLL:
       case ADDON_PLUGIN:
       case ADDON_SERVICE:
+      case ADDON_REPOSITORY:
         {
           CStdString temp = CAddonMgr::Get().GetExtValue(extension->configuration, "@library");
           m_strLibName = temp;
index 7e8dedc..f291cc2 100644 (file)
@@ -94,11 +94,11 @@ CAddonDll<TheDll, TheStruct, TheProps>::CAddonDll(const cp_extension_t *ext)
   {
 #if defined(TARGET_ANDROID)
   m_strLibName = CAddonMgr::Get().GetExtValue(ext->configuration, "@library_android");
-#elif defined(_LINUX) && !defined(TARGET_DARWIN)
+#elif defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
     m_strLibName = CAddonMgr::Get().GetExtValue(ext->configuration, "@library_linux");
-#elif defined(_WIN32) && defined(HAS_SDL_OPENGL)
+#elif defined(TARGET_WINDOWS) && defined(HAS_SDL_OPENGL)
     m_strLibName = CAddonMgr::Get().GetExtValue(ext->configuration, "@library_wingl");
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
     m_strLibName = CAddonMgr::Get().GetExtValue(ext->configuration, "@library_windx");
 #elif defined(TARGET_DARWIN)
     m_strLibName = CAddonMgr::Get().GetExtValue(ext->configuration, "@library_osx");
index 2338b1d..eb5f59b 100644 (file)
@@ -29,7 +29,7 @@
 #include "settings/AdvancedSettings.h"
 #include "settings/Settings.h"
 #include "ApplicationMessenger.h"
-#include "Favourites.h"
+#include "filesystem/FavouritesDirectory.h"
 #include "utils/JobManager.h"
 #include "dialogs/GUIDialogYesNo.h"
 #include "addons/AddonManager.h"
@@ -474,64 +474,81 @@ CAddonInstallJob::CAddonInstallJob(const AddonPtr &addon, const CStdString &hash
 {
 }
 
-bool CAddonInstallJob::DoWork()
+AddonPtr CAddonInstallJob::GetRepoForAddon(const AddonPtr& addon)
 {
-  // Addons are installed by downloading the .zip package on the server to the local
-  // packages folder, then extracting from the local .zip package into the addons folder
-  // Both these functions are achieved by "copying" using the vfs.
+  CAddonDatabase database;
+  database.Open();
+  CStdString repo;
+  database.GetRepoForAddon(addon->ID(), repo);
+  AddonPtr repoPtr;
+  CAddonMgr::Get().GetAddon(repo, repoPtr);
 
-  CStdString dest="special://home/addons/packages/";
-  CStdString package = URIUtils::AddFileToFolder("special://home/addons/packages/",
-                                              URIUtils::GetFileName(m_addon->Path()));
+  return repoPtr;
+}
 
+bool CAddonInstallJob::DoWork()
+{
+  AddonPtr repoPtr = GetRepoForAddon(m_addon);
   CStdString installFrom;
-  if (URIUtils::HasSlashAtEnd(m_addon->Path()))
-  { // passed in a folder - all we need do is copy it across
-    installFrom = m_addon->Path();
-  }
-  else
+  if (!repoPtr || repoPtr->Props().libname.IsEmpty())
   {
-    // zip passed in - download + extract
-    CStdString path(m_addon->Path());
-    if (!m_referer.IsEmpty() && URIUtils::IsInternetStream(path))
-    {
-      CURL url(path);
-      url.SetProtocolOptions(m_referer);
-      path = url.Get();
+    // Addons are installed by downloading the .zip package on the server to the local
+    // packages folder, then extracting from the local .zip package into the addons folder
+    // Both these functions are achieved by "copying" using the vfs.
+
+    CStdString dest="special://home/addons/packages/";
+    CStdString package = URIUtils::AddFileToFolder("special://home/addons/packages/",
+                                                URIUtils::GetFileName(m_addon->Path()));
+
+    if (URIUtils::HasSlashAtEnd(m_addon->Path()))
+    { // passed in a folder - all we need do is copy it across
+      installFrom = m_addon->Path();
     }
-    if (!CFile::Exists(package) && !DownloadPackage(path, dest))
+    else
     {
-      CFile::Delete(package);
-      return false;
-    }
+      // zip passed in - download + extract
+      CStdString path(m_addon->Path());
+      if (!m_referer.IsEmpty() && URIUtils::IsInternetStream(path))
+      {
+        CURL url(path);
+        url.SetProtocolOptions(m_referer);
+        path = url.Get();
+      }
+      if (!CFile::Exists(package) && !DownloadPackage(path, dest))
+      {
+        CFile::Delete(package);
+        return false;
+      }
 
-    // at this point we have the package - check that it is valid
-    if (!CFile::Exists(package) || !CheckHash(package))
-    {
-      CFile::Delete(package);
-      return false;
-    }
+      // at this point we have the package - check that it is valid
+      if (!CFile::Exists(package) || !CheckHash(package))
+      {
+        CFile::Delete(package);
+        return false;
+      }
 
-    // check the archive as well - should have just a single folder in the root
-    CStdString archive;
-    URIUtils::CreateArchivePath(archive,"zip",package,"");
+      // check the archive as well - should have just a single folder in the root
+      CStdString archive;
+      URIUtils::CreateArchivePath(archive,"zip",package,"");
 
-    CFileItemList archivedFiles;
-    CDirectory::GetDirectory(archive, archivedFiles);
+      CFileItemList archivedFiles;
+      CDirectory::GetDirectory(archive, archivedFiles);
 
-    if (archivedFiles.Size() != 1 || !archivedFiles[0]->m_bIsFolder)
-    { // invalid package
-      CFile::Delete(package);
-      return false;
+      if (archivedFiles.Size() != 1 || !archivedFiles[0]->m_bIsFolder)
+      { // invalid package
+        CFile::Delete(package);
+        return false;
+      }
+      installFrom = archivedFiles[0]->GetPath();
     }
-    installFrom = archivedFiles[0]->GetPath();
+    repoPtr.reset();
   }
 
   // run any pre-install functions
   bool reloadAddon = OnPreInstall();
 
   // perform install
-  if (!Install(installFrom))
+  if (!Install(installFrom, repoPtr))
     return false; // something went wrong
 
   // run any post-install guff
@@ -592,60 +609,74 @@ bool CAddonInstallJob::DeleteAddon(const CStdString &addonFolder)
   return job.DoWork();
 }
 
-bool CAddonInstallJob::Install(const CStdString &installFrom)
+bool CAddonInstallJob::Install(const CStdString &installFrom, const AddonPtr& repo)
 {
-  CStdString addonFolder(installFrom);
-  URIUtils::RemoveSlashAtEnd(addonFolder);
-  addonFolder = URIUtils::AddFileToFolder("special://home/addons/",
-                                       URIUtils::GetFileName(addonFolder));
-
-  CFileItemList install;
-  install.Add(CFileItemPtr(new CFileItem(installFrom, true)));
-  install[0]->Select(true);
-  CFileOperationJob job(CFileOperationJob::ActionReplace, install, "special://home/addons/");
-
-  AddonPtr addon;
-  if (!job.DoWork() || !CAddonMgr::Get().LoadAddonDescription(addonFolder, addon))
-  { // failed extraction or failed to load addon description
-    CStdString addonID = URIUtils::GetFileName(addonFolder);
-    ReportInstallError(addonID, addonID);
-    CLog::Log(LOGERROR,"Could not read addon description of %s", addonID.c_str());
-    DeleteAddon(addonFolder);
-    return false;
+  if (repo)
+  {
+    CFileItemList dummy;
+    CStdString s;
+    s.Format("plugin://%s/?action=install"
+             "&package=%s&version=%s", repo->ID().c_str(),
+                                       m_addon->ID().c_str(),
+                                       m_addon->Version().c_str());
+    if (!CDirectory::GetDirectory(s, dummy))
+      return false;
   }
-
-  // resolve dependencies
-  CAddonMgr::Get().FindAddons(); // needed as GetDeps() grabs directly from c-pluff via the addon manager
-  ADDONDEPS deps = addon->GetDeps();
-  CStdString referer;
-  referer.Format("Referer=%s-%s.zip",addon->ID().c_str(),addon->Version().c_str());
-  for (ADDONDEPS::iterator it  = deps.begin(); it != deps.end(); ++it)
+  else
   {
-    if (it->first.Equals("xbmc.metadata"))
-      continue;
+    CStdString addonFolder(installFrom);
+    URIUtils::RemoveSlashAtEnd(addonFolder);
+    addonFolder = URIUtils::AddFileToFolder("special://home/addons/",
+                                         URIUtils::GetFileName(addonFolder));
 
-    const CStdString &addonID = it->first;
-    const AddonVersion &version = it->second.first;
-    bool optional = it->second.second;
-    AddonPtr dependency;
-    bool haveAddon = CAddonMgr::Get().GetAddon(addonID, dependency);
-    if ((haveAddon && !dependency->MeetsVersion(version)) || (!haveAddon && !optional))
-    { // we have it but our version isn't good enough, or we don't have it and we need it
-      bool force=(dependency != NULL);
-      // dependency is already queued up for install - ::Install will fail
-      // instead we wait until the Job has finished. note that we
-      // recall install on purpose in case prior installation failed
-      if (CAddonInstaller::Get().HasJob(addonID))
-      {
-        while (CAddonInstaller::Get().HasJob(addonID))
-          Sleep(50);
-        force = false;
-      }
-      // don't have the addon or the addon isn't new enough - grab it (no new job for these)
-      if (!CAddonInstaller::Get().Install(addonID, force, referer, false))
-      {
-        DeleteAddon(addonFolder);
-        return false;
+    CFileItemList install;
+    install.Add(CFileItemPtr(new CFileItem(installFrom, true)));
+    install[0]->Select(true);
+    CFileOperationJob job(CFileOperationJob::ActionReplace, install, "special://home/addons/");
+
+    AddonPtr addon;
+    if (!job.DoWork() || !CAddonMgr::Get().LoadAddonDescription(addonFolder, addon))
+    { // failed extraction or failed to load addon description
+      CStdString addonID = URIUtils::GetFileName(addonFolder);
+      ReportInstallError(addonID, addonID);
+      CLog::Log(LOGERROR,"Could not read addon description of %s", addonID.c_str());
+      DeleteAddon(addonFolder);
+      return false;
+    }
+
+    // resolve dependencies
+    CAddonMgr::Get().FindAddons(); // needed as GetDeps() grabs directly from c-pluff via the addon manager
+    ADDONDEPS deps = addon->GetDeps();
+    CStdString referer;
+    referer.Format("Referer=%s-%s.zip",addon->ID().c_str(),addon->Version().c_str());
+    for (ADDONDEPS::iterator it  = deps.begin(); it != deps.end(); ++it)
+    {
+      if (it->first.Equals("xbmc.metadata"))
+        continue;
+
+      const CStdString &addonID = it->first;
+      const AddonVersion &version = it->second.first;
+      bool optional = it->second.second;
+      AddonPtr dependency;
+      bool haveAddon = CAddonMgr::Get().GetAddon(addonID, dependency);
+      if ((haveAddon && !dependency->MeetsVersion(version)) || (!haveAddon && !optional))
+      { // we have it but our version isn't good enough, or we don't have it and we need it
+        bool force=(dependency != NULL);
+        // dependency is already queued up for install - ::Install will fail
+        // instead we wait until the Job has finished. note that we
+        // recall install on purpose in case prior installation failed
+        if (CAddonInstaller::Get().HasJob(addonID))
+        {
+          while (CAddonInstaller::Get().HasJob(addonID))
+            Sleep(50);
+          force = false;
+        }
+        // don't have the addon or the addon isn't new enough - grab it (no new job for these)
+        if (!CAddonInstaller::Get().Install(addonID, force, referer, false))
+        {
+          DeleteAddon(addonFolder);
+          return false;
+        }
       }
     }
   }
@@ -771,8 +802,23 @@ bool CAddonUnInstallJob::DoWork()
     if (service)
       service->Stop();
   }
-  if (!CAddonInstallJob::DeleteAddon(m_addon->Path()))
-    return false;
+
+  AddonPtr repoPtr = CAddonInstallJob::GetRepoForAddon(m_addon);
+  RepositoryPtr therepo = boost::dynamic_pointer_cast<CRepository>(repoPtr);
+  if (therepo && !therepo->Props().libname.IsEmpty())
+  {
+    CFileItemList dummy;
+    CStdString s;
+    s.Format("plugin://%s/?action=uninstall"
+             "&package=%s", therepo->ID().c_str(), m_addon->ID().c_str());
+    if (!CDirectory::GetDirectory(s, dummy))
+      return false;
+  }
+  else
+  {
+    if (!CAddonInstallJob::DeleteAddon(m_addon->Path()))
+      return false;
+  }
 
   OnPostUnInstall();
 
@@ -790,7 +836,7 @@ void CAddonUnInstallJob::OnPostUnInstall()
 
   bool bSave(false);
   CFileItemList items;
-  CFavourites::Load(items);
+  XFILE::CFavouritesDirectory::Load(items);
   for (int i=0; i < items.Size(); ++i)
   {
     if (items[i]->GetPath().Find(m_addon->ID()) > -1)
@@ -801,7 +847,7 @@ void CAddonUnInstallJob::OnPostUnInstall()
   }
 
   if (bSave)
-    CFavourites::Save(items);
+    CFavouritesDirectory::Save(items);
 
   if (m_addon->Type() == ADDON_PVRDLL)
   {
index 5df69fb..bca2103 100644 (file)
@@ -158,10 +158,16 @@ public:
    \param addonFolder - the folder to delete
    */
   static bool DeleteAddon(const CStdString &addonFolder);
+
+  /*! \brief Find which repository hosts an add-on
+   *  \param addon The add-on to find the repository for
+   *  \return The hosting repository
+   */
+  static ADDON::AddonPtr GetRepoForAddon(const ADDON::AddonPtr& addon);
 private:
   bool OnPreInstall();
   void OnPostInstall(bool reloadAddon);
-  bool Install(const CStdString &installFrom);
+  bool Install(const CStdString &installFrom, const ADDON::AddonPtr& repo=ADDON::AddonPtr());
   bool DownloadPackage(const CStdString &path, const CStdString &dest);
 
   /*! \brief Queue a notification for addon installation/update failure
index e40fe87..00f5289 100644 (file)
@@ -125,19 +125,19 @@ AddonPtr CAddonMgr::Factory(const cp_extension_t *props)
         if (type == ADDON_SCREENSAVER)
         { // Python screensaver
           CStdString library = CAddonMgr::Get().GetExtValue(props->configuration, "@library");
-          if (URIUtils::GetExtension(library).Equals(".py", false))
+          if (URIUtils::HasExtension(library, ".py"))
             return AddonPtr(new CScreenSaver(props));
         }
 #if defined(TARGET_ANDROID)                                                                                                                                                      
           if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_android")) && value.empty())                                                                
             break;                                                                                                                                                                 
- #elif defined(_LINUX) && !defined(TARGET_DARWIN)
+#elif defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
         if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_linux")) && value.empty())
           break;
-#elif defined(_WIN32) && defined(HAS_SDL_OPENGL)
+#elif defined(TARGET_WINDOWS) && defined(HAS_SDL_OPENGL)
         if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_wingl")) && value.empty())
           break;
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
         if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_windx")) && value.empty())
           break;
 #elif defined(TARGET_DARWIN)
@@ -651,11 +651,11 @@ bool CAddonMgr::PlatformSupportsAddon(const cp_plugin_info_t *plugin) const
         return true;
 #if defined(TARGET_ANDROID)
       if (platforms[i] == "android")
-#elif defined(_LINUX) && !defined(TARGET_DARWIN)
+#elif defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
       if (platforms[i] == "linux")
-#elif defined(_WIN32) && defined(HAS_SDL_OPENGL)
+#elif defined(TARGET_WINDOWS) && defined(HAS_SDL_OPENGL)
       if (platforms[i] == "wingl")
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
       if (platforms[i] == "windx")
 #elif defined(TARGET_DARWIN_OSX)
 // Remove this after Frodo and add an architecture filter
index 580fa91..ec762a6 100644 (file)
@@ -33,6 +33,7 @@
 #include "TextureDatabase.h"
 #include "URL.h"
 #include "pvr/PVRManager.h"
+#include "filesystem/PluginDirectory.h"
 
 using namespace XFILE;
 using namespace ADDON;
@@ -274,7 +275,19 @@ VECADDONS CRepositoryUpdateJob::GrabAddons(RepositoryPtr& repo)
       CLog::Log(LOGERROR,"Repository %s returned no add-ons, listing may have failed",repo->Name().c_str());
       reposum = checksum; // don't update the checksum
     }
-    database.AddRepository(repo->ID(),addons,reposum);
+    else
+    {
+      bool add=true;
+      if (!repo->Props().libname.empty())
+      {
+        CFileItemList dummy;
+        CStdString s;
+        s.Format("plugin://%s/?action=update", repo->ID());
+        add = CDirectory::GetDirectory(s, dummy);
+      }
+      if (add)
+        database.AddRepository(repo->ID(),addons,reposum);
+    }
   }
   else
     database.GetRepository(repo->ID(),addons);
index 2d44e99..5f143bc 100644 (file)
@@ -42,7 +42,7 @@ namespace ADDON
 bool CScreenSaver::CreateScreenSaver()
 {
 #ifdef HAS_PYTHON
-  if (URIUtils::GetExtension(LibPath()).Equals(".py", false))
+  if (URIUtils::HasExtension(LibPath(), ".py"))
   {
     // Don't allow a previously-scheduled alarm to kill our new screensaver
     g_alarmClock.Stop(PYTHON_ALARM, true);
@@ -99,7 +99,7 @@ void CScreenSaver::GetInfo(SCR_INFO *info)
 void CScreenSaver::Destroy()
 {
 #ifdef HAS_PYTHON
-  if (URIUtils::GetExtension(LibPath()).Equals(".py", false))
+  if (URIUtils::HasExtension(LibPath(), ".py"))
   {
     g_alarmClock.Start(PYTHON_ALARM, PYTHON_SCRIPT_TIMEOUT, "StopScript(" + LibPath() + ")", true, false);
     return;
index 81b0a3a..bc8bdee 100644 (file)
@@ -309,7 +309,7 @@ void CSkinInfo::SettingOptionsSkinColorsFiller(const CSetting *setting, std::vec
 
   CStdString settingValue = ((const CSettingString*)setting)->GetValue();
   // Remove the .xml extension from the Themes
-  if (URIUtils::GetExtension(settingValue) == ".xml")
+  if (URIUtils::HasExtension(settingValue, ".xml"))
     URIUtils::RemoveExtension(settingValue);
   
   // Set the choosen theme
index ee672a9..128a137 100644 (file)
@@ -33,7 +33,7 @@
 #include "cores/IPlayer.h"
 #include "cores/AudioEngine/AEFactory.h"
 #include "cores/AudioEngine/Utils/AEConvert.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include <dlfcn.h>
 #include "filesystem/SpecialProtocol.h"
 #endif
index 9402623..12d3d91 100644 (file)
@@ -21,7 +21,7 @@
  *
  */
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include <windows.h>
 #else
 #ifndef __cdecl
index a40022b..5ef7b95 100644 (file)
@@ -108,10 +108,11 @@ extern "C"
    * Call one of the menu hooks (if supported).
    * Supported PVR_MENUHOOK instances have to be added in ADDON_Create(), by calling AddMenuHook() on the callback.
    * @param menuhook The hook to call.
+   * @param item The selected item for which the hook was called.
    * @return PVR_ERROR_NO_ERROR if the hook was called successfully.
    * @remarks Optional. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function.
    */
-  PVR_ERROR CallMenuHook(const PVR_MENUHOOK& menuhook);
+  PVR_ERROR CallMenuHook(const PVR_MENUHOOK& menuhook, const PVR_MENUHOOK_DATA &item);
   //@}
 
   /*! @name PVR EPG methods
index 17182df..1fb0c6c 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef __PVRCLIENT_TYPES_H__
 #define __PVRCLIENT_TYPES_H__
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include <windows.h>
 #else
 #ifndef __cdecl
@@ -74,10 +74,10 @@ struct DemuxPacket;
 #define PVR_STREAM_MAX_STREAMS 20
 
 /* current PVR API version */
-#define XBMC_PVR_API_VERSION "1.7.0"
+#define XBMC_PVR_API_VERSION "1.8.0"
 
 /* min. PVR API version */
-#define XBMC_PVR_MIN_API_VERSION "1.7.0"
+#define XBMC_PVR_MIN_API_VERSION "1.8.0"
 
 #ifdef __cplusplus
 extern "C" {
@@ -121,6 +121,7 @@ extern "C" {
    */
   typedef enum
   {
+    PVR_MENUHOOK_UNKNOWN         =-1, /*!< @brief unknown menu hook */
     PVR_MENUHOOK_ALL             = 0, /*!< @brief all categories */
     PVR_MENUHOOK_CHANNEL         = 1, /*!< @brief for channels */
     PVR_MENUHOOK_TIMER           = 2, /*!< @brief for timers */
@@ -310,6 +311,20 @@ extern "C" {
   } ATTRIBUTE_PACKED PVR_EDL_ENTRY;
 
   /*!
+   * @brief PVR menu hook data
+   */
+  typedef struct PVR_MENUHOOK_DATA
+  {
+    PVR_MENUHOOK_CAT cat;
+    union data {
+      int iEpgUid;
+      PVR_CHANNEL channel;
+      PVR_TIMER timer;
+      PVR_RECORDING recording;
+    } data;
+  } ATTRIBUTE_PACKED PVR_MENUHOOK_DATA;
+
+  /*!
    * @brief Structure to transfer the methods from xbmc_pvr_dll.h to XBMC
    */
   typedef struct PVRClient
@@ -324,7 +339,7 @@ extern "C" {
     const char*  (__cdecl* GetBackendVersion)(void);
     const char*  (__cdecl* GetConnectionString)(void);
     PVR_ERROR    (__cdecl* GetDriveSpace)(long long*, long long*);
-    PVR_ERROR    (__cdecl* MenuHook)(const PVR_MENUHOOK&);
+    PVR_ERROR    (__cdecl* MenuHook)(const PVR_MENUHOOK&, const PVR_MENUHOOK_DATA&);
     PVR_ERROR    (__cdecl* GetEpg)(ADDON_HANDLE, const PVR_CHANNEL&, time_t, time_t);
     int          (__cdecl* GetChannelGroupsAmount)(void);
     PVR_ERROR    (__cdecl* GetChannelGroups)(ADDON_HANDLE, bool);
index a0b261b..4e3d0bf 100644 (file)
@@ -44,6 +44,8 @@
 #include "guilib/GUIWindowManager.h"
 #include "utils/log.h"
 #include "ApplicationMessenger.h"
+#include "utils/StringUtils.h"
+#include "AppParamParser.h"
 #include <android/bitmap.h>
 #include "android/jni/JNIThreading.h"
 #include "android/jni/BroadcastReceiver.h"
 #include "android/jni/BitmapDrawable.h"
 #include "android/jni/Bitmap.h"
 #include "android/jni/CharSequence.h"
+#include "android/jni/URI.h"
+#include "android/jni/Cursor.h"
+#include "android/jni/ContentResolver.h"
+#include "android/jni/MediaStore.h"
 
 #define GIGABYTES       1073741824
 
@@ -81,7 +87,9 @@ ANativeWindow* CXBMCApp::m_window = NULL;
 int CXBMCApp::m_batteryLevel = 0;
 
 CXBMCApp::CXBMCApp(ANativeActivity* nativeActivity)
-  : CJNIContext(nativeActivity), m_wakeLock(NULL)
+  : CJNIContext(nativeActivity)
+  , CJNIBroadcastReceiver("org/xbmc/xbmc/XBMCBroadcastReceiver")
+  , m_wakeLock(NULL)
 {
   m_activity = nativeActivity;
   m_firstrun = true;
@@ -116,11 +124,15 @@ void CXBMCApp::onStart()
 void CXBMCApp::onResume()
 {
   android_printf("%s: ", __PRETTY_FUNCTION__);
+  CJNIIntentFilter batteryFilter;
+  batteryFilter.addAction("android.intent.action.BATTERY_CHANGED");
+  registerReceiver(*this, batteryFilter);
 }
 
 void CXBMCApp::onPause()
 {
   android_printf("%s: ", __PRETTY_FUNCTION__);
+  unregisterReceiver(*this);
 }
 
 void CXBMCApp::onStop()
@@ -236,9 +248,21 @@ void CXBMCApp::run()
   CJNIIntent startIntent = getIntent();
   android_printf("XBMC Started with action: %s\n",startIntent.getAction().c_str());
 
-  CJNIIntentFilter batteryFilter;
-  batteryFilter.addAction("android.intent.action.BATTERY_CHANGED");
-  registerReceiver(*this, batteryFilter);
+  std::string filenameToPlay = GetFilenameFromIntent(startIntent);
+  if (!filenameToPlay.empty())
+  {
+    int argc = 2;
+    const char** argv = (const char**) malloc(argc*sizeof(char*));
+
+    std::string exe_name("XBMC");
+    argv[0] = exe_name.c_str();
+    argv[1] = filenameToPlay.c_str();
+
+    CAppParamParser appParamParser;
+    appParamParser.Parse((const char **)argv, argc);
+
+    free(argv);
+  }
 
   android_printf(" => waiting for a window");
   // Hack!
@@ -344,7 +368,7 @@ bool CXBMCApp::GetIconSize(const string &packageName, int *width, int *height)
   AndroidBitmapInfo info;
   CJNIBitmapDrawable drawable = (CJNIBitmapDrawable)GetPackageManager().getApplicationIcon(packageName);
   CJNIBitmap icon(drawable.getBitmap());
-  AndroidBitmap_getInfo(env, icon.get(), &info);
+  AndroidBitmap_getInfo(env, icon.get_raw(), &info);
   *width = info.width;
   *height = info.height;
   return true;
@@ -356,11 +380,11 @@ bool CXBMCApp::GetIcon(const string &packageName, void* buffer, unsigned int buf
   JNIEnv* env = xbmc_jnienv();
   CJNIBitmapDrawable drawable = (CJNIBitmapDrawable)GetPackageManager().getApplicationIcon(packageName);
   CJNIBitmap bitmap(drawable.getBitmap());
-  AndroidBitmap_lockPixels(env, bitmap.get(), &bitmapBuf);
+  AndroidBitmap_lockPixels(env, bitmap.get_raw(), &bitmapBuf);
   if (bitmapBuf)
   {
     memcpy(buffer, bitmapBuf, bufSize);
-    AndroidBitmap_unlockPixels(env, bitmap.get());
+    AndroidBitmap_unlockPixels(env, bitmap.get_raw());
     return true;
   }
   return false;
@@ -511,6 +535,16 @@ void CXBMCApp::onReceive(CJNIIntent intent)
     m_batteryLevel = intent.getIntExtra("level",-1);
 }
 
+void CXBMCApp::onNewIntent(CJNIIntent intent)
+{
+  std::string action = intent.getAction();
+  if (action == "android.intent.action.VIEW")
+  {
+    std::string playFile = GetFilenameFromIntent(intent);
+    CApplicationMessenger::Get().MediaPlay(playFile);
+  }
+}
+
 void CXBMCApp::SetupEnv()
 {
   setenv("XBMC_ANDROID_SYSTEM_LIBS", CJNISystem::getProperty("java.library.path").c_str(), 0);
@@ -536,3 +570,32 @@ void CXBMCApp::SetupEnv()
   else
     setenv("HOME", getenv("XBMC_TEMP"), 0);
 }
+
+std::string CXBMCApp::GetFilenameFromIntent(const CJNIIntent &intent)
+{
+    std::string ret;
+    if (!intent)
+      return ret;
+    CJNIURI data = intent.getData();
+    if (!data)
+      return ret;
+    std::string scheme = data.getScheme();
+    StringUtils::ToLower(scheme);
+    if (scheme == "content")
+    {
+      std::vector<std::string> filePathColumn;
+      filePathColumn.push_back(CJNIMediaStoreMediaColumns::DATA);
+      CJNICursor cursor = getContentResolver().query(data, filePathColumn, std::string(), std::vector<std::string>(), std::string());
+      if(cursor.moveToFirst())
+      {
+        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
+        ret = cursor.getString(columnIndex);
+      }
+      cursor.close();
+    }
+    else if(scheme == "file")
+      ret = data.getPath();
+    else
+      ret = data.toString();
+  return ret;
+}
index 5c6bed7..fd204fa 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "xbmc.h"
 #include "android/jni/Context.h"
+#include "android/jni/BroadcastReceiver.h"
 
 // forward delares
 class CJNIWakeLock;
@@ -51,12 +52,13 @@ struct androidPackage
 };
 
 
-class CXBMCApp : public IActivityHandler, public CJNIContext
+class CXBMCApp : public IActivityHandler, public CJNIContext, public CJNIBroadcastReceiver
 {
 public:
   CXBMCApp(ANativeActivity *nativeActivity);
   virtual ~CXBMCApp();
   virtual void onReceive(CJNIIntent intent);
+  virtual void onNewIntent(CJNIIntent intent);
 
   bool isValid() { return m_activity != NULL; }
 
@@ -108,6 +110,7 @@ protected:
 private:
   static bool HasLaunchIntent(const std::string &package);
   bool getWakeLock();
+  std::string GetFilenameFromIntent(const CJNIIntent &intent);
   void run();
   void stop();
   void SetupEnv();
index f22b733..763d207 100644 (file)
@@ -47,3 +47,26 @@ extern void android_main(struct android_app* state)
   }
   exit(0);
 }
+
+extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
+{
+  jint version = JNI_VERSION_1_6;
+  JNIEnv* env;
+  if (vm->GetEnv(reinterpret_cast<void**>(&env), version) != JNI_OK)
+    return -1;
+
+  jclass cMain = env->FindClass("org/xbmc/xbmc/XBMCBroadcastReceiver");
+  if(cMain)
+  {
+    JNINativeMethod mOnReceive =   { "_onReceive",     "(Landroid/content/Intent;)V", (void*)&CJNIBroadcastReceiver::_onReceive};
+    env->RegisterNatives(cMain, &mOnReceive, 1);
+  }
+
+  jclass cBroadcastReceiver = env->FindClass("org/xbmc/xbmc/Main");
+  if(cBroadcastReceiver)
+  {
+    JNINativeMethod mOnNewIntent = { "_onNewIntent",   "(Landroid/content/Intent;)V", (void*)&CJNIContext::_onNewIntent};
+    env->RegisterNatives(cBroadcastReceiver, &mOnNewIntent, 1);
+  }
+  return version;
+}
index bc7b88f..398d80c 100644 (file)
 using namespace jni;
 
 int CJNIAudioManager::STREAM_MUSIC(0);
-CJNIAudioManager::CJNIAudioManager(const jni::jhobject &object) : CJNIBase(object)
+
+void CJNIAudioManager::PopulateStaticFields()
 {
-  STREAM_MUSIC = (get_static_field<int>(m_object, "STREAM_MUSIC"));
+  jhclass clazz = find_class("android/media/AudioManager");
+  STREAM_MUSIC = (get_static_field<int>(clazz, "STREAM_MUSIC"));
 }
 
 int CJNIAudioManager::getStreamMaxVolume()
index ba2098e..e9f7408 100644 (file)
@@ -26,8 +26,10 @@ public:
   // Note removal of streamType param.
   int getStreamMaxVolume();
   void setStreamVolume(int index = 0, int flags = 0);
+
+  static void PopulateStaticFields();
   ~CJNIAudioManager(){};
-  CJNIAudioManager(const jni::jhobject &object);
+  CJNIAudioManager(const jni::jhobject &object) : CJNIBase(object){};
 
 private:
   CJNIAudioManager();
diff --git a/xbmc/android/jni/BaseColumns.cpp b/xbmc/android/jni/BaseColumns.cpp
new file mode 100644 (file)
index 0000000..c466b26
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *      Copyright (C) 2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "BaseColumns.h"
+#include "jutils/jutils-details.hpp"
+
+using namespace jni;
+
+std::string CJNIBaseColumns::_ID;
+std::string CJNIBaseColumns::_COUNT;
+
+void CJNIBaseColumns::PopulateStaticFields()
+{
+  jhclass clazz = find_class("android/provider/BaseColumns");
+  _ID = (jcast<std::string>(get_static_field<jhstring>(clazz, "_ID")));
+  _COUNT = (jcast<std::string>(get_static_field<jhstring>(clazz, "_COUNT")));
+}
diff --git a/xbmc/android/jni/BaseColumns.h b/xbmc/android/jni/BaseColumns.h
new file mode 100644 (file)
index 0000000..b60a434
--- /dev/null
@@ -0,0 +1,30 @@
+#pragma once
+/*
+ *      Copyright (C) 2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+#include <string>
+class CJNIBaseColumns
+{
+public:
+  static std::string _ID;
+  static std::string _COUNT;
+  static void PopulateStaticFields();
+private:
+  CJNIBaseColumns();
+};
index f872dd9..6ffecd3 100644 (file)
@@ -49,7 +49,7 @@ void CJNIBitSet::set(int index)
 
 void CJNIBitSet::set(int fromIndex, bool state)
 {
-  call_method<void>(m_object, "fromIndex", "(IZ)V", (jint)index, state);
+  call_method<void>(m_object, "fromIndex", "(IZ)V", fromIndex, state);
 }
 
 void CJNIBitSet::set(int fromIndex, int toIndex)
@@ -109,7 +109,7 @@ bool CJNIBitSet::isEmpty()
 
 bool CJNIBitSet::intersects(const CJNIBitSet &bs)
 {
-  return call_method<jboolean>(m_object, "intersects", "(Ljava/util/BitSet;)Z");
+  return call_method<jboolean>(m_object, "intersects", "(Ljava/util/BitSet;)Z", bs.get_raw());
 }
 
 int CJNIBitSet::cardinality()
@@ -119,22 +119,22 @@ int CJNIBitSet::cardinality()
 
 void CJNIBitSet::jand(const CJNIBitSet &bs)
 {
-  call_method<void>(m_object, "jand", "(Ljava/util/BitSet;)V");
+  call_method<void>(m_object, "jand", "(Ljava/util/BitSet;)V", bs.get_raw());
 }
 
 void CJNIBitSet::jor(const CJNIBitSet &bs)
 {
-  call_method<void>(m_object, "jor", "(Ljava/util/BitSet;)V");
+  call_method<void>(m_object, "jor", "(Ljava/util/BitSet;)V", bs.get_raw());
 }
 
 void CJNIBitSet::jxor(const CJNIBitSet &bs)
 {
-  call_method<void>(m_object, "jxor", "(Ljava/util/BitSet;)V");
+  call_method<void>(m_object, "jxor", "(Ljava/util/BitSet;)V", bs.get_raw());
 }
 
 void CJNIBitSet::jandNot(const CJNIBitSet &bs)
 {
-  call_method<void>(m_object, "jandNot", "(Ljava/util/BitSet;)V");
+  call_method<void>(m_object, "jandNot", "(Ljava/util/BitSet;)V", bs.get_raw());
 }
 
 int CJNIBitSet::hashCode()
index 356debf..fe505f9 100644 (file)
@@ -25,7 +25,7 @@ class CJNIBitmapDrawable : public CJNIDrawable
 public:
   CJNIBitmapDrawable();
   CJNIBitmapDrawable(const jni::jhobject &object) : CJNIDrawable(object){};
-  CJNIBitmapDrawable(const CJNIDrawable &drawable) : CJNIDrawable(drawable.get()){};
+  CJNIBitmapDrawable(const CJNIDrawable &drawable) : CJNIDrawable(drawable.get_raw()){};
   CJNIBitmap getBitmap();
   ~CJNIBitmapDrawable(){};
 };
index 902f156..d62bd75 100644 (file)
 #include "ClassLoader.h"
 #include "jutils/jutils-details.hpp"
 
-CJNIContext * CJNIBroadcastReceiver::jni_app_context=NULL;
-
 using namespace jni;
-CJNIBroadcastReceiver::CJNIBroadcastReceiver(CJNIContext *context) : CJNIBase("org/xbmc/xbmc/XBMCBroadcastReceiver")
-{
-  jni_app_context = context;
-}
 
-void CJNIBroadcastReceiver::InitializeBroadcastReceiver()
+CJNIBroadcastReceiver *CJNIBroadcastReceiver::m_receiverInstance(NULL);
+CJNIBroadcastReceiver::CJNIBroadcastReceiver(const std::string &className) : CJNIBase(className)
 {
+  CJNIContext *appInstance = CJNIContext::GetAppInstance();
+  if (!appInstance || className.empty())
+    return;
+
   // Convert "the/class/name" to "the.class.name" as loadClass() expects it.
-  std::string className = GetClassName();
-  for (std::string::iterator it = className.begin(); it != className.end(); ++it)
+  std::string dotClassName = GetClassName();
+  for (std::string::iterator it = dotClassName.begin(); it != dotClassName.end(); ++it)
   {
     if (*it == '/')
       *it = '.';
   }
-  m_object = new_object(jni_app_context->getClassLoader().loadClass(className));
+  m_object = new_object(appInstance->getClassLoader().loadClass(dotClassName));
+  m_receiverInstance = this;
   m_object.setGlobal();
 }
 
-void CJNIBroadcastReceiver::DestroyBroadcastReceiver()
-{
-  m_object.reset();
-}
-
-extern "C"
-JNIEXPORT void JNICALL Java_org_xbmc_xbmc_XBMCBroadcastReceiver__1onReceive
-  (JNIEnv *env, jobject context, jobject intent)
+void CJNIBroadcastReceiver::_onReceive(JNIEnv *env, jobject context, jobject intent)
 {
-  if(CJNIBroadcastReceiver::jni_app_context)
-    CJNIBroadcastReceiver::jni_app_context->onReceive(CJNIIntent(jhobject(intent)));
+  (void)env;
+  (void)context;
+  if(m_receiverInstance)
+    m_receiverInstance->onReceive(CJNIIntent(jhobject(intent)));
 }
index b448e79..0ba76bb 100644 (file)
  *
  */
 #include "JNIBase.h"
-class CJNIContext;
+class CJNIIntent;
 class CJNIBroadcastReceiver : public CJNIBase
 {
 public:
-  static CJNIContext *jni_app_context;
+  static void _onReceive(JNIEnv *env, jobject context, jobject intent);
+
 protected:
-  void DestroyBroadcastReceiver();
-  CJNIBroadcastReceiver(CJNIContext *context);
+  virtual void onReceive(CJNIIntent intent)=0;
   ~CJNIBroadcastReceiver(){};
-  void InitializeBroadcastReceiver();
+  CJNIBroadcastReceiver(const std::string &className);
+
 private:
-  explicit CJNIBroadcastReceiver(jni::jhobject const& object);
+  static CJNIBroadcastReceiver* m_receiverInstance;
 };
index f9d501a..e27ae66 100644 (file)
@@ -33,19 +33,21 @@ int CJNIConnectivityManager::TYPE_DUMMY(0);
 int CJNIConnectivityManager::TYPE_ETHERNET(0);
 int CJNIConnectivityManager::DEFAULT_NETWORK_PREFERENCE(0);
 using namespace jni;
-CJNIConnectivityManager::CJNIConnectivityManager(const jhobject &object) : CJNIBase(object)
+
+void CJNIConnectivityManager::PopulateStaticFields()
 {
-  TYPE_MOBILE = (get_static_field<int>(m_object, "TYPE_MOBILE"));
-  TYPE_WIFI = (get_static_field<int>(m_object, "TYPE_WIFI"));
-  TYPE_MOBILE_MMS = (get_static_field<int>(m_object, "TYPE_MOBILE_MMS"));
-  TYPE_MOBILE_SUPL = (get_static_field<int>(m_object, "TYPE_MOBILE_SUPL"));
-  TYPE_MOBILE_DUN = (get_static_field<int>(m_object, "TYPE_MOBILE_DUN"));
-  TYPE_MOBILE_HIPRI = (get_static_field<int>(m_object, "TYPE_MOBILE_HIPRI"));
-  TYPE_WIMAX = (get_static_field<int>(m_object, "TYPE_WIMAX"));
-  TYPE_BLUETOOTH = (get_static_field<int>(m_object, "TYPE_BLUETOOTH"));
-  TYPE_DUMMY = (get_static_field<int>(m_object, "TYPE_DUMMY"));
-  TYPE_ETHERNET = (get_static_field<int>(m_object, "TYPE_ETHERNET"));
-  DEFAULT_NETWORK_PREFERENCE = (get_static_field<int>(m_object, "DEFAULT_NETWORK_PREFERENCE"));
+  jhclass clazz = find_class("android.net.ConnectivityManager");
+  TYPE_MOBILE = (get_static_field<int>(clazz, "TYPE_MOBILE"));
+  TYPE_WIFI = (get_static_field<int>(clazz, "TYPE_WIFI"));
+  TYPE_MOBILE_MMS = (get_static_field<int>(clazz, "TYPE_MOBILE_MMS"));
+  TYPE_MOBILE_SUPL = (get_static_field<int>(clazz, "TYPE_MOBILE_SUPL"));
+  TYPE_MOBILE_DUN = (get_static_field<int>(clazz, "TYPE_MOBILE_DUN"));
+  TYPE_MOBILE_HIPRI = (get_static_field<int>(clazz, "TYPE_MOBILE_HIPRI"));
+  TYPE_WIMAX = (get_static_field<int>(clazz, "TYPE_WIMAX"));
+  TYPE_BLUETOOTH = (get_static_field<int>(clazz, "TYPE_BLUETOOTH"));
+  TYPE_DUMMY = (get_static_field<int>(clazz, "TYPE_DUMMY"));
+  TYPE_ETHERNET = (get_static_field<int>(clazz, "TYPE_ETHERNET"));
+  DEFAULT_NETWORK_PREFERENCE = (get_static_field<int>(clazz, "DEFAULT_NETWORK_PREFERENCE"));
 }
 
 bool CJNIConnectivityManager::isNetworkTypeValid(int networkType)
index e17d733..60a53f8 100644 (file)
@@ -24,7 +24,7 @@ class CJNINetworkInfo;
 class CJNIConnectivityManager : public CJNIBase
 {
 public:
-  CJNIConnectivityManager(const jni::jhobject &object);
+  CJNIConnectivityManager(const jni::jhobject &object) : CJNIBase(object){};
   bool isNetworkTypeValid(int);
   void setNetworkPreference(int);
   int getNetworkPreference();
@@ -47,6 +47,8 @@ public:
   static int TYPE_DUMMY;
   static int TYPE_ETHERNET;
   static int DEFAULT_NETWORK_PREFERENCE;
+
+  static void PopulateStaticFields();
 private:
   CJNIConnectivityManager();
 };
diff --git a/xbmc/android/jni/ContentResolver.cpp b/xbmc/android/jni/ContentResolver.cpp
new file mode 100644 (file)
index 0000000..909fb14
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ *      Copyright (C) 2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "ContentResolver.h"
+#include "Cursor.h"
+#include "jutils/jutils-details.hpp"
+#include "URI.h"
+std::string CJNIContentResolver::SCHEME_CONTENT;
+std::string CJNIContentResolver::SCHEME_ANDROID_RESOURCE;
+std::string CJNIContentResolver::SCHEME_FILE;
+std::string CJNIContentResolver::CURSOR_ITEM_BASE_TYPE;
+std::string CJNIContentResolver::CURSOR_DIR_BASE_TYPE;
+
+using namespace jni;
+void CJNIContentResolver::PopulateStaticFields()
+{
+  jhclass clazz = find_class("android/content/ContentResolver");
+  SCHEME_CONTENT = jcast<std::string>(get_static_field<jhstring>(clazz,"SCHEME_CONTENT"));
+  SCHEME_ANDROID_RESOURCE = jcast<std::string>(get_static_field<jhstring>(clazz,"SCHEME_ANDROID_RESOURCE"));
+  SCHEME_FILE = jcast<std::string>(get_static_field<jhstring>(clazz,"SCHEME_FILE"));
+  CURSOR_ITEM_BASE_TYPE = jcast<std::string>(get_static_field<jhstring>(clazz,"CURSOR_ITEM_BASE_TYPE"));
+  CURSOR_DIR_BASE_TYPE = jcast<std::string>(get_static_field<jhstring>(clazz,"CURSOR_DIR_BASE_TYPE"));
+}
+
+CJNICursor CJNIContentResolver::query(const CJNIURI &uri, const std::vector<std::string> &projection, const std::string &selection, const std::vector<std::string> &selectionArgs, const std::string &sortOrder)
+{
+
+  return (CJNICursor)(call_method<jhobject>(m_object, \
+         "query","(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;", \
+         uri.get_raw(), jcast<jhobjectArray>(projection), jcast<jhstring>(selection), jcast<jhobjectArray>(selectionArgs), jcast<jhstring>(sortOrder)));
+}
diff --git a/xbmc/android/jni/ContentResolver.h b/xbmc/android/jni/ContentResolver.h
new file mode 100644 (file)
index 0000000..1add109
--- /dev/null
@@ -0,0 +1,41 @@
+#pragma once
+/*
+ *      Copyright (C) 2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "JNIBase.h"
+
+class CJNICursor;
+class CJNIURI;
+class CJNIContentResolver : public CJNIBase
+{
+public:
+  CJNIContentResolver(const jni::jhobject &object) : CJNIBase(object){};
+
+  static std::string SCHEME_CONTENT;
+  static std::string SCHEME_ANDROID_RESOURCE;
+  static std::string SCHEME_FILE;
+  static std::string CURSOR_ITEM_BASE_TYPE;
+  static std::string CURSOR_DIR_BASE_TYPE;
+
+  CJNICursor query(const CJNIURI &uri, const std::vector<std::string> &projection, const std::string &selection, const std::vector<std::string> &selectionArgs, const std::string &sortOrder);
+
+  static void PopulateStaticFields();
+private:
+  CJNIContentResolver();
+};
index bcfbdb5..529dc7d 100644 (file)
 #include "JNIThreading.h"
 #include "ApplicationInfo.h"
 #include "File.h"
+#include "ContentResolver.h"
+#include "BaseColumns.h"
+#include "MediaStore.h"
+#include "PowerManager.h"
+#include "Cursor.h"
+#include "ConnectivityManager.h"
+#include "AudioManager.h"
 #include <android/native_activity.h>
 
 using namespace jni;
 
 jhobject CJNIContext::m_context(0);
-CJNIContext::CJNIContext(const ANativeActivity *nativeActivity) : CJNIBroadcastReceiver(this)
+CJNIContext* CJNIContext::m_appInstance(NULL);
+CJNIContext::CJNIContext(const ANativeActivity *nativeActivity)
 {
   m_context.reset(nativeActivity->clazz);
   xbmc_jni_on_load(nativeActivity->vm, nativeActivity->env);
-  InitializeBroadcastReceiver();
+  PopulateStaticFields();
+  m_appInstance = this;
 }
 
 CJNIContext::~CJNIContext()
 {
+  m_appInstance = NULL;
   m_context.release();
-  DestroyBroadcastReceiver();
   xbmc_jni_on_unload();
 }
 
+void CJNIContext::PopulateStaticFields()
+{
+  CJNIBaseColumns::PopulateStaticFields();
+  CJNIMediaStoreMediaColumns::PopulateStaticFields();
+  CJNIPowerManager::PopulateStaticFields();
+  CJNIPackageManager::PopulateStaticFields();
+  CJNIMediaStoreMediaColumns::PopulateStaticFields();
+  CJNICursor::PopulateStaticFields();
+  CJNIContentResolver::PopulateStaticFields();
+  CJNIConnectivityManager::PopulateStaticFields();
+  CJNIAudioManager::PopulateStaticFields();
+
+}
+
 CJNIPackageManager CJNIContext::GetPackageManager()
 {
   return (CJNIPackageManager)call_method<jhobject>(m_context, "getPackageManager", "()Landroid/content/pm/PackageManager;");
@@ -54,7 +77,7 @@ CJNIPackageManager CJNIContext::GetPackageManager()
 
 void CJNIContext::startActivity(const CJNIIntent &intent)
 {
-  call_method<void>(jhobject(m_context), "startActivity", "(Landroid/content/Intent;)V", intent.get());
+  call_method<void>(jhobject(m_context), "startActivity", "(Landroid/content/Intent;)V", intent.get_raw());
 }
 
 int CJNIContext::checkCallingOrSelfPermission(const std::string &permission)
@@ -70,18 +93,23 @@ jhobject CJNIContext::getSystemService(const std::string &service)
 CJNIIntent CJNIContext::registerReceiver(const CJNIBroadcastReceiver &receiver, const CJNIIntentFilter &filter)
 {
   return (CJNIIntent)call_method<jhobject>(m_context, "registerReceiver", \
-                             "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;", receiver.get(), filter.get());
+                             "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;", receiver.get_raw(), filter.get_raw());
 }
 
 CJNIIntent CJNIContext::registerReceiver(const CJNIIntentFilter &filter)
 {
   return (CJNIIntent)call_method<jhobject>(m_context, "registerReceiver", \
-                             "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;", (jobject)NULL, filter.get());
+                             "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;", (jobject)NULL, filter.get_raw());
+}
+
+void CJNIContext::unregisterReceiver(const CJNIBroadcastReceiver &receiver)
+{
+  call_method<void>(m_context, "unregisterReceiver", "(Landroid/content/BroadcastReceiver;)V", receiver.get_raw());
 }
 
 CJNIIntent CJNIContext::sendBroadcast(const CJNIIntent &intent)
 {
-  return (CJNIIntent)call_method<jhobject>(m_context, "sendBroadcast", "(Landroid/content/Intent;)V", intent.get());
+  return (CJNIIntent)call_method<jhobject>(m_context, "sendBroadcast", "(Landroid/content/Intent;)V", intent.get_raw());
 }
 
 CJNIIntent CJNIContext::getIntent()
@@ -118,3 +146,16 @@ CJNIFile CJNIContext::getExternalFilesDir(const std::string &path)
 {
   return (CJNIFile)call_method<jhobject>(m_context, "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;", jcast<jhstring>(path));
 }
+
+CJNIContentResolver CJNIContext::getContentResolver()
+{
+  return (CJNIContentResolver)call_method<jhobject>(m_context, "getContentResolver", "()Landroid/content/ContentResolver;");
+}
+
+void CJNIContext::_onNewIntent(JNIEnv *env, jobject context, jobject intent)
+{
+  (void)env;
+  (void)context;
+  if(m_appInstance)
+    m_appInstance->onNewIntent(CJNIIntent(jhobject(intent)));
+}
index c8e8d26..8b17e86 100644 (file)
@@ -28,7 +28,8 @@ class CJNIIntentFilter;
 class CJNIClassLoader;
 class CJNIApplicationInfo;
 class CJNIFile;
-class CJNIContext : public CJNIBroadcastReceiver
+class CJNIContentResolver;
+class CJNIContext
 {
 public:
   static CJNIPackageManager GetPackageManager();
@@ -37,6 +38,7 @@ public:
   static int checkCallingOrSelfPermission(const std::string &permission);
   static CJNIIntent registerReceiver(const CJNIBroadcastReceiver &receiver, const CJNIIntentFilter &filter);
   static CJNIIntent registerReceiver(const CJNIIntentFilter &filter);
+  static void unregisterReceiver(const CJNIBroadcastReceiver &receiver);
   static CJNIIntent sendBroadcast(const CJNIIntent &intent);
   static CJNIIntent getIntent();
   static CJNIClassLoader getClassLoader();
@@ -45,14 +47,19 @@ public:
   static CJNIFile getCacheDir();
   static CJNIFile getDir(const std::string &path, int mode);
   static CJNIFile getExternalFilesDir(const std::string &path);
-  virtual void onReceive(CJNIIntent intent)=0;
+  static CJNIContentResolver getContentResolver();
+  static CJNIContext* GetAppInstance() { return m_appInstance; };
+  static void _onNewIntent(JNIEnv *env, jobject context, jobject intent);
 protected:
+  virtual void onNewIntent(CJNIIntent intent)=0;
   CJNIContext(const ANativeActivity *nativeActivity);
   ~CJNIContext();
 
 private:
   CJNIContext();
+  void PopulateStaticFields();
   void operator=(CJNIContext const&){};
   static jni::jhobject m_context;
+  static CJNIContext *m_appInstance;
 };
 
diff --git a/xbmc/android/jni/Cursor.cpp b/xbmc/android/jni/Cursor.cpp
new file mode 100644 (file)
index 0000000..e79cb8e
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ *      Copyright (C) 2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "Cursor.h"
+#include "jutils/jutils-details.hpp"
+#include "URI.h"
+
+using namespace jni;
+
+int CJNICursor::FIELD_TYPE_NULL(0);
+int CJNICursor::FIELD_TYPE_INTEGER(0);
+int CJNICursor::FIELD_TYPE_FLOAT(0);
+int CJNICursor::FIELD_TYPE_STRING(0);
+int CJNICursor::FIELD_TYPE_BLOB(0);
+
+void CJNICursor::PopulateStaticFields()
+{
+  jhclass clazz = find_class("android/database/Cursor");
+  FIELD_TYPE_NULL = (get_static_field<int>(clazz, "FIELD_TYPE_NULL"));
+  FIELD_TYPE_INTEGER = (get_static_field<int>(clazz, "FIELD_TYPE_INTEGER"));
+  FIELD_TYPE_FLOAT = (get_static_field<int>(clazz, "FIELD_TYPE_FLOAT"));
+  FIELD_TYPE_STRING = (get_static_field<int>(clazz, "FIELD_TYPE_STRING"));
+  FIELD_TYPE_BLOB = (get_static_field<int>(clazz, "FIELD_TYPE_BLOB"));
+}
+
+int CJNICursor::getCount()
+{
+  return call_method<jint>(m_object, "getCount", "()I");
+}
+
+int CJNICursor::getPosition()
+{
+  return call_method<jint>(m_object, "getPosition", "()I");
+}
+
+bool CJNICursor::move(int offset)
+{
+  return call_method<jboolean>(m_object, "move", "(I)Z", offset);
+}
+
+bool CJNICursor::moveToPosition(int position)
+{
+  return call_method<jboolean>(m_object, "moveToPosition", "(I)Z", position);
+}
+
+bool CJNICursor::moveToFirst()
+{
+  return call_method<jboolean>(m_object, "moveToFirst", "()Z");
+}
+
+bool CJNICursor::moveToLast()
+{
+  return call_method<jboolean>(m_object, "moveToLast", "()Z");
+}
+
+bool CJNICursor::moveToNext()
+{
+  return call_method<jboolean>(m_object, "moveToNext", "()Z");
+}
+
+bool CJNICursor::moveToPrevious()
+{
+  return call_method<jboolean>(m_object, "moveToPrevious", "()Z");
+}
+
+bool CJNICursor::isFirst()
+{
+  return call_method<jboolean>(m_object, "isFirst", "()Z");
+}
+
+bool CJNICursor::isLast()
+{
+  return call_method<jboolean>(m_object, "isLast", "()Z");
+}
+
+bool CJNICursor::isBeforeFirst()
+{
+  return call_method<jboolean>(m_object, "isBeforeFirst", "()Z");
+}
+
+bool CJNICursor::isAfterLast()
+{
+  return call_method<jboolean>(m_object, "isAfterLast", "()Z");
+}
+
+int CJNICursor::getColumnIndex(const std::string &columnName)
+{
+  return call_method<jint>(m_object, "getColumnIndex", "(Ljava/lang/String;)I", jcast<jhstring>(columnName));
+}
+
+std::string CJNICursor::getColumnName(int columnIndex)
+{
+  return jcast<std::string>(call_method<jhstring>(m_object, "getColumnName", "(I)Ljava/lang/String;", columnIndex));
+}
+
+std::vector<std::string> CJNICursor::getColumnNames()
+{
+  return jcast<std::vector<std::string>>(call_method<jhobjectArray>(m_object, "getColumnNames", "()[Ljava/lang/String;"));
+}
+
+int CJNICursor::getColumnCount()
+{
+  return call_method<jint>(m_object, "getColumnCount", "()I");
+}
+
+std::string CJNICursor::getString(int columnIndex)
+{
+  return jcast<std::string>(call_method<jhstring>(m_object, "getString", "(I)Ljava/lang/String;", columnIndex));
+}
+
+short CJNICursor::getShort(int columnIndex)
+{
+  return call_method<jshort>(m_object, "getShort", "()S", columnIndex);
+}
+
+int CJNICursor::getInt(int columnIndex)
+{
+  return call_method<jint>(m_object, "getInt", "()I", columnIndex);
+}
+
+long CJNICursor::getLong(int columnIndex)
+{
+  return call_method<jint>(m_object, "getLong", "()J", columnIndex);
+}
+
+float CJNICursor::getFloat(int columnIndex)
+{
+  return call_method<jfloat>(m_object, "getFloat", "()F", columnIndex);
+}
+
+double CJNICursor::getDouble(int columnIndex)
+{
+  return call_method<jdouble>(m_object, "getDouble", "()D", columnIndex);
+}
+
+int CJNICursor::getType(int columnIndex)
+{
+  return call_method<jint>(m_object, "getType", "(I)I", columnIndex);
+}
+
+bool CJNICursor::isNull(int columnIndex)
+{
+  return call_method<jboolean>(m_object, "isNull", "(I)Z", columnIndex);
+}
+
+void CJNICursor::deactivate()
+{
+  call_method<void>(m_object, "deactivate", "()V");
+}
+
+bool CJNICursor::requery()
+{
+  return call_method<jboolean>(m_object, "requery", "()Z");
+}
+
+void CJNICursor::close()
+{
+  call_method<void>(m_object, "close", "()V");
+}
+
+bool CJNICursor::isClosed()
+{
+  return call_method<jboolean>(m_object, "isClosed", "()Z");
+}
+
diff --git a/xbmc/android/jni/Cursor.h b/xbmc/android/jni/Cursor.h
new file mode 100644 (file)
index 0000000..aad672e
--- /dev/null
@@ -0,0 +1,67 @@
+#pragma once
+/*
+ *      Copyright (C) 2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "JNIBase.h"
+#include "MediaStore.h"
+class CJNIURI;
+class CJNICursor : public CJNIBase
+{
+public:
+  ~CJNICursor(){};
+  CJNICursor(const jni::jhobject &object) : CJNIBase(object){};
+  int getCount();
+  int getPosition();
+  bool move(int offset);
+  bool moveToPosition(int position);
+  bool moveToFirst();
+  bool moveToLast();
+  bool moveToNext();
+  bool moveToPrevious();
+  bool isFirst();
+  bool isLast();
+  bool isBeforeFirst();
+  bool isAfterLast();
+  int getColumnIndex(const std::string &columnName);
+  std::string getColumnName(int columnIndex);
+  std::vector<std::string> getColumnNames();
+  int getColumnCount();
+  std::string getString(int columnIndex);
+  short getShort(int columnIndex);
+  int getInt(int columnIndex);
+  long getLong(int columnIndex);
+  float getFloat(int columnIndex);
+  double getDouble(int columnIndex);
+  int getType(int columnIndex);
+  bool isNull(int columnIndex);
+  void deactivate();
+  bool requery();
+  void close();
+  bool isClosed();
+
+  static int FIELD_TYPE_NULL;
+  static int FIELD_TYPE_INTEGER;
+  static int FIELD_TYPE_FLOAT;
+  static int FIELD_TYPE_STRING;
+  static int FIELD_TYPE_BLOB;
+
+  static void PopulateStaticFields();
+private:
+  CJNICursor();
+};
index 064cc64..3472ffd 100644 (file)
@@ -33,5 +33,5 @@ std::string CJNIEnum::toString()
 }
 bool CJNIEnum::equals(const CJNIEnum &object)
 {
-  return call_method<jboolean>(m_object, "equals", "(Ljava/lang/Object;)Z", object.get());
+  return call_method<jboolean>(m_object, "equals", "(Ljava/lang/Object;)Z", object.get_raw());
 }
index 00af491..b4a0cf0 100644 (file)
@@ -25,7 +25,10 @@ using namespace jni;
 
 CJNIIntent::CJNIIntent(const std::string &action) : CJNIBase("android/content/Intent")
 {
-  m_object = new_object(GetClassName());
+  if(action.empty())
+    m_object = new_object(GetClassName());
+  else
+    m_object = new_object(GetClassName(), "<init>", "(Ljava/lang/String;)V", jcast<jhstring>(action));
 }
 
 std::string CJNIIntent::getAction()
@@ -90,7 +93,7 @@ void CJNIIntent::setData(const std::string &uri)
 
 void CJNIIntent::setDataAndType(const CJNIURI &uri, const std::string &type)
 {
-  call_method<jhobject>(m_object, "setDataAndType", "(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;", uri.get(), jcast<jhstring>(type));
+  call_method<jhobject>(m_object, "setDataAndType", "(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;", uri.get_raw(), jcast<jhstring>(type));
 }
 
 void CJNIIntent::setFlags(int flags)
@@ -108,3 +111,7 @@ void CJNIIntent::setType(const std::string &type)
   call_method<jhobject>(m_object, "setType", "(Ljava/lang/String;)Landroid/content/Intent;", jcast<jhstring>(type));
 }
 
+CJNIURI CJNIIntent::getData() const
+{
+  return (CJNIURI)call_method<jhobject>(m_object, "getData","()Landroid/net/Uri;");
+}
index 721ccdb..d69c7b5 100644 (file)
@@ -50,4 +50,5 @@ public:
 
   void setPackage(const std::string &packageName);
   void setType(const std::string &type);
+  CJNIURI getData() const;
 };
index 4dc3dda..98684f5 100644 (file)
@@ -34,10 +34,10 @@ CJNIIntentFilter::CJNIIntentFilter(const std::string &action) : CJNIBase("androi
 
 void CJNIIntentFilter::addAction(std::string action)
 {
-  call_method<jhobject>(m_object, "addAction", "(Ljava/lang/String;)V", jcast<jhstring>(action));
+  call_method<void>(m_object, "addAction", "(Ljava/lang/String;)V", jcast<jhstring>(action));
 }
 
 void CJNIIntentFilter::addDataScheme(std::string scheme)
 {
-  call_method<jhobject>(m_object, "addDataScheme", "(Ljava/lang/String;)V", jcast<jhstring>(scheme));
+  call_method<void>(m_object, "addDataScheme", "(Ljava/lang/String;)V", jcast<jhstring>(scheme));
 }
index 507a66e..48b29be 100644 (file)
@@ -27,7 +27,7 @@ class CJNIBase
 
 public:
   operator safe_bool_type() const { return !m_object ?  0 : &CJNIBase::non_null_object; }
-  const jni::jhobject& get() const { return m_object; }
+  const jni::jhobject& get_raw() const { return m_object; }
 
 protected:
   CJNIBase(jni::jhobject const& object);
index ea7c708..d8db5cf 100644 (file)
@@ -53,6 +53,7 @@ JavaVM *jvm()
 
 static void jnienv_detach_thread(void *arg)
 {
+  (void)arg;
   if (!jvm())
     return;
   __android_log_print(ANDROID_LOG_VERBOSE, "XBMC","detaching thread");
index 254e605..17f2b63 100644 (file)
@@ -15,6 +15,7 @@ SRCS      += jutils.cpp
 SRCS      += URI.cpp
 SRCS      += WifiInfo.cpp
 SRCS      += WifiManager.cpp
+SRCS      += WifiManagerMulticastLock.cpp
 SRCS      += ScanResult.cpp
 SRCS      += List.cpp
 SRCS      += DhcpInfo.cpp
@@ -29,9 +30,13 @@ SRCS      += System.cpp
 SRCS      += ApplicationInfo.cpp
 SRCS      += BitmapDrawable.cpp
 SRCS      += CharSequence.cpp
+SRCS      += ContentResolver.cpp
+SRCS      += Cursor.cpp
+SRCS      += BaseColumns.cpp
+SRCS      += MediaStore.cpp
 
 LIB        = jni.a
 
-CXXFLAGS+=-std=gnu++0x
+CXXFLAGS+=-std=gnu++0x -Wextra
 include @abs_top_srcdir@/Makefile.include
 -include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
diff --git a/xbmc/android/jni/MediaStore.cpp b/xbmc/android/jni/MediaStore.cpp
new file mode 100644 (file)
index 0000000..322c7f4
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *      Copyright (C) 2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "MediaStore.h"
+#include "jutils/jutils-details.hpp"
+
+using namespace jni;
+
+std::string CJNIMediaStoreMediaColumns::DATA;
+std::string CJNIMediaStoreMediaColumns::SIZE;
+std::string CJNIMediaStoreMediaColumns::DISPLAY_NAME;
+std::string CJNIMediaStoreMediaColumns::TITLE;
+std::string CJNIMediaStoreMediaColumns::DATE_ADDED;
+std::string CJNIMediaStoreMediaColumns::DATE_MODIFIED;
+std::string CJNIMediaStoreMediaColumns::MIME_TYPE;
+void CJNIMediaStoreMediaColumns::PopulateStaticFields()
+{
+  jhclass clazz = find_class("android/provider/MediaStore$MediaColumns");
+  DATA = (jcast<std::string>(get_static_field<jhstring>(clazz, "DATA")));
+  SIZE = (jcast<std::string>(get_static_field<jhstring>(clazz, "SIZE")));
+  DISPLAY_NAME = (jcast<std::string>(get_static_field<jhstring>(clazz, "DISPLAY_NAME")));
+  TITLE = (jcast<std::string>(get_static_field<jhstring>(clazz, "TITLE")));
+  DATE_ADDED = (jcast<std::string>(get_static_field<jhstring>(clazz, "DATE_ADDED")));
+  DATE_MODIFIED = (jcast<std::string>(get_static_field<jhstring>(clazz, "DATE_MODIFIED")));
+  MIME_TYPE = (jcast<std::string>(get_static_field<jhstring>(clazz, "MIME_TYPE")));
+}
diff --git a/xbmc/android/jni/MediaStore.h b/xbmc/android/jni/MediaStore.h
new file mode 100644 (file)
index 0000000..bfca88f
--- /dev/null
@@ -0,0 +1,43 @@
+#pragma once
+/*
+ *      Copyright (C) 2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "JNIBase.h"
+#include "BaseColumns.h"
+class CJNIMediaStoreMediaColumns : public CJNIBaseColumns
+{
+public:
+  static std::string DATA; 
+  static std::string SIZE; 
+  static std::string DISPLAY_NAME;
+  static std::string TITLE;
+  static std::string DATE_ADDED;
+  static std::string DATE_MODIFIED;
+  static std::string MIME_TYPE;
+  static void PopulateStaticFields();
+private:
+  CJNIMediaStoreMediaColumns();
+};
+
+class CJNIMediaStore : public CJNIBase
+{
+public:
+  ~CJNIMediaStore(){};
+  CJNIMediaStore(const jni::jhobject &object) : CJNIBase(object){};
+};
index 27fe23c..cc21a2e 100644 (file)
 using namespace jni;
 int CJNIPackageManager::GET_ACTIVITIES(0);
 
-CJNIPackageManager::CJNIPackageManager(const jni::jhobject &object) : CJNIBase(object)
+void CJNIPackageManager::PopulateStaticFields()
 {
-  GET_ACTIVITIES = (get_static_field<int>(m_object, "GET_ACTIVITIES"));
+  jhclass clazz = find_class("android/content/pm/PackageManager");
+  GET_ACTIVITIES = (get_static_field<int>(clazz, "GET_ACTIVITIES"));
 }
 
 CJNIIntent CJNIPackageManager::getLaunchIntentForPackage(const std::string &package)
@@ -45,7 +46,7 @@ CJNIDrawable CJNIPackageManager::getApplicationIcon(const std::string &package)
 
 CJNICharSequence CJNIPackageManager::getApplicationLabel(const CJNIApplicationInfo &info)
 {
-  return (CJNICharSequence)call_method<jhobject>(m_object, "getApplicationLabel", "(Landroid/content/pm/ApplicationInfo;)Ljava/lang/CharSequence;", info.get());
+  return (CJNICharSequence)call_method<jhobject>(m_object, "getApplicationLabel", "(Landroid/content/pm/ApplicationInfo;)Ljava/lang/CharSequence;", info.get_raw());
 }
 
 CJNIList<CJNIApplicationInfo> CJNIPackageManager::getInstalledApplications(int flags)
index 75aed23..7bf2d01 100644 (file)
@@ -28,7 +28,7 @@ class CJNICharSequence;
 class CJNIPackageManager : public CJNIBase
 {
 public:
-  CJNIPackageManager(const jni::jhobject &object);
+  CJNIPackageManager(const jni::jhobject &object) : CJNIBase(object) {};
   ~CJNIPackageManager(){};
 
   CJNIIntent getLaunchIntentForPackage(const std::string &package);
@@ -36,6 +36,7 @@ public:
   CJNIList<CJNIApplicationInfo> getInstalledApplications(int flags);
   CJNICharSequence getApplicationLabel(const CJNIApplicationInfo &info);
 
+  static void PopulateStaticFields();
   static int GET_ACTIVITIES;
 private:
   CJNIPackageManager();
index 77844ac..6ce56d7 100644 (file)
 using namespace jni;
 
 int CJNIPowerManager::FULL_WAKE_LOCK(0);
-CJNIPowerManager::CJNIPowerManager(const jni::jhobject &object) : CJNIBase(object)
+
+void CJNIPowerManager::PopulateStaticFields()
 {
-  FULL_WAKE_LOCK = (get_static_field<int>(m_object, "FULL_WAKE_LOCK"));  
+  jhclass clazz = find_class("android/os/PowerManager");
+  FULL_WAKE_LOCK = (get_static_field<int>(clazz, "FULL_WAKE_LOCK"));
 }
 
 CJNIWakeLock CJNIPowerManager::newWakeLock(const std::string &name)
index e6c2abe..8297614 100644 (file)
@@ -28,7 +28,8 @@ public:
   void reboot(const std::string &reason);
   void goToSleep(int64_t timestamp);
 
-  CJNIPowerManager(const jni::jhobject &object);
+  static void PopulateStaticFields();
+  CJNIPowerManager(const jni::jhobject &object) : CJNIBase(object){};
   ~CJNIPowerManager(){};
 
 private:
index b2bd443..df9f2eb 100644 (file)
@@ -26,3 +26,23 @@ CJNIURI CJNIURI::parse(std::string uriString)
 {
   return (CJNIURI)call_static_method<jhobject>("android/net/Uri", "parse", "(Ljava/lang/String;)Landroid/net/Uri;", jcast<jhstring>(uriString));
 }
+
+std::string CJNIURI::getScheme() const
+{
+  return jcast<std::string>(call_method<jhstring>(m_object, "getScheme", "()Ljava/lang/String;"));
+}
+
+std::string CJNIURI::toString() const
+{
+  return jcast<std::string>(call_method<jhstring>(m_object, "toString", "()Ljava/lang/String;"));
+}
+
+std::string CJNIURI::getLastPathSegment() const
+{
+  return jcast<std::string>(call_method<jhstring>(m_object, "getLastPathSegment", "()Ljava/lang/String;"));
+}
+
+std::string CJNIURI::getPath() const
+{
+  return jcast<std::string>(call_method<jhstring>(m_object, "getPath", "()Ljava/lang/String;"));
+}
index f4f610a..af0c02f 100644 (file)
 class CJNIURI : public CJNIBase
 {
   public:
+  CJNIURI(const jni::jhobject &uri) : CJNIBase(uri){};
+  std::string getScheme() const;
+  std::string toString() const;
+  std::string getLastPathSegment() const;
+  std::string getPath() const;
   static CJNIURI parse(std::string uriString);
   ~CJNIURI(){};
 private:
-  CJNIURI(const jni::jhobject &uri) : CJNIBase(uri){};
   CJNIURI();
 };
index 705ed82..3c895db 100644 (file)
@@ -79,5 +79,5 @@ CJNISupplicantState CJNIWifiInfo::getSupplicantState() const
 
 CJNINetworkInfoDetailedState CJNIWifiInfo::getDetailedStateOf(const CJNISupplicantState &suppState)
 {
-  return call_static_method<jhobject>("android/net/wifi/WifiInfo", "getDetailedStateOf", "(Landroid/net/wifi/SupplicantState;)Landroid/net/NetworkInfo$DetailedState;", suppState.get());
+  return call_static_method<jhobject>("android/net/wifi/WifiInfo", "getDetailedStateOf", "(Landroid/net/wifi/SupplicantState;)Landroid/net/NetworkInfo$DetailedState;", suppState.get_raw());
 }
index 164f923..8571bf8 100644 (file)
@@ -23,6 +23,7 @@
 #include "WifiInfo.h"
 #include "WifiConfiguration.h"
 #include "ScanResult.h"
+#include "WifiManagerMulticastLock.h"
 #include "jutils/jutils-details.hpp"
 
 using namespace jni;
@@ -117,3 +118,8 @@ int CJNIWifiManager::compareSignalLevel(int rssiA, int rssiB)
 {
   return call_static_method<jint>("android/net/wifi/WifiManager", "compareSignalLevel", "(II)I", rssiA, rssiB);
 }
+
+CJNIWifiManagerMulticastLock CJNIWifiManager::createMulticastLock(const std::string &tag)
+{
+  return (CJNIWifiManagerMulticastLock)call_method<jhobject>(m_object, "createMulticastLock", "(Ljava/lang/String;)Landroid/net/wifi/WifiManager$MulticastLock;", jcast<jhstring>(tag));
+}
index 077efdd..e24f092 100644 (file)
@@ -24,6 +24,7 @@ class CJNIDhcpInfo;
 class CJNIWifiInfo;
 class CJNIScanResult;
 class CJNIWifiConfiguration;
+class CJNIWifiManagerMulticastLock;
 class CJNIWifiManager : public CJNIBase
 {
 friend class CJNIContext;
@@ -47,6 +48,7 @@ public:
   bool isWifiEnabled();
   static int calculateSignalLevel(int, int);
   static int compareSignalLevel(int, int);
+  CJNIWifiManagerMulticastLock createMulticastLock(const std::string &tag);
 private:
   CJNIWifiManager();
 };
diff --git a/xbmc/android/jni/WifiManagerMulticastLock.cpp b/xbmc/android/jni/WifiManagerMulticastLock.cpp
new file mode 100644 (file)
index 0000000..579dcf2
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *      Copyright (C) 2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "WifiManagerMulticastLock.h"
+#include "jutils/jutils-details.hpp"
+
+using namespace jni;
+
+void CJNIWifiManagerMulticastLock::acquire()
+{
+  call_method<void>(m_object, "acquire", "()V");
+}
+
+void CJNIWifiManagerMulticastLock::release()
+{
+  call_method<void>(m_object, "release", "()V");
+}
+
+void CJNIWifiManagerMulticastLock::setReferenceCounted(bool refCounted)
+{
+  call_method<void>(m_object, "setReferenceCounted", "(Z)V", refCounted);
+}
+
+bool CJNIWifiManagerMulticastLock::isHeld()
+{
+  return call_method<jboolean>(m_object, "setReferenceCounted", "()Z");
+}
+
+std::string CJNIWifiManagerMulticastLock::toString()
+{
+  return jcast<std::string>(call_method<jhstring>(m_object, "toString", "()Ljava/lang/String;"));
+}
diff --git a/xbmc/android/jni/WifiManagerMulticastLock.h b/xbmc/android/jni/WifiManagerMulticastLock.h
new file mode 100644 (file)
index 0000000..206300b
--- /dev/null
@@ -0,0 +1,35 @@
+#pragma once
+/*
+ *      Copyright (C) 2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "JNIBase.h"
+
+class CJNIWifiManagerMulticastLock : public CJNIBase
+{
+public:
+  CJNIWifiManagerMulticastLock(const jni::jhobject &wakelock) : CJNIBase(wakelock){};
+  ~CJNIWifiManagerMulticastLock(){};
+  void acquire();
+  void release();
+  void setReferenceCounted(bool refCounted);
+  bool isHeld();
+  std::string toString();
+private:
+  CJNIWifiManagerMulticastLock();
+};
index 30d3514..df1df1e 100644 (file)
@@ -72,8 +72,49 @@ std::string jcast_helper<std::string, jstring>::cast(jstring const &v)
 jhstring jcast_helper<jhstring, std::string>::cast(const std::string &s)
 {
     JNIEnv *env = xbmc_jnienv();
-    jstring obj = env->NewStringUTF(s.c_str());
-    return jhstring(obj);
+    jstring ret = NULL;
+    if (!s.empty())
+    {
+      ret = env->NewStringUTF(s.c_str());
+    }
+    return jhstring(ret);
+}
+
+jhobjectArray jcast_helper<jhobjectArray, std::vector<std::string> >::cast(const std::vector<std::string> &s)
+{
+  JNIEnv *env = xbmc_jnienv();
+  jobjectArray ret = NULL;
+  if (!s.empty())
+  {
+    ret = env->NewObjectArray(s.size(), env->FindClass("java/lang/String"), NULL);
+    for (unsigned int i = 0; i < s.size(); i++)
+    env->SetObjectArrayElement(ret, i, env->NewStringUTF(s[i].c_str()));
+  }
+  return jhobjectArray(ret);
+}
+
+std::vector<std::string> jcast_helper<std::vector<std::string>, jobjectArray >::cast(const jobjectArray &s)
+{
+  JNIEnv *env = xbmc_jnienv();
+  std::vector<std::string> ret;
+  jstring element;
+  const char* newString = NULL;
+  if (!s)
+    return ret;
+
+  unsigned int arraySize = env->GetArrayLength(s);
+  ret.reserve(arraySize);
+  for (unsigned int i = 0; i < arraySize; ++i)
+  {
+    element = (jstring) env->GetObjectArrayElement(s, i);
+    newString = env->GetStringUTFChars(element, JNI_FALSE);
+    if (newString)
+    {
+      ret.push_back(newString);
+      env->ReleaseStringUTFChars(element, newString);
+    }
+  }
+  return ret;
 }
 
 #define CRYSTAX_PP_CAT(a, b, c) CRYSTAX_PP_CAT_IMPL(a, b, c)
@@ -149,7 +190,7 @@ jhobject new_object(JNIEnv *env, jclass cls, jmethodID mid, ...)
 template <typename T>
 struct result_helper
 {
-    static T make_result(JNIEnv *env, T obj) {return obj;}
+    static T make_result(JNIEnv *env, T obj) {(void)env; return obj;}
 };
 
 template <typename T>
index 8cce848..f3d0e5c 100644 (file)
@@ -66,12 +66,24 @@ struct jcast_helper<std::string, jstring>
 };
 
 template <>
+struct jcast_helper<std::vector<std::string>, jobjectArray>
+{
+    static std::vector<std::string> cast(jobjectArray const &v);
+};
+
+template <>
 struct jcast_helper<jhstring, std::string>
 {
     static jhstring cast(const std::string &v);
 };
 
 template <>
+struct jcast_helper<jhobjectArray, std::vector<std::string> >
+{
+    static jhobjectArray cast(const std::vector<std::string> &v);
+};
+
+template <>
 struct jcast_helper<std::string, jhstring>
 {
     static std::string cast(jhstring const &v)
@@ -80,6 +92,15 @@ struct jcast_helper<std::string, jhstring>
     }
 };
 
+template <>
+struct jcast_helper<std::vector<std::string>, jhobjectArray>
+{
+    static std::vector<std::string> cast(jhobjectArray const &v)
+    {
+        return jcast_helper<std::vector<std::string>, jobjectArray>::cast(v);
+    }
+};
+
 
 } // namespace details
 
@@ -391,12 +412,18 @@ Ret get_field(const char *clsname, const char *name)
 */
 // Get static field
 
-template <typename Ret, typename T>
-Ret get_static_field(JNIEnv *env, jholder<T> const &obj, const char *name, const char *signature)
+template <typename Ret>
+Ret get_static_field(JNIEnv *env, jhobject const &obj, const char *name, const char *signature)
 {
     return details::jni_helper<Ret>::get_static_field(env, get_class(env, obj), get_static_field_id(env, obj, name, signature));
 }
 
+template <typename Ret>
+Ret get_static_field(JNIEnv *env, jhclass const &cls, const char *name, const char *signature)
+{
+    return details::jni_helper<Ret>::get_static_field(env, cls, get_static_field_id(env, cls, name, signature));
+}
+
 template <typename Ret, typename T>
 Ret get_static_field(jholder<T> const &obj, const char *name, const char *signature)
 {
index 9b8f9c1..ce1c6da 100644 (file)
@@ -234,7 +234,7 @@ CEncoder* CCDDARipJob::SetupEncoder(CFile& reader)
 CStdString CCDDARipJob::SetupTempFile()
 {
   char tmp[MAX_PATH];
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   GetTempFileName(CSpecialProtocol::TranslatePath("special://temp/"), "riptrack", 0, tmp);
 #else
   int fd;
index adb2c08..865165f 100644 (file)
@@ -52,6 +52,7 @@ public:
   virtual const char* GetType() const { return "cdrip"; };
   virtual bool operator==(const CJob *job) const;
   virtual bool DoWork();
+  CStdString GetOutput() const { return m_output; }
 protected:
   //! \brief Setup the audio encoder
   CEncoder* SetupEncoder(XFILE::CFile& reader);
index eb873e8..1078cdb 100644 (file)
@@ -44,6 +44,9 @@
 #include "utils/log.h"
 #include "utils/TimeUtils.h"
 #include "utils/URIUtils.h"
+#include "settings/MediaSourceSettings.h"
+#include "Application.h"
+#include "music/MusicDatabase.h"
 
 using namespace std;
 using namespace XFILE;
@@ -56,6 +59,7 @@ CCDDARipper& CCDDARipper::GetInstance()
 }
 
 CCDDARipper::CCDDARipper()
+  : CJobQueue(false, 1) //enforce fifo and non-parallel processing
 {
 }
 
@@ -67,7 +71,7 @@ CCDDARipper::~CCDDARipper()
 bool CCDDARipper::RipTrack(CFileItem* pItem)
 {
   // don't rip non cdda items
-  if (URIUtils::GetExtension(pItem->GetPath()).CompareNoCase(".cdda") != 0)
+  if (!URIUtils::HasExtension(pItem->GetPath(), ".cdda"))
   {
     CLog::Log(LOGDEBUG, "cddaripper: file is not a cdda track");
     return false;
@@ -182,7 +186,7 @@ bool CCDDARipper::CreateAlbumDir(const MUSIC_INFO::CMusicInfoTag& infoTag, CStdS
   CFileItem ripPath(strDirectory, true);
   if (ripPath.IsSmb())
     legalType = LEGAL_WIN32_COMPAT;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if (ripPath.IsHD())
     legalType = LEGAL_WIN32_COMPAT;
 #endif
@@ -303,7 +307,22 @@ CStdString CCDDARipper::GetTrackName(CFileItem *item)
 void CCDDARipper::OnJobComplete(unsigned int jobID, bool success, CJob* job)
 {
   if (success)
+  {
+    if(CJobQueue::QueueEmpty())
+    {
+      CStdString dir;
+      URIUtils::GetDirectory(((CCDDARipJob*)job)->GetOutput(), dir);
+      bool unimportant;
+      int source = CUtil::GetMatchingSource(dir, *CMediaSourceSettings::Get().CMediaSourceSettings::GetSources("music"), unimportant);
+
+      CMusicDatabase database;
+      database.Open();
+      if (source>=0 && database.InsideScannedPath(dir))
+        g_application.StartMusicScan(dir);
+      database.Close();
+    }
     return CJobQueue::OnJobComplete(jobID, success, job);
+  }
 
   CancelJobs();
 }
index 72b212e..eaf6cdb 100644 (file)
@@ -20,7 +20,7 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 #include <ogg/ogg.h>
index f0a857f..fbe63de 100644 (file)
@@ -20,7 +20,7 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 #include <vorbis/vorbisenc.h>
index 5d5febe..5ed160a 100644 (file)
@@ -20,7 +20,7 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 #include <vorbis/vorbisenc.h>
index 30c9be3..6fbb3b5 100644 (file)
@@ -24,7 +24,7 @@
 #ifndef __STDC_LIMIT_MACROS
 #define __STDC_LIMIT_MACROS
 #endif
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "stdint.h"
 #else
 #define INT64_C __int64
index a1b359b..d368404 100644 (file)
@@ -22,7 +22,7 @@
 #include "settings/Settings.h"
 #include "utils/log.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 extern "C" FILE *fopen_utf8(const char *_Filename, const char *_Mode);
 #else
 #define fopen_utf8 fopen
index 3ece4ad..9f980f8 100644 (file)
@@ -160,7 +160,7 @@ void CAESinkNULL::Process()
       // an approximate sleep time.
       int frames_written = read_bytes / m_sink_frameSize;
       double empty_ms = 1000.0 * (double)frames_written / m_format.m_sampleRate;
-      #if defined(_LINUX)
+      #if defined(TARGET_POSIX)
         usleep(empty_ms * 1000.0);
       #else
         Sleep((int)empty_ms);
index 16bb459..058671c 100644 (file)
@@ -26,7 +26,7 @@
 #include <limits>
 #include "utils/log.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 extern "C" FILE *fopen_utf8(const char *_Filename, const char *_Mode);
 #else
 #define fopen_utf8 fopen
@@ -49,7 +49,7 @@ extern "C" FILE *fopen_utf8(const char *_Filename, const char *_Mode);
 typedef BOOL (APIENTRY *EntryFunc)(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
 
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 /*
  * This is a dirty hack.
  * The win32 DLLs contain an alloca routine, that first probes the soon
@@ -667,7 +667,7 @@ bool DllLoader::Load()
     /* since we are handing execution over to unknown code, safeguard here */
     try
     {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
        extend_stack_for_dll_alloca();
 #endif
       initdll((HINSTANCE)hModule, DLL_PROCESS_ATTACH , 0); //call "DllMain" with DLL_PROCESS_ATTACH
index 434ad64..16079bf 100644 (file)
@@ -106,5 +106,5 @@ protected:
   char* ResolveReferencedDll(char* dll);
   int LoadExports();
   void LoadSymbols();
-  void UnloadSymbols();
+  static void UnloadSymbols();
 };
index 49ed07e..0594fa1 100644 (file)
  */
 
 #include "DllLoaderContainer.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "SoLoader.h"
 #endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "Win32DllLoader.h"
 #endif
 #include "DllLoader.h"
@@ -142,7 +142,7 @@ LibraryLoader* DllLoaderContainer::FindModule(const char* sName, const char* sCu
   { //  Has a path, just try to load
     return LoadDll(sName, bLoadSymbols);
   }
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   else if (strcmp(sName, "xbmc.so") == 0)
     return LoadDll(sName, bLoadSymbols);
 #endif
@@ -238,12 +238,12 @@ LibraryLoader* DllLoaderContainer::LoadDll(const char* sName, bool bLoadSymbols)
 #endif
 
   LibraryLoader* pLoader;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   if (strstr(sName, ".so") != NULL || strstr(sName, ".vis") != NULL || strstr(sName, ".xbs") != NULL
       || strstr(sName, ".mvis") != NULL || strstr(sName, ".dylib") != NULL || strstr(sName, ".framework") != NULL || strstr(sName, ".pvr") != NULL)
     pLoader = new SoLoader(sName, bLoadSymbols);
   else
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
   if (1)
     pLoader = new Win32DllLoader(sName);
   else
index 0f2a1b7..3ab8a41 100644 (file)
@@ -22,7 +22,7 @@
 #define LIBRARY_LOADER
 
 #include "system.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "PlatformDefs.h"
 #endif
 
index 859dd27..4f9ea73 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <stdio.h>
 #include "system.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "PlatformDefs.h"
 #endif
 #include "DllLoader.h"
index 6d13e81..003aa02 100644 (file)
@@ -49,8 +49,8 @@ public:
 private:
   void OverrideImports(const CStdString &dll);
   void RestoreImports();
-  bool ResolveImport(const char *dllName, const char *functionName, void **fixup);
-  bool ResolveOrdinal(const char *dllName, unsigned long ordinal, void **fixup);
+  static bool ResolveImport(const char *dllName, const char *functionName, void **fixup);
+  static bool ResolveOrdinal(const char *dllName, unsigned long ordinal, void **fixup);
   bool NeedsHooking(const char *dllName);
 
   HMODULE m_dllHandle;
index ab54263..4652ee0 100644 (file)
@@ -77,7 +77,7 @@ CoffLoader::~CoffLoader()
 {
   if ( hModule )
   {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
     free(hModule);
 #else
     VirtualFree(hModule, 0, MEM_RELEASE);
@@ -209,7 +209,7 @@ int CoffLoader::LoadCoffHModule(FILE *fp)
     return 0;
 
   // alloc aligned memory
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   hModule = malloc(tempWindowsHeader.SizeOfImage);
 #else
   hModule = VirtualAllocEx(0, (PVOID)tempWindowsHeader.ImageBase, tempWindowsHeader.SizeOfImage, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
index 41ffebb..a8a3240 100644 (file)
@@ -350,7 +350,7 @@ typedef struct
 }
 SymbolTable_t;
 
-#if !defined(_WIN32)
+#if !defined(TARGET_WINDOWS)
 
 #define IMAGE_SYM_UNDEFINED     0
 #define IMAGE_SYM_ABSOLUTE      0xFFFF
index 7315897..28427ae 100644 (file)
@@ -257,7 +257,7 @@ extern "C" DWORD WINAPI dllGetModuleFileNameA(HMODULE hModule, LPSTR lpFilename,
 {
   if (NULL == hModule)
   {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
     return GetModuleFileNameA(hModule, lpFilename, nSize);
 #else
     CLog::Log(LOGDEBUG, "%s - No hModule specified", __FUNCTION__);
index 70b54db..aaaf765 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "threads/CriticalSection.h"
 #include "PlatformDefs.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "system.h" // for SOCKET
 #endif
 
@@ -128,7 +128,7 @@ DllTrackInfo* tracker_get_dlltrackinfo(uintptr_t caller);
 
 void tracker_dll_data_track(DllLoader* pDll, uintptr_t addr);
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #define _ReturnAddress() __builtin_return_address(0)
 #endif
 
@@ -136,7 +136,7 @@ void tracker_dll_data_track(DllLoader* pDll, uintptr_t addr);
 }
 #endif
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 extern "C" void * _ReturnAddress(void);
 #pragma intrinsic(_ReturnAddress)
 #endif
index 25f29c5..67b8ab5 100644 (file)
@@ -24,7 +24,7 @@
 #include "threads/SingleLock.h"
 #include "utils/log.h"
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #define dll_open open
 #define dll_fopen fopen
 #define dll_close close
index c4bcf3b..32f724b 100644 (file)
@@ -21,7 +21,7 @@
 #include "utils/log.h"
 #include "dll_util.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include <windows.h>
 #endif
 #include <stdlib.h>
@@ -102,7 +102,7 @@ uintptr_t create_dummy_function(const char* strDllName, const char* strFunctionN
 
 uintptr_t get_win_function_address(const char* strDllName, const char* strFunctionName)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   HMODULE handle = GetModuleHandle(strDllName);
   if(handle == NULL)
   {
index e555279..560e699 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "storage/IoSupport.h"
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #include <process.h>
 #include "utils/CharsetConverter.h"
 #endif
@@ -32,7 +32,7 @@
 #include "../dll_tracker.h"
 #include "filesystem/SpecialProtocol.h"
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "../../../linux/PlatformInclude.h"
 #define __except catch
 #endif
@@ -82,7 +82,7 @@ extern "C" BOOL WINAPI dllFindClose(HANDLE hFile)
   return FindClose(hFile);
 }
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #define CORRECT_SEP_STR(str) \
   if (strstr(str, "://") == NULL) \
   { \
@@ -100,7 +100,7 @@ extern "C" BOOL WINAPI dllFindClose(HANDLE hFile)
 #define CORRECT_SEP_STR(str)
 #endif
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 static void to_WIN32_FIND_DATA(LPWIN32_FIND_DATAW wdata, LPWIN32_FIND_DATA data)
 {
   CStdString strname;
@@ -164,7 +164,7 @@ extern "C" HANDLE WINAPI dllFindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA
     e[0] = '\0';
   }
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   struct _WIN32_FIND_DATAW FindFileDataW;
   CStdStringW strwfile;
   g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(p), strwfile, false);
@@ -180,7 +180,7 @@ extern "C" HANDLE WINAPI dllFindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA
 
 extern "C" BOOL WINAPI dllFindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   struct _WIN32_FIND_DATAW FindFileDataW;
   to_WIN32_FIND_DATAW(lpFindFileData, &FindFileDataW);
   BOOL res = FindNextFileW(hFindFile, &FindFileDataW);
@@ -208,7 +208,7 @@ extern "C" DWORD WINAPI dllGetFileAttributesA(LPCSTR lpFileName)
   }
   else strcpy(str, lpFileName);
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   // convert '/' to '\\'
   char *p = str;
   while (p = strchr(p, '/')) * p = '\\';
@@ -225,7 +225,7 @@ extern "C" void WINAPI dllSleep(DWORD dwTime)
 
 extern "C" DWORD WINAPI dllGetCurrentProcessId(void)
 {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   return (DWORD)getppid();
 #else
   return GetCurrentProcessId();
@@ -246,7 +246,7 @@ extern "C" int WINAPI dllDuplicateHandle(HANDLE hSourceProcessHandle,   // handl
             hSourceProcessHandle, hSourceHandle, hTargetProcessHandle,
             lpTargetHandle, dwDesiredAccess, bInheritHandle, dwOptions);
 #endif
-#if defined (_LINUX)
+#if defined (TARGET_POSIX)
   *lpTargetHandle = hSourceHandle;
   return 1;
 #else
@@ -256,7 +256,7 @@ extern "C" int WINAPI dllDuplicateHandle(HANDLE hSourceProcessHandle,   // handl
 
 extern "C" BOOL WINAPI dllDisableThreadLibraryCalls(HMODULE h)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   return DisableThreadLibraryCalls(h);
 #else
   not_implement("kernel32.dll fake function DisableThreadLibraryCalls called\n"); //warning
@@ -264,7 +264,7 @@ extern "C" BOOL WINAPI dllDisableThreadLibraryCalls(HMODULE h)
 #endif
 }
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 static void DumpSystemInfo(const SYSTEM_INFO* si)
 {
   CLog::Log(LOGDEBUG, "  Processor architecture %d\n", si->wProcessorArchitecture);
@@ -285,7 +285,7 @@ extern "C" void WINAPI dllGetSystemInfo(LPSYSTEM_INFO lpSystemInfo)
 #ifdef API_DEBUG
   CLog::Log(LOGDEBUG, "GetSystemInfo(0x%x) =>", lpSystemInfo);
 #endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   // VS 2003 complains about x even so it's defined
   lpSystemInfo->wProcessorArchitecture = 0; //#define PROCESSOR_ARCHITECTURE_INTEL 0
 #else
@@ -406,7 +406,7 @@ extern "C" HMODULE WINAPI dllTerminateProcess(HANDLE hProcess, UINT uExitCode)
 }
 extern "C" HANDLE WINAPI dllGetCurrentProcess()
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   return GetCurrentProcess();
 #else
 #ifdef API_DEBUG
@@ -492,7 +492,7 @@ static const char ch_envs[] =
 
 extern "C" LPVOID WINAPI dllGetEnvironmentStrings()
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   return GetEnvironmentStrings();
 #else
 #ifdef API_DEBUG
@@ -504,7 +504,7 @@ extern "C" LPVOID WINAPI dllGetEnvironmentStrings()
 
 extern "C" LPVOID WINAPI dllGetEnvironmentStringsW()
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   return GetEnvironmentStringsW();
 #else  
   return 0;
@@ -513,7 +513,7 @@ extern "C" LPVOID WINAPI dllGetEnvironmentStringsW()
 
 extern "C" int WINAPI dllGetEnvironmentVariableA(LPCSTR lpName, LPSTR lpBuffer, DWORD nSize)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   return GetEnvironmentVariableA(lpName, lpBuffer, nSize);
 #else
   if (lpBuffer)
@@ -580,7 +580,7 @@ extern "C" BOOL WINAPI dllSetPriorityClass(HANDLE hProcess, DWORD dwPriorityClas
 
 extern "C" DWORD WINAPI dllFormatMessageA(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPTSTR lpBuffer, DWORD nSize, va_list* Arguments)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   return FormatMessageA(dwFlags, lpSource, dwMessageId, dwLanguageId, lpBuffer, nSize, Arguments);
 #else
   not_implement("kernel32.dll fake function FormatMessage called\n"); //warning
@@ -590,7 +590,7 @@ extern "C" DWORD WINAPI dllFormatMessageA(DWORD dwFlags, LPCVOID lpSource, DWORD
 
 extern "C" DWORD WINAPI dllGetFullPathNameA(LPCTSTR lpFileName, DWORD nBufferLength, LPTSTR lpBuffer, LPTSTR* lpFilePart)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if (!lpFileName) return 0;
   if(strstr(lpFileName, "://"))
   {
@@ -623,7 +623,7 @@ extern "C" DWORD WINAPI dllGetFullPathNameA(LPCTSTR lpFileName, DWORD nBufferLen
 
 extern "C" DWORD WINAPI dllGetFullPathNameW(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR* lpFilePart)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if (!lpFileName) return 0;
   if(wcsstr(lpFileName, L"://"))
   {
@@ -656,7 +656,7 @@ extern "C" DWORD WINAPI dllGetFullPathNameW(LPCWSTR lpFileName, DWORD nBufferLen
 
 extern "C" DWORD WINAPI dllExpandEnvironmentStringsA(LPCTSTR lpSrc, LPTSTR lpDst, DWORD nSize)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   return ExpandEnvironmentStringsA(lpSrc, lpDst, nSize);
 #else
   not_implement("kernel32.dll fake function ExpandEnvironmentStringsA called\n"); //warning
@@ -703,7 +703,7 @@ extern "C" UINT WINAPI dllGetShortPathName(LPTSTR lpszLongPath, LPTSTR lpszShort
 
 extern "C" HANDLE WINAPI dllGetProcessHeap()
 {
-#ifdef  _LINUX
+#ifdef  TARGET_POSIX
   CLog::Log(LOGWARNING, "KERNEL32!GetProcessHeap() linux cant provide this service!");
   return 0;
 #else
@@ -878,7 +878,7 @@ extern "C" int WINAPI dllMultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCST
     destinationBuffer = (LPWSTR)malloc(destinationBufferSize * sizeof(WCHAR));
   }
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   int ret = MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, destinationBuffer, destinationBufferSize);
 #else
   int ret = 0;
@@ -922,7 +922,7 @@ extern "C" int WINAPI dllWideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWS
     destinationBuffer = (LPSTR)malloc(destinationBufferSize * sizeof(char));
   }
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   int ret = WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, destinationBuffer, destinationBufferSize, lpDefaultChar, lpUsedDefaultChar);
 #else
   int ret = 0;
@@ -954,7 +954,7 @@ extern "C" int WINAPI dllWideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWS
 
 extern "C" UINT WINAPI dllSetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine, BOOL Add)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   return SetConsoleCtrlHandler(HandlerRoutine, Add);
 #else
   // no consoles exists on the xbox, do nothing
@@ -1066,7 +1066,7 @@ extern "C" BOOL WINAPI dllDVDReadFileLayerChangeHack(HANDLE hFile, LPVOID lpBuff
       p++;
     if (p == (BYTE *)lpBuffer + numChecked)
     { // fully NULL block - reread
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
       LONG low = 0;
       LONG high = 0;
 #else
@@ -1091,7 +1091,7 @@ extern "C" BOOL WINAPI dllDVDReadFileLayerChangeHack(HANDLE hFile, LPVOID lpBuff
 
 extern "C" LPVOID WINAPI dllLockResource(HGLOBAL hResData)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   return LockResource(hResData);
 #else
   not_implement("kernel32.dll fake function LockResource called\n"); //warning
@@ -1101,7 +1101,7 @@ extern "C" LPVOID WINAPI dllLockResource(HGLOBAL hResData)
 
 extern "C" SIZE_T WINAPI dllGlobalSize(HGLOBAL hMem)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   return GlobalSize(hMem);
 #else
   not_implement("kernel32.dll fake function GlobalSize called\n"); //warning
@@ -1111,7 +1111,7 @@ extern "C" SIZE_T WINAPI dllGlobalSize(HGLOBAL hMem)
 
 extern "C" DWORD WINAPI dllSizeofResource(HMODULE hModule, HRSRC hResInfo)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   return SizeofResource(hModule, hResInfo);
 #else
   not_implement("kernel32.dll fake function SizeofResource called\n"); //warning
index c71c355..6672c81 100644 (file)
@@ -27,7 +27,7 @@
 #define MAX_LEADBYTES             12
 #define MAX_DEFAULTCHAR           2
 
-#if defined (_LINUX)
+#if defined (TARGET_POSIX)
 typedef struct _STARTUPINFOA
 {
   DWORD cb;
@@ -90,7 +90,7 @@ SYSTEM_INFO, *LPSYSTEM_INFO;
 #endif
 
 typedef DWORD LCTYPE;
-#if defined (_LINUX)
+#if defined (TARGET_POSIX)
 typedef BOOL (*PHANDLER_ROUTINE)(DWORD);
 
 typedef struct _OSVERSIONINFO
@@ -115,7 +115,7 @@ typedef struct _OSVERSIONINFOW
 }
 OSVERSIONINFOW, *LPOSVERSIONINFOW;
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #define EXCEPTION_MAXIMUM_PARAMETERS 15
 typedef struct _EXCEPTION_RECORD {
   DWORD ExceptionCode;
@@ -132,7 +132,7 @@ typedef struct _EXCEPTION_RECORD {
 
 #endif
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #define LANG_ENGLISH 0x09
 #define SUBLANG_ENGLISH_US 0x01
 #define MAKELCID(lgid, srtid)  ((DWORD)((((DWORD)((WORD  )(srtid))) << 16) | ((DWORD)((WORD  )(lgid)))))
@@ -175,7 +175,7 @@ typedef struct _EXCEPTION_RECORD {
 // LOCAL defines from mingw
 #define MAX_LEADBYTES  12
 #define MAX_DEFAULTCHAR        2
-#if defined (_LINUX)
+#if defined (TARGET_POSIX)
 #define LOCALE_NOUSEROVERRIDE  0x80000000
 #define LOCALE_USE_CP_ACP      0x40000000
 #if (WINVER >= 0x0400)
index 10c61ef..1f46d5a 100644 (file)
 #include <stdlib.h>
 #include <stdio.h>
 #include <math.h>
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #include <io.h>
 #include <direct.h>
 #include <process.h>
 #else
-#if !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD)
 #include <mntent.h>
 #endif
 #endif
 #include <sys/stat.h>
 #include <sys/types.h>
-#if !defined(__FreeBSD__)
+#if !defined(TARGET_FREEBSD)
 #include <sys/timeb.h>
 #endif
 #include "system.h" // for HAS_DVD_DRIVE
 #ifdef HAS_DVD_DRIVE
-  #ifdef _LINUX
+  #ifdef TARGET_POSIX
     #include <sys/ioctl.h>
     #if defined(TARGET_DARWIN)
       #include <IOKit/storage/IODVDMediaBSDClient.h>
-    #elif !defined(__FreeBSD__)
+    #elif !defined(TARGET_FREEBSD)
       #include <linux/cdrom.h>
     #endif
   #endif
@@ -49,7 +49,7 @@
 #include <fcntl.h>
 #include <time.h>
 #include <signal.h>
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "PlatformDefs.h" // for __stat64
 #endif
 #include "Util.h"
 #include "util/EmuFileWrapper.h"
 #include "utils/log.h"
 #include "threads/SingleLock.h"
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #include "utils/CharsetConverter.h"
 #include "utils/URIUtils.h"
 #endif
 #if defined(TARGET_ANDROID)
 #include "android/loader/AndroidDyload.h"
-#elif !defined(_WIN32)
+#elif !defined(TARGET_WINDOWS)
 #include <dlfcn.h>
 #endif
+#include "utils/Environment.h"
+
 using namespace std;
 using namespace XFILE;
 
-#if defined(_MSC_VER) && _MSC_VER < 1500
-extern "C" {
-  __int64 __cdecl _ftelli64(FILE *);
-  int __cdecl _fseeki64(FILE *, __int64, int);
-}
-#endif
-
 struct SDirData
 {
   CFileItemList items;
@@ -118,7 +113,7 @@ extern "C" void __stdcall init_emu_environ()
   memset(dll__environ, 0, EMU_MAX_ENVIRONMENT_ITEMS + 1);
 
   // python
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
   // fill our array with the windows system vars
   LPTSTR lpszVariable; 
   LPTCH lpvEnv;
@@ -136,7 +131,7 @@ extern "C" void __stdcall init_emu_environ()
   dll_putenv("OS=win32");
 #elif defined(TARGET_DARWIN)
   dll_putenv("OS=darwin");
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
   dll_putenv("OS=linux");
 #else
   dll_putenv("OS=unknown");
@@ -216,13 +211,8 @@ extern "C" void __stdcall update_emu_environ()
     strProxy += CSettings::Get().GetString("network.httpproxyserver");
     strProxy += ":" + CSettings::Get().GetString("network.httpproxyport");
 
-#ifdef _WIN32
-    pgwin32_putenv(("HTTP_PROXY=http://" +strProxy).c_str());
-    pgwin32_putenv(("HTTPS_PROXY=http://" +strProxy).c_str());
-#else
-    setenv( "HTTP_PROXY", "http://" + strProxy, true );
-    setenv( "HTTPS_PROXY", "http://" + strProxy, true );
-#endif
+    CEnvironment::setenv( "HTTP_PROXY", "http://" + strProxy, true );
+    CEnvironment::setenv( "HTTPS_PROXY", "http://" + strProxy, true );
   }
   else
   {
@@ -247,7 +237,7 @@ static int convert_fmode(const char* mode)
   return iMode;
 }
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 static void to_finddata64i32(_wfinddata64i32_t *wdata, _finddata64i32_t *data)
 {
   CStdString strname;
@@ -456,7 +446,7 @@ extern "C"
 #if defined(TARGET_ANDROID)
     CAndroidDyload temp;
     return temp.Open(filename);
-#elif !defined(_WIN32)
+#elif !defined(TARGET_WINDOWS)
     return dlopen(filename, flag);
 #else
     return NULL;
@@ -701,7 +691,7 @@ extern "C"
     else if (!IS_STD_STREAM(stream))
     {
       // it might be something else than a file, let the operating system handle it
-#ifdef _LINUX
+#ifdef TARGET_POSIX
       flockfile(stream);
       return;
 #else
@@ -723,7 +713,7 @@ extern "C"
     else if (!IS_STD_STREAM(stream))
     {
       // it might be something else than a file, let the operating system handle it
-#ifdef _LINUX
+#ifdef TARGET_POSIX
       return ftrylockfile(stream);
 #else
       CLog::Log(LOGERROR, "%s: ftrylockfile not available on non-linux platforms",  __FUNCTION__);
@@ -744,7 +734,7 @@ extern "C"
     else if (!IS_STD_STREAM(stream))
     {
       // it might be something else than a file, let the operating system handle it
-#ifdef _LINUX
+#ifdef TARGET_POSIX
       funlockfile(stream);
       return;
 #else
@@ -770,7 +760,7 @@ extern "C"
     return EOF;
   }
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   // should be moved to CFile classes
   intptr_t dll_findfirst(const char *file, struct _finddata_t *data)
   {
@@ -1188,7 +1178,7 @@ extern "C"
   FILE* dll_fopen(const char* filename, const char* mode)
   {
     FILE* file = NULL;
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__) && !defined(__ANDROID__)
+#if defined(TARGET_LINUX) && !defined(TARGET_ANDROID)
     if (strcmp(filename, MOUNTED) == 0
     ||  strcmp(filename, MNTTAB) == 0)
     {
@@ -1296,7 +1286,7 @@ extern "C"
     {
       // it might be something else than a file, or the file is not emulated
       // let the operating system handle it
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
       return fseek(stream, offset, origin);
 #else
       return fseeko64(stream, offset, origin);
@@ -1361,7 +1351,7 @@ extern "C"
     {
       // it might be something else than a file, or the file is not emulated
       // let the operating system handle it
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
       return ftello(stream);
 #else
       return ftello64(stream);
@@ -1382,7 +1372,7 @@ extern "C"
     {
       // it might be something else than a file, or the file is not emulated
       // let the operating system handle it
-#ifndef _LINUX
+#ifndef TARGET_POSIX
       return tell(fd);
 #else
       return lseek(fd, 0, SEEK_CUR);
@@ -1405,9 +1395,9 @@ extern "C"
       // let the operating system handle it
       // not supported return telli64(fd);
       CLog::Log(LOGWARNING, "msvcrt.dll: dll_telli64 called, TODO: add 'int64 -> long' type checking");      //warning
-#ifndef _LINUX
+#ifndef TARGET_POSIX
       return (__int64)tell(fd);
-#elif defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#elif defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
       return lseek(fd, 0, SEEK_CUR);
 #else
       return lseek64(fd, 0, SEEK_CUR);
@@ -1581,7 +1571,7 @@ extern "C"
     int ret;
 
     ret = dll_fgetpos64(stream, &tmpPos);
-#if !defined(_LINUX) || defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if !defined(TARGET_POSIX) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
     *pos = (fpos_t)tmpPos;
 #else
     pos->__pos = (off_t)tmpPos.__pos;
@@ -1594,7 +1584,7 @@ extern "C"
     CFile* pFile = g_emuFileWrapper.GetFileXbmcByStream(stream);
     if (pFile != NULL)
     {
-#if !defined(_LINUX) || defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if !defined(TARGET_POSIX) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
       *pos = pFile->GetPosition();
 #else
       pos->__pos = pFile->GetPosition();
@@ -1616,7 +1606,7 @@ extern "C"
     int fd = g_emuFileWrapper.GetDescriptorByStream(stream);
     if (fd >= 0)
     {
-#if !defined(_LINUX) || defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if !defined(TARGET_POSIX) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
       if (dll_lseeki64(fd, *pos, SEEK_SET) >= 0)
 #else
       if (dll_lseeki64(fd, (__off64_t)pos->__pos, SEEK_SET) >= 0)
@@ -1633,7 +1623,7 @@ extern "C"
     {
       // it might be something else than a file, or the file is not emulated
       // let the operating system handle it
-#if !defined(_LINUX) || defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if !defined(TARGET_POSIX) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
       return fsetpos(stream, pos);
 #else
       return fsetpos64(stream, pos);
@@ -1649,7 +1639,7 @@ extern "C"
     if (fd >= 0)
     {
       fpos64_t tmpPos;
-#if !defined(_LINUX) || defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if !defined(TARGET_POSIX) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
       tmpPos= *pos;
 #else
       tmpPos.__pos = (off64_t)(pos->__pos);
@@ -1735,7 +1725,7 @@ extern "C"
     if (!strnicmp(path, "mms://", 6)) // don't stat mms
       return -1;
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
     if (!_stricmp(path, "D:") || !_stricmp(path, "D:\\"))
     {
       buffer->st_mode = S_IFDIR;
@@ -1781,7 +1771,7 @@ extern "C"
     if (!strnicmp(path, "mms://", 6)) // don't stat mms
       return -1;
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
     if (!_stricmp(path, "D:") || !_stricmp(path, "D:\\"))
     {
       buffer->st_mode = _S_IFDIR;
@@ -1797,7 +1787,7 @@ extern "C"
     return CFile::Stat(path, buffer);
   }
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   int dll_stat64i32(const char *path, struct _stat64i32 *buffer)
   {
     struct __stat64 a;
@@ -1861,7 +1851,7 @@ extern "C"
     return -1;
   }
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   int dll_fstat64i32(int fd, struct _stat64i32 *buffer)
   {
     CFile* pFile = g_emuFileWrapper.GetFileXbmcByDescriptor(fd);
@@ -1921,7 +1911,7 @@ extern "C"
 
     // Make sure the slashes are correct & translate the path
     CStdString strPath = CUtil::ValidatePath(CSpecialProtocol::TranslatePath(dir));
-#ifndef _LINUX
+#ifndef TARGET_POSIX
     CStdStringW strWPath;
     g_charsetConverter.utf8ToW(strPath, strWPath, false);
     return _wmkdir(strWPath.c_str());
@@ -2060,7 +2050,7 @@ extern "C"
 
   void (__cdecl * dll_signal(int sig, void (__cdecl *func)(int)))(int)
   {
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
     //vs2008 asserts for known signals, return err for everything unknown to windows.
     if (sig == 5 || sig == 7 || sig == 9 || sig == 10 || sig == 12 || sig == 14 || sig == 18 || sig == 19 || sig == 20)
       return SIG_ERR;
@@ -2085,7 +2075,7 @@ extern "C"
     {
       // it might be something else than a file, or the file is not emulated
       // let the operating system handle it
-#ifndef _LINUX
+#ifndef TARGET_POSIX
       return _commit(fd);
 #else
       return fsync(fd);
@@ -2102,8 +2092,8 @@ extern "C"
     return (char***)&t;
   }
 
-#ifdef _LINUX
-#if defined(__ANDROID__)
+#ifdef TARGET_POSIX
+#if defined(TARGET_ANDROID)
   volatile int * __cdecl dll_errno(void)
   {
     return &errno;
@@ -2122,7 +2112,7 @@ extern "C"
      if (!pFile)
        return -1;
 
-#if defined(HAS_DVD_DRIVE) && !defined(__FreeBSD__)
+#if defined(HAS_DVD_DRIVE) && !defined(TARGET_FREEBSD)
 #if !defined(TARGET_DARWIN)
     if(request == DVD_READ_STRUCT || request == DVD_AUTH)
 #else
@@ -2165,7 +2155,7 @@ extern "C"
       CLog::Log(LOGERROR, "%s - getmntent is not implemented for our virtual filesystem", __FUNCTION__);
       return NULL;
     }
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if defined(TARGET_LINUX)
     return getmntent(fp);
 #else
     CLog::Log(LOGWARNING, "%s - unimplemented function called", __FUNCTION__);
@@ -2190,7 +2180,7 @@ extern "C"
       else
         return 0;
     }
-#ifdef _LINUX
+#ifdef TARGET_POSIX
     return 0;
 #else
     return _filbuf(fp);
@@ -2219,24 +2209,18 @@ extern "C"
       else
         return 0;
     }
-#ifdef _LINUX
+#ifdef TARGET_POSIX
     return 0;
 #else
     return _flsbuf(data, fp);
 #endif
   }
-#if _MSC_VER <= 1310
-  long __cdecl _ftol2_sse(double d)
-  {
-    return (long)d;
-  }
-#endif
 
   // this needs to be wrapped, since dll's have their own file
   // descriptor list, but we always use app's list with our wrappers
   int __cdecl dll_open_osfhandle(intptr_t _OSFileHandle, int _Flags)
   {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
     return _open_osfhandle(_OSFileHandle, _Flags);
 #else
     return -1;
index 24cc93f..a3dc693 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef _EMU_MSVCRT_H_
 #define _EMU_MSVCRT_H_
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #define _onexit_t void*
 #endif
 
@@ -32,13 +32,13 @@ typedef int64_t off64_t;
 typedef off64_t __off64_t;
 typedef fpos_t fpos64_t;
 #endif
-#if defined(__ANDROID__)
+#if defined(TARGET_ANDROID)
 typedef long int __off_t;
 typedef long int __off64_t;
 typedef fpos_t   fpos64_t; // no 64-bit on android
 #endif
 
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
 #include "win32/dirent.h"
 #else
 #include <dirent.h>
@@ -52,7 +52,7 @@ typedef void ( *PFV)(void);
 #define IS_STDIN_STREAM(stream)     (stream != NULL && __IS_STDIN_STREAM(stream))
 #define IS_STDOUT_STREAM(stream)    (stream != NULL && __IS_STDOUT_STREAM(stream))
 #define IS_STDERR_STREAM(stream)    (stream != NULL && __IS_STDERR_STREAM(stream))
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #define IS_VALID_STREAM(stream)     (stream != NULL && (stream->_ptr != NULL))
 #else
 #define IS_VALID_STREAM(stream)     true
@@ -99,7 +99,7 @@ extern "C"
   __off_t dll_lseek(int fd, __off_t lPos, int iWhence);
   char* dll_getenv(const char* szKey);
   int dll_fclose (FILE * stream);
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   intptr_t dll_findfirst(const char *file, struct _finddata_t *data);
   int dll_findnext(intptr_t f, _finddata_t* data);
   int dll_findclose(intptr_t handle);
@@ -143,14 +143,14 @@ extern "C"
   uintptr_t dll_beginthread(void( *start_address )( void * ),unsigned stack_size,void *arglist);
   HANDLE dll_beginthreadex(LPSECURITY_ATTRIBUTES lpThreadAttributes, DWORD dwStackSize,
                            LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags,
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
                            LPLONG lpThreadId);
 #else
                            LPDWORD lpThreadId);
 #endif
   int dll_stati64(const char *path, struct _stati64 *buffer);
   int dll_stat64(const char *path, struct __stat64 *buffer);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   int dll_stat64i32(const char *path, struct _stat64i32 *buffer);
 #endif
   int dll_stat(const char *path, struct stat *buffer);
@@ -174,7 +174,7 @@ extern "C"
   int dll_ftrylockfile(FILE *file);
   void dll_funlockfile(FILE *file);
   int dll_fstat64(int fd, struct __stat64 *buf);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   int dll_fstat64i32(int fd, struct _stat64i32 *buffer);
   int dll_open_osfhandle(intptr_t _OSFileHandle, int _Flags);
 #endif
@@ -182,9 +182,9 @@ extern "C"
   int dll_filbuf(FILE *fp);
   int dll_flsbuf(int data, FILE*fp);
 
-#if defined(__ANDROID__)
+#if defined(TARGET_ANDROID)
   volatile int * __cdecl dll_errno(void);
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
   int * __cdecl dll_errno(void);
 #endif
 
index 58240bf..197f043 100644 (file)
  * SUCH DAMAGE.
  */
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include <windows.h>
 typedef unsigned long in_addr_t;
 #endif
 #include <stdlib.h>
 #include <ctype.h>
 #include <limits.h>
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
 #include <netinet/in.h>
 #endif
 
index 26ccce6..bf6fb7b 100644 (file)
@@ -27,7 +27,7 @@
 #include "system.h"
 #include "threads/CriticalSection.h"
 
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__) && !defined(__ANDROID__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD) && !defined(TARGET_ANDROID)
 #define _file _fileno
 #endif
 
@@ -69,10 +69,10 @@ public:
   EmuFileObject* GetFileObjectByStream(FILE* stream);  
   XFILE::CFile* GetFileXbmcByDescriptor(int fd);
   XFILE::CFile* GetFileXbmcByStream(FILE* stream);
-  int GetDescriptorByStream(FILE* stream);
+  static int GetDescriptorByStream(FILE* stream);
   FILE* GetStreamByDescriptor(int fd);
-  bool DescriptorIsEmulatedFile(int fd);
-  bool StreamIsEmulatedFile(FILE* stream);
+  static bool DescriptorIsEmulatedFile(int fd);
+  static bool StreamIsEmulatedFile(FILE* stream);
 private:
   EmuFileObject m_files[MAX_EMULATED_FILES];
   CCriticalSection m_criticalSection;
index 44b4048..016af32 100644 (file)
 //
 #include <sys/types.h>
 #include <sys/stat.h>
-#if !defined(__ANDROID__)
+#if !defined(TARGET_ANDROID)
 #include <sys/statvfs.h>
 #endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdarg.h>
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "win32-dirent.h"
 #else
 #include <dirent.h>
 #endif
 #include <dlfcn.h>
 
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
 typedef off_t     __off_t;
 typedef int64_t   off64_t;
 typedef off64_t   __off64_t;
@@ -50,7 +50,7 @@ typedef fpos_t    fpos64_t;
 #endif
 #endif
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #define _stat stat
 #endif
 
@@ -452,7 +452,7 @@ int __wrap_setvbuf(FILE *stream, char *buf, int type, size_t size)
 
 struct mntent *__wrap_getmntent(FILE *fp)
 {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   return dll_getmntent(fp);
 #endif
   return NULL;
index 07e3ff4..91c7a22 100644 (file)
@@ -48,7 +48,7 @@ extern "C" {
 #if defined(__GLIBC__) &&  (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0))
 _syscall3( int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount );
 #else
-#if defined(__ANDROID__) && defined(__i386__) && !defined(modify_ldt)
+#if defined(TARGET_ANDROID) && defined(__i386__) && !defined(modify_ldt)
 #define modify_ldt(a,b,c) syscall( __NR_modify_ldt,  a, b, c);
 #else
 int modify_ldt(int func, void *ptr, unsigned long bytecount);
@@ -58,7 +58,7 @@ int modify_ldt(int func, void *ptr, unsigned long bytecount);
 }
 #endif
 #else
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+#if defined(__NetBSD__) || defined(TARGET_FREEBSD) || defined(__OpenBSD__) || defined(__DragonFly__)
 #include <machine/segments.h>
 #include <machine/sysarch.h>
 #endif
@@ -112,7 +112,7 @@ struct modify_ldt_ldt_s {
 #define       LDT_SEL(idx) ((idx) << 3 | 1 << 2 | 3)
 
 /* i got this value from wine sources, it's the first free LDT entry */
-#if (defined(TARGET_DARWIN) || defined(__FreeBSD__)) && defined(LDT_AUTO_ALLOC)
+#if (defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)) && defined(LDT_AUTO_ALLOC)
 #define TEB_SEL_IDX LDT_AUTO_ALLOC
 #define USE_LDT_AA
 #endif
@@ -142,7 +142,7 @@ void Setup_FS_Segment(void)
   );
 }
 
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(TARGET_DARWIN)
+#if defined(__NetBSD__) || defined(TARGET_FREEBSD) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(TARGET_DARWIN)
 static void LDT_EntryToBytes( unsigned long *buffer, const struct modify_ldt_ldt_s *content )
 {
   *buffer++ = ((content->base_addr & 0x0000ffff) << 16) |
@@ -210,7 +210,7 @@ ldt_fs_t* Setup_LDT_Keeper(void)
   }
 #endif /*linux*/
 
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(TARGET_DARWIN)
+#if defined(__NetBSD__) || defined(TARGET_FREEBSD) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(TARGET_DARWIN)
   {
     unsigned long d[2];
 
@@ -232,7 +232,7 @@ ldt_fs_t* Setup_LDT_Keeper(void)
 #endif
     }
   }
-#endif  // __NetBSD__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || TARGET_DARWIN
+#endif  // __NetBSD__ || TARGET_FREEBSD || __OpenBSD__ || __DragonFly__ || TARGET_DARWIN
 
 #if defined(__svr4__)
   {
index 9191145..32805b4 100644 (file)
@@ -38,7 +38,7 @@
 #include "utils/TimeUtils.h"
 #include "utils/log.h"
 #include "cores/AudioEngine/AEFactory.h"
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
   #include "utils/CharsetConverter.h"
   #include "Windows.h"
   #ifdef HAS_IRSERVERSUITE
@@ -62,7 +62,7 @@
 
 using namespace XFILE;
 
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
 extern HWND g_hWnd;
 #endif
 
@@ -91,7 +91,7 @@ CExternalPlayer::CExternalPlayer(IPlayerCallback& callback)
   m_yPos = 0;
 
 
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
   memset(&m_processInfo, 0, sizeof(m_processInfo));
 #endif
 }
@@ -126,7 +126,7 @@ bool CExternalPlayer::CloseFile()
 
   if (m_dialog && m_dialog->IsActive()) m_dialog->Close();
 
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
   if (m_bIsPlaying && m_processInfo.hProcess)
   {
     TerminateProcess(m_processInfo.hProcess, 1);
@@ -231,7 +231,7 @@ void CExternalPlayer::Process()
   // make sure we surround the arguments with quotes where necessary
   CStdString strFName;
   CStdString strFArgs;
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
   // W32 batch-file handline
   if (m_filename.Right(4) == ".bat" || m_filename.Right(4) == ".cmd")
   {
@@ -262,7 +262,7 @@ void CExternalPlayer::Process()
     strFArgs.append("\"");
   }
 
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
   if (m_warpcursor)
   {
     GetCursorPos(&m_ptCursorpos);
@@ -295,7 +295,7 @@ void CExternalPlayer::Process()
     CLog::Log(LOGNOTICE, "%s: Hiding XBMC window", __FUNCTION__);
     g_Windowing.Hide();
   }
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
   else if (currentStyle & WS_EX_TOPMOST)
   {
     CLog::Log(LOGNOTICE, "%s: Lowering XBMC window", __FUNCTION__);
@@ -317,11 +317,11 @@ void CExternalPlayer::Process()
 
 
   BOOL ret = TRUE;
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
   ret = ExecuteAppW32(strFName.c_str(),strFArgs.c_str());
 #elif defined(TARGET_ANDROID)
   ret = ExecuteAppAndroid(m_filename.c_str(), mainFile.c_str());
-#elif defined(_LINUX) || defined(TARGET_DARWIN_OSX)
+#elif defined(TARGET_POSIX) || defined(TARGET_DARWIN_OSX)
   ret = ExecuteAppLinux(strFArgs.c_str());
 #endif
   int64_t elapsedMillis = XbmcThreads::SystemClockMillis() - m_playbackStartTime;
@@ -349,7 +349,7 @@ void CExternalPlayer::Process()
   m_bIsPlaying = false;
   CLog::Log(LOGNOTICE, "%s: Stop", __FUNCTION__);
 
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
   g_Windowing.Restore();
 
   if (currentStyle & WS_EX_TOPMOST)
@@ -365,7 +365,7 @@ void CExternalPlayer::Process()
     g_Windowing.Show();
   }
 
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
   if (m_warpcursor)
   {
     m_xPos = 0;
@@ -396,7 +396,7 @@ void CExternalPlayer::Process()
     m_callback.OnPlayBackEnded();
 }
 
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
 BOOL CExternalPlayer::ExecuteAppW32(const char* strPath, const char* strSwitches)
 {
   CLog::Log(LOGNOTICE, "%s: %s %s", __FUNCTION__, strPath, strSwitches);
@@ -453,7 +453,7 @@ BOOL CExternalPlayer::ExecuteAppW32(const char* strPath, const char* strSwitches
 }
 #endif
 
-#if !defined(TARGET_ANDROID) && (defined(_LINUX) || defined(TARGET_DARWIN_OSX))
+#if !defined(TARGET_ANDROID) && (defined(TARGET_POSIX) || defined(TARGET_DARWIN_OSX))
 BOOL CExternalPlayer::ExecuteAppLinux(const char* strSwitches)
 {
   CLog::Log(LOGNOTICE, "%s: %s", __FUNCTION__, strSwitches);
@@ -645,7 +645,7 @@ bool CExternalPlayer::Initialize(TiXmlElement* pConfig)
   XMLUtils::GetBoolean(pConfig, "hidexbmc", m_hidexbmc);
   if (!XMLUtils::GetBoolean(pConfig, "hideconsole", m_hideconsole))
   {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
     // Default depends on whether player is a batch file
     m_hideconsole = m_filename.Right(4) == ".bat";
 #endif
@@ -678,7 +678,7 @@ bool CExternalPlayer::Initialize(TiXmlElement* pConfig)
           m_islauncher ? "true" : "false",
           warpCursor.c_str());
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   m_filenameReplacers.push_back("^smb:// , / , \\\\ , g");
   m_filenameReplacers.push_back("^smb:\\\\\\\\ , smb:(\\\\\\\\[^\\\\]*\\\\) , \\1 , ");
 #endif
index 610069d..1e81d9f 100644 (file)
@@ -78,12 +78,12 @@ public:
   virtual CStdString GetPlayerState();
   virtual bool SetPlayerState(CStdString state);
   
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
   virtual BOOL ExecuteAppW32(const char* strPath, const char* strSwitches);
   //static void CALLBACK AppFinished(void* closure, BOOLEAN TimerOrWaitFired);
 #elif defined(TARGET_ANDROID)
   virtual BOOL ExecuteAppAndroid(const char* strSwitches,const char* strPath);
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
   virtual BOOL ExecuteAppLinux(const char* strSwitches);
 #endif
 
@@ -100,7 +100,7 @@ private:
   int m_time;
   CStdString m_launchFilename;
   HWND m_hwndXbmc; 
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
   POINT m_ptCursorpos;
   PROCESS_INFORMATION m_processInfo;
 #endif 
index 075d14d..32b8d22 100644 (file)
@@ -21,7 +21,7 @@
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 #include "system.h"
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 
@@ -973,7 +973,7 @@ void CLinuxRendererGL::LoadShaders(int field)
     switch(requestedMethod)
     {
       case RENDER_METHOD_AUTO:
-#if defined(_LINUX) && !defined(__APPLE__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
        //with render method set to auto, don't try glsl on ati if we're on linux
        //it seems to be broken in a random way with every new driver release
        tryGlsl = g_Windowing.GetRenderVendor().Left(3).CompareNoCase("ati") != 0;
index 497adfe..96b752b 100644 (file)
@@ -328,9 +328,9 @@ protected:
 
 
 inline int NP2( unsigned x ) {
-#if defined(_LINUX) && !defined(__POWERPC__) && !defined(__PPC__) && !defined(__arm__)
+#if defined(TARGET_POSIX) && !defined(__POWERPC__) && !defined(__PPC__) && !defined(__arm__)
   // If there are any issues compiling this, just append a ' && 0'
-  // to the above to make it '#if defined(_LINUX) && 0'
+  // to the above to make it '#if defined(TARGET_POSIX) && 0'
 
   // Linux assembly is AT&T Unix style, not Intel style
   unsigned y;
index 1832b40..cb254cf 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #include "system.h"
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 
index acdbdf7..a7788d1 100644 (file)
@@ -64,30 +64,26 @@ template<class T>
 class CRetakeLock
 {
 public:
-  CRetakeLock(CSharedSection &section, bool immidiate = true, CCriticalSection &owned = g_graphicsContext)
-    : m_lock (NULL  ),
-      m_owned(owned )
+  CRetakeLock(CSharedSection &section, CCriticalSection &owned = g_graphicsContext)
+    : m_count(owned.exit())
+    , m_lock (section),
+      m_owned(owned)
   {
-    m_count = m_owned.exit();
-    m_lock  = new T(section);
-    if(immidiate)
-    {
-      m_owned.restore(m_count);
-      m_count = 0;
-    }
+    m_owned.restore(m_count);
   }
-  ~CRetakeLock()
+
+  void Leave() { m_lock.Leave(); }
+  void Enter()
   {
-    delete m_lock;
+    m_count = m_owned.exit();
+    m_lock.Enter();
     m_owned.restore(m_count);
   }
-  void Leave() { m_lock->Leave(); }
-  void Enter() { m_lock->Enter(); }
 
 private:
-  T*                m_lock;
-  CCriticalSection &m_owned;
   DWORD             m_count;
+  T                 m_lock;
+  CCriticalSection &m_owned;
 };
 
 CXBMCRenderManager::CXBMCRenderManager()
@@ -1049,7 +1045,7 @@ void CXBMCRenderManager::PrepareNextRender()
   if(g_graphicsContext.IsFullScreenVideo())
     next = (m_Queue[idx].timestamp <= clocktime + MAXPRESENTDELAY);
   else
-    next = (m_Queue[idx].timestamp <= clocktime);
+    next = (m_Queue[idx].timestamp <= clocktime + frametime);
 
   if (next)
   {
index b75bbe0..d947e9e 100644 (file)
@@ -120,7 +120,7 @@ public:
 
   RESOLUTION GetResolution();
 
-  float GetMaximumFPS();
+  static float GetMaximumFPS();
   inline bool IsStarted() { return m_bIsStarted;}
   double GetDisplayLatency() { return m_displayLatency; }
   int    GetSkippedFrames()  { return m_QueueSkip; }
@@ -132,7 +132,7 @@ public:
 
   EINTERLACEMETHOD AutoInterlaceMethod(EINTERLACEMETHOD mInt);
 
-  double GetPresentTime();
+  static double GetPresentTime();
   void  WaitPresentTime(double presenttime);
 
   CStdString GetVSyncState();
index 1eb9320..70023e8 100644 (file)
@@ -17,7 +17,7 @@
  *  <http://www.gnu.org/licenses/>.
  *
  */
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   #define _USE_MATH_DEFINES
 #endif
 
index 9d8d44c..d2d0488 100644 (file)
@@ -20,7 +20,7 @@
  *
  */
 
-#if !defined(_LINUX) && !defined(HAS_GL)
+#if !defined(TARGET_POSIX) && !defined(HAS_GL)
 
 #include "guilib/GraphicContext.h"
 #include "RenderFlags.h"
index 9d62ed6..8467f3e 100644 (file)
@@ -2163,7 +2163,7 @@ void CAMLPlayer::FindSubtitleFiles()
   for(unsigned int i=0;i<filenames.size();i++)
   {
     // if vobsub subtitle:             
-    if (URIUtils::GetExtension(filenames[i]) == ".idx")
+    if (URIUtils::HasExtension(filenames[i], ".idx"))
     {
       CStdString strSubFile;
       if ( CUtil::FindVobSubPair( filenames, filenames[i], strSubFile ) )
index c78dd15..0963d34 100644 (file)
@@ -20,7 +20,7 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 #include "threads/CriticalSection.h"
index e8c0eae..ff6f290 100644 (file)
@@ -23,7 +23,7 @@
 #include "system.h"
 #include "cores/AudioEngine/AEAudioFormat.h"
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 #include <vector>
index f493b87..9be5de4 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #include "DVDAudioCodecFFmpeg.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "XMemUtils.h"
 #endif
 #include "../../DVDStreamInfo.h"
index 7e225a9..928cab8 100644 (file)
@@ -126,7 +126,7 @@ bool CDVDAudioCodecPassthroughFFmpeg::SetupMuxer(CDVDStreamInfo &hints, CStdStri
   /* request output of wanted endianness */
   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__)
+#if defined(WORDS_BIGENDIAN) && !defined(TARGET_DARWIN)
     CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Unable to set big-endian stream mode (FFmpeg too old?), disabling passthrough");
     Dispose();
     return false;
index 55cc80d..d72236f 100644 (file)
  *  <http://www.gnu.org/licenses/>.
  *
  */
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
-#if defined(_LINUX) || defined(TARGET_DARWIN)
+#if defined(TARGET_POSIX) || defined(TARGET_DARWIN)
   #include <mad.h>
 #else
   #include "libmad/mad.h"
index 7de708c..d315d21 100644 (file)
@@ -20,7 +20,7 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 
index fdb3f89..9ad29f9 100644 (file)
@@ -157,24 +157,24 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, unsigne
 #else
   hwSupport += "AMCodec:no ";
 #endif
-#if defined(HAVE_LIBOPENMAX) && defined(_LINUX)
+#if defined(HAVE_LIBOPENMAX) && defined(TARGET_POSIX)
   hwSupport += "OpenMax:yes ";
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
   hwSupport += "OpenMax:no ";
 #endif
-#if defined(HAVE_LIBVDPAU) && defined(_LINUX)
+#if defined(HAVE_LIBVDPAU) && defined(TARGET_POSIX)
   hwSupport += "VDPAU:yes ";
-#elif defined(_LINUX) && !defined(TARGET_DARWIN)
+#elif defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
   hwSupport += "VDPAU:no ";
 #endif
-#if defined(_WIN32) && defined(HAS_DX)
+#if defined(TARGET_WINDOWS) && defined(HAS_DX)
   hwSupport += "DXVA:yes ";
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
   hwSupport += "DXVA:no ";
 #endif
-#if defined(HAVE_LIBVA) && defined(_LINUX)
+#if defined(HAVE_LIBVA) && defined(TARGET_POSIX)
   hwSupport += "VAAPI:yes ";
-#elif defined(_LINUX) && !defined(TARGET_DARWIN)
+#elif defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
   hwSupport += "VAAPI:no ";
 #endif
 
@@ -259,7 +259,7 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, unsigne
 #endif
 
   // try to decide if we want to try halfres decoding
-#if !defined(_LINUX) && !defined(_WIN32)
+#if !defined(TARGET_POSIX) && !defined(TARGET_WINDOWS)
   float pixelrate = (float)hint.width*hint.height*hint.fpsrate/hint.fpsscale;
   if( pixelrate > 1400.0f*720.0f*30.0f )
   {
index c98e7dc..1e0433d 100644 (file)
@@ -44,7 +44,7 @@ extern "C" {
 /* number of text colors specified by EIA-608 standard */
 #define NUM_FG_COL 7
 
-#ifndef WIN32
+#ifndef TARGET_WINDOWS
 /* colors specified by the EIA 608 standard */
 enum { WHITE, GREEN, BLUE, CYAN, RED, YELLOW, MAGENTA, BLACK, TRANSPARENT };
 #else
index a0570ce..8dd9228 100644 (file)
  * available at http://sourceforge.net/projects/ccdecoder/.
  */
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #undef EMULATE_INTTYPES
 #else
 #define EMULATE_INTTYPES
-#endif /* _LINUX */
+#endif /* TARGET_POSIX */
 
 #ifndef EMULATE_INTTYPES
 #   include <stdint.h>
index 5a2a857..93e81dd 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #include "system.h"
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
 #include "WIN32Util.h"
 #include "util.h"
 #include "dialogs/GUIDialogKaiToast.h"
@@ -42,7 +42,7 @@
 
 namespace BCM
 {
-  #if defined(WIN32)
+  #if defined(TARGET_WINDOWS)
     typedef void               *HANDLE;
   #else
     #ifndef __LINUX_USER__
@@ -1118,7 +1118,7 @@ CCrystalHD::CCrystalHD() :
   memset(&m_sps_pps_context, 0, sizeof(m_sps_pps_context));
 
   m_dll = new DllLibCrystalHD;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CStdString  strDll;
   if(CWIN32Util::GetCrystalHDLibraryPath(strDll) && m_dll->SetFile(strDll) && m_dll->Load() && m_dll->IsLoaded() )
 #else
index 53939a9..02e99ab 100644 (file)
@@ -213,7 +213,7 @@ private:
   // bitstream to bytestream (Annex B) conversion support.
   bool bitstream_convert_init(void *in_extradata, int in_extrasize);
   bool bitstream_convert(uint8_t* pData, int iSize, uint8_t **poutbuf, int *poutbuf_size);
-  void bitstream_alloc_and_copy( uint8_t **poutbuf, int *poutbuf_size,
+  static void bitstream_alloc_and_copy( uint8_t **poutbuf, int *poutbuf_size,
     const uint8_t *sps_pps, uint32_t sps_pps_size, const uint8_t *in, uint32_t in_size);
 
   typedef struct chd_bitstream_ctx {
index 1291131..a1ec3ea 100644 (file)
@@ -18,9 +18,9 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
 #include "system.h"
 #include "DllAvCodec.h"
 #endif
index dc04f8e..7881e58 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #include "system.h"
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 #include "DVDVideoCodecFFmpeg.h"
@@ -29,7 +29,7 @@
 #include "DVDCodecs/DVDCodecs.h"
 #include "DVDCodecs/DVDCodecUtils.h"
 #include "DVDVideoPPFFmpeg.h"
-#if defined(_LINUX) || defined(_WIN32)
+#if defined(TARGET_POSIX) || defined(TARGET_WINDOWS)
 #include "utils/CPUInfo.h"
 #endif
 #include "settings/AdvancedSettings.h"
@@ -38,7 +38,7 @@
 #include "boost/shared_ptr.hpp"
 #include "threads/Atomics.h"
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #define RINT(x) ((x) >= 0 ? ((int)((x) + 0.5)) : ((int)((x) - 0.5)))
 #else
 #include <math.h>
@@ -57,6 +57,9 @@
 #ifdef HAVE_LIBVA
 #include "VAAPI.h"
 #endif
+#ifdef TARGET_DARWIN_OSX
+#include "VDA.h"
+#endif
 
 using namespace boost;
 
@@ -118,6 +121,20 @@ enum PixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx
         dec->Release();
     }
 #endif
+
+#ifdef TARGET_DARWIN_OSX
+    if (*cur == AV_PIX_FMT_VDA_VLD && CSettings::Get().GetBool("videoplayer.usevda"))
+    {
+      VDA::CDecoder* dec = new VDA::CDecoder();
+      if(dec->Open(avctx, *cur, ctx->m_uSurfacesCount))
+      {
+        ctx->SetHardware(dec);
+        return *cur;
+      }
+      else
+        dec->Release();
+    }
+#endif
     cur++;
   }
   return ctx->m_dllAvCodec.avcodec_default_get_format(avctx, fmt);
@@ -559,7 +576,11 @@ bool CDVDVideoCodecFFmpeg::GetPictureCommon(DVDVideoPicture* pDvdVideoPicture)
   /* use variable in the frame */
   AVRational pixel_aspect = m_pCodecContext->sample_aspect_ratio;
   if (m_pBufferRef)
+#if defined(LIBAVFILTER_FROM_FFMPEG)
     pixel_aspect = m_pBufferRef->video->sample_aspect_ratio;
+#else
+    pixel_aspect = m_pBufferRef->video->pixel_aspect;
+#endif
 
   if (pixel_aspect.num == 0)
     aspect_ratio = 0;
index 428e23a..9ec01ec 100644 (file)
@@ -18,9 +18,9 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
 #include "system.h"
 #endif
 
index ea06758..620aa67 100644 (file)
@@ -66,7 +66,7 @@ enum {
 typedef struct frame_queue {
   double              dts;
   double              pts;
-  double              sort_time;
+  int64_t             sort_time;
   FourCharCode        pixel_buffer_format;
   CVBufferRef         pixel_buffer_ref;
   struct frame_queue  *nextframe;
@@ -74,7 +74,7 @@ typedef struct frame_queue {
 
 ////////////////////////////////////////////////////////////////////////////////////////////
 // helper function that wraps dts/pts into a dictionary
-static CFDictionaryRef CreateDictionaryWithDisplayTime(double time, double dts, double pts)
+static CFDictionaryRef CreateDictionaryWithDisplayTime(int64_t time, double dts, double pts)
 {
   CFStringRef key[3] = {
     CFSTR("VideoDisplay_TIME"),
@@ -83,7 +83,7 @@ static CFDictionaryRef CreateDictionaryWithDisplayTime(double time, double dts,
   CFNumberRef value[3];
   CFDictionaryRef display_time;
 
-  value[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &time);
+  value[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberLongLongType, &time);
   value[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &dts);
   value[2] = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &pts);
 
@@ -103,7 +103,7 @@ static void GetFrameDisplayTimeFromDictionary(
   CFDictionaryRef inFrameInfoDictionary, frame_queue *frame)
 {
   // default to DVD_NOPTS_VALUE
-  frame->sort_time = -1.0;
+  frame->sort_time = -1;
   frame->dts = DVD_NOPTS_VALUE;
   frame->pts = DVD_NOPTS_VALUE;
   if (inFrameInfoDictionary == NULL)
@@ -113,7 +113,7 @@ static void GetFrameDisplayTimeFromDictionary(
   //
   value[0] = (CFNumberRef)CFDictionaryGetValue(inFrameInfoDictionary, CFSTR("VideoDisplay_TIME"));
   if (value[0])
-    CFNumberGetValue(value[0], kCFNumberDoubleType, &frame->sort_time);
+    CFNumberGetValue(value[0], kCFNumberLongLongType, &frame->sort_time);
   value[1] = (CFNumberRef)CFDictionaryGetValue(inFrameInfoDictionary, CFSTR("VideoDisplay_DTS"));
   if (value[1])
     CFNumberGetValue(value[1], kCFNumberDoubleType, &frame->dts);
@@ -140,7 +140,7 @@ CDVDVideoCodecVDA::CDVDVideoCodecVDA() : CDVDVideoCodec()
   memset(&m_videobuffer, 0, sizeof(DVDVideoPicture));
   m_DropPictures = false;
   m_decode_async = false;
-  m_sort_time_offset = 0.0;
+  m_sort_time = 0;
   m_use_cvBufferRef = false;
 }
 
@@ -231,8 +231,6 @@ bool CDVDVideoCodecVDA::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
         CFRelease(avcCData);
         return false;
       }
-      if (m_max_ref_frames == 0)
-        m_max_ref_frames = 2;
     }
 
     if (profile == FF_PROFILE_H264_MAIN && level == 32 && m_max_ref_frames > 4)
@@ -369,9 +367,8 @@ bool CDVDVideoCodecVDA::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
     }
 
     m_DropPictures = false;
-    m_max_ref_frames = std::min(m_max_ref_frames, 5);
-    m_sort_time_offset = (CurrentHostCounter() * 1000.0) / CurrentHostFrequency();
-
+    m_max_ref_frames = std::max(m_max_ref_frames + 1, 5);
+    m_sort_time = 0;
     return true;
   }
 
@@ -414,8 +411,7 @@ int CDVDVideoCodecVDA::Decode(uint8_t* pData, int iSize, double dts, double pts)
     CFDataRef avc_demux = CFDataCreate(kCFAllocatorDefault,
       m_bitstream->GetConvertBuffer(), m_bitstream->GetConvertSize());
 
-    double sort_time = (CurrentHostCounter() * 1000.0) / CurrentHostFrequency();
-    CFDictionaryRef avc_time = CreateDictionaryWithDisplayTime(sort_time - m_sort_time_offset, dts, pts);
+    CFDictionaryRef avc_time = CreateDictionaryWithDisplayTime(m_sort_time++, dts, pts);
 
     uint32_t avc_flags = 0;
     if (m_DropPictures)
@@ -441,7 +437,7 @@ int CDVDVideoCodecVDA::Decode(uint8_t* pData, int iSize, double dts, double pts)
   if (m_queue_depth < m_max_ref_frames)
     return VC_BUFFER;
 
-  return VC_PICTURE | VC_BUFFER;
+  return VC_PICTURE;
 }
 
 void CDVDVideoCodecVDA::Reset(void)
@@ -452,7 +448,7 @@ void CDVDVideoCodecVDA::Reset(void)
   while (m_queue_depth)
     DisplayQueuePop();
 
-  m_sort_time_offset = (CurrentHostCounter() * 1000.0) / CurrentHostFrequency();
+  m_sort_time = 0;
 }
 
 bool CDVDVideoCodecVDA::GetPicture(DVDVideoPicture* pDvdVideoPicture)
@@ -519,7 +515,7 @@ bool CDVDVideoCodecVDA::GetPicture(DVDVideoPicture* pDvdVideoPicture)
   //CLog::Log(LOGNOTICE, "%s - VDADecoderDecode dts(%f), pts(%f)", __FUNCTION__,
   //  pDvdVideoPicture->dts, pDvdVideoPicture->pts);
 
-  return VC_PICTURE | VC_BUFFER;
+  return true;
 }
 
 bool CDVDVideoCodecVDA::ClearPicture(DVDVideoPicture* pDvdVideoPicture)
@@ -631,45 +627,30 @@ void CDVDVideoCodecVDA::VDADecoderCallback(
   newFrame->pixel_buffer_ref = CVBufferRetain(imageBuffer);
   GetFrameDisplayTimeFromDictionary(frameInfo, newFrame);
 
-  // if both dts or pts are good we use those, else use decoder insert time for frame sort
-  if ((newFrame->pts != DVD_NOPTS_VALUE) || (newFrame->dts != DVD_NOPTS_VALUE))
-  {
-    // if pts is borked (stupid avi's), use dts for frame sort
-    if (newFrame->pts == DVD_NOPTS_VALUE)
-      newFrame->sort_time = newFrame->dts;
-    else
-      newFrame->sort_time = newFrame->pts;
-  }
-
   // since the frames we get may be in decode order rather than presentation order
   // our hypothetical callback places them in a queue of frames which will
   // hold them in display order for display on another thread
   pthread_mutex_lock(&ctx->m_queue_mutex);
-  //
-  frame_queue *queueWalker = ctx->m_display_queue;
-  if (!queueWalker || (newFrame->sort_time < queueWalker->sort_time))
+
+  frame_queue base;
+  base.nextframe = ctx->m_display_queue;
+  frame_queue *ptr = &base;
+  for(; ptr->nextframe; ptr = ptr->nextframe)
   {
-    // we have an empty queue, or this frame earlier than the current queue head.
-    newFrame->nextframe = queueWalker;
-    ctx->m_display_queue = newFrame;
-  } else {
-    // walk the queue and insert this frame where it belongs in display order.
-    bool frameInserted = false;
-    frame_queue *nextFrame = NULL;
-    //
-    while (!frameInserted)
-    {
-      nextFrame = queueWalker->nextframe;
-      if (!nextFrame || (newFrame->sort_time < nextFrame->sort_time))
-      {
-        // if the next frame is the tail of the queue, or our new frame is earlier.
-        newFrame->nextframe = nextFrame;
-        queueWalker->nextframe = newFrame;
-        frameInserted = true;
-      }
-      queueWalker = nextFrame;
-    }
+    if(ptr->nextframe->pts == DVD_NOPTS_VALUE
+    || newFrame->pts       == DVD_NOPTS_VALUE)
+      continue;
+    if(ptr->nextframe->pts > newFrame->pts)
+      break;
   }
+  /* insert after ptr */
+  newFrame->nextframe = ptr->nextframe;
+  ptr->nextframe = newFrame;
+
+  /* update anchor if needed */
+  if(newFrame->nextframe == ctx->m_display_queue)
+    ctx->m_display_queue = newFrame;
+
   ctx->m_queue_depth++;
   //
   pthread_mutex_unlock(&ctx->m_queue_mutex);   
@@ -678,7 +659,7 @@ void CDVDVideoCodecVDA::VDADecoderCallback(
 unsigned CDVDVideoCodecVDA::GetAllowedReferences()
 {
   if (m_use_cvBufferRef)
-    return 2; /* TODO can this be increased? */
+    return 3;
   else
     return 0;
 }
index 75c263b..49dc43d 100644 (file)
@@ -57,7 +57,7 @@ protected:
   bool              m_DropPictures;
   bool              m_decode_async;
 
-  double            m_sort_time_offset;
+  int64_t           m_sort_time;
   pthread_mutex_t   m_queue_mutex;    // mutex protecting queue manipulation
   frame_queue       *m_display_queue; // display-order queue - next display frame is always at the queue head
   int32_t           m_queue_depth;    // we will try to keep the queue depth around 16+1 frames
index 2a45bbb..e62306b 100644 (file)
@@ -18,7 +18,7 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 
index 5b83a52..dcf19b2 100644 (file)
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 extern "C" {
-#if defined(WIN32)
+#if defined(TARGET_WINDOWS)
   #include "libmpeg2/mpeg2.h"
   #include "libmpeg2/mpeg2convert.h"
 #else
index ccdab34..4029ad0 100644 (file)
@@ -18,9 +18,9 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
 #include "system.h"
 #endif
 
index 49965e4..a3cb0c5 100644 (file)
@@ -18,9 +18,9 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
 #include "system.h"
 #endif
 
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDA.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDA.cpp
new file mode 100644 (file)
index 0000000..d6864cb
--- /dev/null
@@ -0,0 +1,273 @@
+/*
+ *      Copyright (C) 2005-2013 Team XBMC
+ *      http://www.xbmc.org
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library 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
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+#include "system.h"
+#ifdef TARGET_DARWIN_OSX
+#include "osx/CocoaInterface.h"
+#include "DVDVideoCodec.h"
+#include "DVDCodecs/DVDCodecUtils.h"
+#include "VDA.h"
+
+extern "C" {
+  #include <libavcodec/vda.h>
+}
+
+using namespace std;
+using namespace VDA;
+
+
+static void RelBufferS(AVCodecContext *avctx, AVFrame *pic)
+{ ((CDecoder*)((CDVDVideoCodecFFmpeg*)avctx->opaque)->GetHardware())->RelBuffer(avctx, pic); }
+
+static int GetBufferS(AVCodecContext *avctx, AVFrame *pic) 
+{  return ((CDecoder*)((CDVDVideoCodecFFmpeg*)avctx->opaque)->GetHardware())->GetBuffer(avctx, pic); }
+
+CDecoder::CDecoder()
+: m_renderbuffers_count(0)
+{
+  m_ctx = (vda_context*)calloc(1, sizeof(vda_context));
+}
+
+CDecoder::~CDecoder()
+{
+  Close();
+  free(m_ctx);
+}
+
+void CDecoder::RelBuffer(AVCodecContext *avctx, AVFrame *pic)
+{
+  CVPixelBufferRef cv_buffer = (CVPixelBufferRef)pic->data[3];
+  CVPixelBufferRelease(cv_buffer);
+
+  for (int i = 0; i < 4; i++)
+    pic->data[i] = NULL;
+}
+
+int CDecoder::GetBuffer(AVCodecContext *avctx, AVFrame *pic)
+{
+  pic->type = FF_BUFFER_TYPE_USER;
+  pic->data[0] = (uint8_t *)1;
+  return 0;
+}
+
+static void vda_decoder_callback (void *vda_hw_ctx,
+                                  CFDictionaryRef user_info,
+                                  OSStatus status,
+                                  uint32_t infoFlags,
+                                  CVImageBufferRef image_buffer)
+{
+  struct vda_context *vda_ctx = (struct vda_context *)vda_hw_ctx;
+
+  if (!image_buffer)
+    return;
+
+  if (vda_ctx->cv_pix_fmt_type != CVPixelBufferGetPixelFormatType(image_buffer))
+    return;
+
+  vda_ctx->cv_buffer = CVPixelBufferRetain(image_buffer);
+}
+
+bool CDecoder::Create(AVCodecContext *avctx)
+{
+  OSStatus status;
+  CFNumberRef height;
+  CFNumberRef width;
+  CFNumberRef format;
+  CFDataRef avc_data;
+  CFMutableDictionaryRef config_info;
+  CFMutableDictionaryRef buffer_attributes;
+  CFMutableDictionaryRef io_surface_properties;
+  CFNumberRef cv_pix_fmt;
+
+  m_ctx->priv_bitstream = NULL;
+  m_ctx->priv_allocated_size = 0;
+
+  /* Each VCL NAL in the bitstream sent to the decoder
+   * is preceded by a 4 bytes length header.
+   * Change the avcC atom header if needed, to signal headers of 4 bytes. */
+  if (avctx->extradata_size >= 4 && (avctx->extradata[4] & 0x03) != 0x03) {
+    uint8_t *rw_extradata;
+
+    if (!(rw_extradata = (uint8_t*)av_malloc(avctx->extradata_size)))
+      return false;
+
+    memcpy(rw_extradata, avctx->extradata, avctx->extradata_size);
+
+    rw_extradata[4] |= 0x03;
+
+    avc_data = CFDataCreate(kCFAllocatorDefault, rw_extradata, avctx->extradata_size);
+
+    av_freep(&rw_extradata);
+  } else {
+    avc_data = CFDataCreate(kCFAllocatorDefault, avctx->extradata, avctx->extradata_size);
+  }
+
+  config_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
+                                          4,
+                                          &kCFTypeDictionaryKeyCallBacks,
+                                          &kCFTypeDictionaryValueCallBacks);
+
+  height   = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &m_ctx->height);
+  width    = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &m_ctx->width);
+  format   = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &m_ctx->format);
+
+  CFDictionarySetValue(config_info, kVDADecoderConfiguration_Height      , height);
+  CFDictionarySetValue(config_info, kVDADecoderConfiguration_Width       , width);
+  CFDictionarySetValue(config_info, kVDADecoderConfiguration_SourceFormat, format);
+  CFDictionarySetValue(config_info, kVDADecoderConfiguration_avcCData    , avc_data);
+
+  buffer_attributes = CFDictionaryCreateMutable(kCFAllocatorDefault,
+                                                2,
+                                                &kCFTypeDictionaryKeyCallBacks,
+                                                &kCFTypeDictionaryValueCallBacks);
+  io_surface_properties = CFDictionaryCreateMutable(kCFAllocatorDefault,
+                                                    0,
+                                                    &kCFTypeDictionaryKeyCallBacks,
+                                                    &kCFTypeDictionaryValueCallBacks);
+  cv_pix_fmt  = CFNumberCreate(kCFAllocatorDefault,
+                               kCFNumberSInt32Type,
+                               &m_ctx->cv_pix_fmt_type);
+  CFDictionarySetValue(buffer_attributes,
+                       kCVPixelBufferPixelFormatTypeKey,
+                       cv_pix_fmt);
+  CFDictionarySetValue(buffer_attributes,
+                       kCVPixelBufferIOSurfacePropertiesKey,
+                       io_surface_properties);
+
+  status = VDADecoderCreate(config_info,
+                            buffer_attributes,
+                            (VDADecoderOutputCallback*)vda_decoder_callback,
+                            m_ctx,
+                            &m_ctx->decoder);
+
+  CFRelease(height);
+  CFRelease(width);
+  CFRelease(format);
+  CFRelease(avc_data);
+  CFRelease(config_info);
+  CFRelease(io_surface_properties);
+  CFRelease(cv_pix_fmt);
+  CFRelease(buffer_attributes);
+
+  if(status != kVDADecoderNoErr)
+  {
+    CLog::Log(LOGERROR, "VDA::CDecoder - Failed to init VDA decoder: %d", status);
+    return false;
+  }
+  return true;
+}
+
+void CDecoder::Close()
+{
+  OSStatus status = kVDADecoderNoErr;
+
+  if (m_ctx->decoder)
+    status = VDADecoderDestroy(m_ctx->decoder);
+  m_ctx->decoder = NULL;
+  av_freep(&m_ctx->priv_bitstream);
+}
+
+bool CDecoder::Open(AVCodecContext *avctx, enum PixelFormat fmt, unsigned int surfaces)
+{
+  Close();
+
+  if(fmt != AV_PIX_FMT_VDA_VLD)
+    return false;
+
+  if(avctx->codec_id != AV_CODEC_ID_H264)
+    return false;
+
+  switch(avctx->profile)
+  {
+    case FF_PROFILE_H264_HIGH_10:
+    case FF_PROFILE_H264_HIGH_10_INTRA:
+    case FF_PROFILE_H264_HIGH_422:
+    case FF_PROFILE_H264_HIGH_422_INTRA:
+    case FF_PROFILE_H264_HIGH_444_PREDICTIVE:
+    case FF_PROFILE_H264_HIGH_444_INTRA:
+    case FF_PROFILE_H264_CAVLC_444:
+      return false;
+    default:
+      break;
+  }
+
+  if (Cocoa_GPUForDisplayIsNvidiaPureVideo3() && !CDVDCodecUtils::IsVP3CompatibleWidth(avctx->width))
+  {
+    CLog::Log(LOGNOTICE, "%s - Nvidia 9400 GPU hardware limitation, cannot decode a width of %d", __FUNCTION__, avctx->width);
+    return false;
+  }
+
+  if (avctx->profile == FF_PROFILE_H264_MAIN && avctx->level == 32 && avctx->refs > 4)
+  {
+    // Main@L3.2, VDA cannot handle greater than 4 reference frames
+    CLog::Log(LOGNOTICE, "%s - Main@L3.2 detected, VDA cannot decode.", __FUNCTION__);
+    return false;
+  }
+
+  /* init vda */
+  memset(m_ctx, 0, sizeof(struct vda_context));
+  m_ctx->width  = avctx->width;
+  m_ctx->height = avctx->height;
+  m_ctx->format = 'avc1';
+  m_ctx->use_sync_decoding = 1;
+  m_ctx->cv_pix_fmt_type = kCVPixelFormatType_422YpCbCr8;
+
+  if (!Create(avctx))
+    return false;
+
+  avctx->pix_fmt         = fmt;
+  avctx->hwaccel_context = m_ctx;
+  avctx->get_buffer      = GetBufferS;
+  avctx->release_buffer  = RelBufferS;
+
+  return true;
+}
+
+int CDecoder::Decode(AVCodecContext* avctx, AVFrame* frame)
+{
+  int status = Check(avctx);
+  if(status)
+    return status;
+
+  if(frame)
+    return VC_BUFFER | VC_PICTURE;
+  else
+    return VC_BUFFER;
+}
+
+bool CDecoder::GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture)
+{
+  ((CDVDVideoCodecFFmpeg*)avctx->opaque)->GetPictureCommon(picture);
+
+  picture->format      = RENDER_FMT_CVBREF;
+  picture->cvBufferRef = (CVPixelBufferRef)frame->data[3];
+  return true;
+}
+
+int CDecoder::Check(AVCodecContext* avctx)
+{
+  return 0;
+}
+
+unsigned CDecoder::GetAllowedReferences()
+{
+  return m_renderbuffers_count;
+}
+
+#endif
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDA.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDA.h
new file mode 100644 (file)
index 0000000..154457f
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ *      Copyright (C) 2005-2013 Team XBMC
+ *      http://www.xbmc.org
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library 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
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+#pragma once
+
+#include "system_gl.h"
+
+#include "DllAvCodec.h"
+#include "DVDVideoCodecFFmpeg.h"
+
+struct vda_context;
+
+namespace VDA {
+
+class CDecoder
+  : public CDVDVideoCodecFFmpeg::IHardwareDecoder
+{
+public:
+  CDecoder();
+ ~CDecoder();
+  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 int  Check     (AVCodecContext* avctx);
+  virtual void Close();
+  virtual const std::string Name() { return "vda"; }
+  virtual CCriticalSection* Section() {  return NULL; }
+  virtual unsigned GetAllowedReferences();
+
+  int   GetBuffer(AVCodecContext *avctx, AVFrame *pic);
+  void  RelBuffer(AVCodecContext *avctx, AVFrame *pic);
+protected:
+  bool                   Create(AVCodecContext* avctx);
+  unsigned               m_renderbuffers_count;
+  vda_context*           m_ctx;
+};
+
+}
index 3ad5f78..03d40f2 100644 (file)
@@ -173,6 +173,7 @@ CVDPAU::CVDPAU()
   vdp_video_mixer_query_feature_support = NULL;
   vdp_video_mixer_destroy = NULL;
   vdp_video_mixer_render = NULL;
+  m_hwContext.bitstream_buffers_allocated = 0;
 }
 
 bool CVDPAU::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces)
@@ -952,8 +953,7 @@ void CVDPAU::ReadFormatOf( AVCodecID codec
       vdp_decoder_profile = VDP_DECODER_PROFILE_VC1_ADVANCED;
       vdp_chroma_type     = VDP_CHROMA_TYPE_420;
       break;
-#if (defined PIX_FMT_VDPAU_MPEG4_IN_AVUTIL) && \
-    (defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP)
+#if (defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP)
     case AV_CODEC_ID_MPEG4:
       vdp_decoder_profile = VDP_DECODER_PROFILE_MPEG4_PART2_ASP;
       vdp_chroma_type     = VDP_CHROMA_TYPE_420;
index 45f72ac..3c5f366 100644 (file)
@@ -31,10 +31,10 @@ class CDVDInputStream;
 #pragma warning(disable:4244)
 #endif
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 // enum CodecID; // auto defined when neccesary
 #include <libavcodec/avcodec.h>
 #else
index 56fd5fd..9459305 100644 (file)
 
 #include "DVDDemux.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #define __attribute__(dummy_val)
 #else
 #include <config.h>
 #endif
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #pragma pack(push)
 #pragma pack(1)
 #endif
@@ -42,7 +42,7 @@ typedef struct
   uint64_t durationMs;
 } __attribute__((__packed__)) Demux_BXA_FmtHeader;
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #pragma pack(pop)
 #endif
 
index 76b1dea..f9749c8 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "DVDDemux.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #define __attribute__(dummy_val)
 #else
 #include <config.h>
index c9ca616..cdabe9c 100644 (file)
@@ -25,7 +25,7 @@
 #ifndef __STDC_LIMIT_MACROS
 #define __STDC_LIMIT_MACROS
 #endif
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "stdint.h"
 #endif
 #include "DVDDemuxFFmpeg.h"
@@ -47,6 +47,7 @@
 #include "threads/Thread.h"
 #include "threads/SystemClock.h"
 #include "utils/TimeUtils.h"
+#include "URL.h"
 
 void CDemuxStreamAudioFFmpeg::GetStreamInfo(std::string& strInfo)
 {
@@ -286,25 +287,32 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput)
   {
     // special stream type that makes avformat handle file opening
     // allows internal ffmpeg protocols to be used
+    CURL url = m_pInput->GetURL();
+    CStdString protocol = url.GetProtocol();
+
+    AVDictionary *options = GetFFMpegOptionsFromURL(url);
+
     int result=-1;
-    if (strFile.substr(0,6) == "mms://")
+    if (protocol.Equals("mms"))
     {
       // try mmsh, then mmst
-      CStdString strFile2;
-      strFile2.Format("mmsh://%s",strFile.substr(6,strFile.size()-6).c_str());
-      result = m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile2.c_str(), iformat, NULL);
+      url.SetProtocol("mmsh");
+      url.SetProtocolOptions("");
+      result = m_dllAvFormat.avformat_open_input(&m_pFormatContext, url.Get().c_str(), iformat, &options);
       if (result < 0)
       {
-        strFile = "mmst://";
-        strFile += strFile2.Mid(7).c_str();
+        url.SetProtocol("mmst");
+        strFile = url.Get();
       } 
     }
-    if (result < 0 && m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, NULL) < 0 )
+    if (result < 0 && m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0 )
     {
       CLog::Log(LOGDEBUG, "Error, could not open file %s", strFile.c_str());
       Dispose();
+      m_dllAvUtil.av_dict_free(&options);
       return false;
     }
+    m_dllAvUtil.av_dict_free(&options);
   }
   else
   {
@@ -578,6 +586,44 @@ void CDVDDemuxFFmpeg::SetSpeed(int iSpeed)
   }
 }
 
+AVDictionary *CDVDDemuxFFmpeg::GetFFMpegOptionsFromURL(const CURL &url)
+{
+  CStdString protocol = url.GetProtocol();
+
+  AVDictionary *options = NULL;
+
+  if (protocol.Equals("http") || protocol.Equals("https"))
+  {
+    std::map<CStdString, CStdString> protocolOptions;
+    url.GetProtocolOptions(protocolOptions);
+    std::string headers;
+    bool hasUserAgent = false;
+    for(std::map<CStdString, CStdString>::const_iterator it = protocolOptions.begin(); it != protocolOptions.end(); ++it)
+    {
+      const CStdString &name = it->first;
+      const CStdString &value = it->second;
+
+      if (name.Equals("seekable"))
+        m_dllAvUtil.av_dict_set(&options, "seekable", value.c_str(), 0);
+      else if (name.Equals("User-Agent"))
+      {
+        m_dllAvUtil.av_dict_set(&options, "user-agent", value.c_str(), 0);
+        hasUserAgent = true;
+      }
+      else if (!name.Equals("auth") && !name.Equals("Encoding"))
+        // all other protocol options can be added as http header.
+        headers.append(name).append(": ").append(value).append("\r\n");
+    }
+    if (!hasUserAgent)
+      // set default xbmc user-agent.
+      m_dllAvUtil.av_dict_set(&options, "user-agent", g_advancedSettings.m_userAgent.c_str(), 0);
+
+    if (!headers.empty())
+      m_dllAvUtil.av_dict_set(&options, "headers", headers.c_str(), 0);
+  }
+  return options;
+}
+
 double CDVDDemuxFFmpeg::ConvertTimestamp(int64_t pts, int den, int num)
 {
   if (pts == (int64_t)AV_NOPTS_VALUE)
index 568dc87..b78094e 100644 (file)
@@ -31,6 +31,7 @@
 #include <map>
 
 class CDVDDemuxFFmpeg;
+class CURL;
 
 class CDemuxStreamVideoFFmpeg
   : public CDemuxStreamVideo
@@ -127,6 +128,7 @@ protected:
   void CreateStreams(unsigned int program = UINT_MAX);
   void DisposeStreams();
 
+  AVDictionary *GetFFMpegOptionsFromURL(const CURL &url);
   double ConvertTimestamp(int64_t pts, int den, int num);
   void UpdateCurrentPTS();
   bool IsProgramChange();
index 272b8b8..f423f3f 100644 (file)
@@ -24,7 +24,7 @@
 #include "DllAvCodec.h"
 #include "DllAvFormat.h"
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #include <libavformat/avformat.h>
 #else
 extern "C" {
index 44178b2..6008a0e 100644 (file)
@@ -18,7 +18,7 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 #include "DVDDemuxUtils.h"
index c133901..adf5989 100644 (file)
@@ -32,10 +32,11 @@ CDVDInputStream::~CDVDInputStream()
 
 bool CDVDInputStream::Open(const char* strFile, const std::string &content)
 {
-  CURL url = CURL(strFile);
+  CURL url(strFile);
 
-  // get rid of any |option parameters which might have sneaked in here
-  // those are only handled by our curl impl.
+  m_url = url;
+  // get rid of any protocol options which might have sneaked in here
+  // but keep them in m_url.
   url.SetProtocolOptions("");
   m_strFileName = url.Get();
 
index cef4a72..6943e08 100644 (file)
@@ -25,6 +25,7 @@
 #include "filesystem/IFileTypes.h"
 
 #include "FileItem.h"
+#include "URL.h"
 #include "guilib/Geometry.h"
 
 enum DVDStreamType
@@ -150,6 +151,7 @@ public:
   virtual int64_t GetLength() = 0;
   virtual std::string& GetContent() { return m_content; };
   virtual std::string& GetFileName() { return m_strFileName; }
+  virtual CURL &GetURL() { return m_url; }
   virtual ENextStream NextStream() { return NEXTSTREAM_NONE; }
   virtual void Abort() {}
   virtual int GetBlockSize() { return 0; }
@@ -175,6 +177,7 @@ public:
 protected:
   DVDStreamType m_streamType;
   std::string m_strFileName;
+  CURL m_url;
   BitstreamStats m_stats;
   std::string m_content;
   CFileItem m_item;
index 67410f4..3a7accb 100644 (file)
@@ -254,8 +254,6 @@ bool CDVDInputStreamBluray::Open(const char* strFile, const std::string& content
   CStdString strPath(strFile);
   CStdString filename;
   CStdString root;
-  CStdString ext(URIUtils::GetExtension(strPath));
-  ext.ToLower();
 
   if(strPath.Left(7).Equals("bluray:"))
   {
@@ -263,8 +261,7 @@ bool CDVDInputStreamBluray::Open(const char* strFile, const std::string& content
     root     = url.GetHostName();
     filename = URIUtils::GetFileName(url.GetFileName());
   }
-  else if(ext == ".iso"
-       || ext == ".img")
+  else if(URIUtils::HasExtension(strPath, ".iso|.img"))
   {
     CURL url("udf://");
     url.SetHostName(strPath);
@@ -352,7 +349,7 @@ bool CDVDInputStreamBluray::Open(const char* strFile, const std::string& content
     m_navmode = false;
     m_title = GetTitleLongest();
   }
-  else if(URIUtils::GetExtension(filename).Equals(".mpls"))
+  else if(URIUtils::HasExtension(filename, ".mpls"))
   {
     m_navmode = false;
     m_title = GetTitleFile(filename);
index f37177e..3e8343c 100644 (file)
@@ -21,6 +21,7 @@
 #include "DVDInputStreamFile.h"
 #include "filesystem/File.h"
 #include "filesystem/IFile.h"
+#include "settings/AdvancedSettings.h"
 #include "utils/log.h"
 #include "utils/URIUtils.h"
 
@@ -53,6 +54,12 @@ bool CDVDInputStreamFile::Open(const char* strFile, const std::string& content)
 
   unsigned int flags = READ_TRUNCATED | READ_BITRATE | READ_CHUNKED;
 
+  if ( g_advancedSettings.m_alwaysForceBuffer && 
+       !URIUtils::IsOnDVD(strFile) && 
+       !URIUtils::IsBluray(strFile) )
+    flags |= READ_CACHED; 
+
+
   if (content == "video/mp4" || content == "video/x-msvideo" || content == "video/avi")
     flags |= READ_MULTI_STREAM;
 
index 084e76c..f8ffbec 100644 (file)
@@ -46,7 +46,7 @@ public:
   bool            PrevChannel(bool preview = false);
   bool            SelectChannelByNumber(unsigned int channel);
   bool            SelectChannel(const PVR::CPVRChannel &channel) { return false; }
-  bool            GetSelectedChannel(PVR::CPVRChannel *channel) {return false; }
+  static bool     GetSelectedChannel(PVR::CPVRChannel *channel) {return false; }
   bool            UpdateItem(CFileItem& item);
 
   bool            CanRecord()         { return false; }
index 03f6f19..3364505 100644 (file)
@@ -157,8 +157,8 @@ protected:
   int ConvertSubtitleStreamId_XBMCToExternal(int id);
   int ConvertSubtitleStreamId_ExternalToXBMC(int id);
 
-  void SetAudioStreamName(DVDNavStreamInfo &info, const audio_attr_t audio_attributes);
-  void SetSubtitleStreamName(DVDNavStreamInfo &info, const subp_attr_t subp_attributes);
+  static void SetAudioStreamName(DVDNavStreamInfo &info, const audio_attr_t audio_attributes);
+  static void SetSubtitleStreamName(DVDNavStreamInfo &info, const subp_attr_t subp_attributes);
 
   DllDvdNav m_dll;
   bool m_bCheckButtons;
index f0fcd89..1a06a72 100644 (file)
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "system.h" // just for HAS_LIBRTMP
 #endif
 
index ce42bfd..2e9cc47 100644 (file)
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "system.h"
 #endif
 
index ee3561b..e48516c 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 /* config.h.  Generated by hand.  */
-#if defined(_LINUX)
+#if defined(TARGET_POSIX)
 #include "PlatformInclude.h"
 #else
 #include <windows.h>
index b3b41f3..703bcf0 100644 (file)
 #include <limits.h>
 #include <string.h>
 
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
 
 /* pthread_mutex_* wrapper for win32 */
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #include <windows.h>
 #include <process.h>
 typedef CRITICAL_SECTION pthread_mutex_t;
@@ -42,7 +42,7 @@ typedef CRITICAL_SECTION pthread_mutex_t;
 #define pthread_mutex_lock(a)    EnterCriticalSection(a)
 #define pthread_mutex_unlock(a)  LeaveCriticalSection(a)
 #define pthread_mutex_destroy(a) DeleteCriticalSection(a)
-#endif // !_LINUX
+#endif // !TARGET_POSIX
 
 #ifndef HAVE_GETTIMEOFDAY
 /* replacement gettimeofday implementation */
@@ -58,16 +58,16 @@ static inline int _private_gettimeofday( struct timeval *tv, void *tz )
 #define gettimeofday(TV, TZ) _private_gettimeofday((TV), (TZ))
 #endif
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #include <io.h> /* read() */
 #define lseek64 _lseeki64
-#endif // !_LINUX
+#endif // !TARGET_POSIX
 
 #else
 
 #include <pthread.h>
 
-#endif /* WIN32 */
+#endif /* TARGET_WINDOWS */
 
 /* Uncomment for VM command tracing */
 /* #define TRACE */
@@ -217,7 +217,7 @@ dvdnav_status_t dvdnav_set_state(dvdnav_t *self, dvd_state_t *save_state);
 #else
 #define printerrf(...) \
        do { if (this) snprintf(this->err_str, MAX_ERR_LEN, __VA_ARGS__); } while (0)
-#endif /* WIN32 */
+#endif /* TARGET_WINDOWS */
 #endif
 #define printerr(str) \
        do { if (this) strncpy(this->err_str, str, MAX_ERR_LEN - 1); } while (0)
index a040836..22bc1e8 100644 (file)
@@ -622,7 +622,7 @@ bool CDVDPlayer::OpenInputStream()
     for(unsigned int i=0;i<filenames.size();i++)
     {
       // if vobsub subtitle:
-      if (URIUtils::GetExtension(filenames[i]) == ".idx")
+      if (URIUtils::HasExtension(filenames[i], ".idx"))
       {
         CStdString strSubFile;
         if ( CUtil::FindVobSubPair( filenames, filenames[i], strSubFile ) )
@@ -770,10 +770,9 @@ bool CDVDPlayer::ReadPacket(DemuxPacket*& packet, CDemuxStream*& stream)
 {
 
   // check if we should read from subtitle demuxer
-  if(m_dvdPlayerSubtitle.AcceptsData() && m_pSubtitleDemuxer )
+  if( m_pSubtitleDemuxer && m_dvdPlayerSubtitle.AcceptsData() )
   {
-    if(m_pSubtitleDemuxer)
-      packet = m_pSubtitleDemuxer->Read();
+    packet = m_pSubtitleDemuxer->Read();
 
     if(packet)
     {
@@ -3056,6 +3055,7 @@ bool CDVDPlayer::OpenSubtitleStream(int iStream, int source)
   m_CurrentSubtitle.stream = (void*)pStream;
   m_CurrentSubtitle.started = false;
 
+  CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream = m_SelectionStreams.IndexOf(STREAM_SUBTITLE, source, iStream);
   return true;
 }
 
@@ -3672,28 +3672,6 @@ bool CDVDPlayer::OnAction(const CAction &action)
     }
   }
 
-  switch (action.GetID())
-  {
-    case ACTION_NEXT_ITEM:
-      if(GetChapterCount() > 0)
-      {
-        m_messenger.Put(new CDVDMsgPlayerSeekChapter(GetChapter()+1));
-        g_infoManager.SetDisplayAfterSeek();
-        return true;
-      }
-      else
-        break;
-    case ACTION_PREV_ITEM:
-      if(GetChapterCount() > 0)
-      {
-        m_messenger.Put(new CDVDMsgPlayerSeekChapter(GetChapter()-1));
-        g_infoManager.SetDisplayAfterSeek();
-        return true;
-      }
-      else
-        break;
-  }
-
   // return false to inform the caller we didn't handle the message
   return false;
 }
index 80ac86b..6a02f9e 100644 (file)
@@ -498,7 +498,7 @@ void CDVDPlayerAudio::OnStartup()
 
   g_dvdPerformanceCounter.EnableAudioDecodePerformance(this);
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CoInitializeEx(NULL, COINIT_MULTITHREADED);
 #endif
 }
@@ -824,7 +824,7 @@ void CDVDPlayerAudio::OnExit()
 {
   g_dvdPerformanceCounter.DisableAudioDecodePerformance();
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CoUninitialize();
 #endif
 
index d95c768..cb69187 100644 (file)
@@ -34,7 +34,7 @@
 #include "DVDDemuxers/DVDDemuxUtils.h"
 #include "utils/log.h"
 #include "threads/SingleLock.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "config.h"
 #endif
 
index f27d6cb..1b9d88f 100644 (file)
@@ -20,7 +20,7 @@
 
 #pragma once
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 
index 14aa8e8..079b01d 100644 (file)
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 extern "C" {
-#if defined(WIN32)
+#if defined(TARGET_WINDOWS)
   #include "lib/libass/libass/ass.h"
 #else
   #include <ass/ass.h>
index 663780f..5a12711 100644 (file)
@@ -48,8 +48,8 @@ class CPullupCorrection
     void GetPattern(std::vector<double>& pattern);     //gets the current pattern
     void GetDifftypes(std::vector<double>& difftypes); //gets the difftypes from the ringbuffer
 
-    bool MatchDiff(double diff1, double diff2); //checks if two diffs match by MAXERR
-    bool MatchDifftype(int* diffs1, int* diffs2, int nrdiffs); //checks if the difftypes match
+    static bool MatchDiff(double diff1, double diff2); //checks if two diffs match by MAXERR
+    static bool MatchDifftype(int* diffs1, int* diffs2, int nrdiffs); //checks if the difftypes match
 
     //builds a pattern of timestamps in the ringbuffer
     void BuildPattern(std::vector<double>& pattern, int patternlength);
index 3395372..e9111d3 100644 (file)
@@ -18,9 +18,9 @@
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
 #include "system.h"
 #endif
 
@@ -66,7 +66,7 @@ static unsigned int WAVEChannels[OMX_MAX_CHANNELS] =
   SPEAKER_TOP_FRONT_CENTER, SPEAKER_LOW_FREQUENCY,
   SPEAKER_BACK_LEFT,        SPEAKER_BACK_RIGHT,
   SPEAKER_SIDE_LEFT,        SPEAKER_SIDE_RIGHT,
-  SPEAKER_BACK_CENTER,      SPEAKER_SIDE_RIGHT
+  SPEAKER_BACK_CENTER,      0
 };
 
 static const uint16_t AC3Bitrates[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640};
@@ -94,8 +94,6 @@ const float downmixing_coefficients_8[OMX_AUDIO_MAXCHANNELS] = {
 COMXAudio::COMXAudio() :
   m_pCallback       (NULL   ),
   m_Initialized     (false  ),
-  m_Pause           (false  ),
-  m_CanPause        (false  ),
   m_CurrentVolume   (0      ),
   m_drc             (0      ),
   m_Passthrough     (false  ),
@@ -107,15 +105,13 @@ COMXAudio::COMXAudio() :
   m_BitsPerSample   (0      ),
   m_omx_clock       (NULL   ),
   m_av_clock        (NULL   ),
-  m_first_frame     (true   ),
+  m_settings_changed(false  ),
   m_LostSync        (true   ),
   m_SampleRate      (0      ),
   m_eEncoding       (OMX_AUDIO_CodingPCM),
   m_extradata       (NULL   ),
   m_extrasize       (0      ),
-  m_vizBufferSamples(0      ),
-  m_last_pts        (DVD_NOPTS_VALUE),
-  m_omx_render      (NULL   )
+  m_last_pts        (DVD_NOPTS_VALUE)
 {
   m_vizBufferSize   = m_vizRemapBufferSize = VIS_PACKET_SIZE * sizeof(float);
   m_vizRemapBuffer  = (uint8_t *)_aligned_malloc(m_vizRemapBufferSize,16);
@@ -164,13 +160,110 @@ CAEChannelInfo COMXAudio::GetChannelLayout(AEAudioFormat format)
   return info;
 }
 
+
+bool COMXAudio::PortSettingsChanged()
+{
+  OMX_ERRORTYPE omx_err   = OMX_ErrorNone;
+
+  if (m_settings_changed)
+  {
+    m_omx_decoder.DisablePort(m_omx_decoder.GetOutputPort(), true);
+    m_omx_decoder.EnablePort(m_omx_decoder.GetOutputPort(), true);
+    return true;
+  }
+
+  if(!m_Passthrough)
+  {
+    if(!m_omx_mixer.Initialize("OMX.broadcom.audio_mixer", OMX_IndexParamAudioInit))
+      return false;
+  }
+
+  if(!m_omx_render.Initialize("OMX.broadcom.audio_render", OMX_IndexParamAudioInit))
+    return false;
+
+  m_omx_tunnel_clock.Initialize(m_omx_clock, m_omx_clock->GetInputPort(), &m_omx_render, m_omx_render.GetInputPort()+1);
+
+  omx_err = m_omx_tunnel_clock.Establish(false);
+  if(omx_err != OMX_ErrorNone)
+  {
+    CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_clock.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+    return false;
+  }
+
+  m_omx_render.ResetEos();
+
+  OMX_CONFIG_BRCMAUDIODESTINATIONTYPE audioDest;
+  OMX_INIT_STRUCTURE(audioDest);
+  strncpy((char *)audioDest.sName, m_deviceuse.c_str(), strlen(m_deviceuse.c_str()));
+
+  omx_err = m_omx_render.SetConfig(OMX_IndexConfigBrcmAudioDestination, &audioDest);
+  if (omx_err != OMX_ErrorNone)
+  {
+    CLog::Log(LOGERROR, "%s::%s - m_omx_render.SetConfig omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+    return false;
+  }
+
+  if(!m_Passthrough)
+  {
+    m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_mixer, m_omx_mixer.GetInputPort());
+    m_omx_tunnel_mixer.Initialize(&m_omx_mixer, m_omx_mixer.GetOutputPort(), &m_omx_render, m_omx_render.GetInputPort());
+    CLog::Log(LOGDEBUG, "%s::%s - bits:%d mode:%d channels:%d srate:%d nopassthrough", CLASSNAME, __func__,
+            (int)m_pcm_input.nBitPerSample, m_pcm_input.ePCMMode, (int)m_pcm_input.nChannels, (int)m_pcm_input.nSamplingRate);
+  }
+  else
+  {
+    m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_render, m_omx_render.GetInputPort());
+    CLog::Log(LOGDEBUG, "%s::%s - bits:%d mode:%d channels:%d srate:%d passthrough", CLASSNAME, __func__,
+            0, 0, 0, 0);
+  }
+
+  omx_err = m_omx_tunnel_decoder.Establish(false);
+  if(omx_err != OMX_ErrorNone)
+  {
+    CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_decoder.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+    return false;
+  }
+  if(!m_Passthrough)
+  {
+    omx_err = m_omx_mixer.SetStateForComponent(OMX_StateExecuting);
+    if(omx_err != OMX_ErrorNone) {
+      CLog::Log(LOGERROR, "%s::%s - m_omx_mixer OMX_StateExecuting omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+      return false;
+    }
+    omx_err = m_omx_tunnel_mixer.Establish(false);
+    if(omx_err != OMX_ErrorNone)
+    {
+      CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_decoder.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+      return false;
+    }
+  }
+
+  omx_err = m_omx_render.SetStateForComponent(OMX_StateExecuting);
+  if(omx_err != OMX_ErrorNone)
+  {
+    CLog::Log(LOGERROR, "%s::%s - m_omx_render OMX_StateExecuting omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+    return false;
+  }
+
+  m_settings_changed = true;
+  return true;
+}
+
 bool COMXAudio::Initialize(AEAudioFormat format, std::string& device, OMXClock *clock, CDVDStreamInfo &hints, bool bUsePassthrough, bool bUseHWDecode)
 {
+  OMX_ERRORTYPE omx_err;
+
   Deinitialize();
 
   if(!m_dllAvUtil.Load())
     return false;
 
+  if(device == "hdmi") {
+    m_deviceuse = "hdmi";
+  } else {
+    m_deviceuse = "local";
+  }
+
   m_HWDecode    = bUseHWDecode;
   m_Passthrough = bUsePassthrough;
 
@@ -231,29 +324,6 @@ bool COMXAudio::Initialize(AEAudioFormat format, std::string& device, OMXClock *
 
   if (!m_Passthrough)
   {
-    /* setup output channel map */
-    /*
-    int ch = 0, map;
-    int chan = 0;
-    m_OutputChannels = 0;
-
-    for (unsigned int ch = 0; ch < m_format.m_channelLayout.Count(); ++ch)
-    {
-      for(map = 0; map < OMX_MAX_CHANNELS; ++map)
-      {
-        if (m_output_channels[ch] == OMXChannelMap[map])
-        {
-          printf("output %d\n", chan);
-          m_output_channels[chan] = OMXChannels[map]; 
-          chan++;
-          break;
-        }
-      }
-    }
-
-    m_OutputChannels = chan;
-    */
-
     /* setup input channel map */
     int map = 0;
     int chan = 0;
@@ -285,7 +355,7 @@ bool COMXAudio::Initialize(AEAudioFormat format, std::string& device, OMXClock *
   m_pcm_output.eNumData            = OMX_NumericalDataSigned;
   m_pcm_output.eEndian             = OMX_EndianLittle;
   m_pcm_output.bInterleaved        = OMX_TRUE;
-  m_pcm_output.nBitPerSample       = CAEUtil::DataFormatToBits(m_format.m_dataFormat);
+  m_pcm_output.nBitPerSample       = 16; // float is decoded to 16bit integer by gpu
   m_pcm_output.ePCMMode            = OMX_AUDIO_PCMModeLinear;
   m_pcm_output.nChannels           = m_OutputChannels;
   m_pcm_output.nSamplingRate       = m_format.m_sampleRate;
@@ -293,73 +363,36 @@ bool COMXAudio::Initialize(AEAudioFormat format, std::string& device, OMXClock *
   m_SampleRate    = m_format.m_sampleRate;
   m_BitsPerSample = CAEUtil::DataFormatToBits(m_format.m_dataFormat);
   m_BufferLen     = m_BytesPerSec = m_format.m_sampleRate * 
-    (CAEUtil::DataFormatToBits(m_format.m_dataFormat) >> 3) * 
-    m_format.m_channelLayout.Count();
+    (m_BitsPerSample >> 3) * m_format.m_channelLayout.Count();
   m_BufferLen     *= AUDIO_BUFFER_SECONDS;
-  m_ChunkLen      = 6144;
+  // should be big enough that common formats (e.g. 6 channel DTS) fit in a single packet.
+  // we don't mind less common formats being split (e.g. ape/wma output large frames)
+  m_ChunkLen      = 32*1024;
 
   m_wave_header.Samples.wSamplesPerBlock    = 0;
   m_wave_header.Format.nChannels            = m_format.m_channelLayout.Count();
   m_wave_header.Format.nBlockAlign          = m_format.m_channelLayout.Count() * 
-    (CAEUtil::DataFormatToBits(m_format.m_dataFormat) >> 3);
-  m_wave_header.Format.wFormatTag           = WAVE_FORMAT_PCM;
+    (m_BitsPerSample >> 3);
+  // 0x8000 is custom format interpreted by GPU as WAVE_FORMAT_IEEE_FLOAT_PLANAR
+  m_wave_header.Format.wFormatTag           = m_BitsPerSample == 32 ? 0x8000 : WAVE_FORMAT_PCM;
   m_wave_header.Format.nSamplesPerSec       = m_format.m_sampleRate;
   m_wave_header.Format.nAvgBytesPerSec      = m_BytesPerSec;
-  m_wave_header.Format.wBitsPerSample       = CAEUtil::DataFormatToBits(m_format.m_dataFormat);
-  m_wave_header.Samples.wValidBitsPerSample = CAEUtil::DataFormatToBits(m_format.m_dataFormat);
+  m_wave_header.Format.wBitsPerSample       = m_BitsPerSample;
+  m_wave_header.Samples.wValidBitsPerSample = m_BitsPerSample;
   m_wave_header.Format.cbSize               = 0;
   m_wave_header.SubFormat                   = KSDATAFORMAT_SUBTYPE_PCM;
 
   m_pcm_input.eNumData              = OMX_NumericalDataSigned;
   m_pcm_input.eEndian               = OMX_EndianLittle;
   m_pcm_input.bInterleaved          = OMX_TRUE;
-  m_pcm_input.nBitPerSample         = CAEUtil::DataFormatToBits(m_format.m_dataFormat);
+  m_pcm_input.nBitPerSample         = m_BitsPerSample;
   m_pcm_input.ePCMMode              = OMX_AUDIO_PCMModeLinear;
   m_pcm_input.nChannels             = m_format.m_channelLayout.Count();
   m_pcm_input.nSamplingRate         = m_format.m_sampleRate;
 
-  std::string componentName = "OMX.broadcom.audio_render";
-
-  if(!m_omx_render)
-    m_omx_render = new COMXCoreComponent();
-  if(!m_omx_render)
-  {
-    CLog::Log(LOGERROR, "COMXAudio::Initialize error allocate OMX.broadcom.audio_render\n");
-    return false;
-  }
-
-  if(!m_omx_render->Initialize((const std::string)componentName, OMX_IndexParamAudioInit))
-    return false;
-
-  m_omx_render->ResetEos();
-
-  OMX_CONFIG_BRCMAUDIODESTINATIONTYPE audioDest;
-  OMX_INIT_STRUCTURE(audioDest);
-  strncpy((char *)audioDest.sName, device.c_str(), strlen(device.c_str()));
-
-  OMX_ERRORTYPE omx_err = m_omx_render->SetConfig(OMX_IndexConfigBrcmAudioDestination, &audioDest);
-  if (omx_err != OMX_ErrorNone)
-    return false;
-
-  OMX_CONFIG_BOOLEANTYPE configBool;
-  OMX_INIT_STRUCTURE(configBool);
-  configBool.bEnabled = OMX_FALSE;
-
-  omx_err = m_omx_render->SetConfig(OMX_IndexConfigBrcmClockReferenceSource, &configBool);
-  if (omx_err != OMX_ErrorNone)
-    return false;
-
-  componentName = "OMX.broadcom.audio_decode";
-  if(!m_omx_decoder.Initialize((const std::string)componentName, OMX_IndexParamAudioInit))
+  if(!m_omx_decoder.Initialize("OMX.broadcom.audio_decode", OMX_IndexParamAudioInit))
     return false;
 
-  if(!m_Passthrough)
-  {
-    componentName = "OMX.broadcom.audio_mixer";
-    if(!m_omx_mixer.Initialize((const std::string)componentName, OMX_IndexParamAudioInit))
-      return false;
-  }
-
   OMX_CONFIG_BOOLEANTYPE boolType;
   OMX_INIT_STRUCTURE(boolType);
   if(m_Passthrough)
@@ -393,11 +426,30 @@ bool COMXAudio::Initialize(AEAudioFormat format, std::string& device, OMXClock *
   omx_err = m_omx_decoder.SetParameter(OMX_IndexParamPortDefinition, &port_param);
   if(omx_err != OMX_ErrorNone)
   {
-    CLog::Log(LOGERROR, "COMXAudio::Initialize error set OMX_IndexParamPortDefinition omx_err(0x%08x)\n", omx_err);
+    CLog::Log(LOGERROR, "COMXAudio::Initialize error set OMX_IndexParamPortDefinition (intput) omx_err(0x%08x)\n", omx_err);
+    return false;
+  }
+
+  // set up the number/size of buffers for decoder output
+  OMX_INIT_STRUCTURE(port_param);
+  port_param.nPortIndex = m_omx_decoder.GetOutputPort();
+
+  omx_err = m_omx_decoder.GetParameter(OMX_IndexParamPortDefinition, &port_param);
+  if(omx_err != OMX_ErrorNone)
+  {
+    CLog::Log(LOGERROR, "COMXAudio::Initialize error get OMX_IndexParamPortDefinition (output) omx_err(0x%08x)\n", omx_err);
+    return false;
+  }
+
+  //port_param.nBufferCountActual = std::max(1, (int)(m_BufferLen / port_param.nBufferSize));
+
+  omx_err = m_omx_decoder.SetParameter(OMX_IndexParamPortDefinition, &port_param);
+  if(omx_err != OMX_ErrorNone)
+  {
+    CLog::Log(LOGERROR, "COMXAudio::Initialize error set OMX_IndexParamPortDefinition (output) omx_err(0x%08x)\n", omx_err);
     return false;
   }
 
-  //if(m_HWDecode)
   {
     OMX_AUDIO_PARAM_PORTFORMATTYPE formatType;
     OMX_INIT_STRUCTURE(formatType);
@@ -413,15 +465,6 @@ bool COMXAudio::Initialize(AEAudioFormat format, std::string& device, OMXClock *
     }
   }
 
-  m_omx_tunnel_clock.Initialize(m_omx_clock, m_omx_clock->GetInputPort(), m_omx_render, m_omx_render->GetInputPort()+1);
-
-  omx_err = m_omx_tunnel_clock.Establish(false);
-  if(omx_err != OMX_ErrorNone)
-  {
-    CLog::Log(LOGERROR, "COMXAudio::Initialize m_omx_tunnel_clock.Establish\n");
-    return false;
-  }
-
   omx_err = m_omx_decoder.AllocInputBuffers();
   if(omx_err != OMX_ErrorNone) 
   {
@@ -429,61 +472,12 @@ bool COMXAudio::Initialize(AEAudioFormat format, std::string& device, OMXClock *
     return false;
   }
 
-  if(!m_Passthrough)
-  {
-    m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_mixer, m_omx_mixer.GetInputPort());
-    omx_err = m_omx_tunnel_decoder.Establish(false);
-    if(omx_err != OMX_ErrorNone)
-    {
-      CLog::Log(LOGERROR, "COMXAudio::Initialize - Error m_omx_tunnel_decoder.Establish 0x%08x", omx_err);
-      return false;
-    }
-  
-    omx_err = m_omx_decoder.SetStateForComponent(OMX_StateExecuting);
-    if(omx_err != OMX_ErrorNone) {
-      CLog::Log(LOGERROR, "COMXAudio::Initialize - Error setting OMX_StateExecuting 0x%08x", omx_err);
-      return false;
-    }
-
-    m_omx_tunnel_mixer.Initialize(&m_omx_mixer, m_omx_mixer.GetOutputPort(), m_omx_render, m_omx_render->GetInputPort());
-    omx_err = m_omx_tunnel_mixer.Establish(false);
-    if(omx_err != OMX_ErrorNone)
-    {
-      CLog::Log(LOGERROR, "COMXAudio::Initialize - Error m_omx_tunnel_decoder.Establish 0x%08x", omx_err);
-      return false;
-    }
-  
-    omx_err = m_omx_mixer.SetStateForComponent(OMX_StateExecuting);
-    if(omx_err != OMX_ErrorNone) {
-      CLog::Log(LOGERROR, "COMXAudio::Initialize - Error setting OMX_StateExecuting 0x%08x", omx_err);
-      return false;
-    }
-  }
-  else
-  {
-    m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), m_omx_render, m_omx_render->GetInputPort());
-    omx_err = m_omx_tunnel_decoder.Establish(false);
-    if(omx_err != OMX_ErrorNone)
-    {
-      CLog::Log(LOGERROR, "COMXAudio::Initialize - Error m_omx_tunnel_decoder.Establish 0x%08x", omx_err);
-      return false;
-    }
-  
-    omx_err = m_omx_decoder.SetStateForComponent(OMX_StateExecuting);
-    if(omx_err != OMX_ErrorNone) {
-      CLog::Log(LOGERROR, "COMXAudio::Initialize - Error setting OMX_StateExecuting 0x%08x", omx_err);
-      return false;
-    }
-  }
-
-  omx_err = m_omx_render->SetStateForComponent(OMX_StateExecuting);
-  if(omx_err != OMX_ErrorNone) 
-  {
+  omx_err = m_omx_decoder.SetStateForComponent(OMX_StateExecuting);
+  if(omx_err != OMX_ErrorNone) {
     CLog::Log(LOGERROR, "COMXAudio::Initialize - Error setting OMX_StateExecuting 0x%08x", omx_err);
     return false;
   }
 
-  m_omx_decoder.EnablePort(m_omx_decoder.GetInputPort(), true);
 
   if(m_eEncoding == OMX_AUDIO_CodingPCM)
   {
@@ -551,7 +545,7 @@ bool COMXAudio::Initialize(AEAudioFormat format, std::string& device, OMXClock *
     return false;
 
   m_Initialized   = true;
-  m_first_frame   = true;
+  m_settings_changed = false;
   m_last_pts      = DVD_NOPTS_VALUE;
 
   CLog::Log(LOGDEBUG, "COMXAudio::Initialize Ouput bps %d samplerate %d channels %d buffer size %d bytes per second %d", 
@@ -576,21 +570,12 @@ bool COMXAudio::Deinitialize()
 
   m_omx_tunnel_clock.Deestablish();
   if(!m_Passthrough)
-  {
-    // workaround for the strange BCM mixer component
-    if(m_omx_mixer.GetState() == OMX_StateExecuting)
-      m_omx_mixer.SetStateForComponent(OMX_StatePause);
-    if(m_omx_mixer.GetState() != OMX_StateIdle)
-      m_omx_mixer.SetStateForComponent(OMX_StateIdle);
-    m_omx_mixer.DisableAllPorts();
-    m_omx_tunnel_mixer.Deestablish(true);
-  }
+    m_omx_tunnel_mixer.Deestablish();
   m_omx_tunnel_decoder.Deestablish();
 
   m_omx_decoder.FlushInput();
 
-  if(m_omx_render)
-    m_omx_render->Deinitialize(true);
+  m_omx_render.Deinitialize(true);
   if(!m_Passthrough)
     m_omx_mixer.Deinitialize(true);
   m_omx_decoder.Deinitialize(true);
@@ -612,12 +597,8 @@ bool COMXAudio::Deinitialize()
 
   m_dllAvUtil.Unload();
 
-  m_first_frame   = true;
   m_last_pts      = DVD_NOPTS_VALUE;
 
-  delete m_omx_render;
-  m_omx_render = NULL;
-
   return true;
 }
 
@@ -633,48 +614,6 @@ void COMXAudio::Flush()
   
   m_last_pts      = DVD_NOPTS_VALUE;
   m_LostSync      = true;
-  //m_first_frame   = true;
-}
-
-//***********************************************************************************************
-bool COMXAudio::Pause()
-{
-  if (!m_Initialized)
-     return -1;
-
-  if(m_Pause) return true;
-  m_Pause = true;
-
-  m_omx_decoder.SetStateForComponent(OMX_StatePause);
-
-  return true;
-}
-
-//***********************************************************************************************
-bool COMXAudio::Resume()
-{
-  if (!m_Initialized)
-     return -1;
-
-  if(!m_Pause) return true;
-  m_Pause = false;
-
-  m_omx_decoder.SetStateForComponent(OMX_StateExecuting);
-
-  return true;
-}
-
-//***********************************************************************************************
-bool COMXAudio::Stop()
-{
-  if (!m_Initialized)
-     return -1;
-
-  Flush();
-
-  m_Pause = false;
-
-  return true;
 }
 
 //***********************************************************************************************
@@ -755,14 +694,14 @@ bool COMXAudio::SetCurrentVolume(float fVolume)
   {
     OMX_AUDIO_CONFIG_VOLUMETYPE volume;
     OMX_INIT_STRUCTURE(volume);
-    volume.nPortIndex = m_omx_render->GetInputPort();
+    volume.nPortIndex = m_omx_render.GetInputPort();
 
     volume.bLinear    = OMX_TRUE;
     float hardwareVolume = fVolume * gain * 100.0f;
     volume.sVolume.nValue = (int)(hardwareVolume + 0.5f);
 
     OMX_ERRORTYPE omx_err =
-      m_omx_render->SetConfig(OMX_IndexConfigAudioVolume, &volume);
+      m_omx_render.SetConfig(OMX_IndexConfigAudioVolume, &volume);
     if(omx_err != OMX_ErrorNone)
     {
       CLog::Log(LOGERROR, "%s::%s - error setting OMX_IndexConfigAudioVolume, error 0x%08x\n",
@@ -791,37 +730,42 @@ unsigned int COMXAudio::AddPackets(const void* data, unsigned int len, double dt
     return len;
   }
 
-  m_vizBufferSamples = 0;
-
-  if (m_pCallback && len)
+  if (m_pCallback && len && !(m_Passthrough || m_HWDecode))
   {
     /* input samples */
-    m_vizBufferSamples = len / (CAEUtil::DataFormatToBits(AE_FMT_S16LE) >> 3);
-    CAEConvert::AEConvertToFn m_convertFn = CAEConvert::ToFloat(AE_FMT_S16LE);
+    unsigned int vizBufferSamples = len / (CAEUtil::DataFormatToBits(m_format.m_dataFormat) >> 3);
+
     /* input frames */
-    unsigned int frames = m_vizBufferSamples / m_format.m_channelLayout.Count();
+    unsigned int frames = vizBufferSamples / m_format.m_channelLayout.Count();
+    float *floatBuffer = (float *)data;
 
-    /* check convert buffer */
-    CheckOutputBufferSize((void **)&m_vizBuffer, &m_vizBufferSize, m_vizBufferSamples * (CAEUtil::DataFormatToBits(AE_FMT_FLOAT) >> 3));
+    if (m_format.m_dataFormat != AE_FMT_FLOAT)
+    {
+      CAEConvert::AEConvertToFn m_convertFn = CAEConvert::ToFloat(m_format.m_dataFormat);
+
+      /* check convert buffer */
+      CheckOutputBufferSize((void **)&m_vizBuffer, &m_vizBufferSize, vizBufferSamples * (CAEUtil::DataFormatToBits(AE_FMT_FLOAT) >> 3));
 
-    /* convert to float */
-    m_convertFn((uint8_t *)data, m_vizBufferSamples, (float *)m_vizBuffer);
+      /* convert to float */
+      m_convertFn((uint8_t *)data, vizBufferSamples, (float *)m_vizBuffer);
+      floatBuffer = (float *)m_vizBuffer;
+    }
 
-    /* check remap buffer */
-    CheckOutputBufferSize((void **)&m_vizRemapBuffer, &m_vizRemapBufferSize, frames * 2 * (CAEUtil::DataFormatToBits(AE_FMT_FLOAT) >> 3));
+    // Viz channel count is 2
+    CheckOutputBufferSize((void **)&m_vizRemapBuffer, &m_vizRemapBufferSize, frames * 2 * sizeof(float));
 
     /* remap */
-    m_vizRemap.Remap((float *)m_vizBuffer, (float*)m_vizRemapBuffer, frames);
+    m_vizRemap.Remap(floatBuffer, (float*)m_vizRemapBuffer, frames);
 
     /* output samples */
-    m_vizBufferSamples = m_vizBufferSamples / m_format.m_channelLayout.Count() * 2;
+    vizBufferSamples = vizBufferSamples / m_format.m_channelLayout.Count() * 2;
 
     /* viz size is limited */
-    if(m_vizBufferSamples > VIS_PACKET_SIZE)
-      m_vizBufferSamples = VIS_PACKET_SIZE;
+    if(vizBufferSamples > VIS_PACKET_SIZE)
+      vizBufferSamples = VIS_PACKET_SIZE;
 
     if(m_pCallback)
-      m_pCallback->OnAudioData((float *)m_vizRemapBuffer, m_vizBufferSamples);
+      m_pCallback->OnAudioData((float *)m_vizRemapBuffer, vizBufferSamples);
   }
 
   if(m_eEncoding == OMX_AUDIO_CodingDTS && m_LostSync && (m_Passthrough || m_HWDecode))
@@ -838,14 +782,17 @@ unsigned int COMXAudio::AddPackets(const void* data, unsigned int len, double dt
       return len;
   }
 
-  unsigned int demuxer_bytes = (unsigned int)len;
+  int m_InputChannels = m_format.m_channelLayout.Count();
+  unsigned pitch = (m_Passthrough || m_HWDecode) ? 1:(m_BitsPerSample >> 3) * m_InputChannels;
+  unsigned int demuxer_samples = len / pitch;
+  unsigned int demuxer_samples_sent = 0;
   uint8_t *demuxer_content = (uint8_t *)data;
 
   OMX_ERRORTYPE omx_err;
 
   OMX_BUFFERHEADERTYPE *omx_buffer = NULL;
 
-  while(demuxer_bytes)
+  while(demuxer_samples_sent < demuxer_samples)
   {
     // 200ms timeout
     omx_buffer = m_omx_decoder.GetInputBuffer(200);
@@ -859,8 +806,31 @@ unsigned int COMXAudio::AddPackets(const void* data, unsigned int len, double dt
     omx_buffer->nOffset = 0;
     omx_buffer->nFlags  = 0;
 
-    omx_buffer->nFilledLen = (demuxer_bytes > omx_buffer->nAllocLen) ? omx_buffer->nAllocLen : demuxer_bytes;
-    memcpy(omx_buffer->pBuffer, demuxer_content, omx_buffer->nFilledLen);
+    unsigned int remaining = demuxer_samples-demuxer_samples_sent;
+    unsigned int samples_space = omx_buffer->nAllocLen/pitch;
+    unsigned int samples = std::min(remaining, samples_space);
+
+    omx_buffer->nFilledLen = samples * pitch;
+
+    if (samples < demuxer_samples && m_BitsPerSample==32 && !(m_Passthrough || m_HWDecode))
+    {
+       uint8_t *dst = omx_buffer->pBuffer;
+       uint8_t *src = demuxer_content + demuxer_samples_sent * (m_BitsPerSample >> 3);
+       // we need to extract samples from planar audio, so the copying needs to be done per plane
+       for (int i=0; i<m_InputChannels; i++)
+       {
+         memcpy(dst, src, omx_buffer->nFilledLen / m_InputChannels);
+         dst += omx_buffer->nFilledLen / m_InputChannels;
+         src += demuxer_samples * (m_BitsPerSample >> 3);
+       }
+       assert(dst <= omx_buffer->pBuffer + m_ChunkLen);
+    }
+    else
+    {
+       uint8_t *dst = omx_buffer->pBuffer;
+       uint8_t *src = demuxer_content + demuxer_samples_sent * pitch;
+       memcpy(dst, src, omx_buffer->nFilledLen);
+    }
 
     uint64_t val  = (uint64_t)(pts == DVD_NOPTS_VALUE) ? 0 : pts;
 
@@ -897,10 +867,9 @@ unsigned int COMXAudio::AddPackets(const void* data, unsigned int len, double dt
 
     omx_buffer->nTimeStamp = ToOMXTime(val);
 
-    demuxer_bytes -= omx_buffer->nFilledLen;
-    demuxer_content += omx_buffer->nFilledLen;
+    demuxer_samples_sent += samples;
 
-    if(demuxer_bytes == 0)
+    if(demuxer_samples_sent == demuxer_samples)
       omx_buffer->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
 
     int nRetry = 0;
@@ -924,156 +893,14 @@ unsigned int COMXAudio::AddPackets(const void* data, unsigned int len, double dt
       }
     }
 
-    if(m_first_frame)
+    omx_err = m_omx_decoder.WaitForEvent(OMX_EventPortSettingsChanged, 0);
+    if (omx_err == OMX_ErrorNone)
     {
-      m_first_frame = false;
-      //m_omx_render.WaitForEvent(OMX_EventPortSettingsChanged);
-
-      m_omx_render->DisablePort(m_omx_render->GetInputPort(), false);
-      if(!m_Passthrough)
-      {
-        m_omx_mixer.DisablePort(m_omx_mixer.GetOutputPort(), false);
-        m_omx_mixer.DisablePort(m_omx_mixer.GetInputPort(), false);
-      }
-      m_omx_decoder.DisablePort(m_omx_decoder.GetOutputPort(), false);
-
-      if(!m_Passthrough)
-      {
-        if(m_HWDecode)
-        {
-          OMX_INIT_STRUCTURE(m_pcm_input);
-          m_pcm_input.nPortIndex      = m_omx_decoder.GetOutputPort();
-          omx_err = m_omx_decoder.GetParameter(OMX_IndexParamAudioPcm, &m_pcm_input);
-          if(omx_err != OMX_ErrorNone)
-          {
-            CLog::Log(LOGERROR, "COMXAudio::AddPackets error GetParameter 1 omx_err(0x%08x)\n", omx_err);
-          }
-        }
-
-        memcpy(m_pcm_input.eChannelMapping, m_input_channels, sizeof(m_input_channels));
-        m_pcm_input.nSamplingRate = m_format.m_sampleRate;
-
-        /* setup mixer input */
-        m_pcm_input.nPortIndex      = m_omx_mixer.GetInputPort();
-        omx_err = m_omx_mixer.SetParameter(OMX_IndexParamAudioPcm, &m_pcm_input);
-        if(omx_err != OMX_ErrorNone)
-        {
-          CLog::Log(LOGERROR, "COMXAudio::AddPackets error SetParameter 1 input omx_err(0x%08x)\n", omx_err);
-        }
-        omx_err = m_omx_mixer.GetParameter(OMX_IndexParamAudioPcm, &m_pcm_input);
-        if(omx_err != OMX_ErrorNone)
-        {
-          CLog::Log(LOGERROR, "COMXAudio::AddPackets error GetParameter 2 input omx_err(0x%08x)\n", omx_err);
-        }
-
-        m_pcm_output.nSamplingRate = m_format.m_sampleRate;
-
-        /* setup mixer output */
-        m_pcm_output.nPortIndex      = m_omx_mixer.GetOutputPort();
-        omx_err = m_omx_mixer.SetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
-        if(omx_err != OMX_ErrorNone)
-        {
-          CLog::Log(LOGERROR, "COMXAudio::AddPackets error SetParameter 1 output omx_err(0x%08x)\n", omx_err);
-        }
-        omx_err = m_omx_mixer.GetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
-        if(omx_err != OMX_ErrorNone)
-        {
-          CLog::Log(LOGERROR, "COMXAudio::AddPackets error GetParameter 2 output omx_err(0x%08x)\n", omx_err);
-        }
-
-        m_pcm_output.nSamplingRate = m_format.m_sampleRate;
-
-        m_pcm_output.nPortIndex      = m_omx_render->GetInputPort();
-        omx_err = m_omx_render->SetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
-        if(omx_err != OMX_ErrorNone)
-        {
-          CLog::Log(LOGERROR, "COMXAudio::AddPackets error SetParameter 1 render omx_err(0x%08x)\n", omx_err);
-        }
-        omx_err = m_omx_render->GetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
-        if(omx_err != OMX_ErrorNone)
-        {
-          CLog::Log(LOGERROR, "COMXAudio::AddPackets error GetParameter 2 render omx_err(0x%08x)\n", omx_err);
-        }
-
-        PrintPCM(&m_pcm_input, std::string("input"));
-        PrintPCM(&m_pcm_output, std::string("output"));
-      }
-      else
-      {
-        OMX_AUDIO_PARAM_PORTFORMATTYPE formatType;
-        OMX_INIT_STRUCTURE(formatType);
-        formatType.nPortIndex = m_omx_render->GetInputPort();
-
-        omx_err = m_omx_render->GetParameter(OMX_IndexParamAudioPortFormat, &formatType);
-        if(omx_err != OMX_ErrorNone)
-        {
-          CLog::Log(LOGERROR, "COMXAudio::AddPackets error OMX_IndexParamAudioPortFormat omx_err(0x%08x)\n", omx_err);
-          assert(0);
-        }
-
-        formatType.eEncoding = m_eEncoding;
-
-        omx_err = m_omx_render->SetParameter(OMX_IndexParamAudioPortFormat, &formatType);
-        if(omx_err != OMX_ErrorNone)
-        {
-          CLog::Log(LOGERROR, "COMXAudio::AddPackets error OMX_IndexParamAudioPortFormat omx_err(0x%08x)\n", omx_err);
-          assert(0);
-        }
-
-        if(m_eEncoding == OMX_AUDIO_CodingDDP)
-        {
-          OMX_AUDIO_PARAM_DDPTYPE m_ddParam;
-          OMX_INIT_STRUCTURE(m_ddParam);
-
-          m_ddParam.nPortIndex      = m_omx_render->GetInputPort();
-
-          m_ddParam.nChannels       = m_format.m_channelLayout.Count(); //(m_InputChannels == 6) ? 8 : m_InputChannels;
-          m_ddParam.nSampleRate     = m_SampleRate;
-          m_ddParam.eBitStreamId    = OMX_AUDIO_DDPBitStreamIdAC3;
-          m_ddParam.nBitRate        = 0;
-
-          for(unsigned int i = 0; i < OMX_MAX_CHANNELS; i++)
-          {
-            if(i >= m_ddParam.nChannels)
-              break;
-
-            m_ddParam.eChannelMapping[i] = OMXChannels[i];
-          }
-  
-          m_omx_render->SetParameter(OMX_IndexParamAudioDdp, &m_ddParam);
-          m_omx_render->GetParameter(OMX_IndexParamAudioDdp, &m_ddParam);
-          PrintDDP(&m_ddParam);
-        }
-        else if(m_eEncoding == OMX_AUDIO_CodingDTS)
-        {
-          m_dtsParam.nPortIndex      = m_omx_render->GetInputPort();
-
-          m_dtsParam.nChannels       = m_format.m_channelLayout.Count(); //(m_InputChannels == 6) ? 8 : m_InputChannels;
-          m_dtsParam.nBitRate        = 0;
-
-          for(unsigned int i = 0; i < OMX_MAX_CHANNELS; i++)
-          {
-            if(i >= m_dtsParam.nChannels)
-              break;
-
-            m_dtsParam.eChannelMapping[i] = OMXChannels[i];
-          }
-  
-          m_omx_render->SetParameter(OMX_IndexParamAudioDts, &m_dtsParam);
-          m_omx_render->GetParameter(OMX_IndexParamAudioDts, &m_dtsParam);
-          PrintDTS(&m_dtsParam);
-        }
-      }
-
-      m_omx_render->EnablePort(m_omx_render->GetInputPort(), false);
-      if(!m_Passthrough)
+      if(!PortSettingsChanged())
       {
-        m_omx_mixer.EnablePort(m_omx_mixer.GetOutputPort(), false);
-        m_omx_mixer.EnablePort(m_omx_mixer.GetInputPort(), false);
+        CLog::Log(LOGERROR, "%s::%s - error PortSettingsChanged omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
       }
-      m_omx_decoder.EnablePort(m_omx_decoder.GetOutputPort(), false);
     }
   }
 
   return len;
@@ -1089,7 +916,7 @@ unsigned int COMXAudio::GetSpace()
 float COMXAudio::GetDelay()
 {
   unsigned int free = m_omx_decoder.GetInputBufferSize() - m_omx_decoder.GetInputBufferSpace();
-  return (float)free / (float)m_BytesPerSec;
+  return m_BytesPerSec ? (float)free / (float)m_BytesPerSec : 0.0f;
 }
 
 float COMXAudio::GetCacheTime()
@@ -1097,13 +924,13 @@ float COMXAudio::GetCacheTime()
   float fBufferLenFull = (float)m_BufferLen - (float)GetSpace();
   if(fBufferLenFull < 0)
     fBufferLenFull = 0;
-  float ret = fBufferLenFull / (float)m_BytesPerSec;
+  float ret = m_BytesPerSec ? fBufferLenFull / (float)m_BytesPerSec : 0.0f;
   return ret;
 }
 
 float COMXAudio::GetCacheTotal()
 {
-  return (float)m_BufferLen / (float)m_BytesPerSec;
+  return m_BytesPerSec ? (float)m_BufferLen / (float)m_BytesPerSec : 0.0f;
 }
 
 //***********************************************************************************************
@@ -1119,7 +946,6 @@ int COMXAudio::SetPlaySpeed(int iSpeed)
 
 void COMXAudio::RegisterAudioCallback(IAudioCallback *pCallback)
 {
-  m_vizBufferSamples = 0;
   if(!m_Passthrough && !m_HWDecode)
   {
     m_pCallback = pCallback;
@@ -1133,7 +959,6 @@ void COMXAudio::RegisterAudioCallback(IAudioCallback *pCallback)
 void COMXAudio::UnRegisterAudioCallback()
 {
   m_pCallback = NULL;
-  m_vizBufferSamples = 0;
 }
 
 unsigned int COMXAudio::GetAudioRenderingLatency()
@@ -1145,10 +970,10 @@ unsigned int COMXAudio::GetAudioRenderingLatency()
 
   OMX_PARAM_U32TYPE param;
   OMX_INIT_STRUCTURE(param);
-  param.nPortIndex = m_omx_render->GetInputPort();
+  param.nPortIndex = m_omx_render.GetInputPort();
 
   OMX_ERRORTYPE omx_err =
-    m_omx_render->GetConfig(OMX_IndexConfigAudioRenderingLatency, &param);
+    m_omx_render.GetConfig(OMX_IndexConfigAudioRenderingLatency, &param);
 
   if(omx_err != OMX_ErrorNone)
   {
@@ -1164,7 +989,7 @@ void COMXAudio::SubmitEOS()
 {
   CSingleLock lock (m_critSection);
 
-  if(!m_Initialized || m_Pause)
+  if(!m_Initialized)
     return;
 
   OMX_ERRORTYPE omx_err = OMX_ErrorNone;
@@ -1192,7 +1017,7 @@ void COMXAudio::SubmitEOS()
 
 bool COMXAudio::IsEOS()
 {
-  if(!m_Initialized || m_Pause)
+  if(!m_Initialized)
     return true;
   unsigned int latency = GetAudioRenderingLatency();
   CSingleLock lock (m_critSection);
@@ -1434,7 +1259,6 @@ unsigned int COMXAudio::SyncDTS(BYTE* pData, unsigned int iSize)
 unsigned int COMXAudio::SyncAC3(BYTE* pData, unsigned int iSize)
 {
   unsigned int skip = 0;
-  //unsigned int fSize = 0;
 
   for(skip = 0; iSize - skip > 6; ++skip, ++pData)
   {
@@ -1463,7 +1287,6 @@ unsigned int COMXAudio::SyncAC3(BYTE* pData, unsigned int iSize)
       case 2: framesize = bitrate * 4; break;
     }
 
-    //fSize = framesize * 2;
     m_SampleRate = AC3FSCod[fscod];
 
     /* dont do extensive testing if we have not lost sync */
index 9537d9e..0b59873 100644 (file)
@@ -61,15 +61,13 @@ public:
   float GetCacheTotal();
   COMXAudio();
   bool Initialize(AEAudioFormat format, std::string& device, OMXClock *clock, CDVDStreamInfo &hints, bool bUsePassthrough, bool bUseHWDecode);
+  bool PortSettingsChanged();
   ~COMXAudio();
 
   unsigned int AddPackets(const void* data, unsigned int len);
   unsigned int AddPackets(const void* data, unsigned int len, double dts, double pts);
   unsigned int GetSpace();
   bool Deinitialize();
-  bool Pause();
-  bool Stop();
-  bool Resume();
 
   long GetCurrentVolume() const;
   void Mute(bool bMute);
@@ -87,7 +85,7 @@ public:
   void SetCodingType(AEDataFormat dataFormat);
   static bool CanHWDecode(CodecID codec);
 
-  void PrintChannels(OMX_AUDIO_CHANNELTYPE eChannelMapping[]);
+  static void PrintChannels(OMX_AUDIO_CHANNELTYPE eChannelMapping[]);
   void PrintPCM(OMX_AUDIO_PARAM_PCMMODETYPE *pcm, std::string direction);
   void PrintDDP(OMX_AUDIO_PARAM_DDPTYPE *ddparm);
   void PrintDTS(OMX_AUDIO_PARAM_DTSTYPE *dtsparam);
@@ -100,8 +98,6 @@ public:
 private:
   IAudioCallback* m_pCallback;
   bool          m_Initialized;
-  bool          m_Pause;
-  bool          m_CanPause;
   float         m_CurrentVolume;
   long          m_drc;
   bool          m_Passthrough;
@@ -113,14 +109,14 @@ private:
   unsigned int  m_BitsPerSample;
   COMXCoreComponent *m_omx_clock;
   OMXClock       *m_av_clock;
-  bool          m_first_frame;
+  bool          m_settings_changed;
   bool          m_LostSync;
   int           m_SampleRate;
   OMX_AUDIO_CODINGTYPE m_eEncoding;
   uint8_t       *m_extradata;
   int           m_extrasize;
+  std::string   m_deviceuse;
   // stuff for visualisation
-  unsigned int  m_vizBufferSamples;
   double        m_last_pts;
   int           m_vizBufferSize;
   uint8_t       *m_vizBuffer;
@@ -134,7 +130,7 @@ private:
   WAVEFORMATEXTENSIBLE        m_wave_header;
   AEAudioFormat m_format;
 protected:
-  COMXCoreComponent *m_omx_render;
+  COMXCoreComponent m_omx_render;
   COMXCoreComponent m_omx_mixer;
   COMXCoreComponent m_omx_decoder;
   COMXCoreTunel     m_omx_tunnel_clock;
@@ -147,9 +143,9 @@ protected:
 
   CAEChannelInfo    m_channelLayout;
 
-  CAEChannelInfo    GetChannelLayout(AEAudioFormat format);
+  static CAEChannelInfo    GetChannelLayout(AEAudioFormat format);
 
-  void CheckOutputBufferSize(void **buffer, int *oldSize, int newSize);
+  static void CheckOutputBufferSize(void **buffer, int *oldSize, int newSize);
   CCriticalSection m_critSection;
 };
 #endif
index 5b5e13d..2d8fa7a 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #include "OMXAudioCodecOMX.h"
-#ifdef _LINUX
+#ifdef TARGET_LINUX
 #include "XMemUtils.h"
 #endif
 #include "utils/log.h"
 
 #define MAX_AUDIO_FRAME_SIZE (AVCODEC_MAX_AUDIO_FRAME_SIZE*2)
 
-template <class AudioDataType>
-static inline void _Upmix(AudioDataType *input,
-  unsigned int channelsInput, AudioDataType *output,
-  unsigned int channelsOutput, unsigned int frames)
-{
-  unsigned int unused = channelsOutput - channelsInput;
-  AudioDataType *_input  = input;
-  AudioDataType *_output = output;
-
-  for (unsigned int i = 0; i < frames; i++)
-  {
-    // get input channels
-    for(unsigned int j = 0; j < channelsInput; j++)
-      *_output++ = *_input++;
-    // set unused channels
-    for(unsigned int j = 0; j < unused; j++)
-      *_output++ = 0;
-  }
-}
-
-void COMXAudioCodecOMX::Upmix(void *input,
-  unsigned int channelsInput,  void *output,
-  unsigned int channelsOutput, unsigned int frames, AEDataFormat dataFormat)
-{
-  // input channels must be less than output channels
-  if (channelsInput >= channelsOutput)
-    return;
-
-  switch (CAEUtil::DataFormatToBits(dataFormat))
-  {
-    case 8:  _Upmix ( (unsigned char *) input, channelsInput, (unsigned char *) output, channelsOutput, frames ); break;
-    case 16: _Upmix ( (short         *) input, channelsInput, (short         *) output, channelsOutput, frames ); break;
-    case 32: _Upmix ( (float         *) input, channelsInput, (float         *) output, channelsOutput, frames ); break;
-    default: _Upmix ( (int           *) input, channelsInput, (int           *) output, channelsOutput, frames ); break;
-  }
-}
-
 COMXAudioCodecOMX::COMXAudioCodecOMX()
 {
   m_iBufferSize2 = 0;
@@ -84,6 +47,7 @@ COMXAudioCodecOMX::COMXAudioCodecOMX()
   m_layout = 0;
   m_pFrame1 = NULL;
   m_iSampleFormat = AV_SAMPLE_FMT_NONE;
+  m_desiredSampleFormat = AV_SAMPLE_FMT_NONE;
   m_iBufferSize1 = 0;
 }
 
@@ -111,6 +75,7 @@ bool COMXAudioCodecOMX::Open(CDVDStreamInfo &hints)
     return false;
   }
 
+  m_bFirstFrame = true;
   m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
   m_pCodecContext->debug_mv = 0;
   m_pCodecContext->debug = 0;
@@ -146,6 +111,7 @@ bool COMXAudioCodecOMX::Open(CDVDStreamInfo &hints)
   m_pFrame1 = m_dllAvCodec.avcodec_alloc_frame();
   m_bOpenedCodec = true;
   m_iSampleFormat = AV_SAMPLE_FMT_NONE;
+  m_desiredSampleFormat = m_pCodecContext->sample_fmt == AV_SAMPLE_FMT_S16 ? AV_SAMPLE_FMT_S16 : AV_SAMPLE_FMT_FLTP;
   return true;
 }
 
@@ -159,6 +125,8 @@ void COMXAudioCodecOMX::Dispose()
 
   if (m_pCodecContext)
   {
+    if (m_pCodecContext->extradata) m_dllAvUtil.av_free(m_pCodecContext->extradata);
+    m_pCodecContext->extradata = NULL;
     if (m_bOpenedCodec) m_dllAvCodec.avcodec_close(m_pCodecContext);
     m_bOpenedCodec = false;
     m_dllAvUtil.av_free(m_pCodecContext);
@@ -179,9 +147,6 @@ int COMXAudioCodecOMX::Decode(BYTE* pData, int iSize)
   int iBytesUsed, got_frame;
   if (!m_pCodecContext) return -1;
 
-  m_iBufferSize1 = AVCODEC_MAX_AUDIO_FRAME_SIZE;
-  m_iBufferSize2 = 0;
-
   AVPacket avpkt;
   m_dllAvCodec.av_init_packet(&avpkt);
   avpkt.data = pData;
@@ -196,7 +161,9 @@ int COMXAudioCodecOMX::Decode(BYTE* pData, int iSize)
     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);
+  int linesize1, linesize2;
+  m_iBufferSize1 = m_dllAvUtil.av_samples_get_buffer_size(&linesize1, m_pCodecContext->channels, m_pFrame1->nb_samples, m_pCodecContext->sample_fmt, 1);
+  m_iBufferSize2 = m_dllAvUtil.av_samples_get_buffer_size(&linesize2, m_pCodecContext->channels, m_pFrame1->nb_samples, m_desiredSampleFormat, 1);
 
   /* some codecs will attempt to consume more data than what we gave */
   if (iBytesUsed > iSize)
@@ -210,7 +177,16 @@ int COMXAudioCodecOMX::Decode(BYTE* pData, int iSize)
   else
     m_iBuffered = 0;
 
-  if(m_pCodecContext->sample_fmt != AV_SAMPLE_FMT_S16 && m_iBufferSize1 > 0)
+  if (m_bFirstFrame)
+  {
+    CLog::Log(LOGDEBUG, "COMXAudioCodecOMX::Decode(%p,%d) format=%d(%d) chan=%d samples=%d size=%d/%d,%d/%d,%d data=%p,%p,%p,%p,%p,%p,%p,%p",
+             pData, iSize, m_pCodecContext->sample_fmt, m_desiredSampleFormat, m_pCodecContext->channels, m_pFrame1->nb_samples,
+             m_iBufferSize1, m_iBufferSize2, linesize1, linesize2, m_pFrame1->linesize[0],
+             m_pFrame1->data[0], m_pFrame1->data[1], m_pFrame1->data[2], m_pFrame1->data[3], m_pFrame1->data[4], m_pFrame1->data[5], m_pFrame1->data[6], m_pFrame1->data[7]
+             );
+  }
+
+  if(m_pCodecContext->sample_fmt != m_desiredSampleFormat && m_iBufferSize1 > 0)
   {
     if(m_pConvert && (m_pCodecContext->sample_fmt != m_iSampleFormat || m_channels != m_pCodecContext->channels))
       m_dllSwResample.swr_free(&m_pConvert);
@@ -220,7 +196,7 @@ int COMXAudioCodecOMX::Decode(BYTE* pData, int iSize)
       m_iSampleFormat = m_pCodecContext->sample_fmt;
       m_pConvert = m_dllSwResample.swr_alloc_set_opts(NULL,
                       m_dllAvUtil.av_get_default_channel_layout(m_pCodecContext->channels), 
-                      AV_SAMPLE_FMT_S16, m_pCodecContext->sample_rate,
+                      m_desiredSampleFormat, m_pCodecContext->sample_rate,
                       m_dllAvUtil.av_get_default_channel_layout(m_pCodecContext->channels), 
                       m_pCodecContext->sample_fmt, m_pCodecContext->sample_rate,
                       0, NULL);
@@ -228,23 +204,29 @@ int COMXAudioCodecOMX::Decode(BYTE* pData, int iSize)
 
     if(!m_pConvert || m_dllSwResample.swr_init(m_pConvert) < 0)
     {
-      CLog::Log(LOGERROR, "COMXAudioCodecOMX::Decode - Unable to convert %d to AV_SAMPLE_FMT_S16", m_pCodecContext->sample_fmt);
+      CLog::Log(LOGERROR, "COMXAudioCodecOMX::Decode - Unable to initialise convert format %d to %d", m_pCodecContext->sample_fmt, m_desiredSampleFormat);
       m_iBufferSize1 = 0;
       m_iBufferSize2 = 0;
       return iBytesUsed;
     }
+    m_iBufferSize1 = 0;
+
+    BYTE *out_planes[] = {
+            m_pBuffer2 + 0 * linesize2, m_pBuffer2 + 1 * linesize2, m_pBuffer2 + 2 * linesize2, m_pBuffer2 + 3 * linesize2,
+            m_pBuffer2 + 4 * linesize2, m_pBuffer2 + 5 * linesize2, m_pBuffer2 + 6 * linesize2, m_pBuffer2 + 7 * linesize2,
+    };
 
-    int len = m_iBufferSize1 / m_dllAvUtil.av_get_bytes_per_sample(m_pCodecContext->sample_fmt);
-    if(m_dllSwResample.swr_convert(m_pConvert, &m_pBuffer2, len, (const uint8_t**)m_pFrame1->data, m_pFrame1->nb_samples) < 0)
+    if(m_dllSwResample.swr_convert(m_pConvert, out_planes, m_pFrame1->nb_samples, (const uint8_t **)m_pFrame1->data, m_pFrame1->nb_samples) < 0)
     {
-      CLog::Log(LOGERROR, "COMXAudioCodecOMX::Decode - Unable to convert %d to AV_SAMPLE_FMT_S16", (int)m_pCodecContext->sample_fmt);
+      CLog::Log(LOGERROR, "COMXAudioCodecOMX::Decode - Unable to convert format %d to %d", (int)m_pCodecContext->sample_fmt, m_desiredSampleFormat);
       m_iBufferSize1 = 0;
       m_iBufferSize2 = 0;
       return iBytesUsed;
     }
-
-    m_iBufferSize1 = 0;
-    m_iBufferSize2 = len * m_dllAvUtil.av_get_bytes_per_sample(AV_SAMPLE_FMT_S16);
+  }
+  else
+  {
+    m_iBufferSize2 = 0;
   }
 
   return iBytesUsed;
@@ -252,37 +234,57 @@ int COMXAudioCodecOMX::Decode(BYTE* pData, int iSize)
 
 int COMXAudioCodecOMX::GetData(BYTE** dst)
 {
-  unsigned int size = 0;
-  BYTE *src = NULL;
+  int size = 0;
+  bool contiguous = true;
 
   if(m_iBufferSize1)
   {
-    *dst = m_pFrame1->data[0];
-    src = m_pFrame1->data[0];
-    size = m_iBufferSize1;
+    int i;
+    int linesize;
+    BYTE *next = m_pFrame1->data[0];
+    m_dllAvUtil.av_samples_get_buffer_size(&linesize, m_pCodecContext->channels, m_pFrame1->nb_samples, m_pCodecContext->sample_fmt, 1);
+    for (i=0; i<m_pCodecContext->channels; i++)
+    {
+      if (!m_pFrame1->data[i])
+        break;
+      if (next != m_pFrame1->data[i])
+        contiguous = false;
+      next += linesize;
+      size += linesize;
+    }
+    if (size != m_iBufferSize1)
+      contiguous = false;
+
+    if (contiguous)
+    {
+      *dst = m_pFrame1->data[0];
+      size = m_iBufferSize1;
+    }
+    else
+    {
+      m_iBufferUpmixSize = 0;
+      for (i=0; i<m_pCodecContext->channels; i++)
+      {
+        if (m_iBufferUpmixSize + linesize <= MAX_AUDIO_FRAME_SIZE && m_pFrame1->data[i])
+        {
+          memcpy(m_pBufferUpmix + m_iBufferUpmixSize, m_pFrame1->data[i], linesize);
+          m_iBufferUpmixSize += linesize;
+        } else assert(0);
+      }
+      *dst = m_pBufferUpmix;
+      size = m_iBufferUpmixSize;
+    }
   }
   if(m_iBufferSize2)
   {
     *dst = m_pBuffer2;
-    src = m_pBuffer2;
     size = m_iBufferSize2;
   }
-
-  if(m_pCodecContext->channels > 4 && size)
+  if (m_bFirstFrame)
   {
-    unsigned int m_frameSize = (CAEUtil::DataFormatToBits(AE_FMT_S16LE) >> 3) * m_pCodecContext->channels;
-    unsigned int frames = size / m_frameSize;
-
-    memset(m_pBufferUpmix, 0, MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
-
-    Upmix(src, m_pCodecContext->channels, m_pBufferUpmix, 8, frames, AE_FMT_S16LE);
-
-    m_iBufferUpmixSize = frames * 8 * (CAEUtil::DataFormatToBits(AE_FMT_S16LE) >> 3);
-
-    *dst = m_pBufferUpmix;
-    size = m_iBufferUpmixSize;
+    CLog::Log(LOGDEBUG, "COMXAudioCodecOMX::GetData size=%d/%d/%d cont=%d buf=%p", m_iBufferSize1, m_iBufferSize2, size, contiguous, *dst);
+     m_bFirstFrame = false;
   }
-
   return size;
 }
 
@@ -296,24 +298,30 @@ void COMXAudioCodecOMX::Reset()
 
 int COMXAudioCodecOMX::GetChannels()
 {
-  return (m_pCodecContext->channels > 4) ? 8 : m_pCodecContext->channels;
+  if (!m_pCodecContext)
+    return 0;
+  return m_pCodecContext->channels;
 }
 
 int COMXAudioCodecOMX::GetSampleRate()
 {
-  if (m_pCodecContext) return m_pCodecContext->sample_rate;
-  return 0;
+  if (!m_pCodecContext)
+    return 0;
+  return m_pCodecContext->sample_rate;
 }
 
 int COMXAudioCodecOMX::GetBitsPerSample()
 {
-  return 16;
+  if (!m_pCodecContext)
+    return 0;
+  return m_pCodecContext->sample_fmt == AV_SAMPLE_FMT_S16 ? 16 : 32;
 }
 
 int COMXAudioCodecOMX::GetBitRate()
 {
-  if (m_pCodecContext) return m_pCodecContext->bit_rate;
-  return 0;
+  if (!m_pCodecContext)
+    return 0;
+  return m_pCodecContext->bit_rate;
 }
 
 static unsigned count_bits(int64_t value)
@@ -363,13 +371,6 @@ void COMXAudioCodecOMX::BuildChannelMap()
   if (layout & AV_CH_TOP_BACK_LEFT        ) m_channelLayout += AE_CH_BL  ;
   if (layout & AV_CH_TOP_BACK_CENTER      ) m_channelLayout += AE_CH_BC  ;
   if (layout & AV_CH_TOP_BACK_RIGHT       ) m_channelLayout += AE_CH_BR  ;
-
-  //terminate the channel map
-  if(m_pCodecContext->channels > 4)
-  {
-    for(int i = m_pCodecContext->channels; i < 8; i++)
-      m_channelLayout += AE_CH_RAW;
-  }
 }
 
 CAEChannelInfo COMXAudioCodecOMX::GetChannelMap()
index 1497e07..a9513c7 100644 (file)
@@ -32,8 +32,6 @@
 class COMXAudioCodecOMX
 {
 public:
-  static void Upmix(void *input, unsigned int channelsInput,  void *output,
-    unsigned int channelsOutput, unsigned int frames, AEDataFormat dataFormat);
   COMXAudioCodecOMX();
   virtual ~COMXAudioCodecOMX();
   bool Open(CDVDStreamInfo &hints);
@@ -44,7 +42,7 @@ public:
   int GetChannels();
   virtual CAEChannelInfo GetChannelMap();
   int GetSampleRate();
-  static int GetBitsPerSample();
+  int GetBitsPerSample();
   static const char* GetName() { return "FFmpeg"; }
   int GetBufferSize() { return m_iBuffered; }
   int GetBitRate();
@@ -53,6 +51,7 @@ protected:
   AVCodecContext* m_pCodecContext;
   SwrContext*     m_pConvert;
   enum AVSampleFormat m_iSampleFormat;
+  enum AVSampleFormat m_desiredSampleFormat;
   CAEChannelInfo      m_channelLayout;
 
   AVFrame* m_pFrame1;
@@ -70,6 +69,7 @@ protected:
   int     m_channels;
   uint64_t m_layout;
 
+  bool m_bFirstFrame;
   DllAvCodec m_dllAvCodec;
   DllAvUtil m_dllAvUtil;
   DllSwResample m_dllSwResample;
index 674e0fc..8091bea 100644 (file)
@@ -18,9 +18,9 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
 #include "system.h"
 #endif
 
index 6478251..31739ad 100644 (file)
 #include "DVDInputStreams/DVDInputStreamTV.h"
 #include "DVDInputStreams/DVDInputStreamPVRManager.h"
 
+#include "DVDDemuxers/DVDDemux.h"
 #include "DVDDemuxers/DVDDemuxUtils.h"
 #include "DVDDemuxers/DVDDemuxVobsub.h"
 #include "DVDDemuxers/DVDFactoryDemuxer.h"
 #include "DVDDemuxers/DVDDemuxFFmpeg.h"
 
-#include "DVDFileInfo.h"
+#include "DVDCodecs/DVDCodecs.h"
+#include "DVDCodecs/DVDFactoryCodec.h"
 
-#include "Util.h"
-#include "LangInfo.h"
+#include "DVDFileInfo.h"
 
-#include "utils/JobManager.h"
-//#include "cores/AudioEngine/AEFactory.h"
-//#include "cores/AudioEngine/Utils/AEUtil.h"
-#include "video/VideoThumbLoader.h"
+#include "utils/LangCodeExpander.h"
+#include "guilib/Key.h"
+#include "guilib/LocalizeStrings.h"
 
+#include "utils/URIUtils.h"
+#include "GUIInfoManager.h"
+#include "guilib/GUIWindowManager.h"
+#include "Application.h"
+#include "ApplicationMessenger.h"
+#include "DVDPerformanceCounter.h"
+#include "filesystem/File.h"
+#include "pictures/Picture.h"
+#include "DllSwScale.h"
+#ifdef HAS_VIDEO_PLAYBACK
+#include "cores/VideoRenderers/RenderManager.h"
+#endif
+#ifdef HAS_PERFORMANCE_SAMPLE
+#include "xbmc/utils/PerformanceSample.h"
+#else
+#define MEASURE_FUNCTION
+#endif
+#include "settings/AdvancedSettings.h"
+#include "FileItem.h"
+#include "GUIUserMessages.h"
+#include "settings/Settings.h"
+#include "settings/MediaSettings.h"
+#include "utils/log.h"
+#include "utils/TimeUtils.h"
+#include "utils/StreamDetails.h"
 #include "pvr/PVRManager.h"
 #include "pvr/channels/PVRChannel.h"
 #include "pvr/windows/GUIWindowPVR.h"
 #include "pvr/addons/PVRClients.h"
 #include "filesystem/PVRFile.h"
-
+#include "video/dialogs/GUIDialogFullScreenInfo.h"
+#include "utils/StreamUtils.h"
+#include "utils/Variant.h"
+#include "storage/MediaManager.h"
+#include "dialogs/GUIDialogBusy.h"
+#include "dialogs/GUIDialogKaiToast.h"
+#include "xbmc/playlists/PlayListM3U.h"
 #include "utils/StringUtils.h"
+#include "Util.h"
+#include "LangInfo.h"
+#include "URL.h"
 
-using namespace XFILE;
+using namespace std;
 using namespace PVR;
 
-// ****************************************************************
 void COMXSelectionStreams::Clear(StreamType type, StreamSource source)
 {
   CSingleLock lock(m_section);
@@ -402,7 +435,6 @@ void COMXSelectionStreams::Update(CDVDInputStream* input, CDVDDemux* demuxer)
   }
 }
 
-// ****************************************************************
 COMXPlayer::COMXPlayer(IPlayerCallback &callback) 
     : IPlayer(callback),
       CThread("OMXPlayer"),
@@ -411,35 +443,43 @@ COMXPlayer::COMXPlayer(IPlayerCallback &callback)
       m_CurrentSubtitle(STREAM_SUBTITLE, DVDPLAYER_SUBTITLE),
       m_CurrentTeletext(STREAM_TELETEXT, DVDPLAYER_TELETEXT),
       m_messenger("player"),
-      m_player_video(&m_av_clock, &m_overlayContainer, m_messenger),
-      m_player_audio(&m_av_clock, m_messenger),
-      m_player_subtitle(&m_overlayContainer),
-      m_player_teletext(),
+      m_omxPlayerVideo(&m_av_clock, &m_overlayContainer, m_messenger),
+      m_omxPlayerAudio(&m_av_clock, m_messenger),
+      m_dvdPlayerSubtitle(&m_overlayContainer),
+      m_dvdPlayerTeletext(),
       m_ready(true)
 {
-  m_bAbortRequest     = false;
   m_pDemuxer          = NULL;
   m_pSubtitleDemuxer  = NULL;
   m_pInputStream      = NULL;
-  m_UpdateApplication = 0;
-  m_caching           = CACHESTATE_DONE;
-  m_playSpeed         = DVD_PLAYSPEED_NORMAL;
-  m_HasVideo          = false;
-  m_HasAudio          = false;
 
   m_dvd.Clear();
   m_State.Clear();
   m_EdlAutoSkipMarkers.Clear();
+  m_UpdateApplication = 0;
+
+  m_bAbortRequest = false;
+  m_errorCount = 0;
+  m_offset_pts = 0.0;
+  m_playSpeed = DVD_PLAYSPEED_NORMAL;
+  m_caching           = CACHESTATE_DONE;
+  m_HasVideo          = false;
+  m_HasAudio          = false;
 
   memset(&m_SpeedState, 0, sizeof(m_SpeedState));
+
+#ifdef DVDDEBUG_MESSAGE_TRACKER
+  g_dvdMessageTracker.Init();
+#endif
 }
 
 COMXPlayer::~COMXPlayer()
 {
   CloseFile();
 
-  if(m_messenger.IsInited())
-    m_messenger.End();
+#ifdef DVDDEBUG_MESSAGE_TRACKER
+  g_dvdMessageTracker.DeInit();
+#endif
 }
 
 bool COMXPlayer::OpenFile(const CFileItem &file, const CPlayerOptions &options)
@@ -453,34 +493,34 @@ bool COMXPlayer::OpenFile(const CFileItem &file, const CPlayerOptions &options)
     if(IsRunning())
       CloseFile();
 
-    if(!m_av_clock.OMXInitialize(false, false))
+    if(!m_av_clock.OMXInitialize(&m_clock, false, false))
     {
       return false;
     }
     if(CSettings::Get().GetBool("videoplayer.adjustrefreshrate"))
       m_av_clock.HDMIClockSync();
 
-    m_playSpeed = DVD_PLAYSPEED_NORMAL;
-    SetPlaySpeed(DVD_PLAYSPEED_NORMAL);
+    m_bAbortRequest = false;
 
-    m_PlayerOptions     = options;
-    m_bAbortRequest     = false;
+    SetPlaySpeed(DVD_PLAYSPEED_NORMAL);
 
+    m_State.Clear();
     m_UpdateApplication = 0;
     m_offset_pts        = 0;
     m_current_volume    = 0;
     m_current_mute      = false;
     m_change_volume     = true;
 
+    m_PlayerOptions = options;
     m_item              = file;
     m_mimetype          = file.GetMimeType();
     m_filename          = file.GetPath();
 
-    m_State.Clear();
-
     m_ready.Reset();
 
+#if defined(HAS_VIDEO_PLAYBACK)
     g_renderManager.PreInit();
+#endif
 
     Create();
     if(!m_ready.WaitMSec(100))
@@ -535,15 +575,16 @@ bool COMXPlayer::CloseFile()
   // we are done after the StopThread call
   StopThread();
   
-  CLog::Log(LOGDEBUG, "COMXPlayer: finished waiting");
-
   m_Edl.Clear();
   m_EdlAutoSkipMarkers.Clear();
 
   m_HasVideo = false;
   m_HasAudio = false;
 
+  CLog::Log(LOGNOTICE, "DVDPlayer: finished waiting");
+#if defined(HAS_VIDEO_PLAYBACK)
   g_renderManager.UnInit();
+#endif
   return true;
 }
 
@@ -581,7 +622,8 @@ bool COMXPlayer::OpenInputStream()
 
   // before creating the input stream, if this is an HLS playlist then get the
   // most appropriate bitrate based on our network settings
-  if (filename.Left(7) == "http://" && filename.Right(5) == ".m3u8")
+  // ensure to strip off the url options by using a temp CURL object
+  if (filename.Left(7) == "http://" && CURL(filename).GetFileName().Right(5) == ".m3u8")
   {
     // get the available bandwidth (as per user settings)
     int maxrate = CSettings::Get().GetInt("network.bandwidth");
@@ -630,7 +672,7 @@ bool COMXPlayer::OpenInputStream()
     for(unsigned int i=0;i<filenames.size();i++)
     {
       // if vobsub subtitle:
-      if (URIUtils::GetExtension(filenames[i]) == ".idx")
+      if (URIUtils::HasExtension(filenames[i], ".idx"))
       {
         CStdString strSubFile;
         if ( CUtil::FindVobSubPair( filenames, filenames[i], strSubFile ) )
@@ -650,8 +692,9 @@ bool COMXPlayer::OpenInputStream()
 
   SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay);
   SetSubTitleDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay);
-  m_av_clock.Reset();
+  m_clock.Reset();
   m_dvd.Clear();
+  m_errorCount = 0;
   m_iChannelEntryTimeOut = 0;
 
   return true;
@@ -744,7 +787,7 @@ void COMXPlayer::OpenDefaultStreams(bool reset)
     CloseAudioStream(true);
 
   // enable subtitles
-  m_player_video.EnableSubtitle(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn);
+  m_omxPlayerVideo.EnableSubtitle(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn);
 
   // open subtitle stream
   streams = m_SelectionStreams.Get(STREAM_SUBTITLE, PredicateSubtitlePriority);
@@ -755,7 +798,7 @@ void COMXPlayer::OpenDefaultStreams(bool reset)
     {
       valid = true;
       if(it->flags & CDemuxStream::FLAG_FORCED)
-        m_player_video.EnableSubtitle(true);
+        m_omxPlayerVideo.EnableSubtitle(true);
     }
   }
   if(!valid)
@@ -777,7 +820,7 @@ bool COMXPlayer::ReadPacket(DemuxPacket*& packet, CDemuxStream*& stream)
 {
 
   // check if we should read from subtitle demuxer
-  if(m_player_subtitle.AcceptsData() &&  m_pSubtitleDemuxer)
+  if(m_dvdPlayerSubtitle.AcceptsData() &&  m_pSubtitleDemuxer)
   {
     if(m_pSubtitleDemuxer)
       packet = m_pSubtitleDemuxer->Read();
@@ -969,7 +1012,8 @@ void COMXPlayer::Process()
     return;
   }
 
-  m_player_video.EnableFullscreen(true);
+  // allow renderer to switch to fullscreen if requested
+  m_omxPlayerVideo.EnableFullscreen(m_PlayerOptions.fullscreen);
 
   OpenDefaultStreams();
 
@@ -1056,17 +1100,6 @@ void COMXPlayer::Process()
   if (!CachePVRStream())
     SetCaching(CACHESTATE_FLUSH);
 
-  /*
-  if (CJobManager::GetInstance().IsProcessing(CJob::PRIORITY_LOW))
-  {
-    if (!WaitForPausedThumbJobs(20000))
-    {
-      CJobManager::GetInstance().UnPause(kJobTypeMediaFlags);
-      CLog::Log(LOGINFO, "COMXPlayer::Process:thumbgen jobs still running !!!");
-    }
-  }
-  */
-
   while (!m_bAbortRequest)
   {
     #ifdef _DEBUG
@@ -1075,14 +1108,14 @@ void COMXPlayer::Process()
     if ((count++ & 15) == 0)
     {
       vc_gencmd(response, sizeof response, "render_bar 4 video_fifo %d %d %d %d",
-            m_player_video.GetDecoderBufferSize()-m_player_video.GetDecoderFreeSpace(),
-            0 , 0, m_player_video.GetDecoderBufferSize());
+            m_omxPlayerVideo.GetDecoderBufferSize()-m_omxPlayerVideo.GetDecoderFreeSpace(),
+            0 , 0, m_omxPlayerVideo.GetDecoderBufferSize());
       vc_gencmd(response, sizeof response, "render_bar 5 audio_fifo %d %d %d %d",
-            (int)(100.0*m_player_audio.GetDelay()), 0, 0, 100*AUDIO_BUFFER_SECONDS);
+            (int)(100.0*m_omxPlayerAudio.GetDelay()), 0, 0, 100*AUDIO_BUFFER_SECONDS);
       vc_gencmd(response, sizeof response, "render_bar 6 video_queue %d %d %d %d",
-            m_player_video.GetLevel(), 0, 0, 100);
+            m_omxPlayerVideo.GetLevel(), 0, 0, 100);
       vc_gencmd(response, sizeof response, "render_bar 7 audio_queue %d %d %d %d",
-            m_player_audio.GetLevel(), 0, 0, 100);
+            m_omxPlayerAudio.GetLevel(), 0, 0, 100);
     }
     #endif
     // handle messages send to this thread, like seek or demuxer reset requests
@@ -1121,8 +1154,8 @@ void COMXPlayer::Process()
       OpenDefaultStreams();
 
       // never allow first frames after open to be skipped
-      if( m_player_video.IsInited() )
-        m_player_video.SendMessage(new CDVDMsg(CDVDMsg::VIDEO_NOSKIP));
+      if( m_omxPlayerVideo.IsInited() )
+        m_omxPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::VIDEO_NOSKIP));
 
       if (CachePVRStream())
         SetCaching(CACHESTATE_PVR);
@@ -1141,9 +1174,9 @@ void COMXPlayer::Process()
     UpdateApplication(1000);
 
     // OMX emergency exit
-    if(HasAudio() && m_player_audio.BadState())
+    if(HasAudio() && m_omxPlayerAudio.BadState())
     {
-      CLog::Log(LOGERROR, "%s - Closing stream due to m_player_audio.BadState()", __FUNCTION__);
+      CLog::Log(LOGERROR, "%s - Closing stream due to m_omxPlayerAudio.BadState()", __FUNCTION__);
       m_bAbortRequest = true;
       break;
     }
@@ -1152,16 +1185,16 @@ void COMXPlayer::Process()
       continue;
 
     // if the queues are full, no need to read more
-    if ((!m_player_audio.AcceptsData() && m_CurrentAudio.id >= 0)
-    ||  (!m_player_video.AcceptsData() && m_CurrentVideo.id >= 0))
+    if ((!m_omxPlayerAudio.AcceptsData() && m_CurrentAudio.id >= 0) ||
+        (!m_omxPlayerVideo.AcceptsData() && m_CurrentVideo.id >= 0))
     {
       Sleep(10);
       continue;
     }
 
     // always yield to players if they have data levels > 50 percent
-    if((m_player_audio.GetLevel() > 50 || m_CurrentAudio.id < 0)
-    && (m_player_video.GetLevel() > 50 || m_CurrentVideo.id < 0))
+    if((m_omxPlayerAudio.GetLevel() > 50 || m_CurrentAudio.id < 0)
+    && (m_omxPlayerVideo.GetLevel() > 50 || m_CurrentVideo.id < 0))
       Sleep(0);
 
     DemuxPacket* pPacket = NULL;
@@ -1223,33 +1256,28 @@ void COMXPlayer::Process()
         Sleep(100);
         continue;
       }
-      else if (m_pInputStream->IsStreamType(DVDSTREAM_TYPE_PVRMANAGER))
-      {
-        CDVDInputStreamPVRManager* pStream = static_cast<CDVDInputStreamPVRManager*>(m_pInputStream);
-        if (pStream->IsEOF())
-          break;
-
-        Sleep(100);
-        continue;
-      }
 
       // make sure we tell all players to finish it's data
       if (!bOmxSentEOFs)
       {
         if(m_CurrentAudio.inited)
         {
-          m_player_audio.SendMessage   (new CDVDMsg(CDVDMsg::GENERAL_EOF));
+          m_omxPlayerAudio.SendMessage   (new CDVDMsg(CDVDMsg::GENERAL_EOF));
           bOmxWaitAudio = true;
         }
         if(m_CurrentVideo.inited)
         {
-          m_player_video.SendMessage   (new CDVDMsg(CDVDMsg::GENERAL_EOF));
+          m_omxPlayerVideo.SendMessage   (new CDVDMsg(CDVDMsg::GENERAL_EOF));
           bOmxWaitVideo = true;
         }
         if(m_CurrentSubtitle.inited)
-          m_player_subtitle.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_EOF));
+          m_dvdPlayerSubtitle.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_EOF));
         if(m_CurrentTeletext.inited)
-          m_player_teletext.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_EOF));
+          m_dvdPlayerTeletext.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_EOF));
+        m_CurrentAudio.inited    = false;
+        m_CurrentVideo.inited    = false;
+        m_CurrentSubtitle.inited = false;
+        m_CurrentTeletext.inited = false;
         bOmxSentEOFs = true;
       }
 
@@ -1257,20 +1285,20 @@ void COMXPlayer::Process()
       SetCaching(CACHESTATE_DONE);
 
       // while players are still playing, keep going to allow seekbacks
-      if(m_player_video.HasData()
-      || m_player_audio.HasData())
+      if(m_omxPlayerVideo.HasData()
+      || m_omxPlayerAudio.HasData())
       {
         Sleep(100);
         continue;
       }
 
       // wait for omx components to finish
-      if(bOmxWaitVideo && !m_player_video.IsEOS())
+      if(bOmxWaitVideo && !m_omxPlayerVideo.IsEOS())
       {
         Sleep(100);
         continue;
       }
-      if(bOmxWaitAudio && !m_player_audio.IsEOS())
+      if(bOmxWaitAudio && !m_omxPlayerAudio.IsEOS())
       {
         Sleep(100);
         continue;
@@ -1279,10 +1307,6 @@ void COMXPlayer::Process()
       if (!m_pInputStream->IsEOF())
         CLog::Log(LOGINFO, "%s - eof reading from demuxer", __FUNCTION__);
 
-      m_CurrentAudio.inited    = false;
-      m_CurrentVideo.inited    = false;
-      m_CurrentSubtitle.inited = false;
-      m_CurrentTeletext.inited = false;
       m_CurrentAudio.started    = false;
       m_CurrentVideo.started    = false;
       m_CurrentSubtitle.started = false;
@@ -1291,10 +1315,13 @@ void COMXPlayer::Process()
       break;
     }
 
+    // it's a valid data packet, reset error counter
+    m_errorCount = 0;
+
     // check so that none of our streams has become invalid
-    if (!IsValidStream(m_CurrentAudio)    && m_player_audio.IsStalled())    CloseAudioStream(true);
-    if (!IsValidStream(m_CurrentVideo)    && m_player_video.IsStalled())    CloseVideoStream(true);
-    if (!IsValidStream(m_CurrentSubtitle) && m_player_subtitle.IsStalled()) CloseSubtitleStream(true);
+    if (!IsValidStream(m_CurrentAudio)    && m_omxPlayerAudio.IsStalled())    CloseAudioStream(true);
+    if (!IsValidStream(m_CurrentVideo)    && m_omxPlayerVideo.IsStalled())    CloseVideoStream(true);
+    if (!IsValidStream(m_CurrentSubtitle) && m_dvdPlayerSubtitle.IsStalled()) CloseSubtitleStream(true);
     if (!IsValidStream(m_CurrentTeletext))                                  CloseTeletextStream(true);
 
     // see if we can find something better to play
@@ -1305,7 +1332,7 @@ void COMXPlayer::Process()
 
     if(m_change_volume && m_CurrentAudio.started)
     {
-      m_player_audio.SetCurrentVolume(m_current_mute ? VOLUME_MINIMUM : m_current_volume);
+      m_omxPlayerAudio.SetCurrentVolume(m_current_mute ? VOLUME_MINIMUM : m_current_volume);
       m_change_volume = false;
     }
 
@@ -1398,17 +1425,17 @@ void COMXPlayer::ProcessAudioData(CDemuxStream* pStream, DemuxPacket* pPacket)
   else if (m_Edl.InCut(DVD_TIME_TO_MSEC(m_CurrentAudio.dts + m_offset_pts), &cut) && cut.action == CEdl::MUTE // Inside EDL mute
   &&      !m_EdlAutoSkipMarkers.mute) // Mute not already triggered
   {
-    m_player_audio.SendMessage(new CDVDMsgBool(CDVDMsg::AUDIO_SILENCE, true));
+    m_omxPlayerAudio.SendMessage(new CDVDMsgBool(CDVDMsg::AUDIO_SILENCE, true));
     m_EdlAutoSkipMarkers.mute = true;
   }
   else if (!m_Edl.InCut(DVD_TIME_TO_MSEC(m_CurrentAudio.dts + m_offset_pts), &cut) // Outside of any EDL
   &&        m_EdlAutoSkipMarkers.mute) // But the mute hasn't been removed yet
   {
-    m_player_audio.SendMessage(new CDVDMsgBool(CDVDMsg::AUDIO_SILENCE, false));
+    m_omxPlayerAudio.SendMessage(new CDVDMsgBool(CDVDMsg::AUDIO_SILENCE, false));
     m_EdlAutoSkipMarkers.mute = false;
   }
 
-  m_player_audio.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
+  m_omxPlayerAudio.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
 }
 
 void COMXPlayer::ProcessVideoData(CDemuxStream* pStream, DemuxPacket* pPacket)
@@ -1441,7 +1468,7 @@ void COMXPlayer::ProcessVideoData(CDemuxStream* pStream, DemuxPacket* pPacket)
   if (CheckSceneSkip(m_CurrentVideo))
     drop = true;
 
-  m_player_video.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
+  m_omxPlayerVideo.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
 }
 
 void COMXPlayer::ProcessSubData(CDemuxStream* pStream, DemuxPacket* pPacket)
@@ -1467,10 +1494,10 @@ void COMXPlayer::ProcessSubData(CDemuxStream* pStream, DemuxPacket* pPacket)
   if (CheckSceneSkip(m_CurrentSubtitle))
     drop = true;
 
-  m_player_subtitle.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
+  m_dvdPlayerSubtitle.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
 
   if(m_pInputStream && m_pInputStream->IsStreamType(DVDSTREAM_TYPE_DVD))
-    m_player_subtitle.UpdateOverlayInfo((CDVDInputStreamNavigator*)m_pInputStream, LIBDVDNAV_BUTTON_NORMAL);
+    m_dvdPlayerSubtitle.UpdateOverlayInfo((CDVDInputStreamNavigator*)m_pInputStream, LIBDVDNAV_BUTTON_NORMAL);
 }
 
 void COMXPlayer::ProcessTeletextData(CDemuxStream* pStream, DemuxPacket* pPacket)
@@ -1494,7 +1521,7 @@ void COMXPlayer::ProcessTeletextData(CDemuxStream* pStream, DemuxPacket* pPacket
   if (CheckSceneSkip(m_CurrentTeletext))
     drop = true;
 
-  m_player_teletext.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
+  m_dvdPlayerTeletext.SendMessage(new CDVDMsgDemuxerPacket(pPacket, drop));
 }
 
 bool COMXPlayer::GetCachingTimes(double& level, double& delay, double& offset)
@@ -1555,14 +1582,17 @@ void COMXPlayer::HandlePlaySpeed()
     if(GetCachingTimes(level, delay, offset))
     {
       if(level  < 0.0)
+      {
+        CGUIDialogKaiToast::QueueNotification(g_localizeStrings.Get(21454), g_localizeStrings.Get(21455));
         caching = CACHESTATE_INIT;
+      }
       if(level >= 1.0)
         caching = CACHESTATE_INIT;
     }
     else
     {
-      if ((!m_player_audio.AcceptsData() && m_CurrentAudio.id >= 0)
-      ||  (!m_player_video.AcceptsData() && m_CurrentVideo.id >= 0))
+      if ((!m_omxPlayerAudio.AcceptsData() && m_CurrentAudio.id >= 0)
+      ||  (!m_omxPlayerVideo.AcceptsData() && m_CurrentVideo.id >= 0))
         caching = CACHESTATE_INIT;
     }
   }
@@ -1577,8 +1607,8 @@ void COMXPlayer::HandlePlaySpeed()
     // handle situation that we get no data on one stream
     if(m_CurrentAudio.id >= 0 && m_CurrentVideo.id >= 0)
     {
-      if ((!m_player_audio.AcceptsData() && !m_CurrentVideo.started)
-      ||  (!m_player_video.AcceptsData() && !m_CurrentAudio.started))
+      if ((!m_omxPlayerAudio.AcceptsData() && !m_CurrentVideo.started)
+      ||  (!m_omxPlayerVideo.AcceptsData() && !m_CurrentAudio.started))
       {
         caching = CACHESTATE_DONE;
       }
@@ -1589,10 +1619,10 @@ void COMXPlayer::HandlePlaySpeed()
   {
     bool bGotAudio(m_pDemuxer->GetNrOfAudioStreams() > 0);
     bool bGotVideo(m_pDemuxer->GetNrOfVideoStreams() > 0);
-    bool bAudioLevelOk(m_player_audio.GetLevel() > g_advancedSettings.m_iPVRMinAudioCacheLevel);
-    bool bVideoLevelOk(m_player_video.GetLevel() > g_advancedSettings.m_iPVRMinVideoCacheLevel);
-    bool bAudioFull(!m_player_audio.AcceptsData());
-    bool bVideoFull(!m_player_video.AcceptsData());
+    bool bAudioLevelOk(m_omxPlayerAudio.GetLevel() > g_advancedSettings.m_iPVRMinAudioCacheLevel);
+    bool bVideoLevelOk(m_omxPlayerVideo.GetLevel() > g_advancedSettings.m_iPVRMinVideoCacheLevel);
+    bool bAudioFull(!m_omxPlayerAudio.AcceptsData());
+    bool bVideoFull(!m_omxPlayerVideo.AcceptsData());
 
     if (/* if all streams got at least g_advancedSettings.m_iPVRMinCacheLevel in their buffers, we're done */
         ((bGotVideo || bGotAudio) && (!bGotAudio || bAudioLevelOk) && (!bGotVideo || bVideoLevelOk)) ||
@@ -1600,8 +1630,8 @@ void COMXPlayer::HandlePlaySpeed()
         (bAudioFull || bVideoFull))
     {
       CLog::Log(LOGDEBUG, "set caching from pvr to done. audio (%d) = %d. video (%d) = %d",
-          bGotAudio, m_player_audio.GetLevel(),
-          bGotVideo, m_player_video.GetLevel());
+          bGotAudio, m_omxPlayerAudio.GetLevel(),
+          bGotVideo, m_omxPlayerVideo.GetLevel());
 
       CFileItem currentItem(g_application.CurrentFileItem());
       if (currentItem.HasPVRChannelInfoTag())
@@ -1613,17 +1643,17 @@ void COMXPlayer::HandlePlaySpeed()
     {
       /* ensure that automatically started players are stopped while caching */
       if (m_CurrentAudio.started)
-        m_player_audio.SetSpeed(DVD_PLAYSPEED_PAUSE);
+        m_omxPlayerAudio.SetSpeed(DVD_PLAYSPEED_PAUSE);
       if (m_CurrentVideo.started)
-        m_player_video.SetSpeed(DVD_PLAYSPEED_PAUSE);
+        m_omxPlayerVideo.SetSpeed(DVD_PLAYSPEED_PAUSE);
     }
   }
 
   if(caching == CACHESTATE_PLAY)
   {
     // if all enabled streams have started playing we are done
-    if((m_CurrentVideo.id < 0 || !m_player_video.IsStalled())
-    && (m_CurrentAudio.id < 0 || !m_player_audio.IsStalled()))
+    if((m_CurrentVideo.id < 0 || !m_omxPlayerVideo.IsStalled())
+    && (m_CurrentAudio.id < 0 || !m_omxPlayerAudio.IsStalled()))
       caching = CACHESTATE_DONE;
   }
 
@@ -1641,10 +1671,10 @@ void COMXPlayer::HandlePlaySpeed()
     }
     else if (m_CurrentVideo.id >= 0
           &&  m_CurrentVideo.inited == true
-          &&  m_SpeedState.lastpts  != m_player_video.GetCurrentPTS()
+          &&  m_SpeedState.lastpts  != m_omxPlayerVideo.GetCurrentPts()
           &&  m_SpeedState.lasttime != GetTime())
     {
-      m_SpeedState.lastpts  = m_player_video.GetCurrentPTS();
+      m_SpeedState.lastpts  = m_omxPlayerVideo.GetCurrentPts();
       m_SpeedState.lasttime = GetTime();
       // check how much off clock video is when ff/rw:ing
       // a problem here is that seeking isn't very accurate
@@ -1657,13 +1687,13 @@ void COMXPlayer::HandlePlaySpeed()
       // when seeking, give the player a headstart to make sure
       // the time it takes to seek doesn't make a difference.
       double error;
-      error  = m_av_clock.GetClock() - m_SpeedState.lastpts;
+      error  = m_clock.GetClock() - m_SpeedState.lastpts;
       error *= m_playSpeed / abs(m_playSpeed);
 
       if(error > DVD_MSEC_TO_TIME(1000))
       {
         CLog::Log(LOGDEBUG, "COMXPlayer::Process - Seeking to catch up");
-        int64_t iTime = (int64_t)DVD_TIME_TO_MSEC(m_av_clock.GetClock() + m_State.time_offset + 500000.0 * m_playSpeed / DVD_PLAYSPEED_NORMAL);
+        int64_t iTime = (int64_t)DVD_TIME_TO_MSEC(m_clock.GetClock() + m_State.time_offset + 500000.0 * m_playSpeed / DVD_PLAYSPEED_NORMAL);
         m_messenger.Put(new CDVDMsgPlayerSeek(iTime, (GetPlaySpeed() < 0), true, false, false, true));
       }
     }
@@ -1679,13 +1709,13 @@ bool COMXPlayer::CheckStartCaching(COMXCurrentStream& current)
   if(IsInMenu())
     return false;
 
-  if((current.type == STREAM_AUDIO && m_player_audio.IsStalled())
-  || (current.type == STREAM_VIDEO && m_player_video.IsStalled()))
+  if((current.type == STREAM_AUDIO && m_omxPlayerAudio.IsStalled())
+  || (current.type == STREAM_VIDEO && m_omxPlayerVideo.IsStalled()))
   {
     if (CachePVRStream())
     {
-      if ((current.type == STREAM_AUDIO && current.started && m_player_audio.GetLevel() == 0) ||
-         (current.type == STREAM_VIDEO && current.started && m_player_video.GetLevel() == 0))
+      if ((current.type == STREAM_AUDIO && current.started && m_omxPlayerAudio.GetLevel() == 0) ||
+         (current.type == STREAM_VIDEO && current.started && m_omxPlayerVideo.GetLevel() == 0))
       {
         CLog::Log(LOGDEBUG, "%s stream stalled. start buffering", current.type == STREAM_AUDIO ? "audio" : "video");
         SetCaching(CACHESTATE_PVR);
@@ -1694,8 +1724,8 @@ bool COMXPlayer::CheckStartCaching(COMXCurrentStream& current)
     }
 
     // don't start caching if it's only a single stream that has run dry
-    if(m_player_audio.GetLevel() > 50
-    || m_player_video.GetLevel() > 50)
+    if(m_omxPlayerAudio.GetLevel() > 50
+    || m_omxPlayerVideo.GetLevel() > 50)
       return false;
 
     if(current.inited)
@@ -1827,7 +1857,7 @@ void COMXPlayer::UpdateTimestamps(COMXCurrentStream& current, DemuxPacket* pPack
   }
 }
 
-void COMXPlayer::UpdateLimits(double& minimum, double& maximum, double dts)
+static void UpdateLimits(double& minimum, double& maximum, double dts)
 {
   if(dts == DVD_NOPTS_VALUE)
     return;
@@ -1943,7 +1973,7 @@ void COMXPlayer::CheckAutoSceneSkip()
     /*
      * Seeking is NOT flushed so any content up to the demux point is retained when playing forwards.
      */
-    m_messenger.Put(new CDVDMsgPlayerSeek((int)seek, true, true, true, false, true));
+    m_messenger.Put(new CDVDMsgPlayerSeek((int)seek, true, false, true, false, true));
     /*
      * Seek doesn't always work reliably. Last physical seek time is recorded to prevent looping
      * if there was an error with seeking and it landed somewhere unexpected, perhaps back in the
@@ -1961,7 +1991,7 @@ void COMXPlayer::CheckAutoSceneSkip()
     /*
      * Seeking is NOT flushed so any content up to the demux point is retained when playing forwards.
      */
-    m_messenger.Put(new CDVDMsgPlayerSeek(cut.end + 1, true, true, true, false, true));
+    m_messenger.Put(new CDVDMsgPlayerSeek(cut.end + 1, true, false, true, false, true));
     /*
      * Each commercial break is only skipped once so poorly detected commercial breaks can be
      * manually re-entered. Start and end are recorded to prevent looping and to allow seeking back
@@ -1993,15 +2023,15 @@ void COMXPlayer::SynchronizePlayers(unsigned int sources)
 
   CDVDMsgGeneralSynchronize* message = new CDVDMsgGeneralSynchronize(timeout, sources);
   if (m_CurrentAudio.id >= 0)
-    m_player_audio.SendMessage(message->Acquire());
+    m_omxPlayerAudio.SendMessage(message->Acquire());
 
   if (m_CurrentVideo.id >= 0)
-    m_player_video.SendMessage(message->Acquire());
+    m_omxPlayerVideo.SendMessage(message->Acquire());
 /* TODO - we have to rewrite the sync class, to not require
           all other players waiting for subtitle, should only
           be the oposite way
   if (m_CurrentSubtitle.id >= 0)
-    m_player_subtitle.SendMessage(message->Acquire()); 
+    m_dvdPlayerSubtitle.SendMessage(message->Acquire());
 */
   message->Release();
 }
@@ -2009,13 +2039,13 @@ void COMXPlayer::SynchronizePlayers(unsigned int sources)
 void COMXPlayer::SendPlayerMessage(CDVDMsg* pMsg, unsigned int target)
 {
   if(target == DVDPLAYER_AUDIO)
-    m_player_audio.SendMessage(pMsg);
+    m_omxPlayerAudio.SendMessage(pMsg);
   if(target == DVDPLAYER_VIDEO)
-    m_player_video.SendMessage(pMsg);
+    m_omxPlayerVideo.SendMessage(pMsg);
   if(target == DVDPLAYER_SUBTITLE)
-    m_player_subtitle.SendMessage(pMsg);
+    m_dvdPlayerSubtitle.SendMessage(pMsg);
   if(target == DVDPLAYER_TELETEXT)
-    m_player_teletext.SendMessage(pMsg);
+    m_dvdPlayerTeletext.SendMessage(pMsg);
 }
 
 void COMXPlayer::OnExit()
@@ -2078,7 +2108,7 @@ void COMXPlayer::OnExit()
     // clean up all selection streams
     m_SelectionStreams.Clear(STREAM_NONE, STREAM_SOURCE_NONE);
 
-    m_messenger.Flush();
+    m_messenger.End();
 
     m_av_clock.OMXDeinitialize();
 
@@ -2257,7 +2287,7 @@ void COMXPlayer::HandleMessages()
       {
         CDVDMsgBool* pValue = (CDVDMsgBool*)pMsg;
 
-        m_player_video.EnableSubtitle(pValue->m_value);
+        m_omxPlayerVideo.EnableSubtitle(pValue->m_value);
 
         if (m_pInputStream && m_pInputStream->IsStreamType(DVDSTREAM_TYPE_DVD))
           static_cast<CDVDInputStreamNavigator*>(m_pInputStream)->EnableSubtitleStream(pValue->m_value);
@@ -2299,12 +2329,12 @@ void COMXPlayer::HandleMessages()
         if(m_State.timestamp > 0)
         {
           double offset;
-          offset  = m_av_clock.GetAbsoluteClock() - m_State.timestamp;
+          offset  = m_clock.GetAbsoluteClock() - m_State.timestamp;
           offset *= m_playSpeed / DVD_PLAYSPEED_NORMAL;
           if(offset >  1000) offset =  1000;
           if(offset < -1000) offset = -1000;
           m_State.time     += DVD_TIME_TO_MSEC(offset);
-          m_State.timestamp =  m_av_clock.GetAbsoluteClock();
+          m_State.timestamp =  m_clock.GetAbsoluteClock();
         }
 
         if (speed != DVD_PLAYSPEED_PAUSE && m_playSpeed != DVD_PLAYSPEED_PAUSE && speed != m_playSpeed)
@@ -2324,10 +2354,10 @@ void COMXPlayer::HandleMessages()
         // 2. skip frames and adjust their pts or the clock
         m_playSpeed = speed;
         m_caching = CACHESTATE_DONE;
-        m_av_clock.SetSpeed(speed);
+        m_clock.SetSpeed(speed);
         m_av_clock.OMXSetSpeed(speed);
-        m_player_audio.SetSpeed(speed);
-        m_player_video.SetSpeed(speed);
+        m_omxPlayerAudio.SetSpeed(speed);
+        m_omxPlayerVideo.SetSpeed(speed);
 
         // TODO - we really shouldn't pause demuxer
         //        until our buffers are somewhat filled
@@ -2421,7 +2451,7 @@ void COMXPlayer::HandleMessages()
         CSingleLock lock(m_StateSection);
         /* prioritize data from video player, but only accept data        *
          * after it has been started to avoid race conditions after seeks */
-        if(m_CurrentVideo.started && !m_player_video.SubmittedEOS())
+        if(m_CurrentVideo.started && !m_omxPlayerVideo.SubmittedEOS())
         {
           if(state.player == DVDPLAYER_VIDEO)
             m_State = state;
@@ -2462,12 +2492,12 @@ void COMXPlayer::SetCaching(ECacheState state)
   || state == CACHESTATE_INIT
   || state == CACHESTATE_PVR)
   {
-    m_av_clock.SetSpeed(DVD_PLAYSPEED_PAUSE);
+    m_clock.SetSpeed(DVD_PLAYSPEED_PAUSE);
     m_av_clock.OMXSetSpeed(DVD_PLAYSPEED_PAUSE);
-    m_player_audio.SetSpeed(DVD_PLAYSPEED_PAUSE);
-    m_player_audio.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
-    m_player_video.SetSpeed(DVD_PLAYSPEED_PAUSE);
-    m_player_video.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
+    m_omxPlayerAudio.SetSpeed(DVD_PLAYSPEED_PAUSE);
+    m_omxPlayerAudio.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
+    m_omxPlayerVideo.SetSpeed(DVD_PLAYSPEED_PAUSE);
+    m_omxPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
 
     if (state == CACHESTATE_PVR)
       m_pInputStream->ResetScanTimeout((unsigned int) CSettings::Get().GetInt("pvrplayback.scantime") * 1000);
@@ -2476,10 +2506,11 @@ void COMXPlayer::SetCaching(ECacheState state)
   if(state == CACHESTATE_PLAY
   ||(state == CACHESTATE_DONE && m_caching != CACHESTATE_PLAY))
   {
-    m_av_clock.SetSpeed(m_playSpeed);
+    m_clock.SetSpeed(m_playSpeed);
     m_av_clock.OMXSetSpeed(m_playSpeed);
-    m_player_audio.SetSpeed(m_playSpeed);
-    m_player_video.SetSpeed(m_playSpeed);
+    m_omxPlayerAudio.SetSpeed(m_playSpeed);
+    m_omxPlayerVideo.SetSpeed(m_playSpeed);
+    m_pInputStream->ResetScanTimeout(0);
   }
   m_caching = state;
 }
@@ -2491,6 +2522,8 @@ void COMXPlayer::SetPlaySpeed(int speed)
     return;
 
   m_messenger.Put(new CDVDMsgInt(CDVDMsg::PLAYER_SETSPEED, speed));
+  m_omxPlayerAudio.SetSpeed(speed);
+  m_omxPlayerVideo.SetSpeed(speed);
   SynchronizeDemuxer(100);
 }
 
@@ -2543,7 +2576,7 @@ bool COMXPlayer::HasAudio() const
 
 bool COMXPlayer::IsPassthrough() const
 {
-  return m_player_audio.Passthrough();
+  return m_omxPlayerAudio.Passthrough();
 }
 
 bool COMXPlayer::CanSeek()
@@ -2554,6 +2587,15 @@ bool COMXPlayer::CanSeek()
 
 void COMXPlayer::Seek(bool bPlus, bool bLargeStep)
 {
+#if 0
+  // sadly this doesn't work for now, audio player must
+  // drop packets at the same rate as we play frames
+  if( m_playSpeed == DVD_PLAYSPEED_PAUSE && bPlus && !bLargeStep)
+  {
+    m_omxPlayerVideo.StepFrame();
+    return;
+  }
+#endif
   if (!m_State.canseek)
     return;
 
@@ -2594,7 +2636,7 @@ void COMXPlayer::Seek(bool bPlus, bool bLargeStep)
      * Alter the standard seek position based on whether any commercial breaks have been
      * automatically skipped.
      */
-    const int clock = DVD_TIME_TO_MSEC(m_av_clock.GetClock());
+    const int clock = DVD_TIME_TO_MSEC(m_clock.GetClock());
     /*
      * If a large backwards seek occurs within 10 seconds of the end of the last automated
      * commercial skip, then seek back to the start of the commercial break under the assumption
@@ -2682,7 +2724,7 @@ void COMXPlayer::GetAudioInfo(CStdString &strAudioInfo)
   { CSingleLock lock(m_StateSection);
     strAudioInfo.Format("D(%s)", m_StateInput.demux_audio.c_str());
   }
-  strAudioInfo.AppendFormat("\nP(%s)", m_player_audio.GetPlayerInfo().c_str());
+  strAudioInfo.AppendFormat("\nP(%s)", m_omxPlayerAudio.GetPlayerInfo().c_str());
 }
 
 void COMXPlayer::GetVideoInfo(CStdString &strVideoInfo)
@@ -2690,17 +2732,17 @@ void COMXPlayer::GetVideoInfo(CStdString &strVideoInfo)
   { CSingleLock lock(m_StateSection);
     strVideoInfo.Format("D(%s)", m_StateInput.demux_video.c_str());
   }
-  strVideoInfo.AppendFormat("\nP(%s)", m_player_video.GetPlayerInfo().c_str());
+  strVideoInfo.AppendFormat("\nP(%s)", m_omxPlayerVideo.GetPlayerInfo().c_str());
 }
 
 void COMXPlayer::GetGeneralInfo(CStdString& strGeneralInfo)
 {
   if (!m_bStop)
   {
-    double dDelay = m_player_video.GetDelay() / DVD_TIME_BASE - g_renderManager.GetDisplayLatency();
+    double dDelay = m_omxPlayerVideo.GetDelay() / DVD_TIME_BASE - g_renderManager.GetDisplayLatency();
 
-    double apts = m_player_audio.GetCurrentPTS();
-    double vpts = m_player_video.GetCurrentPTS();
+    double apts = m_omxPlayerAudio.GetCurrentPts();
+    double vpts = m_omxPlayerVideo.GetCurrentPts();
     double dDiff = 0;
 
     if( apts != DVD_NOPTS_VALUE && vpts != DVD_NOPTS_VALUE )
@@ -2725,23 +2767,23 @@ void COMXPlayer::GetGeneralInfo(CStdString& strGeneralInfo)
                          , dDiff
                          , strEDL.c_str()
                          , (int)(CThread::GetRelativeUsage()*100)
-                         , (int)(m_player_audio.GetRelativeUsage()*100)
-                         , (int)(m_player_video.GetRelativeUsage()*100)
+                         , (int)(m_omxPlayerAudio.GetRelativeUsage()*100)
+                         , (int)(m_omxPlayerVideo.GetRelativeUsage()*100)
                          , strBuf.c_str()
-                         , m_player_video.GetFreeSpace()
-                         , m_player_audio.GetDelay());
+                         , m_omxPlayerVideo.GetFreeSpace()
+                         , m_omxPlayerAudio.GetDelay());
 
   }
 }
 
-void COMXPlayer::SeekPercentage(float fPercent)
+void COMXPlayer::SeekPercentage(float iPercent)
 {
   int64_t iTotalTime = GetTotalTimeInMsec();
 
   if (!iTotalTime)
     return;
 
-  SeekTime((int64_t)(iTotalTime * fPercent / 100));
+  SeekTime((int64_t)(iTotalTime * iPercent / 100));
 }
 
 float COMXPlayer::GetPercentage()
@@ -2762,22 +2804,22 @@ float COMXPlayer::GetCachePercentage()
 
 void COMXPlayer::SetAVDelay(float fValue)
 {
-  m_player_video.SetDelay(fValue * DVD_TIME_BASE);
+  m_omxPlayerVideo.SetDelay(fValue * DVD_TIME_BASE);
 }
 
 float COMXPlayer::GetAVDelay()
 {
-  return m_player_video.GetDelay() / (float)DVD_TIME_BASE;
+  return m_omxPlayerVideo.GetDelay() / (float)DVD_TIME_BASE;
 }
 
 void COMXPlayer::SetSubTitleDelay(float fValue)
 {
-  m_player_video.SetSubtitleDelay(-fValue * DVD_TIME_BASE);
+  m_omxPlayerVideo.SetSubtitleDelay(-fValue * DVD_TIME_BASE);
 }
 
 float COMXPlayer::GetSubTitleDelay()
 {
-  return -m_player_video.GetSubtitleDelay() / DVD_TIME_BASE;
+  return -m_omxPlayerVideo.GetSubtitleDelay() / DVD_TIME_BASE;
 }
 
 // priority: 1: libdvdnav, 2: external subtitles, 3: muxed subtitles
@@ -2824,7 +2866,7 @@ bool COMXPlayer::GetSubtitleVisible()
       return pStream->IsSubtitleStreamEnabled();
   }
 
-  return m_player_video.IsSubtitleEnabled();
+  return m_omxPlayerVideo.IsSubtitleEnabled();
 }
 
 void COMXPlayer::SetSubtitleVisible(bool bVisible)
@@ -2856,7 +2898,7 @@ TextCacheStruct_t* COMXPlayer::GetTeletextCache()
   if (m_CurrentTeletext.id < 0)
     return 0;
 
-  return m_player_teletext.GetTeletextCache();
+  return m_dvdPlayerTeletext.GetTeletextCache();
 }
 
 void COMXPlayer::LoadPage(int p, int sp, unsigned char* buffer)
@@ -2864,7 +2906,7 @@ void COMXPlayer::LoadPage(int p, int sp, unsigned char* buffer)
   if (m_CurrentTeletext.id < 0)
       return;
 
-  return m_player_teletext.LoadPage(p, sp, buffer);
+  return m_dvdPlayerTeletext.LoadPage(p, sp, buffer);
 }
 
 void COMXPlayer::SeekTime(int64_t iTime)
@@ -2883,7 +2925,7 @@ int64_t COMXPlayer::GetTime()
   const double limit  = DVD_MSEC_TO_TIME(200);
   if(m_State.timestamp > 0)
   {
-    offset  = m_av_clock.GetAbsoluteClock() - m_State.timestamp;
+    offset  = m_clock.GetAbsoluteClock() - m_State.timestamp;
     offset *= m_playSpeed / DVD_PLAYSPEED_NORMAL;
     if(offset >  limit) offset =  limit;
     if(offset < -limit) offset = -limit;
@@ -2954,7 +2996,7 @@ bool COMXPlayer::OpenAudioStream(int iStream, int source, bool reset)
   if(m_CurrentAudio.id    < 0
   || m_CurrentAudio.hint != hint)
   {
-    if(!m_player_audio.OpenStream(hint))
+    if(!m_omxPlayerAudio.OpenStream(hint))
     {
       /* mark stream as disabled, to disallaw further attempts*/
       CLog::Log(LOGWARNING, "%s - Unsupported stream %d. Stream disabled.", __FUNCTION__, iStream);
@@ -2962,11 +3004,9 @@ bool COMXPlayer::OpenAudioStream(int iStream, int source, bool reset)
       pStream->SetDiscard(AVDISCARD_ALL);
       return false;
     }
-    m_av_clock.SetSpeed(DVD_PLAYSPEED_NORMAL);
-    m_av_clock.OMXSetSpeed(DVD_PLAYSPEED_NORMAL);
   }
   else if (reset)
-    m_player_audio.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+    m_omxPlayerAudio.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
 
   /* store information about stream */
   m_CurrentAudio.id = iStream;
@@ -2974,13 +3014,14 @@ bool COMXPlayer::OpenAudioStream(int iStream, int source, bool reset)
   m_CurrentAudio.hint = hint;
   m_CurrentAudio.stream = (void*)pStream;
   m_CurrentAudio.started = false;
+  m_clock.SetMasterClock(false);
   m_HasAudio = true;
 
   /* we are potentially going to be waiting on this */
-  m_player_audio.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
+  m_omxPlayerAudio.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
 
   /* software decoding normaly consumes full cpu time so prio it */
-  m_player_audio.SetPriority(GetPriority()+1);
+  m_omxPlayerAudio.SetPriority(GetPriority()+1);
 
   return true;
 }
@@ -3035,7 +3076,16 @@ bool COMXPlayer::OpenVideoStream(int iStream, int source, bool reset)
   if(m_CurrentVideo.id    < 0
   || m_CurrentVideo.hint != hint)
   {
-    if (!m_player_video.OpenStream(hint))
+    // for music file, don't open artwork as video
+    bool disabled = false;
+    CStdString extension = URIUtils::GetExtension(m_filename);
+    if (!extension.IsEmpty() && g_advancedSettings.m_musicExtensions.Find(extension.ToLower()) != -1)
+    {
+      CLog::Log(LOGWARNING, "%s - Ignoring video in audio filetype:%s", __FUNCTION__, m_filename.c_str());
+      disabled = true;
+    }
+
+    if (disabled || !m_omxPlayerVideo.OpenStream(hint))
     {
       /* mark stream as disabled, to disallaw further attempts */
       CLog::Log(LOGWARNING, "%s - Unsupported stream %d. Stream disabled.", __FUNCTION__, iStream);
@@ -3043,18 +3093,16 @@ bool COMXPlayer::OpenVideoStream(int iStream, int source, bool reset)
       pStream->SetDiscard(AVDISCARD_ALL);
       return false;
     }
-    m_av_clock.SetSpeed(DVD_PLAYSPEED_NORMAL);
-    m_av_clock.OMXSetSpeed(DVD_PLAYSPEED_NORMAL);
   }
   else if (reset)
-    m_player_video.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+    m_omxPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
 
   unsigned flags = 0;
   if(m_filename.find("3DSBS") != string::npos || m_filename.find("HSBS") != string::npos)
     flags = CONF_FLAGS_FORMAT_SBS;
   else if(m_filename.find("3DTAB") != string::npos || m_filename.find("HTAB") != string::npos)
     flags = CONF_FLAGS_FORMAT_TB;
-  m_player_video.SetFlags(flags);
+  m_omxPlayerVideo.SetFlags(flags);
 
   /* store information about stream */
   m_CurrentVideo.id = iStream;
@@ -3065,11 +3113,11 @@ bool COMXPlayer::OpenVideoStream(int iStream, int source, bool reset)
   m_HasVideo = true;
 
   /* we are potentially going to be waiting on this */
-  m_player_video.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
+  m_omxPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
 
   /* use same priority for video thread as demuxing thread, as */
   /* otherwise demuxer will starve if video consumes the full cpu */
-  m_player_video.SetPriority(GetPriority());
+  m_omxPlayerVideo.SetPriority(GetPriority());
 
   return true;
 }
@@ -3102,7 +3150,7 @@ bool COMXPlayer::OpenSubtitleStream(int iStream, int source)
     if(!pStream || pStream->disabled)
       return false;
     pStream->SetDiscard(AVDISCARD_NONE);
-    double pts = m_player_video.GetCurrentPTS();
+    double pts = m_omxPlayerVideo.GetCurrentPts();
     if(pts == DVD_NOPTS_VALUE)
       pts = m_CurrentVideo.dts;
     if(pts == DVD_NOPTS_VALUE)
@@ -3147,7 +3195,7 @@ bool COMXPlayer::OpenSubtitleStream(int iStream, int source)
       CloseSubtitleStream(false);
     }
 
-    if(!m_player_subtitle.OpenStream(hint, filename))
+    if(!m_dvdPlayerSubtitle.OpenStream(hint, filename))
     {
       CLog::Log(LOGWARNING, "%s - Unsupported stream %d. Stream disabled.", __FUNCTION__, iStream);
       if(pStream)
@@ -3159,7 +3207,7 @@ bool COMXPlayer::OpenSubtitleStream(int iStream, int source)
     }
   }
   else
-    m_player_subtitle.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+    m_dvdPlayerSubtitle.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
 
   m_CurrentSubtitle.id     = iStream;
   m_CurrentSubtitle.source = source;
@@ -3181,7 +3229,7 @@ bool COMXPlayer::OpenTeletextStream(int iStream, int source)
 
   CDVDStreamInfo hint(*pStream, true);
 
-  if (!m_player_teletext.CheckStream(hint))
+  if (!m_dvdPlayerTeletext.CheckStream(hint))
     return false;
 
   CLog::Log(LOGNOTICE, "Opening teletext stream: %i source: %i", iStream, source);
@@ -3195,7 +3243,7 @@ bool COMXPlayer::OpenTeletextStream(int iStream, int source)
       CloseTeletextStream(true);
     }
 
-    if (!m_player_teletext.OpenStream(hint))
+    if (!m_dvdPlayerTeletext.OpenStream(hint))
     {
       /* mark stream as disabled, to disallaw further attempts*/
       CLog::Log(LOGWARNING, "%s - Unsupported teletext stream %d. Stream disabled.", __FUNCTION__, iStream);
@@ -3205,7 +3253,7 @@ bool COMXPlayer::OpenTeletextStream(int iStream, int source)
     }
   }
   else
-    m_player_teletext.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+    m_dvdPlayerTeletext.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
 
   /* store information about stream */
   m_CurrentTeletext.id      = iStream;
@@ -3227,7 +3275,7 @@ bool COMXPlayer::CloseAudioStream(bool bWaitForBuffers)
   if(bWaitForBuffers)
     SetCaching(CACHESTATE_DONE);
 
-  m_player_audio.CloseStream(bWaitForBuffers);
+  m_omxPlayerAudio.CloseStream(bWaitForBuffers);
 
   m_CurrentAudio.Clear();
   return true;
@@ -3243,7 +3291,7 @@ bool COMXPlayer::CloseVideoStream(bool bWaitForBuffers)
   if(bWaitForBuffers)
     SetCaching(CACHESTATE_DONE);
 
-  m_player_video.CloseStream(bWaitForBuffers);
+  m_omxPlayerVideo.CloseStream(bWaitForBuffers);
 
   m_CurrentVideo.Clear();
   return true;
@@ -3256,7 +3304,7 @@ bool COMXPlayer::CloseSubtitleStream(bool bKeepOverlays)
 
   CLog::Log(LOGNOTICE, "Closing subtitle stream");
 
-  m_player_subtitle.CloseStream(!bKeepOverlays);
+  m_dvdPlayerSubtitle.CloseStream(!bKeepOverlays);
 
   m_CurrentSubtitle.Clear();
   return true;
@@ -3272,7 +3320,7 @@ bool COMXPlayer::CloseTeletextStream(bool bWaitForBuffers)
   if(bWaitForBuffers)
     SetCaching(CACHESTATE_DONE);
 
-  m_player_teletext.CloseStream(bWaitForBuffers);
+  m_dvdPlayerTeletext.CloseStream(bWaitForBuffers);
 
   m_CurrentTeletext.Clear();
   return true;
@@ -3311,19 +3359,19 @@ void COMXPlayer::FlushBuffers(bool queued, double pts, bool accurate)
 
   if(queued)
   {
-    m_player_audio.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
-    m_player_video.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
-    m_player_video.SendMessage(new CDVDMsg(CDVDMsg::VIDEO_NOSKIP));
-    m_player_subtitle.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
-    m_player_teletext.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+    m_omxPlayerAudio.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+    m_omxPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+    m_omxPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::VIDEO_NOSKIP));
+    m_dvdPlayerSubtitle.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
+    m_dvdPlayerTeletext.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));
     SynchronizePlayers(SYNCSOURCE_ALL);
   }
   else
   {
-    m_player_video.Flush();
-    m_player_audio.Flush();
-    m_player_subtitle.Flush();
-    m_player_teletext.Flush();
+    m_omxPlayerAudio.Flush();
+    m_omxPlayerVideo.Flush();
+    m_dvdPlayerSubtitle.Flush();
+    m_dvdPlayerTeletext.Flush();
 
     // clear subtitle and menu overlays
     m_overlayContainer.Clear();
@@ -3333,8 +3381,8 @@ void COMXPlayer::FlushBuffers(bool queued, double pts, bool accurate)
     {
       // make sure players are properly flushed, should put them in stalled state
       CDVDMsgGeneralSynchronize* msg = new CDVDMsgGeneralSynchronize(1000, 0);
-      m_player_video.SendMessage(msg->Acquire(), 1);
-      m_player_audio.SendMessage(msg->Acquire(), 1);
+      m_omxPlayerAudio.SendMessage(msg->Acquire(), 1);
+      m_omxPlayerVideo.SendMessage(msg->Acquire(), 1);
       msg->Wait(&m_bStop, 0);
       msg->Release();
 
@@ -3350,7 +3398,7 @@ void COMXPlayer::FlushBuffers(bool queued, double pts, bool accurate)
     }
 
     if(pts != DVD_NOPTS_VALUE)
-      m_av_clock.Discontinuity(pts);
+      m_clock.Discontinuity(pts);
     UpdatePlayState(0);
 
     // update state, buffers are flushed and it may take some time until
@@ -3374,7 +3422,7 @@ int COMXPlayer::OnDVDNavResult(void* pData, int iMessage)
     else if(iMessage == 3)
       m_dvd.iSelectedSPUStream   = *(int*)pData;
     else if(iMessage == 4)
-      m_player_video.EnableSubtitle(*(int*)pData ? true: false);
+      m_omxPlayerVideo.EnableSubtitle(*(int*)pData ? true: false);
     else if(iMessage == 5)
     {
       if (m_dvd.state != DVDSTATE_STILL)
@@ -3388,7 +3436,7 @@ int COMXPlayer::OnDVDNavResult(void* pData, int iMessage)
         unsigned int time = 0;
         if( m_CurrentVideo.stream && m_dvd.iDVDStillTime > 0 )
         {
-          time = (unsigned int)(m_player_video.GetOutputDelay() / ( DVD_TIME_BASE / 1000 ));
+          time = (unsigned int)(m_omxPlayerVideo.GetOutputDelay() / ( DVD_TIME_BASE / 1000 ));
           if( time < 10000 && time > 0 )
             m_dvd.iDVDStillTime += time;
         }
@@ -3431,7 +3479,7 @@ int COMXPlayer::OnDVDNavResult(void* pData, int iMessage)
           DWORD time = 0;
           if( m_CurrentVideo.stream && m_dvd.iDVDStillTime > 0 )
           {
-            time = (DWORD)(m_player_video.GetOutputDelay() / ( DVD_TIME_BASE / 1000 ));
+            time = (DWORD)(m_omxPlayerVideo.GetOutputDelay() / ( DVD_TIME_BASE / 1000 ));
             if( time < 10000 && time > 0 )
               m_dvd.iDVDStillTime += time;
           }
@@ -3445,7 +3493,7 @@ int COMXPlayer::OnDVDNavResult(void* pData, int iMessage)
       break;
     case DVDNAV_SPU_CLUT_CHANGE:
       {
-        m_player_subtitle.SendMessage(new CDVDMsgSubtitleClutChange((BYTE*)pData));
+        m_dvdPlayerSubtitle.SendMessage(new CDVDMsgSubtitleClutChange((BYTE*)pData));
       }
       break;
     case DVDNAV_SPU_STREAM_CHANGE:
@@ -3455,7 +3503,7 @@ int COMXPlayer::OnDVDNavResult(void* pData, int iMessage)
         int iStream = event->physical_wide;
         bool visible = !(iStream & 0x80);
 
-        m_player_video.EnableSubtitle(visible);
+        m_omxPlayerVideo.EnableSubtitle(visible);
 
         if (iStream >= 0)
           m_dvd.iSelectedSPUStream = (iStream & ~0x80);
@@ -3485,7 +3533,7 @@ int COMXPlayer::OnDVDNavResult(void* pData, int iMessage)
         //dvdnav_highlight_event_t* pInfo = (dvdnav_highlight_event_t*)pData;
         int iButton = pStream->GetCurrentButton();
         CLog::Log(LOGDEBUG, "DVDNAV_HIGHLIGHT: Highlight button %d\n", iButton);
-        m_player_subtitle.UpdateOverlayInfo((CDVDInputStreamNavigator*)m_pInputStream, LIBDVDNAV_BUTTON_NORMAL);
+        m_dvdPlayerSubtitle.UpdateOverlayInfo((CDVDInputStreamNavigator*)m_pInputStream, LIBDVDNAV_BUTTON_NORMAL);
       }
       break;
     case DVDNAV_VTS_CHANGE:
@@ -3498,8 +3546,8 @@ int COMXPlayer::OnDVDNavResult(void* pData, int iMessage)
 
         //Force an aspect ratio that is set in the dvdheaders if available
         m_CurrentVideo.hint.aspect = pStream->GetVideoAspectRatio();
-        if( m_player_video.IsInited() )
-          m_player_video.SendMessage(new CDVDMsgDouble(CDVDMsg::VIDEO_SET_ASPECT, m_CurrentVideo.hint.aspect));
+        if( m_omxPlayerVideo.IsInited() )
+          m_omxPlayerVideo.SendMessage(new CDVDMsgDouble(CDVDMsg::VIDEO_SET_ASPECT, m_CurrentVideo.hint.aspect));
 
         m_SelectionStreams.Clear(STREAM_NONE, STREAM_SOURCE_NAV);
         m_SelectionStreams.Update(m_pInputStream, m_pDemuxer);
@@ -3514,8 +3562,8 @@ int COMXPlayer::OnDVDNavResult(void* pData, int iMessage)
 
         m_dvd.state = DVDSTATE_NORMAL;
 
-        if( m_player_video.IsInited() )
-          m_player_video.SendMessage(new CDVDMsg(CDVDMsg::VIDEO_NOSKIP));
+        if( m_omxPlayerVideo.IsInited() )
+          m_omxPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::VIDEO_NOSKIP));
       }
       break;
     case DVDNAV_NAV_PACKET:
@@ -3720,7 +3768,7 @@ bool COMXPlayer::OnAction(const CAction &action)
           CLog::Log(LOGDEBUG, " - button select");
           // show button pushed overlay
           if(m_pInputStream->IsStreamType(DVDSTREAM_TYPE_DVD))
-            m_player_subtitle.UpdateOverlayInfo((CDVDInputStreamNavigator*)m_pInputStream, LIBDVDNAV_BUTTON_CLICKED);
+            m_dvdPlayerSubtitle.UpdateOverlayInfo((CDVDInputStreamNavigator*)m_pInputStream, LIBDVDNAV_BUTTON_CLICKED);
 
           pMenus->ActivateButton();
         }
@@ -3786,28 +3834,6 @@ bool COMXPlayer::OnAction(const CAction &action)
     }
   }
 
-  switch (action.GetID())
-  {
-    case ACTION_NEXT_ITEM:
-      if(GetChapterCount() > 0)
-      {
-        m_messenger.Put(new CDVDMsgPlayerSeekChapter(GetChapter()+1));
-        g_infoManager.SetDisplayAfterSeek();
-        return true;
-      }
-      else
-        break;
-    case ACTION_PREV_ITEM:
-      if(GetChapterCount() > 0)
-      {
-        m_messenger.Put(new CDVDMsgPlayerSeekChapter(GetChapter()-1));
-        g_infoManager.SetDisplayAfterSeek();
-        return true;
-      }
-      else
-        break;
-  }
-
   // return false to inform the caller we didn't handle the message
   return false;
 }
@@ -3836,15 +3862,15 @@ bool COMXPlayer::HasMenu()
 
 bool COMXPlayer::GetCurrentSubtitle(CStdString& strSubtitle)
 {
+  double pts = m_av_clock.OMXMediaTime(false);
+
   if (m_pInputStream && m_pInputStream->IsStreamType(DVDSTREAM_TYPE_DVD))
     return false;
 
-  double pts = m_av_clock.OMXMediaTime(false);
-
-  m_player_subtitle.GetCurrentSubtitle(strSubtitle, pts - m_player_video.GetSubtitleDelay());
+  m_dvdPlayerSubtitle.GetCurrentSubtitle(strSubtitle, pts - m_omxPlayerVideo.GetSubtitleDelay());
 
   // In case we stalled, don't output any subs
-  if ((m_player_video.IsStalled() && HasVideo()) || (m_player_audio.IsStalled() && HasAudio()))
+  if ((m_omxPlayerVideo.IsStalled() && HasVideo()) || (m_omxPlayerAudio.IsStalled() && HasAudio()))
     strSubtitle = m_lastSub;
   else
     m_lastSub = strSubtitle;
@@ -3919,14 +3945,14 @@ int COMXPlayer::GetCacheLevel() const
 
 double COMXPlayer::GetQueueTime()
 {
-  int a = m_player_video.GetLevel();
-  int v = m_player_audio.GetLevel();
+  int a = m_omxPlayerVideo.GetLevel();
+  int v = m_omxPlayerAudio.GetLevel();
   return max(a, v) * 8000.0 / 100;
 }
 
 void COMXPlayer::GetVideoStreamInfo(SPlayerVideoStreamInfo &info)
 {
-  info.bitrate = m_player_video.GetVideoBitrate();
+  info.bitrate = m_omxPlayerVideo.GetVideoBitrate();
 
   CStdString retVal;
   if (m_pDemuxer && (m_CurrentVideo.id != -1))
@@ -3950,7 +3976,7 @@ void COMXPlayer::GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info)
     return;
 
   if (index == GetAudioStream())
-    info.bitrate = m_player_audio.GetAudioBitrate();
+    info.bitrate = m_omxPlayerAudio.GetAudioBitrate();
   else
     info.bitrate = m_pDemuxer->GetStreamFromAudioId(index)->iBitRate;
 
@@ -4015,7 +4041,7 @@ int COMXPlayer::AddSubtitleFile(const std::string& filename, const std::string&
 void COMXPlayer::UpdatePlayState(double timeout)
 {
   if(m_StateInput.timestamp != 0
-  && m_StateInput.timestamp + DVD_MSEC_TO_TIME(timeout) > m_av_clock.GetAbsoluteClock())
+  && m_StateInput.timestamp + DVD_MSEC_TO_TIME(timeout) > m_clock.GetAbsoluteClock())
     return;
 
   SPlayerState state(m_StateInput);
@@ -4034,11 +4060,7 @@ void COMXPlayer::UpdatePlayState(double timeout)
     if(state.dts == DVD_NOPTS_VALUE)
       state.time     = 0;
     else 
-      // TODO : workaround until omx clock handling is rewritten
-      if(m_playSpeed == DVD_PLAYSPEED_NORMAL)
-        state.time     = DVD_TIME_TO_MSEC(m_av_clock.OMXMediaTime(true));
-      else
-        state.time     = DVD_TIME_TO_MSEC(state.dts + m_offset_pts);
+      state.time     = DVD_TIME_TO_MSEC(state.dts + m_offset_pts);
     state.time_total = m_pDemuxer->GetStreamLength();
     state.time_src   = ETIMESOURCE_CLOCK;
   }
@@ -4140,7 +4162,7 @@ void COMXPlayer::UpdatePlayState(double timeout)
   else
     state.cache_bytes = 0;
 
-  state.timestamp = m_av_clock.GetAbsoluteClock();
+  state.timestamp = m_clock.GetAbsoluteClock();
   //{CLog::Log(LOGINFO, "%s: time:%.2f stamp:%.2f dts:%d m:%d (p:%d,c:%d) =%llu", __func__, (double)state.time, (double)state.timestamp, (int)DVD_TIME_TO_MSEC(state.dts + m_offset_pts), (int)DVD_TIME_TO_MSEC(m_av_clock.OMXMediaTime()), (int)m_playSpeed, (int)m_caching, llrint(state.time + DVD_TIME_TO_MSEC(offset)));}
 
   CSingleLock lock(m_StateSection);
@@ -4150,7 +4172,7 @@ void COMXPlayer::UpdatePlayState(double timeout)
 void COMXPlayer::UpdateApplication(double timeout)
 {
   if(m_UpdateApplication != 0
-  && m_UpdateApplication + DVD_MSEC_TO_TIME(timeout) > m_av_clock.GetAbsoluteClock())
+  && m_UpdateApplication + DVD_MSEC_TO_TIME(timeout) > m_clock.GetAbsoluteClock())
     return;
 
   CDVDInputStream::IChannel* pStream = dynamic_cast<CDVDInputStream::IChannel*>(m_pInputStream);
@@ -4163,7 +4185,7 @@ void COMXPlayer::UpdateApplication(double timeout)
       CApplicationMessenger::Get().SetCurrentItem(item);
     }
   }
-  m_UpdateApplication = m_av_clock.GetAbsoluteClock();
+  m_UpdateApplication = m_clock.GetAbsoluteClock();
 }
 
 bool COMXPlayer::CanRecord()
@@ -4223,7 +4245,7 @@ bool COMXPlayer::GetStreamDetails(CStreamDetails &details)
        * and UpdatePlayState() has been called at least once. In this case dvdplayer duration/AR will
        * return 0 and we'll have to fallback to the (less accurate) info from the demuxer.
        */
-      float aspect = m_player_video.GetAspectRatio();
+      float aspect = m_omxPlayerVideo.GetAspectRatio();
       if (aspect > 0.0f)
         ((CStreamDetailVideo*)details.GetNthStream(CStreamDetail::VIDEO,0))->m_fAspect = aspect;
 
@@ -4240,7 +4262,7 @@ bool COMXPlayer::GetStreamDetails(CStreamDetails &details)
 CStdString COMXPlayer::GetPlayingTitle()
 {
   /* Currently we support only Title Name from Teletext line 30 */
-  TextCacheStruct_t* ttcache = m_player_teletext.GetTeletextCache();
+  TextCacheStruct_t* ttcache = m_dvdPlayerTeletext.GetTeletextCache();
   if (ttcache && !ttcache->line30.empty())
     return ttcache->line30;
 
@@ -4289,23 +4311,6 @@ void COMXPlayer::SetVolume(float fVolume)
   m_change_volume = true;
 }
 
-bool COMXPlayer::WaitForPausedThumbJobs(int timeout_ms)
-{
-  // use m_bStop and Sleep so we can get canceled.
-  while (!m_bStop && (timeout_ms > 0))
-  {
-    if (CJobManager::GetInstance().IsProcessing(CJob::PRIORITY_LOW))
-    {
-      Sleep(100);
-      timeout_ms -= 100;
-    }
-    else
-      return true;
-  }
-
-  return false;
-}
-
 void COMXPlayer::GetRenderFeatures(std::vector<int> &renderFeatures)
 {
   renderFeatures.push_back(RENDERFEATURE_STRETCH);
index b5054d1..aead0be 100644 (file)
  *
  */
 
-#if defined(HAVE_CONFIG_H) && !defined(TARGET_WINDOWS)
-#include "config.h"
-#define DECLARE_UNUSED(a,b) a __attribute__((unused)) b;
-#endif
-
-#include <semaphore.h>
-#include <deque>
-
-#include "FileItem.h"
 #include "cores/IPlayer.h"
-#include "cores/dvdplayer/IDVDPlayer.h"
-#include "dialogs/GUIDialogBusy.h"
 #include "threads/Thread.h"
-#include "threads/SingleLock.h"
 
+#include "cores/dvdplayer/IDVDPlayer.h"
+
+#include "DVDMessageQueue.h"
 #include "OMXCore.h"
 #include "OMXClock.h"
 #include "OMXPlayerAudio.h"
 #include "DVDPlayerSubtitle.h"
 #include "DVDPlayerTeletext.h"
 
+//#include "DVDChapterReader.h"
+#include "DVDSubtitles/DVDFactorySubtitle.h"
 #include "utils/BitstreamStats.h"
 
 #include "linux/DllBCM.h"
 #include "Edl.h"
-
-#define MAX_CHAPTERS 64
-
-#define DVDPLAYER_AUDIO    1
-#define DVDPLAYER_VIDEO    2
-#define DVDPLAYER_SUBTITLE 3
-#define DVDPLAYER_TELETEXT 4
-
-#define DVDSTATE_NORMAL           0x00000001 // normal dvd state
-#define DVDSTATE_STILL            0x00000002 // currently displaying a still frame
-#define DVDSTATE_WAIT             0x00000003 // waiting for demuxer read error
-#define DVDSTATE_SEEK             0x00000004 // we are finishing a seek request
+#include "FileItem.h"
+#include "threads/SingleLock.h"
 
 class COMXPlayer;
 class OMXPlayerVideo;
@@ -67,6 +50,11 @@ namespace PVR
   class CPVRChannel;
 }
 
+#define DVDSTATE_NORMAL           0x00000001 // normal dvd state
+#define DVDSTATE_STILL            0x00000002 // currently displaying a still frame
+#define DVDSTATE_WAIT             0x00000003 // waiting for demuxer read error
+#define DVDSTATE_SEEK             0x00000004 // we are finishing a seek request
+
 class COMXCurrentStream
 {
 public:
@@ -168,6 +156,11 @@ public:
 };
 
 
+#define DVDPLAYER_AUDIO    1
+#define DVDPLAYER_VIDEO    2
+#define DVDPLAYER_SUBTITLE 3
+#define DVDPLAYER_TELETEXT 4
+
 class COMXPlayer : public IPlayer, public CThread, public IDVDPlayer
 {
 public:
@@ -175,73 +168,35 @@ public:
   COMXPlayer(IPlayerCallback &callback);
   virtual ~COMXPlayer();
   
-  virtual void RegisterAudioCallback(IAudioCallback* pCallback) { m_player_audio.RegisterAudioCallback(pCallback); };
-  virtual void UnRegisterAudioCallback()                        { m_player_audio.UnRegisterAudioCallback();        };
-
-  virtual bool  IsValidStream(COMXCurrentStream& stream);
-  virtual bool  IsBetterStream(COMXCurrentStream& current, CDemuxStream* stream);
-  virtual bool  CheckDelayedChannelEntry(void);
-  virtual bool  ReadPacket(DemuxPacket*& packet, CDemuxStream*& stream);
-  virtual bool  CloseAudioStream(bool bWaitForBuffers);
-  virtual bool  CloseVideoStream(bool bWaitForBuffers);
-  virtual bool  CloseSubtitleStream(bool bKeepOverlays);
-  virtual bool  CloseTeletextStream(bool bWaitForBuffers);
-  virtual bool  OpenAudioStream(int iStream, int source, bool reset = true);
-  virtual bool  OpenVideoStream(int iStream, int source, bool reset = true);
-  virtual bool  OpenSubtitleStream(int iStream, int source); 
-  virtual bool  OpenTeletextStream(int iStream, int source);
-  virtual void  OpenDefaultStreams(bool reset = true);
-  virtual bool  OpenDemuxStream();
-  virtual bool  OpenInputStream();
-  virtual bool  CheckPlayerInit(COMXCurrentStream& current, unsigned int source);
-  virtual void  UpdateCorrection(DemuxPacket* pkt, double correction);
-  virtual void  UpdateTimestamps(COMXCurrentStream& current, DemuxPacket* pPacket);
-  virtual void  UpdateLimits(double& minimum, double& maximum, double dts);
-  virtual bool  CheckSceneSkip(COMXCurrentStream& current);
-  virtual void  CheckAutoSceneSkip();
-  virtual void  CheckContinuity(COMXCurrentStream& current, DemuxPacket* pPacket);
-  virtual void  ProcessAudioData(CDemuxStream* pStream, DemuxPacket* pPacket);
-  virtual void  ProcessVideoData(CDemuxStream* pStream, DemuxPacket* pPacket);
-  virtual void  ProcessSubData(CDemuxStream* pStream, DemuxPacket* pPacket);
-  virtual void  ProcessTeletextData(CDemuxStream* pStream, DemuxPacket* pPacket);
-  virtual void  ProcessPacket(CDemuxStream* pStream, DemuxPacket* pPacket);
-  virtual void  SynchronizeDemuxer(unsigned int timeout);
-  virtual void  SynchronizePlayers(unsigned int sources);
-  virtual void  SendPlayerMessage(CDVDMsg* pMsg, unsigned int target);
-  virtual void  HandleMessages();
-
   virtual bool  OpenFile(const CFileItem &file, const CPlayerOptions &options);
-  virtual bool  QueueNextFile(const CFileItem &file)             {return false;}
-  virtual void  OnNothingToQueueNotify()                         {}
   virtual bool  CloseFile();
   virtual bool  IsPlaying() const;
-  virtual void  SetPlaySpeed(int speed);
-  int GetPlaySpeed()                                                { return m_playSpeed; }
   virtual void  Pause();
   virtual bool  IsPaused() const;
   virtual bool  HasVideo() const;
   virtual bool  HasAudio() const;
   virtual bool  IsPassthrough() const;
   virtual bool  CanSeek();
-  virtual void  Seek(bool bPlus = true, bool bLargeStep = false);
+  virtual void Seek(bool bPlus, bool bLargeStep);
   virtual bool  SeekScene(bool bPlus = true);
-  virtual void  SeekPercentage(float fPercent = 0.0f);
+  virtual void SeekPercentage(float iPercent);
   virtual float GetPercentage();
   virtual float GetCachePercentage();
 
-  virtual void  SetMute(bool bOnOff);
-  virtual void  SetVolume(float fVolume);
-  virtual bool  ControlsVolume() {return true;}
-  virtual void  SetDynamicRangeCompression(long drc)              {}
-  virtual void  GetAudioInfo(CStdString &strAudioInfo);
-  virtual void  GetVideoInfo(CStdString &strVideoInfo);
-  virtual void  GetGeneralInfo(CStdString &strVideoInfo);
-  virtual void  UpdateApplication(double timeout);
-  virtual bool  CanRecord();
-  virtual bool  IsRecording();
-  virtual bool  CanPause();
-  virtual bool  Record(bool bOnOff);
-  virtual void  SetAVDelay(float fValue = 0.0f);
+  virtual void RegisterAudioCallback(IAudioCallback* pCallback) { m_omxPlayerAudio.RegisterAudioCallback(pCallback); }
+  virtual void UnRegisterAudioCallback()                        { m_omxPlayerAudio.UnRegisterAudioCallback(); }
+  virtual void SetVolume(float nVolume);
+  virtual void SetMute(bool bOnOff);
+  virtual bool ControlsVolume() {return true;}
+  virtual void SetDynamicRangeCompression(long drc)              {}
+  virtual void GetAudioInfo(CStdString &strAudioInfo);
+  virtual void GetVideoInfo(CStdString &strVideoInfo);
+  virtual void GetGeneralInfo(CStdString &strVideoInfo);
+  virtual bool CanRecord();
+  virtual bool IsRecording();
+  virtual bool CanPause();
+  virtual bool Record(bool bOnOff);
+  virtual void SetAVDelay(float fValue = 0.0f);
   virtual float GetAVDelay();
 
   virtual void  SetSubTitleDelay(float fValue = 0.0f);
@@ -266,25 +221,24 @@ public:
   virtual void  GetChapterName(CStdString& strChapterName);
   virtual int   SeekChapter(int iChapter);
 
-  virtual void  SeekTime(int64_t iTime = 0);
-  virtual int64_t GetTotalTimeInMsec();
+  virtual void SeekTime(int64_t iTime);
   virtual int64_t GetTime();
   virtual int64_t GetTotalTime();
-  virtual void  ToFFRW(int iSpeed = 0);
-  virtual void  GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info);
-  virtual void  GetVideoStreamInfo(SPlayerVideoStreamInfo &info);
-  virtual int   GetSourceBitrate();
-  virtual int   GetPictureWidth();
-  virtual int   GetPictureHeight();
-  virtual bool  GetStreamDetails(CStreamDetails &details);
-
-  virtual bool  IsInMenu() const;
-  virtual bool  HasMenu();
-
-  virtual bool  GetCurrentSubtitle(CStdString& strSubtitle);
-  //returns a state that is needed for resuming from a specific time
+  virtual void ToFFRW(int iSpeed );
+  virtual bool OnAction(const CAction &action);
+  virtual bool HasMenu();
+  virtual int GetSourceBitrate();
+  virtual void GetVideoStreamInfo(SPlayerVideoStreamInfo &info);
+
+  virtual int GetPictureWidth();
+  virtual int GetPictureHeight();
+  virtual bool GetStreamDetails(CStreamDetails &details);
+  virtual void GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info);
+
+  virtual bool GetCurrentSubtitle(CStdString& strSubtitle);
+
   virtual CStdString GetPlayerState();
-  virtual bool  SetPlayerState(CStdString state);
+  virtual bool SetPlayerState(CStdString state);
   
   virtual CStdString GetPlayingTitle();
 
@@ -300,23 +254,10 @@ public:
   , CACHESTATE_FLUSH    // temporary state player will choose startup between init or full
   };
 
-  int m_playSpeed;
-  struct SSpeedState
-  {
-    double lastpts;  // holds last display pts during ff/rw operations
-    double lasttime;
-  } m_SpeedState;
-
-  void    HandlePlaySpeed();
-  bool    GetCachingTimes(double& play_left, double& cache_left, double& file_offset);
-  bool    CheckStartCaching(COMXCurrentStream& current);
-  void    SetCaching(ECacheState state);
-  double  GetQueueTime();
-  virtual bool  IsCaching() const                                 { return m_caching == CACHESTATE_FULL; }
+  virtual bool  IsCaching() const                                 { return m_caching == CACHESTATE_FULL || m_caching == CACHESTATE_PVR; }
   virtual int   GetCacheLevel() const;
 
   virtual int  OnDVDNavResult(void* pData, int iMessage);
-  virtual bool OnAction(const CAction &action);
 
   virtual void  GetRenderFeatures(std::vector<int> &renderFeatures);
   virtual void  GetDeinterlaceMethods(std::vector<int> &deinterlaceMethods);
@@ -335,19 +276,116 @@ protected:
 
   virtual void  OnStartup();
   virtual void  OnExit();
-  bool WaitForPausedThumbJobs(int timeout_ms);
   virtual void  Process();
 
+  bool OpenAudioStream(int iStream, int source, bool reset = true);
+  bool OpenVideoStream(int iStream, int source, bool reset = true);
+  bool OpenSubtitleStream(int iStream, int source);
+  bool OpenTeletextStream(int iStream, int source);
+  bool CloseAudioStream(bool bWaitForBuffers);
+  bool CloseVideoStream(bool bWaitForBuffers);
+  bool CloseSubtitleStream(bool bKeepOverlays);
+  bool CloseTeletextStream(bool bWaitForBuffers);
+
+  void ProcessPacket(CDemuxStream* pStream, DemuxPacket* pPacket);
+  void ProcessAudioData(CDemuxStream* pStream, DemuxPacket* pPacket);
+  void ProcessVideoData(CDemuxStream* pStream, DemuxPacket* pPacket);
+  void ProcessSubData(CDemuxStream* pStream, DemuxPacket* pPacket);
+  void ProcessTeletextData(CDemuxStream* pStream, DemuxPacket* pPacket);
+
+  bool ShowPVRChannelInfo();
+
+  int  AddSubtitleFile(const std::string& filename, const std::string& subfilename = "", CDemuxStream::EFlags flags = CDemuxStream::FLAG_NONE);
+
+  /**
+   * one of the DVD_PLAYSPEED defines
+   */
+  void SetPlaySpeed(int iSpeed);
+  int GetPlaySpeed()                                                { return m_playSpeed; }
+  void    SetCaching(ECacheState state);
+
+  int64_t GetTotalTimeInMsec();
+
+  double  GetQueueTime();
+  bool    GetCachingTimes(double& play_left, double& cache_left, double& file_offset);
+
+
+  void FlushBuffers(bool queued, double pts = DVD_NOPTS_VALUE, bool accurate = true);
+
+
+  void  HandleMessages();
+  void    HandlePlaySpeed();
+  bool  IsInMenu() const;
+
+  void SynchronizePlayers(unsigned int sources);
+  void SynchronizeDemuxer(unsigned int timeout);
+  void CheckAutoSceneSkip();
+  void CheckContinuity(COMXCurrentStream& current, DemuxPacket* pPacket);
+  bool CheckSceneSkip(COMXCurrentStream& current);
+  bool CheckPlayerInit(COMXCurrentStream& current, unsigned int source);
+  bool CheckStartCaching(COMXCurrentStream& current);
+  void UpdateCorrection(DemuxPacket* pkt, double correction);
+  void UpdateTimestamps(COMXCurrentStream& current, DemuxPacket* pPacket);
+  void SendPlayerMessage(CDVDMsg* pMsg, unsigned int target);
+  bool ReadPacket(DemuxPacket*& packet, CDemuxStream*& stream);
+  bool IsValidStream(COMXCurrentStream& stream);
+  bool IsBetterStream(COMXCurrentStream& current, CDemuxStream* stream);
+  bool CheckDelayedChannelEntry(void);
+  bool OpenInputStream();
+  bool OpenDemuxStream();
+  void OpenDefaultStreams(bool reset = true);
+
+  void UpdateApplication(double timeout);
+  void UpdatePlayState(double timeout);
+  double m_UpdateApplication;
+
+  bool m_bAbortRequest;
+
   std::string           m_filename; // holds the actual filename
-  CDVDInputStream       *m_pInputStream;
-  CDVDDemux             *m_pDemuxer;
+  std::string  m_mimetype;  // hold a hint to what content file contains (mime type)
+  ECacheState  m_caching;
+  CFileItem    m_item;
+  unsigned int m_iChannelEntryTimeOut;
+
+
+  COMXCurrentStream m_CurrentAudio;
+  COMXCurrentStream m_CurrentVideo;
+  COMXCurrentStream m_CurrentSubtitle;
+  COMXCurrentStream m_CurrentTeletext;
+
+  COMXSelectionStreams m_SelectionStreams;
+
+  int m_playSpeed;
+  struct SSpeedState
+  {
+    double lastpts;  // holds last display pts during ff/rw operations
+    double lasttime;
+  } m_SpeedState;
+
+  int m_errorCount;
+  double m_offset_pts;
+
+  CDVDMessageQueue m_messenger;     // thread messenger
+
+  OMXPlayerVideo m_omxPlayerVideo; // video part
+  OMXPlayerAudio m_omxPlayerAudio; // audio part
+  CDVDPlayerSubtitle m_dvdPlayerSubtitle; // subtitle part
+  CDVDTeletextData m_dvdPlayerTeletext; // teletext part
+
+  CDVDClock m_clock;                // master clock
+  OMXClock m_av_clock;
+
+  float m_current_volume;
+  bool m_current_mute;
+  bool m_change_volume;
+
+  CDVDOverlayContainer m_overlayContainer;
+
+  CDVDInputStream* m_pInputStream;  // input stream for current playing file
+  CDVDDemux* m_pDemuxer;            // demuxer for current playing file
   CDVDDemux*            m_pSubtitleDemuxer;
-  COMXSelectionStreams  m_SelectionStreams;
-  std::string           m_mimetype;
-  COMXCurrentStream     m_CurrentAudio;
-  COMXCurrentStream     m_CurrentVideo;
-  COMXCurrentStream     m_CurrentSubtitle;
-  COMXCurrentStream     m_CurrentTeletext;
+
+  CStdString m_lastSub;
 
   struct SDVDInfo
   {
@@ -437,6 +475,9 @@ protected:
   } m_State, m_StateInput;
   CCriticalSection m_StateSection;
 
+  CEvent m_ready;
+  CCriticalSection m_critStreamSection; // need to have this lock when switching streams (audio / video)
+
   CEdl m_Edl;
 
   struct SEdlAutoSkipMarkers {
@@ -458,45 +499,7 @@ protected:
 
   } m_EdlAutoSkipMarkers;
 
-  bool ShowPVRChannelInfo();
-
-  int  AddSubtitleFile(const std::string& filename, const std::string& subfilename = "", CDemuxStream::EFlags flags = CDemuxStream::FLAG_NONE);
-  virtual void UpdatePlayState(double timeout);
-
-  double m_UpdateApplication;
-
-  void RenderUpdateCallBack(const void *ctx, const CRect &SrcRect, const CRect &DestRect);
-
-private:
-  void FlushBuffers(bool queued, double pts = DVD_NOPTS_VALUE, bool accurate = true);
-
-  CCriticalSection        m_critStreamSection;
-
-  bool                    m_paused;
-  bool                    m_bAbortRequest;
-  CFileItem               m_item;
   CPlayerOptions          m_PlayerOptions;
-  unsigned int            m_iChannelEntryTimeOut;
-
-  std::string             m_lastSub;
-
-  double                  m_offset_pts;
-
-  CDVDMessageQueue        m_messenger;
-
-  OMXClock                m_av_clock;
-  OMXPlayerVideo          m_player_video;
-  OMXPlayerAudio          m_player_audio;
-  CDVDPlayerSubtitle      m_player_subtitle;
-  CDVDTeletextData        m_player_teletext;
-
-  CEvent                  m_ready;
-
-  float                   m_current_volume;
-  bool                    m_current_mute;
-  bool                    m_change_volume;
-  CDVDOverlayContainer    m_overlayContainer;
-  ECacheState             m_caching;
 
   bool m_HasVideo;
   bool m_HasAudio;
index bacd119..c6ba9c6 100644 (file)
@@ -18,9 +18,9 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
 #include "system.h"
 #endif
 
@@ -75,12 +75,9 @@ OMXPlayerAudio::OMXPlayerAudio(OMXClock *av_clock, CDVDMessageQueue& parent)
   m_buffer_empty  = false;
   m_nChannels     = 0;
   m_DecoderOpen   = false;
-  m_freq          = CurrentHostFrequency();
   m_bad_state     = false;
   m_hints_current.Clear();
 
-  m_av_clock->SetMasterClock(false);
-
   m_messageQueue.SetMaxDataSize(3 * 1024 * 1024);
   m_messageQueue.SetMaxTimeSize(8.0);
   m_use_passthrough = false;
@@ -88,16 +85,7 @@ OMXPlayerAudio::OMXPlayerAudio(OMXClock *av_clock, CDVDMessageQueue& parent)
   m_use_hw_decode = false;
   m_hw_decode = false;
   m_silence = false;
-  m_error = 0.0;
-  m_errorbuff = 0.0;
-  m_errorcount = 0;
-  m_syncclock = false;
-  m_integral = 0.0;
-  m_skipdupcount = 0;
-  m_prevskipped = false;
   m_flush = false;  
-  m_synctype = 0;
-
 }
 
 
@@ -149,20 +137,11 @@ void OMXPlayerAudio::OpenStream(CDVDStreamInfo &hints, COMXAudioCodecOMX *codec)
 
   m_speed           = DVD_PLAYSPEED_NORMAL;
   m_audioClock      = 0;
-  m_error           = 0;
-  m_errorbuff       = 0;
-  m_errorcount      = 0;
-  m_integral        = 0;
-  m_skipdupcount    = 0;
-  m_prevskipped     = false;
-  m_syncclock       = true;
   m_hw_decode       = false;
-  m_errortime       = CurrentHostCounter();
   m_silence         = false;
   m_started         = false;
   m_flush           = false;
   m_nChannels       = 0;
-  m_synctype        = SYNC_DISCON;
   m_stalled         = m_messageQueue.GetPacketCount(CDVDMsg::DEMUXER_PACKET) == 0;
   m_use_passthrough = (CSettings::Get().GetInt("audiooutput.mode") == AUDIO_HDMI) ? true : false ;
   m_use_hw_decode   = g_advancedSettings.m_omxHWAudioDecode;
@@ -204,110 +183,6 @@ void OMXPlayerAudio::OnExit()
   CLog::Log(LOGNOTICE, "thread end: OMXPlayerAudio::OnExit()");
 }
 
-
-
-void OMXPlayerAudio::HandleSyncError(double duration)
-{
-  double clock = m_av_clock->GetClock();
-  double error = m_audioClock - clock;
-  int64_t now;
-
-  if( fabs(error) > DVD_MSEC_TO_TIME(100) || m_syncclock )
-  {
-    m_av_clock->Discontinuity(clock+error);
-    /*
-    if(m_speed == DVD_PLAYSPEED_NORMAL)
-    CLog::Log(LOGDEBUG, "OMXPlayerAudio:: Discontinuity - was:%f, should be:%f, error:%f\n", clock, clock+error, error);
-    */
-
-    m_errorbuff = 0;
-    m_errorcount = 0;
-    m_skipdupcount = 0;
-    m_error = 0;
-    m_syncclock = false;
-    m_errortime = CurrentHostCounter();
-
-    return;
-  }
-
-  if (m_speed != DVD_PLAYSPEED_NORMAL)
-  {
-    m_errorbuff = 0;
-    m_errorcount = 0;
-    m_integral = 0;
-    m_skipdupcount = 0;
-    m_error = 0;
-    m_errortime = CurrentHostCounter();
-    return;
-  }
-
-  //check if measured error for 1 second
-  now = CurrentHostCounter();
-  if ((now - m_errortime) >= m_freq)
-  {
-    m_errortime = now;
-    m_error = m_errorbuff / m_errorcount;
-
-    m_errorbuff = 0;
-    m_errorcount = 0;
-
-    if (m_synctype == SYNC_DISCON)
-    {
-      double limit, error;
-
-      if (m_av_clock->GetRefreshRate(&limit) > 0)
-      {
-        //when the videoreferenceclock is running, the discontinuity limit is one vblank period
-        limit *= DVD_TIME_BASE;
-
-        //make error a multiple of limit, rounded towards zero,
-        //so it won't interfere with the sync methods in CXBMCRenderManager::WaitPresentTime
-        if (m_error > 0.0)
-          error = limit * floor(m_error / limit);
-        else
-          error = limit * ceil(m_error / limit);
-      }
-      else
-      {
-        limit = DVD_MSEC_TO_TIME(10);
-        error = m_error;
-      }
-
-      /*
-      limit = DVD_MSEC_TO_TIME(10);
-      error = m_error;
-      */
-
-      if (fabs(error) > limit - 0.001)
-      {
-        m_av_clock->Discontinuity(clock+error);
-        /*
-        if(m_speed == DVD_PLAYSPEED_NORMAL)
-          CLog::Log(LOGDEBUG, "COMXPlayerAudio:: Discontinuity - was:%f, should be:%f, error:%f", clock, clock+error, error);
-        */
-      }
-    }
-    /*
-    else if (m_synctype == SYNC_SKIPDUP && m_skipdupcount == 0 && fabs(m_error) > DVD_MSEC_TO_TIME(10))
-    if (m_skipdupcount == 0 && fabs(m_error) > DVD_MSEC_TO_TIME(10))
-    {
-      //check how many packets to skip/duplicate
-      m_skipdupcount = (int)(m_error / duration);
-      //if less than one frame off, see if it's more than two thirds of a frame, so we can get better in sync
-      if (m_skipdupcount == 0 && fabs(m_error) > duration / 3 * 2)
-        m_skipdupcount = (int)(m_error / (duration / 3 * 2));
-
-      if (m_skipdupcount > 0)
-        CLog::Log(LOGDEBUG, "OMXPlayerAudio:: Duplicating %i packet(s) of %.2f ms duration",
-                  m_skipdupcount, duration / DVD_TIME_BASE * 1000.0);
-      else if (m_skipdupcount < 0)
-        CLog::Log(LOGDEBUG, "OMXPlayerAudio:: Skipping %i packet(s) of %.2f ms duration ",
-                  m_skipdupcount * -1,  duration / DVD_TIME_BASE * 1000.0);
-    }
-    */
-  }
-}
-
 bool OMXPlayerAudio::CodecChange()
 {
   unsigned int old_bitrate = m_hints.bitrate;
@@ -408,9 +283,6 @@ bool OMXPlayerAudio::Decode(DemuxPacket *pkt, bool bDropPacket)
         int n = (m_nChannels * m_hints.bitspersample * m_hints.samplerate)>>3;
         if (n > 0)
           m_audioClock += ((double)decoded_size * DVD_TIME_BASE) / n;
-
-        if(m_speed == DVD_PLAYSPEED_NORMAL)
-          HandleSyncError((((double)decoded_size * DVD_TIME_BASE) / n));
         break;
 
       }
@@ -444,9 +316,6 @@ bool OMXPlayerAudio::Decode(DemuxPacket *pkt, bool bDropPacket)
         m_omxAudio.AddPackets(pkt->pData, pkt->iSize, m_audioClock, m_audioClock);
       }
 
-      if(m_speed == DVD_PLAYSPEED_NORMAL)
-        HandleSyncError(0);
-
       m_audioStats.AddSampleBytes(pkt->iSize);
 
       break;
@@ -539,18 +408,7 @@ void OMXPlayerAudio::Process()
     else if (pMsg->IsType(CDVDMsg::GENERAL_RESYNC))
     { //player asked us to set internal clock
       CDVDMsgGeneralResync* pMsgGeneralResync = (CDVDMsgGeneralResync*)pMsg;
-
-      if (pMsgGeneralResync->m_timestamp != DVD_NOPTS_VALUE)
-        m_audioClock = pMsgGeneralResync->m_timestamp;
-
-      if (pMsgGeneralResync->m_clock)
-      {
-        CLog::Log(LOGDEBUG, "COMXPlayerAudio - CDVDMsg::GENERAL_RESYNC(%f, 1)", m_audioClock);
-        m_av_clock->Discontinuity(m_audioClock);
-        //m_av_clock->OMXUpdateClock(m_audioClock);
-      }
-      else
-        CLog::Log(LOGDEBUG, "COMXPlayerAudio - CDVDMsg::GENERAL_RESYNC(%f, 0)", m_audioClock);
+      CLog::Log(LOGDEBUG, "COMXPlayerAudio - CDVDMsg::GENERAL_RESYNC(%f, %d)", m_audioClock, pMsgGeneralResync->m_clock);
       m_flush = false;
     }
     else if (pMsg->IsType(CDVDMsg::GENERAL_RESET))
@@ -573,7 +431,6 @@ void OMXPlayerAudio::Process()
       m_omxAudio.Flush();
       m_av_clock->OMXReset(false);
       m_av_clock->UnLock();
-      m_syncclock = true;
       m_stalled   = true;
       m_started   = false;
 
@@ -625,10 +482,6 @@ void OMXPlayerAudio::Process()
         m_speed = static_cast<CDVDMsgInt*>(pMsg)->m_value;
         CLog::Log(LOGDEBUG, "COMXPlayerAudio - CDVDMsg::PLAYER_SETSPEED %d", m_speed);
       }
-      if (m_speed != DVD_PLAYSPEED_NORMAL)
-      {
-        m_syncclock = true;
-      }
     }
     else if (pMsg->IsType(CDVDMsg::AUDIO_SILENCE))
     {
@@ -683,7 +536,6 @@ AEDataFormat OMXPlayerAudio::GetDataFormat(CDVDStreamInfo hints)
     hdmi_passthrough_ac3 = true;
   if (m_DllBcmHost.vc_tv_hdmi_audio_supported(EDID_AudioFormat_eDTS, 2, EDID_AudioSampleRate_e44KHz, EDID_AudioSampleSize_16bit ) == 0)
     hdmi_passthrough_dts = true;
-  //printf("Audio support AC3=%d, DTS=%d\n", hdmi_passthrough_ac3, hdmi_passthrough_dts);
 
   m_passthrough = false;
   m_hw_decode   = false;
@@ -723,10 +575,10 @@ AEDataFormat OMXPlayerAudio::GetDataFormat(CDVDStreamInfo hints)
   /* software path */
   if(!m_passthrough && !m_hw_decode)
   {
-    /* 6 channel have to be mapped to 8 for PCM */
-    if(m_nChannels > 4)
-      m_nChannels = 8;
-    dataFormat = AE_FMT_S16NE;
+    if (m_pAudioCodec && m_pAudioCodec->GetBitsPerSample() == 16)
+      dataFormat = AE_FMT_S16NE;
+    else
+      dataFormat = AE_FMT_FLOAT;
   }
 
   return dataFormat;
@@ -818,6 +670,11 @@ double OMXPlayerAudio::GetCacheTime()
   return m_omxAudio.GetCacheTime();
 }
 
+double OMXPlayerAudio::GetCacheTotal()
+{
+  return m_omxAudio.GetCacheTotal();
+}
+
 void OMXPlayerAudio::SubmitEOS()
 {
   if(!m_bad_state)
index 21d42c0..87c6023 100644 (file)
@@ -60,19 +60,6 @@ protected:
   int                       m_speed;
   bool                      m_silence;
   double                    m_audioClock;
-  double m_error;    //last average error
-
-  int64_t m_errortime; //timestamp of last time we measured
-  int64_t m_freq;
-
-  void   HandleSyncError(double duration);
-  double m_errorbuff; //place to store average errors
-  int    m_errorcount;//number of errors stored
-  bool   m_syncclock;
-
-  double m_integral; //integral correction for resampler
-  int    m_skipdupcount; //counter for skip/duplicate synctype
-  bool   m_prevskipped;
 
   bool                      m_stalled;
   bool                      m_started;
@@ -82,8 +69,6 @@ protected:
   struct timespec           m_starttime, m_endtime;
   bool                      m_buffer_empty;
   bool                      m_flush;
-  //SYNC_DISCON, SYNC_SKIPDUP, SYNC_RESAMPLE
-  int                       m_synctype;
   int                       m_nChannels;
   bool                      m_DecoderOpen;
 
@@ -118,7 +103,8 @@ public:
   void CloseDecoder();
   double GetDelay();
   double GetCacheTime();
-  double GetCurrentPTS() { return m_audioClock; };
+  double GetCacheTotal();
+  double GetCurrentPts() { return m_audioClock; };
   void WaitCompletion();
   void SubmitEOS();
   void  RegisterAudioCallback(IAudioCallback* pCallback);
index f338941..42f067f 100644 (file)
@@ -18,9 +18,9 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
 #include "system.h"
 #endif
 
@@ -45,6 +45,7 @@
 #include "settings/MediaSettings.h"
 #include "cores/VideoRenderers/RenderFormats.h"
 #include "cores/VideoRenderers/RenderFlags.h"
+#include "guilib/GraphicContext.h"
 
 #include "OMXPlayer.h"
 
@@ -74,7 +75,6 @@ OMXPlayerVideo::OMXPlayerVideo(OMXClock *av_clock,
 {
   m_av_clock              = av_clock;
   m_pOverlayContainer     = pOverlayContainer;
-  m_pTempOverlayPicture   = NULL;
   m_open                  = false;
   m_stream_id             = -1;
   m_fFrameRate            = 25.0f;
@@ -82,21 +82,17 @@ OMXPlayerVideo::OMXPlayerVideo(OMXClock *av_clock,
   m_speed                 = DVD_PLAYSPEED_NORMAL;
   m_stalled               = false;
   m_iSubtitleDelay        = 0;
-  m_FlipTimeStamp         = 0.0;
   m_bRenderSubs           = false;
   m_flags                 = 0;
   m_bAllowFullscreen      = false;
   m_iCurrentPts           = DVD_NOPTS_VALUE;
   m_iVideoDelay           = 0;
-  m_autosync              = 1;
   m_fForcedAspectRatio    = 0.0f;
   m_messageQueue.SetMaxDataSize(10 * 1024 * 1024);
   m_messageQueue.SetMaxTimeSize(8.0);
 
   m_dst_rect.SetRect(0, 0, 0, 0);
-  m_iSleepEndTime = 0.0;
-  m_Deinterlace = false;
-  m_audio_count = 0;
+  m_nextOverlay = DVD_NOPTS_VALUE;
   m_started = false;
   m_flush = false;
   m_view_mode = 0;
@@ -109,19 +105,12 @@ OMXPlayerVideo::~OMXPlayerVideo()
 
 bool OMXPlayerVideo::OpenStream(CDVDStreamInfo &hints)
 {
-  /*
-  if(IsRunning())
-    CloseStream(false);
-  */
-
   m_hints       = hints;
-  m_Deinterlace = ( CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode == VS_DEINTERLACEMODE_OFF ) ? false : true;
   m_hdmi_clock_sync = (CSettings::Get().GetInt("videoplayer.adjustrefreshrate") != ADJUST_REFRESHRATE_OFF);
   m_started     = false;
   m_flush       = false;
   m_stalled     = m_messageQueue.GetPacketCount(CDVDMsg::DEMUXER_PACKET) == 0;
-  m_autosync    = 1;
-  m_iSleepEndTime = DVD_NOPTS_VALUE;
+  m_nextOverlay = DVD_NOPTS_VALUE;
   // force SetVideoRect to be called initially
   m_dst_rect.SetRect(0, 0, 0, 0);
 
@@ -144,15 +133,6 @@ bool OMXPlayerVideo::OpenStream(CDVDStreamInfo &hints)
     Create();
   }
 
-  /*
-  if(!OpenStream(hints, NULL))
-    return false;
-
-  CLog::Log(LOGNOTICE, "Creating video thread");
-  m_messageQueue.Init();
-  Create();
-  */
-
   m_open        = true;
 
   return true;
@@ -180,12 +160,6 @@ bool OMXPlayerVideo::CloseStream(bool bWaitForBuffers)
   m_speed         = DVD_PLAYSPEED_NORMAL;
   m_started       = false;
 
-  if (m_pTempOverlayPicture)
-  {
-    CDVDCodecUtils::FreePicture(m_pTempOverlayPicture);
-    m_pTempOverlayPicture = NULL;
-  }
-
   m_av_clock->Lock();
   m_av_clock->OMXStop(false);
   m_omxVideo.Close();
@@ -202,7 +176,7 @@ bool OMXPlayerVideo::CloseStream(bool bWaitForBuffers)
 void OMXPlayerVideo::OnStartup()
 {
   m_iCurrentPts = DVD_NOPTS_VALUE;
-  m_FlipTimeStamp = m_av_clock->GetAbsoluteClock();
+  m_nextOverlay = DVD_NOPTS_VALUE;
 }
 
 void OMXPlayerVideo::OnExit()
@@ -210,6 +184,40 @@ void OMXPlayerVideo::OnExit()
   CLog::Log(LOGNOTICE, "thread end: video_thread");
 }
 
+double OMXPlayerVideo::NextOverlay(double pts)
+{
+  double delta_start, delta_stop, min_delta = DVD_NOPTS_VALUE;
+
+  CSingleLock lock(*m_pOverlayContainer);
+  VecOverlays* pVecOverlays = m_pOverlayContainer->GetOverlays();
+  VecOverlaysIter it = pVecOverlays->begin();
+
+  //Find the minimum time before a subtitle is added or removed
+  while (it != pVecOverlays->end())
+  {
+    CDVDOverlay* pOverlay = *it++;
+    if(!pOverlay->bForced && !m_bRenderSubs)
+      continue;
+
+    double pts2 = pOverlay->bForced ? pts : pts - m_iSubtitleDelay;
+
+    delta_start = pOverlay->iPTSStartTime - pts2;
+    delta_stop = pOverlay->iPTSStopTime - pts2;
+
+    // when currently on screen, we periodically update to allow (limited rate) ASS animation
+    if (delta_start <= 0.0 && delta_stop > 0.0 && (min_delta == DVD_NOPTS_VALUE || DVD_MSEC_TO_TIME(100) < min_delta))
+      min_delta = DVD_MSEC_TO_TIME(100);
+
+    else if (delta_start > 0.0 && (min_delta == DVD_NOPTS_VALUE || delta_start < min_delta))
+      min_delta = delta_start;
+
+    else if (delta_stop > 0.0 && (min_delta == DVD_NOPTS_VALUE || delta_stop < min_delta))
+      min_delta = delta_stop;
+  }
+  return min_delta == DVD_NOPTS_VALUE ? pts+DVD_MSEC_TO_TIME(500) : pts+min_delta;
+}
+
+
 void OMXPlayerVideo::ProcessOverlays(double pts)
 {
   // remove any overlays that are out of time
@@ -257,80 +265,34 @@ void OMXPlayerVideo::Output(double pts, bool bDropPacket)
     return;
   }
 
-  // calculate the time we need to delay this picture before displaying
-  double iSleepTime, iClockSleep, iFrameSleep, iPlayingClock, iCurrentClock, iFrameDuration;
-
-  iPlayingClock = m_av_clock->GetClock(iCurrentClock, false); // snapshot current clock
-  iClockSleep = pts - iPlayingClock; //sleep calculated by pts to clock comparison
-  iFrameSleep = m_FlipTimeStamp - iCurrentClock; // sleep calculated by duration of frame
-  iFrameDuration = (double)DVD_TIME_BASE / m_fFrameRate; //pPacket->duration;
-
-  // correct sleep times based on speed
-  if(m_speed)
-  {
-    iClockSleep = iClockSleep * DVD_PLAYSPEED_NORMAL / m_speed;
-    iFrameSleep = iFrameSleep * DVD_PLAYSPEED_NORMAL / abs(m_speed);
-    iFrameDuration = iFrameDuration * DVD_PLAYSPEED_NORMAL / abs(m_speed);
-  }
-  else
-  {
-    iClockSleep = 0;
-    iFrameSleep = 0;
-  }
-
-  // dropping to a very low framerate is not correct (it should not happen at all)
-  iClockSleep = min(iClockSleep, DVD_MSEC_TO_TIME(500));
-  iFrameSleep = min(iFrameSleep, DVD_MSEC_TO_TIME(500));
-
-  if( m_stalled )
-    iSleepTime = iFrameSleep;
-  else
-    iSleepTime = iFrameSleep + (iClockSleep - iFrameSleep) / m_autosync;
-
-  // present the current pts of this frame to user, and include the actual
-  // presentation delay, to allow him to adjust for it
-  if( m_stalled )
-    m_iCurrentPts = DVD_NOPTS_VALUE;
-  else
-    m_iCurrentPts = pts - max(0.0, iSleepTime);
+  m_iCurrentPts = pts;
 
-  // timestamp when we think next picture should be displayed based on current duration
-  m_FlipTimeStamp  = iCurrentClock;
-  m_FlipTimeStamp += max(0.0, iSleepTime);
-  m_FlipTimeStamp += iFrameDuration;
-
-  if( m_speed < 0 )
-  {
-    if( iClockSleep < -DVD_MSEC_TO_TIME(200))
-      return;
-  }
-
-  if(bDropPacket)
+  if (CThread::m_bStop)
     return;
 
-  // DVDPlayer sleeps until m_iSleepEndTime here before calling FlipPage.
-  // Video playback in asynchronous in OMXPlayer, so we don't want to do that here, as it prevents the video fifo from being kept full.
-  // So, we keep track of when FlipPage would have been called on DVDPlayer and return early if it is not time.
-  // m_iSleepEndTime == DVD_NOPTS_VALUE means we are not waiting to call FlipPage, otherwise it is the time we want to call FlipPage
-  if (m_iSleepEndTime == DVD_NOPTS_VALUE) {
-    m_iSleepEndTime = iCurrentClock + iSleepTime;
-  }
+  // we aim to submit subtitles 100ms early
+  const double preroll = DVD_MSEC_TO_TIME(100);
+  double media_pts = m_av_clock->OMXMediaTime(false);
 
-  if (!CThread::m_bStop && m_av_clock->GetAbsoluteClock(false) < m_iSleepEndTime + DVD_MSEC_TO_TIME(500))
+  if (m_nextOverlay != DVD_NOPTS_VALUE && media_pts + preroll <= m_nextOverlay)
     return;
 
-  int buffer = g_renderManager.WaitForBuffer(CThread::m_bStop, iSleepTime + DVD_MSEC_TO_TIME(500));
+  int buffer = g_renderManager.WaitForBuffer(CThread::m_bStop);
   if (buffer < 0)
     return;
 
-  double pts_media = m_av_clock->OMXMediaTime(false);
-  ProcessOverlays(pts_media);
+  double subtitle_pts = m_nextOverlay;
+  double time = subtitle_pts != DVD_NOPTS_VALUE ? subtitle_pts - media_pts : 0.0;
+
+  if (m_nextOverlay != DVD_NOPTS_VALUE)
+    media_pts = m_nextOverlay;
 
-  g_renderManager.FlipPage(CThread::m_bStop, m_iSleepEndTime / DVD_TIME_BASE, -1, FS_NONE);
+  m_nextOverlay = NextOverlay(media_pts);
 
-  m_iSleepEndTime = DVD_NOPTS_VALUE;
+  ProcessOverlays(media_pts);
 
-  //m_av_clock->WaitAbsoluteClock((iCurrentClock + iSleepTime));
+  time += m_av_clock->GetAbsoluteClock();
+  g_renderManager.FlipPage(CThread::m_bStop, time/DVD_TIME_BASE);
 }
 
 void OMXPlayerVideo::Process()
@@ -375,23 +337,7 @@ void OMXPlayerVideo::Process()
     else if (pMsg->IsType(CDVDMsg::GENERAL_RESYNC))
     {
       CDVDMsgGeneralResync* pMsgGeneralResync = (CDVDMsgGeneralResync*)pMsg;
-
-      if(pMsgGeneralResync->m_timestamp != DVD_NOPTS_VALUE)
-        pts = pMsgGeneralResync->m_timestamp;
-
-      double delay = m_FlipTimeStamp - m_av_clock->GetAbsoluteClock();
-      if( delay > frametime ) delay = frametime;
-      else if( delay < 0 )    delay = 0;
-
-      if(pMsgGeneralResync->m_clock)
-      {
-        CLog::Log(LOGDEBUG, "COMXPlayerVideo - CDVDMsg::GENERAL_RESYNC(%f, 1)", pts);
-        m_av_clock->Discontinuity(pts - delay);
-        //m_av_clock->OMXUpdateClock(pts - delay);
-      }
-      else
-        CLog::Log(LOGDEBUG, "COMXPlayerVideo - CDVDMsg::GENERAL_RESYNC(%f, 0)", pts);
-
+      CLog::Log(LOGDEBUG, "COMXPlayerVideo - CDVDMsg::GENERAL_RESYNC(%f, %d)", pts, pMsgGeneralResync->m_clock);
       pMsgGeneralResync->Release();
       continue;
     }
@@ -424,14 +370,14 @@ void OMXPlayerVideo::Process()
       m_av_clock->OMXReset(false);
       m_av_clock->UnLock();
       m_started = false;
-      m_iSleepEndTime = DVD_NOPTS_VALUE;
+      m_nextOverlay = DVD_NOPTS_VALUE;
     }
     else if (pMsg->IsType(CDVDMsg::GENERAL_FLUSH)) // private message sent by (COMXPlayerVideo::Flush())
     {
       CLog::Log(LOGDEBUG, "COMXPlayerVideo - CDVDMsg::GENERAL_FLUSH");
       m_stalled = true;
       m_started = false;
-      m_iSleepEndTime = DVD_NOPTS_VALUE;
+      m_nextOverlay = DVD_NOPTS_VALUE;
       m_av_clock->Lock();
       m_av_clock->OMXStop(false);
       m_omxVideo.Reset();
@@ -483,7 +429,7 @@ void OMXPlayerVideo::Process()
 
       #ifdef _DEBUG
       CLog::Log(LOGINFO, "Video: dts:%.0f pts:%.0f size:%d (s:%d f:%d d:%d l:%d) s:%d %d/%d late:%d\n", pPacket->dts, pPacket->pts, 
-          (int)pPacket->iSize, m_started, m_flush, bPacketDrop, m_stalled, m_speed, 0, 0, m_av_clock->OMXLateCount(1));
+          (int)pPacket->iSize, m_started, m_flush, bPacketDrop, m_stalled, m_speed, 0, 0, 0);
       #endif
       if (m_messageQueue.GetDataSize() == 0
       ||  m_speed < 0)
@@ -594,7 +540,7 @@ bool OMXPlayerVideo::OpenDecoder()
   m_av_clock->Lock();
   m_av_clock->OMXStop(false);
 
-  bool bVideoDecoderOpen = m_omxVideo.Open(m_hints, m_av_clock, m_Deinterlace, m_hdmi_clock_sync);
+  bool bVideoDecoderOpen = m_omxVideo.Open(m_hints, m_av_clock, CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode, m_hdmi_clock_sync);
   m_omxVideo.RegisterResolutionUpdateCallBack((void *)this, ResolutionUpdateCallBack);
 
   if(!bVideoDecoderOpen)
index f3cfc2e..1891716 100644 (file)
@@ -50,21 +50,17 @@ protected:
   bool                      m_open;
   CDVDStreamInfo            m_hints;
   double                    m_iCurrentPts;
-  double                    m_iSleepEndTime;
+  double                    m_nextOverlay;
   OMXClock                  *m_av_clock;
   COMXVideo                 m_omxVideo;
   float                     m_fFrameRate;
-  bool                      m_Deinterlace;
   bool                      m_hdmi_clock_sync;
   double                    m_iVideoDelay;
   int                       m_speed;
-  double                    m_FlipTimeStamp; // time stamp of last flippage. used to play at a forced framerate
-  int                       m_audio_count;
   bool                      m_stalled;
   bool                      m_started;
   bool                      m_flush;
   std::string               m_codecname;
-  unsigned int              m_autosync;
   double                    m_iSubtitleDelay;
   bool                      m_bRenderSubs;
   bool                      m_bAllowFullscreen;
@@ -82,9 +78,8 @@ protected:
 
   BitstreamStats m_videoStats;
 
-  DVDVideoPicture* m_pTempOverlayPicture;
-
   void ProcessOverlays(double pts);
+  double NextOverlay(double pts);
 
   virtual void OnStartup();
   virtual void OnExit();
@@ -109,7 +104,7 @@ public:
   bool OpenDecoder();
   int  GetDecoderBufferSize();
   int  GetDecoderFreeSpace();
-  double GetCurrentPTS() { return m_iCurrentPts; };
+  double GetCurrentPts() { return m_iCurrentPts; };
   double GetFPS() { return m_fFrameRate; };
   void  SubmitEOS();
   bool SubmittedEOS();
index 4443fae..6b5f743 100644 (file)
@@ -18,9 +18,9 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
 #include "system.h"
 #endif
 
 #endif
 #define CLASSNAME "COMXVideo"
 
-#if 0
-// TODO: These are Nvidia Tegra2 dependent, need to dynamiclly find the
-// right codec matched to video format.
-#define OMX_H264BASE_DECODER    "OMX.Nvidia.h264.decode"
-// OMX.Nvidia.h264ext.decode segfaults, not sure why.
-//#define OMX_H264MAIN_DECODER  "OMX.Nvidia.h264ext.decode"
-#define OMX_H264MAIN_DECODER    "OMX.Nvidia.h264.decode"
-#define OMX_H264HIGH_DECODER    "OMX.Nvidia.h264ext.decode"
-#define OMX_MPEG4_DECODER       "OMX.Nvidia.mp4.decode"
-#define OMX_MPEG4EXT_DECODER    "OMX.Nvidia.mp4ext.decode"
-#define OMX_MPEG2V_DECODER      "OMX.Nvidia.mpeg2v.decode"
-#define OMX_VC1_DECODER         "OMX.Nvidia.vc1.decode"
-#endif
-
 #define OMX_VIDEO_DECODER       "OMX.broadcom.video_decode"
 #define OMX_H264BASE_DECODER    OMX_VIDEO_DECODER
 #define OMX_H264MAIN_DECODER    OMX_VIDEO_DECODER
 COMXVideo::COMXVideo() : m_video_codec_name("")
 {
   m_is_open           = false;
-  m_Pause             = false;
   m_extradata         = NULL;
   m_extrasize         = 0;
   m_video_convert     = false;
   m_deinterlace       = false;
+  m_deinterlace_request = VS_DEINTERLACEMODE_OFF;
   m_hdmi_clock_sync   = false;
   m_drop_state        = false;
   m_decoded_width     = 0;
@@ -92,6 +78,8 @@ COMXVideo::COMXVideo() : m_video_codec_name("")
   m_res_callback      = NULL;
   m_res_ctx           = NULL;
   m_submitted_eos     = false;
+  m_settings_changed  = false;
+  m_transform         = OMX_DISPLAY_ROT0;
 }
 
 COMXVideo::~COMXVideo()
@@ -151,13 +139,191 @@ bool COMXVideo::NaluFormatStartCodes(enum CodecID codec, uint8_t *in_extradata,
   return false;    
 }
 
-bool COMXVideo::Open(CDVDStreamInfo &hints, OMXClock *clock, bool deinterlace, bool hdmi_clock_sync)
+bool COMXVideo::PortSettingsChanged()
+{
+  OMX_ERRORTYPE omx_err   = OMX_ErrorNone;
+
+  if (m_settings_changed)
+  {
+    m_omx_decoder.DisablePort(m_omx_decoder.GetOutputPort(), true);
+  }
+
+  OMX_PARAM_PORTDEFINITIONTYPE port_image;
+  OMX_INIT_STRUCTURE(port_image);
+  port_image.nPortIndex = m_omx_decoder.GetOutputPort();
+  omx_err = m_omx_decoder.GetParameter(OMX_IndexParamPortDefinition, &port_image);
+  if(omx_err != OMX_ErrorNone)
+  {
+    CLog::Log(LOGERROR, "%s::%s - error m_omx_decoder.GetParameter(OMX_IndexParamPortDefinition) omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+  }
+  // let OMXPlayerVideo know about resolution so it can inform RenderManager
+  if (m_res_callback)
+    m_res_callback(m_res_ctx, port_image.format.video.nFrameWidth, port_image.format.video.nFrameHeight);
+
+  if (m_settings_changed)
+  {
+    m_omx_decoder.EnablePort(m_omx_decoder.GetOutputPort(), true);
+    return true;
+  }
+
+  OMX_CONFIG_INTERLACETYPE interlace;
+  OMX_INIT_STRUCTURE(interlace);
+  interlace.nPortIndex = m_omx_decoder.GetOutputPort();
+  omx_err = m_omx_decoder.GetConfig(OMX_IndexConfigCommonInterlace, &interlace);
+
+  if(m_deinterlace_request == VS_DEINTERLACEMODE_FORCE)
+    m_deinterlace = true;
+  else if(m_deinterlace_request == VS_DEINTERLACEMODE_OFF)
+    m_deinterlace = false;
+  else
+    m_deinterlace = interlace.eMode != OMX_InterlaceProgressive;
+
+  if(!m_omx_render.Initialize("OMX.broadcom.video_render", OMX_IndexParamVideoInit))
+    return false;
+
+  m_omx_render.ResetEos();
+
+  CLog::Log(LOGDEBUG, "%s::%s - %dx%d@%.2f interlace:%d deinterlace:%d", CLASSNAME, __func__,
+      port_image.format.video.nFrameWidth, port_image.format.video.nFrameHeight,
+      port_image.format.video.xFramerate / (float)(1<<16), interlace.eMode, m_deinterlace);
+
+  if(!m_omx_sched.Initialize("OMX.broadcom.video_scheduler", OMX_IndexParamVideoInit))
+    return false;
+
+  if(m_deinterlace)
+  {
+    if(!m_omx_image_fx.Initialize("OMX.broadcom.image_fx", OMX_IndexParamImageInit))
+      return false;
+  }
+
+  OMX_CONFIG_DISPLAYREGIONTYPE configDisplay;
+  OMX_INIT_STRUCTURE(configDisplay);
+  configDisplay.nPortIndex = m_omx_render.GetInputPort();
+
+  configDisplay.set = OMX_DISPLAY_SET_TRANSFORM;
+  configDisplay.transform = m_transform;
+  omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
+  if(omx_err != OMX_ErrorNone)
+  {
+    CLog::Log(LOGWARNING, "%s::%s - could not set transform : %d", CLASSNAME, __func__, m_transform);
+    return false;
+  }
+
+  if(m_hdmi_clock_sync)
+  {
+    OMX_CONFIG_LATENCYTARGETTYPE latencyTarget;
+    OMX_INIT_STRUCTURE(latencyTarget);
+    latencyTarget.nPortIndex = m_omx_render.GetInputPort();
+    latencyTarget.bEnabled = OMX_TRUE;
+    latencyTarget.nFilter = 2;
+    latencyTarget.nTarget = 4000;
+    latencyTarget.nShift = 3;
+    latencyTarget.nSpeedFactor = -135;
+    latencyTarget.nInterFactor = 500;
+    latencyTarget.nAdjCap = 20;
+
+    omx_err = m_omx_render.SetConfig(OMX_IndexConfigLatencyTarget, &latencyTarget);
+    if (omx_err != OMX_ErrorNone)
+    {
+      CLog::Log(LOGERROR, "%s::%s - OMX_IndexConfigLatencyTarget omx_err(0%08x)", CLASSNAME, __func__, omx_err);
+      return false;
+    }
+  }
+
+  if(m_deinterlace)
+  {
+    OMX_CONFIG_IMAGEFILTERPARAMSTYPE image_filter;
+    OMX_INIT_STRUCTURE(image_filter);
+
+    image_filter.nPortIndex = m_omx_image_fx.GetOutputPort();
+    image_filter.nNumParams = 1;
+    image_filter.nParams[0] = 3;
+    image_filter.eImageFilter = OMX_ImageFilterDeInterlaceAdvanced;
+
+    omx_err = m_omx_image_fx.SetConfig(OMX_IndexConfigCommonImageFilterParameters, &image_filter);
+    if(omx_err != OMX_ErrorNone)
+    {
+      CLog::Log(LOGERROR, "%s::%s - OMX_IndexConfigCommonImageFilterParameters omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+      return false;
+    }
+  }
+
+  if(m_deinterlace)
+  {
+    m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_image_fx, m_omx_image_fx.GetInputPort());
+    m_omx_tunnel_image_fx.Initialize(&m_omx_image_fx, m_omx_image_fx.GetOutputPort(), &m_omx_sched, m_omx_sched.GetInputPort());
+  }
+  else
+  {
+    m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_sched, m_omx_sched.GetInputPort());
+  }
+  m_omx_tunnel_sched.Initialize(&m_omx_sched, m_omx_sched.GetOutputPort(), &m_omx_render, m_omx_render.GetInputPort());
+
+  m_omx_tunnel_clock.Initialize(m_omx_clock, m_omx_clock->GetInputPort()  + 1, &m_omx_sched, m_omx_sched.GetOutputPort()  + 1);
+
+  omx_err = m_omx_tunnel_clock.Establish(false);
+  if(omx_err != OMX_ErrorNone)
+  {
+    CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_clock.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+    return false;
+  }
+
+  omx_err = m_omx_tunnel_decoder.Establish(false);
+  if(omx_err != OMX_ErrorNone)
+  {
+    CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_decoder.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+    return false;
+  }
+
+  if(m_deinterlace)
+  {
+    omx_err = m_omx_tunnel_image_fx.Establish(false);
+    if(omx_err != OMX_ErrorNone)
+    {
+      CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_image_fx.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+      return false;
+    }
+
+    omx_err = m_omx_image_fx.SetStateForComponent(OMX_StateExecuting);
+    if (omx_err != OMX_ErrorNone)
+    {
+      CLog::Log(LOGERROR, "%s::%s - m_omx_image_fx.SetStateForComponent omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+      return false;
+    }
+  }
+
+  omx_err = m_omx_tunnel_sched.Establish(false);
+  if(omx_err != OMX_ErrorNone)
+  {
+    CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_sched.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+    return false;
+  }
+
+  omx_err = m_omx_sched.SetStateForComponent(OMX_StateExecuting);
+  if (omx_err != OMX_ErrorNone)
+  {
+    CLog::Log(LOGERROR, "%s::%s - m_omx_sched.SetStateForComponent omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+    return false;
+  }
+
+  omx_err = m_omx_render.SetStateForComponent(OMX_StateExecuting);
+  if (omx_err != OMX_ErrorNone)
+  {
+    CLog::Log(LOGERROR, "%s::%s - m_omx_render.SetStateForComponent omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
+    return false;
+  }
+
+  m_settings_changed = true;
+  return true;
+}
+
+bool COMXVideo::Open(CDVDStreamInfo &hints, OMXClock *clock, EDEINTERLACEMODE deinterlace, bool hdmi_clock_sync)
 {
   bool vflip = false;
   Close();
-
   OMX_ERRORTYPE omx_err   = OMX_ErrorNone;
   std::string decoder_name;
+  m_settings_changed = false;
 
   m_res_ctx           = NULL;
   m_res_callback      = NULL;
@@ -219,24 +385,6 @@ bool COMXVideo::Open(CDVDStreamInfo &hints, OMXClock *clock, bool deinterlace, b
           m_video_codec_name = "omx-h264";
           break;
       }
-
-      /* check interlaced */
-      if(m_extrasize > 9 && m_extradata[0] == 1)
-      {
-        CBitstreamConverter converter;
-        converter.Open(hints.codec, (uint8_t *)hints.extradata, hints.extrasize, true);
-
-        int32_t  max_ref_frames = 0;
-        uint8_t  *spc = m_extradata + 6;
-        uint32_t sps_size = BS_RB16(spc);
-        bool     interlaced = true;
-        if (sps_size)
-          converter.parseh264_sps(spc+3, sps_size-1, &interlaced, &max_ref_frames);
-        if(!interlaced && deinterlace)
-          deinterlace = false;
-
-        converter.Close();
-      }
     }
     break;
     case CODEC_ID_MPEG4:
@@ -304,67 +452,14 @@ bool COMXVideo::Open(CDVDStreamInfo &hints, OMXClock *clock, bool deinterlace, b
       m_video_codec_name = "omx-vc1";
       break;
     default:
+      CLog::Log(LOGERROR, "COMXVideo::Open : Video codec unknown: %x", hints.codec);
       return false;
     break;
   }
+  m_deinterlace_request = deinterlace;
 
-  /* enable deintelace on SD and 1080i */
-  if(m_decoded_width <= 720 && m_decoded_height <=576 && deinterlace)
-    m_deinterlace = deinterlace;
-  else if(m_decoded_width >= 1920 && m_decoded_height >= 540 && deinterlace)
-    m_deinterlace = deinterlace;
-
-  if(m_deinterlace)
-    CLog::Log(LOGDEBUG, "COMXVideo::Open : enable deinterlace\n");
-
-  std::string componentName = decoder_name;
-  if(!m_omx_decoder.Initialize((const std::string)componentName, OMX_IndexParamVideoInit))
-    return false;
-
-  componentName = "OMX.broadcom.video_render";
-  if(!m_omx_render.Initialize((const std::string)componentName, OMX_IndexParamVideoInit))
-    return false;
-
-  m_omx_render.ResetEos();
-
-  componentName = "OMX.broadcom.video_scheduler";
-  if(!m_omx_sched.Initialize((const std::string)componentName, OMX_IndexParamVideoInit))
-    return false;
-
-  if(m_deinterlace)
-  {
-    componentName = "OMX.broadcom.image_fx";
-    if(!m_omx_image_fx.Initialize((const std::string)componentName, OMX_IndexParamImageInit))
-      return false;
-  }
-
-  OMX_VIDEO_PARAM_PORTFORMATTYPE formatType;
-  /*
-  OMX_INIT_STRUCTURE(formatType);
-  formatType.nPortIndex = m_omx_decoder.GetInputPort();
-  OMX_U32 nIndex = 1;
-  bool bFound = false;
-
-  omx_err = OMX_ErrorNone;
-  do
-  {
-    formatType.nIndex = nIndex;
-    omx_err = m_omx_decoder.GetParameter(OMX_IndexParamVideoPortFormat, &formatType);
-    if(formatType.eCompressionFormat == m_codingType)
-    {
-      bFound = true;
-      break;
-    }
-    nIndex++;
-  }
-  while(omx_err == OMX_ErrorNone);
-
-  if(!bFound)
-  {
-    CLog::Log(LOGINFO, "COMXVideo::Open coding : %s not supported\n", m_video_codec_name.c_str());
+  if(!m_omx_decoder.Initialize(decoder_name, OMX_IndexParamVideoInit))
     return false;
-  }
-  */
 
   if(clock == NULL)
     return false;
@@ -379,26 +474,6 @@ bool COMXVideo::Open(CDVDStreamInfo &hints, OMXClock *clock, bool deinterlace, b
     return false;
   }
 
-  if(m_deinterlace)
-  {
-    m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_image_fx, m_omx_image_fx.GetInputPort());
-    m_omx_tunnel_image_fx.Initialize(&m_omx_image_fx, m_omx_image_fx.GetOutputPort(), &m_omx_sched, m_omx_sched.GetInputPort());
-  }
-  else
-  {
-    m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_sched, m_omx_sched.GetInputPort());
-  }
-  m_omx_tunnel_sched.Initialize(&m_omx_sched, m_omx_sched.GetOutputPort(), &m_omx_render, m_omx_render.GetInputPort());
-
-  m_omx_tunnel_clock.Initialize(m_omx_clock, m_omx_clock->GetInputPort()  + 1, &m_omx_sched, m_omx_sched.GetOutputPort()  + 1);
-
-  omx_err = m_omx_tunnel_clock.Establish(false);
-  if(omx_err != OMX_ErrorNone)
-  {
-    CLog::Log(LOGERROR, "COMXVideo::Open m_omx_tunnel_clock.Establish\n");
-    return false;
-  }
-
   omx_err = m_omx_decoder.SetStateForComponent(OMX_StateIdle);
   if (omx_err != OMX_ErrorNone)
   {
@@ -406,6 +481,7 @@ bool COMXVideo::Open(CDVDStreamInfo &hints, OMXClock *clock, bool deinterlace, b
     return false;
   }
 
+  OMX_VIDEO_PARAM_PORTFORMATTYPE formatType;
   OMX_INIT_STRUCTURE(formatType);
   formatType.nPortIndex = m_omx_decoder.GetInputPort();
   formatType.eCompressionFormat = m_codingType;
@@ -461,7 +537,7 @@ bool COMXVideo::Open(CDVDStreamInfo &hints, OMXClock *clock, bool deinterlace, b
     return false;
   }
 
-  if (m_deinterlace)
+  if (m_deinterlace_request != VS_DEINTERLACEMODE_OFF)
   {
     // the deinterlace component requires 3 additional video buffers in addition to the DPB (this is normally 2).
     OMX_PARAM_U32TYPE extra_buffers;
@@ -476,6 +552,7 @@ bool COMXVideo::Open(CDVDStreamInfo &hints, OMXClock *clock, bool deinterlace, b
     }
   }
 
+
   // broadcom omx entension:
   // When enabled, the timestamp fifo mode will change the way incoming timestamps are associated with output images.
   // In this mode the incoming timestamps get used without re-ordering on output images.
@@ -508,26 +585,6 @@ bool COMXVideo::Open(CDVDStreamInfo &hints, OMXClock *clock, bool deinterlace, b
     }
   }
 
-  if(m_hdmi_clock_sync)
-  {
-    OMX_CONFIG_LATENCYTARGETTYPE latencyTarget;
-    OMX_INIT_STRUCTURE(latencyTarget);
-    latencyTarget.nPortIndex = m_omx_render.GetInputPort();
-    latencyTarget.bEnabled = OMX_TRUE;
-    latencyTarget.nFilter = 2;
-    latencyTarget.nTarget = 4000;
-    latencyTarget.nShift = 3;
-    latencyTarget.nSpeedFactor = -135;
-    latencyTarget.nInterFactor = 500;
-    latencyTarget.nAdjCap = 20;
-
-    omx_err = m_omx_render.SetConfig(OMX_IndexConfigLatencyTarget, &latencyTarget);
-    if (omx_err != OMX_ErrorNone)
-    {
-      CLog::Log(LOGERROR, "COMXVideo::Open OMX_IndexConfigLatencyTarget error (0%08x)\n", omx_err);
-      return false;
-    }
-  }
 
   // Alloc buffers for the omx intput port.
   omx_err = m_omx_decoder.AllocInputBuffers();
@@ -537,13 +594,6 @@ bool COMXVideo::Open(CDVDStreamInfo &hints, OMXClock *clock, bool deinterlace, b
     return false;
   }
 
-  omx_err = m_omx_tunnel_decoder.Establish(false);
-  if(omx_err != OMX_ErrorNone)
-  {
-    CLog::Log(LOGERROR, "COMXVideo::Open m_omx_tunnel_decoder.Establish\n");
-    return false;
-  }
-
   omx_err = m_omx_decoder.SetStateForComponent(OMX_StateExecuting);
   if (omx_err != OMX_ErrorNone)
   {
@@ -551,152 +601,29 @@ bool COMXVideo::Open(CDVDStreamInfo &hints, OMXClock *clock, bool deinterlace, b
     return false;
   }
 
-  if(m_deinterlace)
-  {
-    OMX_CONFIG_IMAGEFILTERPARAMSTYPE image_filter;
-    OMX_INIT_STRUCTURE(image_filter);
-
-    image_filter.nPortIndex = m_omx_image_fx.GetOutputPort();
-    image_filter.nNumParams = 1;
-    image_filter.nParams[0] = 3;
-    image_filter.eImageFilter = OMX_ImageFilterDeInterlaceAdvanced;
-
-    omx_err = m_omx_image_fx.SetConfig(OMX_IndexConfigCommonImageFilterParameters, &image_filter);
-    if(omx_err != OMX_ErrorNone)
-    {
-      CLog::Log(LOGERROR, "COMXVideo::Open error OMX_IndexConfigCommonImageFilterParameters omx_err(0x%08x)\n", omx_err);
-      return false;
-    }
-
-    omx_err = m_omx_tunnel_image_fx.Establish(false);
-    if(omx_err != OMX_ErrorNone)
-    {
-      CLog::Log(LOGERROR, "COMXVideo::Open m_omx_tunnel_image_fx.Establish\n");
-      return false;
-    }
-
-    omx_err = m_omx_image_fx.SetStateForComponent(OMX_StateExecuting);
-    if (omx_err != OMX_ErrorNone)
-    {
-      CLog::Log(LOGERROR, "COMXVideo::Open error m_omx_image_fx.SetStateForComponent\n");
-      return false;
-    }
-
-    m_omx_image_fx.DisablePort(m_omx_image_fx.GetInputPort(), false);
-    m_omx_image_fx.DisablePort(m_omx_image_fx.GetOutputPort(), false);
-  }
-
-  omx_err = m_omx_tunnel_sched.Establish(false);
-  if(omx_err != OMX_ErrorNone)
-  {
-    CLog::Log(LOGERROR, "COMXVideo::Open m_omx_tunnel_sched.Establish\n");
-    return false;
-  }
-
-  omx_err = m_omx_sched.SetStateForComponent(OMX_StateExecuting);
-  if (omx_err != OMX_ErrorNone)
-  {
-    CLog::Log(LOGERROR, "COMXVideo::Open error m_omx_sched.SetStateForComponent\n");
-    return false;
-  }
-
-  omx_err = m_omx_render.SetStateForComponent(OMX_StateExecuting);
-  if (omx_err != OMX_ErrorNone)
-  {
-    CLog::Log(LOGERROR, "COMXVideo::Open error m_omx_render.SetStateForComponent\n");
-    return false;
-  }
-
   if(!SendDecoderConfig())
     return false;
 
   m_is_open           = true;
   m_drop_state        = false;
 
-  OMX_CONFIG_DISPLAYREGIONTYPE configDisplay;
-  OMX_INIT_STRUCTURE(configDisplay);
-  configDisplay.nPortIndex = m_omx_render.GetInputPort();
-
-  configDisplay.set = OMX_DISPLAY_SET_TRANSFORM;
-
   switch(hints.orientation)
   {
     case 90:
-      configDisplay.transform = OMX_DISPLAY_ROT90;
+      m_transform = OMX_DISPLAY_ROT90;
       break;
     case 180:
-      configDisplay.transform = OMX_DISPLAY_ROT180;
+      m_transform = OMX_DISPLAY_ROT180;
       break;
     case 270:
-      configDisplay.transform = OMX_DISPLAY_ROT270;
+      m_transform = OMX_DISPLAY_ROT270;
       break;
     default:
-      configDisplay.transform = OMX_DISPLAY_ROT0;
+      m_transform = OMX_DISPLAY_ROT0;
       break;
   }
   if (vflip)
-      configDisplay.transform = OMX_DISPLAY_MIRROR_ROT180;
-
-  omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
-  if(omx_err != OMX_ErrorNone)
-  {
-    CLog::Log(LOGWARNING, "COMXVideo::Open could not set orientation : %d\n", hints.orientation);
-  }
-
-  /*
-  configDisplay.set     = OMX_DISPLAY_SET_LAYER;
-  configDisplay.layer   = 2;
-
-  omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
-  if(omx_err != OMX_ErrorNone)
-    return false;
-
-  configDisplay.set     = OMX_DISPLAY_SET_DEST_RECT;
-  configDisplay.dest_rect.x_offset  = 100;
-  configDisplay.dest_rect.y_offset  = 100;
-  configDisplay.dest_rect.width     = 640;
-  configDisplay.dest_rect.height    = 480;
-    
-  omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
-  if(omx_err != OMX_ErrorNone)
-    return false;
-
-  configDisplay.set     = OMX_DISPLAY_SET_TRANSFORM;
-  configDisplay.transform = OMX_DISPLAY_ROT180;
-    
-  omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
-  if(omx_err != OMX_ErrorNone)
-    return false;
-
-  configDisplay.set     = OMX_DISPLAY_SET_FULLSCREEN;
-  configDisplay.fullscreen = OMX_FALSE;
-    
-  omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
-  if(omx_err != OMX_ErrorNone)
-    return false;
-
-  configDisplay.set     = OMX_DISPLAY_SET_MODE;
-  configDisplay.mode    = OMX_DISPLAY_MODE_FILL; //OMX_DISPLAY_MODE_LETTERBOX;
-    
-  omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
-  if(omx_err != OMX_ErrorNone)
-    return false;
-
-  configDisplay.set     = OMX_DISPLAY_SET_LAYER;
-  configDisplay.layer   = 1;
-
-  omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
-  if(omx_err != OMX_ErrorNone)
-    return false;
-
-  configDisplay.set     = OMX_DISPLAY_SET_ALPHA;
-  configDisplay.alpha   = OMX_FALSE;
-    
-  omx_err = m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
-  if(omx_err != OMX_ErrorNone)
-    return false;
-
-  */
+      m_transform = OMX_DISPLAY_MIRROR_ROT180;
 
   if(m_omx_decoder.BadState())
     return false;
@@ -704,7 +631,7 @@ bool COMXVideo::Open(CDVDStreamInfo &hints, OMXClock *clock, bool deinterlace, b
   CLog::Log(LOGDEBUG,
     "%s::%s - decoder_component(0x%p), input_port(0x%x), output_port(0x%x) deinterlace %d hdmiclocksync %d\n",
     CLASSNAME, __func__, m_omx_decoder.GetComponent(), m_omx_decoder.GetInputPort(), m_omx_decoder.GetOutputPort(),
-    m_deinterlace, m_hdmi_clock_sync);
+    m_deinterlace_request, m_hdmi_clock_sync);
 
   // start from assuming all recent frames had valid pts
   m_history_valid_pts = ~0;
@@ -712,6 +639,7 @@ bool COMXVideo::Open(CDVDStreamInfo &hints, OMXClock *clock, bool deinterlace, b
   return true;
 }
 
+
 void COMXVideo::Close()
 {
   m_omx_tunnel_decoder.Flush();
@@ -795,16 +723,6 @@ int COMXVideo::Decode(uint8_t *pData, int iSize, double dts, double pts)
         return false;
       }
 
-      /*
-      CLog::Log(DEBUG, "COMXVideo::Video VDec : pts %lld omx_buffer 0x%08x buffer 0x%08x number %d\n", 
-          pts, omx_buffer, omx_buffer->pBuffer, (int)omx_buffer->pAppPrivate);
-      if(pts == DVD_NOPTS_VALUE)
-      {
-        CLog::Log(LOGDEBUG, "VDec : pts %f omx_buffer 0x%08x buffer 0x%08x number %d\n", 
-          (float)pts / AV_TIME_BASE, (int)omx_buffer, (int)omx_buffer->pBuffer, (int)omx_buffer->pAppPrivate);
-      }
-      */
-
       omx_buffer->nFlags = 0;
       omx_buffer->nOffset = 0;
       // some packed bitstream AVI files set almost all pts values to DVD_NOPTS_VALUE, but have a scattering of real pts values.
@@ -852,7 +770,7 @@ int COMXVideo::Decode(uint8_t *pData, int iSize, double dts, double pts)
         }
         if(nRetry == 5)
         {
-          CLog::Log(LOGERROR, "%s::%s - OMX_EmptyThisBuffer() finaly failed\n", CLASSNAME, __func__);
+          CLog::Log(LOGERROR, "%s::%s - OMX_EmptyThisBuffer() finally failed\n", CLASSNAME, __func__);
           return false;
         }
       }
@@ -860,74 +778,13 @@ int COMXVideo::Decode(uint8_t *pData, int iSize, double dts, double pts)
       omx_err = m_omx_decoder.WaitForEvent(OMX_EventPortSettingsChanged, 0);
       if (omx_err == OMX_ErrorNone)
       {
-        OMX_PARAM_PORTDEFINITIONTYPE port_image;
-        OMX_INIT_STRUCTURE(port_image);
-        port_image.nPortIndex = m_omx_decoder.GetOutputPort();
-        omx_err = m_omx_decoder.GetParameter(OMX_IndexParamPortDefinition, &port_image);
-        if(omx_err != OMX_ErrorNone)
-        {
-          CLog::Log(LOGERROR, "%s::%s - error m_omx_decoder.GetParameter(OMX_IndexParamPortDefinition) omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
-        }
-        // let OMXPlayerVideo know about resolution so it can inform RenderManager
-        if (m_res_callback)
-          m_res_callback(m_res_ctx, port_image.format.video.nFrameWidth, port_image.format.video.nFrameHeight);
-
-        m_omx_decoder.DisablePort(m_omx_decoder.GetOutputPort(), true);
-        m_omx_sched.DisablePort(m_omx_sched.GetInputPort(), true);
-
-        OMX_CONFIG_INTERLACETYPE interlace;
-        OMX_INIT_STRUCTURE(interlace);
-        interlace.nPortIndex = m_omx_decoder.GetOutputPort();
-        omx_err = m_omx_decoder.GetConfig(OMX_IndexConfigCommonInterlace, &interlace);
-        if(omx_err != OMX_ErrorNone)
-        {
-          CLog::Log(LOGERROR, "%s::%s - error m_omx_decoder.GetConfig(OMX_IndexConfigCommonInterlace) omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
-        }
-
-        if (m_deinterlace)
-        {
-          m_omx_image_fx.DisablePort(m_omx_image_fx.GetInputPort(), true);
-          port_image.nPortIndex = m_omx_image_fx.GetInputPort();
-          omx_err = m_omx_image_fx.SetParameter(OMX_IndexParamPortDefinition, &port_image);
-          if(omx_err != OMX_ErrorNone)
-          {
-            CLog::Log(LOGERROR, "%s::%s - error m_omx_image_fx.SetParameter(OMX_IndexParamPortDefinition) omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
-          }
-          omx_err = m_omx_image_fx.WaitForEvent(OMX_EventPortSettingsChanged);
-          if(omx_err != OMX_ErrorNone)
-          {
-             CLog::Log(LOGERROR, "%s::%s - error m_omx_image_fx.WaitForEvent(OMX_EventPortSettingsChanged) omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
-          }
-          port_image.nPortIndex = m_omx_image_fx.GetOutputPort();
-          omx_err = m_omx_image_fx.GetParameter(OMX_IndexParamPortDefinition, &port_image);
-          if(omx_err != OMX_ErrorNone)
-          {
-            CLog::Log(LOGERROR, "%s::%s - error m_omx_image_fx.GetParameter(OMX_IndexParamPortDefinition) omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
-          }
-          m_omx_image_fx.EnablePort(m_omx_image_fx.GetInputPort(), true);
-
-          m_omx_image_fx.DisablePort(m_omx_image_fx.GetOutputPort(), true);
-        }
-        port_image.nPortIndex = m_omx_sched.GetInputPort();
-        omx_err = m_omx_sched.SetParameter(OMX_IndexParamPortDefinition, &port_image);
-        if(omx_err != OMX_ErrorNone)
-        {
-          CLog::Log(LOGERROR, "%s::%s - error m_omx_sched.SetParameter(OMX_IndexParamPortDefinition) omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
-        }
-        omx_err = m_omx_sched.WaitForEvent(OMX_EventPortSettingsChanged);
-        if(omx_err != OMX_ErrorNone)
+        if(!PortSettingsChanged())
         {
-           CLog::Log(LOGERROR, "%s::%s - error m_omx_sched.WaitForEvent(OMX_EventPortSettingsChanged) omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
-        }
-        if (m_deinterlace)
-        {
-          m_omx_image_fx.EnablePort(m_omx_image_fx.GetOutputPort(), true);
+          CLog::Log(LOGERROR, "%s::%s - error PortSettingsChanged omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
+          return false;
         }
-        m_omx_decoder.EnablePort(m_omx_decoder.GetOutputPort(), true);
-        m_omx_sched.EnablePort(m_omx_sched.GetInputPort(), true);
       }
     }
-
     return true;
 
   }
@@ -942,50 +799,6 @@ void COMXVideo::Reset(void)
 
   m_omx_decoder.FlushInput();
   m_omx_tunnel_decoder.Flush();
-
-  /*
-  OMX_ERRORTYPE omx_err;
-  OMX_CONFIG_BOOLEANTYPE configBool;
-  OMX_INIT_STRUCTURE(configBool);
-  configBool.bEnabled = OMX_TRUE;
-
-  omx_err = m_omx_decoder.SetConfig(OMX_IndexConfigRefreshCodec, &configBool);
-  if (omx_err != OMX_ErrorNone)
-    CLog::Log(LOGERROR, "%s::%s - error reopen codec omx_err(0x%08x)\n", CLASSNAME, __func__, omx_err);
-
-  SendDecoderConfig();
-
-  */
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-bool COMXVideo::Pause()
-{
-  if(m_omx_render.GetComponent() == NULL)
-    return false;
-
-  if(m_Pause) return true;
-  m_Pause = true;
-
-  m_omx_sched.SetStateForComponent(OMX_StatePause);
-  m_omx_render.SetStateForComponent(OMX_StatePause);
-
-  return true;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-bool COMXVideo::Resume()
-{
-  if(m_omx_render.GetComponent() == NULL)
-    return false;
-
-  if(!m_Pause) return true;
-  m_Pause = false;
-
-  m_omx_sched.SetStateForComponent(OMX_StateExecuting);
-  m_omx_render.SetStateForComponent(OMX_StateExecuting);
-
-  return true;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
@@ -995,20 +808,6 @@ void COMXVideo::SetVideoRect(const CRect& SrcRect, const CRect& DestRect)
     return;
 
   OMX_CONFIG_DISPLAYREGIONTYPE configDisplay;
-  float sx1 = SrcRect.x1, sy1 = SrcRect.y1, sx2 = SrcRect.x2, sy2 = SrcRect.y2;
-  float dx1 = DestRect.x1, dy1 = DestRect.y1, dx2 = DestRect.x2, dy2 = DestRect.y2;
-  float sw = SrcRect.Width() / DestRect.Width();
-  float sh = SrcRect.Height() / DestRect.Height();
-
-  // doesn't like negative coordinates on dest_rect. So adjust by increasing src_rect
-  if (dx1 < 0.0f) {
-    sx1 -= dx1 * sw;
-    dx1 = 0;
-  }
-  if (dy1 < 0.0f) {
-    sy1 -= dy1 * sh;
-    dy1 = 0;
-  }
 
   OMX_INIT_STRUCTURE(configDisplay);
   configDisplay.nPortIndex = m_omx_render.GetInputPort();
@@ -1016,15 +815,15 @@ void COMXVideo::SetVideoRect(const CRect& SrcRect, const CRect& DestRect)
   configDisplay.noaspect   = OMX_TRUE;
 
   configDisplay.set                 = (OMX_DISPLAYSETTYPE)(OMX_DISPLAY_SET_DEST_RECT|OMX_DISPLAY_SET_SRC_RECT|OMX_DISPLAY_SET_FULLSCREEN|OMX_DISPLAY_SET_NOASPECT);
-  configDisplay.dest_rect.x_offset  = (int)(dx1+0.5f);
-  configDisplay.dest_rect.y_offset  = (int)(dy1+0.5f);
-  configDisplay.dest_rect.width     = (int)(dx2-dx1+0.5f);
-  configDisplay.dest_rect.height    = (int)(dy2-dy1+0.5f);
-
-  configDisplay.src_rect.x_offset   = (int)(sx1+0.5f);
-  configDisplay.src_rect.y_offset   = (int)(sy1+0.5f);
-  configDisplay.src_rect.width      = (int)(sx2-sx1+0.5f);
-  configDisplay.src_rect.height     = (int)(sy2-sy1+0.5f);
+  configDisplay.dest_rect.x_offset  = (int)(DestRect.x1+0.5f);
+  configDisplay.dest_rect.y_offset  = (int)(DestRect.y1+0.5f);
+  configDisplay.dest_rect.width     = (int)(DestRect.Width()+0.5f);
+  configDisplay.dest_rect.height    = (int)(DestRect.Height()+0.5f);
+
+  configDisplay.src_rect.x_offset   = (int)(SrcRect.x1+0.5f);
+  configDisplay.src_rect.y_offset   = (int)(SrcRect.y1+0.5f);
+  configDisplay.src_rect.width      = (int)(SrcRect.Width()+0.5f);
+  configDisplay.src_rect.height     = (int)(SrcRect.Height()+0.5f);
 
   m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
 
index 19d7206..fe9f174 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "guilib/Geometry.h"
 #include "DVDDemuxers/DVDDemux.h"
+#include "xbmc/settings/VideoSettings.h"
 #include <string>
 
 #define VIDEO_BUFFERS 60
@@ -46,7 +47,8 @@ public:
 
   // Required overrides
   bool SendDecoderConfig();
-  bool Open(CDVDStreamInfo &hints, OMXClock *clock, bool deinterlace = false, bool hdmi_clock_sync = false);
+  bool Open(CDVDStreamInfo &hints, OMXClock *clock, EDEINTERLACEMODE deinterlace = VS_DEINTERLACEMODE_OFF, bool hdmi_clock_sync = false);
+  bool PortSettingsChanged();
   void RegisterResolutionUpdateCallBack(void *ctx, ResolutionUpdateCallBackFn callback) { m_res_ctx = ctx; m_res_callback = callback; }
   void Close(void);
   unsigned int GetFreeSpace();
@@ -54,8 +56,6 @@ public:
   int  Decode(uint8_t *pData, int iSize, double dts, double pts);
   void Reset(void);
   void SetDropState(bool bDrop);
-  bool Pause();
-  bool Resume();
   std::string GetDecoderName() { return m_video_codec_name; };
   void SetVideoRect(const CRect& SrcRect, const CRect& DestRect);
   int GetInputBufferSize();
@@ -84,8 +84,6 @@ protected:
   COMXCoreTunel     m_omx_tunnel_image_fx;
   bool              m_is_open;
 
-  bool              m_Pause;
-
   uint8_t           *m_extradata;
   int               m_extrasize;
 
@@ -93,12 +91,15 @@ protected:
   std::string       m_video_codec_name;
 
   bool              m_deinterlace;
+  EDEINTERLACEMODE  m_deinterlace_request;
   bool              m_hdmi_clock_sync;
   uint32_t          m_history_valid_pts;
   ResolutionUpdateCallBackFn m_res_callback;
   void              *m_res_ctx;
   bool              m_submitted_eos;
-  bool NaluFormatStartCodes(enum CodecID codec, uint8_t *in_extradata, int in_extrasize);
+  OMX_DISPLAYTRANSFORMTYPE m_transform;
+  bool              m_settings_changed;
+  static bool NaluFormatStartCodes(enum CodecID codec, uint8_t *in_extradata, int in_extrasize);
 };
 
 #endif
index 1795fe5..cbeda34 100644 (file)
@@ -22,6 +22,7 @@
 #include "utils/URIUtils.h"
 #include "filesystem/File.h"
 
+
 ASAPCodec::ASAPCodec()
 {
   m_CodecName = "asap";
@@ -38,9 +39,7 @@ bool ASAPCodec::Init(const CStdString &strFile, unsigned int filecache)
 
   CStdString strFileToLoad = strFile;
   int song = -1;
-  CStdString strExtension = URIUtils::GetExtension(strFile);
-  strExtension.MakeLower();
-  if (strExtension == ".asapstream")
+  if (URIUtils::HasExtension(strFile, ".asapstream"))
   {
     CStdString strFileName = URIUtils::GetFileName(strFile);
     int iStart = strFileName.ReverseFind('-') + 1;
@@ -96,3 +95,4 @@ bool ASAPCodec::IsSupportedFormat(const CStdString &strExt)
     || ext == "tmc" || ext == "tm8" || ext == "tm2"
     || ext == "cms" || ext == "cm3" || ext == "dlt";
 }
+
index a20e7fc..eb287d6 100644 (file)
@@ -49,9 +49,7 @@ bool NSFCodec::Init(const CStdString &strFile, unsigned int filecache)
 
   CStdString strFileToLoad = strFile;
   m_iTrack = 0;
-  CStdString strExtension = URIUtils::GetExtension(strFile);
-  strExtension.MakeLower();
-  if (strExtension==".nsfstream")
+  if (URIUtils::HasExtension(strFile, ".nsfstream"))
   {
     //  Extract the track to play
     CStdString strFileName=URIUtils::GetFileName(strFile);
index 9754c47..3973c53 100644 (file)
@@ -55,10 +55,8 @@ bool OGGCodec::Init(const CStdString &strFile1, unsigned int filecache)
 
   m_CurrentStream=0;
 
-  CStdString strExtension = URIUtils::GetExtension(strFile);
-
   //  A bitstream inside a ogg file?
-  if (strExtension==".oggstream")
+  if (URIUtils::HasExtension(strFile, ".oggstream"))
   {
     //  Extract the bitstream to play
     CStdString strFileName=URIUtils::GetFileName(strFile);
index d5b4177..c290af5 100644 (file)
@@ -47,9 +47,7 @@ bool SIDCodec::Init(const CStdString &strFile, unsigned int filecache)
 
   CStdString strFileToLoad = strFile;
   m_iTrack = 0;
-  CStdString strExtension = URIUtils::GetExtension(strFile);
-  strExtension.MakeLower();
-  if (strExtension==".sidstream")
+  if (URIUtils::HasExtension(strFile, ".sidstream"))
   {
     //  Extract the track to play
     CStdString strFileName=URIUtils::GetFileName(strFile);
index 056a76f..7b5f177 100644 (file)
@@ -27,7 +27,7 @@
 #include "DynamicDll.h"
 #include "Util.h"
 #include "utils/log.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "cores/DllLoader/Win32DllLoader.h"
 #endif
 
@@ -44,7 +44,7 @@ SPCCodec::SPCCodec()
   m_dll.EmuAPU = NULL;
   m_dll.LoadSPCFile = NULL;
   m_dll.SeekAPU = NULL;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   m_dll.ResetAPU = NULL;
   m_dll.InitAPU = NULL;
 #endif
@@ -63,7 +63,7 @@ bool SPCCodec::Init(const CStdString &strFile, unsigned int filecache)
   // coping DLL_PATH_SPC_CODEC into special://temp and using a unique name. Then
   // loading this unique named SNESAPU as the library.
   // This forces the shared lib loader to load a per-instance copy of SNESAPU.
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   m_loader_name = CUtil::GetNextFilename("special://temp/SNESAPU-%03d.so", 999);
   XFILE::CFile::Cache(DLL_PATH_SPC_CODEC, m_loader_name);
 
@@ -91,7 +91,7 @@ bool SPCCodec::Init(const CStdString &strFile, unsigned int filecache)
   m_loader->ResolveExport("LoadSPCFile",(void**)&m_dll.LoadSPCFile);
   m_loader->ResolveExport("EmuAPU",(void**)&m_dll.EmuAPU);
   m_loader->ResolveExport("SeekAPU",(void**)&m_dll.SeekAPU);
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   m_loader->ResolveExport("InitAPU",(void**)&m_dll.InitAPU);
   m_loader->ResolveExport("ResetAPU",(void**)&m_dll.ResetAPU);
 #endif
@@ -114,7 +114,7 @@ bool SPCCodec::Init(const CStdString &strFile, unsigned int filecache)
   file.Close();
 
   m_pApuRAM = new u8[65536];
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   m_dll.InitAPU();
   m_dll.ResetAPU();
 #endif
index 646f45b..a76a17f 100644 (file)
@@ -37,7 +37,7 @@ public:
   virtual int ReadPCM(BYTE *pBuffer, int size, int *actualsize);
   virtual bool CanInit();
 private:
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   typedef void  (__cdecl *LoadMethod) ( const void* p1);
   typedef void* (__cdecl *EmuMethod) ( void *p1, u32 p2, u32 p3);
   typedef void  (__cdecl *SeekMethod) ( u32 p1, b8 p2 );
@@ -53,7 +53,7 @@ private:
     LoadMethod LoadSPCFile;
     EmuMethod EmuAPU;
     SeekMethod SeekAPU;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
     InitMethod InitAPU;
     DeInitMethod ResetAPU;
 #endif
index f83e8ad..58978a4 100644 (file)
@@ -26,7 +26,7 @@
 #include "Util.h"
 #include "utils/log.h"
 #include "filesystem/SpecialProtocol.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "../DllLoader/Win32DllLoader.h"
 #endif
 
@@ -60,7 +60,7 @@ bool TimidityCodec::Init(const CStdString &strFile, unsigned int filecache)
   // This forces the shared lib loader to load a per-instance copy of MID_CODEC.
   if ( !m_loader )
   {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
     m_loader_name = CUtil::GetNextFilename("special://temp/libtimidity-%03d.so", 999);
     XFILE::CFile::Cache(DLL_PATH_MID_CODEC, m_loader_name);
 
index 58cdd40..2421a79 100644 (file)
@@ -24,7 +24,7 @@
 #include "utils/log.h"
 #include "cores/AudioEngine/Utils/AEUtil.h"
 
-#if defined(WIN32)
+#if defined(TARGET_WINDOWS)
 #include <mmreg.h>
 #include <ks.h>
 #include <ksmedia.h>
index 05ffb87..d5a4515 100644 (file)
@@ -128,7 +128,7 @@ void Dataset::setSqlParams(const char *sqlFrmt, sqlType t, ...) {
   char sqlCmd[DB_BUFF_MAX+1];
 
   va_start(ap, t);
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   _vsnprintf(sqlCmd, DB_BUFF_MAX-1, sqlFrmt, ap);
 #else
   vsnprintf(sqlCmd, DB_BUFF_MAX-1, sqlFrmt, ap);
@@ -517,7 +517,7 @@ DbErrors::DbErrors(const char *msg, ...) {
   va_list vl;
   va_start(vl, msg);
   char buf[DB_BUFF_MAX]="";
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   _vsnprintf(buf, DB_BUFF_MAX-1, msg, vl);
 #else
   vsnprintf(buf, DB_BUFF_MAX-1, msg, vl);
index 07f3875..5586362 100644 (file)
@@ -29,7 +29,7 @@
 #ifdef HAS_MYSQL
 #include "mysqldataset.h"
 #include "mysql/errmsg.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #pragma comment(lib, "mysqlclient.lib")
 #endif
 
index 2226683..1bbd099 100644 (file)
@@ -34,7 +34,7 @@
 #include "system.h" // for Sleep(), OutputDebugString() and GetLastError()
 #include "utils/URIUtils.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #pragma comment(lib, "sqlite3.lib")
 #endif
 
index da7d485..d6982bb 100644 (file)
@@ -45,7 +45,7 @@
 #include "video/windows/GUIWindowVideoBase.h"
 #include "URL.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "WIN32Util.h"
 #endif
 
index 9f147fa..79ed85e 100644 (file)
@@ -21,7 +21,8 @@
 #include "GUIDialogFavourites.h"
 #include "GUIDialogContextMenu.h"
 #include "GUIDialogFileBrowser.h"
-#include "Favourites.h"
+#include "filesystem/Directory.h"
+#include "filesystem/FavouritesDirectory.h"
 #include "guilib/GUIWindowManager.h"
 #include "guilib/GUIKeyboardFactory.h"
 #include "guilib/Key.h"
@@ -83,7 +84,7 @@ bool CGUIDialogFavourites::OnMessage(CGUIMessage &message)
 
 void CGUIDialogFavourites::OnInitWindow()
 {
-  CFavourites::Load(*m_favourites);
+  XFILE::CDirectory::GetDirectory("favourites://", *m_favourites);
   UpdateList();
   CGUIWindow::OnInitWindow();
 }
@@ -154,7 +155,7 @@ void CGUIDialogFavourites::OnMoveItem(int item, int amount)
   if (nextItem < 0) nextItem += m_favourites->Size();
 
   m_favourites->Swap(item, nextItem);
-  CFavourites::Save(*m_favourites);
+  CFavouritesDirectory::Save(*m_favourites);
 
   CGUIMessage message(GUI_MSG_ITEM_SELECT, GetID(), FAVOURITES_LIST, nextItem);
   OnMessage(message);
@@ -167,7 +168,7 @@ void CGUIDialogFavourites::OnDelete(int item)
   if (item < 0 || item >= m_favourites->Size())
     return;
   m_favourites->Remove(item);
-  CFavourites::Save(*m_favourites);
+  CFavouritesDirectory::Save(*m_favourites);
 
   CGUIMessage message(GUI_MSG_ITEM_SELECT, GetID(), FAVOURITES_LIST, item < m_favourites->Size() ? item : item - 1);
   OnMessage(message);
@@ -184,7 +185,7 @@ void CGUIDialogFavourites::OnRename(int item)
   if (CGUIKeyboardFactory::ShowAndGetInput(label, g_localizeStrings.Get(16008), false))
     (*m_favourites)[item]->SetLabel(label);
 
-  CFavourites::Save(*m_favourites);
+  CFavouritesDirectory::Save(*m_favourites);
 
   UpdateList();
 }
@@ -220,7 +221,7 @@ void CGUIDialogFavourites::OnSetThumb(int item)
     return;
 
   (*m_favourites)[item]->SetArt("thumb", thumb);
-  CFavourites::Save(*m_favourites);
+  CFavouritesDirectory::Save(*m_favourites);
   UpdateList();
 }
 
index 8064290..e13d5c0 100644 (file)
@@ -172,7 +172,7 @@ void CGUIDialogSmartPlaylistEditor::OnOK()
     }
     else
       return;
-    if (URIUtils::GetExtension(path) != ".xsp")
+    if (!URIUtils::HasExtension(path, ".xsp"))
       path += ".xsp";
 
     // should we check whether we should overwrite?
index e10d502..d620942 100644 (file)
@@ -316,7 +316,7 @@ void CGUIDialogSmartPlaylistRule::OnBrowse()
   CStdString strHeading;
   strHeading.Format(g_localizeStrings.Get(13401),g_localizeStrings.Get(iLabel));
   pDialog->SetHeading(strHeading);
-  pDialog->SetMultiSelection(true);
+  pDialog->SetMultiSelection(m_rule.m_field != FieldPlaylist);
 
   if (!m_rule.m_parameter.empty())
     pDialog->SetSelected(m_rule.m_parameter);
index 9a59195..808c180 100644 (file)
@@ -24,7 +24,7 @@
 #include "FileItem.h"
 #include "guilib/GUIControl.h"
 #include "guilib/GUIListItemLayout.h"
-#include "guilib/GUIBaseContainer.h"
+#include "guilib/IGUIContainer.h"
 
 namespace PVR
 {
index 921e350..1c56eb1 100644 (file)
@@ -21,7 +21,7 @@
 // FileAFP.cpp: implementation of the CAFPFile class.
 //
 //////////////////////////////////////////////////////////////////////
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "system.h"
 
 #if defined(HAS_FILESYSTEM_AFP)
@@ -477,7 +477,7 @@ bool CAFPFile::Open(const CURL& url)
   CLog::Log(LOGDEBUG,"CAFPFile::Open - opened %s, fd=%d",url.GetFileName().c_str(), m_pFp ? m_pFp->fileid:-1);
   m_url = url;
   
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   struct __stat64 tmpBuffer;
 #else
   struct stat tmpBuffer;
@@ -730,4 +730,4 @@ bool CAFPFile::IsValidFile(const CStdString& strFileName)
   return true;
 }
 #endif // HAS_FILESYSTEM_AFP
-#endif // _LINUX
+#endif // TARGET_POSIX
index 4551b00..ca92000 100644 (file)
@@ -23,7 +23,7 @@
 #define FILEAFP_H_
 
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 
 #include "IFile.h"
 #include "URL.h"
@@ -132,5 +132,5 @@ protected:
   struct afp_volume    *m_pAfpVol;  
 };
 }
-#endif // _LINUX
+#endif // TARGET_POSIX
 #endif // FILEAFP_H_
index 73263f1..e0f7083 100644 (file)
@@ -56,9 +56,9 @@ bool CFileCDDA::Open(const CURL& url)
     return false;
 
   // Open the dvd drive
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   m_pCdIo = m_cdio->cdio_open(g_mediaManager.TranslateDevicePath(strURL), DRIVER_UNKNOWN);
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
   m_pCdIo = m_cdio->cdio_open_win32(g_mediaManager.TranslateDevicePath(strURL, true));
 #else
   m_pCdIo = m_cdio->cdio_open_win32("D:");
@@ -218,10 +218,7 @@ int64_t CFileCDDA::GetLength()
 bool CFileCDDA::IsValidFile(const CURL& url)
 {
   // Only .cdda files are supported
-  CStdString strExtension = URIUtils::GetExtension(url.Get());
-  strExtension.MakeLower();
-
-  return (strExtension == ".cdda");
+  return URIUtils::HasExtension(url.Get(), ".cdda");
 }
 
 int CFileCDDA::GetTrackNum(const CURL& url)
index 039342a..d9c00f7 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "threads/SystemClock.h"
 #include "CacheStrategy.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "PlatformInclude.h"
 #endif
 #include "Util.h"
@@ -28,7 +28,7 @@
 #include "threads/SingleLock.h"
 #include "utils/TimeUtils.h"
 #include "SpecialProtocol.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "PlatformDefs.h" //for PRIdS, PRId64
 #endif
 
@@ -209,9 +209,10 @@ int64_t CSimpleFileCache::Seek(int64_t iFilePosition)
   }
 
   int64_t nDiff = iTarget - m_nWritePosition;
-  if ( nDiff > 500000 || (nDiff > 0 && WaitForData((unsigned int)(iTarget - m_nReadPosition), 5000) == CACHE_RC_TIMEOUT)  ) {
-    CLog::Log(LOGWARNING,"%s - attempt to seek past read data (seek to %"PRId64". max: %"PRId64". reset read pointer. (%"PRId64")", __FUNCTION__, iTarget, m_nWritePosition, iFilePosition);
-    return  CACHE_RC_ERROR;
+  if (nDiff > 500000 || (nDiff > 0 && WaitForData((unsigned int)(iTarget - m_nReadPosition), 5000) == CACHE_RC_TIMEOUT))
+  {
+    CLog::Log(LOGDEBUG,"CSimpleFileCache::Seek - Attempt to seek past read data");
+    return CACHE_RC_ERROR;
   }
 
   LARGE_INTEGER pos;
index 8b33beb..c69b168 100644 (file)
@@ -23,7 +23,7 @@
 #define XFILECACHESTRATEGY_H
 
 #include <stdint.h>
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "PlatformDefs.h"
 #include "XHandlePublic.h"
 #include "XFileUtils.h"
index fa2f83a..f0b1a99 100644 (file)
@@ -35,7 +35,7 @@ CCircularCache::CCircularCache(size_t front, size_t back)
  , m_buf(NULL)
  , m_size(front + back)
  , m_size_back(back)
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
  , m_handle(INVALID_HANDLE_VALUE)
 #endif
 {
@@ -48,7 +48,7 @@ CCircularCache::~CCircularCache()
 
 int CCircularCache::Open()
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   m_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, m_size, NULL);
   if(m_handle == NULL)
     return CACHE_RC_ERROR;
@@ -66,7 +66,7 @@ int CCircularCache::Open()
 
 void CCircularCache::Close()
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   UnmapViewOfFile(m_buf);
   CloseHandle(m_handle);
   m_handle = INVALID_HANDLE_VALUE;
index d815628..18680e4 100644 (file)
@@ -57,7 +57,7 @@ protected:
     size_t            m_size_back; /**< guaranteed size of back buffer (actual size can be smaller, or larger if front buffer doesn't need it) */
     CCriticalSection  m_sync;
     CEvent            m_written;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
     HANDLE            m_handle;
 #endif
 };
index b25b871..1e5cc15 100644 (file)
@@ -29,7 +29,7 @@
 #include <vector>
 #include <climits>
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include <errno.h>
 #include <inttypes.h>
 #include "../linux/XFileUtils.h"
@@ -322,6 +322,9 @@ void CCurlFile::CReadState::SetResume(void)
 
 long CCurlFile::CReadState::Connect(unsigned int size)
 {
+  if (m_filePos != 0)
+    CLog::Log(LOGDEBUG,"CurlFile::CReadState::Connect - Resume from position %"PRId64, m_filePos);
+
   SetResume();
   g_curlInterface.multi_add_handle(m_multiHandle, m_easyHandle);
 
index e347bbe..c25f535 100644 (file)
@@ -24,9 +24,7 @@
 #if !defined(AFX_FILEDAAP_H___INCLUDED_)
 #define AFX_FILEDAAP_H___INCLUDED_
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 
 #include "lib/libXDAAP/client.h"
 #include "CurlFile.h"
index 9235fec..9d7f13d 100644 (file)
@@ -286,7 +286,10 @@ bool CDirectory::Remove(const CStdString& strPath)
     auto_ptr<IDirectory> pDirectory(CDirectoryFactory::Create(realPath));
     if (pDirectory.get())
       if(pDirectory->Remove(realPath.c_str()))
+      {
+        g_directoryCache.ClearFile(realPath);
         return true;
+      }
   }
   XBMCCOMMONS_HANDLE_UNCHECKED
   catch (...)
index de0edb9..7667546 100644 (file)
@@ -190,7 +190,7 @@ bool CDirectoryCache::FileExists(const CStdString& strFile, bool& bInCache)
 #ifdef _DEBUG
     m_cacheHits++;
 #endif
-    return dir->m_Items->Contains(strFile);
+    return (strPath.Equals(storedPath) || dir->m_Items->Contains(strFile));
   }
 #ifdef _DEBUG
   m_cacheMisses++;
index df35e16..c29cd8d 100644 (file)
@@ -18,7 +18,7 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 #include "network/Network.h"
@@ -33,6 +33,7 @@
 #include "MusicDatabaseDirectory.h"
 #include "MusicSearchDirectory.h"
 #include "VideoDatabaseDirectory.h"
+#include "FavouritesDirectory.h"
 #include "LibraryDirectory.h"
 #include "AddonsDirectory.h"
 #include "SourcesDirectory.h"
@@ -46,7 +47,7 @@
 #include "network/WakeOnAccess.h"
 
 #ifdef HAS_FILESYSTEM_SMB
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "windows/WINSMBDirectory.h"
 #else
 #include "SMBDirectory.h"
@@ -165,6 +166,7 @@ IDirectory* CDirectoryFactory::Create(const CStdString& strPath)
   if (strProtocol == "musicsearch") return new CMusicSearchDirectory();
   if (strProtocol == "videodb") return new CVideoDatabaseDirectory();
   if (strProtocol == "library") return new CLibraryDirectory();
+  if (strProtocol == "favourites") return new CFavouritesDirectory();
   if (strProtocol == "filereader")
     return CDirectoryFactory::Create(url.GetFileName());
 
@@ -178,7 +180,7 @@ IDirectory* CDirectoryFactory::Create(const CStdString& strPath)
     if (strProtocol == "sftp" || strProtocol == "ssh") return new CSFTPDirectory();
 #endif
 #ifdef HAS_FILESYSTEM_SMB
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
     if (strProtocol == "smb") return new CWINSMBDirectory();
 #else
     if (strProtocol == "smb") return new CSMBDirectory();
index 89a1fae..4bfd9fe 100644 (file)
@@ -18,7 +18,7 @@
  *
  */
 
-#if _WIN32
+#if TARGET_WINDOWS
 #define PCRE_STATIC
 #endif
 #include <pcrecpp.h>
diff --git a/xbmc/filesystem/FavouritesDirectory.cpp b/xbmc/filesystem/FavouritesDirectory.cpp
new file mode 100644 (file)
index 0000000..aaecb75
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ *      Copyright (C) 2005-2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "FavouritesDirectory.h"
+#include "File.h"
+#include "Util.h"
+#include "profiles/ProfilesManager.h"
+#include "FileItem.h"
+#include "utils/XBMCTinyXML.h"
+#include "utils/log.h"
+#include "utils/StringUtils.h"
+#include "utils/URIUtils.h"
+#include "settings/AdvancedSettings.h"
+#include "video/VideoInfoTag.h"
+#include "URL.h"
+
+namespace XFILE
+{
+
+
+bool CFavouritesDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
+{
+  items.Clear();
+  CURL url(strPath);
+  
+  if (url.GetProtocol() == "favourites")
+  {
+    Load(items); //load the default favourite files
+  }
+  return LoadFavourites(strPath, items); //directly load the given file
+}
+  
+bool CFavouritesDirectory::Exists(const char* strPath)
+{
+  CURL url(strPath);
+  
+  if (url.GetProtocol() == "favourites")
+  {
+    return XFILE::CFile::Exists("special://xbmc/system/favourites.xml") 
+        || XFILE::CFile::Exists(URIUtils::AddFileToFolder(CProfilesManager::Get().GetProfileUserDataFolder(), "favourites.xml"));
+  }
+  return XFILE::CFile::Exists(strPath); //directly load the given file
+}
+
+bool CFavouritesDirectory::Load(CFileItemList &items)
+{
+  items.Clear();
+  CStdString favourites;
+
+  favourites = "special://xbmc/system/favourites.xml";
+  if(XFILE::CFile::Exists(favourites))
+    CFavouritesDirectory::LoadFavourites(favourites, items);
+  else
+    CLog::Log(LOGDEBUG, "CFavourites::Load - no system favourites found, skipping");
+  favourites = URIUtils::AddFileToFolder(CProfilesManager::Get().GetProfileUserDataFolder(), "favourites.xml");
+  if(XFILE::CFile::Exists(favourites))
+    CFavouritesDirectory::LoadFavourites(favourites, items);
+  else
+    CLog::Log(LOGDEBUG, "CFavourites::Load - no userdata favourites found, skipping");
+
+  return true;
+}
+
+bool CFavouritesDirectory::LoadFavourites(const CStdString& strPath, CFileItemList& items)
+{
+  CXBMCTinyXML doc;
+  if (!doc.LoadFile(strPath))
+  {
+    CLog::Log(LOGERROR, "Unable to load %s (row %i column %i)", strPath.c_str(), doc.Row(), doc.Column());
+    return false;
+  }
+  TiXmlElement *root = doc.RootElement();
+  if (!root || strcmp(root->Value(), "favourites"))
+  {
+    CLog::Log(LOGERROR, "Favourites.xml doesn't contain the <favourites> root element");
+    return false;
+  }
+
+  TiXmlElement *favourite = root->FirstChildElement("favourite");
+  while (favourite)
+  {
+    // format:
+    // <favourite name="Cool Video" thumb="foo.jpg">PlayMedia(c:\videos\cool_video.avi)</favourite>
+    // <favourite name="My Album" thumb="bar.tbn">ActivateWindow(MyMusic,c:\music\my album)</favourite>
+    // <favourite name="Apple Movie Trailers" thumb="path_to_thumb.png">RunScript(special://xbmc/scripts/apple movie trailers/default.py)</favourite>
+    const char *name = favourite->Attribute("name");
+    const char *thumb = favourite->Attribute("thumb");
+    if (name && favourite->FirstChild())
+    {
+      if(!items.Contains(favourite->FirstChild()->Value()))
+      {
+        CFileItemPtr item(new CFileItem(name));
+        item->SetPath(favourite->FirstChild()->Value());
+        if (thumb) item->SetArt("thumb", thumb);
+        items.Add(item);
+      }
+    }
+    favourite = favourite->NextSiblingElement("favourite");
+  }
+  return true;
+}
+
+bool CFavouritesDirectory::Save(const CFileItemList &items)
+{
+  CStdString favourites;
+  CXBMCTinyXML doc;
+  TiXmlElement xmlRootElement("favourites");
+  TiXmlNode *rootNode = doc.InsertEndChild(xmlRootElement);
+  if (!rootNode) return false;
+
+  for (int i = 0; i < items.Size(); i++)
+  {
+    const CFileItemPtr item = items[i];
+    TiXmlElement favNode("favourite");
+    favNode.SetAttribute("name", item->GetLabel().c_str());
+    if (item->HasArt("thumb"))
+      favNode.SetAttribute("thumb", item->GetArt("thumb").c_str());
+    TiXmlText execute(item->GetPath());
+    favNode.InsertEndChild(execute);
+    rootNode->InsertEndChild(favNode);
+  }
+
+  favourites = URIUtils::AddFileToFolder(CProfilesManager::Get().GetProfileUserDataFolder(), "favourites.xml");
+  return doc.SaveFile(favourites);
+}
+
+bool CFavouritesDirectory::AddOrRemove(CFileItem *item, int contextWindow)
+{
+  if (!item) return false;
+
+  // load our list
+  CFileItemList items;
+  Load(items);
+
+  CStdString executePath(GetExecutePath(item, contextWindow));
+
+  CFileItemPtr match = items.Get(executePath);
+  if (match)
+  { // remove the item
+    items.Remove(match.get());
+  }
+  else
+  { // create our new favourite item
+    CFileItemPtr favourite(new CFileItem(item->GetLabel()));
+    if (item->GetLabel().IsEmpty())
+      favourite->SetLabel(CUtil::GetTitleFromPath(item->GetPath(), item->m_bIsFolder));
+    favourite->SetArt("thumb", item->GetArt("thumb"));
+    favourite->SetPath(executePath);
+    items.Add(favourite);
+  }
+
+  // and save our list again
+  return Save(items);
+}
+
+bool CFavouritesDirectory::IsFavourite(CFileItem *item, int contextWindow)
+{
+  CFileItemList items;
+  if (!Load(items)) return false;
+
+  return items.Contains(GetExecutePath(item, contextWindow));
+}
+
+CStdString CFavouritesDirectory::GetExecutePath(const CFileItem *item, int contextWindow)
+{
+  CStdString execute;
+  if (item->m_bIsFolder && (g_advancedSettings.m_playlistAsFolders ||
+                            !(item->IsSmartPlayList() || item->IsPlayList())))
+    execute.Format("ActivateWindow(%i,%s)", contextWindow, StringUtils::Paramify(item->GetPath()).c_str());
+  else if (item->IsScript())
+    execute.Format("RunScript(%s)", StringUtils::Paramify(item->GetPath().Mid(9)).c_str());
+  else if (item->IsAndroidApp())
+    execute.Format("StartAndroidActivity(%s)", StringUtils::Paramify(item->GetPath().Mid(26)).c_str());
+  else  // assume a media file
+  {
+    if (item->IsVideoDb() && item->HasVideoInfoTag())
+      execute.Format("PlayMedia(%s)", StringUtils::Paramify(item->GetVideoInfoTag()->m_strFileNameAndPath).c_str());
+    else
+      execute.Format("PlayMedia(%s)", StringUtils::Paramify(item->GetPath()).c_str());
+  }
+  return execute;
+}
+  
+}
diff --git a/xbmc/filesystem/FavouritesDirectory.h b/xbmc/filesystem/FavouritesDirectory.h
new file mode 100644 (file)
index 0000000..7cfe248
--- /dev/null
@@ -0,0 +1,47 @@
+#pragma once
+
+/*
+ *      Copyright (C) 2005-2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "utils/StdString.h"
+#include "IDirectory.h"
+
+class CFileItemList;
+class CFileItem;
+
+namespace XFILE
+{
+
+  class CFavouritesDirectory : public IDirectory
+  {
+  public:
+    virtual bool GetDirectory(const CStdString& strPath, CFileItemList &items);
+    virtual bool Exists(const char* strPath);
+    static bool Load(CFileItemList &items);
+    static bool LoadFavourites(const CStdString& strPath, CFileItemList& items);
+
+    static bool AddOrRemove(CFileItem *item, int contextWindow);
+    static bool Save(const CFileItemList& items);
+    static bool IsFavourite(CFileItem *item, int contextWindow);
+  private:
+    static CStdString GetExecutePath(const CFileItem *item, int contextWindow);
+  };
+  
+}
index cc6d51a..8b9aa5e 100644 (file)
@@ -100,7 +100,7 @@ bool CFile::Cache(const CStdString& strFileName, const CStdString& strDest, XFIL
       {
         CURL url(strDirectory);
         CStdString pathsep;
-#ifndef _LINUX
+#ifndef TARGET_POSIX
         pathsep = "\\";
 #else
         pathsep = "/";
index 2cc6cfe..51261c9 100644 (file)
@@ -25,9 +25,7 @@
 #if !defined(AFX_FILE_H__A7ED6320_C362_49CB_8925_6C6C8CAE7B78__INCLUDED_)
 #define AFX_FILE_H__A7ED6320_C362_49CB_8925_6C6C8CAE7B78__INCLUDED_
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 
 #include <iostream>
 #include "utils/StdString.h"
index b5c4f28..3349d94 100644 (file)
@@ -223,7 +223,6 @@ void CFileCache::Process()
       bool sourceSeekFailed = false;
       if (!cacheReachEOF)
       {
-        CLog::Log(LOGDEBUG,"CFileCache::Process - Request seek on source to %"PRId64, cacheMaxPos);
         m_nSeekResult = m_source.Seek(cacheMaxPos, SEEK_SET);
         if (m_nSeekResult != cacheMaxPos)
         {
index a6c8071..db02683 100644 (file)
@@ -62,6 +62,9 @@ CFileDirectoryFactory::~CFileDirectoryFactory(void)
 // return NULL + set pItem->m_bIsFolder to remove it completely from list.
 IFileDirectory* CFileDirectoryFactory::Create(const CStdString& strPath, CFileItem* pItem, const CStdString& strMask)
 {
+  if (URIUtils::IsStack(strPath)) // disqualify stack as we need to work with each of the parts instead
+    return NULL;
+
   CStdString strExtension=URIUtils::GetExtension(strPath);
   strExtension.MakeLower();
 
index 40331a8..c168516 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 #include "network/Network.h"
@@ -32,7 +32,7 @@
 #include "ShoutcastFile.h"
 #include "FileReaderFile.h"
 #ifdef HAS_FILESYSTEM_SMB
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "windows/WINFileSmb.h"
 #else
 #include "SmbFile.h"
@@ -164,7 +164,7 @@ IFile* CFileFactory::CreateLoader(const CURL& url)
     else if (strProtocol == "myth") return new CMythFile();
     else if (strProtocol == "cmyth") return new CMythFile();
 #ifdef HAS_FILESYSTEM_SMB
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
     else if (strProtocol == "smb") return new CWINFileSMB();
 #else
     else if (strProtocol == "smb") return new CSmbFile();
index fa521d2..18b4260 100644 (file)
@@ -25,9 +25,7 @@
 #if !defined(AFX_FILEFACTORY1_H__068E3138_B7CB_4BEE_B5CE_8AA8CADAB233__INCLUDED_)
 #define AFX_FILEFACTORY1_H__068E3138_B7CB_4BEE_B5CE_8AA8CADAB233__INCLUDED_
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 
 #include "IFile.h"
 #include "utils/StdString.h"
index 0ce400f..4c47be9 100644 (file)
@@ -27,7 +27,7 @@
 #include "utils/AliasShortcutUtils.h"
 #include "utils/URIUtils.h"
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #include "utils/CharsetConverter.h"
 #endif
 
@@ -35,7 +35,7 @@
 #define INVALID_FILE_ATTRIBUTES ((DWORD) -1)
 #endif
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 typedef WIN32_FIND_DATAW LOCAL_WIN32_FIND_DATA;
 #define LocalFindFirstFile FindFirstFileW
 #define LocalFindNextFile FindNextFileW
@@ -68,7 +68,7 @@ bool CHDDirectory::GetDirectory(const CStdString& strPath1, CFileItemList &items
 
   memset(&wfd, 0, sizeof(wfd));
   URIUtils::AddSlashAtEnd(strRoot);
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   strRoot.Replace("/", "\\");
 #endif
   if (URIUtils::IsDVD(strRoot) && m_isoReader.IsScanned())
@@ -78,7 +78,7 @@ bool CHDDirectory::GetDirectory(const CStdString& strPath1, CFileItemList &items
     m_isoReader.Reset();
   }
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CStdStringW strSearchMask;
   g_charsetConverter.utf8ToW(strRoot, strSearchMask, false);
   strSearchMask.Insert(0, L"\\\\?\\");
@@ -101,7 +101,7 @@ bool CHDDirectory::GetDirectory(const CStdString& strPath1, CFileItemList &items
       if (wfd.cFileName[0] != 0)
       {
         CStdString strLabel;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
         g_charsetConverter.wToUTF8(wfd.cFileName,strLabel);
 #else
         strLabel = wfd.cFileName;
@@ -149,7 +149,7 @@ bool CHDDirectory::Create(const char* strPath)
   CStdString strPath1 = strPath;
   URIUtils::AddSlashAtEnd(strPath1);
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if (strPath1.size() == 3 && strPath1[1] == ':')
     return Exists(strPath);  // A drive - we can't "create" a drive
   CStdStringW strWPath1;
@@ -169,7 +169,7 @@ bool CHDDirectory::Create(const char* strPath)
 
 bool CHDDirectory::Remove(const char* strPath)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CStdStringW strWPath;
   g_charsetConverter.utf8ToW(strPath, strWPath, false);
   strWPath.Replace(L"/", L"\\");
@@ -185,7 +185,7 @@ bool CHDDirectory::Exists(const char* strPath)
   if (!strPath || !*strPath)
     return false;
   CStdString strReplaced=strPath;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CStdStringW strWReplaced;
   strReplaced.Replace("/","\\");
   URIUtils::AddSlashAtEnd(strReplaced);
index e8c52e3..ed65eb8 100644 (file)
 #include "Util.h"
 #include "URL.h"
 #include "utils/AliasShortcutUtils.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "XHandle.h"
 #endif
 
 #include <sys/stat.h>
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #else
@@ -93,7 +93,7 @@ bool CHDFile::Open(const CURL& url)
 {
   CStdString strFile = GetLocal(url);
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CStdStringW strWFile;
   g_charsetConverter.utf8ToW(strFile, strWFile, false);
   m_hFile.attach(CreateFileW(strWFile.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL));
@@ -114,7 +114,7 @@ bool CHDFile::Exists(const CURL& url)
   struct __stat64 buffer;
   CStdString strFile = GetLocal(url);
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CStdStringW strWFile;
   URIUtils::RemoveSlashAtEnd(strFile);
   g_charsetConverter.utf8ToW(strFile, strWFile, false);
@@ -129,7 +129,7 @@ bool CHDFile::Exists(const CURL& url)
 
 int CHDFile::Stat(struct __stat64* buffer)
 {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   return _fstat64((*m_hFile).fd, buffer);
 #else
   // Duplicate the handle, as retrieving and closing a matching crt handle closes the crt handle AND the original Windows handle.
@@ -157,7 +157,7 @@ int CHDFile::Stat(const CURL& url, struct __stat64* buffer)
 {
   CStdString strFile = GetLocal(url);
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CStdStringW strWFile;
   /* _wstat64 can't handle long paths therefore we remove the \\?\ */
   strFile.Replace("\\\\?\\", "");
@@ -177,7 +177,7 @@ int CHDFile::Stat(const CURL& url, struct __stat64* buffer)
 
 bool CHDFile::SetHidden(const CURL &url, bool hidden)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CStdStringW path;
   g_charsetConverter.utf8ToW(GetLocal(url), path, false);
   DWORD attributes = hidden ? FILE_ATTRIBUTE_HIDDEN : FILE_ATTRIBUTE_NORMAL;
@@ -193,7 +193,7 @@ bool CHDFile::OpenForWrite(const CURL& url, bool bOverWrite)
   // make sure it's a legal FATX filename (we are writing to the harddisk)
   CStdString strPath = GetLocal(url);
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CStdStringW strWPath;
   g_charsetConverter.utf8ToW(strPath, strWPath, false);
   m_hFile.attach(CreateFileW(strWPath.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, bOverWrite ? CREATE_ALWAYS : OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL));
@@ -318,7 +318,7 @@ bool CHDFile::Delete(const CURL& url)
 {
   CStdString strFile=GetLocal(url);
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CStdStringW strWFile;
   g_charsetConverter.utf8ToW(strFile, strWFile, false);
   return ::DeleteFileW(strWFile.c_str()) ? true : false;
@@ -332,7 +332,7 @@ bool CHDFile::Rename(const CURL& url, const CURL& urlnew)
   CStdString strFile=GetLocal(url);
   CStdString strNewFile=GetLocal(urlnew);
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CStdStringW strWFile;
   CStdStringW strWNewFile;
   g_charsetConverter.utf8ToW(strFile, strWFile, false);
@@ -350,7 +350,7 @@ void CHDFile::Flush()
 
 int CHDFile::IoControl(EIoControl request, void* param)
 {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   if(request == IOCTRL_NATIVE && param)
   {
     SNativeIoControl* s = (SNativeIoControl*)param;
@@ -362,7 +362,7 @@ int CHDFile::IoControl(EIoControl request, void* param)
 
 int CHDFile::Truncate(int64_t size)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   // Duplicate the handle, as retrieving and closing a matching crt handle closes the crt handle AND the original Windows handle.
   HANDLE hFileDup;
   if (0 == DuplicateHandle(GetCurrentProcess(), (HANDLE)m_hFile, GetCurrentProcess(), &hFileDup, 0, FALSE, DUPLICATE_SAME_ACCESS))
index 80a46d3..7b13195 100644 (file)
@@ -25,9 +25,7 @@
 #if !defined(AFX_FILEHD_H__DD2B0A9E_4971_4A29_B525_78CEFCDAF4A1__INCLUDED_)
 #define AFX_FILEHD_H__DD2B0A9E_4971_4A29_B525_78CEFCDAF4A1__INCLUDED_
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 
 #include "IFile.h"
 #include "utils/AutoPtrHandle.h"
index 385e2db..9beee3b 100644 (file)
@@ -57,11 +57,7 @@ bool CHomeRunFile::Exists(const CURL& url)
    * The filename starts with "tuner" and has no extension. This check will cover off requests
    * for *.tbn, *.jpg, *.jpeg, *.edl etc. that do not exist.
    */
-  if(path.Left(5) == "tuner"
-  && URIUtils::GetExtension(path).IsEmpty())
-    return true;
-
-  return false;
+  return path.Left(5) == "tuner" && !URIUtils::HasExtension(path);
 }
 
 int64_t CHomeRunFile::Seek(int64_t iFilePosition, int iWhence)
index 15a6bfe..d9db565 100644 (file)
@@ -39,44 +39,45 @@ IDirectory::~IDirectory(void)
 {}
 
 /*!
- \brief Test a file for an extension specified with SetMask().
+ \brief Test if file have an allowed extension, as specified with SetMask()
  \param strFile File to test
- \return Returns \e true, if file is allowed.
+ \return \e true if file is allowed
+ \note If extension is ".ifo", filename format must be "vide_ts.ifo" or
+       "vts_##_0.ifo". If extension is ".dat", filename format must be
+       "AVSEQ##(#).DAT", "ITEM###(#).DAT" or "MUSIC##(#).DAT".
  */
 bool IDirectory::IsAllowed(const CStdString& strFile) const
 {
-  if ( !m_strFileMask.size() ) return true;
-  if ( !strFile.size() ) return true;
-
-  CStdString strExtension = URIUtils::GetExtension(strFile);
+  if (m_strFileMask.empty() || strFile.empty())
+    return true;
 
-  if (strExtension.empty())
+  // Check if strFile have an allowed extension
+  if (!URIUtils::HasExtension(strFile, m_strFileMask))
     return false;
 
-  strExtension.ToLower();
-  strExtension += '|'; // ensures that we have a | at the end of it
-  if (m_strFileMask.Find(strExtension) != -1)
-  { // it's allowed, but we should also ignore all non dvd related ifo files.
-    if (strExtension.Equals(".ifo|"))
-    {
-      CStdString fileName = URIUtils::GetFileName(strFile);
-      if (fileName.Equals("video_ts.ifo")) return true;
-      if (fileName.length() == 12 && fileName.Left(4).Equals("vts_") && fileName.Right(6).Equals("_0.ifo")) return true;
-      return false;
-    }
-    if (strExtension.Equals(".dat|"))
-    {
-      CStdString fileName = URIUtils::GetFileName(strFile);
-      /* VCD filenames are of the form AVSEQ##(#).DAT, ITEM###(#).DAT, MUSIC##(#).DAT - i.e. all 11 or 12 characters long
-         starting with AVSEQ, MUSIC or ITEM */
-      if ((fileName.length() == 11 || fileName.length() == 12) &&
-          (fileName.Left(5).Equals("AVSEQ") || fileName.Left(5).Equals("MUSIC") || fileName.Left(4).Equals("ITEM")))
-        return true;
-      return false;
-    }
-    return true;
+  // We should ignore all non dvd/vcd related ifo and dat files.
+  if (URIUtils::HasExtension(strFile, ".ifo"))
+  {
+    CStdString fileName = URIUtils::GetFileName(strFile);
+
+    // Allow filenames of the form video_ts.ifo or vts_##_0.ifo
+    return fileName == "video_ts.ifo" ||
+          (fileName.length() == 12 && fileName.Left(4) == "vts_" &&
+           fileName.Right(6) == "_0.ifo");
   }
-  return false;
+  
+  if (URIUtils::HasExtension(strFile, ".dat"))
+  {
+    CStdString fileName = URIUtils::GetFileName(strFile);
+
+    // Allow filenames of the form AVSEQ##(#).DAT, ITEM###(#).DAT
+    // and MUSIC##(#).DAT
+    return (fileName.length() == 11 || fileName.length() == 12) &&
+           (fileName.Left(5) == "AVSEQ" || fileName.Left(5) == "MUSIC" ||
+            fileName.Left(4) == "ITEM");
+  }
+
+  return true;
 }
 
 /*!
index 86ce0ed..2bd12ad 100644 (file)
 #if !defined(AFX_IFILE_H__7EE73AC7_36BC_4822_93FF_44F3B0C766F6__INCLUDED_)
 #define AFX_IFILE_H__7EE73AC7_36BC_4822_93FF_44F3B0C766F6__INCLUDED_
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "PlatformDefs.h" // for __stat64
 #endif
 
index 6e87dff..8bafd9e 100644 (file)
@@ -25,9 +25,7 @@
 #if !defined(AFX_FILEISO_H__C2FB9C6D_3319_4182_AB45_65E57EFAC8D1__INCLUDED_)
 #define AFX_FILEISO_H__C2FB9C6D_3319_4182_AB45_65E57EFAC8D1__INCLUDED_
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 
 #include "IFile.h"
 #include "utils/RingBuffer.h"
index 6e47c5d..5431b28 100644 (file)
@@ -51,7 +51,7 @@ bool CLibraryDirectory::GetDirectory(const CStdString& strPath, CFileItemList &i
   if (libNode.IsEmpty())
     return false;
 
-  if (URIUtils::GetExtension(libNode).Equals(".xml"))
+  if (URIUtils::HasExtension(libNode, ".xml"))
   { // a filter node
     TiXmlElement *node = LoadXML(libNode);
     if (node)
index f73851a..c5a6738 100644 (file)
@@ -17,6 +17,7 @@ SRCS += DirectoryCache.cpp
 SRCS += DirectoryFactory.cpp
 SRCS += DirectoryHistory.cpp
 SRCS += DllLibCurl.cpp
+SRCS += FavouritesDirectory.cpp
 SRCS += File.cpp
 SRCS += FileCache.cpp
 SRCS += FileDirectoryFactory.cpp
index aee139c..c6cad1e 100644 (file)
@@ -18,7 +18,7 @@
  *
  */
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "threads/SystemClock.h"
 #include "linux/PlatformDefs.h"
 #endif
index ae3fa3e..8499777 100644 (file)
@@ -56,9 +56,7 @@ CStdString CMusicDatabaseFile::TranslateUrl(const CURL& url)
   if (!musicDatabase.GetSong(idSong, song))
     return "";
 
-  CStdString strExtensionFromDb = URIUtils::GetExtension(song.strFileName);
-
-  if (!strExtensionFromDb.Equals(strExtension))
+  if (!URIUtils::HasExtension(song.strFileName, strExtension))
     return "";
 
   return song.strFileName;
index 5e23477..4b01bca 100644 (file)
@@ -647,7 +647,7 @@ bool CMythDirectory::SupportsWriteFileOperations(const CStdString& strPath)
    */
   return filename.Left(11) == "recordings/" ||
          filename.Left(7)  == "movies/" ||
-        (filename.Left(8)  == "tvshows/" && URIUtils::GetExtension(filename) != "");
+        (filename.Left(8)  == "tvshows/" && URIUtils::HasExtension(filename));
 }
 
 bool CMythDirectory::IsLiveTV(const CStdString& strPath)
index cfcf6be..e554932 100644 (file)
@@ -194,7 +194,7 @@ bool CMythFile::SetupLiveTV(const CURL& url)
     return false;
 
   CStdString channel = url.GetFileNameWithoutPath();
-  if(!URIUtils::GetExtension(channel).Equals(".ts"))
+  if(!URIUtils::HasExtension(channel, ".ts"))
   {
     CLog::Log(LOGERROR, "%s - invalid channel url %s", __FUNCTION__, channel.c_str());
     return false;
@@ -396,8 +396,7 @@ bool CMythFile::Exists(const CURL& url)
   if ((path.Left(11) == "recordings/"
     || path.Left(7)  == "movies/"
     || path.Left(8)  == "tvshows/")
-    && (URIUtils::GetExtension(path).Equals(".mpg")
-    ||  URIUtils::GetExtension(path).Equals(".nuv")))
+    && (URIUtils::HasExtension(path, ".mpg|.nuv")))
   {
     if(!SetupConnection(url, true, false, false))
       return false;
index 075a58d..937fd0c 100644 (file)
@@ -25,9 +25,7 @@
 #if !defined(AFX_FILEPIPE_H__DD2B0A9E_4971_4A29_B525_78CEFCDAF4A1__INCLUDED_)
 #define AFX_FILEPIPE_H__DD2B0A9E_4971_4A29_B525_78CEFCDAF4A1__INCLUDED_
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 
 #include "IFile.h"
 #include "utils/AutoPtrHandle.h"
index 59e0aa4..d3acb91 100644 (file)
@@ -91,7 +91,8 @@ bool CPluginDirectory::StartScript(const CStdString& strPath, bool retrievingDir
 {
   CURL url(strPath);
 
-  if (!CAddonMgr::Get().GetAddon(url.GetHostName(), m_addon, ADDON_PLUGIN) && !CAddonInstaller::Get().PromptForInstall(url.GetHostName(), m_addon))
+  if (!CAddonMgr::Get().GetAddon(url.GetHostName(), m_addon, ADDON_UNKNOWN) && 
+      !CAddonInstaller::Get().PromptForInstall(url.GetHostName(), m_addon))
   {
     CLog::Log(LOGERROR, "Unable to find plugin %s", url.GetHostName().c_str());
     return false;
index 94d0c9c..ab929eb 100644 (file)
@@ -88,40 +88,18 @@ bool CRSSDirectory::ContainsFiles(const CStdString& strPath)
 
 static bool IsPathToMedia(const CStdString& strPath )
 {
-  CStdString extension = URIUtils::GetExtension(strPath);
-
-  if (extension.IsEmpty())
-    return false;
-
-  extension.ToLower();
-
-  if (g_advancedSettings.m_videoExtensions.Find(extension) != -1)
-    return true;
-
-  if (g_advancedSettings.m_musicExtensions.Find(extension) != -1)
-    return true;
-
-  if (g_advancedSettings.m_pictureExtensions.Find(extension) != -1)
-    return true;
-
-  return false;
+  return URIUtils::HasExtension(strPath,
+                              g_advancedSettings.m_videoExtensions + '|' +
+                              g_advancedSettings.m_musicExtensions + '|' +
+                              g_advancedSettings.m_pictureExtensions);
 }
 
 static bool IsPathToThumbnail(const CStdString& strPath )
 {
   // Currently just check if this is an image, maybe we will add some
   // other checks later
-  CStdString extension = URIUtils::GetExtension(strPath);
-
-  if (extension.IsEmpty())
-    return false;
-
-  extension.ToLower();
-
-  if (g_advancedSettings.m_pictureExtensions.Find(extension) != -1)
-    return true;
-
-  return false;
+  return URIUtils::HasExtension(strPath,
+                                    g_advancedSettings.m_pictureExtensions);
 }
 
 static time_t ParseDate(const CStdString & strDate)
index 61fef68..e025ace 100644 (file)
@@ -27,7 +27,7 @@
 #include "utils/log.h"
 #include <errno.h>
 #include <sys/stat.h>
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "PlatformDefs.h" //for PRIdS
 #endif
 extern "C"
index c96fdfd..5bc2c4c 100644 (file)
@@ -25,9 +25,7 @@
 #if !defined(AFX_FILERTV_H___INCLUDED_)
 #define AFX_FILERTV_H___INCLUDED_
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 
 #include "IFile.h"
 
index 80e77c3..e0cdb60 100644 (file)
@@ -32,7 +32,7 @@
 #include "utils/log.h"
 #include "UnrarXLib/rar.hpp"
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #include <process.h>
 #endif
 
index 81811f5..e449aed 100644 (file)
@@ -132,7 +132,7 @@ bool CRarManager::CacheRarredFile(CStdString& strPathInCache, const CStdString&
   }
 
   CStdString strPath = strPathInRar;
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   strPath.Replace('/', '\\');
 #endif
   //g_charsetConverter.unknownToUTF8(strPath);
index 317a41a..f7d45e5 100644 (file)
@@ -1,9 +1,7 @@
 #if !defined(AFX_RARMANAGER_H__06BA7C2E_3FCA_11D9_8186_0050FC718317__INCLUDED_)
 #define AFX_RARMANAGER_H__06BA7C2E_3FCA_11D9_8186_0050FC718317__INCLUDED_
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 /*
  *      Copyright (C) 2005-2013 Team XBMC
  *      http://www.xbmc.org
index 87fc696..189b68f 100644 (file)
@@ -31,7 +31,7 @@
 #if defined(TARGET_DARWIN)
 #include "osx/OSXGNUReplacements.h" // strnlen
 #endif
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
 #include "freebsd/FreeBSDGNUReplacements.h"
 #endif
 
@@ -389,7 +389,7 @@ void CSAPSessions::Process()
   if(m_socket == INVALID_SOCKET)
     return;
 
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
   unsigned long nonblocking = 1;
   ioctlsocket(m_socket, FIONBIO, &nonblocking);
 #else
index 42f6979..d51ef7b 100644 (file)
 #include <fcntl.h>
 #include <sstream>
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #pragma comment(lib, "ssh.lib")
 #endif
 
-#ifdef TARGET_WINDOWS
+#ifndef S_ISDIR
 #define S_ISDIR(m) ((m & _S_IFDIR) != 0)
+#endif
+#ifndef S_ISREG
 #define S_ISREG(m) ((m & _S_IFREG) != 0)
 #endif
-
-#ifdef _MSC_VER
+#ifndef O_RDONLY
 #define O_RDONLY _O_RDONLY
 #endif
 
index 5bda9a2..ac9d6c7 100644 (file)
@@ -62,14 +62,14 @@ using namespace std;
 
 CSMBDirectory::CSMBDirectory(void)
 {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   smb.AddActiveConnection();
 #endif
 }
 
 CSMBDirectory::~CSMBDirectory(void)
 {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   smb.AddIdleConnection();
 #endif
 }
@@ -401,7 +401,7 @@ bool CSMBDirectory::Exists(const char* strPath)
 CStdString CSMBDirectory::MountShare(const CStdString &smbPath, const CStdString &strType, const CStdString &strName,
     const CStdString &strUser, const CStdString &strPass)
 {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   UnMountShare(strType, strName);
 
   CStdString strMountPoint = GetMountPoint(strType, strName);
@@ -468,7 +468,7 @@ void CSMBDirectory::UnMountShare(const CStdString &strType, const CStdString &st
 
   // Execute command.
   CUtil::Command(args);
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
   CStdString strCmd = "umount " + GetMountPoint(strType, strName);
   CUtil::SudoCommand(strCmd);
 #endif
index d353fa9..87f474f 100644 (file)
@@ -314,7 +314,7 @@ namespace XFILE
   {
     CFileItemList list;
     bool filesExist = false;
-    if (playlistType == "songs" || playlistType == "albums")
+    if (playlistType == "songs" || playlistType == "albums" || playlistType == "artists")
       filesExist = CDirectory::GetDirectory("special://musicplaylists/", list, ".xsp", false);
     else // all others are video
       filesExist = CDirectory::GetDirectory("special://videoplaylists/", list, ".xsp", false);
index f80f3b4..28ce790 100644 (file)
@@ -45,7 +45,7 @@
 #define NT_STATUS_INVALID_HANDLE long(0xC0000000 | 0x0008)
 #define NT_STATUS_ACCESS_DENIED long(0xC0000000 | 0x0022)
 #define NT_STATUS_OBJECT_NAME_NOT_FOUND long(0xC0000000 | 0x0034)
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #define NT_STATUS_INVALID_COMPUTER_NAME long(0xC0000000 | 0x0122)
 #endif
 
@@ -61,7 +61,7 @@ public:
   void Deinit();
   void Purge();
   void PurgeEx(const CURL& url);
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   void CheckIfIdle();
   void SetActivityTime();
   void AddActiveConnection();
@@ -75,7 +75,7 @@ private:
   SMBCCTX *m_context;
   CStdString m_strLastHost;
   CStdString m_strLastShare;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   int m_OpenConnections;
   unsigned int m_IdleTimeout;
 #endif
index 584a3db..46bae17 100644 (file)
@@ -28,7 +28,7 @@
 #include "utils/log.h"
 #include "utils/URIUtils.h"
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include <dirent.h>
 #endif
 
@@ -98,7 +98,7 @@ CStdString CSpecialProtocol::TranslatePath(const CURL &url)
   // check for special-protocol, if not, return
   if (!url.GetProtocol().Equals("special"))
   {
-#if defined(_LINUX) && defined(_DEBUG)
+#if defined(TARGET_POSIX) && defined(_DEBUG)
     CStdString path(url.Get());
     if (path.length() >= 2 && path[1] == ':')
     {
@@ -181,7 +181,7 @@ CStdString CSpecialProtocol::TranslatePathConvertCase(const CStdString& path)
 {
   CStdString translatedPath = TranslatePath(path);
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   if (translatedPath.Find("://") > 0)
     return translatedPath;
 
index 8263360..1e9a5f3 100644 (file)
@@ -75,7 +75,7 @@ private:
   static std::map<CStdString, CStdString> m_pathMap;
 };
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #define PATH_SEPARATOR_CHAR '\\'
 #define PATH_SEPARATOR_STRING "\\"
 #else
index 6544225..f597f5d 100644 (file)
@@ -69,7 +69,7 @@ bool CVTPFile::Open(const CURL& url2)
   {
 
     CStdString channel = path.Mid(9);
-    if(!URIUtils::GetExtension(channel).Equals(".ts"))
+    if(!URIUtils::HasExtension(channel, ".ts"))
     {
       CLog::Log(LOGERROR, "%s - invalid channel url %s", __FUNCTION__, channel.c_str());
       return false;
index e19c8d3..207d44c 100644 (file)
@@ -30,7 +30,7 @@
 #include "storage/MediaManager.h"
 #include "File.h"
 #include "FileItem.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "WIN32Util.h"
 #endif
 
index a64c508..5099b01 100644 (file)
@@ -47,7 +47,7 @@ ISO9660
 #include "threads/SingleLock.h"
 #include "IFile.h"
 
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
 #include "storage/DetectDVDType.h"  // for MODE2_DATA_SIZE etc.
 #endif
 #include <cdio/bytesex.h>
index 3e49517..81bea6b 100644 (file)
@@ -25,7 +25,7 @@
 #include <string>
 #include "system.h" // for win32 types
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 // Ideally we should just be including iso9660.h, but it's not win32-ified at this point,
 // and these are all we need
 typedef uint32_t iso723_t;
index 737440c..fae7a2b 100644 (file)
@@ -22,9 +22,7 @@
 //
 //////////////////////////////////////////////////////////////////////
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 
 #include "filesystem/IFile.h"
 #include "utils/AutoPtrHandle.h"
index 0d312b9..96fd3fd 100644 (file)
@@ -30,7 +30,7 @@
 #include "filesystem/SpecialProtocol.h"
 #include "utils/EndianSwap.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 extern "C" FILE *fopen_utf8(const char *_Filename, const char *_Mode);
 #else
 #define fopen_utf8 fopen
index ee62aa3..f6f6cb2 100644 (file)
@@ -136,7 +136,7 @@ bool IsPalettedFormat(XB_D3DFORMAT format);
 void ParseTextureHeader(D3DTexture *tex, XB_D3DFORMAT &fmt, DWORD &width, DWORD &height, DWORD &pitch, DWORD &offset);
 bool IsSwizzledFormat(XB_D3DFORMAT format);
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 typedef unsigned __int32 uint32_t;
 typedef unsigned __int8 uint8_t;
 typedef __int16 int16_t;
index 6f4d5cd..fe1fa22 100644 (file)
@@ -39,18 +39,6 @@ using namespace std;
 #define SCROLLING_GAP   200U
 #define SCROLLING_THRESHOLD 300U
 
-
-IGUIContainer::IGUIContainer(int parentID, int controlID, float posX, float posY, float width, float height)
-  : CGUIControl(parentID, controlID, posX, posY, width, height)
-{
-}
-
-void IGUIContainer::SetType(VIEW_TYPE type, const CStdString &label)
-{
-  m_type = type;
-  m_label = label;
-}
-
 CGUIBaseContainer::CGUIBaseContainer(int parentID, int controlID, float posX, float posY, float width, float height, ORIENTATION orientation, const CScroller& scroller, int preloadItems)
     : IGUIContainer(parentID, controlID, posX, posY, width, height)
     , m_scroller(scroller)
index d4f3cbe..8dfb68f 100644 (file)
  *
  */
 
-#include "GUIControl.h"
+#include "IGUIContainer.h"
 #include "GUIListItemLayout.h"
-#include "boost/shared_ptr.hpp"
 #include "utils/Stopwatch.h"
 
-typedef boost::shared_ptr<CGUIListItem> CGUIListItemPtr;
-
 /*!
  \ingroup controls
  \brief
  */
 
-class IGUIContainer : public CGUIControl
-{
-protected:
-  VIEW_TYPE m_type;
-  CStdString m_label;
-public:
-  IGUIContainer(int parentID, int controlID, float posX, float posY, float width, float height);
-  virtual bool IsContainer() const { return true; };
-
-  VIEW_TYPE GetType() const { return m_type; };
-  const CStdString &GetLabel() const { return m_label; };
-  void SetType(VIEW_TYPE type, const CStdString &label);
-
-  virtual CGUIListItemPtr GetListItem(int offset, unsigned int flag = 0) const = 0;
-  virtual CStdString GetLabel(int info) const                                  = 0;
-};
-
 class CGUIBaseContainer : public IGUIContainer
 {
 public:
@@ -203,7 +183,16 @@ protected:
    this also marks the control as dirty (if needed)
    */
   void SetOffset(int offset);
+  /*! \brief Returns the index of the first visible row
+   returns the first row. This may be outside of the range of available items. Use GetItemOffset() to retrieve the first visible item in the list.
+   \sa GetItemOffset
+  */
   inline int GetOffset() const { return m_offset; };
+  /*! \brief Returns the index of the first visible item
+   returns the first visible item. This will always be in the range of available items. Use GetOffset() to retrieve the first visible row in the list.
+   \sa GetOffset
+  */
+  inline int GetItemOffset() const { return CorrectOffset(GetOffset(), 0); }
 
 private:
   int m_cursor;
index 9f767db..b2472f1 100644 (file)
@@ -41,6 +41,7 @@ CGUIBorderedImage::~CGUIBorderedImage(void)
 
 void CGUIBorderedImage::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
 {
+  CGUIImage::Process(currentTime, dirtyregions);
   if (!m_borderImage.GetFileName().IsEmpty() && m_texture.ReadyToRender())
   {
     CRect rect = CRect(m_texture.GetXPosition(), m_texture.GetYPosition(), m_texture.GetXPosition() + m_texture.GetWidth(), m_texture.GetYPosition() + m_texture.GetHeight());
@@ -52,7 +53,6 @@ void CGUIBorderedImage::Process(unsigned int currentTime, CDirtyRegionList &dirt
     if (m_borderImage.Process(currentTime))
       MarkDirtyRegion();
   }
-  CGUIImage::Process(currentTime, dirtyregions);
 }
 
 void CGUIBorderedImage::Render()
index 6bf28c1..8d6ed91 100644 (file)
@@ -103,7 +103,7 @@ public:
   {
     GUIEvent<Cookie>::m_pInstance = (GUIEvent<Cookie>*) ((LPVOID) pInstance);
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
     // Its dirty but it works!
     memcpy(&m_pMethod, &aMethodPtr, sizeof(GUIEvent<Cookie>::m_pMethod));
 #else
index 6821cba..e752157 100644 (file)
@@ -255,6 +255,7 @@ bool CGUIControlFactory::GetTexture(const TiXmlNode* pRootNode, const char* strT
   const char *flipY = pNode->Attribute("flipy");
   if (flipY && strcmpi(flipY, "true") == 0) image.orientation = 3 - image.orientation;  // either 3 or 2
   image.diffuse = pNode->Attribute("diffuse");
+  image.diffuseColor.Parse(pNode->Attribute("colordiffuse"), 0);
   const char *background = pNode->Attribute("background");
   if (background && strnicmp(background, "true", 4) == 0)
     image.useLarge = true;
index ea7ef53..57d6649 100644 (file)
@@ -38,7 +38,7 @@ const unsigned int CGUIEditControl::smsDelay = 1000;
 
 using namespace std;
 
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
 extern HWND g_hWnd;
 #endif
 
@@ -584,7 +584,7 @@ void CGUIEditControl::OnPasteClipboard()
     m_cursorPos+=strlen(szStr);
     UpdateText();
   }
-#elif defined _WIN32
+#elif defined TARGET_WINDOWS
   if (OpenClipboard(g_hWnd))
   {
     HGLOBAL hglb = GetClipboardData(CF_TEXT);
index 8ca6ff5..feb9ee1 100644 (file)
@@ -82,7 +82,7 @@ static bool CheckFont(CStdString& strPath, const CStdString& newPath,
   if (!XFILE::CFile::Exists(strPath))
   {
     strPath = URIUtils::AddFileToFolder(newPath,filename);
-#ifdef _LINUX
+#ifdef TARGET_POSIX
     strPath = CSpecialProtocol::TranslatePathConvertCase(strPath);
 #endif
     return false;
@@ -116,7 +116,7 @@ CGUIFont* GUIFontManager::LoadTTF(const CStdString& strFontName, const CStdStrin
   else
     strPath = strFilename;
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   strPath = CSpecialProtocol::TranslatePathConvertCase(strPath);
 #endif
 
@@ -596,11 +596,9 @@ void GUIFontManager::SettingOptionsFontsFiller(const CSetting *setting, std::vec
     {
       CFileItemPtr pItem = items[i];
 
-      if (!pItem->m_bIsFolder)
+      if (!pItem->m_bIsFolder
+          && URIUtils::HasExtension(pItem->GetLabel(), ".ttf"))
       {
-        if (!URIUtils::GetExtension(pItem->GetLabel()).Equals(".ttf"))
-          continue;
-
         list.push_back(make_pair(pItem->GetLabel(), pItem->GetLabel()));
       }
     }
index ef3018c..761248c 100644 (file)
@@ -39,7 +39,7 @@
 
 #define USE_RELEASE_LIBS
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #pragma comment(lib, "freetype246MT.lib")
 #endif
 
index 92807ed..ee3a1d1 100644 (file)
@@ -27,7 +27,7 @@ class CGUIKeyboard;
 enum FILTERING { FILTERING_NONE = 0, FILTERING_CURRENT, FILTERING_SEARCH };
 typedef void (*char_callback_t) (CGUIKeyboard *ref, const std::string &typedString);
 
-#ifdef _WIN32 // disable 4355: 'this' used in base member initializer list
+#ifdef TARGET_WINDOWS // disable 4355: 'this' used in base member initializer list
 #pragma warning(push)
 #pragma warning(disable: 4355)
 #endif
@@ -88,6 +88,6 @@ class CGUIKeyboard : public ITimerCallback
     CTimer m_idleTimer;
 };
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #pragma warning(pop)
 #endif
index e8a03ab..2ca35cf 100644 (file)
@@ -153,6 +153,13 @@ bool CGUILabel::SetAlign(uint32_t align)
   return changed;
 }
 
+bool CGUILabel::SetStyledText(const vecText &text, const vecColors &colors)
+{
+  m_textLayout.UpdateStyled(text, colors, m_maxRect.Width());
+  m_invalid = false;
+  return true;
+}
+
 bool CGUILabel::SetText(const CStdString &label)
 {
   if (m_textLayout.Update(label, m_maxRect.Width(), m_invalid))
index e64171a..2cc9977 100644 (file)
@@ -115,17 +115,25 @@ public:
   /*! \brief Set the text to be displayed in the label
    Updates the label control and recomputes final position and size
    \param text CStdString to set as this labels text
-   \sa SetTextW
+   \sa SetTextW, SetStyledText
    */
   bool SetText(const CStdString &label);
 
   /*! \brief Set the text to be displayed in the label
    Updates the label control and recomputes final position and size
    \param text CStdStringW to set as this labels text
-   \sa SetText
+   \sa SetText, SetStyledText
    */
   bool SetTextW(const CStdStringW &label);
-  
+
+  /*! \brief Set styled text to be displayed in the label
+   Updates the label control and recomputes final position and size
+   \param text styled text to set.
+   \param colors colors referenced in the styled text.
+   \sa SetText, SetTextW
+   */
+  bool SetStyledText(const vecText &text, const vecColors &colors);
+
   /*! \brief Set the color to use for the label
    Sets the color to be used for this label.  Takes effect at the next render
    \param color color to be used for the label
index 6568022..dec06c0 100644 (file)
@@ -132,87 +132,47 @@ void CGUILabelControl::UpdateInfo(const CGUIListItem *item)
 {
   CStdString label(m_infoLabel.GetLabel(m_parentID));
 
-  if (m_startHighlight < m_endHighlight || m_startSelection < m_endSelection)
+  bool changed = false;
+  if (m_startHighlight < m_endHighlight || m_startSelection < m_endSelection || m_bShowCursor)
   {
     CStdStringW utf16;
     g_charsetConverter.utf8ToW(label, utf16);
-
-    std::vector<InsertPointInfo> insertPoints;
-    if (m_bShowCursor)
-    {
-      CStdStringW col;
-      if ((++m_dwCounter % 50) > 25)
-        col.Format(L"[COLOR %x]|[/COLOR]", (color_t)m_label.GetLabelInfo().textColor);
-      else
-        col = L"[COLOR 00FFFFFF]|[/COLOR]";
-      InsertPointInfo info = {m_iCursorPos, InsertPointInfo::HEAD_AND_TAIL, 0, 0, col};
-      insertPoints.push_back(info);
-    }
-    CStdStringW tmp;
-    if (m_startHighlight < m_endHighlight)
-    {
-      if (m_startHighlight > 0 && m_startHighlight <= utf16.size())
-      {
-        tmp.Format(L"[COLOR %x]", (color_t)m_label.GetLabelInfo().disabledColor);
-        InsertPointInfo infoH = {0, InsertPointInfo::HEAD, m_startHighlight, 0, tmp};
-        InsertPointInfo infoT = {m_startHighlight, InsertPointInfo::TAIL, m_startHighlight, 0, L"[/COLOR]"};
-        insertPoints.push_back(infoH);
-        insertPoints.push_back(infoT);
-      }
-      if (m_endHighlight < utf16.size())
-      {
-        tmp.Format(L"[COLOR %x]", (color_t)m_label.GetLabelInfo().disabledColor);
-        InsertPointInfo infoH = {m_endHighlight, InsertPointInfo::HEAD, utf16.size() - m_endHighlight, 0, tmp};
-        InsertPointInfo infoT = {utf16.size(), InsertPointInfo::TAIL, utf16.size() - m_endHighlight, 0, L"[/COLOR]"};
-        insertPoints.push_back(infoH);
-        insertPoints.push_back(infoT);
-      }
-    }
-    if (m_startSelection < m_endSelection && m_endSelection <= utf16.size())
+    vecText text; text.reserve(utf16.size()+1);
+    vecColors colors;
+    colors.push_back(m_label.GetLabelInfo().textColor);
+    colors.push_back(m_label.GetLabelInfo().disabledColor);
+    color_t select = m_label.GetLabelInfo().selectedColor;
+    if (!select)
+      select = 0xFFFF0000;
+    colors.push_back(select);
+    colors.push_back(0xFF000000);
+    for (unsigned int i = 0; i < utf16.size(); i++)
     {
-      color_t selectedColor = m_label.GetLabelInfo().selectedColor;
-      if (!selectedColor)
-        selectedColor = 0xFFFFFF00;
-      tmp.Format(L"[COLOR %x]", selectedColor);
-      // we set selection insert point higher priority than the highlight disable block, so it is still show the selection
-      InsertPointInfo infoH = {m_startSelection, InsertPointInfo::HEAD, m_startSelection - m_endSelection, 1, tmp};
-      InsertPointInfo infoT = {m_endSelection, InsertPointInfo::TAIL, m_startSelection - m_endSelection, 1, L"[/COLOR]"};
-      insertPoints.push_back(infoH);
-      insertPoints.push_back(infoT);
+      unsigned int ch = utf16[i];
+      if ((m_startSelection < m_endSelection) && (m_startSelection <= i && i < m_endSelection))
+        ch |= (2 << 16);
+      else if ((m_startHighlight < m_endHighlight) && (i < m_startHighlight || i >= m_endHighlight))
+        ch |= (1 << 16);
+      text.push_back(ch);
     }
-
-    // we sort the insert points to make sure small color block is nested in larger block
-    std::sort(insertPoints.begin(), insertPoints.end());
-
-    // insert the styles from back to front, so we can use the correct insert points.
-    for (int i = insertPoints.size() - 1; i >= 0; --i)
+    if (m_bShowCursor && m_iCursorPos >= 0 && (unsigned int)m_iCursorPos <= utf16.size())
     {
-      const InsertPointInfo &insertPointInfo = insertPoints[i];
-      utf16.Insert(insertPointInfo.pos, insertPointInfo.text);
+      unsigned int ch = L'|';
+      if ((++m_dwCounter % 50) <= 25)
+        ch |= (3 << 16);
+      text.insert(text.begin() + m_iCursorPos, ch);
     }
-    g_charsetConverter.wToUTF8(utf16, label);
+    changed |= m_label.SetMaxRect(m_posX, m_posY, GetWidth(), m_height);
+    changed |= m_label.SetStyledText(text, colors);
   }
-  else if (m_bShowCursor)
-  { // cursor location assumes utf16 text, so deal with that (inefficient, but it's not as if it's a high-use area
-    // virtual keyboard only)
-    CStdStringW utf16;
-    g_charsetConverter.utf8ToW(label, utf16);
-    CStdStringW col;
-    if ((++m_dwCounter % 50) > 25)
-      col = L"|";
-    else
-      col = L"[COLOR 00FFFFFF]|[/COLOR]";
-    utf16.Insert(m_iCursorPos, col);
-    g_charsetConverter.wToUTF8(utf16, label);
-  }
-  else if (m_bHasPath)
-    label = ShortenPath(label);
-
-  bool changed = false;
-
-  changed |= m_label.SetMaxRect(m_posX, m_posY, GetWidth(), m_height);
-  changed |= m_label.SetText(label);
+  else
+  {
+    if (m_bHasPath)
+      label = ShortenPath(label);
 
+    changed |= m_label.SetMaxRect(m_posX, m_posY, GetWidth(), m_height);
+    changed |= m_label.SetText(label);
+  }
   if (changed)
     MarkDirtyRegion();
 }
index 49c0459..491eecd 100644 (file)
@@ -223,24 +223,28 @@ bool CGUITextLayout::UpdateW(const CStdStringW &text, float maxWidth /*= 0*/, bo
   if (text.Equals(m_lastText) && !forceUpdate)
     return false;
 
+  // parse the text for style information
   vecText parsedText;
+  vecColors colors;
+  ParseText(text, m_font ? m_font->GetStyle() : 0, m_textColor, colors, parsedText);
+
+  // and update
+  UpdateStyled(parsedText, colors, maxWidth, forceLTRReadingOrder);
+  m_lastText = text;
+  return true;
+}
 
+void CGUITextLayout::UpdateStyled(const vecText &text, const vecColors &colors, float maxWidth, bool forceLTRReadingOrder)
+{
   // empty out our previous string
   m_lines.clear();
-  m_colors.clear();
-  m_colors.push_back(m_textColor);
-
-  // parse the text into our string objects
-  ParseText(text, parsedText);
-
-  // add \n to the end of the string
-  parsedText.push_back(L'\n');
+  m_colors = colors;
 
   // if we need to wrap the text, then do so
   if (m_wrap && maxWidth > 0)
-    WrapText(parsedText, maxWidth);
+    WrapText(text, maxWidth);
   else
-    LineBreakText(parsedText, m_lines);
+    LineBreakText(text, m_lines);
 
   // remove any trailing blank lines
   while (!m_lines.empty() && m_lines.back().m_text.empty())
@@ -250,9 +254,6 @@ bool CGUITextLayout::UpdateW(const CStdStringW &text, float maxWidth /*= 0*/, bo
 
   // and cache the width and height for later reading
   CalcTextExtent();
-
-  m_lastText = text;
-  return true;
 }
 
 // BidiTransform is used to handle RTL text flipping in the string
@@ -316,21 +317,14 @@ void CGUITextLayout::Filter(CStdString &text)
   utf8ToW(text, utf16);
   vecColors colors;
   vecText parsedText;
-  ParseText(utf16, 0, colors, parsedText);
+  ParseText(utf16, 0, 0xffffffff, colors, parsedText);
   utf16.Empty();
   for (unsigned int i = 0; i < parsedText.size(); i++)
     utf16 += (wchar_t)(0xffff & parsedText[i]);
   g_charsetConverter.wToUTF8(utf16, text);
 }
 
-void CGUITextLayout::ParseText(const CStdStringW &text, vecText &parsedText)
-{
-  if (!m_font)
-    return;
-  ParseText(text, m_font->GetStyle(), m_colors, parsedText);
-}
-
-void CGUITextLayout::ParseText(const CStdStringW &text, uint32_t defaultStyle, vecColors &colors, vecText &parsedText)
+void CGUITextLayout::ParseText(const CStdStringW &text, uint32_t defaultStyle, color_t defaultColor, vecColors &colors, vecText &parsedText)
 {
   // run through the string, searching for:
   // [B] or [/B] -> toggle bold on and off
@@ -341,6 +335,7 @@ void CGUITextLayout::ParseText(const CStdStringW &text, uint32_t defaultStyle, v
   uint32_t currentStyle = defaultStyle; // start with the default font's style
   color_t currentColor = 0;
 
+  colors.push_back(defaultColor);
   stack<color_t> colorStack;
   colorStack.push(0);
 
@@ -562,6 +557,12 @@ void CGUITextLayout::LineBreakText(const vecText &text, vector<CGUIString> &line
     }
     pos++;
   }
+  // handle the last line if non-empty
+  if (lineStart < text.end() && (nMaxLines <= 0 || lines.size() < (size_t)nMaxLines))
+  {
+    CGUIString string(lineStart, text.end(), true);
+    lines.push_back(string);
+  }
 }
 
 void CGUITextLayout::GetTextExtent(float &width, float &height) const
index 857bb64..615987d 100644 (file)
@@ -88,6 +88,15 @@ public:
   bool Update(const CStdString &text, float maxWidth = 0, bool forceUpdate = false, bool forceLTRReadingOrder = false);
   bool UpdateW(const CStdStringW &text, float maxWidth = 0, bool forceUpdate = false, bool forceLTRReadingOrder = false);
 
+  /*! \brief Update text from a pre-styled vecText/vecColors combination
+   Allows styled text to be passed directly to the text layout.
+   \param text the styled text to set.
+   \param colors the colors used on the text.
+   \param maxWidth the maximum width for wrapping text, defaults to 0 (no max width).
+   \param forceLTRReadingOrder whether to force left to right reading order, defaults to false.
+   */
+  void UpdateStyled(const vecText &text, const vecColors &colors, float maxWidth = 0, bool forceLTRReadingOrder = false);
+
   unsigned int GetTextLength() const;
   void GetFirstText(vecText &text) const;
   void Reset();
@@ -100,7 +109,6 @@ public:
   static void Filter(CStdString &text);
 
 protected:
-  void ParseText(const CStdStringW &text, vecText &parsedText);
   void LineBreakText(const vecText &text, std::vector<CGUIString> &lines);
   void WrapText(const vecText &text, float maxWidth);
   void BidiTransform(std::vector<CGUIString> &lines, bool forceLTRReadingOrder);
@@ -136,7 +144,7 @@ private:
   };
   static void AppendToUTF32(const CStdString &utf8, character_t colStyle, vecText &utf32);
   static void AppendToUTF32(const CStdStringW &utf16, character_t colStyle, vecText &utf32);
-  static void ParseText(const CStdStringW &text, uint32_t defaultStyle, vecColors &colors, vecText &parsedText);
+  static void ParseText(const CStdStringW &text, uint32_t defaultStyle, color_t defaultColor, vecColors &colors, vecText &parsedText);
 
   static void utf8ToW(const CStdString &utf8, CStdStringW &utf16);
 };
index 5896606..8df3d22 100644 (file)
@@ -46,6 +46,7 @@ CTextureInfo& CTextureInfo::operator=(const CTextureInfo &right)
   diffuse = right.diffuse;
   filename = right.filename;
   useLarge = right.useLarge;
+  diffuseColor = right.diffuseColor;
 
   return *this;
 }
@@ -174,8 +175,12 @@ void CGUITextureBase::Render()
 
   // set our draw color
   #define MIX_ALPHA(a,c) (((a * (c >> 24)) / 255) << 24) | (c & 0x00ffffff)
-  color_t color = m_diffuseColor;
-  if (m_alpha != 0xFF) color = MIX_ALPHA(m_alpha, m_diffuseColor);
+
+  // diffuse color
+  color_t color = (m_info.diffuseColor) ? (color_t)m_info.diffuseColor : m_diffuseColor;
+  if (m_alpha != 0xFF)
+         color = MIX_ALPHA(m_alpha, color);
+
   color = g_graphicsContext.MergeAlpha(color);
 
   // setup our renderer
@@ -542,6 +547,7 @@ bool CGUITextureBase::SetDiffuseColor(color_t color)
 {
   bool changed = m_diffuseColor != color;
   m_diffuseColor = color;
+  changed |= m_info.diffuseColor.Update();
   return changed;
 }
 
index 89cf214..a49807c 100644 (file)
@@ -31,6 +31,7 @@
 #include "TextureManager.h"
 #include "Geometry.h"
 #include "system.h" // HAS_GL, HAS_DX, etc
+#include "GUIInfoTypes.h"
 
 typedef uint32_t color_t;
 
@@ -74,10 +75,11 @@ public:
   CTextureInfo(const CStdString &file);
   CTextureInfo& operator=(const CTextureInfo &right);
   bool       useLarge;
-  CRect      border;      // scaled  - unneeded if we get rid of scale on load
-  int        orientation; // orientation of the texture (0 - 7 == EXIForientation - 1)
-  CStdString diffuse;     // diffuse overlay texture
-  CStdString filename;    // main texture file
+  CRect      border;          // scaled  - unneeded if we get rid of scale on load
+  int        orientation;     // orientation of the texture (0 - 7 == EXIForientation - 1)
+  CStdString diffuse;         // diffuse overlay texture
+  CGUIInfoColor diffuseColor; // diffuse color
+  CStdString filename;        // main texture file
 };
 
 class CGUITextureBase
index 72daf4d..23e9f42 100644 (file)
@@ -388,7 +388,7 @@ void CGraphicContext::SetVideoResolution(RESOLUTION res, bool forceUpdate)
 
   if (g_advancedSettings.m_fullScreen)
   {
-#if defined (TARGET_DARWIN) || defined (_WIN32)
+#if defined (TARGET_DARWIN) || defined (TARGET_WINDOWS)
     bool blankOtherDisplays = CSettings::Get().GetBool("videoscreen.blankdisplays");
     g_Windowing.SetFullScreen(true,  CDisplaySettings::Get().GetResolutionInfo(res), blankOtherDisplays);
 #else
diff --git a/xbmc/guilib/IGUIContainer.h b/xbmc/guilib/IGUIContainer.h
new file mode 100644 (file)
index 0000000..42427fe
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ *      Copyright (C) 2005-2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#pragma once
+
+#include "GUIControl.h"
+#include "boost/shared_ptr.hpp"
+
+typedef boost::shared_ptr<CGUIListItem> CGUIListItemPtr;
+
+/*!
+ \ingroup controls
+ \brief
+ */
+
+class IGUIContainer : public CGUIControl
+{
+protected:
+  VIEW_TYPE m_type;
+  CStdString m_label;
+public:
+  IGUIContainer(int parentID, int controlID, float posX, float posY, float width, float height)
+   : CGUIControl(parentID, controlID, posX, posY, width, height), m_type(VIEW_TYPE_NONE) {}
+
+  virtual bool IsContainer() const { return true; };
+
+  VIEW_TYPE GetType() const { return m_type; };
+  const CStdString &GetLabel() const { return m_label; };
+  void SetType(VIEW_TYPE type, const CStdString &label)
+  {
+    m_type = type;
+    m_label = label;
+  }
+
+  virtual CGUIListItemPtr GetListItem(int offset, unsigned int flag = 0) const = 0;
+  virtual CStdString GetLabel(int info) const                                  = 0;
+};
index 0dda500..3b46d0f 100644 (file)
@@ -215,9 +215,8 @@ CBaseTexture *CBaseTexture::LoadFromFileInMemory(unsigned char *buffer, size_t b
 bool CBaseTexture::LoadFromFileInternal(const CStdString& texturePath, unsigned int maxWidth, unsigned int maxHeight, bool autoRotate)
 {
 #if defined(HAS_OMXPLAYER)
-  if (URIUtils::GetExtension(texturePath).Equals(".jpg") || 
-      URIUtils::GetExtension(texturePath).Equals(".tbn") 
-      /*|| URIUtils::GetExtension(texturePath).Equals(".png")*/)
+  if (URIUtils::HasExtension(texturePath, ".jpg|.tbn")
+      /*|| URIUtils::HasExtension(texturePath, ".png")*/)
   {
     COMXImage omx_image;
 
@@ -281,7 +280,7 @@ bool CBaseTexture::LoadFromFileInternal(const CStdString& texturePath, unsigned
     omx_image.ClampLimits(maxWidth, maxHeight);
   }
 #endif
-  if (URIUtils::GetExtension(texturePath).Equals(".dds"))
+  if (URIUtils::HasExtension(texturePath, ".dds"))
   { // special case for DDS images
     CDDSImage image;
     if (image.ReadFile(texturePath))
index ce366c2..c2a31b4 100644 (file)
@@ -32,7 +32,7 @@
 #include "XBTF.h"
 #include <lzo/lzo1x.h>
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #pragma comment(lib,"liblzo2.lib")
 #endif
 
index 20b50b5..7713874 100644 (file)
@@ -24,7 +24,7 @@
 #include "GraphicContext.h"
 #include "DirectXGraphics.h"
 #include "utils/log.h"
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #include <sys/stat.h>
 #include "utils/CharsetConverter.h"
 #endif
@@ -35,7 +35,7 @@
 #include "utils/EndianSwap.h"
 #include "utils/URIUtils.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #pragma comment(lib,"liblzo2.lib")
 #endif
 
@@ -140,7 +140,7 @@ bool CTextureBundleXPR::OpenBundle()
 
   strPath = CSpecialProtocol::TranslatePathConvertCase(strPath);
 
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   CStdStringW strPathW;
   g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(strPath), strPathW, false);
   m_hFile = _wfopen(strPathW.c_str(), L"rb");
@@ -278,13 +278,13 @@ bool CTextureBundleXPR::LoadFile(const CStdString& Filename, CAutoTexBuffer& Unp
 
   if (!buffer || !UnpackedBuf.Set((BYTE*)XPhysicalAlloc(file->second.UnpackedSize, MAXULONG_PTR, 128, PAGE_READWRITE)))
   { // failed due to lack of memory
-#ifndef _LINUX
+#ifndef TARGET_POSIX
     MEMORYSTATUSEX stat;
     stat.dwLength = sizeof(MEMORYSTATUSEX);
     GlobalMemoryStatusEx(&stat);
     CLog::Log(LOGERROR, "Out of memory loading texture: %s (need %lu bytes, have %"PRIu64" bytes)", name.c_str(),
               file->second.UnpackedSize + file->second.PackedSize, stat.ullAvailPhys);
-#elif defined(TARGET_DARWIN) || defined(__FreeBSD__)
+#elif defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
     CLog::Log(LOGERROR, "Out of memory loading texture: %s (need %d bytes)", name.c_str(),
               file->second.UnpackedSize + file->second.PackedSize);
 #else
index ee5459c..7f20174 100644 (file)
@@ -22,7 +22,7 @@
 #include "XBTFReader.h"
 #include "utils/EndianSwap.h"
 #include "utils/CharsetConverter.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "FileSystem/SpecialProtocol.h"
 #endif
 
@@ -57,7 +57,7 @@ bool CXBTFReader::Open(const CStdString& fileName)
 {
   m_fileName = fileName;
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   CStdStringW strPathW;
   g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(m_fileName), strPathW, false);
   m_file = _wfopen(strPathW.c_str(), L"rb");
@@ -188,7 +188,7 @@ bool CXBTFReader::Load(const CXBTFFrame& frame, unsigned char* buffer)
   {
     return false;
   }
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
     if (fseeko(m_file, (off_t)frame.GetOffset(), SEEK_SET) == -1)
 #else
     if (fseeko64(m_file, (off_t)frame.GetOffset(), SEEK_SET) == -1)
index 5c38b05..9a73f07 100644 (file)
@@ -27,7 +27,7 @@
  *
  */
 
-#include "system.h" // for WIN32 types
+#include "system.h" // for TARGET_WINDOWS types
 
 #define GAMMA_RAMP_FLAG  D3DSGR_CALIBRATE
 
index d4ff71d..185e805 100644 (file)
@@ -405,7 +405,7 @@ static const WindowMapping fallbackWindows[] =
   { WINDOW_DIALOG_FULLSCREEN_INFO,     WINDOW_FULLSCREEN_VIDEO }
 };
 
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
 static const ActionMapping appcommands[] =
 {
   { "browser_back",        APPCOMMAND_BROWSER_BACKWARD },
@@ -559,7 +559,7 @@ bool CButtonTranslator::Load(bool AlwaysLoad)
   }
 
 #if defined(HAS_LIRC) || defined(HAS_IRSERVERSUITE)
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #define REMOTEMAP "Lircmap.xml"
 #else
 #define REMOTEMAP "IRSSmap.xml"
@@ -635,7 +635,7 @@ bool CButtonTranslator::LoadKeymap(const CStdString &keymapPath)
 #if defined(HAS_LIRC) || defined(HAS_IRSERVERSUITE)
 bool CButtonTranslator::LoadLircMap(const CStdString &lircmapPath)
 {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #define REMOTEMAPTAG "lircmap"
 #else
 #define REMOTEMAPTAG "irssmap"
@@ -1015,7 +1015,7 @@ int CButtonTranslator::GetActionCode(int window, const CKey &key, CStdString &st
     strAction = (*it2).second.strID;
     it2 = (*it).second.end();
   }
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   // Some buttoncodes changed in Hardy
   if (action == 0 && (code & KEY_VKEY) == KEY_VKEY && (code & 0x0F00))
   {
@@ -1409,7 +1409,7 @@ uint32_t CButtonTranslator::TranslateKeyboardButton(TiXmlElement *pButton)
 
 uint32_t CButtonTranslator::TranslateAppCommand(const char *szButton)
 {
-#ifdef WIN32
+#ifdef TARGET_WINDOWS
   CStdString strAppCommand = szButton;
   strAppCommand.ToLower();
 
index e94862a..93d0997 100644 (file)
@@ -24,9 +24,9 @@
 // Comment OUT, if not really debugging!!!
 // #define DEBUG_KEYBOARD_GETCHAR
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "linux/PlatformDefs.h"
-#elif defined (WIN32)
+#elif defined (TARGET_WINDOWS)
 #include "windows.h"
 #else
 #include "xtl.h"
index 6685e7f..487affd 100644 (file)
 // maximum time between touch down and up (in nanoseconds)
 #define SWIPE_MAX_TIME            500000000
 // maxmium swipe distance between touch down and up (in multiples of screen DPI)
-#define SWIPE_MIN_DISTANCE        0.5
+#define SWIPE_MIN_DISTANCE        0.5f
 // original maximum variance of the touch movement
-#define SWIPE_MAX_VARIANCE        0.2
+#define SWIPE_MAX_VARIANCE        0.2f
 // tangens of the maximum angle (20 degrees) the touch movement may vary in a
 // direction perpendicular to the swipe direction (in radians)
 // => tan(20 deg) = tan(20 * M_PI / 180)
-#define SWIPE_MAX_VARIANCE_ANGLE  0.363970234266
+#define SWIPE_MAX_VARIANCE_ANGLE  0.36397023f
 
 CGenericTouchSwipeDetector::CGenericTouchSwipeDetector(ITouchActionHandler *handler, float dpi)
   : IGenericTouchGestureDetector(handler, dpi),
index 28fdc7a..57f83db 100644 (file)
@@ -123,10 +123,12 @@ const BUILT_IN commands[] = {
   { "Suspend",                    false,  "Suspends the system" },
   { "InhibitIdleShutdown",        false,  "Inhibit idle shutdown" },
   { "AllowIdleShutdown",          false,  "Allow idle shutdown" },
+  { "ActivateScreensaver",        false,  "Activate Screensaver" },
   { "RestartApp",                 false,  "Restart XBMC" },
   { "Minimize",                   false,  "Minimize XBMC" },
   { "Reset",                      false,  "Reset the system (same as reboot)" },
   { "Mastermode",                 false,  "Control master mode" },
+  { "SetGUILanguage",             true,   "Set GUI Language" },
   { "ActivateWindow",             true,   "Activate the specified window" },
   { "ActivateWindowAndFocus",     true,   "Activate the specified window and sets focus to the specified id" },
   { "ReplaceWindowAndFocus",      true,   "Replaces the current window with the new one and sets focus to the specified id" },
@@ -291,6 +293,10 @@ int CBuiltins::Execute(const CStdString& execString)
     bool inhibit = (params.size() == 1 && params[0].Equals("true"));
     CApplicationMessenger::Get().InhibitIdleShutdown(inhibit);
   }
+  else if (execute.Equals("activatescreensaver"))
+  {
+    CApplicationMessenger::Get().ActivateScreensaver();
+  }
   else if (execute.Equals("minimize"))
   {
     CApplicationMessenger::Get().Minimize();
@@ -326,6 +332,13 @@ int CBuiltins::Execute(const CStdString& execString)
     CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE);
     g_windowManager.SendMessage(msg);
   }
+  else if (execute.Equals("setguilanguage"))
+  {
+    if (params.size())
+    {
+      CApplicationMessenger::Get().SetGUILanguage(params[0]);
+    }
+  }
   else if (execute.Equals("takescreenshot"))
   {
     CScreenShot::TakeScreenshot();
@@ -375,7 +388,7 @@ int CBuiltins::Execute(const CStdString& execString)
     {
       // disable the screensaver
       g_application.WakeUpScreenSaverAndDPMS();
-#if defined(__APPLE__) && defined(__arm__)
+#if defined(TARGET_DARWIN_IOS)
       if (params[0].Equals("shutdownmenu"))
         CBuiltins::Execute("Quit");
 #endif
@@ -401,8 +414,7 @@ int CBuiltins::Execute(const CStdString& execString)
   else if (execute.Equals("runscript") && params.size())
   {
 #if defined(TARGET_DARWIN_OSX)
-    if (URIUtils::GetExtension(strParameterCaseIntact) == ".applescript" ||
-        URIUtils::GetExtension(strParameterCaseIntact) == ".scpt")
+    if (URIUtils::HasExtension(strParameterCaseIntact, ".applescript|.scpt"))
     {
       CStdString osxPath = CSpecialProtocol::TranslatePath(strParameterCaseIntact);
       Cocoa_DoAppleScriptFile(osxPath.c_str());
index e74957f..2f39d6c 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 #include "FavouritesOperations.h"
-#include "Favourites.h"
+#include "filesystem/FavouritesDirectory.h"
 #include "input/ButtonTranslator.h"
 #include "utils/RegExp.h"
 #include "utils/StringUtils.h"
 
 using namespace std;
 using namespace JSONRPC;
+using namespace XFILE;
 
 JSONRPC_STATUS CFavouritesOperations::GetFavourites(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
 {
   CFileItemList favourites;
-  CFavourites::Load(favourites);
+  CFavouritesDirectory::Load(favourites);
   
   string type = !parameterObject["type"].isNull() ? parameterObject["type"].asString() : "";
 
@@ -158,7 +159,7 @@ JSONRPC_STATUS CFavouritesOperations::AddFavourite(const CStdString &method, ITr
   if (ParameterNotNull(parameterObject,"thumbnail"))
     item.SetArt("thumb", parameterObject["thumbnail"].asString());
 
-  if (CFavourites::AddOrRemove(&item, contextWindow))
+  if (CFavouritesDirectory::AddOrRemove(&item, contextWindow))
     return ACK;
   else
     return FailedToExecute;
index 9052494..87d6ad1 100644 (file)
 #include "Util.h"
 #include "URL.h"
 #include "utils/URIUtils.h"
+#include "utils/FileUtils.h"
 
 using namespace XFILE;
 using namespace JSONRPC;
 
-static const unsigned int SourcesSize = 5;
-static CStdString SourceNames[] = { "programs", "files", "video", "music", "pictures" };
-
 JSONRPC_STATUS CFileOperations::GetRootDirectory(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
 {
   CStdString media = parameterObject["media"].asString();
@@ -82,15 +80,8 @@ JSONRPC_STATUS CFileOperations::GetDirectory(const CStdString &method, ITranspor
   CFileItemList items;
   CStdString strPath = parameterObject["directory"].asString();
 
-  // Check if this directory is part of a source and whether it's locked
-  bool isSource;
-  for (unsigned int index = 0; index < SourcesSize; index++)
-  {
-    VECSOURCES* sources = CMediaSourceSettings::Get().GetSources(SourceNames[index]);
-    int sourceIndex = CUtil::GetMatchingSource(strPath, *sources, isSource);
-    if (sourceIndex >= 0 && sourceIndex < (int)sources->size() && sources->at(sourceIndex).m_iHasLock == 2)
-      return InvalidParams;
-  }
+  if (!CFileUtils::RemoteAccessAllowed(strPath))
+    return InvalidParams;
 
   CStdStringArray regexps;
   CStdString extensions = "";
@@ -180,6 +171,9 @@ JSONRPC_STATUS CFileOperations::GetFileDetails(const CStdString &method, ITransp
   if (!CFile::Exists(file))
     return InvalidParams;
 
+  if (!CFileUtils::RemoteAccessAllowed(file))
+    return InvalidParams;
+
   CStdString path;
   URIUtils::GetDirectory(file, path);
 
index 2e31724..292c425 100644 (file)
@@ -43,6 +43,7 @@
 #include "pvr/channels/PVRChannel.h"
 #include "pvr/channels/PVRChannelGroupsContainer.h"
 #include "cores/IPlayer.h"
+#include "settings/MediaSettings.h"
 
 using namespace JSONRPC;
 using namespace PLAYLIST;
@@ -1438,7 +1439,7 @@ JSONRPC_STATUS CPlayerOperations::GetPropertyValue(PlayerType player, const CStd
         if (g_application.m_pPlayer)
         {
           result = CVariant(CVariant::VariantTypeObject);
-          int index = g_application.m_pPlayer->GetSubtitle();
+          int index = CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream;
           if (index >= 0)
           {
             SPlayerSubtitleStreamInfo info;
index ad9182b..52b563a 100644 (file)
@@ -236,7 +236,7 @@ namespace XBMCAddon
       return value;
     }
 
-    void Dialog::notification(const String& heading, const String& message, const String& icon, int time)
+    void Dialog::notification(const String& heading, const String& message, const String& icon, int time, bool sound)
     {
       DelayedCallGuard dcguard(languageHook);
 
@@ -249,13 +249,13 @@ namespace XBMCAddon
         strIcon = icon;
       
       if (strIcon.Equals(getNOTIFICATION_INFO()))
-        CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, heading, message, iTime);
+        CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, heading, message, iTime, sound);
       else if (strIcon.Equals(getNOTIFICATION_WARNING()))
-        CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Warning, heading, message, iTime);
+        CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Warning, heading, message, iTime, sound);
       else if (strIcon.Equals(getNOTIFICATION_ERROR()))
-        CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, heading, message, iTime);
+        CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, heading, message, iTime, sound);
       else
-        CGUIDialogKaiToast::QueueNotification(strIcon, heading, message, iTime);
+        CGUIDialogKaiToast::QueueNotification(strIcon, heading, message, iTime, sound);
     }
     
     DialogProgress::~DialogProgress() { TRACE; deallocating(); }
index 109edc9..b96d906 100644 (file)
@@ -219,12 +219,13 @@ namespace XBMCAddon
       String numeric(int type, const String& heading, const String& defaultt = emptyString);
       
       /**
-       * notification(heading, message[, icon, time]) -- Show a Notification alert.
+       * notification(heading, message[, icon, time, sound]) -- Show a Notification alert.
        * 
        * heading        : string - dialog heading.
        * message        : string - dialog message.
        * icon           : [opt] string - icon to use. (default xbmcgui.NOTIFICATION_INFO)
        * time           : [opt] integer - time in milliseconds (default 5000)
+       * sound          : [opt] bool - play notification sound (default True)
        * 
        * Builtin Icons:
        *   xbmcgui.NOTIFICATION_INFO
@@ -235,7 +236,7 @@ namespace XBMCAddon
        *   - dialog = xbmcgui.Dialog()
        *   - dialog.notification('Movie Trailers', 'Finding Nemo download finished.', xbmcgui.NOTIFICATION_INFO, 5000)\n
        */
-      void notification(const String& heading, const String& message, const String& icon = emptyString, int time = 0);
+      void notification(const String& heading, const String& message, const String& icon = emptyString, int time = 0, bool sound = true);
     };
 
     /**
index 41c3b39..860623b 100644 (file)
@@ -21,7 +21,7 @@
 
 // TODO: Need a uniform way of returning an error status
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 #include "network/Network.h"
index ed7887f..9103f13 100644 (file)
@@ -30,6 +30,7 @@
 #include "AddonUtils.h"
 #include "utils/log.h"
 #include "cores/IPlayer.h"
+#include "settings/MediaSettings.h"
 
 namespace XBMCAddon
 {
@@ -396,7 +397,7 @@ namespace XBMCAddon
       if (g_application.m_pPlayer)
       {
         SPlayerSubtitleStreamInfo info;
-        g_application.m_pPlayer->GetSubtitleStreamInfo(g_application.m_pPlayer->GetSubtitle(), info);
+        g_application.m_pPlayer->GetSubtitleStreamInfo(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream, info);
 
         if (info.language.length() > 0)
           return info.language;
index 8ada5b3..0a3c03b 100644 (file)
@@ -61,7 +61,7 @@ namespace XBMCAddon
        *  the call will wrongly proceed back to the xbmc core side rather than
        *  to the Addon API side.
        */  
-      bool up() { bool ret = (upcallTls.get() != NULL); upcallTls.set(NULL); return ret; }
+      static bool up() { bool ret = (upcallTls.get() != NULL); upcallTls.set(NULL); return ret; }
     public:
 
       virtual ~InterceptorBase() { if (window.isNotNull()) { window->interceptorClear(); } }
index 6de431f..fd668b5 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "WindowInterceptor.h"
 #include "guilib/GUIWindowManager.h"
+#include "guilib/TextureManager.h"
 #include "settings/Settings.h"
 #include "addons/Skin.h"
 #include "filesystem/File.h"
index e189883..e1ca2ae 100644 (file)
@@ -21,7 +21,7 @@
 
 #pragma once
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 
index 238fb9d..69361c8 100644 (file)
@@ -19,7 +19,7 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 
@@ -54,7 +54,7 @@
 #include "utils/CharsetConverter.h"
 #include "PyContext.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 extern "C" FILE *fopen_utf8(const char *_Filename, const char *_Mode);
 #else
 #define fopen_utf8 fopen
index 4d78a45..3a95293 100644 (file)
@@ -19,7 +19,7 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 
@@ -41,6 +41,9 @@
 #include "utils/TimeUtils.h"
 #include "Util.h"
 #include "guilib/GraphicContext.h"
+#ifdef TARGET_WINDOWS
+#include "utils/Environment.h"
+#endif
 
 #include "threads/SystemClock.h"
 #include "addons/Addon.h"
@@ -466,7 +469,7 @@ void XBPython::Initialize()
   if (!m_bInitialized)
   {
       // first we check if all necessary files are installed
-#ifndef _LINUX
+#ifndef TARGET_POSIX
       if(!FileExist("special://xbmc/system/python/DLLs/_socket.pyd") ||
         !FileExist("special://xbmc/system/python/DLLs/_ssl.pyd") ||
         !FileExist("special://xbmc/system/python/DLLs/bz2.pyd") ||
@@ -488,7 +491,7 @@ void XBPython::Initialize()
       // Info about interesting python envvars available
       // at http://docs.python.org/using/cmdline.html#environment-variables
 
-#if !defined(_WIN32) && !defined(TARGET_ANDROID)
+#if !defined(TARGET_WINDOWS) && !defined(TARGET_ANDROID)
       /* 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,
@@ -504,20 +507,18 @@ void XBPython::Initialize()
         CLog::Log(LOGDEBUG, "PYTHONPATH -> %s", CSpecialProtocol::TranslatePath("special://frameworks").c_str());
       }
       setenv("PYTHONCASEOK", "1", 1); //This line should really be removed
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
       // because the third party build of python is compiled with vs2008 we need
       // a hack to set the PYTHONPATH
-      // buf is corrupted after putenv and might need a strdup but it seems to
-      // work this way
       CStdString buf;
       buf = "PYTHONPATH=" + CSpecialProtocol::TranslatePath("special://xbmc/system/python/DLLs") + ";" + CSpecialProtocol::TranslatePath("special://xbmc/system/python/Lib");
-      pgwin32_putenv(buf.c_str());
+      CEnvironment::putenv(buf);
       buf = "PYTHONOPTIMIZE=1";
-      pgwin32_putenv(buf.c_str());
+      CEnvironment::putenv(buf);
       buf = "PYTHONHOME=" + CSpecialProtocol::TranslatePath("special://xbmc/system/python");
-      pgwin32_putenv(buf.c_str());
+      CEnvironment::putenv(buf);
       buf = "OS=win32";
-      pgwin32_putenv(buf.c_str());
+      CEnvironment::putenv(buf);
 
 #elif defined(TARGET_ANDROID)
       CStdString apkPath = getenv("XBMC_ANDROID_APK");
@@ -589,15 +590,15 @@ void XBPython::Finalize()
       PyEval_ReleaseLock();
     }
 
-#if !(defined(TARGET_DARWIN) || defined(_WIN32))
+#if !(defined(TARGET_DARWIN) || defined(TARGET_WINDOWS))
     UnloadExtensionLibs();
 #endif
 
     // first free all dlls loaded by python, after that python24.dll (this is done by UnloadPythonDlls
-#if !(defined(TARGET_DARWIN) || defined(_WIN32))
+#if !(defined(TARGET_DARWIN) || defined(TARGET_WINDOWS))
     DllLoaderContainer::UnloadPythonDlls();
 #endif
-#if defined(_LINUX) && !defined(__APPLE__) && !defined(__FreeBSD__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD)
     // we can't release it on windows, as this is done in UnloadPythonDlls() for win32 (see above).
     // The implementation for linux needs looking at - UnloadPythonDlls() currently only searches for "python24.dll"
     // The implementation for osx can never unload the python dylib.
index 9fafd48..cbf87b9 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "PlatformDefs.h"
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 
 #include <stdio.h>
 #include <ctype.h>
index 9ab94aa..972edc0 100644 (file)
@@ -29,7 +29,7 @@
 #if defined(TARGET_DARWIN)
 #include "osx/OSXGNUReplacements.h"
 #endif
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
 #include "freebsd/FreeBSDGNUReplacements.h"
 #endif
 
index 1b84918..2c6d033 100644 (file)
@@ -18,9 +18,9 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
 #include "system.h"
 #endif
 
 #include "OMXClock.h"
 #include "utils/MathUtils.h"
 
-int64_t OMXClock::m_systemOffset;
-int64_t OMXClock::m_systemFrequency;
-bool    OMXClock::m_ismasterclock;
-
 #define OMX_PRE_ROLL 800
 
 OMXClock::OMXClock()
@@ -46,23 +42,10 @@ OMXClock::OMXClock()
   m_audio_start = false;
   m_pause       = false;
 
-  m_systemOffset = 0;
-  m_systemFrequency = 0;
-  m_startClock = 0;
-
-  CheckSystemClock();
-
-  m_systemUsed = m_systemFrequency;
-  m_pauseClock = 0;
-  m_bReset = true;
-  m_iDisc = 0;
-  m_maxspeedadjust = 0.0;
-  m_speedadjust = false;
-  m_ismasterclock = true;
-  m_ClockOffset = 0;
   m_fps = 25.0f;
   m_omx_speed = DVD_PLAYSPEED_NORMAL;
   m_audio_buffer = false;
+  m_clock        = NULL;
 
   pthread_mutex_init(&m_lock, NULL);
 }
@@ -83,200 +66,6 @@ void OMXClock::UnLock()
   pthread_mutex_unlock(&m_lock);
 }
 
-double OMXClock::GetAbsoluteClock(bool interpolated /*= true*/)
-{
-  Lock();
-  CheckSystemClock();
-
-  int64_t current;
-  current = g_VideoReferenceClock.GetTime(interpolated);
-
-  UnLock();
-  return SystemToAbsolute(current);
-}
-
-double OMXClock::WaitAbsoluteClock(double target)
-{
-  Lock();
-  CheckSystemClock();
-
-  int64_t systemtarget, freq, offset;
-  freq   = m_systemFrequency;
-  offset = m_systemOffset;
-  UnLock();
-
-  systemtarget = (int64_t)(target / DVD_TIME_BASE * (double)freq);
-  systemtarget += offset;
-  systemtarget = g_VideoReferenceClock.Wait(systemtarget);
-  systemtarget -= offset;
-  return (double)systemtarget / freq * DVD_TIME_BASE;
-}
-
-// Returns the current absolute clock in units of DVD_TIME_BASE (usually microseconds).
-void OMXClock::CheckSystemClock()
-{
-  if(!m_systemFrequency)
-    m_systemFrequency = g_VideoReferenceClock.GetFrequency();
-
-  if(!m_systemOffset)
-    m_systemOffset = g_VideoReferenceClock.GetTime();
-}
-
-double OMXClock::GetClock(bool interpolated /*= true*/)
-{
-  Lock();
-  double clock = SystemToPlaying(g_VideoReferenceClock.GetTime(interpolated));
-  UnLock();
-  return clock;
-}
-
-double OMXClock::GetClock(double& absolute, bool interpolated /*= true*/)
-{
-  int64_t current = g_VideoReferenceClock.GetTime(interpolated);
-
-  Lock();
-  CheckSystemClock();
-  absolute = SystemToAbsolute(current);
-  current = SystemToPlaying(current);
-  UnLock();
-
-  return current;
-}
-
-void OMXClock::SetSpeed(int iSpeed)
-{
-  // this will sometimes be a little bit of due to rounding errors, ie clock might jump abit when changing speed
-  Lock();
-
-  if(iSpeed == DVD_PLAYSPEED_PAUSE)
-  {
-    if(!m_pauseClock)
-      m_pauseClock = g_VideoReferenceClock.GetTime();
-    UnLock();
-    return;
-  }
-
-  int64_t current;
-  int64_t newfreq = m_systemFrequency * DVD_PLAYSPEED_NORMAL / iSpeed;
-
-  current = g_VideoReferenceClock.GetTime();
-  if( m_pauseClock )
-  {
-    m_startClock += current - m_pauseClock;
-    m_pauseClock = 0;
-  }
-
-  m_startClock = current - (int64_t)((double)(current - m_startClock) * newfreq / m_systemUsed);
-  m_systemUsed = newfreq;
-  UnLock();
-}
-
-void OMXClock::Discontinuity(double currentPts)
-{
-  Lock();
-  m_startClock = g_VideoReferenceClock.GetTime();
-  if(m_pauseClock)
-    m_pauseClock = m_startClock;
-  m_iDisc = currentPts;
-  m_bReset = false;
-  UnLock();
-}
-
-void OMXClock::Pause()
-{
-  Lock();
-  if(!m_pauseClock)
-    m_pauseClock = g_VideoReferenceClock.GetTime();
-  UnLock();
-}
-
-void OMXClock::Resume()
-{
-  Lock();
-  if( m_pauseClock )
-  {
-    int64_t current;
-    current = g_VideoReferenceClock.GetTime();
-
-    m_startClock += current - m_pauseClock;
-    m_pauseClock = 0;
-  }
-  UnLock();
-}
-
-bool OMXClock::SetMaxSpeedAdjust(double speed)
-{
-  Lock();
-  m_maxspeedadjust = speed;
-  UnLock();
-  return m_speedadjust;
-}
-
-//returns the refreshrate if the videoreferenceclock is running, -1 otherwise
-int OMXClock::UpdateFramerate(double fps, double* interval /*= NULL*/)
-{
-  //sent with fps of 0 means we are not playing video
-  if(fps == 0.0)
-  {
-    Lock();
-    m_speedadjust = false;
-    UnLock();
-    return -1;
-  }
-
-  //check if the videoreferenceclock is running, will return -1 if not
-  int rate = g_VideoReferenceClock.GetRefreshRate(interval);
-
-  if (rate <= 0)
-    return -1;
-
-  Lock();
-
-  m_speedadjust = true;
-
-  double weight = (double)rate / (double)MathUtils::round_int(fps);
-
-  //set the speed of the videoreferenceclock based on fps, refreshrate and maximum speed adjust set by user
-  if (m_maxspeedadjust > 0.05)
-  {
-    if (weight / MathUtils::round_int(weight) < 1.0 + m_maxspeedadjust / 100.0
-    &&  weight / MathUtils::round_int(weight) > 1.0 - m_maxspeedadjust / 100.0)
-      weight = MathUtils::round_int(weight);
-  }
-  double speed = (double)rate / (fps * weight);
-  UnLock();
-
-  g_VideoReferenceClock.SetSpeed(speed);
-
-  return rate;
-}
-
-double OMXClock::SystemToAbsolute(int64_t system)
-{
-  return DVD_TIME_BASE * (double)(system - m_systemOffset) / m_systemFrequency;
-}
-
-double OMXClock::SystemToPlaying(int64_t system)
-{
-  int64_t current;
-
-  if (m_bReset)
-  {
-    m_startClock = system;
-    m_systemUsed = m_systemFrequency;
-    m_pauseClock = 0;
-    m_iDisc = 0;
-    m_bReset = false;
-  }
-
-  if (m_pauseClock)
-    current = m_pauseClock;
-  else
-    current = system;
-
-  return DVD_TIME_BASE * (double)(current - m_startClock) / m_systemUsed + m_iDisc;
-}
-
 void OMXClock::OMXSetClockPorts(OMX_TIME_CONFIG_CLOCKSTATETYPE *clock)
 {
   if(m_omx_clock.GetComponent() == NULL)
@@ -340,9 +129,8 @@ bool OMXClock::OMXSetReferenceClock(bool lock /* = true */)
   return ret;
 }
 
-bool OMXClock::OMXInitialize(bool has_video, bool has_audio)
+bool OMXClock::OMXInitialize(CDVDClock *clock, bool has_video, bool has_audio)
 {
-  OMX_ERRORTYPE omx_err = OMX_ErrorNone;
   std::string componentName = "";
 
   m_has_video = has_video;
@@ -353,27 +141,14 @@ bool OMXClock::OMXInitialize(bool has_video, bool has_audio)
   m_pause       = false;
   m_audio_buffer = false;
 
+  m_clock = clock;
+
   componentName = "OMX.broadcom.clock";
   if(!m_omx_clock.Initialize((const std::string)componentName, OMX_IndexParamOtherInit))
     return false;
 
   m_omx_clock.DisableAllPorts();
 
-  /*
-  if(!OMXSetReferenceClock(false))
-    return false;
-
-  OMX_TIME_CONFIG_CLOCKSTATETYPE clock;
-  OMX_INIT_STRUCTURE(clock);
-
-  clock.eState    = OMX_TIME_ClockStateWaitingForStartTime;
-  clock.nOffset   = ToOMXTime(-1000LL * OMX_PRE_ROLL);
-
-  omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeClockState, &clock);
-  if(omx_err != OMX_ErrorNone)
-    CLog::Log(LOGWARNING, "OMXClock::OMXInitialize setting OMX_IndexConfigTimeClockState\n");
-  */
-
   return true;
 }
 
@@ -387,33 +162,6 @@ void OMXClock::OMXDeinitialize()
   m_omx_speed = DVD_PLAYSPEED_NORMAL;
 }
 
-bool OMXClock::OMXStatePause(bool lock /* = true */)
-{
-  if(m_omx_clock.GetComponent() == NULL)
-    return false;
-
-  if(lock)
-    Lock();
-
-  if(m_omx_clock.GetState() != OMX_StatePause)
-  {
-    OMX_ERRORTYPE omx_err = OMX_ErrorNone;
-    omx_err = m_omx_clock.SetStateForComponent(OMX_StatePause);
-    if (omx_err != OMX_ErrorNone)
-    {
-      CLog::Log(LOGERROR, "OMXClock::StatePause m_omx_clock.SetStateForComponent\n");
-      if(lock)
-        UnLock();
-      return false;
-    }
-  }
-
-  if(lock)
-    UnLock();
-
-  return true;
-}
-
 bool OMXClock::OMXStateExecute(bool lock /* = true */)
 {
   if(m_omx_clock.GetComponent() == NULL)
@@ -439,44 +187,6 @@ bool OMXClock::OMXStateExecute(bool lock /* = true */)
     }
   }
 
-  /*
-  if(m_has_audio)
-  {
-    omx_err = m_omx_clock.EnablePort(m_omx_clock.GetInputPort(), true);
-    if(omx_err != OMX_ErrorNone)
-    {
-      CLog::Log(LOGERROR, "OMXClock::StateExecute - Error enable port %d on component %s omx_err(0x%08x)", 
-            m_omx_clock.GetInputPort(), m_omx_clock.GetName().c_str(), (int)omx_err);
-    }
-  }
-
-  if(m_has_video)
-  {
-    omx_err = m_omx_clock.EnablePort(m_omx_clock.GetInputPort() + 1, true);
-    if(omx_err != OMX_ErrorNone)
-    {
-      CLog::Log(LOGERROR, "OMXClock::StateExecute - Error enable port %d on component %s omx_err(0x%08x)", 
-            m_omx_clock.GetInputPort(), m_omx_clock.GetName().c_str(), (int)omx_err);
-    }
-  }
-
-  OMX_TIME_CONFIG_CLOCKSTATETYPE clock;
-  OMX_INIT_STRUCTURE(clock);
-
-  clock.eState      = OMX_TIME_ClockStateWaitingForStartTime;
-  clock.nStartTime  = ToOMXTime(0LL);
-  clock.nOffset     = ToOMXTime(-1000LL * OMX_PRE_ROLL);
-  clock.nWaitMask   = 0;
-
-  omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeClockState, &clock);
-  if(omx_err != OMX_ErrorNone)
-  {
-    CLog::Log(LOGERROR, "OMXClock::OMXStateExecute error setting OMX_IndexConfigTimeClockState\n");
-  }
-  */
-
-  //OMXStart(lock);
-
   if(lock)
     UnLock();
 
@@ -506,43 +216,6 @@ COMXCoreComponent *OMXClock::GetOMXClock()
   return &m_omx_clock;
 }
 
-void OMXClock::OMXSaveState(bool lock /* = true */)
-{
-  if(m_omx_clock.GetComponent() == NULL)
-    return;
-
-  if(lock)
-    Lock();
-
-  OMX_ERRORTYPE omx_err = OMX_ErrorNone;
-  OMX_INIT_STRUCTURE(m_clock_state);
-
-  omx_err = m_omx_clock.GetConfig(OMX_IndexConfigTimeClockState, &m_clock_state);
-  if(omx_err != OMX_ErrorNone)
-    CLog::Log(LOGERROR, "OMXClock::SaveState error geting OMX_IndexConfigTimeClockState\n");
-
-  if(lock)
-    UnLock();
-}
-
-void OMXClock::OMXRestoreState(bool lock /* = true */)
-{
-  if(m_omx_clock.GetComponent() == NULL)
-    return;
-
-  if(lock)
-    Lock();
-
-  OMX_ERRORTYPE omx_err = OMX_ErrorNone;
-
-  omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeClockState, &m_clock_state);
-  if(omx_err != OMX_ErrorNone)
-    CLog::Log(LOGERROR, "OMXClock::RestoreState error setting OMX_IndexConfigTimeClockState\n");
-
-  if(lock)
-    UnLock();
-}
-
 bool  OMXClock::OMXStop(bool lock /* = true */)
 {
   if(m_omx_clock.GetComponent() == NULL)
@@ -579,7 +252,7 @@ bool OMXClock::OMXStart(bool lock /* = true */)
 {
   if(m_omx_clock.GetComponent() == NULL)
     return false;
-  
+
   if(lock)
     Lock();
 
@@ -621,6 +294,36 @@ void OMXClock::AudioStart(bool audio_start)
   UnLock();
 };
 
+bool OMXClock::OMXStep(int steps /* = 1 */, bool lock /* = true */)
+{
+  if(m_omx_clock.GetComponent() == NULL)
+    return false;
+
+  if(lock)
+    Lock();
+
+  OMX_ERRORTYPE omx_err = OMX_ErrorNone;
+  OMX_PARAM_U32TYPE param;
+  OMX_INIT_STRUCTURE(param);
+
+  param.nPortIndex = OMX_ALL;
+  param.nU32 = steps;
+
+  omx_err = m_omx_clock.SetConfig(OMX_IndexConfigSingleStep, &param);
+  if(omx_err != OMX_ErrorNone)
+  {
+    CLog::Log(LOGERROR, "OMXClock::Error setting OMX_IndexConfigSingleStep\n");
+    if(lock)
+      UnLock();
+    return false;
+  }
+
+  if(lock)
+    UnLock();
+
+  return true;
+}
+
 bool OMXClock::OMXReset(bool lock /* = true */)
 {
   if(m_omx_clock.GetComponent() == NULL)
@@ -678,7 +381,7 @@ bool OMXClock::OMXReset(bool lock /* = true */)
   return true;
 }
 
-double OMXClock::OMXWallTime(bool lock /* = true */)
+double OMXClock::OMXMediaTime(bool fixPreroll /* true */ , bool lock /* = true */)
 {
   if(m_omx_clock.GetComponent() == NULL)
     return 0;
@@ -693,10 +396,10 @@ double OMXClock::OMXWallTime(bool lock /* = true */)
   OMX_INIT_STRUCTURE(timeStamp);
   timeStamp.nPortIndex = m_omx_clock.GetInputPort();
 
-  omx_err = m_omx_clock.GetConfig(OMX_IndexConfigTimeCurrentWallTime, &timeStamp);
+  omx_err = m_omx_clock.GetConfig(OMX_IndexConfigTimeCurrentMediaTime, &timeStamp);
   if(omx_err != OMX_ErrorNone)
   {
-    CLog::Log(LOGERROR, "OMXClock::WallTime error getting OMX_IndexConfigTimeCurrentWallTime\n");
+    CLog::Log(LOGERROR, "OMXClock::MediaTime error getting OMX_IndexConfigTimeCurrentMediaTime\n");
     if(lock)
       UnLock();
     return 0;
@@ -704,13 +407,16 @@ double OMXClock::OMXWallTime(bool lock /* = true */)
 
   pts = FromOMXTime(timeStamp.nTimestamp);
 
+  if(fixPreroll)
+    pts += (OMX_PRE_ROLL * 1000);
+
   if(lock)
     UnLock();
   
   return pts;
 }
 
-double OMXClock::OMXMediaTime(bool fixPreroll /* true */ , bool lock /* = true */)
+double OMXClock::OMXClockAdjustment(bool lock /* = true */)
 {
   if(m_omx_clock.GetComponent() == NULL)
     return 0;
@@ -725,26 +431,24 @@ double OMXClock::OMXMediaTime(bool fixPreroll /* true */ , bool lock /* = true *
   OMX_INIT_STRUCTURE(timeStamp);
   timeStamp.nPortIndex = m_omx_clock.GetInputPort();
 
-  omx_err = m_omx_clock.GetConfig(OMX_IndexConfigTimeCurrentMediaTime, &timeStamp);
+  omx_err = m_omx_clock.GetConfig(OMX_IndexConfigClockAdjustment, &timeStamp);
   if(omx_err != OMX_ErrorNone)
   {
-    CLog::Log(LOGERROR, "OMXClock::MediaTime error getting OMX_IndexConfigTimeCurrentMediaTime\n");
+    CLog::Log(LOGERROR, "OMXClock::MediaTime error getting OMX_IndexConfigClockAdjustment\n");
     if(lock)
       UnLock();
     return 0;
   }
 
-  pts = FromOMXTime(timeStamp.nTimestamp);
-
-  if(fixPreroll)
-    pts += (OMX_PRE_ROLL * 1000);
-
+  pts = (double)FromOMXTime(timeStamp.nTimestamp);
+  //CLog::Log(LOGINFO, "OMXClock::ClockAdjustment %.0f %.0f\n", (double)FromOMXTime(timeStamp.nTimestamp), pts);
   if(lock)
     UnLock();
-  
+
   return pts;
 }
 
+
 // Set the media time, so calls to get media time use the updated value,
 // useful after a seek so mediatime is updated immediately (rather than waiting for first decoded packet)
 bool OMXClock::OMXMediaTime(double pts, bool fixPreroll /* = true*/, bool lock /* = true*/)
@@ -791,203 +495,45 @@ bool OMXClock::OMXMediaTime(double pts, bool fixPreroll /* = true*/, bool lock /
   return true;
 }
 
-// gets count of late frames, indicating underrun has occurred
-int OMXClock::OMXLateCount(int port /* true */ , bool lock /* = true */)
-{
-  if(m_omx_clock.GetComponent() == NULL)
-    return 0;
-
-  if(lock)
-    Lock();
-
-  OMX_ERRORTYPE omx_err = OMX_ErrorNone;
-
-  OMX_PARAM_U32TYPE late;
-  OMX_INIT_STRUCTURE(late);
-  late.nPortIndex = m_omx_clock.GetInputPort()+port;
-
-  omx_err = m_omx_clock.GetConfig(OMX_IndexConfigBrcmClockMissCount, &late);
-  if(omx_err != OMX_ErrorNone)
-  {
-    CLog::Log(LOGERROR, "OMXClock::OMXLateCount error getting OMX_IndexConfigBrcmClockMissCount(%d)\n", port);
-    if(lock)
-      UnLock();
-    return 0;
-  }
-
-  //CLog::Log(LOGINFO, "OMXClock::OMXLateCount(%d)=%d", port, late.nU32);
-
-  if(lock)
-    UnLock();
-
-  return late.nU32;
-}
-
 bool OMXClock::OMXPause(bool lock /* = true */)
 {
   if(m_omx_clock.GetComponent() == NULL)
     return false;
 
-  if(lock)
-    Lock();
-
-  OMX_ERRORTYPE omx_err = OMX_ErrorNone;
-  OMX_TIME_CONFIG_SCALETYPE scaleType;
-  OMX_INIT_STRUCTURE(scaleType);
-
-  scaleType.xScale = 0; // pause
-
-  omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeScale, &scaleType);
-  if(omx_err != OMX_ErrorNone)
+  if(!m_pause)
   {
-    CLog::Log(LOGERROR, "OMXClock::Pause error setting OMX_IndexConfigTimeClockState\n");
     if(lock)
-      UnLock();
-    return false;
-  }
+      Lock();
 
-  CLog::Log(LOGDEBUG, "OMXClock::OMXPause\n");
+    if (OMXSetSpeed(0, false, true))
+      m_pause = true;
 
-  m_pause = true;
-
-  if(lock)
-    UnLock();
-
-  return true;
-}
-
-bool OMXClock::OMXResume(bool lock /* = true */)
-{
-  if(m_omx_clock.GetComponent() == NULL)
-    return false;
-
-  if(lock)
-    Lock();
-
-  OMX_ERRORTYPE omx_err = OMX_ErrorNone;
-  OMX_TIME_CONFIG_SCALETYPE scaleType;
-  OMX_INIT_STRUCTURE(scaleType);
-
-  scaleType.xScale = ((m_omx_speed / DVD_PLAYSPEED_NORMAL) << 16);
-
-  omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeScale, &scaleType);
-  if(omx_err != OMX_ErrorNone)
-  {
-    CLog::Log(LOGERROR, "OMXClock::Resume error setting OMX_IndexConfigTimeClockState\n");
     if(lock)
       UnLock();
-    return false;
   }
-
-  m_pause = false;
-
-  CLog::Log(LOGDEBUG, "OMXClock::OMXResume\n");
-
-  if(lock)
-    UnLock();
-
-  return true;
+  return m_pause == true;
 }
 
-bool OMXClock::OMXUpdateClock(double pts, bool lock /* = true */)
+bool OMXClock::OMXResume(bool lock /* = true */)
 {
   if(m_omx_clock.GetComponent() == NULL)
     return false;
 
-  if(lock)
-    Lock();
-
-  OMX_ERRORTYPE omx_err = OMX_ErrorNone;
-  OMX_TIME_CONFIG_TIMESTAMPTYPE ts;
-  OMX_INIT_STRUCTURE(ts);
-
-  ts.nPortIndex = OMX_ALL;
-  ts.nTimestamp = ToOMXTime((uint64_t)pts);
-
-  CLog::Log(LOGDEBUG, "OMXClock::OMXUpdateClock %f", pts / DVD_TIME_BASE);
-
-  if(m_has_audio)
-  {
-    omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeCurrentAudioReference, &ts);
-    if(omx_err != OMX_ErrorNone)
-      CLog::Log(LOGERROR, "OMXClock::OMXUpdateClock error setting OMX_IndexConfigTimeCurrentAudioReference\n");
-  }
-  else
+  if(m_pause)
   {
-    omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeCurrentVideoReference, &ts);
-    if(omx_err != OMX_ErrorNone)
-      CLog::Log(LOGERROR, "OMXClock::OMXUpdateClock error setting OMX_IndexConfigTimeCurrentVideoReference\n");
-  }
-
-  if(lock)
-    UnLock();
-
-  return true;
-}
-
-bool OMXClock::OMXWaitStart(double pts, bool lock /* = true */)
-{
-  if(m_omx_clock.GetComponent() == NULL)
-    return false;
-
-  if(lock)
-    Lock();
-
-  OMX_ERRORTYPE omx_err = OMX_ErrorNone;
-  OMX_TIME_CONFIG_CLOCKSTATETYPE clock;
-  OMX_INIT_STRUCTURE(clock);
+    if(lock)
+      Lock();
 
-  clock.eState    = OMX_TIME_ClockStateWaitingForStartTime;
-  clock.nOffset   = ToOMXTime(-1000LL * OMX_PRE_ROLL);
-  OMXSetClockPorts(&clock);
-  clock.nStartTime  = ToOMXTime((uint64_t)pts);
+    if (OMXSetSpeed(m_omx_speed, false, true))
+      m_pause = false;
 
-  omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeClockState, &clock);
-  if(omx_err != OMX_ErrorNone)
-  {
-    CLog::Log(LOGERROR, "OMXClock::OMXWaitStart error setting OMX_IndexConfigTimeClockState\n");
     if(lock)
       UnLock();
-    return false;
-  }
-
-  if(lock)
-    UnLock();
-
-  return true;
-}
-
-void OMXClock::OMXHandleBackward(bool lock /* = true */)
-{
-  /*
-  if(m_omx_clock.GetComponent() == NULL)
-    return;
-
-  if(lock)
-    Lock();
-
-  if(m_omx_speed < 0)
-  {
-    OMX_ERRORTYPE omx_err = OMX_ErrorNone;
-    OMX_TIME_CONFIG_CLOCKSTATETYPE clock;
-    OMX_INIT_STRUCTURE(clock);
-    
-    clock.eState    = OMX_TIME_ClockStateRunning;
-    clock.nOffset   = ToOMXTime(-1000LL * OMX_PRE_ROLL);
-
-    omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeClockState, &clock);
-    if(omx_err != OMX_ErrorNone)
-    {
-      CLog::Log(LOGERROR, "OMXClock::OMXHandleBackward error setting OMX_IndexConfigTimeClockState\n");
-    }
   }
-
-  if(lock)
-    UnLock();
-  */
+  return m_pause == false;
 }
 
-bool OMXClock::OMXSetSpeed(int speed, bool lock /* = true */)
+bool OMXClock::OMXSetSpeed(int speed, bool lock /* = true */, bool pause_resume /* = false */)
 {
   if(m_omx_clock.GetComponent() == NULL)
     return false;
@@ -995,18 +541,15 @@ bool OMXClock::OMXSetSpeed(int speed, bool lock /* = true */)
   if(lock)
     Lock();
 
-  m_omx_speed = speed;
-
   m_audio_buffer = false; 
 
-  CLog::Log(LOGDEBUG, "OMXClock::OMXSetSpeed %d buffering %d", m_omx_speed / DVD_PLAYSPEED_NORMAL, m_audio_buffer);
+  CLog::Log(LOGDEBUG, "OMXClock::OMXSetSpeed(%.2f) pause_resume:%d audio_buffer:%d", (float)m_omx_speed / (float)DVD_PLAYSPEED_NORMAL, pause_resume, m_audio_buffer);
 
   OMX_ERRORTYPE omx_err = OMX_ErrorNone;
   OMX_TIME_CONFIG_SCALETYPE scaleType;
   OMX_INIT_STRUCTURE(scaleType);
 
-  scaleType.xScale = ((m_omx_speed / DVD_PLAYSPEED_NORMAL) << 16);
-
+  scaleType.xScale = (speed << 16) / DVD_PLAYSPEED_NORMAL;
   omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeScale, &scaleType);
   if(omx_err != OMX_ErrorNone)
   {
@@ -1016,23 +559,15 @@ bool OMXClock::OMXSetSpeed(int speed, bool lock /* = true */)
     return false;
   }
 
+  if (!pause_resume)
+    m_omx_speed = speed;
+
   if(lock)
     UnLock();
 
   return true;
 }
 
-void OMXClock::AddTimespecs(struct timespec &time, long millisecs)
-{
-   time.tv_sec  += millisecs / 1000;
-   time.tv_nsec += (millisecs % 1000) * 1000000;
-   if (time.tv_nsec > 1000000000)
-   {
-      time.tv_sec  += 1;
-      time.tv_nsec -= 1000000000;
-   }
-}
-
 bool OMXClock::HDMIClockSync(bool lock /* = true */)
 {
   if(m_omx_clock.GetComponent() == NULL)
@@ -1081,17 +616,6 @@ int64_t OMXClock::CurrentHostFrequency(void)
   return( (int64_t)1000000000L );
 }
 
-void OMXClock::AddTimeSpecNano(struct timespec &time, uint64_t nanoseconds)
-{
-   time.tv_sec  += nanoseconds / 1000000000;
-   time.tv_nsec += (nanoseconds % 1000000000);
-   if (time.tv_nsec > 1000000000)
-   {
-      time.tv_sec  += 1;
-      time.tv_nsec -= 1000000000;
-   }
-}
-
 int OMXClock::GetRefreshRate(double* interval)
 {
   if(!interval)
index a969e17..bc79d82 100644 (file)
@@ -59,26 +59,12 @@ protected:
   bool              m_has_audio;
   int               m_play_speed;
   pthread_mutex_t   m_lock;
-  double            SystemToAbsolute(int64_t system);
-  double            SystemToPlaying(int64_t system);
-  int64_t           m_systemUsed;
-  int64_t           m_startClock;
-  int64_t           m_pauseClock;
-  double            m_iDisc;
-  bool              m_bReset;
-  static int64_t    m_systemFrequency;
-  static int64_t    m_systemOffset;
-  int64_t           m_ClockOffset;
-  double            m_maxspeedadjust;
-  bool              m_speedadjust;
-  static bool       m_ismasterclock;
   double            m_fps;
   int               m_omx_speed;
   bool              m_video_start;
   bool              m_audio_start;
   bool              m_audio_buffer;
-  CDVDClock         m_clock;
-  OMX_TIME_CONFIG_CLOCKSTATETYPE m_clock_state;
+  CDVDClock         *m_clock;
 private:
   COMXCoreComponent m_omx_clock;
 public:
@@ -86,51 +72,29 @@ public:
   ~OMXClock();
   void Lock();
   void UnLock();
-  double  GetAbsoluteClock(bool interpolated = true);
-  double  GetFrequency() { return (double)m_systemFrequency ; }
-  double  WaitAbsoluteClock(double target);
-  double GetClock(bool interpolated = true);
-  double GetClock(double& absolute, bool interpolated = true);
-  void CheckSystemClock();
-  void SetSpeed(int iSpeed);
-  void SetMasterClock(bool ismasterclock) { m_ismasterclock = ismasterclock; }
-  bool IsMasterClock()                    { return m_ismasterclock;          }
-  void Discontinuity(double currentPts = 0LL);
-
-  void Reset() { m_bReset = true; }
-  void Pause();
-  void Resume();
-
-  int UpdateFramerate(double fps, double* interval = NULL);
-  bool   SetMaxSpeedAdjust(double speed);
-
+  double GetAbsoluteClock(bool interpolated = true) { return m_clock ? m_clock->GetAbsoluteClock(interpolated):0; }
+  double GetClock(bool interpolated = true) { return m_clock ? m_clock->GetClock(interpolated):0; }
+  double GetClock(double& absolute, bool interpolated = true) { return m_clock ? m_clock->GetClock(absolute, interpolated):0; }
+  void Discontinuity(double currentPts = 0LL) { if (m_clock) m_clock->Discontinuity(currentPts); }
   void OMXSetClockPorts(OMX_TIME_CONFIG_CLOCKSTATETYPE *clock);
   bool OMXSetReferenceClock(bool lock = true);
-  bool OMXInitialize(bool has_video, bool has_audio);
+  bool OMXInitialize(CDVDClock *clock, bool has_video, bool has_audio);
   void OMXDeinitialize();
   bool OMXIsPaused() { return m_pause; };
-  void OMXSaveState(bool lock = true);
-  void OMXRestoreState(bool lock = true);
   bool OMXStop(bool lock = true);
   bool OMXStart(bool lock = true);
+  bool OMXStep(int steps = 1, bool lock = true);
   bool OMXReset(bool lock = true);
-  double OMXWallTime(bool lock = true);
   double OMXMediaTime(bool fixPreroll = true, bool lock = true);
+  double OMXClockAdjustment(bool lock = true);
   bool OMXMediaTime(double pts, bool fixPreroll = true, bool lock = true);
-  int OMXLateCount(int port, bool lock = true);
   bool OMXPause(bool lock = true);
   bool OMXResume(bool lock = true);
-  bool OMXUpdateClock(double pts, bool lock = true);
-  bool OMXWaitStart(double pts, bool lock = true);
-  void OMXHandleBackward(bool lock = true);
-  bool OMXSetSpeed(int speed, bool lock = true);
+  bool OMXSetSpeed(int speed, bool lock = true, bool pause_resume = false);
   int  OMXPlaySpeed() { return m_omx_speed; };
-  int  OMXGetPlaySpeed() { return m_omx_speed; };
   COMXCoreComponent *GetOMXClock();
-  bool OMXStatePause(bool lock = true);
   bool OMXStateExecute(bool lock = true);
   void OMXStateIdle(bool lock = true);
-  static void AddTimespecs(struct timespec &time, long millisecs);
   bool HDMIClockSync(bool lock = true);
   static int64_t CurrentHostCounter(void);
   static int64_t CurrentHostFrequency(void);
@@ -142,8 +106,6 @@ public:
   bool AudioStart() { return m_audio_start; };
   void VideoStart(bool video_start);
   void AudioStart(bool audio_start);
-  static void AddTimeSpecNano(struct timespec &time, uint64_t nanoseconds);
-
   void OMXAudioBufferStart();
   void OMXAudioBufferStop();
   bool OMXAudioBuffer() { return m_audio_buffer; };
index 4946b1d..c5dcaaa 100644 (file)
@@ -18,9 +18,9 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
 #include "system.h"
 #endif
 
@@ -33,7 +33,7 @@
 
 #include "OMXClock.h"
 
-#ifdef _LINUX
+#ifdef TARGET_LINUX
 #include "XMemUtils.h"
 #endif
 
@@ -428,9 +428,6 @@ void COMXCoreComponent::TransitionToStateLoaded()
   if(!m_handle)
     return;
 
-  if(GetState() == OMX_StateExecuting)
-    SetStateForComponent(OMX_StatePause);
-
   if(GetState() != OMX_StateIdle)
     SetStateForComponent(OMX_StateIdle);
 
index b26fd5a..cbcefa7 100644 (file)
@@ -21,7 +21,7 @@
  *
  */
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 
 #define LINE_ENDING "\n"
 
@@ -51,7 +51,7 @@
 #if defined(TARGET_DARWIN_OSX)
 #include <libkern/OSTypes.h>
 #endif
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
 #include <stdio.h>
 #include <sys/sysctl.h>
 #include <sys/types.h>
@@ -85,7 +85,7 @@
 #include <stdint.h>
 
 #ifndef PRId64
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
 #define PRId64 "I64d"
 #else
 #if __WORDSIZE == 64
@@ -97,7 +97,7 @@
 #endif
 
 #ifndef PRIu64
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
 #define PRIu64 "I64u"
 #else
 #if __WORDSIZE == 64
 #endif
        
 #ifndef PRIx64
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
 #define PRIx64 "I64x"
 #else
 #if __WORDSIZE == 64
 #define PRIuS "zu"
 #endif
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 
 #define XXLog(a,b) printf("%s", (b))
 
 #define CALLBACK    __stdcall
 #define WINAPI      __stdcall
 #define WINAPIV     __cdecl
-#if !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD)
 #define APIENTRY    WINAPI
 #else
 #define APIENTRY
index 7f4d745..2d84168 100644 (file)
@@ -96,7 +96,7 @@ std::vector<CStdString> CPosixMountProvider::GetDiskUsage()
 
 #if defined(TARGET_DARWIN)
   FILE* pipe = popen("df -hT ufs,cd9660,hfs,udf", "r");
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
   FILE* pipe = popen("df -h -t ufs,cd9660,hfs,udf,zfs", "r");
 #else
   FILE* pipe = popen("df -h", "r");
index 7604e55..7d0e7fb 100644 (file)
 #include "XTimeUtils.h"
 #include "filesystem/SpecialProtocol.h"
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "XHandle.h"
 #include <sys/types.h>
 #include <sys/stat.h>
-#if !defined(TARGET_DARWIN) && !defined(__FreeBSD__) && !defined(__ANDROID__)
+#if !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD) && !defined(TARGET_ANDROID)
 #include <sys/vfs.h>
 #else
 #include <sys/param.h>
@@ -37,7 +37,7 @@
 #include <dirent.h>
 #include <errno.h>
 
-#if defined(__ANDROID__)
+#if defined(TARGET_ANDROID)
 #include <sys/file.h>
 #include <sys/statfs.h>
 
@@ -67,7 +67,7 @@ HANDLE FindFirstFile(LPCSTR szPath,LPWIN32_FIND_DATA lpFindData)
   strPath.Replace("\\","/");
 
   // if the file name is a directory then we add a * to look for all files in this directory
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__) || defined(__ANDROID__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_ANDROID)
   DIR *testDir = opendir(strPath.c_str());
 #else
   DIR *testDir = opendir(szPath);
@@ -104,7 +104,7 @@ HANDLE FindFirstFile(LPCSTR szPath,LPWIN32_FIND_DATA lpFindData)
     return(INVALID_HANDLE_VALUE);
 
   struct dirent **namelist = NULL;
-#if defined(__ANDROID__)
+#if defined(TARGET_ANDROID)
   // android is more strict with the sort function. Let's hope it is implemented correctly.
   typedef int (*sortFunc)(const struct dirent ** a, const struct dirent **b);
   int n = scandir(strDir, &namelist, 0, (sortFunc)alphasort);
@@ -574,7 +574,7 @@ DWORD  SetFilePointer(HANDLE hFile, int32_t lDistanceToMove,
     nMode = SEEK_END;
 
   off64_t currOff;
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
   currOff = lseek(hFile->fd, offset, nMode);
 #else
   currOff = lseek64(hFile->fd, offset, nMode);
@@ -597,7 +597,7 @@ BOOL GetDiskFreeSpaceEx(
   )
 
 {
-#if defined(__ANDROID__)
+#if defined(TARGET_ANDROID)
   struct statfs fsInfo;
   // is 64-bit on android
   if (statfs(CSpecialProtocol::TranslatePath(lpDirectoryName), &fsInfo) != 0)
@@ -644,7 +644,7 @@ BOOL SetEndOfFile(HANDLE hFile)
     return false;
 
   // get the current offset
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
   off64_t currOff = lseek(hFile->fd, 0, SEEK_CUR);
 #else
   off64_t currOff = lseek64(hFile->fd, 0, SEEK_CUR);
@@ -675,7 +675,7 @@ BOOL SetFilePointerEx(  HANDLE hFile,
 
   off64_t toMove = liDistanceToMove.QuadPart;
 
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
   off64_t currOff = lseek(hFile->fd, toMove, nMode);
 #else
   off64_t currOff = lseek64(hFile->fd, toMove, nMode);
index 753db8e..582c924 100644 (file)
@@ -24,7 +24,7 @@
 #include "PlatformDefs.h"
 #include "XHandlePublic.h"
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #define XBMC_FILE_SEP '/'
 #else
 #define XBMC_FILE_SEP '\\'
index d897525..8714e96 100644 (file)
@@ -21,7 +21,7 @@
  *
  */
 
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
 
 #include <list>
 
@@ -50,7 +50,7 @@ public:
 
   // simulate mutex and critical section
   CCriticalSection *m_hMutex;
-  int       RecursionCount;  // for mutex - for compatibility with WIN32 critical section
+  int       RecursionCount;  // for mutex - for compatibility with TARGET_WINDOWS critical section
   int       fd;
   bool      m_bManualEvent;
   time_t    m_tmCreation;
index 2362ed2..94c4041 100644 (file)
@@ -52,9 +52,9 @@ void _aligned_free(void *p) {
   free(pFull);
 }
 
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
 
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD)
 static FILE* procMeminfoFP = NULL;
 #endif
 
@@ -104,7 +104,7 @@ void GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
           lpBuffer->ullAvailVirtual  = lpBuffer->ullAvailPhys; // FIXME.
       }
   }
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_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;
index 44b9108..2d19b40 100644 (file)
@@ -26,7 +26,7 @@
 #include "threads/Atomics.h"
 #endif
 
-#if defined(__ANDROID__)
+#if defined(TARGET_ANDROID)
 #include <time64.h>
 #endif
 
@@ -44,7 +44,7 @@
  */
 #define IsLeapYear(y) ((!(y % 4)) ? (((!(y % 400)) && (y % 100)) ? 1 : 0) : 0)
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 
 void WINAPI Sleep(DWORD dwMilliSeconds)
 {
@@ -116,7 +116,7 @@ BOOL   SystemTimeToFileTime(const SYSTEMTIME* lpSystemTime,  LPFILETIME lpFileTi
   CAtomicSpinLock lock(timegm_lock);
 #endif
 
-#if defined(__ANDROID__)
+#if defined(TARGET_ANDROID)
   time64_t t = timegm64(&sysTime);
 #else
   time_t t = timegm(&sysTime);
index 89af7f0..c8ed2fb 100644 (file)
@@ -25,7 +25,7 @@
 #include "PlayListPlayer.h"
 #include "utils/log.h"
 #include "xbmc.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include <sys/resource.h>
 #include <signal.h>
 #endif
@@ -58,7 +58,7 @@ int main(int argc, char* argv[])
 #endif
   CLog::SetLogLevel(g_advancedSettings.m_logLevel);
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #if defined(DEBUG)
   struct rlimit rlim;
   rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
@@ -69,7 +69,7 @@ int main(int argc, char* argv[])
   setlocale(LC_NUMERIC, "C");
   g_advancedSettings.Initialize();
 
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
   CAppParamParser appParamParser;
   appParamParser.Parse((const char **)argv, argc);
 #endif
index 6730316..fe793bc 100644 (file)
@@ -187,7 +187,7 @@ bool CMusicDatabase::CreateTables()
     CLog::Log(LOGINFO, "create song index3");
     m_pDS->exec("CREATE INDEX idxSong3 ON song(idAlbum)");
     CLog::Log(LOGINFO, "create song index6");
-    m_pDS->exec("CREATE UNIQUE INDEX idxSong6 ON song( idPath, strFileName(255) )");
+    m_pDS->exec("CREATE INDEX idxSong6 ON song( idPath, strFileName(255) )");
     CLog::Log(LOGINFO, "create song index7");
     m_pDS->exec("CREATE UNIQUE INDEX idxSong7 ON song( idAlbum, strMusicBrainzTrackID(36) )");
 
@@ -2022,8 +2022,7 @@ bool CMusicDatabase::CleanupSongsByIds(const CStdString &strSongIds)
       //  Special case for streams inside an ogg file. (oggstream)
       //  The last dir in the path is the ogg file that
       //  contains the stream, so test if its there
-      CStdString strExtension=URIUtils::GetExtension(strFileName);
-      if (strExtension==".oggstream" || strExtension==".nsfstream")
+      if (URIUtils::HasExtension(strFileName, ".oggstream|.nsfstream"))
       {
         CStdString strFileAndPath=strFileName;
         URIUtils::GetDirectory(strFileAndPath, strFileName);
@@ -2193,6 +2192,12 @@ bool CMusicDatabase::CleanupPaths()
   return false;
 }
 
+bool CMusicDatabase::InsideScannedPath(const CStdString& path)
+{
+  CStdString sql = PrepareSQL("select idPath from path where SUBSTR(strPath,1,%i)='%s' LIMIT 1", path.size(), path.c_str());
+  return !GetSingleValue(sql).empty();
+}
+
 bool CMusicDatabase::CleanupArtists()
 {
   try
@@ -3724,7 +3729,7 @@ bool CMusicDatabase::UpdateOldVersion(int version)
   if (version < 33)
   {
     m_pDS->exec("DROP INDEX idxSong6 ON song");
-    m_pDS->exec("CREATE UNIQUE INDEX idxSong6 on song( idPath, strFileName(255) )");
+    m_pDS->exec("CREATE INDEX idxSong6 on song( idPath, strFileName(255) )");
   }
 
   if (version < 34)
@@ -3777,6 +3782,13 @@ bool CMusicDatabase::UpdateOldVersion(int version)
       }
     }
   }
+  if (version < 37)
+  {
+    m_pDS->exec("DROP INDEX idxSong6 ON song");
+    m_pDS->exec("CREATE INDEX idxSong6 on song( idPath, strFileName(255) )");
+  }
+    
   // always recreate the views after any table change
   CreateViews();
 
@@ -3785,7 +3797,7 @@ bool CMusicDatabase::UpdateOldVersion(int version)
 
 int CMusicDatabase::GetMinVersion() const
 {
-  return 36;
+  return 37;
 }
 
 unsigned int CMusicDatabase::GetSongIDs(const Filter &filter, vector<pair<int,int> > &songIDs)
index 1819794..dfe79fd 100644 (file)
@@ -171,6 +171,10 @@ public:
   bool GetAlbum(int idAlbum, CAlbum& album);
   int  UpdateAlbum(int idAlbum, const CAlbum &album);
   bool DeleteAlbum(int idAlbum);
+  /*! \brief Checks if the given path is inside a folder that has already been scanned into the library
+   \param path the path we want to check
+   */
+  bool InsideScannedPath(const CStdString& path);
 
   //// Misc Album
   int  GetAlbumIdByPath(const CStdString& path);
index f6b292e..b83d18b 100644 (file)
@@ -31,7 +31,7 @@
 #include "guilib/GUIKeyboardFactory.h"
 #include "guilib/Key.h"
 #include "GUIUserMessages.h"
-#include "Favourites.h"
+#include "filesystem/FavouritesDirectory.h"
 #include "profiles/ProfilesManager.h"
 #include "settings/MediaSettings.h"
 #include "settings/Settings.h"
@@ -521,7 +521,7 @@ void CGUIWindowMusicPlayList::GetContextButtons(int itemNumber, CContextButtons
         buttons.Add(CONTEXT_BUTTON_PLAY_WITH, 15213); // Play With...
 
       buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); // Song Info
-      if (CFavourites::IsFavourite(item.get(), GetID()))
+      if (XFILE::CFavouritesDirectory::IsFavourite(item.get(), GetID()))
         buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14077);     // Remove Favourite
       else
         buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14076);     // Add To Favourites;
@@ -590,7 +590,7 @@ bool CGUIWindowMusicPlayList::OnContextButton(int itemNumber, CONTEXT_BUTTON but
   case CONTEXT_BUTTON_ADD_FAVOURITE:
     {
       CFileItemPtr item = m_vecItems->Get(itemNumber);
-      CFavourites::AddOrRemove(item.get(), GetID());
+      XFILE::CFavouritesDirectory::AddOrRemove(item.get(), GetID());
       return true;
     }
 
index 513543a..b419a9b 100644 (file)
@@ -55,7 +55,7 @@ bool CDNSNameCache::Lookup(const CStdString& strHostName, CStdString& strIpAddre
   if(g_DNSCache.GetCached(strHostName, strIpAddress))
     return true;
 
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
   // perform netbios lookup (win32 is handling this via gethostbyname)
   char nmb_ip[100];
   char line[200];
index aa7862b..941a32b 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "GUIDialogAccessPoints.h"
 #include "guilib/GUIKeyboardFactory.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "linux/NetworkLinux.h"
 #endif
 #include "Application.h"
index 9795a54..36346b9 100644 (file)
@@ -89,6 +89,46 @@ bool in_ether (const char *bufp, unsigned char *addr)
   return true;
 }
 
+int NetworkAccessPoint::getQuality() const
+{
+  // Cisco dBm lookup table (partially nonlinear)
+  // Source: "Converting Signal Strength Percentage to dBm Values, 2002"
+  int quality;
+  if (m_dBm >= -10) quality = 100;
+  else if (m_dBm >= -20) quality = 85 + (m_dBm + 20);
+  else if (m_dBm >= -30) quality = 77 + (m_dBm + 30);
+  else if (m_dBm >= -60) quality = 48 + (m_dBm + 60);
+  else if (m_dBm >= -98) quality = 13 + (m_dBm + 98);
+  else if (m_dBm >= -112) quality = 1 + (m_dBm + 112);
+  else quality = 0;
+  return quality;
+}
+
+int NetworkAccessPoint::FreqToChannel(float frequency)
+{
+  int IEEE80211Freq[] = {2412, 2417, 2422, 2427, 2432,
+                         2437, 2442, 2447, 2452, 2457,
+                         2462, 2467, 2472, 2484,
+                         5180, 5200, 5210, 5220, 5240, 5250,
+                         5260, 5280, 5290, 5300, 5320,
+                         5745, 5760, 5765, 5785, 5800, 5805, 5825};
+  int IEEE80211Ch[] =   {   1,    2,    3,    4,    5,
+                            6,    7,    8,    9,   10,
+                           11,   12,   13,   14,
+                           36,   40,   42,   44,   48,   50,
+                           52,   56,   58,   60,   64,
+                          149,  152,  153,  157,  160,  161,  165};
+  // Round frequency to the nearest MHz
+  int mod_chan = (int)(frequency / 1000000 + 0.5f);
+  for (unsigned int i = 0; i < sizeof(IEEE80211Freq) / sizeof(int); ++i)
+  {
+    if (IEEE80211Freq[i] == mod_chan)
+      return IEEE80211Ch[i];
+  }
+  return 0; // unknown
+}
+
+
 CNetwork::CNetwork()
 {
   CApplicationMessenger::Get().NetworkMessage(SERVICES_UP, 0);
@@ -276,7 +316,7 @@ bool CNetwork::WakeOnLan(const char* mac)
 static const char* ConnectHostPort(SOCKET soc, const struct sockaddr_in& addr, struct timeval& timeOut, bool tryRead)
 {
   // set non-blocking
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
   u_long nonblocking = 1;
   int result = ioctlsocket(soc, FIONBIO, &nonblocking);
 #else
@@ -290,7 +330,7 @@ static const char* ConnectHostPort(SOCKET soc, const struct sockaddr_in& addr, s
 
   if (result < 0)
   {
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
     if (WSAGetLastError() != WSAEWOULDBLOCK)
 #else
     if (errno != EINPROGRESS)
@@ -377,7 +417,7 @@ bool CNetwork::PingHost(unsigned long ipaddr, unsigned short port, unsigned int
 
   if (err_msg && *err_msg)
   {
-#ifdef _MSC_VER
+#ifdef TARGET_WINDOWS
     CStdString sock_err = WUSysMsg(WSAGetLastError());
 #else
     CStdString sock_err = strerror(errno);
index d2053e3..99784aa 100644 (file)
@@ -32,21 +32,41 @@ enum NetworkAssignment { NETWORK_DASH = 0, NETWORK_DHCP = 1, NETWORK_STATIC = 2,
 class NetworkAccessPoint
 {
 public:
-   NetworkAccessPoint(CStdString& essId, int quality, EncMode encryption)
+   NetworkAccessPoint(const CStdString &essId, const CStdString &macAddress, int signalStrength, EncMode encryption, int channel = 0)
    {
-      m_essId = essId;
-      m_quality = quality;
+      m_essId          = essId;
+      m_macAddress     = macAddress;
+      m_dBm            = signalStrength;
       m_encryptionMode = encryption;
+      m_channel        = channel;
    }
 
-   CStdString getEssId() { return m_essId; }
-   int getQuality() { return m_quality; }
-   EncMode getEncryptionMode() { return m_encryptionMode; }
+   const CStdString &getEssId() const { return m_essId; }
+   const CStdString &getMacAddress() const { return m_macAddress; }
+   int getSignalStrength() const { return m_dBm; }
+   EncMode getEncryptionMode() const { return m_encryptionMode; }
+   int getChannel() const { return m_channel; }
+
+   /*!
+    \brief  Returns the quality, normalized as a percentage, of the network access point
+    \return The quality as an integer between 0 and 100
+    */
+   int getQuality() const;
+
+   /*!
+    \brief  Translates a 802.11a+g frequency into the corresponding channel
+    \param  frequency  The frequency of the channel in units of Hz
+    \return The channel as an integer between 1 and 14 (802.11b+g) or
+            between 36 and 165 (802.11a), or 0 if unknown.
+    */
+   static int FreqToChannel(float frequency);
 
 private:
-   CStdString   m_essId;
-   int          m_quality;
-   EncMode      m_encryptionMode;
+   CStdString  m_essId;
+   CStdString  m_macAddress;
+   int         m_dBm;
+   EncMode     m_encryptionMode;
+   int         m_channel;
 };
 
 class CNetworkInterface
index 232517e..ac07e98 100644 (file)
@@ -47,7 +47,7 @@ bool CPosixUDPSocket::Bind(CAddress& addr, int port, int range)
 
   if (m_iSock == INVALID_SOCKET)
   {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
     int ierr = WSAGetLastError();
     CLog::Log(LOGERROR, "UDP: Could not create socket %d", ierr);
     // hack for broken third party libs
index 8de583d..90ea344 100644 (file)
 #include <sys/time.h>
 #include <sys/types.h>
 #include <unistd.h>
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
 #include <netinet/in.h>
 #endif
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 typedef int SOCKET;
 #endif
 
index d060ffb..ef6ae6c 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "threads/SystemClock.h"
 #include "UdpClient.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include <sys/ioctl.h>
 #endif
 #include "Network.h"
@@ -175,7 +175,7 @@ void CUdpClient::Process()
     {
       // read data
       int messageLength = sizeof(messageBuffer) - 1 ;
-#ifndef _LINUX
+#ifndef TARGET_POSIX
       int remoteAddressSize;
 #else
       socklen_t remoteAddressSize;
index 8f39a70..cc10f2e 100644 (file)
@@ -237,14 +237,13 @@ private:
 class NetworkStartWaiter : public WaitCondition
 {
 public:
-  NetworkStartWaiter (unsigned settle_time_ms) : m_settle_time_ms (settle_time_ms)
+  NetworkStartWaiter (unsigned settle_time_ms, const CStdString& host) : m_settle_time_ms (settle_time_ms), m_host(host)
   {
   }
   virtual bool SuccessWaiting () const
   {
-    CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
-
-    bool online = iface && iface->IsEnabled();
+    unsigned long address = ntohl(HostToIP(m_host));
+    bool online = g_application.getNetwork().HasInterfaceForIP(address);
 
     if (!online) // setup endtime so we dont return true until network is consistently connected
       m_end.Set (m_settle_time_ms);
@@ -254,6 +253,7 @@ public:
 private:
   mutable XbmcThreads::EndTime m_end;
   unsigned m_settle_time_ms;
+  const CStdString m_host;
 };
 
 class PingResponseWaiter : public WaitCondition, private IJobCallback
@@ -369,7 +369,7 @@ void CWakeOnAccess::WakeUpHost(const WakeUpEntry& server)
   ProgressDialogHelper dlg (heading);
 
   {
-    NetworkStartWaiter waitObj (m_netsettle_ms); // wait until network connected before sending wake-on-lan
+    NetworkStartWaiter waitObj (m_netsettle_ms, server.host); // wait until network connected before sending wake-on-lan
 
     if (dlg.ShowAndWait (waitObj, m_netinit_sec, LOCALIZED(13028)) != ProgressDialogHelper::Success)
     {
index f10f42e..63d6779 100644 (file)
@@ -35,7 +35,7 @@
 
 //#define WEBSERVER_DEBUG
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #pragma comment(lib, "libmicrohttpd.dll.lib")
 #endif
 
index e2c3026..808fb19 100644 (file)
 #include "Zeroconf.h"
 #include "settings/Settings.h"
 
-#ifdef _LINUX
-#if !defined(TARGET_DARWIN)
+#if defined(HAS_AVAHI)
 #include "linux/ZeroconfAvahi.h"
-#else
+#elif defined(TARGET_DARWIN)
 //on osx use the native implementation
 #include "osx/ZeroconfOSX.h"
-#endif
-#elif defined(TARGET_WINDOWS)
-#include "windows/ZeroconfWIN.h"
+#elif defined(HAS_MDNS)
+#include "mdns/ZeroconfMDNS.h"
 #endif
 
 #include "threads/CriticalSection.h"
@@ -137,10 +135,10 @@ CZeroconf*  CZeroconf::GetInstance()
 #else
 #if defined(TARGET_DARWIN)
     smp_instance = new CZeroconfOSX;
-#elif defined(_LINUX)
+#elif defined(HAS_AVAHI)
     smp_instance  = new CZeroconfAvahi;
-#elif defined(TARGET_WINDOWS)
-    smp_instance  = new CZeroconfWIN;
+#elif defined(HAS_MDNS)
+    smp_instance  = new CZeroconfMDNS;
 #endif
 #endif
   }
index de94b59..6a930d8 100644 (file)
 #include <stdexcept>
 #include "utils/log.h"
 
-#ifdef _LINUX
-#if !defined(TARGET_DARWIN)
+#if defined (HAS_AVAHI)
 #include "linux/ZeroconfBrowserAvahi.h"
-#else
+#elif defined(TARGET_DARWIN)
 //on osx use the native implementation
 #include "osx/ZeroconfBrowserOSX.h"
-#endif
-#elif defined(TARGET_WINDOWS)
-#include "windows/ZeroconfBrowserWIN.h"
+#elif defined(HAS_MDNS)
+#include "mdns/ZeroconfBrowserMDNS.h"
 #endif
 
 #include "threads/CriticalSection.h"
 #include "threads/SingleLock.h"
 #include "threads/Atomics.h"
 
-#if !defined(HAS_ZEROCONF)
+// FIXME - once zeroconf browser with mdnsembedded is fixed -remove that condition here
+#if !defined(HAS_ZEROCONF) || defined(HAS_MDNS_EMBEDDED)
 //dummy implementation used if no zeroconf is present
 //should be optimized away
 class CZeroconfBrowserDummy : public CZeroconfBrowser
@@ -153,15 +152,16 @@ CZeroconfBrowser*  CZeroconfBrowser::GetInstance()
     CAtomicSpinLock lock(sm_singleton_guard);
     if(!smp_instance)
     {
-#if !defined(HAS_ZEROCONF)
+// FIXME - once zeroconf browser with mdnsembedded is fixed -remove that condition here
+#if !defined(HAS_ZEROCONF) || defined(HAS_MDNS_EMBEDDED)
       smp_instance = new CZeroconfBrowserDummy;
 #else
 #if defined(TARGET_DARWIN)
       smp_instance = new CZeroconfBrowserOSX;
-#elif defined(_LINUX)
+#elif defined(HAS_AVAHI)
       smp_instance  = new CZeroconfBrowserAvahi;
-#elif defined(TARGET_WINDOWS)
-      smp_instance  = new CZeroconfBrowserWIN;
+#elif defined(HAS_MDNS)
+      smp_instance  = new CZeroconfBrowserMDNS;
 #endif
 #endif
     }
index f3f9d23..a90c217 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "utils/StdString.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #undef SetPort // WIN32INCLUDES this is defined as SetPortA in WinSpool.h which is being included _somewhere_
 #endif
 
index 131484c..8796964 100644 (file)
@@ -26,7 +26,7 @@
 #include <sstream>
 #include <iostream>
 #include <map>
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #include <strstream>
 #endif
 #include "storage/cdioSupport.h"
index 522809d..a73f733 100644 (file)
@@ -64,8 +64,8 @@ int CHTTPVfsHandler::HandleHTTPRequest(const HTTPRequest &request)
 
           for (VECSOURCES::const_iterator source = sources->begin(); source != sources->end() && !accessible; source++)
           {
-            // don't allow access to locked sources
-            if (source->m_iHasLock == 2)
+            // don't allow access to locked / disabled sharing sources
+            if (source->m_iHasLock == 2 || !source->m_allowSharing)
               continue;
 
             for (vector<CStdString>::const_iterator path = source->vecPaths.begin(); path != source->vecPaths.end(); path++)
index c5d6528..7c1e003 100644 (file)
@@ -514,7 +514,7 @@ std::vector<CStdString> CNetworkLinux::GetNameServers(void)
 
 void CNetworkLinux::SetNameServers(std::vector<CStdString> nameServers)
 {
-#if !defined(__ANDROID__)
+#if !defined(TARGET_ANDROID)
    FILE* fp = fopen("/etc/resolv.conf", "w");
    if (fp != NULL)
    {
@@ -655,7 +655,7 @@ std::vector<NetworkAccessPoint> CNetworkInterfaceLinux::GetAccessPoints(void)
       return result;
 
 #if defined(TARGET_LINUX)
-   // Query the wireless extentsions version number. It will help us when we
+   // Query the wireless extension's version number. It will help us when we
    // parse the resulting events
    struct iwreq iwr;
    char rangebuffer[sizeof(iw_range) * 2];    /* Large enough */
@@ -680,14 +680,18 @@ std::vector<NetworkAccessPoint> CNetworkInterfaceLinux::GetAccessPoints(void)
    iwr.ifr_name[IFNAMSIZ - 1] = 0;
    if (ioctl(m_network->GetSocket(), SIOCSIWSCAN, &iwr) < 0)
    {
-      CLog::Log(LOGWARNING, "Cannot initiate wireless scan: ioctl[SIOCSIWSCAN]: %s", strerror(errno));
+      // Triggering scanning is a privileged operation (root only)
+      if (errno == EPERM)
+         CLog::Log(LOGWARNING, "Cannot initiate wireless scan: ioctl[SIOCSIWSCAN]: %s. Try running as root", strerror(errno));
+      else
+         CLog::Log(LOGWARNING, "Cannot initiate wireless scan: ioctl[SIOCSIWSCAN]: %s", strerror(errno));
       return result;
    }
 
    // Get the results of the scanning. Three scenarios:
    //    1. There's not enough room in the result buffer (E2BIG)
    //    2. The scanning is not complete (EAGAIN) and we need to try again. We cap this with 15 seconds.
-   //    3. Were'e good.
+   //    3. We're good.
    int duration = 0; // ms
    unsigned char* res_buf = NULL;
    int res_buf_len = IW_SCAN_MAX_DATA;
@@ -732,25 +736,29 @@ std::vector<NetworkAccessPoint> CNetworkInterfaceLinux::GetAccessPoints(void)
       }
    }
 
-   size_t len = iwr.u.data.length;
-   char* pos = (char *) res_buf;
-   char* end = (char *) res_buf + len;
-   char* custom;
-   struct iw_event iwe_buf, *iwe = &iwe_buf;
+   size_t len = iwr.u.data.length;           // total length of the wireless events from the scan results
+   unsigned char* pos = res_buf;             // pointer to the current event (about 10 per wireless network)
+   unsigned char* end = res_buf + len;       // marks the end of the scan results
+   unsigned char* custom;                    // pointer to the event payload
+   struct iw_event iwe_buf, *iwe = &iwe_buf; // buffer to hold individual events
 
    CStdString essId;
-   int quality = 0;
+   CStdString macAddress;
+   int signalLevel = 0;
    EncMode encryption = ENC_NONE;
-   bool first = true;
+   int channel = 0;
 
    while (pos + IW_EV_LCP_LEN <= end)
    {
       /* Event data may be unaligned, so make a local, aligned copy
        * before processing. */
+
+      // copy event prefix (size of event minus IOCTL fixed payload)
       memcpy(&iwe_buf, pos, IW_EV_LCP_LEN);
       if (iwe->len <= IW_EV_LCP_LEN)
          break;
 
+      // if the payload is nontrivial (i.e. > 16 octets) assume it comes after a pointer
       custom = pos + IW_EV_POINT_LEN;
       if (range->we_version_compiled > 18 &&
           (iwe->cmd == SIOCGIWESSID ||
@@ -758,29 +766,48 @@ std::vector<NetworkAccessPoint> CNetworkInterfaceLinux::GetAccessPoints(void)
            iwe->cmd == IWEVGENIE ||
            iwe->cmd == IWEVCUSTOM))
       {
-         /* Wireless extentsions v19 removed the pointer from struct iw_point */
-         char *dpos = (char *) &iwe_buf.u.data.length;
-         int dlen = dpos - (char *) &iwe_buf;
-         memcpy(dpos, pos + IW_EV_LCP_LEN, sizeof(struct iw_event) - dlen);
+         /* Wireless extensions v19 removed the pointer from struct iw_point */
+         char *data_pos = (char *) &iwe_buf.u.data.length;
+         int data_len = data_pos - (char *) &iwe_buf;
+         memcpy(data_pos, pos + IW_EV_LCP_LEN, sizeof(struct iw_event) - data_len);
       }
       else
       {
+         // copy the rest of the event and point custom toward the payload offset
          memcpy(&iwe_buf, pos, sizeof(struct iw_event));
          custom += IW_EV_POINT_OFF;
       }
 
+      // Interpret the payload based on event type. Each access point generates ~12 different events
       switch (iwe->cmd)
       {
+         // Get access point MAC addresses
          case SIOCGIWAP:
-            if (first)
-               first = false;
-            else
-            {
-               result.push_back(NetworkAccessPoint(essId, quality, encryption));
-               encryption = ENC_NONE;
-            }
+         {
+            // This event marks a new access point, so push back the old information
+            if (!macAddress.IsEmpty())
+               result.push_back(NetworkAccessPoint(essId, macAddress, signalLevel, encryption, channel));
+            unsigned char* mac = (unsigned char*)iwe->u.ap_addr.sa_data;
+            // macAddress is big-endian, write in byte chunks
+            macAddress.Format("%02x-%02x-%02x-%02x-%02x-%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+            // Reset the remaining fields
+            essId = "";
+            encryption = ENC_NONE;
+            signalLevel = 0;
+            channel = 0;
             break;
+         }
+
+         // Get operation mode
+         case SIOCGIWMODE:
+         {
+            // Ignore Ad-Hoc networks (1 is the magic number for this)
+            if (iwe->u.mode == 1)
+               macAddress = "";
+            break;
+         }
 
+         // Get ESSID
          case SIOCGIWESSID:
          {
             char essid[IW_ESSID_MAX_SIZE+1];
@@ -793,21 +820,42 @@ std::vector<NetworkAccessPoint> CNetworkInterfaceLinux::GetAccessPoints(void)
             break;
          }
 
+         // Quality part of statistics
          case IWEVQUAL:
-             quality = iwe->u.qual.qual;
-             break;
+         {
+            // u.qual.qual is scaled to a vendor-specific RSSI_Max, so use u.qual.level
+            signalLevel = iwe->u.qual.level - 0x100; // and remember we use 8-bit arithmetic
+            break;
+         }
 
+         // Get channel/frequency (Hz)
+         // This gets called twice per network, what's the difference between the two?
+         case SIOCGIWFREQ:
+         {
+            float freq = ((float)iwe->u.freq.m) * pow(10, iwe->u.freq.e);
+            if (freq > 1000)
+               channel = NetworkAccessPoint::FreqToChannel(freq);
+            else
+               channel = (int)freq; // Some drivers report channel instead of frequency
+            break;
+         }
+
+         // Get encoding token & mode
          case SIOCGIWENCODE:
-             if (!(iwe->u.data.flags & IW_ENCODE_DISABLED) && encryption == ENC_NONE)
-                encryption = ENC_WEP;
-             break;
+         {
+            if (!(iwe->u.data.flags & IW_ENCODE_DISABLED) && encryption == ENC_NONE)
+               encryption = ENC_WEP;
+            break;
+         }
 
+         // Generic IEEE 802.11 information element (IE) for WPA, RSN, WMM, ...
          case IWEVGENIE:
          {
             int offset = 0;
-            while (offset <= iwe_buf.u.data.length)
+            // Loop on each IE, each IE is minimum 2 bytes
+            while (offset <= (iwe_buf.u.data.length - 2))
             {
-               switch ((unsigned char)custom[offset])
+               switch (custom[offset])
                {
                   case 0xdd: /* WPA1 */
                      if (encryption != ENC_WPA2)
@@ -816,7 +864,7 @@ std::vector<NetworkAccessPoint> CNetworkInterfaceLinux::GetAccessPoints(void)
                   case 0x30: /* WPA2 */
                      encryption = ENC_WPA2;
                }
-
+               // Skip over this IE to the next one in the list
                offset += custom[offset+1] + 2;
             }
          }
@@ -825,8 +873,8 @@ std::vector<NetworkAccessPoint> CNetworkInterfaceLinux::GetAccessPoints(void)
       pos += iwe->len;
    }
 
-   if (!first)
-      result.push_back(NetworkAccessPoint(essId, quality, encryption));
+   if (!macAddress.IsEmpty())
+      result.push_back(NetworkAccessPoint(essId, macAddress, signalLevel, encryption, channel));
 
    free(res_buf);
    res_buf = NULL;
diff --git a/xbmc/network/mdns/Makefile b/xbmc/network/mdns/Makefile
new file mode 100644 (file)
index 0000000..5ea37cb
--- /dev/null
@@ -0,0 +1,7 @@
+SRCS=ZeroconfMDNS.cpp \
+     ZeroconfBrowserMDNS.cpp \
+
+LIB=mdns.a
+
+include ../../../Makefile.include
+-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
diff --git a/xbmc/network/mdns/ZeroconfBrowserMDNS.cpp b/xbmc/network/mdns/ZeroconfBrowserMDNS.cpp
new file mode 100644 (file)
index 0000000..7a2ff0d
--- /dev/null
@@ -0,0 +1,336 @@
+/*
+ *      Copyright (C) 2012-2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ZeroconfBrowserMDNS.h"
+#include <utils/log.h>
+#include <threads/SingleLock.h>
+#include "guilib/GUIWindowManager.h"
+#include "guilib/GUIMessage.h"
+#include "GUIUserMessages.h"
+#if defined(TARGET_WINDOWS)
+#include "win32/WIN32Util.h"
+#endif //TARGET_WINDOWS
+#include "network/DNSNameCache.h"
+
+#pragma comment(lib, "dnssd.lib")
+
+extern HWND g_hWnd;
+
+
+CZeroconfBrowserMDNS::CZeroconfBrowserMDNS()
+{
+  m_browser = NULL;
+}
+
+CZeroconfBrowserMDNS::~CZeroconfBrowserMDNS()
+{
+  CSingleLock lock(m_data_guard);
+  //make sure there are no browsers anymore
+  for(tBrowserMap::iterator it = m_service_browsers.begin(); it != m_service_browsers.end(); ++it )
+    doRemoveServiceType(it->first);
+
+#if defined(TARGET_WINDOWS)
+  WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_browser ), g_hWnd, BONJOUR_BROWSER_EVENT, 0 );
+#endif //TARGET_WINDOWS
+
+  if (m_browser)
+    DNSServiceRefDeallocate(m_browser);
+  m_browser = NULL;
+}
+
+void DNSSD_API CZeroconfBrowserMDNS::BrowserCallback(DNSServiceRef browser,
+                                                    DNSServiceFlags flags,
+                                                    uint32_t interfaceIndex,
+                                                    DNSServiceErrorType errorCode,
+                                                    const char *serviceName,
+                                                    const char *regtype,
+                                                    const char *replyDomain,
+                                                    void *context)
+{
+
+  if (errorCode == kDNSServiceErr_NoError)
+  {
+    //get our instance
+    CZeroconfBrowserMDNS* p_this = reinterpret_cast<CZeroconfBrowserMDNS*>(context);
+    //store the service
+    ZeroconfService s(serviceName, regtype, replyDomain);
+
+    if (flags & kDNSServiceFlagsAdd)
+    {
+      CLog::Log(LOGDEBUG, "ZeroconfBrowserMDNS::BrowserCallback found service named: %s, type: %s, domain: %s", s.GetName().c_str(), s.GetType().c_str(), s.GetDomain().c_str());
+      p_this->addDiscoveredService(browser, s);
+    }
+    else
+    {
+      CLog::Log(LOGDEBUG, "ZeroconfBrowserMDNS::BrowserCallback service named: %s, type: %s, domain: %s disappeared", s.GetName().c_str(), s.GetType().c_str(), s.GetDomain().c_str());
+      p_this->removeDiscoveredService(browser, s);
+    }
+    if(! (flags & kDNSServiceFlagsMoreComing) )
+    {
+      CGUIMessage message(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_PATH);
+      message.SetStringParam("zeroconf://");
+      g_windowManager.SendThreadMessage(message);
+      CLog::Log(LOGDEBUG, "ZeroconfBrowserMDNS::BrowserCallback sent gui update for path zeroconf://");
+    }
+  }
+  else
+  {
+    CLog::Log(LOGERROR, "ZeroconfBrowserMDNS::BrowserCallback returned (error = %ld)\n", (int)errorCode);
+  }
+}
+
+void DNSSD_API CZeroconfBrowserMDNS::ResolveCallback(DNSServiceRef                       sdRef,
+                                                    DNSServiceFlags                     flags,
+                                                    uint32_t                            interfaceIndex,
+                                                    DNSServiceErrorType                 errorCode,
+                                                    const char                          *fullname,
+                                                    const char                          *hosttarget,
+                                                    uint16_t                            port,        /* In network byte order */
+                                                    uint16_t                            txtLen,
+                                                    const unsigned char                 *txtRecord,
+                                                    void                                *context
+                                                    )
+{
+
+  if (errorCode)
+  {
+    CLog::Log(LOGERROR, "ZeroconfBrowserMDNS: ResolveCallback failed with error = %ld", (int) errorCode);
+    return;
+  }
+
+  DNSServiceErrorType err;
+  CZeroconfBrowser::ZeroconfService::tTxtRecordMap recordMap; 
+  CStdString strIP;
+  CZeroconfBrowserMDNS* p_instance = static_cast<CZeroconfBrowserMDNS*> ( context );
+
+  if(!CDNSNameCache::Lookup(hosttarget, strIP))
+  {
+    CLog::Log(LOGERROR, "ZeroconfBrowserMDNS: Could not resolve hostname %s",hosttarget);
+    p_instance->m_resolved_event.Set();
+    return;
+  }
+  p_instance->m_resolving_service.SetIP(strIP);
+
+  for(uint16_t i = 0; i < TXTRecordGetCount(txtLen, txtRecord); ++i)
+  {
+    char key[256];
+    uint8_t valueLen;
+    const void *value;
+    std::string strvalue;
+    err = TXTRecordGetItemAtIndex(txtLen, txtRecord,i ,sizeof(key) , key, &valueLen, &value);
+    if(err != kDNSServiceErr_NoError)
+      continue;
+
+    if(value != NULL && valueLen > 0)
+      strvalue.append((const char *)value, valueLen);
+
+    recordMap.insert(std::make_pair(key, strvalue));
+  }
+  p_instance->m_resolving_service.SetTxtRecords(recordMap);
+  p_instance->m_resolving_service.SetPort(ntohs(port));
+  p_instance->m_resolved_event.Set();
+}
+
+/// adds the service to list of found services
+void CZeroconfBrowserMDNS::addDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service)
+{
+  CSingleLock lock(m_data_guard);
+  tDiscoveredServicesMap::iterator browserIt = m_discovered_services.find(browser);
+  if(browserIt == m_discovered_services.end())
+  {
+     //first service by this browser
+     browserIt = m_discovered_services.insert(make_pair(browser, std::vector<std::pair<ZeroconfService, unsigned int> >())).first;
+  }
+  //search this service
+  std::vector<std::pair<ZeroconfService, unsigned int> >& services = browserIt->second;
+  std::vector<std::pair<ZeroconfService, unsigned int> >::iterator serviceIt = services.begin();
+  for( ; serviceIt != services.end(); ++serviceIt)
+  {
+    if(serviceIt->first == fcr_service)
+      break;
+  }
+  if(serviceIt == services.end())
+    services.push_back(std::make_pair(fcr_service, 1));
+  else
+    ++serviceIt->second;
+}
+
+void CZeroconfBrowserMDNS::removeDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service)
+{
+  CSingleLock lock(m_data_guard);
+  tDiscoveredServicesMap::iterator browserIt = m_discovered_services.find(browser);
+  //search this service
+  std::vector<std::pair<ZeroconfService, unsigned int> >& services = browserIt->second;
+  std::vector<std::pair<ZeroconfService, unsigned int> >::iterator serviceIt = services.begin();
+  for( ; serviceIt != services.end(); ++serviceIt)
+    if(serviceIt->first == fcr_service)
+      break;
+  if(serviceIt != services.end())
+  {
+    //decrease refCount
+    --serviceIt->second;
+    if(!serviceIt->second)
+    {
+      //eventually remove the service
+      services.erase(serviceIt);
+    }
+  } else
+  {
+    //looks like we missed the announce, no problem though..
+  }
+}
+
+
+bool CZeroconfBrowserMDNS::doAddServiceType(const CStdString& fcr_service_type)
+{
+  DNSServiceErrorType err;
+  DNSServiceRef browser = NULL;
+
+#if !defined(HAS_MDNS_EMBEDDED)
+  if(m_browser == NULL)
+  {
+    err = DNSServiceCreateConnection(&m_browser);
+    if (err != kDNSServiceErr_NoError)
+    {
+      CLog::Log(LOGERROR, "ZeroconfBrowserMDNS: DNSServiceCreateConnection failed with error = %ld", (int) err);
+      return false;
+    }
+#if defined(TARGET_WINDOWS)
+    err = WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_browser ), g_hWnd, BONJOUR_BROWSER_EVENT, FD_READ | FD_CLOSE );
+    if (err != kDNSServiceErr_NoError)
+      CLog::Log(LOGERROR, "ZeroconfBrowserMDNS: WSAAsyncSelect failed with error = %ld", (int) err);
+#endif //TARGET_WINDOWS
+  }
+#endif //!HAS_MDNS_EMBEDDED
+
+  {
+    CSingleLock lock(m_data_guard);
+    browser = m_browser;
+    err = DNSServiceBrowse(&browser, kDNSServiceFlagsShareConnection, kDNSServiceInterfaceIndexAny, fcr_service_type.c_str(), NULL, BrowserCallback, this);
+  }
+
+  if( err != kDNSServiceErr_NoError )
+  {
+    if (browser)
+      DNSServiceRefDeallocate(browser);
+
+    CLog::Log(LOGERROR, "ZeroconfBrowserMDNS: DNSServiceBrowse returned (error = %ld)", (int) err);
+    return false;
+  }
+
+  //store the browser
+  {
+    CSingleLock lock(m_data_guard);
+    m_service_browsers.insert(std::make_pair(fcr_service_type, browser));
+  }
+
+  return true;
+}
+
+bool CZeroconfBrowserMDNS::doRemoveServiceType(const CStdString& fcr_service_type)
+{
+  //search for this browser and remove it from the map
+  DNSServiceRef browser = 0;
+  {
+    CSingleLock lock(m_data_guard);
+    tBrowserMap::iterator it = m_service_browsers.find(fcr_service_type);
+    if(it == m_service_browsers.end())
+    {
+      return false;
+    }
+    browser = it->second;
+    m_service_browsers.erase(it);
+  }
+
+  //remove the services of this browser
+  {
+    CSingleLock lock(m_data_guard);
+    tDiscoveredServicesMap::iterator it = m_discovered_services.find(browser);
+    if(it != m_discovered_services.end())
+      m_discovered_services.erase(it);
+  }
+
+  if (browser)
+    DNSServiceRefDeallocate(browser);
+
+  return true;
+}
+
+std::vector<CZeroconfBrowser::ZeroconfService> CZeroconfBrowserMDNS::doGetFoundServices()
+{
+  std::vector<CZeroconfBrowser::ZeroconfService> ret;
+  CSingleLock lock(m_data_guard);
+  for(tDiscoveredServicesMap::const_iterator it = m_discovered_services.begin();
+      it != m_discovered_services.end(); ++it)
+  {
+    const std::vector<std::pair<CZeroconfBrowser::ZeroconfService, unsigned int> >& services = it->second;
+    for(unsigned int i = 0; i < services.size(); ++i)
+    {
+      ret.push_back(services[i].first);
+    }
+  }
+  return ret;
+}
+
+bool CZeroconfBrowserMDNS::doResolveService(CZeroconfBrowser::ZeroconfService& fr_service, double f_timeout)
+{
+  DNSServiceErrorType err;
+  DNSServiceRef sdRef = NULL;
+  
+  //start resolving
+  m_resolving_service = fr_service;
+  m_resolved_event.Reset();
+
+  err = DNSServiceResolve(&sdRef, 0, kDNSServiceInterfaceIndexAny, fr_service.GetName(), fr_service.GetType(), fr_service.GetDomain(), ResolveCallback, this);
+
+  if( err != kDNSServiceErr_NoError )
+  {
+    if (sdRef)
+      DNSServiceRefDeallocate(sdRef);
+
+    CLog::Log(LOGERROR, "ZeroconfBrowserMDNS: DNSServiceResolve returned (error = %ld)", (int) err);
+    return false;
+  }
+
+  err = DNSServiceProcessResult(sdRef);
+
+  if (err != kDNSServiceErr_NoError)
+      CLog::Log(LOGERROR, "ZeroconfBrowserMDNS::doResolveService DNSServiceProcessResult returned (error = %ld)", (int) err);
+
+  if (sdRef)
+    DNSServiceRefDeallocate(sdRef);
+
+#if defined(HAS_MDNS_EMBEDDED)
+  // when using the embedded mdns service the call to DNSServiceProcessResult
+  // above will not block until the resolving was finished - instead we have to
+  // wait for resolve to return or timeout  
+  m_resolved_event.WaitMSec(f_timeout * 1000);
+#endif //HAS_MDNS_EMBEDDED
+  fr_service = m_resolving_service;
+  return (!fr_service.GetIP().empty());
+}
+
+void CZeroconfBrowserMDNS::ProcessResults()
+{
+  CSingleLock lock(m_data_guard);
+  DNSServiceErrorType err = DNSServiceProcessResult(m_browser);
+  if (err != kDNSServiceErr_NoError)
+    CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceProcessResult returned (error = %ld)", (int) err);
+}
diff --git a/xbmc/network/mdns/ZeroconfBrowserMDNS.h b/xbmc/network/mdns/ZeroconfBrowserMDNS.h
new file mode 100644 (file)
index 0000000..506bf21
--- /dev/null
@@ -0,0 +1,88 @@
+#pragma once
+/*
+ *      Copyright (C) 2012-2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <memory>
+#include <map>
+
+#include "network/ZeroconfBrowser.h"
+#include "threads/Thread.h"
+#include "threads/CriticalSection.h"
+#include <dns_sd.h>
+
+//platform specific implementation of  zeroconfbrowser interface using native os x APIs
+class CZeroconfBrowserMDNS : public CZeroconfBrowser
+{
+public:
+  CZeroconfBrowserMDNS();
+  ~CZeroconfBrowserMDNS();
+
+private:
+  ///implementation if CZeroconfBrowser interface
+  ///@{
+  virtual bool doAddServiceType(const CStdString& fcr_service_type);
+  virtual bool doRemoveServiceType(const CStdString& fcr_service_type);
+
+  virtual std::vector<CZeroconfBrowser::ZeroconfService> doGetFoundServices();
+  virtual bool doResolveService(CZeroconfBrowser::ZeroconfService& fr_service, double f_timeout);
+  ///@}
+
+  /// browser callback
+  static void DNSSD_API BrowserCallback(DNSServiceRef browser,
+                                        DNSServiceFlags flags,
+                                        uint32_t interfaceIndex,
+                                        DNSServiceErrorType errorCode,
+                                        const char *serviceName,
+                                        const char *regtype,
+                                        const char *replyDomain,
+                                        void *context);
+  /// resolve callback
+  static void DNSSD_API ResolveCallback(DNSServiceRef                       sdRef,
+                                        DNSServiceFlags                     flags,
+                                        uint32_t                            interfaceIndex,
+                                        DNSServiceErrorType                 errorCode,
+                                        const char                          *fullname,
+                                        const char                          *hosttarget,
+                                        uint16_t                            port,        /* In network byte order */
+                                        uint16_t                            txtLen,
+                                        const unsigned char                 *txtRecord,
+                                        void                                *context
+                                        );
+
+  /// adds the service to list of found services
+  void addDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service);
+  /// removes the service from list of found services
+  void removeDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service);
+  // win32: process replies from the bonjour daemon
+  void ProcessResults();
+
+  //shared variables (with guard)
+  CCriticalSection m_data_guard;
+  // tBrowserMap maps service types the corresponding browser
+  typedef std::map<std::string, DNSServiceRef> tBrowserMap;
+  tBrowserMap m_service_browsers;
+  //tDiscoveredServicesMap maps browsers to their discovered services + a ref-count for each service
+  //ref-count is needed, because a service might pop up more than once, if there's more than one network-iface
+  typedef std::map<DNSServiceRef, std::vector<std::pair<ZeroconfService, unsigned int> > > tDiscoveredServicesMap;
+  tDiscoveredServicesMap m_discovered_services;
+  DNSServiceRef m_browser;
+  CZeroconfBrowser::ZeroconfService m_resolving_service;
+  CEvent m_resolved_event;
+};
diff --git a/xbmc/network/mdns/ZeroconfMDNS.cpp b/xbmc/network/mdns/ZeroconfMDNS.cpp
new file mode 100644 (file)
index 0000000..7401364
--- /dev/null
@@ -0,0 +1,219 @@
+/*
+ *      Copyright (C) 2005-2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ZeroconfMDNS.h"
+
+#include <string>
+#include <sstream>
+#include <threads/SingleLock.h>
+#include <utils/log.h>
+#include "dialogs/GUIDialogKaiToast.h"
+#include "guilib/LocalizeStrings.h"
+#if defined(TARGET_WINDOWS)
+#include "win32/WIN32Util.h"
+#endif //TARGET_WINDOWS
+
+#if defined(HAS_MDNS_EMBEDDED)
+#include <mDnsEmbedded.h>
+#endif //HAS_MDNS_EMBEDDED
+
+#pragma comment(lib, "dnssd.lib")
+
+extern HWND g_hWnd;
+
+void CZeroconfMDNS::Process()
+{
+#if defined(HAS_MDNS_EMBEDDED)
+  CLog::Log(LOGDEBUG, "ZeroconfEmbedded - processing...");
+  struct timeval timeout;
+  timeout.tv_sec = 1;
+  while (( !m_bStop ))
+    embedded_mDNSmainLoop(timeout);
+#endif //HAS_MDNS_EMBEDDED
+
+}
+
+
+CZeroconfMDNS::CZeroconfMDNS()  : CThread("ZerocconfEmbedded")
+{
+  m_service = NULL;
+#if defined(HAS_MDNS_EMBEDDED)
+  embedded_mDNSInit();
+  Create();
+#endif //HAS_MDNS_EMBEDDED
+}
+
+CZeroconfMDNS::~CZeroconfMDNS()
+{
+  doStop();
+#if defined(HAS_MDNS_EMBEDDED)
+  StopThread();
+  embedded_mDNSExit();
+#endif //HAS_MDNS_EMBEDDED
+}
+
+bool CZeroconfMDNS::IsZCdaemonRunning()
+{
+#if !defined(HAS_MDNS_EMBEDDED)
+  uint32_t version;
+  uint32_t size = sizeof(version);
+  DNSServiceErrorType err = DNSServiceGetProperty(kDNSServiceProperty_DaemonVersion, &version, &size);
+  if(err != kDNSServiceErr_NoError)
+  {
+    CLog::Log(LOGERROR, "ZeroconfMDNS: Zeroconf can't be started probably because Apple's Bonjour Service isn't installed. You can get it by either installing Itunes or Apple's Bonjour Print Service for Windows (http://support.apple.com/kb/DL999)");
+    CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(34300), g_localizeStrings.Get(34301), 10000, true);
+    return false;
+  }
+  CLog::Log(LOGDEBUG, "ZeroconfMDNS:Bonjour version is %d.%d", version / 10000, version / 100 % 100);
+#endif //!HAS_MDNS_EMBEDDED
+  return true;
+}
+
+//methods to implement for concrete implementations
+bool CZeroconfMDNS::doPublishService(const std::string& fcr_identifier,
+                      const std::string& fcr_type,
+                      const std::string& fcr_name,
+                      unsigned int f_port,
+                      const std::vector<std::pair<std::string, std::string> >& txt)
+{
+  DNSServiceRef netService = NULL;
+  TXTRecordRef txtRecord;
+  DNSServiceErrorType err;
+  TXTRecordCreate(&txtRecord, 0, NULL);
+
+#if !defined(HAS_MDNS_EMBEDDED)
+  if(m_service == NULL)
+  {
+    err = DNSServiceCreateConnection(&m_service);
+    if (err != kDNSServiceErr_NoError)
+    {
+      CLog::Log(LOGERROR, "ZeroconfMDNS: DNSServiceCreateConnection failed with error = %ld", (int) err);
+      return false;
+    }
+    err = WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_service ), g_hWnd, BONJOUR_EVENT, FD_READ | FD_CLOSE );
+    if (err != kDNSServiceErr_NoError)
+      CLog::Log(LOGERROR, "ZeroconfMDNS: WSAAsyncSelect failed with error = %ld", (int) err);
+  }
+#endif //!HAS_MDNS_EMBEDDED
+
+  CLog::Log(LOGDEBUG, "ZeroconfMDNS: identifier: %s type: %s name:%s port:%i", fcr_identifier.c_str(), fcr_type.c_str(), fcr_name.c_str(), f_port);
+
+  //add txt records
+  if(!txt.empty())
+  {
+    for(std::vector<std::pair<std::string, std::string> >::const_iterator it = txt.begin(); it != txt.end(); ++it)
+    {
+      CLog::Log(LOGDEBUG, "ZeroconfMDNS: key:%s, value:%s",it->first.c_str(),it->second.c_str());
+      uint8_t txtLen = (uint8_t)strlen(it->second.c_str());
+      TXTRecordSetValue(&txtRecord, it->first.c_str(), txtLen, it->second.c_str());
+    }
+  }
+
+  {
+    CSingleLock lock(m_data_guard);
+    netService = m_service;
+    err = DNSServiceRegister(&netService, kDNSServiceFlagsShareConnection, 0, fcr_name.c_str(), fcr_type.c_str(), NULL, NULL, htons(f_port), TXTRecordGetLength(&txtRecord), TXTRecordGetBytesPtr(&txtRecord), registerCallback, NULL);
+  }
+
+  if (err != kDNSServiceErr_NoError)
+  {
+    // Something went wrong so lets clean up.
+    if (netService)
+      DNSServiceRefDeallocate(netService);
+
+    CLog::Log(LOGERROR, "ZeroconfMDNS: DNSServiceRegister returned (error = %ld)", (int) err);
+  }
+  else
+  {
+    CSingleLock lock(m_data_guard);
+    m_services.insert(make_pair(fcr_identifier, netService));
+  }
+
+  TXTRecordDeallocate(&txtRecord);
+
+  return err == kDNSServiceErr_NoError;
+}
+
+bool CZeroconfMDNS::doRemoveService(const std::string& fcr_ident)
+{
+  CSingleLock lock(m_data_guard);
+  tServiceMap::iterator it = m_services.find(fcr_ident);
+  if(it != m_services.end())
+  {
+    DNSServiceRefDeallocate(it->second);
+    m_services.erase(it);
+    CLog::Log(LOGDEBUG, "ZeroconfMDNS: Removed service %s", fcr_ident.c_str());
+    return true;
+  }
+  else
+    return false;
+}
+
+void CZeroconfMDNS::doStop()
+{
+  {
+    CSingleLock lock(m_data_guard);
+    CLog::Log(LOGDEBUG, "ZeroconfMDNS: Shutdown services");
+    for(tServiceMap::iterator it = m_services.begin(); it != m_services.end(); ++it)
+    {
+      DNSServiceRefDeallocate(it->second);
+      CLog::Log(LOGDEBUG, "ZeroconfMDNS: Removed service %s", it->first.c_str());
+    }
+    m_services.clear();
+  }
+  {
+    CSingleLock lock(m_data_guard);
+#if defined(TARGET_WINDOWS)
+    WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_service ), g_hWnd, BONJOUR_EVENT, 0 );
+#endif //TARGET_WINDOWS
+
+    if (m_service)
+      DNSServiceRefDeallocate(m_service);
+    m_service = NULL;
+  }
+}
+
+void DNSSD_API CZeroconfMDNS::registerCallback(DNSServiceRef sdref, const DNSServiceFlags flags, DNSServiceErrorType errorCode, const char *name, const char *regtype, const char *domain, void *context)
+{
+  (void)sdref;    // Unused
+  (void)flags;    // Unused
+  (void)context;  // Unused
+
+  if (errorCode == kDNSServiceErr_NoError)
+  {
+    if (flags & kDNSServiceFlagsAdd)
+      CLog::Log(LOGDEBUG, "ZeroconfMDNS: %s.%s%s now registered and active", name, regtype, domain);
+    else
+      CLog::Log(LOGDEBUG, "ZeroconfMDNS: %s.%s%s registration removed", name, regtype, domain);
+  }
+  else if (errorCode == kDNSServiceErr_NameConflict)
+     CLog::Log(LOGDEBUG, "ZeroconfMDNS: %s.%s%s Name in use, please choose another", name, regtype, domain);
+  else
+    CLog::Log(LOGDEBUG, "ZeroconfMDNS: %s.%s%s error code %d", name, regtype, domain, errorCode);
+}
+
+void CZeroconfMDNS::ProcessResults()
+{
+  CSingleLock lock(m_data_guard);
+  DNSServiceErrorType err = DNSServiceProcessResult(m_service);
+  if (err != kDNSServiceErr_NoError)
+    CLog::Log(LOGERROR, "ZeroconfMDNS: DNSServiceProcessResult returned (error = %ld)", (int) err);
+}
+
diff --git a/xbmc/network/mdns/ZeroconfMDNS.h b/xbmc/network/mdns/ZeroconfMDNS.h
new file mode 100644 (file)
index 0000000..b8eba69
--- /dev/null
@@ -0,0 +1,71 @@
+#pragma once
+/*
+ *      Copyright (C) 2005-2013 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, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <memory>
+
+#include "network/Zeroconf.h"
+#include "threads/CriticalSection.h"
+#include <dns_sd.h>
+#include "threads/Thread.h"
+
+class CZeroconfMDNS : public CZeroconf,public CThread
+{
+public:
+  CZeroconfMDNS();
+  ~CZeroconfMDNS();
+
+protected:
+
+  //CThread interface
+  void Process();
+
+  //implement base CZeroConf interface
+  bool doPublishService(const std::string& fcr_identifier,
+                        const std::string& fcr_type,
+                        const std::string& fcr_name,
+                        unsigned int f_port,
+                        const std::vector<std::pair<std::string, std::string> >& txt);
+
+  bool doRemoveService(const std::string& fcr_ident);
+
+  virtual void doStop();
+
+  bool IsZCdaemonRunning();
+
+  void ProcessResults();
+
+private:
+
+  static void DNSSD_API registerCallback(DNSServiceRef sdref,
+                                         const DNSServiceFlags flags,
+                                         DNSServiceErrorType errorCode,
+                                         const char *name,
+                                         const char *regtype,
+                                         const char *domain,
+                                         void *context);
+
+
+  //lock + data (accessed from runloop(main thread) + the rest)
+  CCriticalSection m_data_guard;
+  typedef std::map<std::string, DNSServiceRef> tServiceMap;
+  tServiceMap m_services;
+  DNSServiceRef m_service;
+};
index 339f5c3..98ade1b 100644 (file)
@@ -561,8 +561,7 @@ BuildObject(CFileItem&                    item,
             CTextureCache::GetWrappedImageURL(thumb).c_str());
 
         // Set DLNA profileID by extension, defaulting to JPEG.
-        NPT_String ext = URIUtils::GetExtension(thumb).c_str();
-        if (strcmp(ext, ".png") == 0) {
+        if (URIUtils::HasExtension(thumb, ".png")) {
             art.dlna_profile = "PNG_TN";
         } else {
             art.dlna_profile = "JPEG_TN";
index 986824a..51e9cc8 100644 (file)
@@ -392,8 +392,7 @@ CUPnPRenderer::GetMetadata(NPT_String& meta)
             "/thumb",
             query.ToString()).ToString();
         // Set DLNA profileID by extension, defaulting to JPEG.
-        NPT_String ext = URIUtils::GetExtension(item.GetArt("thumb")).c_str();
-        if (strcmp(ext, ".png") == 0) {
+        if (URIUtils::HasExtension(item.GetArt("thumb"), ".png")) {
             art.dlna_profile = "PNG_TN";
         } else {
             art.dlna_profile = "JPEG_TN";
index 9bbd6d8..2549a70 100644 (file)
@@ -24,6 +24,7 @@
 #include "video/VideoDatabase.h"
 #include "guilib/GUIWindowManager.h"
 #include "xbmc/GUIUserMessages.h"
+#include "utils/FileUtils.h"
 
 using namespace std;
 using namespace ANNOUNCEMENT;
@@ -475,23 +476,7 @@ static NPT_String TranslateWMPObjectId(NPT_String id)
 NPT_Result
 ObjectIDValidate(const NPT_String& id)
 {
-    if(id.Find("..") != -1)
-        return NPT_ERROR_NO_SUCH_FILE;
-    if(id.StartsWith("virtualpath://upnproot/"))
-        return NPT_SUCCESS;
-    else if(id.StartsWith("musicdb://"))
-        return NPT_SUCCESS;
-    else if(id.StartsWith("videodb://"))
-        return NPT_SUCCESS;
-    else if(id.StartsWith("library://video"))
-        return NPT_SUCCESS;
-    else if(id.StartsWith("sources://video"))
-        return NPT_SUCCESS;
-    else if(id.StartsWith("special://musicplaylists"))
-        return NPT_SUCCESS;
-    else if(id.StartsWith("special://profile/playlists"))
-        return NPT_SUCCESS;
-    else if(id.StartsWith("special://videoplaylists"))
+    if (CFileUtils::RemoteAccessAllowed(id.GetChars()))
         return NPT_SUCCESS;
     return NPT_ERROR_NO_SUCH_FILE;
 }
index 03b0507..85fc48f 100644 (file)
@@ -52,7 +52,7 @@ CUPnPSettings& CUPnPSettings::Get()
   return sUPnPSettings;
 }
 
-void CUPnPSettings::OnSettingsCleared()
+void CUPnPSettings::OnSettingsUnloaded()
 {
   Clear();
 }
index 4efb6f5..8586140 100644 (file)
@@ -29,7 +29,7 @@ class CUPnPSettings : public ISettingsHandler
 public:
   static CUPnPSettings& Get();
   
-  virtual void OnSettingsCleared();
+  virtual void OnSettingsUnloaded();
 
   bool Load(const std::string &file);
   bool Save(const std::string &file) const;
index 82fe5a8..53c5233 100644 (file)
@@ -29,7 +29,7 @@
 
 // undefine if you want to build without the wlan stuff
 // might be needed for VS2003
-//#define HAS_WIN32_WLAN_API
+#define HAS_WIN32_WLAN_API
 
 #ifdef HAS_WIN32_WLAN_API
 #include "Wlanapi.h"
@@ -115,7 +115,7 @@ CStdString CNetworkInterfaceWin32::GetCurrentWirelessEssId(void)
       PWLAN_INTERFACE_INFO_LIST ppInterfaceList;
       if(WlanEnumInterfaces(hClientHdl,NULL, &ppInterfaceList ) == ERROR_SUCCESS)
       {
-        for(int i=0; i<ppInterfaceList->dwNumberOfItems;i++)
+        for(unsigned int i=0; i<ppInterfaceList->dwNumberOfItems;i++)
         {
           GUID guid = ppInterfaceList->InterfaceInfo[i].InterfaceGuid;
           WCHAR wcguid[64];
@@ -318,8 +318,85 @@ bool CNetworkInterfaceWin32::GetHostMacAddress(unsigned long host, CStdString& m
 std::vector<NetworkAccessPoint> CNetworkInterfaceWin32::GetAccessPoints(void)
 {
    std::vector<NetworkAccessPoint> result;
+#ifdef HAS_WIN32_WLAN_API
+  if (!IsWireless())
+    return result;
+
+  // According to Mozilla: "We could be executing on either Windows XP or Windows
+  // Vista, so use the lower version of the client WLAN API. It seems that the
+  // negotiated version is the Vista version irrespective of what we pass!"
+  // http://dxr.mozilla.org/mozilla-central/source/netwerk/wifi/nsWifiScannerWin.cpp#l51
+  static const int xpWlanClientVersion = 1;
+  DWORD negotiated_version;
+  DWORD dwResult;
+  HANDLE wlan_handle = NULL;
+
+  // Get the handle to the WLAN API
+  dwResult = WlanOpenHandle(xpWlanClientVersion, NULL, &negotiated_version, &wlan_handle);
+  if (dwResult != ERROR_SUCCESS || !wlan_handle)
+  {
+    CLog::Log(LOGERROR, "Could not load the client WLAN API");
+    return result;
+  }
+
+  // Get the list of interfaces (WlanEnumInterfaces allocates interface_list)
+  WLAN_INTERFACE_INFO_LIST *interface_list = NULL;
+  dwResult = WlanEnumInterfaces(wlan_handle, NULL, &interface_list);
+  if (dwResult != ERROR_SUCCESS || !interface_list)
+  {
+    WlanCloseHandle(wlan_handle, NULL);
+    CLog::Log(LOGERROR, "Failed to get the list of interfaces");
+    return result;
+  }
+
+  for (unsigned int i = 0; i < interface_list->dwNumberOfItems; ++i)
+  {
+    GUID guid = interface_list->InterfaceInfo[i].InterfaceGuid;
+    WCHAR wcguid[64];
+    StringFromGUID2(guid, (LPOLESTR)&wcguid, 64);
+    CStdStringW strGuid = wcguid;
+    CStdStringW strAdaptername = m_adapter.AdapterName;
+    if (strGuid == strAdaptername)
+    {
+      WLAN_BSS_LIST *bss_list;
+      HRESULT rv = WlanGetNetworkBssList(wlan_handle,
+                                         &interface_list->InterfaceInfo[i].InterfaceGuid,
+                                         NULL,               // Get all SSIDs
+                                         dot11_BSS_type_any, // unused
+                                         false,              // bSecurityEnabled - unused
+                                         NULL,               // reserved
+                                         &bss_list);
+      if (rv != ERROR_SUCCESS || !bss_list)
+        break;
+      for (unsigned int j = 0; j < bss_list->dwNumberOfItems; ++j)
+      {
+        const WLAN_BSS_ENTRY bss_entry = bss_list->wlanBssEntries[j];
+        // Add the access point info to the list of results
+        CStdString essId((char*)bss_entry.dot11Ssid.ucSSID, (unsigned int)bss_entry.dot11Ssid.uSSIDLength);
+        CStdString macAddress;
+        // macAddress is big-endian, write in byte chunks
+        macAddress.Format("%02x-%02x-%02x-%02x-%02x-%02x",
+          bss_entry.dot11Bssid[0], bss_entry.dot11Bssid[1], bss_entry.dot11Bssid[2],
+          bss_entry.dot11Bssid[3], bss_entry.dot11Bssid[4], bss_entry.dot11Bssid[5]);
+        int signalLevel = bss_entry.lRssi;
+        EncMode encryption = ENC_NONE; // TODO
+        int channel = NetworkAccessPoint::FreqToChannel((float)bss_entry.ulChCenterFrequency * 1000);
+        result.push_back(NetworkAccessPoint(essId, macAddress, signalLevel, encryption, channel));
+      }
+      WlanFreeMemory(bss_list);
+      break;
+    }
+  }
 
-   return result;
+  // Free the interface list
+  WlanFreeMemory(interface_list);
+
+  // Close the handle
+  WlanCloseHandle(wlan_handle, NULL);
+
+#endif
+
+  return result;
 }
 
 void CNetworkInterfaceWin32::GetSettings(NetworkAssignment& assignment, CStdString& ipAddress, CStdString& networkMask, CStdString& defaultGateway, CStdString& essId, CStdString& key, EncMode& encryptionMode)
@@ -388,7 +465,7 @@ void CNetworkInterfaceWin32::GetSettings(NetworkAssignment& assignment, CStdStri
       PWLAN_INTERFACE_INFO_LIST ppInterfaceList;
       if(WlanEnumInterfaces(hClientHdl,NULL, &ppInterfaceList ) == ERROR_SUCCESS)
       {
-        for(int i=0; i<ppInterfaceList->dwNumberOfItems;i++)
+        for(unsigned int i=0; i<ppInterfaceList->dwNumberOfItems;i++)
         {
           GUID guid = ppInterfaceList->InterfaceInfo[i].InterfaceGuid;
           WCHAR wcguid[64];
diff --git a/xbmc/network/windows/ZeroconfBrowserWIN.cpp b/xbmc/network/windows/ZeroconfBrowserWIN.cpp
deleted file mode 100644 (file)
index ce921f1..0000000
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- *      Copyright (C) 2012-2013 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, see
- *  <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "ZeroconfBrowserWIN.h"
-#include <utils/log.h>
-#include <threads/SingleLock.h>
-#include "guilib/GUIWindowManager.h"
-#include "guilib/GUIMessage.h"
-#include "GUIUserMessages.h"
-#include "win32/WIN32Util.h"
-#include "network/DNSNameCache.h"
-
-#pragma comment(lib, "dnssd.lib")
-
-extern HWND g_hWnd;
-
-CZeroconfBrowserWIN::CZeroconfBrowserWIN()
-{
-  m_browser = NULL;
-}
-
-CZeroconfBrowserWIN::~CZeroconfBrowserWIN()
-{
-  CSingleLock lock(m_data_guard);
-  //make sure there are no browsers anymore
-  for(tBrowserMap::iterator it = m_service_browsers.begin(); it != m_service_browsers.end(); ++it )
-    doRemoveServiceType(it->first);
-
-  WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_browser ), g_hWnd, BONJOUR_BROWSER_EVENT, 0 );
-  DNSServiceRefDeallocate(m_browser);
-  m_browser = NULL;
-}
-
-void DNSSD_API CZeroconfBrowserWIN::BrowserCallback(DNSServiceRef browser,
-                                                    DNSServiceFlags flags,
-                                                    uint32_t interfaceIndex,
-                                                    DNSServiceErrorType errorCode,
-                                                    const char *serviceName,
-                                                    const char *regtype,
-                                                    const char *replyDomain,
-                                                    void *context)
-{
-
-  if (errorCode == kDNSServiceErr_NoError)
-  {
-    //get our instance
-    CZeroconfBrowserWIN* p_this = reinterpret_cast<CZeroconfBrowserWIN*>(context);
-    //store the service
-    ZeroconfService s(serviceName, regtype, replyDomain);
-
-    if (flags & kDNSServiceFlagsAdd)
-    {
-      CLog::Log(LOGDEBUG, "ZeroconfBrowserWIN::BrowserCallback found service named: %s, type: %s, domain: %s", s.GetName().c_str(), s.GetType().c_str(), s.GetDomain().c_str());
-      p_this->addDiscoveredService(browser, s);
-    }
-    else
-    {
-      CLog::Log(LOGDEBUG, "ZeroconfBrowserWIN::BrowserCallback service named: %s, type: %s, domain: %s disappeared", s.GetName().c_str(), s.GetType().c_str(), s.GetDomain().c_str());
-      p_this->removeDiscoveredService(browser, s);
-    }
-    if(! (flags & kDNSServiceFlagsMoreComing) )
-    {
-      CGUIMessage message(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_PATH);
-      message.SetStringParam("zeroconf://");
-      g_windowManager.SendThreadMessage(message);
-      CLog::Log(LOGDEBUG, "ZeroconfBrowserWIN::BrowserCallback sent gui update for path zeroconf://");
-    }
-  }
-  else
-  {
-    CLog::Log(LOGERROR, "ZeroconfBrowserWIN::BrowserCallback returned (error = %ld)\n", (int)errorCode);
-  }
-}
-
-void DNSSD_API CZeroconfBrowserWIN::ResolveCallback(DNSServiceRef                       sdRef,
-                                                    DNSServiceFlags                     flags,
-                                                    uint32_t                            interfaceIndex,
-                                                    DNSServiceErrorType                 errorCode,
-                                                    const char                          *fullname,
-                                                    const char                          *hosttarget,
-                                                    uint16_t                            port,        /* In network byte order */
-                                                    uint16_t                            txtLen,
-                                                    const unsigned char                 *txtRecord,
-                                                    void                                *context
-                                                    )
-{
-
-  if (errorCode)
-  {
-    CLog::Log(LOGERROR, "ZeroconfBrowserWIN: ResolveCallback failed with error = %ld", (int) errorCode);
-    return;
-  }
-
-  DNSServiceErrorType err;
-  CZeroconfBrowser::ZeroconfService::tTxtRecordMap recordMap; 
-  CStdString strIP;
-  CZeroconfBrowser::ZeroconfService* service = (CZeroconfBrowser::ZeroconfService*) context;
-
-  if(!CDNSNameCache::Lookup(hosttarget, strIP))
-  {
-    CLog::Log(LOGERROR, "ZeroconfBrowserWIN: Could not resolve hostname %s",hosttarget);
-    return;
-  }
-  service->SetIP(strIP);
-
-  for(uint16_t i = 0; i < TXTRecordGetCount(txtLen, txtRecord); ++i)
-  {
-    char key[256];
-    uint8_t valueLen;
-    const void *value;
-    std::string strvalue;
-    err = TXTRecordGetItemAtIndex(txtLen, txtRecord,i ,sizeof(key) , key, &valueLen, &value);
-    if(err != kDNSServiceErr_NoError)
-      continue;
-
-    if(value != NULL && valueLen > 0)
-      strvalue.append((const char *)value, valueLen);
-
-    recordMap.insert(std::make_pair(key, strvalue));
-  }
-  service->SetTxtRecords(recordMap);
-  service->SetPort(ntohs(port));
-}
-
-/// adds the service to list of found services
-void CZeroconfBrowserWIN::addDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service)
-{
-  CSingleLock lock(m_data_guard);
-  tDiscoveredServicesMap::iterator browserIt = m_discovered_services.find(browser);
-  if(browserIt == m_discovered_services.end())
-  {
-     //first service by this browser
-     browserIt = m_discovered_services.insert(make_pair(browser, std::vector<std::pair<ZeroconfService, unsigned int> >())).first;
-  }
-  //search this service
-  std::vector<std::pair<ZeroconfService, unsigned int> >& services = browserIt->second;
-  std::vector<std::pair<ZeroconfService, unsigned int> >::iterator serviceIt = services.begin();
-  for( ; serviceIt != services.end(); ++serviceIt)
-  {
-    if(serviceIt->first == fcr_service)
-      break;
-  }
-  if(serviceIt == services.end())
-    services.push_back(std::make_pair(fcr_service, 1));
-  else
-    ++serviceIt->second;
-}
-
-void CZeroconfBrowserWIN::removeDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service)
-{
-  CSingleLock lock(m_data_guard);
-  tDiscoveredServicesMap::iterator browserIt = m_discovered_services.find(browser);
-  //search this service
-  std::vector<std::pair<ZeroconfService, unsigned int> >& services = browserIt->second;
-  std::vector<std::pair<ZeroconfService, unsigned int> >::iterator serviceIt = services.begin();
-  for( ; serviceIt != services.end(); ++serviceIt)
-    if(serviceIt->first == fcr_service)
-      break;
-  if(serviceIt != services.end())
-  {
-    //decrease refCount
-    --serviceIt->second;
-    if(!serviceIt->second)
-    {
-      //eventually remove the service
-      services.erase(serviceIt);
-    }
-  } else
-  {
-    //looks like we missed the announce, no problem though..
-  }
-}
-
-
-bool CZeroconfBrowserWIN::doAddServiceType(const CStdString& fcr_service_type)
-{
-  DNSServiceErrorType err;
-  DNSServiceRef browser = NULL;
-
-  if(m_browser == NULL)
-  {
-    err = DNSServiceCreateConnection(&m_browser);
-    if (err != kDNSServiceErr_NoError)
-    {
-      CLog::Log(LOGERROR, "ZeroconfBrowserWIN: DNSServiceCreateConnection failed with error = %ld", (int) err);
-      return false;
-    }
-    err = WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_browser ), g_hWnd, BONJOUR_BROWSER_EVENT, FD_READ | FD_CLOSE );
-    if (err != kDNSServiceErr_NoError)
-      CLog::Log(LOGERROR, "ZeroconfBrowserWIN: WSAAsyncSelect failed with error = %ld", (int) err);
-  }
-
-  {
-    CSingleLock lock(m_data_guard);
-    browser = m_browser;
-    err = DNSServiceBrowse(&browser, kDNSServiceFlagsShareConnection, kDNSServiceInterfaceIndexAny, fcr_service_type.c_str(), NULL, BrowserCallback, this);
-  }
-
-  if( err != kDNSServiceErr_NoError )
-  {
-    if (browser)
-      DNSServiceRefDeallocate(browser);
-
-    CLog::Log(LOGERROR, "ZeroconfBrowserWIN: DNSServiceBrowse returned (error = %ld)", (int) err);
-    return false;
-  }
-
-  //store the browser
-  {
-    CSingleLock lock(m_data_guard);
-    m_service_browsers.insert(std::make_pair(fcr_service_type, browser));
-  }
-
-  return true;
-}
-
-bool CZeroconfBrowserWIN::doRemoveServiceType(const CStdString& fcr_service_type)
-{
-  //search for this browser and remove it from the map
-  DNSServiceRef browser = 0;
-  {
-    CSingleLock lock(m_data_guard);
-    tBrowserMap::iterator it = m_service_browsers.find(fcr_service_type);
-    if(it == m_service_browsers.end())
-    {
-      return false;
-    }
-    browser = it->second;
-    m_service_browsers.erase(it);
-  }
-
-  //remove the services of this browser
-  {
-    CSingleLock lock(m_data_guard);
-    tDiscoveredServicesMap::iterator it = m_discovered_services.find(browser);
-    if(it != m_discovered_services.end())
-      m_discovered_services.erase(it);
-  }
-
-  DNSServiceRefDeallocate(browser);
-
-  return true;
-}
-
-std::vector<CZeroconfBrowser::ZeroconfService> CZeroconfBrowserWIN::doGetFoundServices()
-{
-  std::vector<CZeroconfBrowser::ZeroconfService> ret;
-  CSingleLock lock(m_data_guard);
-  for(tDiscoveredServicesMap::const_iterator it = m_discovered_services.begin();
-      it != m_discovered_services.end(); ++it)
-  {
-    const std::vector<std::pair<CZeroconfBrowser::ZeroconfService, unsigned int> >& services = it->second;
-    for(unsigned int i = 0; i < services.size(); ++i)
-    {
-      ret.push_back(services[i].first);
-    }
-  }
-  return ret;
-}
-
-bool CZeroconfBrowserWIN::doResolveService(CZeroconfBrowser::ZeroconfService& fr_service, double f_timeout)
-{
-  DNSServiceErrorType err;
-  DNSServiceRef sdRef = NULL;
-
-  err = DNSServiceResolve(&sdRef, 0, kDNSServiceInterfaceIndexAny, fr_service.GetName(), fr_service.GetType(), fr_service.GetDomain(), ResolveCallback, &fr_service);
-
-  if( err != kDNSServiceErr_NoError )
-  {
-    if (sdRef)
-      DNSServiceRefDeallocate(sdRef);
-
-    CLog::Log(LOGERROR, "ZeroconfBrowserWIN: DNSServiceResolve returned (error = %ld)", (int) err);
-    return false;
-  }
-
-  err = DNSServiceProcessResult(sdRef);
-
-  if (err != kDNSServiceErr_NoError)
-      CLog::Log(LOGERROR, "ZeroconfBrowserWIN::doResolveService DNSServiceProcessResult returned (error = %ld)", (int) err);
-
-  if (sdRef)
-    DNSServiceRefDeallocate(sdRef);
-
-  return true;
-}
-
-void CZeroconfBrowserWIN::ProcessResults()
-{
-  CSingleLock lock(m_data_guard);
-  DNSServiceErrorType err = DNSServiceProcessResult(m_browser);
-  if (err != kDNSServiceErr_NoError)
-    CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceProcessResult returned (error = %ld)", (int) err);
-}
\ No newline at end of file
diff --git a/xbmc/network/windows/ZeroconfBrowserWIN.h b/xbmc/network/windows/ZeroconfBrowserWIN.h
deleted file mode 100644 (file)
index 4c3205b..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-#pragma once
-/*
- *      Copyright (C) 2012-2013 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, see
- *  <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <memory>
-#include <map>
-
-#include "network/ZeroconfBrowser.h"
-#include "threads/Thread.h"
-#include "threads/CriticalSection.h"
-#include <dns_sd.h>
-
-//platform specific implementation of  zeroconfbrowser interface using native os x APIs
-class CZeroconfBrowserWIN : public CZeroconfBrowser
-{
-public:
-  CZeroconfBrowserWIN();
-  ~CZeroconfBrowserWIN();
-
-private:
-  ///implementation if CZeroconfBrowser interface
-  ///@{
-  virtual bool doAddServiceType(const CStdString& fcr_service_type);
-  virtual bool doRemoveServiceType(const CStdString& fcr_service_type);
-
-  virtual std::vector<CZeroconfBrowser::ZeroconfService> doGetFoundServices();
-  virtual bool doResolveService(CZeroconfBrowser::ZeroconfService& fr_service, double f_timeout);
-  ///@}
-
-  /// browser callback
-  static void DNSSD_API BrowserCallback(DNSServiceRef browser,
-                                        DNSServiceFlags flags,
-                                        uint32_t interfaceIndex,
-                                        DNSServiceErrorType errorCode,
-                                        const char *serviceName,
-                                        const char *regtype,
-                                        const char *replyDomain,
-                                        void *context);
-  /// resolve callback
-  static void DNSSD_API ResolveCallback(DNSServiceRef                       sdRef,
-                                        DNSServiceFlags                     flags,
-                                        uint32_t                            interfaceIndex,
-                                        DNSServiceErrorType                 errorCode,
-                                        const char                          *fullname,
-                                        const char                          *hosttarget,
-                                        uint16_t                            port,        /* In network byte order */
-                                        uint16_t                            txtLen,
-                                        const unsigned char                 *txtRecord,
-                                        void                                *context
-                                        );
-
-  /// adds the service to list of found services
-  void addDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service);
-  /// removes the service from list of found services
-  void removeDiscoveredService(DNSServiceRef browser, CZeroconfBrowser::ZeroconfService const& fcr_service);
-  // win32: process replies from the bonjour daemon
-  void ProcessResults();
-
-  //shared variables (with guard)
-  CCriticalSection m_data_guard;
-  // tBrowserMap maps service types the corresponding browser
-  typedef std::map<std::string, DNSServiceRef> tBrowserMap;
-  tBrowserMap m_service_browsers;
-  //tDiscoveredServicesMap maps browsers to their discovered services + a ref-count for each service
-  //ref-count is needed, because a service might pop up more than once, if there's more than one network-iface
-  typedef std::map<DNSServiceRef, std::vector<std::pair<ZeroconfService, unsigned int> > > tDiscoveredServicesMap;
-  tDiscoveredServicesMap m_discovered_services;
-  DNSServiceRef m_browser;
-};
diff --git a/xbmc/network/windows/ZeroconfWIN.cpp b/xbmc/network/windows/ZeroconfWIN.cpp
deleted file mode 100644 (file)
index e84bc6e..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- *      Copyright (C) 2005-2013 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, see
- *  <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "ZeroconfWIN.h"
-
-#include <string>
-#include <sstream>
-#include <threads/SingleLock.h>
-#include <utils/log.h>
-#include "dialogs/GUIDialogKaiToast.h"
-#include "guilib/LocalizeStrings.h"
-#include "win32/WIN32Util.h"
-
-#pragma comment(lib, "dnssd.lib")
-
-extern HWND g_hWnd;
-
-CZeroconfWIN::CZeroconfWIN()
-{
-  m_service = NULL;
-}
-
-CZeroconfWIN::~CZeroconfWIN()
-{
-  doStop();
-}
-
-bool CZeroconfWIN::IsZCdaemonRunning()
-{
-  uint32_t version;
-  uint32_t size = sizeof(version);
-  DNSServiceErrorType err = DNSServiceGetProperty(kDNSServiceProperty_DaemonVersion, &version, &size);
-  if(err != kDNSServiceErr_NoError)
-  {
-    CLog::Log(LOGERROR, "ZeroconfWIN: Zeroconf can't be started probably because Apple's Bonjour Service isn't installed. You can get it by either installing Itunes or Apple's Bonjour Print Service for Windows (http://support.apple.com/kb/DL999)");
-    CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(34300), g_localizeStrings.Get(34301), 10000, true);
-    return false;
-  }
-  CLog::Log(LOGDEBUG, "ZeroconfWIN:Bonjour version is %d.%d", version / 10000, version / 100 % 100);
-  return true;
-}
-
-//methods to implement for concrete implementations
-bool CZeroconfWIN::doPublishService(const std::string& fcr_identifier,
-                      const std::string& fcr_type,
-                      const std::string& fcr_name,
-                      unsigned int f_port,
-                      const std::vector<std::pair<std::string, std::string> >& txt)
-{
-  DNSServiceRef netService = NULL;
-  TXTRecordRef txtRecord;
-  DNSServiceErrorType err;
-  TXTRecordCreate(&txtRecord, 0, NULL);
-
-  if(m_service == NULL)
-  {
-    err = DNSServiceCreateConnection(&m_service);
-    if (err != kDNSServiceErr_NoError)
-    {
-      CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceCreateConnection failed with error = %ld", (int) err);
-      return false;
-    }
-    err = WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_service ), g_hWnd, BONJOUR_EVENT, FD_READ | FD_CLOSE );
-    if (err != kDNSServiceErr_NoError)
-      CLog::Log(LOGERROR, "ZeroconfWIN: WSAAsyncSelect failed with error = %ld", (int) err);
-  }
-
-  CLog::Log(LOGDEBUG, "ZeroconfWIN: identifier: %s type: %s name:%s port:%i", fcr_identifier.c_str(), fcr_type.c_str(), fcr_name.c_str(), f_port);
-
-  //add txt records
-  if(!txt.empty())
-  {
-    for(std::vector<std::pair<std::string, std::string> >::const_iterator it = txt.begin(); it != txt.end(); ++it)
-    {
-      CLog::Log(LOGDEBUG, "ZeroconfWIN: key:%s, value:%s",it->first.c_str(),it->second.c_str());
-      uint8_t txtLen = (uint8_t)strlen(it->second.c_str());
-      TXTRecordSetValue(&txtRecord, it->first.c_str(), txtLen, it->second.c_str());
-    }
-  }
-
-  {
-    CSingleLock lock(m_data_guard);
-    netService = m_service;
-    err = DNSServiceRegister(&netService, kDNSServiceFlagsShareConnection, 0, fcr_name.c_str(), fcr_type.c_str(), NULL, NULL, htons(f_port), TXTRecordGetLength(&txtRecord), TXTRecordGetBytesPtr(&txtRecord), registerCallback, NULL);
-  }
-
-  if (err != kDNSServiceErr_NoError)
-  {
-    // Something went wrong so lets clean up.
-    if (netService)
-      DNSServiceRefDeallocate(netService);
-
-    CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceRegister returned (error = %ld)", (int) err);
-  }
-  else
-  {
-    CSingleLock lock(m_data_guard);
-    m_services.insert(make_pair(fcr_identifier, netService));
-  }
-
-  TXTRecordDeallocate(&txtRecord);
-
-  return err == kDNSServiceErr_NoError;
-}
-
-bool CZeroconfWIN::doRemoveService(const std::string& fcr_ident)
-{
-  CSingleLock lock(m_data_guard);
-  tServiceMap::iterator it = m_services.find(fcr_ident);
-  if(it != m_services.end())
-  {
-    DNSServiceRefDeallocate(it->second);
-    m_services.erase(it);
-    CLog::Log(LOGDEBUG, "ZeroconfWIN: Removed service %s", fcr_ident.c_str());
-    return true;
-  }
-  else
-    return false;
-}
-
-void CZeroconfWIN::doStop()
-{
-  {
-    CSingleLock lock(m_data_guard);
-    CLog::Log(LOGDEBUG, "ZeroconfWIN: Shutdown services");
-    for(tServiceMap::iterator it = m_services.begin(); it != m_services.end(); ++it)
-    {
-      DNSServiceRefDeallocate(it->second);
-      CLog::Log(LOGDEBUG, "ZeroconfWIN: Removed service %s", it->first.c_str());
-    }
-    m_services.clear();
-  }
-  {
-    CSingleLock lock(m_data_guard);
-    WSAAsyncSelect( (SOCKET) DNSServiceRefSockFD( m_service ), g_hWnd, BONJOUR_EVENT, 0 );
-    DNSServiceRefDeallocate(m_service);
-    m_service = NULL;
-  }
-}
-
-void DNSSD_API CZeroconfWIN::registerCallback(DNSServiceRef sdref, const DNSServiceFlags flags, DNSServiceErrorType errorCode, const char *name, const char *regtype, const char *domain, void *context)
-{
-  (void)sdref;    // Unused
-  (void)flags;    // Unused
-  (void)context;  // Unused
-
-  if (errorCode == kDNSServiceErr_NoError)
-  {
-    if (flags & kDNSServiceFlagsAdd)
-      CLog::Log(LOGDEBUG, "ZeroconfWIN: %s.%s%s now registered and active", name, regtype, domain);
-    else
-      CLog::Log(LOGDEBUG, "ZeroconfWIN: %s.%s%s registration removed", name, regtype, domain);
-  }
-  else if (errorCode == kDNSServiceErr_NameConflict)
-     CLog::Log(LOGDEBUG, "ZeroconfWIN: %s.%s%s Name in use, please choose another", name, regtype, domain);
-  else
-    CLog::Log(LOGDEBUG, "ZeroconfWIN: %s.%s%s error code %d", name, regtype, domain, errorCode);
-}
-
-void CZeroconfWIN::ProcessResults()
-{
-  CSingleLock lock(m_data_guard);
-  DNSServiceErrorType err = DNSServiceProcessResult(m_service);
-  if (err != kDNSServiceErr_NoError)
-    CLog::Log(LOGERROR, "ZeroconfWIN: DNSServiceProcessResult returned (error = %ld)", (int) err);
-}
\ No newline at end of file
diff --git a/xbmc/network/windows/ZeroconfWIN.h b/xbmc/network/windows/ZeroconfWIN.h
deleted file mode 100644 (file)
index bea0079..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#pragma once
-/*
- *      Copyright (C) 2005-2013 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, see
- *  <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <memory>
-
-#include "network/Zeroconf.h"
-#include "threads/CriticalSection.h"
-#include <dns_sd.h>
-
-class CZeroconfWIN : public CZeroconf
-{
-public:
-  CZeroconfWIN();
-  ~CZeroconfWIN();
-protected:
-  //implement base CZeroConf interface
-  bool doPublishService(const std::string& fcr_identifier,
-                        const std::string& fcr_type,
-                        const std::string& fcr_name,
-                        unsigned int f_port,
-                        const std::vector<std::pair<std::string, std::string> >& txt);
-
-  bool doRemoveService(const std::string& fcr_ident);
-
-  virtual void doStop();
-
-  bool IsZCdaemonRunning();
-
-  void ProcessResults();
-
-private:
-
-  static void DNSSD_API registerCallback(DNSServiceRef sdref,
-                                         const DNSServiceFlags flags,
-                                         DNSServiceErrorType errorCode,
-                                         const char *name,
-                                         const char *regtype,
-                                         const char *domain,
-                                         void *context);
-
-
-  //lock + data (accessed from runloop(main thread) + the rest)
-  CCriticalSection m_data_guard;
-  typedef std::map<std::string, DNSServiceRef> tServiceMap;
-  tServiceMap m_services;
-  DNSServiceRef m_service;
-};
index 70492eb..8ff9957 100644 (file)
@@ -5,7 +5,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include <winsock.h>
 #else
 #include <sys/socket.h>
@@ -131,14 +131,14 @@ public:
 
   static void Clean()
   {
-  #ifdef _WIN32
+  #ifdef TARGET_WINDOWS
     WSACleanup();
   #endif
   }
 
   static bool Initialize()
   {
-  #ifdef _WIN32
+  #ifdef TARGET_WINDOWS
     WSADATA wsaData;
     if (WSAStartup(MAKEWORD(1, 1), &wsaData))
       return false;
index 0833ab1..1e720c5 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <map>
 #include <stdio.h>
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "PlatformDefs.h"
 #endif
 #include "utils/StdString.h"
index 0e673ee..15e3d8c 100644 (file)
 using namespace std;
 using namespace PERIPHERALS;
 
-#define PERIPHERAL_DEFAULT_RESCAN_INTERVAL 1000
+#define PERIPHERAL_DEFAULT_RESCAN_INTERVAL 5000
 
-CPeripheralBus::CPeripheralBus(CPeripherals *manager, PeripheralBusType type) :
-    CThread("PeripheralBus"),
+CPeripheralBus::CPeripheralBus(const CStdString &threadname, CPeripherals *manager, PeripheralBusType type) :
+    CThread(threadname),
     m_iRescanTime(PERIPHERAL_DEFAULT_RESCAN_INTERVAL),
     m_bInitialised(false),
     m_bIsStarted(false),
index cc368ac..879821d 100644 (file)
@@ -33,7 +33,7 @@ namespace PERIPHERALS
 
   /*!
    * @class CPeripheralBus
-   * This represents a bus on the system. By default, this bus instance will scan for changes every second.
+   * This represents a bus on the system. By default, this bus instance will scan for changes every 5 seconds.
    * If this bus only has to be updated after a notification sent by the system, set m_bNeedsPolling to false
    * in the constructor, and implement the OnDeviceAdded(), OnDeviceChanged() and OnDeviceRemoved() methods.
    *
@@ -42,7 +42,7 @@ namespace PERIPHERALS
   class CPeripheralBus : protected CThread
   {
   public:
-    CPeripheralBus(CPeripherals *manager, PeripheralBusType type);
+    CPeripheralBus(const CStdString &threadname, CPeripherals *manager, PeripheralBusType type);
     virtual ~CPeripheralBus(void) { Clear(); }
 
     /*!
index bfc2a0a..ec4e9b4 100644 (file)
@@ -26,7 +26,7 @@
 using namespace PERIPHERALS;
 
 CPeripheralBusUSB::CPeripheralBusUSB(CPeripherals *manager) :
-    CPeripheralBus(manager, PERIPHERAL_BUS_USB)
+    CPeripheralBus("PeripBusUSB", manager, PERIPHERAL_BUS_USB)
 {
   usb_init();
   usb_find_busses();
@@ -50,7 +50,7 @@ bool CPeripheralBusUSB::PerformDeviceScan(PeripheralScanResults &results)
                              dev->config[0].bNumInterfaces > 0 && dev->config[0].interface[0].num_altsetting > 0) ?
                                  GetType(dev->config[0].interface[0].altsetting[0].bInterfaceClass) :
                                  GetType(dev->descriptor.bDeviceClass);
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
       result.m_strLocation.Format("%s", dev->filename);
 #else
       result.m_strLocation.Format("/bus%s/dev%s", bus->dirname, dev->filename);
index 411a8b9..724717f 100644 (file)
@@ -77,7 +77,7 @@ extern "C" {
 using namespace PERIPHERALS;
 
 CPeripheralBusUSB::CPeripheralBusUSB(CPeripherals *manager) :
-    CPeripheralBus(manager, PERIPHERAL_BUS_USB)
+    CPeripheralBus("PeripBusUSBUdev", manager, PERIPHERAL_BUS_USB)
 {
   /* the Process() method in this class overrides the one in CPeripheralBus, so leave this set to true */
   m_bNeedsPolling = true;
index 4eca577..88c856a 100644 (file)
@@ -43,7 +43,7 @@ typedef struct USBDevicePrivateData {
 #endif
 
 CPeripheralBusUSB::CPeripheralBusUSB(CPeripherals *manager) :
-    CPeripheralBus(manager, PERIPHERAL_BUS_USB)
+    CPeripheralBus("PeripBusUSB", manager, PERIPHERAL_BUS_USB)
 {
   m_bNeedsPolling = false;
 
index da169c1..447e3fa 100644 (file)
@@ -53,11 +53,11 @@ class PERIPHERALS::DllLibCEC : public DllDynamic, DllLibCECInterface
 };
 
 CPeripheralBusCEC::CPeripheralBusCEC(CPeripherals *manager) :
-    CPeripheralBus(manager, PERIPHERAL_BUS_CEC),
+    CPeripheralBus("PeripBusCEC", manager, PERIPHERAL_BUS_CEC),
     m_dll(new DllLibCEC),
     m_cecAdapter(NULL)
 {
-  m_iRescanTime = 1000;
+  m_iRescanTime = 5000;
   if (!m_dll->Load() || !m_dll->IsLoaded())
   {
     delete m_dll;
index e77cb7b..86d26e5 100644 (file)
@@ -31,7 +31,7 @@ static GUID USB_NIC_GUID =  { 0xAD498944, 0x762F, 0x11D0, { 0x8D, 0xCB, 0x00, 0x
 using namespace PERIPHERALS;
 
 CPeripheralBusUSB::CPeripheralBusUSB(CPeripherals *manager) :
-    CPeripheralBus(manager, PERIPHERAL_BUS_USB)
+    CPeripheralBus("PeripBusUSB", manager, PERIPHERAL_BUS_USB)
 {
   /* device removals aren't always triggering OnDeviceRemoved events, so poll for changes every 5 seconds to be sure we don't miss anything */
   m_iRescanTime = 5000;
index 3349406..636198a 100644 (file)
@@ -26,7 +26,7 @@
   #undef LoadImage
  #endif
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 typedef struct tagRGBQUAD {
    BYTE rgbBlue;
    BYTE rgbGreen;
index af11b0f..bd638c5 100644 (file)
@@ -1142,7 +1142,7 @@ void CGUIWindowSlideShow::OnLoadPic(int iPic, int iSlideNumber, const CStdString
     {
       CURL url(m_slides->Get(m_iCurrentSlide)->GetPath());
       CStdString strHostName = url.GetHostName();
-      if (URIUtils::GetExtension(strHostName).Equals(".cbr", false) || URIUtils::GetExtension(strHostName).Equals(".cbz", false))
+      if (URIUtils::HasExtension(strHostName, ".cbr|.cbz"))
       {
         m_Image[iPic].m_bIsComic = true;
         m_Image[iPic].Move((float)m_Image[iPic].GetOriginalWidth(),(float)m_Image[iPic].GetOriginalHeight());
index 27a70c5..bc0f32f 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #include "system.h"
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 
@@ -42,7 +42,7 @@ using namespace XFILE;
 bool CPicture::CreateThumbnailFromSurface(const unsigned char *buffer, int width, int height, int stride, const CStdString &thumbFile)
 {
   CLog::Log(LOGDEBUG, "cached image '%s' size %dx%d", thumbFile.c_str(), width, height);
-  if (URIUtils::GetExtension(thumbFile).Equals(".jpg"))
+  if (URIUtils::HasExtension(thumbFile, ".jpg"))
   {
 #if defined(HAS_OMXPLAYER)
     COMXImage *omxImage = new COMXImage();
index fb0c78c..892f59d 100644 (file)
@@ -438,7 +438,7 @@ bool CPlayList::LoadData(std::istream &stream)
 {
   // try to read as a string
   CStdString data;
-#if _MSC_VER > 1500
+#if TARGET_WINDOWS
   std::stringstream _stream(data);
   _stream << stream;
 #else
index be4e293..0a22044 100644 (file)
@@ -129,18 +129,7 @@ bool CPlayListFactory::IsPlaylist(const CFileItem& item)
 
 bool CPlayListFactory::IsPlaylist(const CStdString& filename)
 {
-  CStdString extension = URIUtils::GetExtension(filename);
-  extension.ToLower();
-
-  if (extension == ".m3u") return true;
-  if (extension == ".b4s") return true;
-  if (extension == ".pls") return true;
-  if (extension == ".strm") return true;
-  if (extension == ".wpl") return true;
-  if (extension == ".asx") return true;
-  if (extension == ".ram") return true;
-  if (extension == ".url") return true;
-  if (extension == ".pxml") return true;
-  return false;
+  return URIUtils::HasExtension(filename,
+                     ".m3u|.b4s|.pls|.strm|.wpl|.asx|.ram|.url|.pxml");
 }
 
index c38caa1..d584509 100644 (file)
@@ -1323,7 +1323,7 @@ const TiXmlNode* CSmartPlaylist::readNameFromPath(const CStdString &path)
   if (m_playlistName.empty())
   {
     m_playlistName = CUtil::GetTitleFromPath(path);
-    if (URIUtils::GetExtension(m_playlistName) == ".xsp")
+    if (URIUtils::HasExtension(m_playlistName, ".xsp"))
       URIUtils::RemoveExtension(m_playlistName);
   }
 
index 5bc1647..7c00281 100644 (file)
@@ -25,7 +25,7 @@
 #include "utils/SystemInfo.h"
 #include <assert.h>
 #include <string>
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "guilib/GraphicContext.h"
 #endif
 
@@ -187,7 +187,7 @@ bool DPMSSupport::PlatformSpecificDisablePowerSaving()
 }
 
 /////  Add other platforms here.
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
 void DPMSSupport::PlatformSpecificInit()
 {
   // Assume we support DPMS. Is there a way to test it?
index 3e68ba8..f2a063f 100644 (file)
@@ -40,7 +40,7 @@
 #include "osx/CocoaPowerSyscall.h"
 #elif defined(TARGET_ANDROID)
 #include "android/AndroidPowerSyscall.h"
-#elif defined(_LINUX) && defined(HAS_DBUS)
+#elif defined(TARGET_POSIX) && defined(HAS_DBUS)
 #include "linux/ConsoleUPowerSyscall.h"
 #include "linux/ConsoleDeviceKitPowerSyscall.h"
 #include "linux/SystemdUPowerSyscall.h"
@@ -48,7 +48,7 @@
 #ifdef HAS_HAL
 #include "linux/HALPowerSyscall.h"
 #endif
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
 #include "powermanagement/windows/Win32PowerSyscall.h"
 extern HWND g_hWnd;
 #endif
@@ -73,7 +73,7 @@ void CPowerManager::Initialize()
   m_instance = new CCocoaPowerSyscall();
 #elif defined(TARGET_ANDROID)
   m_instance = new CAndroidPowerSyscall();
-#elif defined(_LINUX) && defined(HAS_DBUS)
+#elif defined(TARGET_POSIX) && defined(HAS_DBUS)
   if (CConsoleUPowerSyscall::HasConsoleKitAndUPower())
     m_instance = new CConsoleUPowerSyscall();
   else if (CConsoleDeviceKitPowerSyscall::HasDeviceConsoleKit())
@@ -86,7 +86,7 @@ void CPowerManager::Initialize()
   else
     m_instance = new CHALPowerSyscall();
 #endif
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
   m_instance = new CWin32PowerSyscall();
 #endif
 
@@ -257,7 +257,7 @@ void CPowerManager::OnWake()
 #if defined(HAS_SDL) || defined(TARGET_WINDOWS)
   if (g_Windowing.IsFullScreen())
   {
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
     ShowWindow(g_hWnd,SW_RESTORE);
     SetForegroundWindow(g_hWnd);
 #elif !defined(TARGET_DARWIN_OSX)
index d88cbf7..de3646e 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "Win32PowerSyscall.h"
 #include "powermanagement/PowerManager.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "WIN32Util.h"
 
 bool CWin32PowerSyscall::m_OnResume = false;
index 1baa0c6..ef65c83 100644 (file)
  *
  */
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #ifndef _WIN32_POWER_SYSCALL_H_
 #define _WIN32_POWER_SYSCALL_H_
 #include "powermanagement/IPowerSyscall.h"
index f503460..1455cbf 100644 (file)
@@ -166,7 +166,7 @@ void CPVRManager::OnSettingAction(const CSetting *setting)
   else if (settingId == "pvrclient.menuhook")
   {
     if (IsStarted())
-      Clients()->ProcessMenuHooks(-1, PVR_MENUHOOK_SETTING);
+      Clients()->ProcessMenuHooks(-1, PVR_MENUHOOK_SETTING, NULL);
   }
 }
 
index 72aff20..ebde2af 100644 (file)
@@ -395,12 +395,41 @@ PVR_ERROR CPVRClient::StartChannelScan(void)
   return PVR_ERROR_UNKNOWN;
 }
 
-void CPVRClient::CallMenuHook(const PVR_MENUHOOK &hook)
+void CPVRClient::CallMenuHook(const PVR_MENUHOOK &hook, const CFileItem *item)
 {
   if (!m_bReadyToUse)
     return;
 
-  try { m_pStruct->MenuHook(hook); }
+  try {
+    PVR_MENUHOOK_DATA hookData;
+    hookData.cat = PVR_MENUHOOK_UNKNOWN;
+
+    if (item)
+    {
+      if (item->IsEPG())
+      {
+        hookData.cat = PVR_MENUHOOK_EPG;
+        hookData.data.iEpgUid = item->GetEPGInfoTag()->BroadcastId();
+      }
+      else if (item->IsPVRChannel())
+      {
+        hookData.cat = PVR_MENUHOOK_CHANNEL;
+        WriteClientChannelInfo(*item->GetPVRChannelInfoTag(), hookData.data.channel);
+      }
+      else if (item->IsPVRRecording())
+      {
+        hookData.cat = PVR_MENUHOOK_RECORDING;
+        WriteClientRecordingInfo(*item->GetPVRRecordingInfoTag(), hookData.data.recording);
+      }
+      else if (item->IsPVRTimer())
+      {
+        hookData.cat = PVR_MENUHOOK_TIMER;
+        WriteClientTimerInfo(*item->GetPVRTimerInfoTag(), hookData.data.timer);
+      }
+    }
+
+    m_pStruct->MenuHook(hook, hookData);
+  }
   catch (exception &e) { LogException(e, __FUNCTION__); }
 }
 
index 61bef23..7a326d8 100644 (file)
@@ -156,8 +156,9 @@ namespace PVR
     /*!
      * @brief Call one of the menu hooks of this client.
      * @param hook The hook to call.
+     * @param item The selected file item for which the hook was called.
      */
-    void CallMenuHook(const PVR_MENUHOOK &hook);
+    void CallMenuHook(const PVR_MENUHOOK &hook, const CFileItem *item);
 
     //@}
     /** @name PVR EPG methods */
index 16fad44..2b43bcb 100644 (file)
@@ -682,7 +682,7 @@ bool CPVRClients::GetMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat, PVR_MENUHOOK
   return bReturn;
 }
 
-void CPVRClients::ProcessMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat)
+void CPVRClients::ProcessMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat, const CFileItem *item)
 {
   PVR_MENUHOOKS *hooks = NULL;
 
@@ -739,7 +739,7 @@ void CPVRClients::ProcessMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat)
 
     int selection = pDialog->GetSelectedLabel();
     if (selection >= 0)
-      client->CallMenuHook(hooks->at(selection));
+      client->CallMenuHook(hooks->at(selection), item);
   }
 }
 
index d515ebd..b80132c 100644 (file)
@@ -519,8 +519,9 @@ namespace PVR
     /*!
      * @brief Open selection and progress PVR actions.
      * @param iClientId The ID of the client to process the menu entries for. Process the menu entries for the active channel if iClientId < 0.
+     * @param item The selected file item for which the hook was called.
      */
-    void ProcessMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat);
+    void ProcessMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat, const CFileItem *item);
 
     //@}
 
index d1990bd..25b4b78 100644 (file)
@@ -342,13 +342,13 @@ bool CGUIWindowPVRCommon::OnContextButtonMenuHooks(CFileItem *item, CONTEXT_BUTT
     bReturn = true;
 
     if (item->IsEPG() && item->GetEPGInfoTag()->HasPVRChannel())
-      g_PVRClients->ProcessMenuHooks(item->GetEPGInfoTag()->ChannelTag()->ClientID(), PVR_MENUHOOK_EPG);
+      g_PVRClients->ProcessMenuHooks(item->GetEPGInfoTag()->ChannelTag()->ClientID(), PVR_MENUHOOK_EPG, item);
     else if (item->IsPVRChannel())
-      g_PVRClients->ProcessMenuHooks(item->GetPVRChannelInfoTag()->ClientID(), PVR_MENUHOOK_CHANNEL);
+      g_PVRClients->ProcessMenuHooks(item->GetPVRChannelInfoTag()->ClientID(), PVR_MENUHOOK_CHANNEL, item);
     else if (item->IsPVRRecording())
-      g_PVRClients->ProcessMenuHooks(item->GetPVRRecordingInfoTag()->m_iClientId, PVR_MENUHOOK_RECORDING);
+      g_PVRClients->ProcessMenuHooks(item->GetPVRRecordingInfoTag()->m_iClientId, PVR_MENUHOOK_RECORDING, item);
     else if (item->IsPVRTimer())
-      g_PVRClients->ProcessMenuHooks(item->GetPVRTimerInfoTag()->m_iClientId, PVR_MENUHOOK_TIMER);
+      g_PVRClients->ProcessMenuHooks(item->GetPVRTimerInfoTag()->m_iClientId, PVR_MENUHOOK_TIMER, item);
   }
 
   return bReturn;
@@ -643,7 +643,7 @@ bool CGUIWindowPVRCommon::PlayRecording(CFileItem *item, bool bPlayMinimized /*
       vector<int> stack;
       for (int i = 0; i < items.Size(); ++i)
       {
-        if (URIUtils::GetExtension(items[i]->GetPath()) == ext)
+        if (URIUtils::HasExtension(items[i]->GetPath(), ext))
           stack.push_back(i);
       }
 
index 8650ef2..a7f98bc 100644 (file)
@@ -47,7 +47,7 @@ CRenderSystemGL::~CRenderSystemGL()
 void CRenderSystemGL::CheckOpenGLQuirks()
 
 {
-#ifdef __APPLE__       
+#ifdef TARGET_DARWIN_OSX
   if (m_RenderVendor.Find("NVIDIA") > -1)
   {             
     // Nvidia 7300 (AppleTV) and 7600 cannot do DXT with NPOT under OSX
@@ -546,7 +546,7 @@ void CRenderSystemGL::CalculateMaxTexturesize()
     }
   }
 
-#ifdef __APPLE__
+#ifdef TARGET_DARWIN_OSX
   // Max Texture size reported on some apple machines seems incorrect
   // Displaying a picture with that resolution results in a corrupted output
   // So force it to a lower value
index 95a4451..3189ad9 100644 (file)
@@ -73,6 +73,11 @@ void CAdvancedSettings::OnSettingsLoaded()
   CLog::SetLogLevel(m_logLevel);
 }
 
+void CAdvancedSettings::OnSettingsUnloaded()
+{
+  m_initialized = false;
+}
+
 void CAdvancedSettings::OnSettingChanged(const CSetting *setting)
 {
   if (setting == NULL)
@@ -100,6 +105,9 @@ void CAdvancedSettings::OnSettingAction(const CSetting *setting)
 
 void CAdvancedSettings::Initialize()
 {
+  if (m_initialized)
+    return;
+
   m_audioHeadRoom = 0;
   m_ac3Gain = 12.0f;
   m_audioApplyDrc = true;
@@ -322,7 +330,7 @@ void CAdvancedSettings::Initialize()
   m_bVirtualShares = true;
 
 //caused lots of jerks
-//#ifdef _WIN32
+//#ifdef TARGET_WINDOWS
 //  m_ForcedSwapTime = 2.0;
 //#else
   m_ForcedSwapTime = 0.0;
@@ -353,6 +361,7 @@ void CAdvancedSettings::Initialize()
   m_measureRefreshrate = false;
 
   m_cacheMemBufferSize = 1024 * 1024 * 20;
+  m_alwaysForceBuffer = false;
   m_addonPackageFolderSize = 200;
 
   m_jsonOutputCompact = true;
@@ -756,6 +765,7 @@ void CAdvancedSettings::ParseSettingsFile(const CStdString &file)
     XMLUtils::GetInt(pElement, "curlretries", m_curlretries, 0, 10);
     XMLUtils::GetBoolean(pElement,"disableipv6", m_curlDisableIPV6);
     XMLUtils::GetUInt(pElement, "cachemembuffersize", m_cacheMemBufferSize);
+    XMLUtils::GetBoolean(pElement, "alwaysforcebuffer", m_alwaysForceBuffer);
   }
 
   pElement = pRootElement->FirstChildElement("jsonrpc");
@@ -1190,7 +1200,6 @@ void CAdvancedSettings::GetCustomTVRegexps(TiXmlElement *pRootElement, SETTINGS_
           }
         }
         CStdString regExp = pRegExp->FirstChild()->Value();
-        regExp.MakeLower();
         if (iAction == 2)
           settings.insert(settings.begin() + i++, 1, TVShowRegexp(bByDate,regExp,iDefaultSeason));
         else
index c810074..dc0c854 100644 (file)
@@ -95,6 +95,7 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler
     static CAdvancedSettings* getInstance();
 
     virtual void OnSettingsLoaded();
+    virtual void OnSettingsUnloaded();
 
     virtual void OnSettingChanged(const CSetting *setting);
 
@@ -363,6 +364,7 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler
     unsigned int m_addonPackageFolderSize;
 
     unsigned int m_cacheMemBufferSize;
+    bool m_alwaysForceBuffer;
 
     bool m_jsonOutputCompact;
     unsigned int m_jsonTcpPort;
index 6c304ff..7b77337 100644 (file)
@@ -589,7 +589,7 @@ void CDisplaySettings::SettingOptionsScreensFiller(const CSetting *setting, std:
 
 void CDisplaySettings::SettingOptionsVerticalSyncsFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int &current)
 {
-#if defined(_LINUX) && !defined(TARGET_DARWIN)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
   list.push_back(make_pair(g_localizeStrings.Get(13101), VSYNC_DRIVER));
 #endif
   list.push_back(make_pair(g_localizeStrings.Get(13106), VSYNC_DISABLED));
index 70d928a..b31d88b 100644 (file)
@@ -54,10 +54,16 @@ public:
    */
   virtual void OnSettingsSaved() const { }
   /*!
+   \brief Setting values have been unloaded.
+
+   This callback can be used to trigger uninitializing any state variables
+   (e.g. before re-loading the settings).
+   */
+  virtual void OnSettingsUnloaded() { }
+  /*!
    \brief Settings have been cleared.
 
-   This callback can be used to trigger clearing any state variables (e.g.
-   before re-loading the settings).
+   This callback can be used to trigger clearing any state variables.
    */
   virtual void OnSettingsCleared() { }
 };
index 531e586..f9335ea 100644 (file)
@@ -67,7 +67,7 @@ void CMediaSourceSettings::OnSettingsLoaded()
   Load();
 }
 
-void CMediaSourceSettings::OnSettingsCleared()
+void CMediaSourceSettings::OnSettingsUnloaded()
 {
   Clear();
 }
@@ -416,6 +416,8 @@ bool CMediaSourceSettings::GetSource(const std::string &category, const TiXmlNod
   if (pThumbnailNode && pThumbnailNode->FirstChild())
     share.m_strThumbnailImage = pThumbnailNode->FirstChild()->Value();
 
+  XMLUtils::GetBoolean(source, "allowsharing", share.m_allowSharing);
+
   return true;
 }
 
@@ -485,9 +487,12 @@ bool CMediaSourceSettings::SetSources(TiXmlNode *root, const char *section, cons
       XMLUtils::SetString(&source, "lockcode", share.m_strLockCode);
       XMLUtils::SetInt(&source, "badpwdcount", share.m_iBadPwdCount);
     }
+
     if (!share.m_strThumbnailImage.empty())
       XMLUtils::SetPath(&source, "thumbnail", share.m_strThumbnailImage);
 
+    XMLUtils::SetBoolean(&source, "allowsharing", share.m_allowSharing);
+
     sectionNode->InsertEndChild(source);
   }
 
index 0602f80..1119d54 100644 (file)
@@ -34,7 +34,7 @@ public:
   static std::string GetSourcesFile();
   
   virtual void OnSettingsLoaded();
-  virtual void OnSettingsCleared();
+  virtual void OnSettingsUnloaded();
 
   bool Load();
   bool Load(const std::string &file);
index 164e926..3c8ff5e 100644 (file)
@@ -45,9 +45,9 @@
 #elif defined(HAS_SDL_JOYSTICK)
 #include "input/SDLJoystick.h"
 #endif // defined(HAS_SDL_JOYSTICK)
-#if defined(TARGET_LINUX)
+#if defined(TARGET_POSIX)
 #include "linux/LinuxTimezone.h"
-#endif // defined(TARGET_LINUX)
+#endif // defined(TARGET_POSIX)
 #include "network/NetworkServices.h"
 #include "network/upnp/UPnPSettings.h"
 #include "network/WakeOnAccess.h"
@@ -250,8 +250,6 @@ bool CSettings::Initialize()
   if (!InitializeDefinitions())
     return false;
 
-  InitializeVisibility();
-  InitializeDefaults();
   m_settingsManager->SetInitialized();
 
   InitializeISettingsHandlers();  
@@ -535,9 +533,6 @@ bool CSettings::InitializeDefinitions()
 #if defined(TARGET_WINDOWS)
   if (CFile::Exists(SETTINGS_XML_FOLDER "win32.xml") && !Initialize(SETTINGS_XML_FOLDER "win32.xml"))
     CLog::Log(LOGFATAL, "Unable to load win32-specific settings definitions");
-#elif defined(TARGET_LINUX)
-  if (CFile::Exists(SETTINGS_XML_FOLDER "linux.xml") && !Initialize(SETTINGS_XML_FOLDER "linux.xml"))
-    CLog::Log(LOGFATAL, "Unable to load linux-specific settings definitions");
 #elif defined(TARGET_ANDROID)
   if (CFile::Exists(SETTINGS_XML_FOLDER "android.xml") && !Initialize(SETTINGS_XML_FOLDER "android.xml"))
     CLog::Log(LOGFATAL, "Unable to load android-specific settings definitions");
@@ -547,6 +542,9 @@ bool CSettings::InitializeDefinitions()
 #elif defined(TARGET_FREEBSD)
   if (CFile::Exists(SETTINGS_XML_FOLDER "freebsd.xml") && !Initialize(SETTINGS_XML_FOLDER "freebsd.xml"))
     CLog::Log(LOGFATAL, "Unable to load freebsd-specific settings definitions");
+#elif defined(TARGET_LINUX)
+  if (CFile::Exists(SETTINGS_XML_FOLDER "linux.xml") && !Initialize(SETTINGS_XML_FOLDER "linux.xml"))
+    CLog::Log(LOGFATAL, "Unable to load linux-specific settings definitions");
 #elif defined(TARGET_DARWIN)
   if (CFile::Exists(SETTINGS_XML_FOLDER "darwin.xml") && !Initialize(SETTINGS_XML_FOLDER "darwin.xml"))
     CLog::Log(LOGFATAL, "Unable to load darwin-specific settings definitions");
@@ -562,6 +560,12 @@ bool CSettings::InitializeDefinitions()
 #endif
 #endif
 #endif
+
+  // load any custom visibility and default values before loading the special
+  // appliance.xml so that appliances are able to overwrite even those values
+  InitializeVisibility();
+  InitializeDefaults();
+
   if (CFile::Exists(SETTINGS_XML_FOLDER "appliance.xml") && !Initialize(SETTINGS_XML_FOLDER "appliance.xml"))
     CLog::Log(LOGFATAL, "Unable to load appliance-specific settings definitions");
 
@@ -578,25 +582,16 @@ void CSettings::InitializeSettingTypes()
 void CSettings::InitializeVisibility()
 {
   // hide some settings if necessary
-#if defined(TARGET_LINUX) || defined(TARGET_DARWIN)
+#if defined(TARGET_DARWIN)
   CSettingString* timezonecountry = (CSettingString*)m_settingsManager->GetSetting("locale.timezonecountry");
   CSettingString* timezone = (CSettingString*)m_settingsManager->GetSetting("locale.timezone");
 
-#if defined(TARGET_DARWIN)
   if (!g_sysinfo.IsAppleTV2() || GetIOSVersion() >= 4.3)
   {
     timezonecountry->SetVisible(false);
     timezone->SetVisible(false);
   }
 #endif
-#if defined(TARGET_LINUX)
-  if (timezonecountry->IsVisible())
-    timezonecountry->SetDefault(g_timezone.GetCountryByTimezone(g_timezone.GetOSConfiguredTimezone()));
-  if (timezone->IsVisible())
-    timezone->SetDefault(g_timezone.GetOSConfiguredTimezone());
-#endif
-#endif
 }
 
 void CSettings::InitializeDefaults()
@@ -606,6 +601,16 @@ void CSettings::InitializeDefaults()
   ((CSettingAddon*)m_settingsManager->GetSetting("lookandfeel.skin"))->SetDefault("skin.touched");
 #endif
 
+#if defined(TARGET_POSIX)
+  CSettingString* timezonecountry = (CSettingString*)m_settingsManager->GetSetting("locale.timezonecountry");
+  CSettingString* timezone = (CSettingString*)m_settingsManager->GetSetting("locale.timezone");
+
+  if (timezonecountry->IsVisible())
+    timezonecountry->SetDefault(g_timezone.GetCountryByTimezone(g_timezone.GetOSConfiguredTimezone()));
+  if (timezone->IsVisible())
+    timezone->SetDefault(g_timezone.GetOSConfiguredTimezone());
+#endif // defined(TARGET_POSIX)
+
 #if defined(TARGET_WINDOWS)
   #if defined(HAS_DX)
   ((CSettingString*)m_settingsManager->GetSetting("musicplayer.visualisation"))->SetDefault("visualization.milkdrop");
@@ -725,10 +730,6 @@ void CSettings::InitializeConditions()
 #ifdef HAVE_LIBVA
   m_settingsManager->AddCondition("have_libva");
 #endif
-#ifdef TARGET_DARWIN_OSX
-  m_settingsManager->AddCondition("have_libvdadecoder");
-  m_settingsManager->AddCondition("hasvdadecoder");
-#endif
 #ifdef HAVE_LIBVDPAU
   m_settingsManager->AddCondition("have_libvdpau");
 #endif
index 54c9626..5763db7 100644 (file)
@@ -207,14 +207,24 @@ bool CSettingsManager::Save(TiXmlNode *root) const
 void CSettingsManager::Unload()
 {
   CSingleLock lock(m_critical);
+  if (!m_loaded)
+    return;
+
+  // needs to be set before calling CSetting::Reset() to avoid calls to
+  // OnSettingChanging() and OnSettingChanged()
   m_loaded = false;
+
   for (SettingMap::iterator setting = m_settings.begin(); setting != m_settings.end(); setting++)
     setting->second.setting->Reset();
+
+  OnSettingsUnloaded();
 }
 
 void CSettingsManager::Clear()
 {
   CSingleLock lock(m_critical);
+  Unload();
+
   m_settings.clear();
   for (SettingSectionMap::iterator section = m_sections.begin(); section != m_sections.end(); section++)
     delete section->second;
@@ -225,7 +235,6 @@ void CSettingsManager::Clear()
   for (std::set<ISubSettings*>::const_iterator it = m_subSettings.begin(); it != m_subSettings.end(); it++)
     (*it)->Clear();
 
-  m_loaded = false;
   m_initialized = false;
 }
 
index 3ca4c8b..b7c4116 100644 (file)
@@ -24,9 +24,7 @@
 #if !defined(AFX_VIDEOSETTINGS_H__562A722A_CD2A_4B4A_8A67_32DE8088A7D3__INCLUDED_)
 #define AFX_VIDEOSETTINGS_H__562A722A_CD2A_4B4A_8A67_32DE8088A7D3__INCLUDED_
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 
 enum EDEINTERLACEMODE
 {
index 1859e93..8318ec6 100644 (file)
@@ -60,6 +60,7 @@ using namespace std;
 #define CONTROL_SETTINGS_LABEL          2
 #define CATEGORY_GROUP_ID               3
 #define SETTINGS_GROUP_ID               5
+#define CONTROL_DESCRIPTION             6
 #define CONTROL_DEFAULT_BUTTON          7
 #define CONTROL_DEFAULT_RADIOBUTTON     8
 #define CONTROL_DEFAULT_SPIN            9
@@ -172,18 +173,27 @@ bool CGUIWindowSettingsCategory::OnMessage(CGUIMessage &message)
         }
 
         // check if we have changed the category and need to create new setting controls
-        if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < (int)(CONTROL_START_BUTTONS + m_categories.size()) &&
-            focusedControl - CONTROL_START_BUTTONS != m_iCategory)
+        if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < (int)(CONTROL_START_BUTTONS + m_categories.size()))
         {
-          if (!m_categories[focusedControl - CONTROL_START_BUTTONS]->CanAccess())
+          int categoryIndex = focusedControl - CONTROL_START_BUTTONS;
+          if (categoryIndex != m_iCategory)
           {
-            // unable to go to this category - focus the previous one
-            SET_CONTROL_FOCUS(CONTROL_START_BUTTONS + m_iCategory, 0);
-            return false;
+            if (!m_categories[categoryIndex]->CanAccess())
+            {
+              // unable to go to this category - focus the previous one
+              SET_CONTROL_FOCUS(CONTROL_START_BUTTONS + m_iCategory, 0);
+              return false;
+            }
+
+            m_iCategory = categoryIndex;
+            CreateSettings();
           }
-
-          m_iCategory = focusedControl - CONTROL_START_BUTTONS;
-          CreateSettings();
+        }
+        else if (focusedControl >= CONTROL_START_CONTROL && focusedControl < (int)(CONTROL_START_CONTROL + m_settingControls.size()))
+        {
+          CSetting *setting = GetSettingControl(focusedControl)->GetSetting();
+          if (setting != NULL)
+            SetDescription(setting->GetHelp());
         }
       }
       return true;
@@ -304,47 +314,6 @@ bool CGUIWindowSettingsCategory::OnAction(const CAction &action)
       return true;
     }
 
-    case ACTION_SHOW_INFO:
-    {
-      int label = -1;
-      int help = -1;
-      int focusedControl = GetFocusedControlID();
-      // check if we are focusing a category
-      if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < (int)(CONTROL_START_BUTTONS + m_categories.size()))
-      {
-        CSettingCategory *category = m_categories[focusedControl - CONTROL_START_BUTTONS];
-        label = category->GetLabel();
-        help = category->GetHelp();
-      }
-      else if (focusedControl >= CONTROL_START_CONTROL && focusedControl < (int)(CONTROL_START_CONTROL + m_settingControls.size()))
-      {
-        CSetting *setting = GetSettingControl(focusedControl)->GetSetting();
-        if (setting != NULL)
-        {
-          label = setting->GetLabel();
-          help = setting->GetHelp();
-        }
-      }
-      else
-        break;
-
-      if (help >= 0)
-      {
-        CGUIDialogTextViewer *dialog = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER);
-        if (dialog != NULL)
-        {
-          if (label < 0)
-            label = 10043; // "Help"
-          dialog->SetHeading(g_localizeStrings.Get(label));
-          dialog->SetText(g_localizeStrings.Get(help));
-          dialog->DoModal();
-        }
-      }
-      else
-        CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(10043), g_localizeStrings.Get(10044), 2000U);
-      return true;
-    }
-
     default:
       break;
   }
@@ -553,6 +522,9 @@ void CGUIWindowSettingsCategory::CreateSettings()
   if (category == NULL)
     return;
 
+  // set the description of the current category
+  SetDescription(category->GetHelp());
+
   std::set<std::string> settingMap;
 
   const SettingGroupList& groups = category->GetGroups(CViewStateSettings::Get().GetSettingLevel());
@@ -601,6 +573,19 @@ void CGUIWindowSettingsCategory::UpdateSettings()
   }
 }
 
+void CGUIWindowSettingsCategory::SetDescription(const CVariant &label)
+{
+  if (GetControl(CONTROL_DESCRIPTION) == NULL)
+    return;
+
+  if (label.isString())
+    SET_CONTROL_LABEL(CONTROL_DESCRIPTION, label.asString());
+  else if (label.isInteger() && label.asInteger() >= 0)
+    SET_CONTROL_LABEL(CONTROL_DESCRIPTION, (int)label.asInteger());
+  else
+    SET_CONTROL_LABEL(CONTROL_DESCRIPTION, "");
+}
+
 CGUIControl* CGUIWindowSettingsCategory::AddSetting(CSetting *pSetting, float width, int &iControlID)
 {
   if (pSetting == NULL)
index c729034..f1e8de2 100644 (file)
@@ -60,6 +60,7 @@ protected:
   
   void CreateSettings();
   void UpdateSettings();
+  void SetDescription(const CVariant &label);
   CGUIControl* AddSetting(CSetting *pSetting, float width, int &iControlID);
   CGUIControl* AddSeparator(float width, int &iControlID);
   CGUIControl* AddSettingControl(CGUIControl *pControl, BaseSettingControlPtr pSettingControl, float width, int &iControlID);
index 870ae7e..6f29429 100644 (file)
 #include "cdioSupport.h"
 #include "filesystem/iso9660.h"
 #include "threads/SingleLock.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <fcntl.h>
-#if !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD)
 #include <linux/cdrom.h>
 #endif
 #endif
@@ -314,7 +314,7 @@ void CDetectDVDMedia::SetNewDVDShareUrl( const CStdString& strNewUrl, bool bCDDA
 
 DWORD CDetectDVDMedia::GetTrayState()
 {
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 
   char* dvdDevice = m_cdio->GetDeviceFileName();
   if (strlen(dvdDevice) == 0)
@@ -400,7 +400,7 @@ DWORD CDetectDVDMedia::GetTrayState()
     return DRIVE_NOT_READY;
 
 #endif // USING_CDIO78
-#endif // _LINUX
+#endif // TARGET_POSIX
 
   if (m_dwTrayState == TRAY_CLOSED_MEDIA_PRESENT)
   {
index fd28132..cb108bc 100644 (file)
 #include "system.h"
 #include "IoSupport.h"
 #include "utils/log.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "my_ntddcdrm.h"
 #include "WIN32Util.h"
 #include "utils/CharsetConverter.h"
 #endif
-#if defined (_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if defined(TARGET_LINUX)
 #include <linux/limits.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <IOKit/storage/IOStorageDeviceCharacteristics.h>
 #endif
 #endif
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
 #include <sys/syslimits.h>
 #endif
 #include "cdioSupport.h"
 #include "filesystem/iso9660.h"
 #include "MediaManager.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "XHandle.h"
 #endif
 
@@ -72,12 +72,12 @@ HANDLE CIoSupport::OpenCDROM()
   HANDLE hDevice = 0;
 
 #ifdef HAS_DVD_DRIVE
-#if defined(_LINUX)
+#if defined(TARGET_POSIX)
   int fd = open(CLibcdio::GetInstance()->GetDeviceFileName(), O_RDONLY | O_NONBLOCK);
   hDevice = new CXHandle(CXHandle::HND_FILE);
   hDevice->fd = fd;
   hDevice->m_bCDROM = true;
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
   hDevice = CreateFile(g_mediaManager.TranslateDevicePath("",true), GENERIC_READ, FILE_SHARE_READ,
                        NULL, OPEN_EXISTING,
                        FILE_FLAG_RANDOM_ACCESS, NULL );
@@ -94,14 +94,14 @@ HANDLE CIoSupport::OpenCDROM()
 
 void CIoSupport::AllocReadBuffer()
 {
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   m_rawXferBuffer = GlobalAlloc(GPTR, RAW_SECTOR_SIZE);
 #endif
 }
 
 void CIoSupport::FreeReadBuffer()
 {
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   GlobalFree(m_rawXferBuffer);
 #endif
 }
@@ -129,7 +129,7 @@ INT CIoSupport::ReadSector(HANDLE hDevice, DWORD dwSector, LPSTR lpczBuffer)
     return -1;
   }
   return 2048;
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
   if (hDevice->m_bCDROM)
   {
     int fd = hDevice->fd;
@@ -202,9 +202,9 @@ INT CIoSupport::ReadSectorMode2(HANDLE hDevice, DWORD dwSector, LPSTR lpczBuffer
     return -1;
   }
   return MODE2_DATA_SIZE;
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
   // NYI
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
   if (hDevice->m_bCDROM)
   {
     int fd = hDevice->fd;
index 7ce5a1f..23e0c00 100644 (file)
@@ -27,9 +27,7 @@
 
 #include "system.h" // for Win32 types
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 
 #define MODE1_DATA_SIZE    2048 // Mode1 sector has 2048 bytes of data
 
index c89014d..07a0ee1 100644 (file)
 #include "guilib/LocalizeStrings.h"
 #include "URL.h"
 #include "utils/URIUtils.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "WIN32Util.h"
 #include "utils/CharsetConverter.h"
 #endif
 #include "guilib/GUIWindowManager.h"
 #ifdef HAS_DVD_DRIVE
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
 // TODO: switch all ports to use auto sources
 #include "DetectDVDType.h"
 #include "filesystem/iso9660.h"
 #include "android/AndroidStorageProvider.h"
 #elif defined(TARGET_FREEBSD)
 #include "linux/LinuxStorageProvider.h"
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
 #include "linux/LinuxStorageProvider.h"
 #include <sys/ioctl.h>
 #include <linux/cdrom.h>
-#elif _WIN32
+#elif TARGET_WINDOWS
 #include "windows/Win32StorageProvider.h"
 #endif
 
@@ -95,9 +95,9 @@ void CMediaManager::Initialize()
       m_platformStorage = new CDarwinStorageProvider();
     #elif defined(TARGET_ANDROID)
       m_platformStorage = new CAndroidStorageProvider();
-    #elif defined(_LINUX)
+    #elif defined(TARGET_POSIX)
       m_platformStorage = new CLinuxStorageProvider();
-    #elif _WIN32
+    #elif TARGET_WINDOWS
       m_platformStorage = new CWin32StorageProvider();
     #endif
   }
@@ -317,7 +317,7 @@ CStdString CMediaManager::TranslateDevicePath(const CStdString& devicePath, bool
     strDevice = m_strFirstAvailDrive;
 #endif
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if(!m_bhasoptical)
     return "";
 
@@ -334,7 +334,7 @@ CStdString CMediaManager::TranslateDevicePath(const CStdString& devicePath, bool
 bool CMediaManager::IsDiscInDrive(const CStdString& devicePath)
 {
 #ifdef HAS_DVD_DRIVE
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if(!m_bhasoptical)
     return false;
 
@@ -360,7 +360,7 @@ bool CMediaManager::IsDiscInDrive(const CStdString& devicePath)
 bool CMediaManager::IsAudio(const CStdString& devicePath)
 {
 #ifdef HAS_DVD_DRIVE
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if(!m_bhasoptical)
     return false;
 
@@ -391,7 +391,7 @@ bool CMediaManager::HasOpticalDrive()
 DWORD CMediaManager::GetDriveStatus(const CStdString& devicePath)
 {
 #ifdef HAS_DVD_DRIVE
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if(!m_bhasoptical)
     return DRIVE_NOT_READY;
 
@@ -426,7 +426,7 @@ DWORD CMediaManager::GetDriveStatus(const CStdString& devicePath)
 #ifdef HAS_DVD_DRIVE
 CCdInfo* CMediaManager::GetCdInfo(const CStdString& devicePath)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if(!m_bhasoptical)
     return NULL;
   
@@ -477,7 +477,7 @@ bool CMediaManager::RemoveCdInfo(const CStdString& devicePath)
 
 CStdString CMediaManager::GetDiskLabel(const CStdString& devicePath)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if(!m_bhasoptical)
     return "";
 
@@ -501,7 +501,7 @@ CStdString CMediaManager::GetDiskUniqueId(const CStdString& devicePath)
   if (strDevice.IsEmpty()) // if no value passed, use the current default disc path.
     strDevice = GetDiscPath();    // in case of non-Windows we must obtain the disc path
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if (!m_bhasoptical)
     return "";
   strDevice = TranslateDevicePath(strDevice);
@@ -510,7 +510,7 @@ CStdString CMediaManager::GetDiskUniqueId(const CStdString& devicePath)
 
   CStdString strDrive = g_mediaManager.TranslateDevicePath(strDevice);
 
-#ifndef _WIN32
+#ifndef TARGET_WINDOWS
   {
     CSingleLock waitLock(m_muAutoSource);
     CCdInfo* pInfo = g_mediaManager.GetCdInfo();
@@ -601,7 +601,7 @@ bool CMediaManager::HashDVD(const CStdString& dvdpath, uint32_t& crc)
 
 CStdString CMediaManager::GetDiscPath()
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   return g_mediaManager.TranslateDevicePath("");
 #else
 
@@ -662,9 +662,9 @@ void CMediaManager::CloseTray(const char cDriveLetter)
 #ifdef HAS_DVD_DRIVE
 #if defined(TARGET_DARWIN)
   // FIXME...
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
   // NYI
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
   char* dvdDevice = CLibcdio::GetInstance()->GetDeviceFileName();
   if (strlen(dvdDevice) != 0)
   {
index eee5583..5d8ee53 100644 (file)
 #include "cdioSupport.h"
 #include "threads/SingleLock.h"
 #include "utils/log.h"
+#include "utils/Environment.h"
 #include <cdio/logging.h>
 #include <cdio/util.h>
 #include <cdio/mmc.h>
 #include <cdio/cd_types.h>
 
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
 #pragma comment(lib, "libcdio.dll.lib")
 #endif
 
@@ -211,8 +212,9 @@ char* CLibcdio::GetDeviceFileName()
 
   if (s_defaultDevice == NULL)
   {
-    if (getenv("XBMC_DVD_DEVICE") != NULL)
-      s_defaultDevice = strdup(getenv("XBMC_DVD_DEVICE"));
+    std::string strEnvDvd = CEnvironment::getenv("XBMC_DVD_DEVICE");
+    if (!strEnvDvd.empty())
+      s_defaultDevice = strdup(strEnvDvd.c_str());
     else
     {
       CdIo_t *p_cdio = ::cdio_open(NULL, DRIVER_UNKNOWN);
index 1bd0c98..3fadcc4 100644 (file)
   #define HAS_UPNP
 #endif
 
+#if defined(HAVE_LIBMDNSEMBEDDED)
+  #define HAS_ZEROCONF
+  #define HAS_MDNS
+  #define HAS_MDNS_EMBEDDED
+#endif
+
 /**********************
  * Non-free Components
  **********************/
 #define HAS_FILESYSTEM_SMB
 #define HAS_FILESYSTEM_NFS
 #define HAS_ZEROCONF
+#define HAS_MDNS
 #define HAS_AIRPLAY
 #define HAS_AIRTUNES
 #define HAVE_LIBSHAIRPLAY
index 80085b8..9de0510 100644 (file)
@@ -64,7 +64,7 @@ void TestBasicEnvironment::SetUp()
   /* Create a temporary directory and set it to be used throughout the
    * test suite run.
    */
-#ifndef _LINUX
+#ifdef TARGET_WINDOWS
   TCHAR lpTempPathBuffer[MAX_PATH];
   if (!GetTempPath(MAX_PATH, lpTempPathBuffer))
     SetUpError();
index 6c8617c..7344217 100644 (file)
@@ -24,7 +24,7 @@
 #include "filesystem/SpecialProtocol.h"
 #include "utils/StringUtils.h"
 
-#ifndef _LINUX
+#ifdef TARGET_WINDOWS
 #include <windows.h>
 #else
 #include <cstdlib>
@@ -55,7 +55,7 @@ public:
     }
     strcpy(tmp, m_ptempFilePath.c_str());
 
-#ifndef _LINUX
+#ifdef TARGET_WINDOWS
     if (!GetTempFileName(CSpecialProtocol::TranslatePath("special://temp/"),
                          "xbmctempfile", 0, tmp))
     {
@@ -186,11 +186,6 @@ XFILE::CFile *CXBMCTestUtils::CreateCorruptedFile(CStdString const& strFileName,
 }
 
 
-std::vector<CStdString> &CXBMCTestUtils::getTestDownloadQueueUrls()
-{
-  return TestDownloadQueueUrls;
-}
-
 std::vector<CStdString> &CXBMCTestUtils::getTestFileFactoryReadUrls()
 {
   return TestFileFactoryReadUrls;
@@ -227,13 +222,6 @@ static const char usage[] =
 "\n"
 "The following options are recognized by the xbmc-test program.\n"
 "\n"
-"  --add-testdownloadqueue-url [URL]\n"
-"    Add a url to be used in the TestDownloadQueue tests.\n"
-"\n"
-"  --add-testdownloadqueue-urls [URLS]\n"
-"    Add multiple urls from a ',' delimited string of urls. to be used\n"
-"    in the TestDownloadQueue tests.\n"
-"\n"
 "  --add-testfilefactory-readurl [URL]\n"
 "    Add a url to be used int the TestFileFactory read tests.\n"
 "\n"
@@ -279,19 +267,7 @@ void CXBMCTestUtils::ParseArgs(int argc, char **argv)
   for (i = 1; i < argc; i++)
   {
     arg = argv[i];
-    if (arg == "--add-testdownloadqueue-url")
-    {
-      TestDownloadQueueUrls.push_back(argv[++i]);
-    }
-    else if (arg == "--add-testdownloadqueue-urls")
-    {
-      arg = argv[++i];
-      std::vector<std::string> urls = StringUtils::Split(arg, ",");
-      std::vector<std::string>::iterator it;
-      for (it = urls.begin(); it < urls.end(); it++)
-        TestDownloadQueueUrls.push_back(*it);
-    }
-    else if (arg == "--add-testfilefactory-readurl")
+    if (arg == "--add-testfilefactory-readurl")
     {
       TestFileFactoryReadUrls.push_back(argv[++i]);
     }
index 2918e2e..3196d14 100644 (file)
@@ -54,9 +54,6 @@ public:
   /* Function to get path of a tempfile */
   CStdString TempFilePath(XFILE::CFile const* const tempfile);
 
-  /* Functions to get variables used in the TestDownloadQueue tests. */
-  std::vector<CStdString> &getTestDownloadQueueUrls();
-
   /* Functions to get variables used in the TestFileFactory tests. */
   std::vector<CStdString> &getTestFileFactoryReadUrls();
 
@@ -94,7 +91,6 @@ private:
   CXBMCTestUtils(CXBMCTestUtils const&);
   void operator=(CXBMCTestUtils const&);
 
-  std::vector<CStdString> TestDownloadQueueUrls;
   std::vector<CStdString> TestFileFactoryReadUrls;
   std::vector<CStdString> TestFileFactoryWriteUrls;
   CStdString TestFileFactoryWriteInputFile;
index 63f541b..3a0d049 100644 (file)
@@ -68,7 +68,7 @@ long cas(volatile long *pAddr, long expectedVal, long swapVal)
   #error atomic cas undefined for mips
   return prev;
 
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
   long prev;
   __asm
   {
@@ -108,7 +108,7 @@ long long cas2(volatile long long* pAddr, long long expectedVal, long long swapV
 // Hack to allow compilation
   throw "cas2 is not implemented";
 
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
   long long prev;
   __asm
   {
@@ -188,7 +188,7 @@ long AtomicIncrement(volatile long* pAddr)
   #error AtomicIncrement undefined for mips
   return val;
 
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
   long val;
   __asm
   {
@@ -266,7 +266,7 @@ long AtomicAdd(volatile long* pAddr, long amount)
   #error AtomicAdd undefined for mips
   return val;
 
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
   __asm
   {
     mov eax, amount;
@@ -344,7 +344,7 @@ long AtomicDecrement(volatile long* pAddr)
   #error AtomicDecrement undefined for mips
   return val;
 
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
   long val;
   __asm
   {
@@ -422,7 +422,7 @@ long AtomicSubtract(volatile long* pAddr, long amount)
   #error AtomicSubtract undefined for mips
   return val;
 
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
   amount *= -1;
   __asm
   {
index 85c1791..6b8dce8 100644 (file)
@@ -27,7 +27,7 @@
 #endif
 #include <sys/resource.h>
 #include <string.h>
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
 #include <sys/param.h>
 #if __FreeBSD_version < 900031
 #include <sys/thr.h>
@@ -58,7 +58,7 @@ void CThread::TermHandler() { }
 
 void CThread::SetThreadInfo()
 {
-#ifdef __FreeBSD__
+#ifdef TARGET_FREEBSD
 #if __FreeBSD_version < 900031
   long lwpid;
   thr_self(&lwpid);
index 3539db6..ce1076f 100644 (file)
@@ -21,7 +21,7 @@
 #if defined(TARGET_DARWIN_OSX)
 #include <CoreServices/CoreServices.h>
 #include "utils/URIUtils.h"
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
 #else
 #endif
 
@@ -34,7 +34,7 @@ bool IsAliasShortcut(CStdString &path)
 #if defined(TARGET_DARWIN_OSX)
   // Note: regular files that have an .alias extension can be
   //   reported as an alias when clearly, they are not. Trap them out.
-  if (URIUtils::GetExtension(path) != ".alias")
+  if (!URIUtils::HasExtension(path, ".alias"))
   {
     FSRef fileRef;
     Boolean targetIsFolder, wasAliased;
@@ -52,9 +52,9 @@ bool IsAliasShortcut(CStdString &path)
       }
     }
   }
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
   // Linux does not use alias or shortcut methods
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
 /* Needs testing under Windows platform so ignore shortcuts for now
     if (CUtil::GetExtension(path) == ".lnk")
     {
@@ -85,10 +85,10 @@ void TranslateAliasShortcut(CStdString &path)
       }
     }
   }
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
   // Linux does not use alias or shortcut methods
 
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
 /* Needs testing under Windows platform so ignore shortcuts for now
   CComPtr<IShellLink> ipShellLink;
 
index 44dec1e..eecde15 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 #include <string>
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "linux/PlatformDefs.h"
 #endif
 
index 64c90b9..7a4335f 100644 (file)
@@ -49,7 +49,7 @@
 #include "android/activity/AndroidFeatures.h"
 #endif
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include <intrin.h>
 
 // Defines to help with calls to CPUID
@@ -91,7 +91,7 @@ using namespace std;
 // In milliseconds
 #define MINIMUM_TIME_BETWEEN_READS 500
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 /* replacement gettimeofday implementation, copy from dvdnav_internal.h */
 #include <sys/timeb.h>
 static inline int _private_gettimeofday( struct timeval *tv, void *tz )
@@ -181,7 +181,7 @@ CCPUInfo::CCPUInfo(void)
     m_cores[core.m_id] = core;
   }
 
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
   char rgValue [128];
   HKEY hKey;
   DWORD dwSize=128;
@@ -433,7 +433,7 @@ int CCPUInfo::getUsedPercentage()
   idleTicks -= m_idleTicks;
   ioTicks -= m_ioTicks;
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if(userTicks + systemTicks == 0)
     return m_lastUsedPercentage;
   int result = (int) ((userTicks + systemTicks - idleTicks) * 100 / (userTicks + systemTicks));
@@ -464,7 +464,7 @@ float CCPUInfo::getCPUFrequency()
   if (sysctlbyname("hw.cpufrequency", &hz, &len, NULL, 0) == -1)
     return 0.f;
   return hz / 1000000.0;
-#elif defined _WIN32
+#elif defined TARGET_WINDOWS
   HKEY hKey;
   DWORD dwMHz=0;
   DWORD dwSize=sizeof(dwMHz);
@@ -577,7 +577,7 @@ bool CCPUInfo::readProcStat(unsigned long long& user, unsigned long long& nice,
     unsigned long long& system, unsigned long long& idle, unsigned long long& io)
 {
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   FILETIME idleTime;
   FILETIME kernelTime;
   FILETIME userTime;
@@ -724,7 +724,7 @@ CStdString CCPUInfo::GetCoresUsageString() const
   while (iter != m_cores.end())
   {
     CStdString strCore;
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
     // atm we get only the average over all cores
     strCore.Format("CPU %d core(s) average: %3.1f%% ",m_cpuCount, iter->second.m_fPct);
 #else
@@ -738,7 +738,7 @@ CStdString CCPUInfo::GetCoresUsageString() const
 
 void CCPUInfo::ReadCPUFeatures()
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 
   int CPUInfo[4]; // receives EAX, EBX, ECD and EDX in that order
 
index f5001ff..d6b06a8 100644 (file)
@@ -37,7 +37,7 @@
   #define WCHAR_CHARSET "UTF-32LE"
 #endif
   #define UTF8_SOURCE "UTF-8-MAC"
-#elif defined(WIN32)
+#elif defined(TARGET_WINDOWS)
   #define WCHAR_CHARSET "UTF-16LE"
   #define UTF8_SOURCE "UTF-8"
   #pragma comment(lib, "libfribidi.lib")
index cbe52be..9c29473 100644 (file)
@@ -26,7 +26,7 @@
 #include "threads/Thread.h"
 #include "utils/log.h"
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #else
 #define HAVE_OPENSSL
diff --git a/xbmc/utils/DownloadQueue.cpp b/xbmc/utils/DownloadQueue.cpp
deleted file mode 100644 (file)
index cefc5cd..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- *      Copyright (C) 2005-2013 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, see
- *  <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "DownloadQueue.h"
-#include "URIUtils.h"
-#include "log.h"
-
-#include "filesystem/File.h"
-#include "filesystem/CurlFile.h"
-#include "threads/SingleLock.h"
-
-using namespace std;
-using namespace XFILE;
-
-WORD CDownloadQueue::m_wNextQueueId = 0;
-
-CDownloadQueue::CDownloadQueue(void) : CThread("DownloadQueue")
-{
-  m_bStop = false;
-  m_wQueueId = m_wNextQueueId++;
-  m_dwNextItemId = 0;
-  CThread::Create(false);
-}
-
-void CDownloadQueue::OnStartup()
-{
-  SetPriority( GetMinPriority() );
-}
-
-CDownloadQueue::~CDownloadQueue(void)
-{
-}
-
-
-TICKET CDownloadQueue::RequestContent(const CStdString& aUrl, IDownloadQueueObserver* aObserver)
-{
-  CSingleLock lock(m_critical);
-  TICKET ticket(m_wQueueId, m_dwNextItemId++);
-
-  Command request = {ticket, aUrl, "", aObserver};
-  m_queue.push(request);
-
-  return request.ticket;
-}
-
-TICKET CDownloadQueue::RequestFile(const CStdString& aUrl, const CStdString& aFilePath, IDownloadQueueObserver* aObserver)
-{
-  CSingleLock lock(m_critical);
-
-  TICKET ticket(m_wQueueId, m_dwNextItemId++);
-
-  Command request = {ticket, aUrl, aFilePath, aObserver};
-  m_queue.push(request);
-
-  return request.ticket;
-}
-
-void CDownloadQueue::CancelRequests(IDownloadQueueObserver *aObserver)
-{
-  CSingleLock lock(m_critical);
-
-  CLog::Log(LOGDEBUG, "CancelRequests from observer at %p", aObserver);
-  // run through our queue, and create a new queue with the requests
-  // from aObserver NULL'd out.
-  queue<Command> newQueue;
-  while (m_queue.size())
-  {
-    Command request = m_queue.front();
-    m_queue.pop();
-    if (request.observer == aObserver)
-      request.observer = NULL;
-    newQueue.push(request);
-  }
-  m_queue = newQueue;
-}
-
-TICKET CDownloadQueue::RequestFile(const CStdString& aUrl, IDownloadQueueObserver* aObserver)
-{
-  CSingleLock lock(m_critical);
-
-  CLog::Log(LOGDEBUG, "RequestFile from observer at %p", aObserver);
-  // create a temporary destination
-  CStdString strExtension = URIUtils::GetExtension(aUrl);
-
-  TICKET ticket(m_wQueueId, m_dwNextItemId++);
-
-  CStdString strFilePath;
-  strFilePath.Format("special://temp/q%d-item%u%s", ticket.wQueueId, ticket.dwItemId, strExtension.c_str());
-
-  Command request = {ticket, aUrl, strFilePath, aObserver};
-  m_queue.push(request);
-
-  return request.ticket;
-}
-
-VOID CDownloadQueue::Flush()
-{
-  CSingleLock lock(m_critical);
-
-  m_queue.empty();
-
-}
-
-void CDownloadQueue::Process()
-{
-  CLog::Log(LOGNOTICE, "DownloadQueue ready.");
-
-  CCurlFile http;
-  bool bSuccess;
-
-  while ( !m_bStop )
-  {
-    while ( CDownloadQueue::Size() > 0 )
-    {
-      CSingleLock lock(m_critical);
-
-      // get the first item, but don't pop it from our queue
-      // so that the download can be interrupted
-      Command request = m_queue.front();
-      lock.Leave();
-
-      bool bFileRequest = request.content.length() > 0;
-      DWORD dwSize = 0;
-
-      if (bFileRequest)
-      {
-        CFile::Delete(request.content);
-        bSuccess = http.Download(request.location, request.content, &dwSize);
-      }
-      else
-      {
-        bSuccess = http.Get(request.location, request.content);
-      }
-
-      // now re-grab the item as we may have cancelled our download
-      // while we were working
-      { CSingleLock lock2(m_critical); // open lock2 scope
-
-      request = m_queue.front();
-      m_queue.pop();
-
-      // if the request has been cancelled our observer will be NULL
-      if (NULL != request.observer)
-      {
-        try
-        {
-          if (bFileRequest)
-          {
-            request.observer->OnFileComplete(request.ticket, request.content, dwSize,
-                                             bSuccess ? IDownloadQueueObserver::Succeeded : IDownloadQueueObserver::Failed );
-          }
-          else
-          {
-            request.observer->OnContentComplete(request.ticket, request.content,
-                                                bSuccess ? IDownloadQueueObserver::Succeeded : IDownloadQueueObserver::Failed );
-          }
-        }
-        catch (...)
-        {
-          CLog::Log(LOGERROR, "exception while updating download observer.");
-
-          if (bFileRequest)
-          {
-            CFile::Delete(request.content);
-          }
-        }
-      }
-      } // close lock2 scope
-    }
-
-    Sleep(500);
-  }
-
-  CLog::Log(LOGNOTICE, "DownloadQueue terminated.");
-}
-
-INT CDownloadQueue::Size()
-{
-  CSingleLock lock(m_critical);
-
-  int sizeOfQueue = m_queue.size();
-
-  return sizeOfQueue;
-}
-
diff --git a/xbmc/utils/DownloadQueue.h b/xbmc/utils/DownloadQueue.h
deleted file mode 100644 (file)
index 9619eac..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-#pragma once
-
-/*
- *      Copyright (C) 2005-2013 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, see
- *  <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <queue>
-#include "threads/Thread.h"
-#include "threads/CriticalSection.h"
-#include "StdString.h"
-
-#include "system.h"
-
-struct TICKET
-{
-  TICKET(WORD aQueueId, DWORD aItemId)
-  {
-    wQueueId = aQueueId;
-    dwItemId = aItemId;
-  };
-
-  WORD wQueueId;
-  DWORD dwItemId;
-};
-
-class IDownloadQueueObserver
-{
-public:
-  enum Result {Succeeded, Failed};
-  virtual ~IDownloadQueueObserver() {};
-  virtual void OnContentComplete(TICKET aTicket, CStdString& aContentString, Result aResult){};
-  virtual void OnFileComplete(TICKET aTicket, CStdString& aFilePath, INT aByteRxCount, Result aResult){};
-};
-
-
-class CDownloadQueue: CThread
-{
-public:
-  CDownloadQueue();
-  virtual ~CDownloadQueue(void);
-
-  TICKET RequestContent(const CStdString& aUrl, IDownloadQueueObserver* aObserver);
-  TICKET RequestFile(const CStdString& aUrl, IDownloadQueueObserver* aObserver);
-  TICKET RequestFile(const CStdString& aUrl, const CStdString& aFilePath, IDownloadQueueObserver* aObserver);
-  void CancelRequests(IDownloadQueueObserver* aObserver);
-
-  VOID Flush();
-  INT Size();
-
-protected:
-
-  void OnStartup();
-  void Process();
-
-  struct Command
-  {
-    TICKET ticket;
-    CStdString location;
-    CStdString content;
-    IDownloadQueueObserver* observer;
-  };
-
-  typedef std::queue<Command> COMMANDQUEUE;
-  COMMANDQUEUE m_queue;
-  CCriticalSection m_critical;
-
-  WORD m_wQueueId;
-  DWORD m_dwNextItemId;
-
-  static WORD m_wNextQueueId;
-};
diff --git a/xbmc/utils/DownloadQueueManager.cpp b/xbmc/utils/DownloadQueueManager.cpp
deleted file mode 100644 (file)
index 0618c51..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- *      Copyright (C) 2005-2013 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, see
- *  <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "DownloadQueueManager.h"
-#include "threads/SingleLock.h"
-#include <assert.h>
-
-CDownloadQueueManager::CDownloadQueueManager()
-{
-}
-
-CDownloadQueueManager::~CDownloadQueueManager(void)
-{
-}
-
-VOID CDownloadQueueManager::Initialize()
-{
-}
-
-
-TICKET CDownloadQueueManager::RequestContent(const CStdString& aUrl, IDownloadQueueObserver* aObserver)
-{
-  CSingleLock lock(m_critical);
-  return GetNextDownloadQueue()->RequestContent(aUrl, aObserver);
-}
-
-TICKET CDownloadQueueManager::RequestFile(const CStdString& aUrl, const CStdString& aFilePath, IDownloadQueueObserver* aObserver)
-{
-  CSingleLock lock(m_critical);
-  return GetNextDownloadQueue()->RequestFile(aUrl, aFilePath, aObserver);
-}
-
-TICKET CDownloadQueueManager::RequestFile(const CStdString& aUrl, IDownloadQueueObserver* aObserver)
-{
-  CSingleLock lock(m_critical);
-  return GetNextDownloadQueue()->RequestFile(aUrl, aObserver);
-}
-
-void CDownloadQueueManager::CancelRequests(IDownloadQueueObserver *aObserver)
-{
-  CSingleLock lock(m_critical);
-  // run through all our queues and remove all requests from this observer
-  for (QUEUEPOOL::iterator it = m_queues.begin(); it != m_queues.end(); ++it)
-  {
-    CDownloadQueue* downloadQueue = *it;
-    downloadQueue->CancelRequests(aObserver);
-  }
-}
-
-CDownloadQueue* CDownloadQueueManager::GetNextDownloadQueue()
-{
-  CDownloadQueue* pQueueAvailable = NULL;
-
-  // if we haven't added any queues to the pool, add one.
-  if (m_queues.size() < 1)
-  {
-    m_queues.push_back( new CDownloadQueue() );
-  }
-
-  // return the queue with the least number of items pending
-  for (QUEUEPOOL::iterator it = m_queues.begin(); it != m_queues.end(); ++it)
-  {
-    // always choose the first queue if we haven't selected one yet
-    if (!pQueueAvailable)
-    {
-      pQueueAvailable = *it;
-    }
-    else
-    {
-      // pick this queue if it has less items pending than our previous selection
-      if ( pQueueAvailable->Size() > (*it)->Size() )
-      {
-        pQueueAvailable = *it;
-      }
-    }
-  }
-
-  // if we picked a queue with pending items and we haven't reached out max pool limit
-  if (pQueueAvailable && pQueueAvailable->Size() > 0 && m_queues.size() < MAX_DOWNLOAD_QUEUES)
-  {
-    // spawn a new queue
-    pQueueAvailable = new CDownloadQueue();
-    m_queues.push_back(pQueueAvailable);
-  }
-
-  assert(pQueueAvailable != NULL);
-
-  return pQueueAvailable;
-}
-
diff --git a/xbmc/utils/DownloadQueueManager.h b/xbmc/utils/DownloadQueueManager.h
deleted file mode 100644 (file)
index e858547..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#pragma once
-
-/*
- *      Copyright (C) 2005-2013 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, see
- *  <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "DownloadQueue.h"
-#include "system.h"
-
-#define MAX_DOWNLOAD_QUEUES  3
-
-class CDownloadQueueManager
-{
-public:
-  CDownloadQueueManager();
-  virtual ~CDownloadQueueManager(void);
-
-  VOID Initialize();
-  TICKET RequestContent(const CStdString& aUrl, IDownloadQueueObserver* aObserver);
-  TICKET RequestFile(const CStdString& aUrl, IDownloadQueueObserver* aObserver);
-  TICKET RequestFile(const CStdString& aUrl, const CStdString& aFilePath, IDownloadQueueObserver* aObserver);
-  void CancelRequests(IDownloadQueueObserver *aObserver);
-
-protected:
-
-  CDownloadQueue* GetNextDownloadQueue();
-
-  typedef std::vector<CDownloadQueue*> QUEUEPOOL;
-  QUEUEPOOL m_queues;
-
-  CCriticalSection m_critical;
-};
-
-// Single global instance of class is in cpp file
-extern CDownloadQueueManager g_DownloadManager;
index f4d8669..4c53acf 100644 (file)
 
 /* Include config.h to define (or not) WORDS_BIGENDIAN
    File created by configure */
-#if defined(__linux__) || defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
+#if defined(TARGET_POSIX)
 #include "config.h"
 #include <inttypes.h>
 #endif
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #define __inline__ __inline
 #include <stdint.h>
 #endif
index b23ace7..a327be8 100644 (file)
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #ifdef TARGET_WINDOWS
 #include <Windows.h>
+#include "utils\SystemInfo.h"
 #endif
 
 // --------------------- Helper Functions ---------------------
@@ -76,11 +77,13 @@ std::string CEnvironment::win32ConvertWToUtf8(const std::wstring &text, bool *re
   if (resultSuccessful != NULL)
     *resultSuccessful = false;
 
-  int bufSize = WideCharToMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, text.c_str(), -1, NULL, 0, NULL, NULL);
+  static const DWORD convFlags = (CSysInfo::IsWindowsVersionAtLeast(CSysInfo::WindowsVersionVista)) ?
+    /*WC_ERR_INVALID_CHARS*/ 0x80 : 0;
+  int bufSize = WideCharToMultiByte(CP_UTF8,  convFlags, text.c_str(), -1, NULL, 0, NULL, NULL);
   if (bufSize == 0)
     return "";
   char * converted = new char[bufSize];
-  if (WideCharToMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, text.c_str(), -1, converted, bufSize, NULL, NULL) != bufSize)
+  if (WideCharToMultiByte(CP_UTF8, convFlags, text.c_str(), -1, converted, bufSize, NULL, NULL) != bufSize)
   {
     delete[] converted;
     return "";
@@ -91,7 +94,7 @@ std::string CEnvironment::win32ConvertWToUtf8(const std::wstring &text, bool *re
   
   if (resultSuccessful != NULL)
     *resultSuccessful = true;
-  return converted;
+  return ret;
 }
 
 // --------------------- Internal Function ---------------------
@@ -148,6 +151,9 @@ int CEnvironment::win32_setenv(const std::string &name, const std::string &value
     { L"msvcr100d.dll" },// Visual Studio 2010 (debug)
 #endif
     { L"msvcr110.dll" }, // Visual Studio 2012
+#ifdef _DEBUG
+    { L"msvcr110d.dll" },// Visual Studio 2012 (debug)
+#endif
     { NULL }             // Terminating NULL for list
   };
   
@@ -197,13 +203,13 @@ std::string CEnvironment::getenv(const std::string &name)
   if (Wname.empty())
     return "";
 
-  std::wstring Wvalue (::_wgetenv(Wname.c_str()));
-  if (!Wvalue.empty())
-    return win32ConvertWToUtf8(Wvalue);
+  wchar_t * wStr = ::_wgetenv(Wname.c_str());
+  if (wStr != NULL)
+    return win32ConvertWToUtf8(wStr);
 
   // Not found in Environment of runtime library 
   // Try Environment of process as fallback
-  int varSize = GetEnvironmentVariableW(Wname.c_str(), NULL, 0);
+  unsigned int varSize = GetEnvironmentVariableW(Wname.c_str(), NULL, 0);
   if (varSize == 0)
     return ""; // Not found
   wchar_t * valBuf = new wchar_t[varSize];
@@ -212,12 +218,15 @@ std::string CEnvironment::getenv(const std::string &name)
     delete[] valBuf;
     return "";
   }
-  Wvalue = valBuf;
+  std::wstring Wvalue (valBuf);
   delete[] valBuf;
 
   return win32ConvertWToUtf8(Wvalue);
 #else
-  return ::getenv(name.c_str());
+  char * str = ::getenv(name.c_str());
+  if (str == NULL)
+    return "";
+  return str;
 #endif
 }
 
index 2ba0737..0f3541a 100644 (file)
@@ -168,7 +168,7 @@ bool CFileOperationJob::DoProcess(FileAction action, CFileItemList & items, cons
         // get filename from label instead of path
         strFileName = pItem->GetLabel();
 
-        if(!pItem->m_bIsFolder && URIUtils::GetExtension(strFileName).length() == 0)
+        if(!pItem->m_bIsFolder && !URIUtils::HasExtension(strFileName))
         {
           // FIXME: for now we only work well if the url has the extension
           // we should map the content type to the extension otherwise
@@ -312,7 +312,7 @@ bool CFileOperationJob::CFileOperation::ExecuteOperation(CFileOperationJob *base
 
 inline bool CFileOperationJob::CanBeRenamed(const CStdString &strFileA, const CStdString &strFileB)
 {
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   if (strFileA[1] == ':' && strFileA[0] == strFileB[0])
     return true;
 #else
index e47a87d..1ad29c9 100644 (file)
@@ -9,6 +9,10 @@
 #include "URIUtils.h"
 #include "filesystem/MultiPathDirectory.h"
 #include <vector>
+#include "settings/MediaSourceSettings.h"
+#include "Util.h"
+#include "StringUtils.h"
+#include "URL.h"
 
 using namespace XFILE;
 using namespace std;
@@ -81,3 +85,42 @@ bool CFileUtils::RenameFile(const CStdString &strFile)
   }
   return false;
 }
+
+bool CFileUtils::RemoteAccessAllowed(const CStdString &strPath)
+{
+  const unsigned int SourcesSize = 5;
+  CStdString SourceNames[] = { "programs", "files", "video", "music", "pictures" };
+
+  string realPath = URIUtils::GetRealPath(strPath);
+  // for rar:// and zip:// paths we need to extract the path to the archive
+  // instead of using the VFS path
+  while (URIUtils::IsInArchive(realPath))
+    realPath = CURL(realPath).GetHostName();
+
+  if (StringUtils::StartsWith(realPath, "virtualpath://upnproot/"))
+    return true;
+  else if (StringUtils::StartsWith(realPath, "musicdb://"))
+    return true;
+  else if (StringUtils::StartsWith(realPath, "videodb://"))
+    return true;
+  else if (StringUtils::StartsWith(realPath, "library://video"))
+    return true;
+  else if (StringUtils::StartsWith(realPath, "sources://video"))
+    return true;
+  else if (StringUtils::StartsWith(realPath, "special://musicplaylists"))
+    return true;
+  else if (StringUtils::StartsWith(realPath, "special://profile/playlists"))
+    return true;
+  else if (StringUtils::StartsWith(realPath, "special://videoplaylists"))
+    return true;
+
+  bool isSource;
+  for (unsigned int index = 0; index < SourcesSize; index++)
+  {
+    VECSOURCES* sources = CMediaSourceSettings::Get().GetSources(SourceNames[index]);
+    int sourceIndex = CUtil::GetMatchingSource(realPath, *sources, isSource);
+    if (sourceIndex >= 0 && sourceIndex < (int)sources->size() && sources->at(sourceIndex).m_iHasLock != 2 && sources->at(sourceIndex).m_allowSharing)
+      return true;
+  }
+  return false;
+}
\ No newline at end of file
index 7d8fce4..20cac66 100644 (file)
@@ -7,4 +7,5 @@ public:
   static bool DeleteItem(const CFileItemPtr &item, bool force=false);
   static bool DeleteItem(const CStdString &strPath, bool force=false);
   static bool RenameFile(const CStdString &strFile);
+  static bool RemoteAccessAllowed(const CStdString &strPath);
 };
index c7a90e0..5399097 100644 (file)
@@ -158,6 +158,13 @@ void CJobQueue::CancelJobs()
   m_processing.clear();
 }
 
+
+bool CJobQueue::QueueEmpty() const
+{
+  CSingleLock lock(m_section);
+  return m_jobQueue.empty();
+}
+
 CJobManager &CJobManager::GetInstance()
 {
   static CJobManager sJobManager;
index c53ea68..626d77c 100644 (file)
@@ -135,6 +135,13 @@ public:
    */
   virtual void OnJobComplete(unsigned int jobID, bool success, CJob *job);
 
+protected:
+  /*!
+   \brief Returns if we still have jobs waiting to be processed
+   NOTE: This function does not take into account the jobs that are currently processing 
+   */
+  bool QueueEmpty() const;
+  
 private:
   void QueueNextJob();
 
index 6cd46c1..b8d36e4 100644 (file)
@@ -158,7 +158,7 @@ bool CLangCodeExpander::ConvertTwoToThreeCharCode(CStdString& strThreeCharCode,
     {
       if (strTwoCharCodeLower.Equals(CharCode2To3[index].old))
       {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
         if (localeHack && CharCode2To3[index].win_id)
         {
           strThreeCharCode = CharCode2To3[index].win_id;
index 529be0e..694a9bd 100644 (file)
@@ -12,8 +12,6 @@ SRCS += CPUInfo.cpp
 SRCS += Crc32.cpp
 SRCS += CryptThreading.cpp
 SRCS += DatabaseUtils.cpp
-SRCS += DownloadQueue.cpp
-SRCS += DownloadQueueManager.cpp
 SRCS += EndianSwap.cpp
 SRCS += EdenVideoArtUpdater.cpp
 SRCS += Environment.cpp
index 3700116..08d5aef 100644 (file)
 
 #if defined(__ppc__) || \
     defined(__powerpc__) || \
-   (defined(__APPLE__) && defined(__arm__) && defined(__llvm__)) || \
-   (defined(__ANDROID__) && defined(__arm__)) || \
+   (defined(TARGET_DARWIN_IOS) && defined(__llvm__)) || \
+   (defined(TARGET_ANDROID) && defined(__arm__)) || \
     defined(TARGET_RASPBERRY_PI)
   #define DISABLE_MATHUTILS_ASM_ROUND_INT
 #endif
 
 #if defined(__ppc__) || \
     defined(__powerpc__) || \
-   (defined(__APPLE__) && defined(__llvm__)) || \
-   (defined(__ANDROID__) && defined(__arm__)) || \
+   (defined(TARGET_DARWIN) && defined(__llvm__)) || \
+   (defined(TARGET_ANDROID) && defined(__arm__)) || \
     defined(TARGET_RASPBERRY_PI)
   #define DISABLE_MATHUTILS_ASM_TRUNCATE_INT
 #endif
@@ -130,7 +130,7 @@ namespace MathUtils
     const float round_dn_to_nearest = 0.4999999f;
     i = (x > 0) ? _mm_cvttsd_si32(_mm_set_sd(x + round_to_nearest)) : _mm_cvttsd_si32(_mm_set_sd(x - round_dn_to_nearest));
 
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
     __asm
     {
       fld x
@@ -178,7 +178,7 @@ namespace MathUtils
     );
     return i;
 
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
     const float round_towards_m_i = -0.5f;
     __asm
     {
index 24a2fbf..8079d4a 100644 (file)
@@ -21,7 +21,7 @@
 #include "system.h"
 #include "PerformanceSample.h"
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "linux/PlatformInclude.h"
 #endif
 
@@ -52,7 +52,7 @@ CPerformanceSample::~CPerformanceSample()
 void CPerformanceSample::Reset()
 {
   m_tmStart = CurrentHostCounter();
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   if (getrusage(RUSAGE_SELF, &m_usage) == -1)
     CLog::Log(LOGERROR,"error %d in getrusage", errno);
 #endif
@@ -66,7 +66,7 @@ void CPerformanceSample::CheckPoint()
   double elapsed = (double)(tmNow - m_tmStart) / (double)m_tmFreq.QuadPart;
 
   double dUser=0.0, dSys=0.0;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   struct rusage usage;
   if (getrusage(RUSAGE_SELF, &usage) == -1)
     CLog::Log(LOGERROR,"error %d in getrusage", errno);
index 815c11d..221e5f5 100644 (file)
@@ -21,7 +21,7 @@
  *
  */
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "linux/PlatformDefs.h"
 #include <sys/time.h>
 #include <sys/times.h>
@@ -55,7 +55,7 @@ protected:
   std::string m_statName;
   bool m_bCheckWhenDone;
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   struct rusage m_usage;
 #endif
 
index c95f7a8..ff9107c 100644 (file)
@@ -26,7 +26,7 @@
 #include <vector>
 
 namespace PCRE {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #define PCRE_STATIC
 #include "lib/win32/pcre/pcre.h"
 #else
index 8b71ed5..6e45eaa 100644 (file)
@@ -55,7 +55,7 @@ void CRssManager::OnSettingsLoaded()
   Load();
 }
 
-void CRssManager::OnSettingsCleared()
+void CRssManager::OnSettingsUnloaded()
 {
   Clear();
 }
index 8fd187d..7b5ba8c 100644 (file)
@@ -45,7 +45,7 @@ public:
   static CRssManager& Get();
 
   virtual void OnSettingsLoaded();
-  virtual void OnSettingsCleared();
+  virtual void OnSettingsUnloaded();
 
   virtual void OnSettingAction(const CSetting *setting);
 
index 1c870b3..cdf8a86 100644 (file)
@@ -3,7 +3,7 @@
 #include <stdint.h>
 #include <vector>
 
-#if defined(_WIN32) && !defined(va_copy)
+#if defined(TARGET_WINDOWS) && !defined(va_copy)
 #define va_copy(dst, src) ((dst) = (src))
 #endif
 
@@ -864,7 +864,7 @@ inline const Type& SSMAX(const Type& arg1, const Type& arg2)
       PWSTR pNextDstW      = pDstW;
       SSCodeCvt::result res  = SSCodeCvt::ok;
       const SSCodeCvt& conv  = SS_USE_FACET(loc, SSCodeCvt);
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
       SSCodeCvt::state_type st= { { 0 } };
 #else
       SSCodeCvt::state_type st= { 0 };
@@ -872,7 +872,7 @@ inline const Type& SSMAX(const Type& arg1, const Type& arg2)
       res            = conv.in(st,
                     pSrcA, pSrcA + nSrc, pNextSrcA,
                     pDstW, pDstW + nDst, pNextDstW);
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #define ASSERT2(a) if (!(a)) {fprintf(stderr, "StdString: Assertion Failed on line %d\n", __LINE__);}
 #else
 #define ASSERT2 ASSERT
@@ -911,7 +911,7 @@ inline const Type& SSMAX(const Type& arg1, const Type& arg2)
       PCWSTR pNextSrcW    = pSrcW;
       SSCodeCvt::result res  = SSCodeCvt::ok;
       const SSCodeCvt& conv  = SS_USE_FACET(loc, SSCodeCvt);
-#if defined(TARGET_DARWIN) || defined(__FreeBSD__)
+#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
       SSCodeCvt::state_type st= { { 0 } };
 #else
       SSCodeCvt::state_type st= { 0 };
@@ -919,7 +919,7 @@ inline const Type& SSMAX(const Type& arg1, const Type& arg2)
       res            = conv.out(st,
                     pSrcW, pSrcW + nSrc, pNextSrcW,
                     pDstA, pDstA + nDst, pNextDstA);
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #define ASSERT2(a) if (!(a)) {fprintf(stderr, "StdString: Assertion Failed on line %d\n", __LINE__);}
 #else
 #define ASSERT2 ASSERT
index 4d0be38..8f39b7e 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "threads/SystemClock.h"
 #include "Stopwatch.h"
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN) && !defined(TARGET_FREEBSD)
 #include <sys/sysinfo.h>
 #endif
 #include "utils/TimeUtils.h"
@@ -39,7 +39,7 @@ CStopWatch::CStopWatch(bool useFrameTime /*=false*/)
   else
   {
   // Get the timer frequency (ticks per second)
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   m_timerPeriod = 1.0f / (float)CurrentHostFrequency();
 #else
   m_timerPeriod = 1.0f / 1000.0f; // we want seconds
@@ -99,7 +99,7 @@ int64_t CStopWatch::GetTicks() const
 {
   if (m_useFrameTime)
     return CTimeUtils::GetFrameTime();
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   return CurrentHostCounter();
 #else
   return XbmcThreads::SystemClockMillis();
index e6b967e..9c1fcd3 100644 (file)
@@ -23,7 +23,7 @@
 #include "threads/SystemClock.h"
 #include "system.h"
 #include "SystemInfo.h"
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #include <conio.h>
 #else
 #include <sys/utsname.h>
@@ -37,7 +37,7 @@
 #include "CPUInfo.h"
 #include "utils/TimeUtils.h"
 #include "utils/log.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "dwmapi.h"
 #endif
 #if defined(TARGET_DARWIN)
@@ -115,7 +115,7 @@ CStdString CSysInfoJob::GetBatteryLevel()
 
 double CSysInfoJob::GetCPUFrequency()
 {
-#if defined (_LINUX) || defined(_WIN32)
+#if defined (TARGET_POSIX) || defined(TARGET_WINDOWS)
   return double (g_cpuInfo.getCPUFrequency());
 #else
   return 0;
@@ -260,7 +260,7 @@ bool CSysInfo::GetDiskSpace(const CStdString drive,int& iTotal, int& iTotalFree,
 
   if( !drive.IsEmpty() && !drive.Equals("*") )
   {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
     UINT uidriveType = GetDriveType(( drive + ":\\" ));
     if(uidriveType != DRIVE_UNKNOWN && uidriveType != DRIVE_NO_ROOT_DIR)
 #endif
@@ -270,7 +270,7 @@ bool CSysInfo::GetDiskSpace(const CStdString drive,int& iTotal, int& iTotalFree,
   {
     ULARGE_INTEGER ULTotalTmp= { { 0 } };
     ULARGE_INTEGER ULTotalFreeTmp= { { 0 } };
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
     char* pcBuffer= NULL;
     DWORD dwStrLength= GetLogicalDriveStrings( 0, pcBuffer );
     if( dwStrLength != 0 )
@@ -355,7 +355,7 @@ CStdString CSysInfo::GetCPUSerial()
 
 bool CSysInfo::IsAeroDisabled()
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if (IsWindowsVersionAtLeast(CSysInfo::WindowsVersionVista))
   {
     BOOL aeroEnabled = FALSE;
@@ -439,7 +439,7 @@ bool CSysInfo::IsOS64bit()
 
 CStdString CSysInfo::GetKernelVersion()
 {
-#if defined (_LINUX)
+#if defined (TARGET_POSIX)
   struct utsname un;
   if (uname(&un)==0)
   {
@@ -595,7 +595,7 @@ CStdString CSysInfo::GetHddSpaceInfo(int& percent, int drive, bool shortText)
   return strRet;
 }
 
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if defined(TARGET_LINUX)
 CStdString CSysInfo::GetLinuxDistro()
 {
 #if defined(TARGET_ANDROID)
@@ -646,7 +646,7 @@ CStdString CSysInfo::GetLinuxDistro()
 }
 #endif
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 CStdString CSysInfo::GetUnameVersion()
 {
   CStdString result = "";
@@ -726,7 +726,7 @@ CStdString CSysInfo::GetUserAgent()
 {
   CStdString result;
   result = "XBMC/" + g_infoManager.GetLabel(SYSTEM_BUILD_VERSION) + " (";
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
   result += GetUAWindowsVersion();
 #elif defined(TARGET_DARWIN)
 #if defined(TARGET_DARWIN_IOS)
@@ -735,10 +735,10 @@ CStdString CSysInfo::GetUserAgent()
   result += "Mac OS X; ";
 #endif
   result += GetUnameVersion();
-#elif defined(__FreeBSD__)
+#elif defined(TARGET_FREEBSD)
   result += "FreeBSD; ";
   result += GetUnameVersion();
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
   result += "Linux; ";
   result += GetLinuxDistro();
   result += "; ";
index 93e6eef..f40e622 100644 (file)
@@ -103,10 +103,10 @@ public:
   bool GetHDDInfo(CStdString& strHDDModel, CStdString& strHDDSerial,CStdString& strHDDFirmware,CStdString& strHDDpw,CStdString& strHDDLockState);
   bool GetRefurbInfo(CStdString& rfi_FirstBootTime, CStdString& rfi_PowerCycleCount);
 
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if defined(TARGET_LINUX)
   CStdString GetLinuxDistro();
 #endif
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   CStdString GetUnameVersion();
 #endif
 #if defined(TARGET_WINDOWS)
index a19b5a9..a51933c 100644 (file)
@@ -61,6 +61,51 @@ CStdString URIUtils::GetExtension(const CStdString& strFileName)
   return strFileName.substr(period);
 }
 
+bool URIUtils::HasExtension(const CStdString& strFileName)
+{
+  if (IsURL(strFileName))
+  {
+    CURL url(strFileName);
+    return HasExtension(url.GetFileName());
+  }
+
+  size_t iPeriod = strFileName.find_last_of("./\\");
+  return iPeriod != string::npos && strFileName[iPeriod] == '.';
+}
+
+bool URIUtils::HasExtension(const CStdString& strFileName, const CStdString& strExtensions)
+{
+  if (IsURL(strFileName))
+  {
+    CURL url(strFileName);
+    return HasExtension(url.GetFileName(), strExtensions);
+  }
+
+  // Search backwards so that '.' can be used as a search terminator.
+  CStdString::const_reverse_iterator itExtensions = strExtensions.rbegin();
+  while (itExtensions != strExtensions.rend())
+  {
+    // Iterate backwards over strFileName untill we hit a '.' or a mismatch
+    for (CStdString::const_reverse_iterator itFileName = strFileName.rbegin();
+         itFileName != strFileName.rend(), itExtensions != strExtensions.rend(),
+         tolower(*itFileName) == *itExtensions;
+         ++itFileName, ++itExtensions)
+    {
+      if (*itExtensions == '.')
+        return true; // Match
+    }
+
+    // No match. Look for more extensions to try.
+    while (itExtensions != strExtensions.rend() && *itExtensions != '|')
+      ++itExtensions;
+
+    while (itExtensions != strExtensions.rend() && *itExtensions == '|')
+      ++itExtensions;
+  }
+
+  return false;
+}
+
 void URIUtils::RemoveExtension(CStdString& strFileName)
 {
   if(IsURL(strFileName))
@@ -326,7 +371,7 @@ bool URIUtils::GetParentPath(const CStdString& strPath, CStdString& strParent)
   }
 
   int iPos = strFile.ReverseFind('/');
-#ifndef _LINUX
+#ifndef TARGET_POSIX
   if (iPos < 0)
   {
     iPos = strFile.ReverseFind('\\');
@@ -398,7 +443,7 @@ bool URIUtils::IsRemote(const CStdString& strFile)
 
 bool URIUtils::IsOnDVD(const CStdString& strFile)
 {
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
   if (strFile.Mid(1,1) == ":")
     return (GetDriveType(strFile.Left(2)) == DRIVE_CDROM);
 #endif
@@ -506,7 +551,7 @@ bool URIUtils::IsDVD(const CStdString& strFile)
   if (strFileLow.Find("video_ts.ifo") != -1 && IsOnDVD(strFile))
     return true;
 
-#if defined(_WIN32)
+#if defined(TARGET_WINDOWS)
   if (strFile.Left(6).Equals("dvd://"))
     return true;
 
@@ -573,31 +618,17 @@ bool URIUtils::IsInRAR(const CStdString& strFile)
 
 bool URIUtils::IsAPK(const CStdString& strFile)
 {
-  return GetExtension(strFile).CompareNoCase(".apk") == 0;
+  return HasExtension(strFile, ".apk");
 }
 
 bool URIUtils::IsZIP(const CStdString& strFile) // also checks for comic books!
 {
-  CStdString strExtension = GetExtension(strFile);
-
-  if (strExtension.CompareNoCase(".zip") == 0)
-    return true;
-
-  if (strExtension.CompareNoCase(".cbz") == 0)
-    return true;
-
-  return false;
+  return HasExtension(strFile, ".zip|.cbz");
 }
 
 bool URIUtils::IsArchive(const CStdString& strFile)
 {
-  CStdString extension = GetExtension(strFile);
-
-  return (extension.CompareNoCase(".zip") == 0 ||
-          extension.CompareNoCase(".rar") == 0 ||
-          extension.CompareNoCase(".apk") == 0 ||
-          extension.CompareNoCase(".cbz") == 0 ||
-          extension.CompareNoCase(".cbr") == 0);
+  return HasExtension(strFile, ".zip|.rar|.apk|.cbz|.cbr");
 }
 
 bool URIUtils::IsSpecial(const CStdString& strFile)
index b7742e3..dd72605 100644 (file)
@@ -36,6 +36,28 @@ public:
   static const CStdString GetFileName(const CStdString& strFileNameAndPath);
 
   static CStdString GetExtension(const CStdString& strFileName);
+
+  /*!
+   \brief Check if there is a file extension
+   \param strFileName Path or URL to check
+   \return \e true if strFileName have an extension.
+   \note Returns false when strFileName is empty.
+   \sa GetExtension
+   */
+  static bool HasExtension(const CStdString& strFileName);
+
+  /*!
+   \brief Check if filename have any of the listed extensions
+   \param strFileName Path or URL to check
+   \param strExtensions List of '.' prefixed lowercase extensions seperated with '|'
+   \return \e true if strFileName have any one of the extensions.
+   \note The check is case insensitive for strFileName, but requires
+         strExtensions to be lowercase. Returns false when strFileName or
+         strExtensions is empty.
+   \sa GetExtension
+   */
+  static bool HasExtension(const CStdString& strFileName, const CStdString& strExtensions);
+
   static void RemoveExtension(CStdString& strFileName);
   static CStdString ReplaceExtension(const CStdString& strFile,
                                      const CStdString& strNewExtension);
index f6f0701..f139f3f 100644 (file)
@@ -18,7 +18,7 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 #include "Weather.h"
index cf8c18a..a296185 100644 (file)
@@ -19,7 +19,7 @@
  *
  */
 
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
   #include "config.h"
 #endif
 #ifdef TARGET_WINDOWS
index 465c6b6..7662c89 100644 (file)
@@ -21,7 +21,7 @@
 #include "XMLUtils.h"
 #include "URL.h"
 #include "StringUtils.h"
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include "PlatformDefs.h" //for strcasecmp
 #endif
 
index 92c581d..d15c892 100644 (file)
@@ -21,7 +21,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
-#if !defined(_WIN32) && !defined(__ppc__) && !defined(__powerpc__) && !defined(__arm__) 
+#if !defined(TARGET_WINDOWS) && !defined(__ppc__) && !defined(__powerpc__) && !defined(__arm__) 
 #define HAVE_MMX2
 #define HAVE_SSE
 
index f40ab20..f88a576 100644 (file)
@@ -23,7 +23,7 @@
 extern "C" {
 #endif
 
-#if !defined(_WIN32) && !defined(__ppc__) && !defined(__powerpc__) && !defined(TARGET_ANDROID) && !defined(TARGET_DARWIN_IOS)
+#if !defined(TARGET_WINDOWS) && !defined(__ppc__) && !defined(__powerpc__) && !defined(TARGET_ANDROID) && !defined(TARGET_DARWIN_IOS)
 void * fast_memcpy(void * to, const void * from, size_t len);
 //#define fast_memcpy memcpy
 #else
index e863856..e6b9bc1 100644 (file)
@@ -99,7 +99,7 @@ CStdString XBMC::XBMC_MD5::GetMD5(const CStdString &text)
 
 #include <sys/types.h>         /* for stupid systems */
 #include <string.h>            /* for memcpy() */
-#if defined(HAVE_CONFIG_H) && !defined(_WIN32)
+#if defined(HAVE_CONFIG_H) && !defined(TARGET_WINDOWS)
 #include "../config.h"
 #endif
 
index e44d979..2c38acd 100644 (file)
@@ -10,8 +10,6 @@ SRCS= \
        TestCrc32.cpp \
        TestCryptThreading.cpp \
        TestDatabaseUtils.cpp \
-       TestDownloadQueue.cpp \
-       TestDownloadQueueManager.cpp \
        TestEndianSwap.cpp \
        Testfastmemcpy.cpp \
        Testfft.cpp \
diff --git a/xbmc/utils/test/TestDownloadQueue.cpp b/xbmc/utils/test/TestDownloadQueue.cpp
deleted file mode 100644 (file)
index 220448f..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- *      Copyright (C) 2005-2013 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, see
- *  <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "utils/DownloadQueue.h"
-#include "threads/Thread.h"
-#include "settings/Settings.h"
-#include "test/TestUtils.h"
-
-#include "gtest/gtest.h"
-
-class CTestDownloadQueueThread : public CThread
-{
-public:
-  CTestDownloadQueueThread() :
-    CThread("TestDownloadQueue"){}
-};
-
-/* Need to set some settings for network connectivity when an
- * http/https url is tested.
- */
-class TestDownloadQueue : public testing::Test
-{
-protected:
-  TestDownloadQueue()
-  {
-    CSettingsCategory* net = CSettings::Get().AddCategory(4, "network", 798);
-    CSettings::Get().AddBool(net, "network.usehttpproxy", 708, false);
-    CSettings::Get().AddString(net, "network.httpproxyserver", 706, "",
-                            EDIT_CONTROL_INPUT);
-    CSettings::Get().AddString(net, "network.httpproxyport", 730, "8080",
-                            EDIT_CONTROL_NUMBER_INPUT, false, 707);
-    CSettings::Get().AddString(net, "network.httpproxyusername", 1048, "",
-                            EDIT_CONTROL_INPUT);
-    CSettings::Get().AddString(net, "network.httpproxypassword", 733, "",
-                            EDIT_CONTROL_HIDDEN_INPUT,true,733);
-    CSettings::Get().AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024,
-                         SPIN_CONTROL_INT_PLUS, 14048, 351);
-  }
-
-  ~TestDownloadQueue()
-  {
-    CSettings::Get().Clear();
-  }
-};
-
-TEST_F(TestDownloadQueue, RequestContent)
-{
-  IDownloadQueueObserver observer;
-  CDownloadQueue queue;
-  CTestDownloadQueueThread thread;
-  unsigned int count;
-
-  std::vector<CStdString> urls =
-    CXBMCTestUtils::Instance().getTestDownloadQueueUrls();
-
-  std::vector<CStdString>::iterator it;
-  count = 0;
-  for (it = urls.begin(); it < urls.end(); it++)
-  {
-    std::cout << "Testing URL: " << *it << std::endl;
-    TICKET t = queue.RequestContent(*it, &observer);
-    EXPECT_EQ(count, t.dwItemId);
-    count++;
-  }
-
-  thread.Sleep(1000);
-  queue.Flush();
-  EXPECT_EQ(0, queue.Size());
-}
-
-TEST_F(TestDownloadQueue, RequestFile)
-{
-  IDownloadQueueObserver observer;
-  CDownloadQueue queue;
-  CTestDownloadQueueThread thread;
-  unsigned int count;
-
-  std::vector<CStdString> urls =
-    CXBMCTestUtils::Instance().getTestDownloadQueueUrls();
-
-  std::vector<CStdString>::iterator it;
-  count = 0;
-  for (it = urls.begin(); it < urls.end(); it++)
-  {
-    std::cout << "Testing URL: " << *it << std::endl;
-    TICKET t = queue.RequestFile(*it, &observer);
-    EXPECT_EQ(count, t.dwItemId);
-    count++;
-  }
-
-  thread.Sleep(1000);
-  queue.Flush();
-  EXPECT_EQ(0, queue.Size());
-}
diff --git a/xbmc/utils/test/TestDownloadQueueManager.cpp b/xbmc/utils/test/TestDownloadQueueManager.cpp
deleted file mode 100644 (file)
index aa8c2e0..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- *      Copyright (C) 2005-2013 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, see
- *  <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "utils/DownloadQueueManager.h"
-#include "threads/Thread.h"
-#include "settings/Settings.h"
-#include "test/TestUtils.h"
-
-#include "gtest/gtest.h"
-
-class CTestDownloadQueueManagerThread : public CThread
-{
-public:
-  CTestDownloadQueueManagerThread() :
-    CThread("TestDownloadQueueManager"){}
-};
-
-/* Need to set some settings for network connectivity when an
- * http/https url is tested.
- */
-class TestDownloadQueueManager : public testing::Test
-{
-protected:
-  TestDownloadQueueManager()
-  {
-    /* TODO
-    CSettingsCategory* net = CSettings::Get().AddCategory(4, "network", 798);
-    CSettings::Get().AddBool(net, "network.usehttpproxy", 708, false);
-    CSettings::Get().AddString(net, "network.httpproxyserver", 706, "",
-                            EDIT_CONTROL_INPUT);
-    CSettings::Get().AddString(net, "network.httpproxyport", 730, "8080",
-                            EDIT_CONTROL_NUMBER_INPUT, false, 707);
-    CSettings::Get().AddString(net, "network.httpproxyusername", 1048, "",
-                            EDIT_CONTROL_INPUT);
-    CSettings::Get().AddString(net, "network.httpproxypassword", 733, "",
-                            EDIT_CONTROL_HIDDEN_INPUT,true,733);
-    CSettings::Get().AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024,
-                         SPIN_CONTROL_INT_PLUS, 14048, 351);
-    */
-  }
-
-  ~TestDownloadQueueManager()
-  {
-    CSettings::Get().Unload();
-  }
-};
-
-TEST_F(TestDownloadQueueManager, RequestContent)
-{
-  IDownloadQueueObserver observer;
-  CTestDownloadQueueManagerThread thread;
-  int count;
-
-  std::vector<CStdString> urls =
-    CXBMCTestUtils::Instance().getTestDownloadQueueUrls();
-
-  std::vector<CStdString>::iterator it;
-  count = 0;
-  for (it = urls.begin(); it < urls.end(); it++)
-  {
-    std::cout << "Testing URL: " << *it << std::endl;
-    TICKET t = g_DownloadManager.RequestContent(*it, &observer);
-    std::cout << "  Ticket Item ID: " << t.dwItemId << std::endl;
-    count++;
-  }
-
-  thread.Sleep(1000);
-}
-
-TEST_F(TestDownloadQueueManager, RequestFile)
-{
-  IDownloadQueueObserver observer;
-  CTestDownloadQueueManagerThread thread;
-  int count;
-
-  std::vector<CStdString> urls =
-    CXBMCTestUtils::Instance().getTestDownloadQueueUrls();
-
-  std::vector<CStdString>::iterator it;
-  count = 0;
-  for (it = urls.begin(); it < urls.end(); it++)
-  {
-    std::cout << "Testing URL: " << *it << std::endl;
-    TICKET t = g_DownloadManager.RequestFile(*it, &observer);
-    std::cout << "  Ticket Item ID: " << t.dwItemId << std::endl;
-    count++;
-  }
-
-  thread.Sleep(1000);
-}
index 9629c1d..b4b44c3 100644 (file)
 
 TEST(TestMime, GetMimeType_string)
 {
-  std::string refstr, varstr;
-
-  refstr = "video/x-msvideo";
-  varstr = CMime::GetMimeType("avi");
-  EXPECT_STREQ(refstr.c_str(), varstr.c_str());
+  EXPECT_STREQ("video/avi",       CMime::GetMimeType("avi").c_str());
+  EXPECT_STRNE("video/x-msvideo", CMime::GetMimeType("avi").c_str());
+  EXPECT_STRNE("video/avi",       CMime::GetMimeType("xvid").c_str());
 }
 
 TEST(TestMime, GetMimeType_CFileItem)
index c8a0c87..eda1ec3 100644 (file)
@@ -29,7 +29,7 @@ class TestSystemInfo : public testing::Test
 protected:
   TestSystemInfo()
   {
-    CSettingsCategory* net = CSettings::Get().AddCategory(4, "network", 798);
+/*    CSettingsCategory* net = CSettings::Get().AddCategory(4, "network", 798);
     CSettings::Get().AddBool(net, "network.usehttpproxy", 708, false);
     CSettings::Get().AddString(net, "network.httpproxyserver", 706, "",
                             EDIT_CONTROL_INPUT);
@@ -40,22 +40,22 @@ protected:
     CSettings::Get().AddString(net, "network.httpproxypassword", 733, "",
                             EDIT_CONTROL_HIDDEN_INPUT,true,733);
     CSettings::Get().AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024,
-                         SPIN_CONTROL_INT_PLUS, 14048, 351);
+                         SPIN_CONTROL_INT_PLUS, 14048, 351);*/
   }
   ~TestSystemInfo()
   {
-    CSettings::Get().Clear();
+//    CSettings::Get().Clear();
   }
 };
 
-#if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(__FreeBSD__)
+#if defined(TARGET_LINUX)
 TEST_F(TestSystemInfo, GetLinuxDistro)
 {
   std::cout << "GetLinuxDistro(): " << g_sysinfo.GetLinuxDistro() << std::endl;
 }
 #endif
 
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 TEST_F(TestSystemInfo, GetUnameVersion)
 {
   std::cout << "GetUnameVersion(): " << g_sysinfo.GetUnameVersion() << std::endl;
@@ -91,10 +91,11 @@ TEST_F(TestSystemInfo, IsAeroDisabled)
     testing::PrintToString(g_sysinfo.IsAeroDisabled()) << std::endl;
 }
 
-TEST_F(TestSystemInfo, IsVistaOrHigher)
+TEST_F(TestSystemInfo, IsWindowsVersionAtLeast_Vista)
 {
-  std::cout << "IsVistaOrHigher(): " <<
-    testing::PrintToString(g_sysinfo.IsVistaOrHigher()) << std::endl;
+  std::cout << "IsWindowsVersionAtLeast(WindowsVersionVista): " <<
+    testing::PrintToString(g_sysinfo.IsWindowsVersionAtLeast(
+                                  CSysInfo::WindowsVersionVista)) << std::endl;
 }
 
 TEST_F(TestSystemInfo, GetKernelVersion)
index 5c928ff..9e8d4d4 100644 (file)
@@ -55,6 +55,25 @@ TEST_F(TestURIUtils, GetExtension)
                URIUtils::GetExtension("/path/to/movie.avi").c_str());
 }
 
+TEST_F(TestURIUtils, HasExtension)
+{
+  EXPECT_TRUE (URIUtils::HasExtension("/path/to/movie.AvI"));
+  EXPECT_FALSE(URIUtils::HasExtension("/path/to/movie"));
+  EXPECT_FALSE(URIUtils::HasExtension("/path/.to/movie"));
+  EXPECT_FALSE(URIUtils::HasExtension(""));
+
+  EXPECT_TRUE (URIUtils::HasExtension("/path/to/movie.AvI", ".avi"));
+  EXPECT_FALSE(URIUtils::HasExtension("/path/to/movie.AvI", ".mkv"));
+  EXPECT_FALSE(URIUtils::HasExtension("/path/.avi/movie", ".avi"));
+  EXPECT_FALSE(URIUtils::HasExtension("", ".avi"));
+
+  EXPECT_TRUE (URIUtils::HasExtension("/path/movie.AvI", ".avi|.mkv|.mp4"));
+  EXPECT_TRUE (URIUtils::HasExtension("/path/movie.AvI", ".mkv|.avi|.mp4"));
+  EXPECT_FALSE(URIUtils::HasExtension("/path/movie.AvI", ".mpg|.mkv|.mp4"));
+  EXPECT_FALSE(URIUtils::HasExtension("/path.mkv/movie.AvI", ".mpg|.mkv|.mp4"));
+  EXPECT_FALSE(URIUtils::HasExtension("", ".avi|.mkv|.mp4"));
+}
+
 TEST_F(TestURIUtils, GetFileName)
 {
   EXPECT_STREQ("movie.avi",
index 7ee9181..509c751 100644 (file)
@@ -64,7 +64,7 @@ bool CPlayerController::OnAction(const CAction &action)
       if (CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn)
       {
         SPlayerSubtitleStreamInfo info;
-        g_application.m_pPlayer->GetSubtitleStreamInfo(g_application.m_pPlayer->GetSubtitle(), info);
+        g_application.m_pPlayer->GetSubtitleStreamInfo(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream, info);
         if (!g_LangCodeExpander.Lookup(lang, info.language))
           lang = g_localizeStrings.Get(13205); // Unknown
 
@@ -209,9 +209,15 @@ bool CPlayerController::OnAction(const CAction &action)
         CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream = 0;
       g_application.m_pPlayer->SetAudioStream(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream);    // Set the audio stream to the one selected
       CStdString aud;
+      CStdString lan;
       SPlayerAudioStreamInfo info;
       g_application.m_pPlayer->GetAudioStreamInfo(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioStream, info);
-      aud = info.name;
+      if (!g_LangCodeExpander.Lookup(lan, info.language))
+        lan = g_localizeStrings.Get(13205); // Unknown
+      if (info.name.empty())
+        aud = lan;
+      else
+        aud.Format("%s - %s", lan.c_str(), info.name.c_str());
       CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(460), aud, DisplTime, false, MsgTime);
       return true;
     }
index 2681ff5..ef0029c 100644 (file)
@@ -41,7 +41,7 @@ namespace dbiplus
 }
 
 #ifndef my_offsetof
-#ifndef _LINUX
+#ifndef TARGET_POSIX
 #define my_offsetof(TYPE, MEMBER) offsetof(TYPE, MEMBER)
 #else
 /*
index c42dff3..3c56881 100644 (file)
@@ -548,7 +548,7 @@ namespace VIDEO
   INFO_RET CVideoInfoScanner::RetrieveInfoForMovie(CFileItem *pItem, bool bDirNames, ScraperPtr &info2, bool useLocal, CScraperUrl* pURL, CGUIDialogProgress* pDlgProgress)
   {
     if (pItem->m_bIsFolder || !pItem->IsVideo() || pItem->IsNFO() ||
-       (pItem->IsPlayList() && !URIUtils::GetExtension(pItem->GetPath()).Equals(".strm")))
+       (pItem->IsPlayList() && !URIUtils::HasExtension(pItem->GetPath(), ".strm")))
       return INFO_NOT_NEEDED;
 
     if (ProgressCancelled(pDlgProgress, 198, pItem->GetLabel()))
@@ -597,7 +597,7 @@ namespace VIDEO
   INFO_RET CVideoInfoScanner::RetrieveInfoForMusicVideo(CFileItem *pItem, bool bDirNames, ScraperPtr &info2, bool useLocal, CScraperUrl* pURL, CGUIDialogProgress* pDlgProgress)
   {
     if (pItem->m_bIsFolder || !pItem->IsVideo() || pItem->IsNFO() ||
-       (pItem->IsPlayList() && !URIUtils::GetExtension(pItem->GetPath()).Equals(".strm")))
+       (pItem->IsPlayList() && !URIUtils::HasExtension(pItem->GetPath(), ".strm")))
       return INFO_NOT_NEEDED;
 
     if (ProgressCancelled(pDlgProgress, 20394, pItem->GetLabel()))
@@ -1493,9 +1493,6 @@ namespace VIDEO
     // Find a matching .nfo file
     if (!item->m_bIsFolder)
     {
-      // file
-      CStdString strExtension = URIUtils::GetExtension(item->GetPath());
-
       if (URIUtils::IsInRAR(item->GetPath())) // we have a rarred item - we want to check outside the rars
       {
         CFileItem item2(*item);
@@ -1537,7 +1534,7 @@ namespace VIDEO
       else
       {
         // already an .nfo file?
-        if ( strcmpi(strExtension.c_str(), ".nfo") == 0 )
+        if (URIUtils::HasExtension(item->GetPath(), ".nfo"))
           nfoFile = item->GetPath();
         // no, create .nfo file
         else
index cc20523..ca239cf 100644 (file)
@@ -36,7 +36,7 @@
   #include "osx/CocoaInterface.h"
 #elif defined(TARGET_DARWIN_IOS)
   #include "windowing/WindowingFactory.h"
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
   #pragma comment (lib,"d3d9.lib")
   #if (D3DX_SDK_VERSION >= 42) //aug 2009 sdk and up there is no dxerr9 anymore
     #include <Dxerr.h>
@@ -53,7 +53,7 @@
 
 using namespace std;
 
-#if defined(_WIN32) && defined(HAS_DX)
+#if defined(TARGET_WINDOWS) && defined(HAS_DX)
 
   void CD3DCallback::Reset()
   {
@@ -146,7 +146,7 @@ void CVideoReferenceClock::Process()
   bool SetupSuccess = false;
   int64_t Now;
 
-#if defined(_WIN32) && defined(HAS_DX)
+#if defined(TARGET_WINDOWS) && defined(HAS_DX)
   //register callback
   m_D3dCallback.Reset();
   g_Windowing.Register(&m_D3dCallback);
@@ -157,13 +157,13 @@ void CVideoReferenceClock::Process()
     //set up the vblank clock
 #if defined(HAS_GLX) && defined(HAS_XRANDR)
     SetupSuccess = SetupGLX();
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
     SetupSuccess = SetupD3D();
 #elif defined(TARGET_DARWIN)
     SetupSuccess = SetupCocoa();
 #elif defined(HAS_GLX)
     CLog::Log(LOGDEBUG, "CVideoReferenceClock: compiled without RandR support");
-#elif defined(_WIN32)
+#elif defined(TARGET_WINDOWS)
     CLog::Log(LOGDEBUG, "CVideoReferenceClock: only available on directx build");
 #else
     CLog::Log(LOGDEBUG, "CVideoReferenceClock: no implementation available");
@@ -189,7 +189,7 @@ void CVideoReferenceClock::Process()
       //run the clock
 #if defined(HAS_GLX) && defined(HAS_XRANDR)
       RunGLX();
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
       RunD3D();
 #elif defined(TARGET_DARWIN)
       RunCocoa();
@@ -211,7 +211,7 @@ void CVideoReferenceClock::Process()
     //clean up the vblank clock
 #if defined(HAS_GLX) && defined(HAS_XRANDR)
     CleanupGLX();
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
     CleanupD3D();
 #elif defined(TARGET_DARWIN)
     CleanupCocoa();
@@ -219,7 +219,7 @@ void CVideoReferenceClock::Process()
     if (!SetupSuccess) break;
   }
 
-#if defined(_WIN32) && defined(HAS_DX)
+#if defined(TARGET_WINDOWS) && defined(HAS_DX)
   g_Windowing.Unregister(&m_D3dCallback);
 #endif
 }
@@ -693,7 +693,7 @@ void CVideoReferenceClock::RunGLX()
   }
 }
 
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
 
 void CVideoReferenceClock::RunD3D()
 {
@@ -1228,7 +1228,7 @@ bool CVideoReferenceClock::UpdateRefreshrate(bool Forced /*= false*/)
 
   return true;
 
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
 
   D3DDISPLAYMODE DisplayMode;
   m_D3dDev->GetDisplayMode(0, &DisplayMode);
index ace9bf5..1791570 100644 (file)
@@ -30,7 +30,7 @@
   #include <X11/X.h>
   #include <X11/Xlib.h>
   #include <GL/glx.h>
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
   #include <d3d9.h>
   #include "guilib/D3DResource.h"
 
@@ -126,7 +126,7 @@ class CVideoReferenceClock : public CThread
     bool         m_UseNvSettings;
     bool         m_bIsATI;
 
-#elif defined(_WIN32) && defined(HAS_DX)
+#elif defined(TARGET_WINDOWS) && defined(HAS_DX)
     bool   SetupD3D();
     double MeasureRefreshrate(int MSecs);
     void   RunD3D();
index 70865c3..244a067 100644 (file)
@@ -200,7 +200,7 @@ void CGUIDialogAudioSubtitleSettings::AddSubtitleStreams(unsigned int id)
   setting.type = SettingInfo::SPIN;
   setting.min = 0;
   setting.data = &m_subtitleStream;
-  m_subtitleStream = g_application.m_pPlayer->GetSubtitle();
+  m_subtitleStream = CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream;
 
   if(m_subtitleStream < 0) m_subtitleStream = 0;
 
@@ -339,7 +339,7 @@ void CGUIDialogAudioSubtitleSettings::OnSettingChanged(SettingInfo &setting)
     }
     if (CGUIDialogFileBrowser::ShowAndGetFile(shares,strMask,g_localizeStrings.Get(293),strPath,false,true)) // "subtitles"
     {
-      if (URIUtils::GetExtension(strPath) == ".sub")
+      if (URIUtils::HasExtension(strPath, ".sub"))
         if (CFile::Exists(URIUtils::ReplaceExtension(strPath, ".idx")))
           strPath = URIUtils::ReplaceExtension(strPath, ".idx");
       
index a1a0bc3..b881699 100644 (file)
@@ -286,7 +286,7 @@ void CGUIWindowVideoBase::OnInfo(CFileItem* pItem, const ADDON::ScraperPtr& scra
     return;
 
   if (pItem->IsParentFolder() || pItem->m_bIsShareOrDrive || pItem->GetPath().Equals("add") ||
-     (pItem->IsPlayList() && !URIUtils::GetExtension(pItem->GetPath()).Equals(".strm")))
+     (pItem->IsPlayList() && !URIUtils::HasExtension(pItem->GetPath(), ".strm")))
     return;
 
   // ShowIMDB can kill the item as this window can be closed while we do it,
@@ -993,7 +993,7 @@ bool CGUIWindowVideoBase::OnInfo(int iItem)
   CFileItemPtr item = m_vecItems->Get(iItem);
 
   if (item->GetPath().Equals("add") || item->IsParentFolder() ||
-     (item->IsPlayList() && !URIUtils::GetExtension(item->GetPath()).Equals(".strm")))
+     (item->IsPlayList() && !URIUtils::HasExtension(item->GetPath(), ".strm")))
     return false;
 
   if (!m_vecItems->IsPlugin() && (item->IsPlugin() || item->IsScript()))
@@ -1094,9 +1094,7 @@ bool CGUIWindowVideoBase::ShowPlaySelection(CFileItemPtr& item)
     }
   }
 
-  CStdString ext = URIUtils::GetExtension(item->GetPath());
-  ext.ToLower();
-  if (ext == ".iso" ||  ext == ".img")
+  if (URIUtils::HasExtension(item->GetPath(), ".iso|.img"))
   {
     CURL url2("udf://");
     url2.SetHostName(item->GetPath());
@@ -1554,7 +1552,7 @@ bool CGUIWindowVideoBase::OnPlayMedia(int iItem)
           vector<int> stack;
           for (int i = 0; i < items.Size(); ++i)
           {
-            if (URIUtils::GetExtension(items[i]->GetPath()) == ext)
+            if (URIUtils::HasExtension(items[i]->GetPath(), ext))
               stack.push_back(i);
           }
 
index 3c8a343..0816207 100644 (file)
@@ -29,9 +29,9 @@
 #include "guilib/GUIWindowManager.h"
 #include "guilib/GUIKeyboardFactory.h"
 #include "GUIUserMessages.h"
-#include "Favourites.h"
-#include "settings/MediaSettings.h"
+#include "filesystem/FavouritesDirectory.h"
 #include "settings/Settings.h"
+#include "settings/MediaSettings.h"
 #include "guilib/Key.h"
 #include "guilib/LocalizeStrings.h"
 #include "utils/log.h"
@@ -415,7 +415,7 @@ void CGUIWindowVideoPlaylist::GetContextButtons(int itemNumber, CContextButtons
       if (vecCores.size() > 1)
         buttons.Add(CONTEXT_BUTTON_PLAY_WITH, 15213); // Play With...
 
-      if (CFavourites::IsFavourite(item.get(), GetID()))
+      if (XFILE::CFavouritesDirectory::IsFavourite(item.get(), GetID()))
         buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14077);     // Remove Favourite
       else
         buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14076);     // Add To Favourites;
@@ -491,7 +491,7 @@ bool CGUIWindowVideoPlaylist::OnContextButton(int itemNumber, CONTEXT_BUTTON but
   case CONTEXT_BUTTON_ADD_FAVOURITE:
     {
       CFileItemPtr item = m_vecItems->Get(itemNumber);
-      CFavourites::AddOrRemove(item.get(), GetID());
+      XFILE::CFavouritesDirectory::AddOrRemove(item.get(), GetID());
       return true;
     }
   case CONTEXT_BUTTON_CANCEL_PARTYMODE:
index 0781ec6..cfc87f6 100644 (file)
@@ -25,6 +25,7 @@
 #include "guilib/LocalizeStrings.h"
 #include "GUIInfoManager.h"
 #include "guilib/WindowIDs.h"
+#include "guilib/IGUIContainer.h"
 
 CGUIViewControl::CGUIViewControl(void)
 {
index d2a3c1b..a17445f 100644 (file)
  *
  */
 
-#include "view/GUIViewState.h"
+#include <vector>
+#include "utils/StdString.h"
+#include "guilib/GraphicContext.h" // for VIEW_TYPE
 
-#include "guilib/GUIBaseContainer.h"
+class CGUIControl;
+class CFileItemList;
 
 class CGUIViewControl
 {
index 2c7cb3b..997598b 100644 (file)
@@ -24,7 +24,7 @@
 #include "utils/LegacyPathTranslation.h"
 #include "utils/log.h"
 #include "utils/StringUtils.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "linux/ConvUtils.h" // GetLastError()
 #endif
 #include "dbwrappers/dataset.h"
index b81bfbc..bf9e5f4 100644 (file)
     <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">.vis</TargetExt>
     <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">$(DXSDK_DIR)Include;$(IncludePath)</IncludePath>
     <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">$(DXSDK_DIR)Lib\x86;$(LibraryPath)</LibraryPath>
-    <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">false</PostBuildEventUseInBuild>
+    <PostBuildEventUseInBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">true</PostBuildEventUseInBuild>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;DIRECTX_SPEKTRUM_EXPORTS;_WIN32PC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;DIRECTX_SPEKTRUM_EXPORTS;_WIN32PC;TARGET_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -90,7 +90,7 @@
       <Optimization>Full</Optimization>
       <AdditionalIncludeDirectories>
       </AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;DIRECTX_SPEKTRUM_EXPORTS;_WIN32PC;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;DIRECTX_SPEKTRUM_EXPORTS;_WIN32PC;_USRDLL;TARGET_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <WarningLevel>Level3</WarningLevel>
index 01b0064..f1286cf 100644 (file)
 *
 */
 
-#if defined(__APPLE__)                                                                                                                                                                                           
+#if defined(TARGET_DARWIN)                                                                                                                                                                                           
   #include <OpenGLES/ES2/gl.h>                                                                                                                                                                                     
   #include <OpenGLES/ES2/glext.h>                                                                                                                                                                                  
 #else                                                                                                                                                                                                            
   #include <GLES2/gl2.h>
   #include <GLES2/gl2ext.h>
-#endif//__APPLE__
+#endif
 
 #include <string.h>
 #include <vector>
index 5dd15fc..3bad2fb 100644 (file)
  *
  */
 
-#if defined(__APPLE__)                                                                                                                                                                                           
+#if defined(TARGET_DARWIN)                                                                                                                                                                                           
 #include <OpenGLES/ES2/gl.h>                                                                                                                                                                                     
 #include <OpenGLES/ES2/glext.h>                                                                                                                                                                                  
 #else                                                                                                                                                                                                            
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
-#endif//__APPLE__
+#endif
 
 #include <vector>
 #include <string>
index 574f6f9..ce962e5 100644 (file)
@@ -61,7 +61,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_EXPORTS;HAS_DX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>TARGET_WINDOWS;WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_EXPORTS;HAS_DX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <ExceptionHandling>Sync</ExceptionHandling>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -90,7 +90,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_EXPORTS;HAS_DX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>TARGET_WINDOWS;WIN32;NDEBUG;_WINDOWS;_USRDLL;PLUGIN_EXPORTS;HAS_DX;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
       <WarningLevel>Level3</WarningLevel>
index 8810f6a..ae7f0f2 100644 (file)
@@ -25,9 +25,7 @@
 //
 //////////////////////////////////////////////////////////////////////
 
-#if _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
 
 //#include <xtl.h>
 #include <windows.h>
index 8d28076..65fec94 100644 (file)
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WAVEFORM_EXPORTS;_WIN32PC;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WAVEFORM_EXPORTS;_WIN32PC;_CRT_NONSTDC_NO_DEPRECATE;TARGET_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">
     <ClCompile>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;WAVEFORM_EXPORTS;_WIN32PC;_CRT_NONSTDC_NO_DEPRECATE%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;WAVEFORM_EXPORTS;_WIN32PC;_CRT_NONSTDC_NO_DEPRECATE;TARGET_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <PrecompiledHeader>
       </PrecompiledHeader>
index cddf2a3..ea10f0d 100644 (file)
@@ -21,7 +21,7 @@
  *
  */
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 
 #define LINE_ENDING "\r\n"
 
@@ -82,9 +82,8 @@ typedef long          __off_t;
 extern "C" char * strptime(const char *buf, const char *fmt, struct tm *tm);
 extern "C" int strverscmp (const char *s1, const char *s2);
 extern "C" char * strcasestr(const char* haystack, const char* needle);
-extern int pgwin32_putenv(const char *envval);
 
-#endif // _WIN32
+#endif // TARGET_WINDOWS
 
 #endif //__PLATFORM_DEFS_H__
 
index 0e97225..be0eec0 100644 (file)
@@ -21,7 +21,7 @@
  *
  */
 
-#if !defined(_DEBUG) && _MSC_VER >= 1500 && !defined(_LIB)
+#if !defined(_DEBUG) && defined(TARGET_WINDOWS) && !defined(_LIB)
 #include "git_rev.h" //generated file
 #endif
 #include <errno.h> // for ENOENT and EINVAL
index b4c9def..9651288 100644 (file)
@@ -28,9 +28,7 @@
 #include <shlobj.h>
 #include "filesystem/SpecialProtocol.h"
 #include "my_ntddscsi.h"
-#if _MSC_VER > 1400
 #include "Setupapi.h"
-#endif
 #include "storage/MediaManager.h"
 #include "windowing/WindowingFactory.h"
 #include "guilib/LocalizeStrings.h"
@@ -42,6 +40,7 @@
 #include "utils/URIUtils.h"
 #include "powermanagement\PowerManager.h"
 #include "utils/SystemInfo.h"
+#include "utils/Environment.h"
 
 // default Broadcom registy bits (setup when installing a CrystalHD card)
 #define BC_REG_PATH       "Software\\Broadcom\\MediaPC"
@@ -244,8 +243,6 @@ char CWIN32Util::FirstDriveFromMask (ULONG unitmask)
 
 bool CWIN32Util::PowerManagement(PowerState State)
 {
-// SetSuspendState not available in vs2003
-#if _MSC_VER > 1400
   HANDLE hToken;
   TOKEN_PRIVILEGES tkp;
   // Get a token for this process.
@@ -295,9 +292,6 @@ bool CWIN32Util::PowerManagement(PowerState State)
     return false;
     break;
   }
-#else
-  return false;
-#endif
 }
 
 int CWIN32Util::BatteryLevel()
@@ -500,23 +494,20 @@ CStdString CWIN32Util::SmbToUnc(const CStdString &strPath)
 
 void CWIN32Util::ExtendDllPath()
 {
-  CStdStringW strEnvW;
+  CStdString strEnv;
   CStdStringArray vecEnv;
-  WCHAR wctemp[32768];
-  if(GetEnvironmentVariableW(L"PATH",wctemp,32767) != 0)
-    strEnvW = wctemp;
+  strEnv = CEnvironment::getenv("PATH");
+  if (strEnv.IsEmpty())
+    CLog::Log(LOGWARNING, "Can get system env PATH or PATH is empty");
 
   StringUtils::SplitString(DLL_ENV_PATH, ";", vecEnv);
   for (int i=0; i<(int)vecEnv.size(); ++i)
-  {
-    CStdStringW strFileW;
-    g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(vecEnv[i]), strFileW, false);
-    strEnvW.append(L";" + strFileW);
-  }
-  if(SetEnvironmentVariableW(L"PATH",strEnvW.c_str())!=0)
-    CLog::Log(LOGDEBUG,"Setting system env PATH to %S",strEnvW.c_str());
+    strEnv.append(";" + CSpecialProtocol::TranslatePath(vecEnv[i]));
+
+  if (CEnvironment::setenv("PATH", strEnv) == 0)
+    CLog::Log(LOGDEBUG,"Setting system env PATH to %S",strEnv.c_str());
   else
-    CLog::Log(LOGDEBUG,"Can't set system env PATH to %S",strEnvW.c_str());
+    CLog::Log(LOGDEBUG,"Can't set system env PATH to %S",strEnv.c_str());
 
 }
 
@@ -604,7 +595,6 @@ HRESULT CWIN32Util::CloseTray(const char cDriveLetter)
 // http://www.codeproject.com/KB/system/RemoveDriveByLetter.aspx
 // http://www.techtalkz.com/microsoft-device-drivers/250734-remove-usb-device-c-3.html
 
-#if _MSC_VER > 1400
 DEVINST CWIN32Util::GetDrivesDevInstByDiskNumber(long DiskNumber)
 {
 
@@ -680,11 +670,9 @@ DEVINST CWIN32Util::GetDrivesDevInstByDiskNumber(long DiskNumber)
   SetupDiDestroyDeviceInfoList(hDevInfo);
   return 0;
 }
-#endif
 
 bool CWIN32Util::EjectDrive(const char cDriveLetter)
 {
-#if _MSC_VER > 1400
   if( !cDriveLetter )
     return false;
 
@@ -729,9 +717,6 @@ bool CWIN32Util::EjectDrive(const char cDriveLetter)
   }
 
   return bSuccess;
-#else
-  return false;
-#endif
 }
 
 #ifdef HAS_GL
@@ -992,7 +977,7 @@ extern "C" {
    * POSSIBILITY OF SUCH DAMAGE.
    */
 
-  #if !defined(_WIN32)
+  #if !defined(TARGET_WINDOWS)
   #include <sys/cdefs.h>
   #endif
 
@@ -1000,7 +985,7 @@ extern "C" {
   __RCSID("$NetBSD: strptime.c,v 1.25 2005/11/29 03:12:00 christos Exp $");
   #endif
 
-  #if !defined(_WIN32)
+  #if !defined(TARGET_WINDOWS)
   #include "namespace.h"
   #include <sys/localedef.h>
   #else
@@ -1011,7 +996,7 @@ extern "C" {
   #include <locale.h>
   #include <string.h>
   #include <time.h>
-  #if !defined(_WIN32)
+  #if !defined(TARGET_WINDOWS)
   #include <tzfile.h>
   #endif
 
@@ -1019,7 +1004,7 @@ extern "C" {
   __weak_alias(strptime,_strptime)
   #endif
 
-  #if !defined(_WIN32)
+  #if !defined(TARGET_WINDOWS)
   #define  _ctloc(x)    (_CurrentTimeLocale->x)
   #else
   #define _ctloc(x)   (x)
index 307e0d0..f48acb4 100644 (file)
@@ -21,9 +21,7 @@
  */
 
 #include "URL.h"
-#if _MSC_VER > 1400
 #include "Cfgmgr32.h"
-#endif
 #include "MediaSource.h"
 #include "guilib/Geometry.h"
 #include "powermanagement/PowerManager.h"
@@ -89,9 +87,7 @@ public:
   static bool IsUsbDevice(const CStdStringW &strWdrive);
 
 private:
-#if _MSC_VER > 1400
   static DEVINST GetDrivesDevInstByDiskNumber(long DiskNumber);
-#endif
 };
 
 
diff --git a/xbmc/win32/win32env.cpp b/xbmc/win32/win32env.cpp
deleted file mode 100644 (file)
index d1d2960..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * win32env.c
- *       putenv() and unsetenv() for win32, that updates both process
- *       environment and the cached versions in (potentially multiple)
- *       MSVCRT.
- *
- * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- *       src/port/win32env.c
- *
- *-------------------------------------------------------------------------
- */
-
-//#include "windows.h"
-
-int
-pgwin32_wputenv(const wchar_t *envval)
-{
-       wchar_t    *envcpy;
-       wchar_t    *cp;
-
-       /*
-        * Each version of MSVCRT has its own _putenv() call in the runtime
-        * library.
-        *
-        * mingw always uses MSVCRT.DLL, but if we are in a Visual C++
-        * environment, attempt to update the environment in all MSVCRT modules
-        * that are currently loaded, to work properly with any third party
-        * libraries linked against a different MSVCRT but still relying on
-        * environment variables.
-        *
-        * Also separately update the system environment that gets inherited by
-        * subprocesses.
-        */
-#ifdef _MSC_VER
-       typedef int (_cdecl * PUTENVPROC) (const wchar_t *name);
-       static struct
-       {
-               char       *modulename;
-               HMODULE         hmodule;
-               PUTENVPROC      putenvFunc;
-       }                       rtmodules[] =
-       {
-               {
-                       "msvcrt", 0, NULL
-               },                                              /* Visual Studio 6.0 / mingw */
-               {
-                       "msvcr70", 0, NULL
-               },                                              /* Visual Studio 2002 */
-               {
-                       "msvcr71", 0, NULL
-               },                                              /* Visual Studio 2003 */
-               {
-                       "msvcr80", 0, NULL
-               },                                              /* Visual Studio 2005 */
-               {
-                       "msvcr90", 0, NULL
-               },                                              /* Visual Studio 2008 */
-               {
-                       "msvcr100", 0, NULL
-               },                                              /* Visual Studio 2010 */
-               {
-                       NULL, 0, NULL
-               }
-       };
-       int                     i;
-
-       for (i = 0; rtmodules[i].modulename; i++)
-       {
-               if (rtmodules[i].putenvFunc == NULL)
-               {
-                       if (rtmodules[i].hmodule == 0)
-                       {
-                               /* Not attempted before, so try to find this DLL */
-                               rtmodules[i].hmodule = GetModuleHandle(rtmodules[i].modulename);
-                               if (rtmodules[i].hmodule == NULL)
-                               {
-                                       /*
-                                        * Set to INVALID_HANDLE_VALUE so we know we have tried
-                                        * this one before, and won't try again.
-                                        */
-                                       rtmodules[i].hmodule = ((HMODULE)(LONG_PTR)-1);
-                                       continue;
-                               }
-                               else
-                               {
-                                       rtmodules[i].putenvFunc = (PUTENVPROC) GetProcAddress(rtmodules[i].hmodule, "_wputenv");
-                                       if (rtmodules[i].putenvFunc == NULL)
-                                       {
-                                               CloseHandle(rtmodules[i].hmodule);
-                                               rtmodules[i].hmodule = ((HMODULE)(LONG_PTR)-1);
-                                               continue;
-                                       }
-                               }
-                       }
-                       else
-                       {
-                               /*
-                                * Module loaded, but we did not find the function last time.
-                                * We're not going to find it this time either...
-                                */
-                               continue;
-                       }
-               }
-               /* At this point, putenvFunc is set or we have exited the loop */
-               rtmodules[i].putenvFunc(envval);
-       }
-#endif   /* _MSC_VER */
-
-       /*
-        * Update the process environment - to make modifications visible to child
-        * processes.
-        *
-        * Need a copy of the string so we can modify it.
-        */
-       envcpy = wcsdup(envval);
-       if (!envcpy)
-               return -1;
-       cp = wcschr(envcpy, '=');
-       if (cp == NULL)
-       {
-               free(envcpy);
-               return -1;
-       }
-       *cp = '\0';
-       cp++;
-       if (wcslen(cp))
-       {
-               /*
-                * Only call SetEnvironmentVariable() when we are adding a variable,
-                * not when removing it. Calling it on both crashes on at least
-                * certain versions of MingW.
-                */
-               if (!SetEnvironmentVariableW(envcpy, cp))
-               {
-                       free(envcpy);
-                       return -1;
-               }
-       }
-       free(envcpy);
-
-       /* Finally, update our "own" cache */
-       return _wputenv(envval);
-}
-
-/*takes utf8 encoding*/
-int pgwin32_putenv(const char *envval)
-{
-  int size_needed = MultiByteToWideChar(CP_UTF8, 0, envval, strlen(envval), NULL, 0);
-  std::wstring strTo(size_needed, 0);
-  MultiByteToWideChar(CP_UTF8, 0, envval, strlen(envval), &strTo[0], size_needed);
-  return pgwin32_wputenv(strTo.c_str());
-}
-
-void
-pgwin32_unsetenv(const wchar_t *name)
-{
-       wchar_t    *envbuf;
-
-       envbuf = (wchar_t *) malloc(wcslen(name) + 2);
-       if (!envbuf)
-               return;
-
-       wsprintfW(envbuf, L"%s=", name);
-       pgwin32_wputenv(envbuf);
-       free(envbuf);
-}
index c266c1e..b6c1c5b 100644 (file)
@@ -25,6 +25,7 @@
 #include "WinEventsSDL.h"
 #include "Application.h"
 #include "ApplicationMessenger.h"
+#include "GUIUserMessages.h"
 #include "guilib/GUIWindowManager.h"
 #include "guilib/Key.h"
 #ifdef HAS_SDL_JOYSTICK
 #endif
 #include "input/MouseStat.h"
 #include "WindowingFactory.h"
-#if defined(__APPLE__)
+#if defined(TARGET_DARWIN)
 #include "osx/CocoaInterface.h"
 #endif
 
-#if defined(_LINUX) && !defined(__APPLE__) && !defined(__ANDROID__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN) && !defined(TARGET_ANDROID)
 #include <X11/Xlib.h>
 #include <X11/XKBlib.h>
 #include "input/XBMC_keysym.h"
 #include "utils/log.h"
 #endif
 
-#if defined(_LINUX) && !defined(__APPLE__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
 // The following chunk of code is Linux specific. For keys that have
 // with keysym.sym set to zero it checks the scan code, and sets the sym
 // for some known scan codes. This is mostly the multimedia keys.
@@ -253,7 +254,7 @@ bool CWinEventsSDL::MessagePump()
       case SDL_KEYDOWN:
       {
         // process any platform specific shortcuts before handing off to XBMC
-#ifdef __APPLE__
+#ifdef TARGET_DARWIN_OSX
         if (ProcessOSXShortcuts(event))
         {
           ret = true;
@@ -277,7 +278,7 @@ bool CWinEventsSDL::MessagePump()
           mod |= XBMCKMOD_LSUPER;
         newEvent.key.keysym.mod = (XBMCMod) mod;
 
-#if defined(_LINUX) && !defined(__APPLE__)
+#if defined(TARGET_POSIX) && !defined(TARGET_DARWIN)
         // If the keysym.sym is zero try to get it from the scan code
         if (newEvent.key.keysym.sym == 0)
           newEvent.key.keysym.sym = (XBMCKey) SymFromScancode(newEvent.key.keysym.scancode);
@@ -340,7 +341,7 @@ bool CWinEventsSDL::MessagePump()
         if (0 == (SDL_GetAppState() & SDL_APPMOUSEFOCUS))
         {
           g_Mouse.SetActive(false);
-#if defined(__APPLE__)
+#if defined(TARGET_DARWIN_OSX)
           // See CApplication::ProcessSlow() for a description as to why we call Cocoa_HideMouse.
           // this is here to restore the pointer when toggling back to window mode from fullscreen.
           Cocoa_ShowMouse();
@@ -388,7 +389,7 @@ bool CWinEventsSDL::MessagePump()
   return ret;
 }
 
-#ifdef __APPLE__
+#ifdef TARGET_DARWIN_OSX
 bool CWinEventsSDL::ProcessOSXShortcuts(SDL_Event& event)
 {
   static bool shift = false, cmd = false;
@@ -418,6 +419,19 @@ bool CWinEventsSDL::ProcessOSXShortcuts(SDL_Event& event)
       CApplicationMessenger::Get().Minimize();
       return true;
 
+    case SDLK_v: // CMD-v to paste clipboard text
+      if (g_Windowing.IsTextInputEnabled())
+      {
+        const char *szStr = Cocoa_Paste();
+        if (szStr)
+        {
+          CGUIMessage msg(GUI_MSG_INPUT_TEXT, 0, 0);
+          msg.SetLabel(szStr);
+          g_windowManager.SendMessage(msg, g_windowManager.GetFocusedWindow());
+        }
+      }
+      return true;
+
     default:
       return false;
     }
@@ -426,7 +440,7 @@ bool CWinEventsSDL::ProcessOSXShortcuts(SDL_Event& event)
   return false;
 }
 
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
 
 bool CWinEventsSDL::ProcessLinuxShortcuts(SDL_Event& event)
 {
index ed81bf5..bfdc47d 100644 (file)
@@ -33,9 +33,9 @@ public:
   static bool MessagePump();
 
 protected:
-#ifdef __APPLE__
+#ifdef TARGET_DARWIN
   static bool ProcessOSXShortcuts(SDL_Event& event);
-#elif defined(_LINUX)
+#elif defined(TARGET_POSIX)
   static bool ProcessLinuxShortcuts(SDL_Event& event);
 #endif
 };
index 9069436..30c1909 100644 (file)
@@ -29,7 +29,7 @@
 #include "utils/XBMCTinyXML.h"
 #include "../xbmc/utils/log.h"
 
-#if defined(__FreeBSD__)
+#if defined(TARGET_FREEBSD)
 #include <sys/types.h>
 #include <sys/wait.h>
 #endif
index b47cee2..40981b4 100644 (file)
@@ -18,7 +18,7 @@
  *
  */
 
-#if defined(__APPLE__) && !defined(__arm__)
+#if defined(TARGET_DARWIN_OSX)
 
 //hack around problem with xbmc's typedef int BOOL
 // and obj-c's typedef unsigned char BOOL
index e1d663a..b2c5b05 100644 (file)
@@ -50,7 +50,7 @@
 #include "network/Zeroconf.h"
 #include "network/ZeroconfBrowser.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 
 using namespace PERIPHERALS;
 
index 6b27a58..c0536ca 100644 (file)
@@ -27,7 +27,7 @@
 #include "settings/Settings.h"
 #include "utils/log.h"
 
-#ifdef _WIN32
+#ifdef TARGET_WINDOWS
 #include <tpcshrd.h>
 
 CWinSystemWin32::CWinSystemWin32()
index 2f06406..f3e20ec 100644 (file)
@@ -35,7 +35,7 @@
 #include "PartyModeManager.h"
 #include "dialogs/GUIDialogMediaSource.h"
 #include "GUIWindowFileManager.h"
-#include "Favourites.h"
+#include "filesystem/FavouritesDirectory.h"
 #include "utils/LabelFormatter.h"
 #include "dialogs/GUIDialogProgress.h"
 #include "profiles/ProfilesManager.h"
@@ -1577,7 +1577,7 @@ void CGUIMediaWindow::GetContextButtons(int itemNumber, CContextButtons &buttons
   if (!item->IsParentFolder() && !item->GetPath().Equals("add") && !item->GetPath().Equals("newplaylist://") &&
       !item->GetPath().Left(19).Equals("newsmartplaylist://") && !item->GetPath().Left(9).Equals("newtag://"))
   {
-    if (CFavourites::IsFavourite(item.get(), GetID()))
+    if (XFILE::CFavouritesDirectory::IsFavourite(item.get(), GetID()))
       buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14077);     // Remove Favourite
     else
       buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14076);     // Add To Favourites;
@@ -1595,7 +1595,7 @@ bool CGUIMediaWindow::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
   case CONTEXT_BUTTON_ADD_FAVOURITE:
     {
       CFileItemPtr item = m_vecItems->Get(itemNumber);
-      CFavourites::AddOrRemove(item.get(), GetID());
+      XFILE::CFavouritesDirectory::AddOrRemove(item.get(), GetID());
       return true;
     }
   case CONTEXT_BUTTON_PLUGIN_SETTINGS:
index 35df23e..5f4f2b9 100644 (file)
@@ -24,6 +24,7 @@
 #include "filesystem/VirtualDirectory.h"
 #include "filesystem/DirectoryHistory.h"
 #include "view/GUIViewControl.h"
+#include "view/GUIViewState.h"
 #include "dialogs/GUIDialogContextMenu.h"
 #include "playlists/SmartPlayList.h"
 
index 566d847..752201a 100644 (file)
@@ -102,7 +102,7 @@ void CGUIWindowDebugInfo::Process(unsigned int currentTime, CDirtyRegionList &di
     GlobalMemoryStatusEx(&stat);
     CStdString profiling = CGUIControlProfiler::IsRunning() ? " (profiling)" : "";
     CStdString strCores = g_cpuInfo.GetCoresUsageString();
-#if !defined(_LINUX)
+#if !defined(TARGET_POSIX)
     info.Format("LOG: %sxbmc.log\nMEM: %"PRIu64"/%"PRIu64" KB - FPS: %2.1f fps\nCPU: %s%s", g_advancedSettings.m_logFolder.c_str(),
                 stat.ullAvailPhys/1024, stat.ullTotalPhys/1024, g_infoManager.GetFPS(), strCores.c_str(), profiling.c_str());
 #else
index ae3611f..0bae81d 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 #include "guilib/GUIDialog.h"
-#ifdef _LINUX
+#ifdef TARGET_POSIX
 #include "linux/LinuxResourceCounter.h"
 #endif
 
@@ -40,7 +40,7 @@ protected:
   virtual void UpdateVisibility();
 private:
   CGUITextLayout *m_layout;
-#ifdef _LINUX
+#ifdef TARGET_POSIX
   CLinuxResourceCounter m_resourceCounter;
 #endif
 };
index 462655a..b3ec41e 100644 (file)
@@ -44,7 +44,7 @@
 #include "guilib/GUIKeyboardFactory.h"
 #include "dialogs/GUIDialogProgress.h"
 #include "dialogs/GUIDialogExtendedProgressBar.h"
-#include "Favourites.h"
+#include "filesystem/FavouritesDirectory.h"
 #include "playlists/PlayList.h"
 #include "utils/AsyncFileCopy.h"
 #include "storage/MediaManager.h"
@@ -496,7 +496,7 @@ bool CGUIWindowFileManager::Update(int iList, const CStdString &strDirectory)
   {
     CFileItemPtr pItem = m_vecItems[iList]->Get(i);
     if (pItem->IsHD() &&
-        URIUtils::GetExtension(pItem->GetPath()).CompareNoCase(".tbn") == 0)
+        URIUtils::HasExtension(pItem->GetPath(), ".tbn"))
     {
       pItem->SetArt("thumb", pItem->GetPath());
     }
@@ -991,7 +991,7 @@ void CGUIWindowFileManager::OnPopupMenu(int list, int item, bool bContextDriven
   {
     choices.Add(1, 188); // SelectAll
     if (!pItem->IsParentFolder())
-      choices.Add(2, CFavourites::IsFavourite(pItem.get(), GetID()) ? 14077 : 14076); // Add/Remove Favourite
+      choices.Add(2,  XFILE::CFavouritesDirectory::IsFavourite(pItem.get(), GetID()) ? 14077 : 14076); // Add/Remove Favourite
     if (vecCores.size() > 1)
       choices.Add(3, 15213); // Play Using...
     if (CanRename(list) && !pItem->IsParentFolder())
@@ -1021,7 +1021,7 @@ void CGUIWindowFileManager::OnPopupMenu(int list, int item, bool bContextDriven
   }
   if (btnid == 2)
   {
-    CFavourites::AddOrRemove(pItem.get(), GetID());
+    XFILE::CFavouritesDirectory::AddOrRemove(pItem.get(), GetID());
     return;
   }
   if (btnid == 3)