Update to VS2013 and a slew of build-related updates. Notes:

* Currently there is no DEBUGFAST configuration. Defining DEBUGFAST as a preprocessor definition in Base.props (or a global header) enables it for now, pending a better method. This was done to make managing the build harder to screw up. However it may not even be an issue anymore with the new .props usage.
* D3DX11SaveTextureToFile usage is dropped and not replaced.
* If you have $(DXSDK_DIR) in your global property sheets (Microsoft.Cpp.$(PlatformName).user), you need to remove it. The build will error out with a message if it's configured incorrectly.
* If you are on Windows 8 or above, you no longer need the June 2010 DirectX SDK installed to build dolphin. If you are in this situation, it is still required if you want your built binaries to be able to use XAudio2 and XInput on previous Windows versions.
* GLew updated to 1.10.0
* compiler switches added: /volatile:iso, /d2Zi+
* LTCG available via msbuild property: DolphinRelease
* SDL updated to 2.0.0
* All Externals (excl. OpenAL and SDL) are built from source.
* Now uses STL version of std::{mutex,condition_variable,thread}
* Now uses Build as root directory for *all* intermediate files
* Binary directory is populated as post-build msbuild action
* .gitignore is simplified
* UnitTests project is no longer compiled
This commit is contained in:
Shawn Hoffman
2013-10-19 02:27:57 -07:00
parent 1eba4da21a
commit ccd30024b3
390 changed files with 104570 additions and 35686 deletions

View File

@ -7,6 +7,7 @@
#include "Mixer.h"
#include "NullSoundStream.h"
#include "DSoundStream.h"
#include "XAudio2_7Stream.h"
#include "XAudio2Stream.h"
#include "AOSoundStream.h"
#include "AlsaSoundStream.h"
@ -18,34 +19,47 @@
#include "../../Core/Src/ConfigManager.h"
// This shouldn't be a global, at least not here.
SoundStream *soundStream;
SoundStream *soundStream = nullptr;
namespace AudioCommon
{
SoundStream *InitSoundStream(CMixer *mixer, void *hWnd)
SoundStream *InitSoundStream(CMixer *mixer)
{
// TODO: possible memleak with mixer
std::string backend = SConfig::GetInstance().sBackend;
if (backend == BACKEND_OPENAL && OpenALStream::isValid())
if (backend == BACKEND_OPENAL && OpenALStream::isValid())
soundStream = new OpenALStream(mixer);
else if (backend == BACKEND_NULLSOUND && NullSound::isValid())
soundStream = new NullSound(mixer, hWnd);
else if (backend == BACKEND_DIRECTSOUND && DSound::isValid())
soundStream = new DSound(mixer, hWnd);
else if (backend == BACKEND_XAUDIO2 && XAudio2::isValid())
soundStream = new XAudio2(mixer);
else if (backend == BACKEND_AOSOUND && AOSound::isValid())
else if (backend == BACKEND_NULLSOUND && NullSound::isValid())
soundStream = new NullSound(mixer);
else if (backend == BACKEND_DIRECTSOUND && DSound::isValid())
soundStream = new DSound(mixer);
else if (backend == BACKEND_XAUDIO2)
{
if (XAudio2::isValid())
soundStream = new XAudio2(mixer);
else if (XAudio2_7::isValid())
soundStream = new XAudio2_7(mixer);
}
else if (backend == BACKEND_AOSOUND && AOSound::isValid())
soundStream = new AOSound(mixer);
else if (backend == BACKEND_ALSA && AlsaSound::isValid())
soundStream = new AlsaSound(mixer);
else if (backend == BACKEND_COREAUDIO && CoreAudioSound::isValid())
else if (backend == BACKEND_COREAUDIO && CoreAudioSound::isValid())
soundStream = new CoreAudioSound(mixer);
else if (backend == BACKEND_PULSEAUDIO && PulseAudio::isValid())
soundStream = new PulseAudio(mixer);
else if (backend == BACKEND_OPENSLES && OpenSLESStream::isValid())
soundStream = new OpenSLESStream(mixer);
if (soundStream != NULL)
if (!soundStream && NullSound::isValid())
{
WARN_LOG(DSPHLE, "Could not initialize backend %s, using %s instead.",
backend.c_str(), BACKEND_NULLSOUND);
soundStream = new NullSound(mixer);
}
if (soundStream)
{
UpdateSoundStream();
if (soundStream->Start())
@ -61,11 +75,12 @@ namespace AudioCommon
}
PanicAlertT("Could not initialize backend %s.", backend.c_str());
}
PanicAlertT("Sound backend %s is not valid.", backend.c_str());
delete soundStream;
soundStream = NULL;
return NULL;
soundStream = nullptr;
return nullptr;
}
void ShutdownSoundStream()
@ -79,7 +94,7 @@ namespace AudioCommon
soundStream->GetMixer()->StopLogAudio();
//soundStream->StopLogAudio();
delete soundStream;
soundStream = NULL;
soundStream = nullptr;
}
INFO_LOG(DSPHLE, "Done shutting down sound stream");
@ -93,7 +108,7 @@ namespace AudioCommon
backends.push_back(BACKEND_NULLSOUND);
if (DSound::isValid())
backends.push_back(BACKEND_DIRECTSOUND);
if (XAudio2::isValid())
if (XAudio2_7::isValid() || XAudio2::isValid())
backends.push_back(BACKEND_XAUDIO2);
if (AOSound::isValid())
backends.push_back(BACKEND_AOSOUND);

