99 lines
3.3 KiB
C++
99 lines
3.3 KiB
C++
// Copyright (c) 2016-2018 Kiwano - 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 <kiwano/core/Logger.h>
|
|
#include <kiwano-audio/libraries.h>
|
|
|
|
namespace kiwano
|
|
{
|
|
namespace audio
|
|
{
|
|
namespace dlls
|
|
{
|
|
XAudio2::XAudio2()
|
|
: xaudio2()
|
|
, XAudio2Create(nullptr)
|
|
{
|
|
const auto xaudio2_dll_names =
|
|
{
|
|
L"xaudio2_9.dll", // for Windows 10
|
|
L"xaudio2_8.dll", // for Windows 8
|
|
L"xaudio2_7.dll" // for DirectX SDK
|
|
};
|
|
|
|
for (const auto& name : xaudio2_dll_names)
|
|
{
|
|
if (xaudio2.Load(name))
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (xaudio2.IsValid())
|
|
{
|
|
XAudio2Create = xaudio2.GetProcess<PFN_XAudio2Create>(L"XAudio2Create");
|
|
}
|
|
else
|
|
{
|
|
KGE_ERROR(L"Load xaudio2.dll failed");
|
|
throw std::runtime_error("Load xaudio2.dll failed");
|
|
}
|
|
}
|
|
|
|
MediaFoundation::MediaFoundation()
|
|
: mfplat()
|
|
, mfreadwrite()
|
|
, MFStartup(nullptr)
|
|
, MFShutdown(nullptr)
|
|
, MFCreateMediaType(nullptr)
|
|
, MFCreateWaveFormatExFromMFMediaType(nullptr)
|
|
, MFCreateSourceReaderFromURL(nullptr)
|
|
, MFCreateSourceReaderFromByteStream(nullptr)
|
|
, MFCreateMFByteStreamOnStream(nullptr)
|
|
{
|
|
if (mfplat.Load(L"Mfplat.dll"))
|
|
{
|
|
MFStartup = mfplat.GetProcess<PFN_MFStartup>(L"MFStartup");
|
|
MFShutdown = mfplat.GetProcess<PFN_MFShutdown>(L"MFShutdown");
|
|
MFCreateMediaType = mfplat.GetProcess<PFN_MFCreateMediaType>(L"MFCreateMediaType");
|
|
MFCreateWaveFormatExFromMFMediaType = mfplat.GetProcess<PFN_MFCreateWaveFormatExFromMFMediaType>(L"MFCreateWaveFormatExFromMFMediaType");
|
|
MFCreateMFByteStreamOnStream = mfplat.GetProcess<PFN_MFCreateMFByteStreamOnStream>(L"MFCreateMFByteStreamOnStream");
|
|
}
|
|
else
|
|
{
|
|
KGE_SYS_LOG(L"Load Mfplat.dll failed");
|
|
throw std::runtime_error("Load Mfplat.dll failed");
|
|
}
|
|
|
|
if (mfreadwrite.Load(L"Mfreadwrite.dll"))
|
|
{
|
|
MFCreateSourceReaderFromURL = mfreadwrite.GetProcess<PFN_MFCreateSourceReaderFromURL>(L"MFCreateSourceReaderFromURL");
|
|
MFCreateSourceReaderFromByteStream = mfreadwrite.GetProcess<PFN_MFCreateSourceReaderFromByteStream>(L"MFCreateSourceReaderFromByteStream");
|
|
}
|
|
else
|
|
{
|
|
KGE_SYS_LOG(L"Load Mfreadwrite.dll failed");
|
|
throw std::runtime_error("Load Mfreadwrite.dll failed");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|