mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-06-02 20:41:38 +00:00
Ensure that all ay_change's get processed + LogOutput if any ay_change's are dropped
This commit is contained in:
parent
c204783816
commit
011d5ac77f
|
@ -471,6 +471,9 @@ sound_write_buf_pstereo( libspectrum_signed_word * out, int c )
|
|||
#define AY_ENV_HOLD 1
|
||||
|
||||
#define HZ_COMMON_DENOMINATOR 50
|
||||
static bool g_dbg = false;
|
||||
#include "Log.h"
|
||||
extern int g_nDbgNumSamplesError; // DBG
|
||||
|
||||
void CAY8910::sound_ay_overlay( void )
|
||||
{
|
||||
|
@ -495,8 +498,25 @@ void CAY8910::sound_ay_overlay( void )
|
|||
sfreq = sound_generator_freq / HZ_COMMON_DENOMINATOR;
|
||||
// cpufreq = machine_current->timings.processor_speed / HZ_COMMON_DENOMINATOR;
|
||||
cpufreq = (libspectrum_dword) (m_fCurrentCLK_AY8910 / HZ_COMMON_DENOMINATOR); // [TC]
|
||||
int dbgCount=0;
|
||||
for( f = 0; f < ay_change_count; f++ )
|
||||
{
|
||||
ay_change[f].ofs = (USHORT) (( ay_change[f].tstates * sfreq ) / cpufreq); // [TC] Added cast
|
||||
#if 1
|
||||
if (ay_change[f].ofs >= sound_generator_framesiz) // [TC] Ensure that all ay_change's get processed
|
||||
{
|
||||
if (g_dbg)
|
||||
ay_change[f].ofs = sound_generator_framesiz-1; // [TC] - parent, sound_frame(), just dumps outstanding changes (ay_change_count=0)
|
||||
else
|
||||
dbgCount++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (dbgCount)
|
||||
{
|
||||
LogOutput("ay_change: dropped %d, numSamplesError=%d\n", dbgCount, g_nDbgNumSamplesError);
|
||||
//_ASSERT(g_nDbgNumSamplesError != 0);
|
||||
}
|
||||
|
||||
libspectrum_signed_word* pBuf1 = g_ppSoundBuffers[0];
|
||||
libspectrum_signed_word* pBuf2 = g_ppSoundBuffers[1];
|
||||
|
|
|
@ -756,6 +756,8 @@ static void Votrax_Write(BYTE nDevice, BYTE nValue)
|
|||
|
||||
//===========================================================================
|
||||
|
||||
int g_nDbgNumSamplesError = 0; // DBG
|
||||
|
||||
//#define DBG_MB_UPDATE
|
||||
static UINT64 g_uLastMBUpdateCycle = 0;
|
||||
|
||||
|
@ -823,8 +825,8 @@ static void MB_Update(void)
|
|||
|
||||
g_uLastMBUpdateCycle = g_uLastCumulativeCycles;
|
||||
|
||||
const double nIrqFreq = g_fCurrentCLK6502 / updateInterval + 0.5; // Round-up
|
||||
const int nNumSamplesPerPeriod = (int) ((double)SAMPLE_RATE / nIrqFreq); // Eg. For 60Hz this is 735
|
||||
const double nIrqFreq = g_fCurrentCLK6502 / updateInterval;
|
||||
const int nNumSamplesPerPeriod = (int) ceil((double)SAMPLE_RATE / nIrqFreq); // Eg. For 60Hz this is 735
|
||||
|
||||
static int nNumSamplesError = 0;
|
||||
int nNumSamples = nNumSamplesPerPeriod + nNumSamplesError; // Apply correction
|
||||
|
@ -898,6 +900,7 @@ static void MB_Update(void)
|
|||
nNumSamplesError -= nErrorInc; // > 0.50 of buffer remaining
|
||||
else
|
||||
nNumSamplesError = 0; // Acceptable amount of data in buffer
|
||||
g_nDbgNumSamplesError = nNumSamplesError; // DBG
|
||||
|
||||
#ifdef DBG_MB_UPDATE
|
||||
double fTicksSecs = (double)GetTickCount() / 1000.0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user