Build on the preivous dsp fix so that it can work with dsp plugins that return partial blocks. It's not tested properly since I don't know of any plugin which does that.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2789 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gigaherz 2010-03-28 21:27:53 +00:00
parent db63162c0d
commit 294705aea6
1 changed files with 6 additions and 5 deletions

View File

@ -264,7 +264,7 @@ void SndBuffer::Init()
m_underrun_freeze = false;
sndTempBuffer = new StereoOut32[SndOutPacketSize];
sndTempBuffer16 = new StereoOut16[SndOutPacketSize];
sndTempBuffer16 = new StereoOut16[SndOutPacketSize * 2]; // in case of leftovers.
}
catch( std::bad_alloc& )
{
@ -340,11 +340,12 @@ void SndBuffer::Write( const StereoOut32& Sample )
{
// Convert in, send to winamp DSP, and convert out.
for( int i=0; i<SndOutPacketSize; ++i ) { sndTempBuffer16[i] = sndTempBuffer[i].DownSample(); }
m_dsp_progress += DspProcess( (s16*)sndTempBuffer16, SndOutPacketSize );
int ei= m_dsp_progress;
for( int i=0; i<SndOutPacketSize; ++i, ++ei ) { sndTempBuffer16[ei] = sndTempBuffer[i].DownSample(); }
m_dsp_progress += DspProcess( (s16*)sndTempBuffer16 + m_dsp_progress, SndOutPacketSize );
// Some ugly code to ensure full packet handling:
int ei = 0;
ei = 0;
while( m_dsp_progress >= SndOutPacketSize )
{
for( int i=0; i<SndOutPacketSize; ++i, ++ei ) { sndTempBuffer[i] = sndTempBuffer16[ei].UpSample(); }
@ -360,7 +361,7 @@ void SndBuffer::Write( const StereoOut32& Sample )
// copy any leftovers to the front of the dsp buffer.
if( m_dsp_progress > 0 )
{
memcpy( &sndTempBuffer16[ei], sndTempBuffer16,
memcpy( sndTempBuffer16, &sndTempBuffer16[ei],
sizeof(sndTempBuffer16[0]) * m_dsp_progress
);
}