View File

@ -40,7 +40,7 @@ union UDSPControl
namespace AudioCommon
{
SoundStream *InitSoundStream(CMixer *mixer, void *hWnd);
SoundStream *InitSoundStream(CMixer *mixer);
void ShutdownSoundStream();
std::vector<std::string> GetSoundBackends();
bool UseJIT();

View File

@ -6,7 +6,6 @@
#include <functional>
#include <windows.h>
#include <dxerr.h>
#include "AudioCommon.h"
#include "DSoundStream.h"
@ -43,7 +42,7 @@ bool DSound::CreateBuffer()
else
{
// Failed.
PanicAlertT("Sound buffer creation failed: %s", DXGetErrorString(res));
PanicAlertT("Sound buffer creation failed: %08x", res);
dsBuffer = NULL;
return false;
}

View File

@ -9,6 +9,7 @@
#include "Thread.h"
#ifdef _WIN32
#include <Windows.h>
#include <mmsystem.h>
#include <dsound.h>
@ -70,7 +71,7 @@ public:
#else
public:
DSound(CMixer *mixer, void *hWnd = NULL)
DSound(CMixer *mixer)
: SoundStream(mixer)
{}
#endif

View File

@ -16,7 +16,7 @@ class NullSound : public SoundStream
short realtimeBuffer[BUF_SIZE / sizeof(short)];
public:
NullSound(CMixer *mixer, void *hWnd = NULL)
NullSound(CMixer *mixer)
: SoundStream(mixer)
{}

View File

@ -48,9 +48,9 @@ public:
OpenALStream(CMixer *mixer, void *hWnd = NULL)
: SoundStream(mixer)
, uiSource(0)
{};
{}
virtual ~OpenALStream() {};
virtual ~OpenALStream() {}
virtual bool Start();
virtual void SoundLoop();
@ -74,7 +74,9 @@ private:
u8 numBuffers;
#else
public:
OpenALStream(CMixer *mixer, void *hWnd = NULL): SoundStream(mixer) {}
OpenALStream(CMixer *mixer)
: SoundStream(mixer)
{}
#endif // HAVE_OPENAL
};

View File

@ -22,8 +22,8 @@ protected:
bool m_muted;
public:
SoundStream(CMixer *mixer) : m_mixer(mixer), threadData(0), m_logAudio(false), m_muted(false) {}
virtual ~SoundStream() { delete m_mixer;}
SoundStream(CMixer *mixer) : m_mixer(mixer), threadData(0), m_logAudio(false), m_muted(false) {}
virtual ~SoundStream() { delete m_mixer; }
static bool isValid() { return false; }
virtual CMixer *GetMixer() const { return m_mixer; }

View File

