Use a callback to notify frame skip
A skipped frame is detected when the producer offers a frame while the current pending frame has not been consumed. However, the producer (in practice the decoder) is not interested in the fact that a frame has been skipped, only the consumer (the renderer) is. Therefore, notify frame skip via a consumer callback. This allows to manage the skipped and rendered frames count at the same place, and remove fps_counter from decoder.
This commit is contained in:
@@ -204,6 +204,14 @@ on_frame_available(struct video_buffer *vb, void *userdata) {
|
||||
SDL_PushEvent(&new_frame_event);
|
||||
}
|
||||
|
||||
static void
|
||||
on_frame_skipped(struct video_buffer *vb, void *userdata) {
|
||||
(void) vb;
|
||||
|
||||
struct screen *screen = userdata;
|
||||
fps_counter_add_skipped_frame(screen->fps_counter);
|
||||
}
|
||||
|
||||
void
|
||||
screen_init(struct screen *screen, struct video_buffer *vb,
|
||||
struct fps_counter *fps_counter) {
|
||||
@@ -213,9 +221,10 @@ screen_init(struct screen *screen, struct video_buffer *vb,
|
||||
|
||||
static const struct video_buffer_callbacks cbs = {
|
||||
.on_frame_available = on_frame_available,
|
||||
.on_frame_skipped = on_frame_skipped,
|
||||
};
|
||||
|
||||
video_buffer_set_consumer_callbacks(vb, &cbs, NULL);
|
||||
video_buffer_set_consumer_callbacks(vb, &cbs, screen);
|
||||
}
|
||||
|
||||
static inline SDL_Texture *
|
||||
|
||||
Reference in New Issue
Block a user