TV nudge counter access is now an atomic operation

This commit is contained in:
JetSetIlly 2023-07-22 19:32:01 +01:00
parent 3d610ccdcc
commit 45ae4b6be3
2 changed files with 5 additions and 4 deletions

View file

@ -74,7 +74,7 @@ type limiter struct {
matchRefreshRateDelay int
// nudge the limiter so that it doesn't wait for the specified number of frames
nudge int
nudge atomic.Int32
}
func (lmtr *limiter) init(tv *Television) {
@ -131,8 +131,9 @@ func (lmtr *limiter) setRate(fps float32) {
func (lmtr *limiter) checkFrame() {
lmtr.measureCt++
if lmtr.nudge > 0 {
lmtr.nudge--
nudge := lmtr.nudge.Load()
if nudge > 0 {
lmtr.nudge.Store(nudge - 1)
} else {
if lmtr.active {
lmtr.pulseCt++

View file

@ -841,7 +841,7 @@ func (tv *Television) NudgeFPSCap(frames int) {
if frames < 0 {
frames = 0
}
tv.lmtr.nudge = frames
tv.lmtr.nudge.Store(int32(frames))
}
// SetFPSCap whether the emulation should wait for FPS limiter. Returns the