@ -2,9 +2,42 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <xaudio2.h>
#include "AudioCommon.h"
#include "XAudio2Stream.h"
#ifndef XAUDIO2_DLL
#error You are building this module against the wrong version of DirectX. You probably need to remove DXSDK_DIR from your include path.
#endif
struct StreamingVoiceContext : public IXAudio2VoiceCallback
{
private:
CMixer* const m_mixer;
Common::Event& m_sound_sync_event;
IXAudio2SourceVoice* m_source_voice;
std::unique_ptr<BYTE[]> xaudio_buffer;
void SubmitBuffer(PBYTE buf_data);
public:
StreamingVoiceContext(IXAudio2 *pXAudio2, CMixer *pMixer, Common::Event& pSyncEvent);
~StreamingVoiceContext();
void StreamingVoiceContext::Stop();
void StreamingVoiceContext::Play();
STDMETHOD_(void, OnVoiceError) (THIS_ void* pBufferContext, HRESULT Error) {}
STDMETHOD_(void, OnVoiceProcessingPassStart) (UINT32) {}
STDMETHOD_(void, OnVoiceProcessingPassEnd) () {}
STDMETHOD_(void, OnBufferStart) (void*) {}
STDMETHOD_(void, OnLoopEnd) (void*) {}
STDMETHOD_(void, OnStreamEnd) () {}
STDMETHOD_(void, OnBufferEnd) (void* context);
};
const int NUM_BUFFERS = 3;
const int SAMPLES_PER_BUFFER = 96;
@ -90,13 +123,59 @@ void StreamingVoiceContext::OnBufferEnd(void* context)
SubmitBuffer(static_cast<BYTE*>(context));
}
HMODULE XAudio2::m_xaudio2_dll = nullptr;
typedef decltype(&XAudio2Create) XAudio2Create_t;
void *XAudio2::PXAudio2Create = nullptr;
bool XAudio2::InitLibrary()
{
if (m_xaudio2_dll)
{
return true;
}
m_xaudio2_dll = ::LoadLibrary(XAUDIO2_DLL);
if (!m_xaudio2_dll)
{
return false;
}
if (!PXAudio2Create)
{
PXAudio2Create = (XAudio2Create_t)::GetProcAddress(m_xaudio2_dll, "XAudio2Create");
if (!PXAudio2Create)
{
::FreeLibrary(m_xaudio2_dll);
m_xaudio2_dll = nullptr;
return false;
}
}
return true;
}
XAudio2::XAudio2(CMixer *mixer)
: SoundStream(mixer)
, m_mastering_voice(nullptr)
, m_volume(1.0f)
, m_cleanup_com(SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED)))
{
}
XAudio2::~XAudio2()
{
Stop();
if (m_cleanup_com)
CoUninitialize();
}
bool XAudio2::Start()
{
HRESULT hr;
// callback doesn't seem to run on a specific cpu anyways
IXAudio2* xaudptr;
if (FAILED(hr = XAudio2Create(&xaudptr, 0, XAUDIO2_DEFAULT_PROCESSOR)))
if (FAILED(hr = ((XAudio2Create_t)PXAudio2Create)(&xaudptr, 0, XAUDIO2_DEFAULT_PROCESSOR)))
{
PanicAlertT("XAudio2 init failed: %#X", hr);
Stop();
@ -172,4 +251,11 @@ void XAudio2::Stop()
}
m_xaudio2.reset(); // release interface
if (m_xaudio2_dll)
{
::FreeLibrary(m_xaudio2_dll);
m_xaudio2_dll = nullptr;
PXAudio2Create = nullptr;
}
}

View File

