mirror of https://github.com/PCSX2/pcsx2.git
spu2-x:windows:xaudio: Remove ifdefs and rename class/vars
This reverts commit 8a61c7d336
.
The plan is to support both XAudio2 2.7 and 2.8+. This file will only be
used for 2.7, so let's remove the ifdefs and rename the class and vars.
This commit is contained in:
parent
c8162df936
commit
de56e30bba
|
@ -87,7 +87,7 @@ SndOutModule* mods[]=
|
||||||
{
|
{
|
||||||
&NullOut,
|
&NullOut,
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
XAudio2Out,
|
XAudio2_27_Out,
|
||||||
DSoundOut,
|
DSoundOut,
|
||||||
WaveOut,
|
WaveOut,
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -670,7 +670,7 @@ public:
|
||||||
//internal
|
//internal
|
||||||
extern SndOutModule* WaveOut;
|
extern SndOutModule* WaveOut;
|
||||||
extern SndOutModule* DSoundOut;
|
extern SndOutModule* DSoundOut;
|
||||||
extern SndOutModule* XAudio2Out;
|
extern SndOutModule* XAudio2_27_Out;
|
||||||
#endif
|
#endif
|
||||||
extern SndOutModule* PortaudioOut;
|
extern SndOutModule* PortaudioOut;
|
||||||
#if defined(SPU2X_SDL) || defined(SPU2X_SDL2)
|
#if defined(SPU2X_SDL) || defined(SPU2X_SDL2)
|
||||||
|
|
|
@ -127,7 +127,7 @@ void ReadSettings()
|
||||||
// let's use xaudio2 until this is sorted (rama)
|
// let's use xaudio2 until this is sorted (rama)
|
||||||
|
|
||||||
// CfgReadStr(L"OUTPUT", L"Output_Module", omodid, 127, PortaudioOut->GetIdent());
|
// CfgReadStr(L"OUTPUT", L"Output_Module", omodid, 127, PortaudioOut->GetIdent());
|
||||||
CfgReadStr(L"OUTPUT", L"Output_Module", omodid, 127, XAudio2Out->GetIdent());
|
CfgReadStr(L"OUTPUT", L"Output_Module", omodid, 127, XAudio2_27_Out->GetIdent());
|
||||||
|
|
||||||
// find the driver index of this module:
|
// find the driver index of this module:
|
||||||
OutputModule = FindOutputModuleById( omodid );
|
OutputModule = FindOutputModuleById( omodid );
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
#define _WIN32_DCOM
|
|
||||||
#include "Dialogs.h"
|
#include "Dialogs.h"
|
||||||
|
|
||||||
#include <xaudio2.h>
|
#include <xaudio2.h>
|
||||||
|
@ -25,7 +24,7 @@
|
||||||
|
|
||||||
namespace Exception
|
namespace Exception
|
||||||
{
|
{
|
||||||
class XAudio2Error : public std::runtime_error
|
class XAudio2_27Error : public std::runtime_error
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
static const char* SomeKindaErrorString( HRESULT hr )
|
static const char* SomeKindaErrorString( HRESULT hr )
|
||||||
|
@ -50,8 +49,8 @@ namespace Exception
|
||||||
return m_Message.c_str();
|
return m_Message.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~XAudio2Error() throw() {}
|
virtual ~XAudio2_27Error() throw() {}
|
||||||
XAudio2Error( const HRESULT result, const std::string& msg ) :
|
XAudio2_27Error( const HRESULT result, const std::string& msg ) :
|
||||||
runtime_error( msg ),
|
runtime_error( msg ),
|
||||||
ErrorCode( result ),
|
ErrorCode( result ),
|
||||||
m_Message()
|
m_Message()
|
||||||
|
@ -65,7 +64,7 @@ namespace Exception
|
||||||
|
|
||||||
static const double SndOutNormalizer = (double)(1UL<<(SndOutVolumeShift+16));
|
static const double SndOutNormalizer = (double)(1UL<<(SndOutVolumeShift+16));
|
||||||
|
|
||||||
class XAudio2Mod: public SndOutModule
|
class XAudio2_27_Mod: public SndOutModule
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static const int PacketsPerBuffer = 8;
|
static const int PacketsPerBuffer = 8;
|
||||||
|
@ -132,7 +131,7 @@ private:
|
||||||
if( FAILED(hr = pXAudio2->CreateSourceVoice( &pSourceVoice, (WAVEFORMATEX*)&wfx,
|
if( FAILED(hr = pXAudio2->CreateSourceVoice( &pSourceVoice, (WAVEFORMATEX*)&wfx,
|
||||||
XAUDIO2_VOICE_NOSRC, 1.0f, this ) ) )
|
XAUDIO2_VOICE_NOSRC, 1.0f, this ) ) )
|
||||||
{
|
{
|
||||||
throw Exception::XAudio2Error( hr, "XAudio2 CreateSourceVoice failure." );
|
throw Exception::XAudio2_27Error( hr, "XAudio2 CreateSourceVoice failure." );
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeCriticalSection( &cs );
|
InitializeCriticalSection( &cs );
|
||||||
|
@ -232,9 +231,8 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
#if _WIN32_WINNT < 0x602
|
|
||||||
HMODULE xAudio2DLL;
|
HMODULE xAudio2DLL;
|
||||||
#endif
|
|
||||||
CComPtr<IXAudio2> pXAudio2;
|
CComPtr<IXAudio2> pXAudio2;
|
||||||
IXAudio2MasteringVoice* pMasteringVoice;
|
IXAudio2MasteringVoice* pMasteringVoice;
|
||||||
BaseStreamingVoice* voiceContext;
|
BaseStreamingVoice* voiceContext;
|
||||||
|
@ -246,7 +244,7 @@ public:
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
jASSUME( pXAudio2 == NULL );
|
jASSUME( pXAudio2 == NULL );
|
||||||
#if _WIN32_WINNT < 0x602
|
|
||||||
// On some systems XAudio2.7 can unload itself and cause PCSX2 to crash.
|
// On some systems XAudio2.7 can unload itself and cause PCSX2 to crash.
|
||||||
// Maintain an extra library reference so it can't do so. Does not
|
// Maintain an extra library reference so it can't do so. Does not
|
||||||
// affect XAudio 2.8+, but that's Win8+. See
|
// affect XAudio 2.8+, but that's Win8+. See
|
||||||
|
@ -255,7 +253,6 @@ public:
|
||||||
xAudio2DLL = LoadLibrary(L"XAudioD2_7.dll");
|
xAudio2DLL = LoadLibrary(L"XAudioD2_7.dll");
|
||||||
#else
|
#else
|
||||||
xAudio2DLL = LoadLibrary(L"XAudio2_7.dll");
|
xAudio2DLL = LoadLibrary(L"XAudio2_7.dll");
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -264,23 +261,20 @@ public:
|
||||||
CoInitializeEx( NULL, COINIT_MULTITHREADED );
|
CoInitializeEx( NULL, COINIT_MULTITHREADED );
|
||||||
|
|
||||||
UINT32 flags = 0;
|
UINT32 flags = 0;
|
||||||
#if _WIN32_WINNT < 0x602
|
|
||||||
if( IsDebugBuild )
|
if( IsDebugBuild )
|
||||||
flags |= XAUDIO2_DEBUG_ENGINE;
|
flags |= XAUDIO2_DEBUG_ENGINE;
|
||||||
#endif
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( FAILED(hr = XAudio2Create( &pXAudio2, flags ) ) )
|
if ( FAILED(hr = XAudio2Create( &pXAudio2, flags ) ) )
|
||||||
throw Exception::XAudio2Error( hr,
|
throw Exception::XAudio2_27Error( hr,
|
||||||
"Failed to init XAudio2 engine. XA2 may not be available on your system.\n"
|
"Failed to init XAudio2 engine. XA2 may not be available on your system.\n"
|
||||||
"Ensure that you have the latest DirectX runtimes installed, or use \n"
|
"Ensure that you have the latest DirectX runtimes installed, or use \n"
|
||||||
"DirectX / WaveOut drivers instead. Error Details:"
|
"DirectX / WaveOut drivers instead. Error Details:"
|
||||||
);
|
);
|
||||||
#if _WIN32_WINNT < 0x602
|
|
||||||
XAUDIO2_DEVICE_DETAILS deviceDetails;
|
XAUDIO2_DEVICE_DETAILS deviceDetails;
|
||||||
pXAudio2->GetDeviceDetails( 0, &deviceDetails );
|
pXAudio2->GetDeviceDetails( 0, &deviceDetails );
|
||||||
#endif
|
|
||||||
|
|
||||||
// Stereo Expansion was planned to grab the currently configured number of
|
// Stereo Expansion was planned to grab the currently configured number of
|
||||||
// Speakers from Windows's audio config.
|
// Speakers from Windows's audio config.
|
||||||
|
@ -296,10 +290,8 @@ public:
|
||||||
default: speakers = 2;
|
default: speakers = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if _WIN32_WINNT < 0x602
|
|
||||||
// Any windows driver should support stereo at the software level, I should think!
|
// Any windows driver should support stereo at the software level, I should think!
|
||||||
jASSUME( deviceDetails.OutputFormat.Format.nChannels > 1 );
|
jASSUME( deviceDetails.OutputFormat.Format.nChannels > 1 );
|
||||||
#endif
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create a mastering voice
|
// Create a mastering voice
|
||||||
|
@ -360,7 +352,7 @@ public:
|
||||||
|
|
||||||
voiceContext->Init( pXAudio2 );
|
voiceContext->Init( pXAudio2 );
|
||||||
}
|
}
|
||||||
catch( Exception::XAudio2Error& ex )
|
catch( Exception::XAudio2_27Error& ex )
|
||||||
{
|
{
|
||||||
SysMessage( ex.CMessage() );
|
SysMessage( ex.CMessage() );
|
||||||
pXAudio2.Release();
|
pXAudio2.Release();
|
||||||
|
@ -394,12 +386,10 @@ public:
|
||||||
pXAudio2.Release();
|
pXAudio2.Release();
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
|
|
||||||
#if _WIN32_WINNT < 0x602
|
|
||||||
if (xAudio2DLL) {
|
if (xAudio2DLL) {
|
||||||
FreeLibrary(xAudio2DLL);
|
FreeLibrary(xAudio2DLL);
|
||||||
xAudio2DLL = nullptr;
|
xAudio2DLL = nullptr;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Configure(uptr parent)
|
virtual void Configure(uptr parent)
|
||||||
|
@ -424,7 +414,7 @@ public:
|
||||||
|
|
||||||
const wchar_t* GetLongName() const
|
const wchar_t* GetLongName() const
|
||||||
{
|
{
|
||||||
return L"XAudio 2 (Recommended)";
|
return L"XAudio 2.7 (Recommended)";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadSettings()
|
void ReadSettings()
|
||||||
|
@ -441,4 +431,4 @@ public:
|
||||||
|
|
||||||
} static XA2;
|
} static XA2;
|
||||||
|
|
||||||
SndOutModule *XAudio2Out = &XA2;
|
SndOutModule *XAudio2_27_Out = &XA2;
|
||||||
|
|
Loading…
Reference in New Issue