SPU2: remove waveout windows

SPU2: remove waveout windows
This commit is contained in:
Mrlinkwii 2021-08-07 21:39:10 +01:00 committed by lightningterror
parent 5f3c1816f9
commit e4e306baca
9 changed files with 2 additions and 392 deletions

View File

@ -84,7 +84,6 @@ SndOutModule* mods[] =
&NullOut,
#ifdef _MSC_VER
XAudio2Out,
WaveOut,
#endif
#if defined(SPU2X_PORTAUDIO)
PortaudioOut,

View File

@ -665,7 +665,6 @@ public:
#ifdef _MSC_VER
//internal
extern SndOutModule* WaveOut;
extern SndOutModule* XAudio2Out;
#endif
#if defined(SPU2X_PORTAUDIO)

View File

@ -62,7 +62,6 @@ int SynchMode = 0; // Time Stretch, Async or Disabled.
u32 OutputModule = 0;
CONFIG_WAVEOUT Config_WaveOut;
CONFIG_XAUDIO2 Config_XAudio2;
// DSP
@ -127,10 +126,6 @@ void ReadSettings()
dspPluginModule = CfgReadInt(L"DSP PLUGIN", L"ModuleNum", 0);
dspPluginEnabled = CfgReadBool(L"DSP PLUGIN", L"Enabled", false);
// Read WAVEOUT configs:
CfgReadStr(L"WAVEOUT", L"Device", Config_WaveOut.Device, L"default");
Config_WaveOut.NumBuffers = CfgReadInt(L"WAVEOUT", L"Buffer_Count", 4);
PortaudioOut->ReadSettings();
SoundtouchCfg::ReadSettings();
@ -174,11 +169,6 @@ void WriteSettings()
CfgWriteInt(L"OUTPUT", L"SpeakerConfiguration", numSpeakers);
CfgWriteInt(L"OUTPUT", L"DplDecodingLevel", dplLevel);
if (Config_WaveOut.Device.empty())
Config_WaveOut.Device = L"default";
CfgWriteStr(L"WAVEOUT", L"Device", Config_WaveOut.Device);
CfgWriteInt(L"WAVEOUT", L"Buffer_Count", Config_WaveOut.NumBuffers);
CfgWriteStr(L"DSP PLUGIN", L"Filename", dspPlugin);
CfgWriteInt(L"DSP PLUGIN", L"ModuleNum", dspPluginModule);
CfgWriteBool(L"DSP PLUGIN", L"Enabled", dspPluginEnabled);
@ -191,10 +181,7 @@ void WriteSettings()
void CheckOutputModule(HWND window)
{
OutputModule = SendMessage(GetDlgItem(window, IDC_OUTPUT), CB_GETCURSEL, 0, 0);
const bool IsConfigurable =
mods[OutputModule] == PortaudioOut ||
mods[OutputModule] == WaveOut;
const bool IsConfigurable = mods[OutputModule] == PortaudioOut;
const bool AudioExpansion =
mods[OutputModule] == XAudio2Out ||
mods[OutputModule] == PortaudioOut;

View File

@ -64,21 +64,6 @@ BEGIN
DEFPUSHBUTTON "Close",IDOK,246,451,50,14
END
IDD_WAVEOUT DIALOGEX 0, 0, 170, 122
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "WaveOut Output Module Settings"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,32,100,50,14
PUSHBUTTON "Cancel",IDCANCEL,88,100,50,14
COMBOBOX IDC_DS_DEVICE,6,13,159,62,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "WaveOut Device:",IDC_STATIC,4,3,60,8
LTEXT "Number of Buffers",IDC_STATIC,4,39,61,15
CONTROL "",IDC_BUFFERS_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | WS_TABSTOP,71,48,94,10
LTEXT "Use extra buffers if you are experiencing loopy or studdery audio even when games run at high FPS.",IDC_STATIC,8,66,151,27
CTEXT "8 (80 ms latency)",IDC_LATENCY_LABEL,70,37,95,11
END
IDD_CONFIG_SOUNDTOUCH DIALOGEX 0, 0, 206, 223
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Soundtouch Advanced Configuration - SPU2"
@ -154,15 +139,7 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 465
END
IDD_WAVEOUT, DIALOG
BEGIN
LEFTMARGIN, 4
RIGHTMARGIN, 165
TOPMARGIN, 3
BOTTOMMARGIN, 118
END
IDD_CONFIG_SOUNDTOUCH, DIALOG
BEGIN
LEFTMARGIN, 5

View File

@ -1,334 +0,0 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "SPU2/Global.h"
#include "Dialogs.h"
class WaveOutModule : public SndOutModule
{
private:
static const uint MAX_BUFFER_COUNT = 8;
static const int PacketsPerBuffer = (1024 / SndOutPacketSize);
static const int BufferSize = SndOutPacketSize * PacketsPerBuffer;
u32 numBuffers;
HWAVEOUT hwodevice;
WAVEFORMATEX wformat;
WAVEHDR whbuffer[MAX_BUFFER_COUNT];
StereoOut16* qbuffer;
#define QBUFFER(x) (qbuffer + BufferSize * (x))
bool waveout_running;
HANDLE thread;
DWORD tid;
wchar_t ErrText[256];
template <typename T>
DWORD CALLBACK Thread()
{
static const int BufferSizeBytes = BufferSize * sizeof(T);
while (waveout_running)
{
bool didsomething = false;
for (u32 i = 0; i < numBuffers; i++)
{
if (!(whbuffer[i].dwFlags & WHDR_DONE))
continue;
WAVEHDR* buf = whbuffer + i;
buf->dwBytesRecorded = buf->dwBufferLength;
T* t = (T*)buf->lpData;
for (int p = 0; p < PacketsPerBuffer; p++, t += SndOutPacketSize)
SndBuffer::ReadSamples(t);
whbuffer[i].dwFlags &= ~WHDR_DONE;
waveOutWrite(hwodevice, buf, sizeof(WAVEHDR));
didsomething = true;
}
if (didsomething)
Sleep(1);
else
Sleep(0);
}
return 0;
}
template <typename T>
static DWORD CALLBACK RThread(WaveOutModule* obj)
{
return obj->Thread<T>();
}
public:
s32 Init()
{
numBuffers = Config_WaveOut.NumBuffers;
MMRESULT woores;
if (Test())
return -1;
// TODO : Use dsound to determine the speaker configuration, and expand audio from there.
#if 0
int speakerConfig;
//if( StereoExpansionEnabled )
speakerConfig = 2; // better not mess with this in wavout :p (rama)
// Any windows driver should support stereo at the software level, I should think!
pxAssume( speakerConfig > 1 );
LPTHREAD_START_ROUTINE threadproc;
switch( speakerConfig )
{
case 2:
ConLog( "* SPU2 > Using normal 2 speaker stereo output.\n" );
threadproc = (LPTHREAD_START_ROUTINE)&RThread<StereoOut16>;
speakerConfig = 2;
break;
case 4:
ConLog( "* SPU2 > 4 speaker expansion enabled [quadraphenia]\n" );
threadproc = (LPTHREAD_START_ROUTINE)&RThread<StereoQuadOut16>;
speakerConfig = 4;
break;
case 6:
case 7:
ConLog( "* SPU2 > 5.1 speaker expansion enabled.\n" );
threadproc = (LPTHREAD_START_ROUTINE)&RThread<Stereo51Out16>;
speakerConfig = 6;
break;
default:
ConLog( "* SPU2 > 7.1 speaker expansion enabled.\n" );
threadproc = (LPTHREAD_START_ROUTINE)&RThread<Stereo51Out16>;
speakerConfig = 8;
break;
}
#endif
wformat.wFormatTag = WAVE_FORMAT_PCM;
wformat.nSamplesPerSec = SampleRate;
wformat.wBitsPerSample = 16;
wformat.nChannels = 2;
wformat.nBlockAlign = ((wformat.wBitsPerSample * wformat.nChannels) / 8);
wformat.nAvgBytesPerSec = (wformat.nSamplesPerSec * wformat.nBlockAlign);
wformat.cbSize = 0;
qbuffer = new StereoOut16[BufferSize * numBuffers];
woores = waveOutOpen(&hwodevice, WAVE_MAPPER, &wformat, 0, 0, 0);
if (woores != MMSYSERR_NOERROR)
{
waveOutGetErrorText(woores, (wchar_t*)&ErrText, 255);
SysMessage("WaveOut Error: %s", ErrText);
return -1;
}
const int BufferSizeBytes = wformat.nBlockAlign * BufferSize;
for (u32 i = 0; i < numBuffers; i++)
{
whbuffer[i].dwBufferLength = BufferSizeBytes;
whbuffer[i].dwBytesRecorded = BufferSizeBytes;
whbuffer[i].dwFlags = 0;
whbuffer[i].dwLoops = 0;
whbuffer[i].dwUser = 0;
whbuffer[i].lpData = (LPSTR)QBUFFER(i);
whbuffer[i].lpNext = 0;
whbuffer[i].reserved = 0;
waveOutPrepareHeader(hwodevice, whbuffer + i, sizeof(WAVEHDR));
whbuffer[i].dwFlags |= WHDR_DONE; //avoid deadlock
}
// Start Thread
// [Air]: The waveout code does not use wait objects, so setting a time critical
// priority level is a bad idea. Standard priority will do fine. The buffer will get the
// love it needs and won't suck resources idling pointlessly. Just don't try to
// run it in uber-low-latency mode.
waveout_running = true;
thread = CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)RThread<StereoOut16>, this, 0, &tid);
return 0;
}
void Close()
{
// Stop Thread
fprintf(stderr, "* SPU2: Waiting for waveOut thread to finish...");
waveout_running = false;
WaitForSingleObject(thread, INFINITE);
CloseHandle(thread);
fprintf(stderr, " Done.\n");
//
// Clean up
//
waveOutReset(hwodevice);
for (u32 i = 0; i < numBuffers; i++)
{
waveOutUnprepareHeader(hwodevice, &whbuffer[i], sizeof(WAVEHDR));
}
waveOutClose(hwodevice);
safe_delete_array(qbuffer);
}
private:
static BOOL CALLBACK ConfigProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
switch (uMsg)
{
case WM_INITDIALOG:
wchar_t temp[128];
INIT_SLIDER(IDC_BUFFERS_SLIDER, 3, MAX_BUFFER_COUNT, 2, 1, 1);
SendMessage(GetDlgItem(hWnd, IDC_BUFFERS_SLIDER), TBM_SETPOS, TRUE, Config_WaveOut.NumBuffers);
swprintf_s(temp, 128, L"%d (%d ms latency)", Config_WaveOut.NumBuffers, 1000 / (96000 / (Config_WaveOut.NumBuffers * BufferSize)));
SetWindowText(GetDlgItem(hWnd, IDC_LATENCY_LABEL), temp);
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDOK:
{
Config_WaveOut.NumBuffers = (int)SendMessage(GetDlgItem(hWnd, IDC_BUFFERS_SLIDER), TBM_GETPOS, 0, 0);
if (Config_WaveOut.NumBuffers < 3)
Config_WaveOut.NumBuffers = 3;
if (Config_WaveOut.NumBuffers > MAX_BUFFER_COUNT)
Config_WaveOut.NumBuffers = MAX_BUFFER_COUNT;
}
EndDialog(hWnd, 0);
break;
case IDCANCEL:
EndDialog(hWnd, 0);
break;
default:
return FALSE;
}
break;
case WM_HSCROLL:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
switch (wmId)
{
case TB_LINEUP:
case TB_LINEDOWN:
case TB_PAGEUP:
case TB_PAGEDOWN:
case TB_TOP:
case TB_BOTTOM:
wmEvent = (int)SendMessage((HWND)lParam, TBM_GETPOS, 0, 0);
case TB_THUMBPOSITION:
case TB_THUMBTRACK:
if (wmEvent < 3)
wmEvent = 3;
if (wmEvent > MAX_BUFFER_COUNT)
wmEvent = MAX_BUFFER_COUNT;
SendMessage((HWND)lParam, TBM_SETPOS, TRUE, wmEvent);
swprintf_s(temp, L"%d (%d ms latency)", wmEvent, 1000 / (96000 / (wmEvent * BufferSize)));
SetWindowText(GetDlgItem(hWnd, IDC_LATENCY_LABEL), temp);
break;
default:
return FALSE;
}
break;
default:
return FALSE;
}
return TRUE;
}
public:
virtual void Configure(uptr parent)
{
INT_PTR ret;
ret = DialogBoxParam(nullptr, MAKEINTRESOURCE(IDD_WAVEOUT), (HWND)parent, (DLGPROC)ConfigProc, 1);
if (ret == -1)
{
MessageBox((HWND)parent, L"Error Opening the config dialog.", L"OMG ERROR!", MB_OK | MB_SETFOREGROUND);
return;
}
}
s32 Test() const
{
if (waveOutGetNumDevs() == 0)
{
SysMessage("No waveOut Devices Present\n");
return -1;
}
return 0;
}
int GetEmptySampleCount()
{
int result = 0;
for (int i = 0; i < MAX_BUFFER_COUNT; i++)
{
result += (whbuffer[i].dwFlags & WHDR_DONE) ? BufferSize : 0;
}
return result;
}
const wchar_t* GetIdent() const
{
return L"waveout";
}
const wchar_t* GetLongName() const
{
return L"WaveOut (Laggy)";
}
void ReadSettings()
{
}
void SetApiSettings(wxString api)
{
}
void WriteSettings() const
{
}
} static WO;
SndOutModule* WaveOut = &WO;