@ -2,43 +2,21 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#ifndef _XAUDIO2STREAM_H_
#define _XAUDIO2STREAM_H_
// This audio backend uses XAudio2 via XAUDIO2_DLL
// It works on Windows 8+, where it is included as an OS component.
// This backend is always compiled, but only available if running on Win8+
#pragma once
#include <memory>
#include "Thread.h"
#include "SoundStream.h"
#ifdef _WIN32
#include "Thread.h"
#include <xaudio2.h>
#include <memory>
struct StreamingVoiceContext : public IXAudio2VoiceCallback
{
private:
CMixer* const m_mixer;
Common::Event& m_sound_sync_event;
IXAudio2SourceVoice* m_source_voice;
std::unique_ptr<BYTE[]> xaudio_buffer;
void SubmitBuffer(PBYTE buf_data);
public:
StreamingVoiceContext(IXAudio2 *pXAudio2, CMixer *pMixer, Common::Event& pSyncEvent);
~StreamingVoiceContext();
void StreamingVoiceContext::Stop();
void StreamingVoiceContext::Play();
STDMETHOD_(void, OnVoiceError) (THIS_ void* pBufferContext, HRESULT Error) {}
STDMETHOD_(void, OnVoiceProcessingPassStart) (UINT32) {}
STDMETHOD_(void, OnVoiceProcessingPassEnd) () {}
STDMETHOD_(void, OnBufferStart) (void*) {}
STDMETHOD_(void, OnLoopEnd) (void*) {}
STDMETHOD_(void, OnStreamEnd) () {}
STDMETHOD_(void, OnBufferEnd) (void* context);
};
struct StreamingVoiceContext;
struct IXAudio2;
struct IXAudio2MasteringVoice;
#endif
@ -46,6 +24,7 @@ class XAudio2 : public SoundStream
{
#ifdef _WIN32
private:
class Releaser
{
public:
@ -56,7 +35,6 @@ class XAudio2 : public SoundStream
}
};
private:
std::unique_ptr<IXAudio2, Releaser> m_xaudio2;
std::unique_ptr<StreamingVoiceContext> m_voice_context;
IXAudio2MasteringVoice *m_mastering_voice;
@ -66,20 +44,14 @@ private:
const bool m_cleanup_com;
public:
XAudio2(CMixer *mixer)
: SoundStream(mixer)
, m_mastering_voice(nullptr)
, m_volume(1.0f)
, m_cleanup_com(SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED)))
{}
static HMODULE m_xaudio2_dll;
static void *PXAudio2Create;
virtual ~XAudio2()
{
Stop();
if (m_cleanup_com)
CoUninitialize();
}
static bool InitLibrary();
public:
XAudio2(CMixer *mixer);
virtual ~XAudio2();
virtual bool Start();
virtual void Stop();
@ -89,15 +61,14 @@ public:
virtual void SetVolume(int volume);
virtual bool usesMixer() const { return true; }
static bool isValid() { return true; }
static bool isValid() { return InitLibrary(); }
#else
public:
XAudio2(CMixer *mixer, void *hWnd = NULL)
XAudio2(CMixer *mixer)
: SoundStream(mixer)
{}
#endif
};
#endif //_XAUDIO2STREAM_H_

View File

