spu2-x: Fix warnings regarding initializing with memset/memzero/etc... (#2682)

* spu2-x: Fix warnings regarding initializing with memset/memzero/etc...

* Use fill_n instead, per turtleli's suggestion.

* spu2-x: Comment out StereoOut initialization.

* spu2-x: As requested, remove commented out code.
This commit is contained in:
arcum42 2018-12-09 14:09:22 -08:00 committed by GitHub
parent 3a094604f6
commit af742a753e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 11 deletions

View File

@ -178,6 +178,7 @@ void SPU2writeLog(const char *action, u32 rmem, u16 value)
break; break;
case REG_S_VMIXL: case REG_S_VMIXL:
RegLog(1, "VMIXL0", rmem, core, value); RegLog(1, "VMIXL0", rmem, core, value);
break;
case (REG_S_VMIXL + 2): case (REG_S_VMIXL + 2):
RegLog(1, "VMIXL1", rmem, core, value); RegLog(1, "VMIXL1", rmem, core, value);
break; break;

View File

@ -282,7 +282,7 @@ void SndBuffer::ReadSamples(T *bData)
// If quietSamples != 0 it means we have an underrun... // If quietSamples != 0 it means we have an underrun...
// Let's just dull out some silence, because that's usually the least // Let's just dull out some silence, because that's usually the least
// painful way of dealing with underruns: // painful way of dealing with underruns:
memset(bData, 0, quietSamples * sizeof(T)); std::fill_n(bData, quietSamples, T{});
} }
template void SndBuffer::ReadSamples(StereoOut16 *); template void SndBuffer::ReadSamples(StereoOut16 *);
@ -388,11 +388,6 @@ void SndBuffer::Init()
return; return;
} }
// clear buffers!
// Fixes loopy sounds on emu resets.
memset(sndTempBuffer, 0, sizeof(StereoOut32) * SndOutPacketSize);
memset(sndTempBuffer16, 0, sizeof(StereoOut16) * SndOutPacketSize);
sndTempProgress = 0; sndTempProgress = 0;
soundtouchInit(); // initializes the timestretching soundtouchInit(); // initializes the timestretching
@ -445,7 +440,8 @@ void SndBuffer::Write(const StereoOut32 &Sample)
//Don't play anything directly after loading a savestate, avoids static killing your speakers. //Don't play anything directly after loading a savestate, avoids static killing your speakers.
if (ssFreeze > 0) { if (ssFreeze > 0) {
ssFreeze--; ssFreeze--;
memset(sndTempBuffer, 0, sizeof(StereoOut32) * SndOutPacketSize); // Play silence // Play silence
std::fill_n(sndTempBuffer, SndOutPacketSize, StereoOut32{});
} }
#ifndef __POSIX__ #ifndef __POSIX__
if (dspPluginEnabled) { if (dspPluginEnabled) {

View File

@ -118,8 +118,30 @@ V_Core::~V_Core() throw()
void V_Core::Init(int index) void V_Core::Init(int index)
{ {
ConLog("* SPU2-X: Init SPU2 core %d \n", index); ConLog("* SPU2-X: Init SPU2 core %d \n", index);
memset(this, 0, sizeof(V_Core)); //memset(this, 0, sizeof(V_Core));
// Explicitly initializing variables instead.
Mute = false;
DMABits = 0;
NoiseClk = 0;
AutoDMACtrl = 0;
InputDataLeft = 0;
InputPosRead = 0;
InputPosWrite = 0;
InputDataProgress = 0;
ReverbX = 0;
LastEffect.Left = 0;
LastEffect.Right = 0;
CoreEnabled = 0;
AttrBit0 = 0;
DmaMode = 0;
DMAPtr = nullptr;
MADR = 0;
TADR = 0;
KeyOn = 0;
psxmode = false; psxmode = false;
psxSoundDataTransferControl = 0;
psxSPUSTAT = 0;
const int c = Index = index; const int c = Index = index;
@ -150,7 +172,7 @@ void V_Core::Init(int index)
ExtEffectsStartA = EffectsStartA; ExtEffectsStartA = EffectsStartA;
ExtEffectsEndA = EffectsEndA; ExtEffectsEndA = EffectsEndA;
FxEnable = 0; // Uninitialized it's 0 for both cores. Resetting libs however may set this to 0 or 1. FxEnable = false; // Uninitialized it's 0 for both cores. Resetting libs however may set this to 0 or 1.
// These are real PS2 values, mainly constant apart from a few bits: 0x3220EAA4, 0x40505E9C. // These are real PS2 values, mainly constant apart from a few bits: 0x3220EAA4, 0x40505E9C.
// These values mean nothing. They do not reflect the actual address the SPU2 is testing, // These values mean nothing. They do not reflect the actual address the SPU2 is testing,
// it would seem that reading the IRQA register returns the last written value, not the // it would seem that reading the IRQA register returns the last written value, not the
@ -160,7 +182,7 @@ void V_Core::Init(int index)
// in the input or output areas, so we're using 0x800. // in the input or output areas, so we're using 0x800.
// F1 2005 is known to rely on an uninitialised IRQA being an address which will be hit. // F1 2005 is known to rely on an uninitialised IRQA being an address which will be hit.
IRQA = 0x800; IRQA = 0x800;
IRQEnable = 0; // PS2 confirmed IRQEnable = false; // PS2 confirmed
for (uint v = 0; v < NumVoices; ++v) { for (uint v = 0; v < NumVoices; ++v) {
VoiceGates[v].DryL = -1; VoiceGates[v].DryL = -1;
@ -180,7 +202,9 @@ void V_Core::Init(int index)
} }
DMAICounter = 0; DMAICounter = 0;
AdmaInProgress = 0; AutoDmaFree = 0;
AdmaInProgress = false;
DmaStarted = false;
Regs.STATX = 0x80; Regs.STATX = 0x80;
Regs.ENDX = 0xffffff; // PS2 confirmed Regs.ENDX = 0xffffff; // PS2 confirmed