mirror of https://github.com/stella-emu/stella.git
improved playback sound muting
This commit is contained in:
parent
ee8734ce14
commit
3eec0defce
|
@ -158,6 +158,7 @@ class RewindManager
|
||||||
uInt64 getFirstCycles() const;
|
uInt64 getFirstCycles() const;
|
||||||
uInt64 getCurrentCycles() const;
|
uInt64 getCurrentCycles() const;
|
||||||
uInt64 getLastCycles() const;
|
uInt64 getLastCycles() const;
|
||||||
|
uInt64 getInterval() const { return myInterval; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get a collection of cycle timestamps, offset from the first one in
|
Get a collection of cycle timestamps, offset from the first one in
|
||||||
|
|
|
@ -450,14 +450,17 @@ void FrameBuffer::update(UpdateMode mode)
|
||||||
|
|
||||||
success = r.unwindStates(1);
|
success = r.unwindStates(1);
|
||||||
|
|
||||||
|
// Determine playback speed, the faster the more the statess are apart
|
||||||
Int64 frameCycles = 76 * std::max<Int32>(myOSystem.console().tia().scanlinesLastFrame(), 240);
|
Int64 frameCycles = 76 * std::max<Int32>(myOSystem.console().tia().scanlinesLastFrame(), 240);
|
||||||
|
Int32 intervalFrames = r.getInterval() / frameCycles;
|
||||||
|
Int32 stateFrames = (r.getCurrentCycles() - prevCycles) / frameCycles;
|
||||||
|
|
||||||
// Use time between previous and current state
|
//frames = intervalFrames + std::sqrt(std::max(stateFrames - intervalFrames, 0));
|
||||||
// to playback larger state gaps faster
|
frames = std::round(std::sqrt(stateFrames));
|
||||||
frames = std::sqrt((r.getCurrentCycles() - prevCycles) / frameCycles);
|
|
||||||
|
|
||||||
// TODO: test and verify with CS
|
// Mute sound if saved states were removed or states are too far apart
|
||||||
//myOSystem.sound().mute(uInt32(frames) > myOSystem.audioSettings().headroom() / 2 + 1);
|
myOSystem.sound().mute(stateFrames > intervalFrames
|
||||||
|
|| frames > myOSystem.audioSettings().bufferSize() / 2 + 1);
|
||||||
}
|
}
|
||||||
redraw |= success;
|
redraw |= success;
|
||||||
if(redraw)
|
if(redraw)
|
||||||
|
@ -468,6 +471,7 @@ void FrameBuffer::update(UpdateMode mode)
|
||||||
if(!success)
|
if(!success)
|
||||||
{
|
{
|
||||||
frames = 0;
|
frames = 0;
|
||||||
|
myOSystem.sound().mute(true);
|
||||||
myOSystem.eventHandler().enterMenuMode(EventHandlerState::TIMEMACHINE);
|
myOSystem.eventHandler().enterMenuMode(EventHandlerState::TIMEMACHINE);
|
||||||
}
|
}
|
||||||
break; // EventHandlerState::PLAYBACK
|
break; // EventHandlerState::PLAYBACK
|
||||||
|
|
Loading…
Reference in New Issue