MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ tick()

void MayaFlux::Vruta::FrameClock::tick ( uint64_t  forced_frames = 0)
overridevirtual

Advance clock by computing elapsed frames since last tick.

Self-driven advancement: Calculates how much time has passed since last tick and advances frame count accordingly.

This is fundamentally different from SampleClock::tick(samples) which receives the sample count from external audio callback.

Called from graphics thread loop. Thread-safe for single writer.

Parameters
forced_framesIf non-zero, advances by this many frames instead of calculating from elapsed time. Used for testing or special cases.

Implements MayaFlux::Vruta::IClock.

Definition at line 55 of file Clock.cpp.

56{
57 auto now = std::chrono::steady_clock::now();
58
59 uint64_t frames_to_advance = forced_frames > 0 ? forced_frames : calculate_elapsed_frames(now);
60
61 if (frames_to_advance > 0) {
62 m_current_frame.fetch_add(frames_to_advance, std::memory_order_release);
64 m_last_tick_time = now;
66 }
67}
std::chrono::steady_clock::time_point m_last_tick_time
Definition Clock.hpp:283
std::chrono::nanoseconds m_frame_duration
Definition Clock.hpp:276
std::chrono::steady_clock::time_point m_next_frame_time
Definition Clock.hpp:284
uint64_t calculate_elapsed_frames(std::chrono::steady_clock::time_point now) const
Calculate frames elapsed based on wall-clock time.
Definition Clock.cpp:165
std::atomic< uint64_t > m_current_frame
Definition Clock.hpp:279
void update_fps_measurement(std::chrono::steady_clock::time_point now)
Update measured FPS based on tick interval Called internally during tick()
Definition Clock.cpp:151

References calculate_elapsed_frames(), m_current_frame, m_frame_duration, m_last_tick_time, m_next_frame_time, and update_fps_measurement().

+ Here is the call graph for this function: