summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorNiklas Haas <git@nand.wakku.to>2016-06-06 02:44:15 +0200
committerwm4 <wm4@nowhere>2016-06-07 12:17:25 +0200
commit393a06911269b69ed83f1b29bd5e252c07ba59bf (patch)
treeba49b6ce002d4a9ef1946d04c8bfa5be4fb3755a /player/command.c
parent8ceb935bd8e1062ff83287c00cca0b7428a7dfba (diff)
downloadmpv-393a06911269b69ed83f1b29bd5e252c07ba59bf.tar.bz2
mpv-393a06911269b69ed83f1b29bd5e252c07ba59bf.tar.xz
vo_opengl: expose performance timers as properties
This is plumbed through a new VOCTRL, VOCTRL_PERFORMANCE_DATA, and exposed as properties render-time-last, render-time-avg etc. All of these numbers are in microseconds, which gives a good precision range when just outputting them via show-text. (Lua scripts can obviously still do their own formatting etc.) Signed-off-by: wm4 <wm4@nowhere>
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c
index 6a45222558..5a8af686fe 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2381,6 +2381,39 @@ static int panscan_property_helper(void *ctx, struct m_property *prop,
return r;
}
+// Properties retrieved through VOCTRL_PERFORMANCE_DATA
+static int perfdata_property_helper(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ if (!mpctx->video_out)
+ return M_PROPERTY_UNAVAILABLE;
+
+ struct voctrl_performance_data data = {0};
+ if (vo_control(mpctx->video_out, VOCTRL_PERFORMANCE_DATA, &data) <= 0)
+ return M_PROPERTY_UNAVAILABLE;
+
+ // Figure out the right field based on the name. This string
+ // match should never fail (based on the hard-coded property names)
+ struct bstr name = bstr0(prop->name), prefix, field;
+ bstr_split_tok(name, "-", &prefix, &name);
+ bstr_split_tok(name, "-", &name, &field);
+
+ // No need to have a failure case or fallthrough since these checks are all
+ // mutually exclusive and will never fail (based on the hard-coded names)
+ struct voctrl_performance_entry e = {0};
+ if (bstrcmp0(prefix, "upload") == 0) e = data.upload;
+ if (bstrcmp0(prefix, "render") == 0) e = data.render;
+ if (bstrcmp0(prefix, "present") == 0) e = data.present;
+
+ uint64_t val = 0;
+ if (bstrcmp0(field, "last") == 0) val = e.last;
+ if (bstrcmp0(field, "avg") == 0) val = e.avg;
+ if (bstrcmp0(field, "peak") == 0) val = e.peak;
+
+ return m_property_int64_ro(action, arg, val);
+}
+
/// Helper to set vo flags.
/** \ingroup PropertyImplHelper
*/
@@ -3785,6 +3818,16 @@ static const struct m_property mp_properties[] = {
{"estimated-frame-count", mp_property_frame_count},
{"estimated-frame-number", mp_property_frame_number},
+ {"upload-time-last", perfdata_property_helper},
+ {"upload-time-avg", perfdata_property_helper},
+ {"upload-time-peak", perfdata_property_helper},
+ {"render-time-last", perfdata_property_helper},
+ {"render-time-avg", perfdata_property_helper},
+ {"render-time-peak", perfdata_property_helper},
+ {"present-time-last", perfdata_property_helper},
+ {"present-time-avg", perfdata_property_helper},
+ {"present-time-peak", perfdata_property_helper},
+
{"osd-width", mp_property_osd_w},
{"osd-height", mp_property_osd_h},
{"osd-par", mp_property_osd_par},