mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-16 21:29:31 +00:00
HACK: Experimental fix for speaker-getting-wedged issue
- Repro: GDB breakpoint while cpu_thread() is nanosleeping() seems to produce maximum cycles_speaker_feedback, and it never clears up
This commit is contained in:
parent
d63ba9538d
commit
a5a4a50983
19
src/timing.c
19
src/timing.c
|
@ -298,23 +298,34 @@ cpu_runloop:
|
|||
clock_gettime(CLOCK_MONOTONIC, &ti);
|
||||
|
||||
deltat = timespec_diff(t0, ti, &negative);
|
||||
if (deltat.tv_sec) {
|
||||
if (UNLIKELY(deltat.tv_sec)) {
|
||||
if (!is_fullspeed) {
|
||||
TIMING_LOG("NOTE : serious divergence from target time ...");
|
||||
}
|
||||
t0 = ti;
|
||||
deltat = timespec_diff(t0, ti, &negative);
|
||||
deltat = (struct timespec){ 0 };
|
||||
}
|
||||
t0 = timespec_add(t0, EXECUTION_PERIOD_NSECS); // expected interval
|
||||
drift_adj_nsecs = negative ? ~deltat.tv_nsec : deltat.tv_nsec;
|
||||
|
||||
// set up increment & decrement counters
|
||||
// Determine the count of 65c02 cycles to execute
|
||||
{
|
||||
static int speaker_wedged_count = 0;
|
||||
|
||||
run_args.cpu65_cycles_to_execute = (cycles_persec_target / 1000); // cycles_persec_target * EXECUTION_PERIOD_NSECS / NANOSECONDS_PER_SECOND
|
||||
if (!is_fullspeed) {
|
||||
// Speaker backend (real-time soundcard) actually drives us!
|
||||
run_args.cpu65_cycles_to_execute += cycles_speaker_feedback;
|
||||
}
|
||||
if (run_args.cpu65_cycles_to_execute < 0) {
|
||||
if (UNLIKELY(run_args.cpu65_cycles_to_execute <= 0)) {
|
||||
run_args.cpu65_cycles_to_execute = 0;
|
||||
if (++speaker_wedged_count >= SOUNDCORE_ERROR_MAX<<1) {
|
||||
speaker_wedged_count = 0;
|
||||
emul_reinitialize_audio = true;
|
||||
}
|
||||
} else {
|
||||
speaker_wedged_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
MB_StartOfCpuExecute();
|
||||
|
|
Loading…
Reference in New Issue
Block a user