Skip to content

Commit

Permalink
libmpv: add mpv_time_ns()
Browse files Browse the repository at this point in the history
9606c3f added mp_time_ns(). Since we
apparently expose the mp_time_us() to clients already, there's no reason
to not also expose the new nanosecond one.
  • Loading branch information
Dudemanguy committed Sep 29, 2023
1 parent f09acbc commit 9ada013
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions DOCS/client-api-changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ API changes

::

--- mpv 0.37.0 ---
2.2 - add mpv_time_ns()
--- mpv 0.36.0 ---
2.1 - add mpv_del_property()
--- mpv 0.35.0 ---
Expand Down
11 changes: 9 additions & 2 deletions libmpv/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ extern "C" {
* relational operators (<, >, <=, >=).
*/
#define MPV_MAKE_VERSION(major, minor) (((major) << 16) | (minor) | 0UL)
#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(2, 1)
#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(2, 2)

/**
* The API user is allowed to "#define MPV_ENABLE_DEPRECATED 0" before
Expand Down Expand Up @@ -602,7 +602,7 @@ MPV_EXPORT mpv_handle *mpv_create_weak_client(mpv_handle *ctx, const char *name)
MPV_EXPORT int mpv_load_config_file(mpv_handle *ctx, const char *filename);

/**
* Return the internal time in microseconds. This has an arbitrary start offset,
* Return the internal time in nanoseconds. This has an arbitrary start offset,
* but will never wrap or go backwards.
*
* Note that this is always the real time, and doesn't necessarily have to do
Expand All @@ -615,6 +615,11 @@ MPV_EXPORT int mpv_load_config_file(mpv_handle *ctx, const char *filename);
*
* Safe to be called from mpv render API threads.
*/
MPV_EXPORT int64_t mpv_get_time_ns(mpv_handle *ctx);

/**
* Same as mpv_get_time_ns but in microseconds.
*/
MPV_EXPORT int64_t mpv_get_time_us(mpv_handle *ctx);

/**
Expand Down Expand Up @@ -1951,6 +1956,8 @@ MPV_DEFINE_SYM_PTR(mpv_create_weak_client)
#define mpv_create_weak_client pfn_mpv_create_weak_client
MPV_DEFINE_SYM_PTR(mpv_load_config_file)
#define mpv_load_config_file pfn_mpv_load_config_file
MPV_DEFINE_SYM_PTR(mpv_get_time_ns)
#define mpv_get_time_ns pfn_mpv_get_time_ns
MPV_DEFINE_SYM_PTR(mpv_get_time_us)
#define mpv_get_time_us pfn_mpv_get_time_us
MPV_DEFINE_SYM_PTR(mpv_free_node_contents)
Expand Down
5 changes: 5 additions & 0 deletions player/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -2129,6 +2129,11 @@ void mpv_free(void *data)
talloc_free(data);
}

int64_t mpv_get_time_ns(mpv_handle *ctx)
{
return mp_time_ns();
}

int64_t mpv_get_time_us(mpv_handle *ctx)
{
return mp_time_us();
Expand Down

0 comments on commit 9ada013

Please sign in to comment.