fixed potential buffer overflow when using resampling (FM High-Quality mode).

This commit is contained in:
ekeeke31 2010-02-12 13:27:09 +00:00
parent 3cef34ffa4
commit 0f1850ec6e

View File

@ -187,12 +187,11 @@ int sound_update(unsigned int cycles)
/* resynchronize FM & PSG chips */ /* resynchronize FM & PSG chips */
YM2612Update(Fir_Resampler_buffer(), remain); YM2612Update(Fir_Resampler_buffer(), remain);
Fir_Resampler_write(remain << 1); Fir_Resampler_write(remain << 1);
fm_cycles_count = psg_cycles_count;
} }
fm_cycles_count = psg_cycles_count;
#ifdef LOGSOUND #ifdef LOGSOUND
error("%d FM samples available\n",Fir_Resampler_written() >> 1); error("%d FM samples available (%d needed)\n",Fir_Resampler_written() >> 1, remain);
#endif #endif
} }
else else
@ -210,7 +209,7 @@ int sound_update(unsigned int cycles)
error("%lu FM cycles run \n",fm_cycles_count); error("%lu FM cycles run \n",fm_cycles_count);
#endif #endif
/* adjust PSG & FM cycle counts */ /* adjust PSG & FM cycle counts for next frame */
psg_cycles_count -= (cycles << 11); psg_cycles_count -= (cycles << 11);
fm_cycles_count -= (cycles << 11); fm_cycles_count -= (cycles << 11);