2018-11-08 21:39:26 +08:00
|
|
|
// Copyright (c) 2016-2018 Easy2D - Nomango
|
|
|
|
|
//
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
|
//
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
|
//
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
#include "modules.h"
|
2018-11-15 17:59:18 +08:00
|
|
|
#include "logs.h"
|
2018-11-08 21:39:26 +08:00
|
|
|
|
|
|
|
|
namespace easy2d
|
|
|
|
|
{
|
|
|
|
|
namespace modules
|
|
|
|
|
{
|
2018-11-17 17:15:32 +08:00
|
|
|
Shlwapi::Shlwapi()
|
2018-11-08 21:39:26 +08:00
|
|
|
{
|
2018-11-17 17:15:32 +08:00
|
|
|
shlwapi = LoadLibraryW(L"shlwapi.dll");
|
|
|
|
|
if (shlwapi)
|
|
|
|
|
{
|
|
|
|
|
PathFileExistsW = (PFN_PathFileExistsW)
|
|
|
|
|
GetProcAddress(shlwapi, "PathFileExistsW");
|
2019-01-08 19:30:02 +08:00
|
|
|
|
|
|
|
|
SHCreateMemStream = (PFN_SHCreateMemStream)
|
|
|
|
|
GetProcAddress(shlwapi, "SHCreateMemStream");
|
2018-11-17 17:15:32 +08:00
|
|
|
}
|
|
|
|
|
else
|
2018-11-08 21:39:26 +08:00
|
|
|
{
|
2018-11-17 17:15:32 +08:00
|
|
|
E2D_LOG("load shlapi.dll failed");
|
2018-11-08 21:39:26 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-17 17:15:32 +08:00
|
|
|
DirectX::DirectX()
|
2018-11-08 21:39:26 +08:00
|
|
|
{
|
2018-11-17 17:15:32 +08:00
|
|
|
d2d = LoadLibraryW(L"d2d1.dll");
|
|
|
|
|
if (d2d)
|
|
|
|
|
{
|
|
|
|
|
D2D1CreateFactory = (PFN_D2D1CreateFactory)
|
|
|
|
|
GetProcAddress(d2d, "D2D1CreateFactory");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
E2D_LOG("load d2d.dll failed");
|
|
|
|
|
}
|
2018-11-12 20:46:54 +08:00
|
|
|
|
2018-11-17 17:15:32 +08:00
|
|
|
dwrite = LoadLibraryW(L"dwrite.dll");
|
|
|
|
|
if (dwrite)
|
|
|
|
|
{
|
|
|
|
|
DWriteCreateFactory = (PFN_DWriteCreateFactory)
|
|
|
|
|
GetProcAddress(dwrite, "DWriteCreateFactory");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
E2D_LOG("load dwrite.dll failed");
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-11-15 17:59:18 +08:00
|
|
|
|
2018-11-17 17:15:32 +08:00
|
|
|
XAudio2::XAudio2()
|
|
|
|
|
{
|
2018-11-08 21:39:26 +08:00
|
|
|
const auto xaudio2_dll_names =
|
|
|
|
|
{
|
|
|
|
|
L"xaudio2_9.dll",
|
|
|
|
|
L"xaudio2_8.dll",
|
|
|
|
|
L"xaudio2_7.dll"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (const auto& name : xaudio2_dll_names)
|
|
|
|
|
{
|
2018-11-17 17:15:32 +08:00
|
|
|
xaudio2 = LoadLibraryW(name);
|
|
|
|
|
if (xaudio2)
|
2018-11-08 21:39:26 +08:00
|
|
|
{
|
2018-11-17 17:15:32 +08:00
|
|
|
XAudio2Create = (PFN_XAudio2Create)
|
|
|
|
|
GetProcAddress(xaudio2, "XAudio2Create");
|
2018-11-08 21:39:26 +08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-17 17:15:32 +08:00
|
|
|
if (!xaudio2)
|
2018-11-08 21:39:26 +08:00
|
|
|
{
|
2018-11-17 17:15:32 +08:00
|
|
|
E2D_LOG("load xaudio2.dll failed");
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-11-08 21:39:26 +08:00
|
|
|
|
2018-11-17 17:15:32 +08:00
|
|
|
MediaFoundation::MediaFoundation()
|
|
|
|
|
{
|
|
|
|
|
mfplat = LoadLibraryW(L"Mfplat.dll");
|
|
|
|
|
if (mfplat)
|
|
|
|
|
{
|
|
|
|
|
MFStartup = (PFN_MFStartup)
|
|
|
|
|
GetProcAddress(mfplat, "MFStartup");
|
2018-11-08 21:39:26 +08:00
|
|
|
|
2018-11-17 17:15:32 +08:00
|
|
|
MFShutdown = (PFN_MFShutdown)
|
|
|
|
|
GetProcAddress(mfplat, "MFShutdown");
|
2018-11-08 21:39:26 +08:00
|
|
|
|
2018-11-17 17:15:32 +08:00
|
|
|
MFCreateMediaType = (PFN_MFCreateMediaType)
|
|
|
|
|
GetProcAddress(mfplat, "MFCreateMediaType");
|
2018-11-08 21:39:26 +08:00
|
|
|
|
2018-11-17 17:15:32 +08:00
|
|
|
MFCreateWaveFormatExFromMFMediaType = (PFN_MFCreateWaveFormatExFromMFMediaType)
|
|
|
|
|
GetProcAddress(mfplat, "MFCreateWaveFormatExFromMFMediaType");
|
2018-11-08 21:39:26 +08:00
|
|
|
|
2018-11-17 17:15:32 +08:00
|
|
|
MFCreateMFByteStreamOnStream = (PFN_MFCreateMFByteStreamOnStream)
|
|
|
|
|
GetProcAddress(mfplat, "MFCreateMFByteStreamOnStream");
|
|
|
|
|
}
|
|
|
|
|
else
|
2018-11-08 21:39:26 +08:00
|
|
|
{
|
2018-11-17 17:15:32 +08:00
|
|
|
E2D_LOG("load Mfplat.dll failed");
|
2018-11-08 21:39:26 +08:00
|
|
|
}
|
2018-11-12 20:46:54 +08:00
|
|
|
|
2018-11-17 17:15:32 +08:00
|
|
|
mfreadwrite = LoadLibraryW(L"Mfreadwrite.dll");
|
|
|
|
|
if (mfreadwrite)
|
|
|
|
|
{
|
|
|
|
|
MFCreateSourceReaderFromURL = (PFN_MFCreateSourceReaderFromURL)
|
|
|
|
|
GetProcAddress(mfreadwrite, "MFCreateSourceReaderFromURL");
|
2018-11-15 17:59:18 +08:00
|
|
|
|
2018-11-17 17:15:32 +08:00
|
|
|
MFCreateSourceReaderFromByteStream = (PFN_MFCreateSourceReaderFromByteStream)
|
|
|
|
|
GetProcAddress(mfreadwrite, "MFCreateSourceReaderFromByteStream");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
E2D_LOG("load Mfreadwrite.dll failed");
|
|
|
|
|
}
|
2018-11-08 21:39:26 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|