From 5d7007c6448660b2bdbc7758db7f486157ff1fa2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 24 Feb 2014 21:59:20 +0100 Subject: client API: expose the internal clock May or may not be useful in some ways. We require a context parameter for this just to be sure, even if the internal implementation currently doesn't. That's one less mpv internal function for the Lua wrapper. --- player/client.c | 6 ++++++ player/lua.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'player') diff --git a/player/client.c b/player/client.c index 11fe86bdfc..eaf91c45a8 100644 --- a/player/client.c +++ b/player/client.c @@ -24,6 +24,7 @@ #include "options/m_option.h" #include "options/m_property.h" #include "osdep/threads.h" +#include "osdep/timer.h" #include "command.h" #include "core.h" @@ -992,3 +993,8 @@ void mpv_free(void *data) { talloc_free(data); } + +int64_t mpv_get_time_us(mpv_handle *ctx) +{ + return mp_time_us(); +} diff --git a/player/lua.c b/player/lua.c index dec5d22cab..edd01c0c73 100644 --- a/player/lua.c +++ b/player/lua.c @@ -722,7 +722,8 @@ static int script_get_mouse_pos(lua_State *L) static int script_get_time(lua_State *L) { - lua_pushnumber(L, mp_time_sec()); + struct script_ctx *ctx = get_ctx(L); + lua_pushnumber(L, mpv_get_time_us(ctx->client) / (double)(1000 * 1000)); return 1; } -- cgit v1.2.3