@ -0,0 +1,289 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
// Note that this file *and this file only* must also have %DXSDK_DIR%/Include prepended
// to its include path in order fetch dxsdkver.h and XAudio2.h from the DXSDK
// instead of other possible places. This may be accomplished by adding the path to
// the AdditionalIncludeDirectories for this file via msbuild.
#include "AudioCommon.h"
#include "XAudio2_7Stream.h"
#ifdef HAVE_DXSDK
#include <dxsdkver.h>
#if (_DXSDK_PRODUCT_MAJOR == 9) && (_DXSDK_PRODUCT_MINOR == 29) && (_DXSDK_BUILD_MAJOR == 1962) && (_DXSDK_BUILD_MINOR == 0)
#define HAVE_DXSDK_JUNE_2010
#else
#pragma message("You have DirectX SDK installed, but it is not the expected version (June 2010). Update it to build this module.")
#endif
#endif
#ifdef HAVE_DXSDK_JUNE_2010
#include <XAudio2.h>
struct StreamingVoiceContext2_7 : public IXAudio2VoiceCallback
{
private:
CMixer* const m_mixer;
Common::Event& m_sound_sync_event;
IXAudio2SourceVoice* m_source_voice;
std::unique_ptr<BYTE[]> xaudio_buffer;
void SubmitBuffer(PBYTE buf_data);
public:
StreamingVoiceContext2_7(IXAudio2 *pXAudio2, CMixer *pMixer, Common::Event& pSyncEvent);
~StreamingVoiceContext2_7();
void StreamingVoiceContext2_7::Stop();
void StreamingVoiceContext2_7::Play();
STDMETHOD_(void, OnVoiceError) (THIS_ void* pBufferContext, HRESULT Error) {}
STDMETHOD_(void, OnVoiceProcessingPassStart) (UINT32) {}
STDMETHOD_(void, OnVoiceProcessingPassEnd) () {}
STDMETHOD_(void, OnBufferStart) (void*) {}
STDMETHOD_(void, OnLoopEnd) (void*) {}
STDMETHOD_(void, OnStreamEnd) () {}
STDMETHOD_(void, OnBufferEnd) (void* context);
};
const int NUM_BUFFERS = 3;
const int SAMPLES_PER_BUFFER = 96;
const int NUM_CHANNELS = 2;
const int BUFFER_SIZE = SAMPLES_PER_BUFFER * NUM_CHANNELS;
const int BUFFER_SIZE_BYTES = BUFFER_SIZE * sizeof(s16);
void StreamingVoiceContext2_7::SubmitBuffer(PBYTE buf_data)
{
XAUDIO2_BUFFER buf = {};
buf.AudioBytes = BUFFER_SIZE_BYTES;
buf.pContext = buf_data;
buf.pAudioData = buf_data;
m_source_voice->SubmitSourceBuffer(&buf);
}
StreamingVoiceContext2_7::StreamingVoiceContext2_7(IXAudio2 *pXAudio2, CMixer *pMixer, Common::Event& pSyncEvent)
: m_mixer(pMixer)
, m_sound_sync_event(pSyncEvent)
, xaudio_buffer(new BYTE[NUM_BUFFERS * BUFFER_SIZE_BYTES]())
{
WAVEFORMATEXTENSIBLE wfx = {};
wfx.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
wfx.Format.nSamplesPerSec = m_mixer->GetSampleRate();
wfx.Format.nChannels = 2;
wfx.Format.wBitsPerSample = 16;
wfx.Format.nBlockAlign = wfx.Format.nChannels*wfx.Format.wBitsPerSample / 8;
wfx.Format.nAvgBytesPerSec = wfx.Format.nSamplesPerSec * wfx.Format.nBlockAlign;
wfx.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
wfx.Samples.wValidBitsPerSample = 16;
wfx.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
wfx.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
// create source voice
HRESULT hr;
if (FAILED(hr = pXAudio2->CreateSourceVoice(&m_source_voice, &wfx.Format, XAUDIO2_VOICE_NOSRC, 1.0f, this)))
{
PanicAlertT("XAudio2_7 CreateSourceVoice failed: %#X", hr);
return;
}
m_source_voice->Start();
// start buffers with silence
for (int i = 0; i != NUM_BUFFERS; ++i)
SubmitBuffer(xaudio_buffer.get() + (i * BUFFER_SIZE_BYTES));
}
StreamingVoiceContext2_7::~StreamingVoiceContext2_7()
{
if (m_source_voice)
{
m_source_voice->Stop();
m_source_voice->DestroyVoice();
}
}
void StreamingVoiceContext2_7::Stop()
{
if (m_source_voice)
m_source_voice->Stop();
}
void StreamingVoiceContext2_7::Play()
{
if (m_source_voice)
m_source_voice->Start();
}
void StreamingVoiceContext2_7::OnBufferEnd(void* context)
{
// buffer end callback; gets SAMPLES_PER_BUFFER samples for a new buffer
if (!m_source_voice || !context)
return;
//m_sound_sync_event->Wait(); // sync
//m_sound_sync_event->Spin(); // or tight sync
m_mixer->Mix(static_cast<short*>(context), SAMPLES_PER_BUFFER);
SubmitBuffer(static_cast<BYTE*>(context));
}
HMODULE XAudio2_7::m_xaudio2_dll = nullptr;
void XAudio2_7::ReleaseIXAudio2(IXAudio2* ptr)
{
ptr->Release();
}
bool XAudio2_7::InitLibrary()
{
if (m_xaudio2_dll)
{
return true;
}
m_xaudio2_dll = ::LoadLibrary(TEXT("xaudio2_7.dll"));
return m_xaudio2_dll != nullptr;
}
XAudio2_7::XAudio2_7(CMixer *mixer)
: SoundStream(mixer)
, m_mastering_voice(nullptr)
, m_volume(1.0f)
, m_cleanup_com(SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED)))
{
}
XAudio2_7::~XAudio2_7()
{
Stop();
if (m_cleanup_com)
CoUninitialize();
}
bool XAudio2_7::Start()
{
HRESULT hr;
// callback doesn't seem to run on a specific cpu anyways
IXAudio2* xaudptr;
if (FAILED(hr = XAudio2Create(&xaudptr, 0, XAUDIO2_DEFAULT_PROCESSOR)))
{
PanicAlertT("XAudio2_7 init failed: %#X", hr);
Stop();
return false;
}
m_xaudio2 = std::unique_ptr<IXAudio2, Releaser>(xaudptr);
// XAudio2 master voice
// XAUDIO2_DEFAULT_CHANNELS instead of 2 for expansion?
if (FAILED(hr = m_xaudio2->CreateMasteringVoice(&m_mastering_voice, 2, m_mixer->GetSampleRate())))
{
PanicAlertT("XAudio2_7 master voice creation failed: %#X", hr);
Stop();
return false;
}
// Volume
m_mastering_voice->SetVolume(m_volume);
m_voice_context = std::unique_ptr<StreamingVoiceContext2_7>
(new StreamingVoiceContext2_7(m_xaudio2.get(), m_mixer, m_sound_sync_event));
return true;
}
void XAudio2_7::SetVolume(int volume)
{
//linear 1- .01
m_volume = (float)volume / 100.f;
if (m_mastering_voice)
m_mastering_voice->SetVolume(m_volume);
}
void XAudio2_7::Update()
{
//m_sound_sync_event.Set();
//static int xi = 0;
//if (100000 == ++xi)
//{
// xi = 0;
// XAUDIO2_PERFORMANCE_DATA perfData;
// pXAudio2->GetPerformanceData(&perfData);
// NOTICE_LOG(DSPHLE, "XAudio2_7 latency (samples): %i", perfData.CurrentLatencyInSamples);
// NOTICE_LOG(DSPHLE, "XAudio2_7 total glitches: %i", perfData.GlitchesSinceEngineStarted);
//}
}
void XAudio2_7::Clear(bool mute)
{
m_muted = mute;
if (m_voice_context)
{
if (m_muted)
m_voice_context->Stop();
else
m_voice_context->Play();
}
}
void XAudio2_7::Stop()
{
//m_sound_sync_event.Set();
m_voice_context.reset();
if (m_mastering_voice)
{
m_mastering_voice->DestroyVoice();
m_mastering_voice = nullptr;
}
m_xaudio2.reset(); // release interface
if (m_xaudio2_dll)
{
::FreeLibrary(m_xaudio2_dll);
m_xaudio2_dll = nullptr;
}
}
bool XAudio2_7::usesMixer() const { return true; }
#else
struct StreamingVoiceContext2_7 {};
struct IXAudio2 {};
struct IXAudio2MasteringVoice {};
void XAudio2_7::ReleaseIXAudio2(IXAudio2* ptr) {}
XAudio2_7::XAudio2_7(CMixer *mixer)
: SoundStream(mixer)
, m_mastering_voice(nullptr)
, m_volume(1.0f)
, m_cleanup_com(false)
{}
XAudio2_7::~XAudio2_7() {}
bool XAudio2_7::Start() { return SoundStream::Start(); }
void XAudio2_7::Stop() {}
void XAudio2_7::Update() {}
void XAudio2_7::Clear(bool mute) {}
void XAudio2_7::SetVolume(int volume) {}
bool XAudio2_7::usesMixer() const { return false; }
bool XAudio2_7::InitLibrary() { return false; }
#endif

