Skip to content

Commit

Permalink
Merge pull request #318 from afedchin/videoplayer
Browse files Browse the repository at this point in the history
[VideoPlayer] win32 adjustments.
  • Loading branch information
FernetMenta committed Nov 20, 2015
2 parents 6099c4a + fad2c42 commit bb0ebe9
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 126 deletions.
1 change: 1 addition & 0 deletions project/VS2010Express/XBMC.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@
<ClInclude Include="..\..\xbmc\filesystem\XbtManager.h" />
<ClInclude Include="..\..\xbmc\guiinfo\GUIInfoLabels.h" />
<ClInclude Include="..\..\xbmc\guilib\cximage.h" />
<ClInclude Include="..\..\xbmc\guilib\DispResource.h" />
<ClInclude Include="..\..\xbmc\guilib\Gif.h" />
<ClInclude Include="..\..\xbmc\guilib\GUIKeyboard.h" />
<ClInclude Include="..\..\xbmc\guilib\GUIKeyboardFactory.h" />
Expand Down
4 changes: 4 additions & 0 deletions project/VS2010Express/XBMC.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -3224,6 +3224,7 @@
</ClCompile>
<ClCompile Include="..\..\xbmc\input\InputCodingTableKorean.cpp">
<Filter>input</Filter>
</ClCompile>
<ClCompile Include="..\..\xbmc\guilib\Resolution.cpp">
<Filter>guilib</Filter>
</ClCompile>
Expand Down Expand Up @@ -6267,6 +6268,9 @@
<ClInclude Include="..\..\xbmc\pvr\PVRSettings.h">
<Filter>pvr</Filter>
</ClInclude>
<ClInclude Include="..\..\xbmc\guilib\DispResource.h">
<Filter>guilib</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\xbmc\win32\XBMC_PC.rc">
Expand Down
9 changes: 3 additions & 6 deletions xbmc/cores/VideoPlayer/VideoRenderers/WinRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ bool CWinRenderer::Configure(unsigned int width, unsigned int height, unsigned i

// calculate the input frame aspect ratio
CalculateFrameAspectRatio(d_width, d_height);
ChooseBestResolution(fps);
m_destWidth = g_graphicsContext.GetResInfo(m_resolution).iWidth;
m_destHeight = g_graphicsContext.GetResInfo(m_resolution).iHeight;
RESOLUTION_INFO res = g_graphicsContext.GetResInfo(g_graphicsContext.GetVideoResolution());
m_destWidth = res.iWidth;
m_destHeight = res.iHeight;
SetViewMode(CMediaSettings::GetInstance().GetCurrentVideoSettings().m_ViewMode);
ManageDisplay();

Expand Down Expand Up @@ -402,9 +402,6 @@ void CWinRenderer::PreInit()
CSingleLock lock(g_graphicsContext);
m_bConfigured = false;
UnInit();
m_resolution = CDisplaySettings::GetInstance().GetCurrentResolution();
if ( m_resolution == RES_WINDOW )
m_resolution = RES_DESKTOP;

// setup the background colour
m_clearColour = g_Windowing.UseLimitedColor() ? (16 * 0x010101) : 0;
Expand Down
22 changes: 10 additions & 12 deletions xbmc/rendering/dx/RenderSystemDX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,11 @@ void CRenderSystemDX::SetFullScreenInternal()

// resize window (in windowed mode) or monitor resolution (in fullscreen mode) to required mode
hr = m_pSwapChain->ResizeTarget(&matchedMode);
m_bResizeRequred = S_OK == hr;
if (S_OK == hr && !m_bResizeRequred)
{
m_bResizeRequred = true;
ResolutionChanged();
}

if (FAILED(hr))
CLog::Log(LOGERROR, "%s - Failed to switch output mode: %s", __FUNCTION__, GetErrorDescription(hr).c_str());
Expand Down Expand Up @@ -828,6 +832,10 @@ bool CRenderSystemDX::CreateWindowSizeDependentResources()

Sleep(100);
}

