command: avoid returning invalid FPS values

It's possible that fps is sometimes 0 in case it's unset.
This commit is contained in:
wm4 2014-11-29 00:34:53 +01:00
parent a937ba203d
commit 87f5ba6ab3
1 changed files with 5 additions and 3 deletions

View File

@ -23,6 +23,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <assert.h> #include <assert.h>
#include <time.h> #include <time.h>
#include <math.h>
#include <pthread.h> #include <pthread.h>
#include <sys/types.h> #include <sys/types.h>
@ -2535,9 +2536,10 @@ static int mp_property_fps(void *ctx, struct m_property *prop,
int action, void *arg) int action, void *arg)
{ {
MPContext *mpctx = ctx; MPContext *mpctx = ctx;
if (!mpctx->d_video) float fps = mpctx->d_video ? mpctx->d_video->fps : 0;
return M_PROPERTY_UNAVAILABLE; if (fps < 0.1 || !isfinite(fps))
return m_property_float_ro(action, arg, mpctx->d_video->fps); return M_PROPERTY_UNAVAILABLE;;
return m_property_float_ro(action, arg, fps);
} }
static int mp_property_vf_fps(void *ctx, struct m_property *prop, static int mp_property_vf_fps(void *ctx, struct m_property *prop,