View File

@ -0,0 +1,81 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
// This audio backend uses XAudio2 via XAudio2_7.dll
// This version of the library is included in the June 2010 DirectX SDK and
// works on all versions of Windows, however the SDK and/or redist must be
// seperately installed.
// Therefore this backend is available iff:
// * SDK is available at compile-time
// * runtime dll is available at runtime
#pragma once
#include <memory>
#include "Thread.h"
#include "SoundStream.h"
#ifdef _WIN32
#include <Windows.h>
struct StreamingVoiceContext2_7;
struct IXAudio2;
struct IXAudio2MasteringVoice;
#endif
class XAudio2_7 : public SoundStream
{
#ifdef _WIN32
private:
static void ReleaseIXAudio2(IXAudio2 *ptr);
class Releaser
{
public:
template <typename R>
void operator()(R *ptr)
{
ReleaseIXAudio2(ptr);
}
};
std::unique_ptr<IXAudio2, Releaser> m_xaudio2;
std::unique_ptr<StreamingVoiceContext2_7> m_voice_context;
IXAudio2MasteringVoice *m_mastering_voice;
Common::Event m_sound_sync_event;
float m_volume;
const bool m_cleanup_com;
static HMODULE m_xaudio2_dll;
static bool InitLibrary();
public:
XAudio2_7(CMixer *mixer);
virtual ~XAudio2_7();
virtual bool Start();
virtual void Stop();
virtual void Update();
virtual void Clear(bool mute);
virtual void SetVolume(int volume);
virtual bool usesMixer() const;
static bool isValid() { return InitLibrary(); }
#else
public:
XAudio2_7(CMixer *mixer)
: SoundStream(mixer)
{}
#endif
};

View File

@ -0,0 +1,5 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include "stdafx.h"

View File

@ -0,0 +1,17 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#pragma once
/*
#ifdef HAVE_DXSDK_JUNE_2010
#define _WIN32_WINNT 0x501
#else
#pragma message("Resulting binary will be compatible with DirectX >= Windows 8. Install the June 2010 DirectX SDK if you want to build for older environments.")
#define _WIN32_WINNT 0x602
#endif
*/
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <algorithm>
#include <functional>