// when transition from/to stereo mode trigger display reset event
if (bNeedRecreate)
ResolutionChanged();
}
else
{
Expand Down Expand Up @@ -1097,7 +1105,7 @@ bool CRenderSystemDX::PresentRenderImpl(const CDirtyRegionList &dirty)
{
HRESULT hr;

if (!m_bRenderCreated)
if (!m_bRenderCreated || m_resizeInProgress)
return false;

if (m_nDeviceStatus != S_OK)
Expand Down Expand Up @@ -1297,16 +1305,6 @@ bool CRenderSystemDX::IsExtSupported(const char* extension)
return false;
}

bool CRenderSystemDX::PresentRender(const CDirtyRegionList &dirty)
{
if (!m_bRenderCreated || m_resizeInProgress)
return false;

bool result = PresentRenderImpl(dirty);

return result;
}

void CRenderSystemDX::SetVSync(bool enable)
{
m_bVSync = enable;
Expand Down
43 changes: 5 additions & 38 deletions xbmc/rendering/dx/RenderSystemDX.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,41 +49,31 @@ class CRenderSystemDX : public CRenderSystemBase
virtual bool InitRenderSystem();
virtual bool DestroyRenderSystem();
virtual bool ResetRenderSystem(int width, int height, bool fullScreen, float refreshRate);

virtual bool BeginRender();
virtual bool EndRender();
virtual bool PresentRender(const CDirtyRegionList &dirty);
virtual bool ClearBuffers(color_t color);
virtual bool IsExtSupported(const char* extension);
virtual bool IsFormatSupport(DXGI_FORMAT format, unsigned int usage);

virtual void SetVSync(bool vsync);

virtual void SetViewPort(CRect& viewPort);
virtual void GetViewPort(CRect& viewPort);
virtual void RestoreViewPort();

virtual CRect ClipRectToScissorRect(const CRect &rect);
virtual bool ScissorsCanEffectClipping();
virtual void SetScissors(const CRect &rect);
virtual void ResetScissors();

virtual void CaptureStateBlock();
virtual void ApplyStateBlock();

virtual void SetCameraPosition(const CPoint &camera, int screenWidth, int screenHeight, float stereoFactor = 0.f);

virtual void ApplyHardwareTransform(const TransformMatrix &matrix);
virtual void RestoreHardwareTransform();
virtual void SetStereoMode(RENDER_STEREO_MODE mode, RENDER_STEREO_VIEW view);
virtual bool SupportsStereo(RENDER_STEREO_MODE mode) const;
virtual bool TestRender();

void GetDisplayMode(DXGI_MODE_DESC *mode, bool useCached = false);
IDXGIOutput* GetCurrentOutput(void) { return m_pOutput; }

virtual void Project(float &x, float &y, float &z);

IDXGIOutput* GetCurrentOutput(void) { return m_pOutput; }
void GetDisplayMode(DXGI_MODE_DESC *mode, bool useCached = false);
void FinishCommandList(bool bExecute = true);
void FlushGPU();

Expand All @@ -98,24 +88,6 @@ class CRenderSystemDX : public CRenderSystemBase
int GetBackbufferCount() const { return 2; }
void SetAlphaBlendEnable(bool enable);

/*!
\brief Register as a dependent of the DirectX Render System
Resources should call this on construction if they're dependent on the Render System
for survival. Any resources that registers will get callbacks on loss and reset of
device, where resources that are in the D3DPOOL_DEFAULT pool should be handled.
In addition, callbacks for destruction and creation of the device are also called,
where any resources dependent on the DirectX device should be destroyed and recreated.
\sa Unregister, ID3DResource
*/
void Register(ID3DResource *resource);

/*!
\brief Unregister as a dependent of the DirectX Render System
Resources should call this on destruction if they're a dependent on the Render System
\sa Register, ID3DResource
*/
void Unregister(ID3DResource *resource);

static std::string GetErrorDescription(HRESULT hr);

protected:
Expand All @@ -137,15 +109,17 @@ class CRenderSystemDX : public CRenderSystemBase
void SetFullScreenInternal();
void GetClosestDisplayModeToCurrent(IDXGIOutput* output, DXGI_MODE_DESC* outCurrentDisplayMode, bool useCached = false);
void CheckInterlasedStereoView(void);
void Register(ID3DResource *resource);
void Unregister(ID3DResource *resource);

virtual void ResolutionChanged() {};
virtual void UpdateMonitor() {};

// our adapter could change as we go
bool m_needNewDevice;
bool m_needNewViews;
bool m_resizeInProgress;
unsigned int m_screenHeight;

HWND m_hFocusWnd;
HWND m_hDeviceWnd;
unsigned int m_nBackBufferWidth;
Expand All @@ -157,12 +131,9 @@ class CRenderSystemDX : public CRenderSystemBase
int64_t m_systemFreq;
D3D11_USAGE m_defaultD3DUsage;
bool m_useWindowedDX;

CCriticalSection m_resourceSection;
std::vector<ID3DResource*> m_resources;

bool m_inScene; ///< True if we're in a BeginScene()/EndScene() block

D3D_DRIVER_TYPE m_driverType;
D3D_FEATURE_LEVEL m_featureLevel;
IDXGIFactory1* m_dxgiFactory;
Expand All @@ -172,15 +143,13 @@ class CRenderSystemDX : public CRenderSystemBase
IDXGIOutput* m_pOutput;
ID3D11DeviceContext* m_pContext;
ID3D11DeviceContext* m_pImdContext;

IDXGISwapChain* m_pSwapChain;
IDXGISwapChain1* m_pSwapChain1;
ID3D11RenderTargetView* m_pRenderTargetView;
ID3D11DepthStencilState* m_depthStencilState;
ID3D11DepthStencilView* m_depthStencilView;
D3D11_VIEWPORT m_viewPort;
CRect m_scissor;

CGUIShaderDX* m_pGUIShader;
ID3D11BlendState* m_BlendEnableState;
ID3D11BlendState* m_BlendDisableState;
Expand All @@ -189,14 +158,12 @@ class CRenderSystemDX : public CRenderSystemBase
ID3D11RasterizerState* m_RSScissorEnable;
bool m_ScissorsEnabled;
DXGI_ADAPTER_DESC m_adapterDesc;

// stereo interlaced/checkerboard intermediate target
ID3D11Texture2D* m_pTextureRight;
ID3D11RenderTargetView* m_pRenderTargetViewRight;
ID3D11ShaderResourceView* m_pShaderResourceViewRight;
bool m_bResizeRequred;
bool m_bHWStereoEnabled;

// improve get current mode
DXGI_MODE_DESC m_cachedMode;
#ifdef _DEBUG
Expand Down
19 changes: 15 additions & 4 deletions xbmc/win32/WIN32Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@

#include <cassert>

#define DLL_ENV_PATH "special://xbmc/system/;" \
// special://xbmc/system/players/dvdplayer/ is temporal solution needs to be deleted
// after dependencies will be changed to extract to a videoplayer folder
#define DLL_ENV_PATH "special://xbmc/;" \
"special://xbmc/system/;" \
"special://xbmc/system/players/VideoPlayer/;" \
"special://xbmc/system/players/dvdplayer/;" \
"special://xbmc/system/players/paplayer/;" \
"special://xbmc/system/cdrip/;" \
"special://xbmc/system/python/;" \
"special://xbmc/system/webserver/;" \
"special://xbmc/"
"special://xbmc/system/webserver/"

#include <locale.h>

Expand Down Expand Up @@ -571,7 +574,15 @@ void CWIN32Util::ExtendDllPath()

vecEnv = StringUtils::Split(DLL_ENV_PATH, ";");
for (int i=0; i<(int)vecEnv.size(); ++i)
strEnv.append(";" + CSpecialProtocol::TranslatePath(vecEnv[i]));
{
std::string strPath; std::wstring strPathW;

strPath = CSpecialProtocol::TranslatePath(vecEnv[i]);
g_charsetConverter.utf8ToW(strPath, strPathW);

strEnv.append(";" + strPath);
AddDllDirectory(strPathW.c_str());
}

if (CEnvironment::setenv("PATH", strEnv) == 0)
CLog::Log(LOGDEBUG,"Setting system env PATH to %s",strEnv.c_str());
Expand Down
85 changes: 20 additions & 65 deletions xbmc/win32/Win32DelayedDllLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,80 +19,35 @@
*/

#include <DelayImp.h>
#include "filesystem/SpecialProtocol.h"
#include "Application.h"
#include "utils/StringUtils.h"

static const std::string dlls[] = {
"ssh.dll",
"sqlite3.dll",
"dnssd.dll",
"libxslt.dll",
"avcodec-56.dll",
"avfilter-5.dll",
"avformat-56.dll",
"avutil-54.dll",
"postproc-53.dll",
"swresample-1.dll",
"swscale-3.dll"
};

FARPROC WINAPI delayHookNotifyFunc (unsigned dliNotify, PDelayLoadInfo pdli)
{
switch (dliNotify)
{
case dliNotePreLoadLibrary:
if (stricmp(pdli->szDll, "ssh.dll") == 0)
{
std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/ssh.dll");
HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
return (FARPROC)hMod;
}
if (stricmp(pdli->szDll, "sqlite3.dll") == 0)
{
std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/sqlite3.dll");
HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
return (FARPROC)hMod;
}
if (stricmp(pdli->szDll, "dnssd.dll") == 0)
{
std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/dnssd.dll");
HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
return (FARPROC)hMod;
}
if (stricmp(pdli->szDll, "libxslt.dll") == 0)
{
std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/libxslt.dll");
HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
return (FARPROC)hMod;
}
if (stricmp(pdli->szDll, "avcodec-56.dll") == 0)
{
std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/VideoPlayer/avcodec-56.dll");
HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
return (FARPROC)hMod;
}
if (stricmp(pdli->szDll, "avfilter-5.dll") == 0)
{
std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/VideoPlayer/avfilter-5.dll");
HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
return (FARPROC)hMod;
}
if (stricmp(pdli->szDll, "avformat-56.dll") == 0)
{
std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/VideoPlayer/avformat-56.dll");
HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
return (FARPROC)hMod;
}
if (stricmp(pdli->szDll, "avutil-54.dll") == 0)
{
std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/VideoPlayer/avutil-54.dll");
HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
return (FARPROC)hMod;
}
if (stricmp(pdli->szDll, "postproc-53.dll") == 0)
{
std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/VideoPlayer/postproc-53.dll");
HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
return (FARPROC)hMod;
}
if (stricmp(pdli->szDll, "swresample-1.dll") == 0)
{
std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/VideoPlayer/swresample-1.dll");
HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
return (FARPROC)hMod;
}
if (stricmp(pdli->szDll, "swscale-3.dll") == 0)
for (size_t i = 0; i < ARRAYSIZE(dlls); ++i)
{
std::string strDll = CSpecialProtocol::TranslatePath("special://xbmcbin/system/players/VideoPlayer/swscale-3.dll");
HMODULE hMod = LoadLibraryEx(strDll.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
return (FARPROC)hMod;
if (stricmp(pdli->szDll, dlls[i].c_str()) == 0)
{
HMODULE hMod = LoadLibraryEx(pdli->szDll, 0, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
return (FARPROC)hMod;
}
}
break;
}
Expand Down
Loading

0 comments on commit bb0ebe9

Please sign in to comment.