View File

@ -68,17 +68,4 @@ struct CONFIG_XAUDIO2
}
};
struct CONFIG_WAVEOUT
{
wxString Device;
s8 NumBuffers;
CONFIG_WAVEOUT()
: Device()
, NumBuffers(4)
{
}
};
extern CONFIG_WAVEOUT Config_WaveOut;
extern CONFIG_XAUDIO2 Config_XAudio2;

View File

@ -3,7 +3,6 @@
// Used by SPU2.rc
#define IDD_CONFIG 9
#define IDD_DEBUG 105
#define IDD_WAVEOUT 109
#define IDD_CONFIG_SOUNDTOUCH 117
#define IDD_CONFIG_DEBUG 118
#define IDD_PORTAUDIO 119

View File

@ -342,7 +342,6 @@
<ClCompile Include="SPU2\wavedump_wav.cpp" />
<ClCompile Include="SPU2\SndOut.cpp" />
<ClCompile Include="SPU2\Timestretcher.cpp" />
<ClCompile Include="SPU2\Windows\SndOut_waveOut.cpp" />
<ClCompile Include="SPU2\Windows\SndOut_XAudio2.cpp" />
<ClCompile Include="SPU2\dma.cpp" />
<ClCompile Include="SPU2\RegTable.cpp" />

View File

@ -1130,9 +1130,6 @@
<ClCompile Include="SPU2\Windows\SndOut_XAudio2.cpp">
<Filter>System\Ps2\SPU2</Filter>
</ClCompile>
<ClCompile Include="SPU2\Windows\SndOut_waveOut.cpp">
<Filter>System\Ps2\SPU2</Filter>
</ClCompile>
<ClCompile Include="SPU2\Windows\UIHelpers.cpp">
<Filter>System\Ps2\SPU2</Filter>
</ClCompile>