mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-15 12:20:01 +01:00
Fixed FPS stable computation
This commit is contained in:
@@ -109,8 +109,7 @@ static void saveSession(const std::string& filename, Session *session)
|
|||||||
session->unlock();
|
session->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
Mixer::Mixer() : session_(nullptr), back_session_(nullptr), current_view_(nullptr),
|
Mixer::Mixer() : session_(nullptr), back_session_(nullptr), current_view_(nullptr), dt_(0.f), dt__(0.f)
|
||||||
/*update_time_(GST_CLOCK_TIME_NONE),*/ dt_(0.f), fps_(59.f)
|
|
||||||
{
|
{
|
||||||
// unsused initial empty session
|
// unsused initial empty session
|
||||||
session_ = new Session;
|
session_ = new Session;
|
||||||
@@ -203,9 +202,8 @@ void Mixer::update()
|
|||||||
dt_ = g_timer_elapsed (timer, NULL) * 1000.0;
|
dt_ = g_timer_elapsed (timer, NULL) * 1000.0;
|
||||||
g_timer_start(timer);
|
g_timer_start(timer);
|
||||||
|
|
||||||
// compute fps
|
// compute stabilized dt__
|
||||||
if (dt_ > 1.f)
|
dt__ = 0.05f * dt_ + 0.95f * dt__;
|
||||||
fps_ = 1.f / (dt_+1.f) + 0.999f * fps_;
|
|
||||||
|
|
||||||
// update session and associated sources
|
// update session and associated sources
|
||||||
session_->update(dt_);
|
session_->update(dt_);
|
||||||
|
|||||||
4
Mixer.h
4
Mixer.h
@@ -33,7 +33,7 @@ public:
|
|||||||
// update session and all views
|
// update session and all views
|
||||||
void update();
|
void update();
|
||||||
inline float dt() const { return dt_;}
|
inline float dt() const { return dt_;}
|
||||||
inline float fps() const { return fps_;}
|
inline int fps() const { return int(roundf(1000.f/dt__));}
|
||||||
|
|
||||||
// draw session and current view
|
// draw session and current view
|
||||||
void draw();
|
void draw();
|
||||||
@@ -129,7 +129,7 @@ protected:
|
|||||||
TransitionView transition_;
|
TransitionView transition_;
|
||||||
|
|
||||||
float dt_;
|
float dt_;
|
||||||
float fps_;
|
float dt__;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MIXER_H
|
#endif // MIXER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user