SPU2: Attempt 96khz sample rate if 48khz fails

This commit is contained in:
refractionpcsx2 2020-12-31 23:51:51 +00:00
parent a94561fba7
commit af89879750
2 changed files with 21 additions and 0 deletions

View File

@ -893,6 +893,9 @@ __forceinline
SndBuffer::Write(Out); SndBuffer::Write(Out);
if(SampleRate == 96000) // Double up samples for 96khz (Port Audio Non-Exclusive)
SndBuffer::Write(Out);
// Update AutoDMA output positioning // Update AutoDMA output positioning
OutPos++; OutPos++;
if (OutPos >= 0x200) if (OutPos >= 0x200)

View File

@ -297,6 +297,22 @@ public:
PaCallback, PaCallback,
nullptr); nullptr);
if (err == paInvalidSampleRate && SampleRate == 48000)
{
DevCon.Warning("Failed to create device at 48khz, trying 96khz");
SampleRate = 96000;
err = Pa_OpenStream(&stream,
nullptr, &outParams, SampleRate,
SndOutPacketSize,
paNoFlag,
PaCallback,
nullptr);
}
if (err == paInvalidSampleRate && SampleRate == 96000) // It didn't work, so lets just put the samplerate back
SampleRate = 48000;
} }
else else
{ {
@ -308,6 +324,8 @@ public:
} }
if (err != paNoError) if (err != paNoError)
{ {
if(err == paInvalidSampleRate)
Console.Warning("Failed to create Port Audio Device %dkhz, Please use Exclusive Mode", SampleRate / 1000);
fprintf(stderr, "* SPU2: PortAudio error: %s\n", Pa_GetErrorText(err)); fprintf(stderr, "* SPU2: PortAudio error: %s\n", Pa_GetErrorText(err));
Pa_Terminate(); Pa_Terminate();
return -1; return -1;