Make SKIP_FRAMES a compilation flag

The skip_frames flag was a non-configurable runtime flag. Since it is
not exposed to the user, there is no need for a (possible) runtime cost.

For testing purpose, we still want it to be configurable, so make it a
compilation flag.
This commit is contained in:
Romain Vimont
2018-02-07 12:25:52 +01:00
parent 53ff1aa410
commit 8d30d40b79
6 changed files with 30 additions and 13 deletions

View File

@@ -6,6 +6,7 @@
#include <SDL2/SDL_thread.h>
#include <unistd.h>
#include "config.h"
#include "events.h"
#include "frames.h"
#include "lockutil.h"
@@ -22,13 +23,17 @@ static int read_packet(void *opaque, uint8_t *buf, int buf_size) {
static void push_frame(struct decoder *decoder) {
struct frames *frames = decoder->frames;
mutex_lock(frames->mutex);
if (!decoder->skip_frames) {
while (!frames->rendering_frame_consumed) {
cond_wait(frames->rendering_frame_consumed_cond, frames->mutex);
}
} else if (!frames->rendering_frame_consumed) {
#ifndef SKIP_FRAMES
// if SKIP_FRAMES is disabled, then the decoder must wait for the current
// frame to be consumed
while (!frames->rendering_frame_consumed) {
cond_wait(frames->rendering_frame_consumed_cond, frames->mutex);
}
#else
if (!frames->rendering_frame_consumed) {
SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, "Skip frame");
}
#endif
frames_swap(frames);
frames->rendering_frame_consumed = SDL_FALSE;